diff options
Diffstat (limited to 'firmware/drivers/tuner/stfm1000.c')
-rw-r--r-- | firmware/drivers/tuner/stfm1000.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/firmware/drivers/tuner/stfm1000.c b/firmware/drivers/tuner/stfm1000.c index ae96993285..8626d4e2a5 100644 --- a/firmware/drivers/tuner/stfm1000.c +++ b/firmware/drivers/tuner/stfm1000.c | |||
@@ -31,6 +31,36 @@ | |||
31 | #include "fmradio_i2c.h" /* physical interface driver */ | 31 | #include "fmradio_i2c.h" /* physical interface driver */ |
32 | #include "stfm1000.h" | 32 | #include "stfm1000.h" |
33 | 33 | ||
34 | #define STFM100_I2C_ADDR 0xc0 | ||
35 | |||
36 | #define CHIPID 0x80 | ||
37 | |||
38 | static int stfm1000_read_reg(uint8_t reg, uint32_t *val) | ||
39 | { | ||
40 | uint8_t buf[4]; | ||
41 | buf[0] = reg; | ||
42 | int ret = fmradio_i2c_write(STFM100_I2C_ADDR, buf, 1); | ||
43 | if(ret < 0) return ret; | ||
44 | ret = fmradio_i2c_read(STFM100_I2C_ADDR, buf, 4); | ||
45 | *val = buf[0] | buf[1] << 8 | buf[2] << 16 | buf[3] << 24; | ||
46 | return ret; | ||
47 | } | ||
48 | |||
49 | static int stfm1000_write_reg(uint8_t reg, uint32_t val) | ||
50 | { | ||
51 | uint8_t buf[5]; | ||
52 | buf[0] = reg; | ||
53 | buf[1] = val & 0xff; buf[2] = (val >> 8) & 0xff; | ||
54 | buf[3] = (val >> 16) & 0xff; buf[4] = (val >> 24) & 0xff; | ||
55 | return fmradio_i2c_write(STFM100_I2C_ADDR, buf, 5); | ||
56 | } | ||
57 | |||
58 | void stfm1000_dbg_info(struct stfm1000_dbg_info *nfo) | ||
59 | { | ||
60 | memset(nfo, 0, sizeof(struct stfm1000_dbg_info)); | ||
61 | stfm1000_read_reg(CHIPID, &nfo->chipid); | ||
62 | } | ||
63 | |||
34 | void stfm1000_init(void) | 64 | void stfm1000_init(void) |
35 | { | 65 | { |
36 | } | 66 | } |