1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2012 by Amaury Pouly
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
#include "config.h"
#include "system.h"
#include <string.h>
#include "kernel.h"
#include "power.h"
#include "tuner.h" /* tuner abstraction interface */
#include "fmradio.h"
#include "fmradio_i2c.h" /* physical interface driver */
#include "stfm1000.h"
#define STFM100_I2C_ADDR 0xc0
#define CHIPID 0x80
static int stfm1000_read_reg(uint8_t reg, uint32_t *val)
{
uint8_t buf[4];
buf[0] = reg;
int ret = fmradio_i2c_write(STFM100_I2C_ADDR, buf, 1);
if(ret < 0) return ret;
ret = fmradio_i2c_read(STFM100_I2C_ADDR, buf, 4);
*val = buf[0] | buf[1] << 8 | buf[2] << 16 | buf[3] << 24;
return ret;
}
#if 0
static int stfm1000_write_reg(uint8_t reg, uint32_t val)
{
uint8_t buf[5];
buf[0] = reg;
buf[1] = val & 0xff; buf[2] = (val >> 8) & 0xff;
buf[3] = (val >> 16) & 0xff; buf[4] = (val >> 24) & 0xff;
return fmradio_i2c_write(STFM100_I2C_ADDR, buf, 5);
}
#endif
void stfm1000_dbg_info(struct stfm1000_dbg_info *nfo)
{
memset(nfo, 0, sizeof(struct stfm1000_dbg_info));
stfm1000_read_reg(CHIPID, &nfo->chipid);
}
void stfm1000_init(void)
{
}
int stfm1000_set(int setting, int value)
{
(void) setting;
(void) value;
return -1;
}
int stfm1000_get(int setting)
{
(void) setting;
return -1;
}
|