summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2012-05-19 18:03:27 +0200
committerAmaury Pouly <amaury.pouly@gmail.com>2012-05-19 18:04:25 +0200
commite4016834822e3211ff0693691c456f3d620cad0a (patch)
treef6e5bd8a60828f3a91fdd69a2964b6b290353b8a
parent4f5efac9e5ae326f666d30a8b93cab5a7c18eb4e (diff)
downloadrockbox-e4016834822e3211ff0693691c456f3d620cad0a.tar.gz
rockbox-e4016834822e3211ff0693691c456f3d620cad0a.zip
zenxfi3&stfm1000: implement fmradio i2c and debug screen
Change-Id: I83dbdee13185d9adcf590dc213da5a8c97adb2ba
-rw-r--r--apps/debug_menu.c9
-rw-r--r--firmware/SOURCES1
-rw-r--r--firmware/drivers/tuner/stfm1000.c30
-rw-r--r--firmware/export/stfm1000.h6
-rw-r--r--firmware/target/arm/imx233/creative-zenxfi3/fmradio-i2c-zenxfi3.c40
-rw-r--r--firmware/target/arm/imx233/system-imx233.c3
6 files changed, 88 insertions, 1 deletions
diff --git a/apps/debug_menu.c b/apps/debug_menu.c
index 2762c4b79b..e611694b5b 100644
--- a/apps/debug_menu.c
+++ b/apps/debug_menu.c
@@ -1867,6 +1867,15 @@ static int radio_callback(int btn, struct gui_synclist *lists)
1867 } 1867 }
1868 } 1868 }
1869#endif /* RDA55802 */ 1869#endif /* RDA55802 */
1870#if (CONFIG_TUNER & STFM1000)
1871 IF_TUNER_TYPE(STFM1000)
1872 {
1873 struct stfm1000_dbg_info nfo;
1874 stfm1000_dbg_info(&nfo);
1875 simplelist_addline(SIMPLELIST_ADD_LINE, "STFM1000 regs:");
1876 simplelist_addline(SIMPLELIST_ADD_LINE,"chipid: 0x%x", nfo.chipid);
1877 }
1878#endif /* STFM1000 */
1870 1879
1871#ifdef HAVE_RDS_CAP 1880#ifdef HAVE_RDS_CAP
1872 simplelist_addline(SIMPLELIST_ADD_LINE, "PI:%04X PS:'%8s'", 1881 simplelist_addline(SIMPLELIST_ADD_LINE, "PI:%04X PS:'%8s'",
diff --git a/firmware/SOURCES b/firmware/SOURCES
index f6d7c2b69f..5cb464e6b1 100644
--- a/firmware/SOURCES
+++ b/firmware/SOURCES
@@ -1146,6 +1146,7 @@ target/arm/imx233/creative-zenxfi2/audio-zenxfi2.c
1146 1146
1147#ifdef CREATIVE_ZENXFI3 1147#ifdef CREATIVE_ZENXFI3
1148drivers/mpr121.c 1148drivers/mpr121.c
1149target/arm/imx233/creative-zenxfi3/fmradio-i2c-zenxfi3.c
1149target/arm/imx233/creative-zenxfi3/backlight-zenxfi3.c 1150target/arm/imx233/creative-zenxfi3/backlight-zenxfi3.c
1150target/arm/imx233/creative-zenxfi3/lcd-zenxfi3.c 1151target/arm/imx233/creative-zenxfi3/lcd-zenxfi3.c
1151target/arm/imx233/creative-zenxfi3/button-zenxfi3.c 1152target/arm/imx233/creative-zenxfi3/button-zenxfi3.c
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
38static 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
49static 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
58void 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
34void stfm1000_init(void) 64void stfm1000_init(void)
35{ 65{
36} 66}
diff --git a/firmware/export/stfm1000.h b/firmware/export/stfm1000.h
index 2143a81ad4..6c01d6308e 100644
--- a/firmware/export/stfm1000.h
+++ b/firmware/export/stfm1000.h
@@ -29,10 +29,16 @@
29#define HAVE_RADIO_REGION 29#define HAVE_RADIO_REGION
30#define HAVE_RADIO_RSSI 30#define HAVE_RADIO_RSSI
31 31
32struct stfm1000_dbg_info
33{
34 uint32_t chipid;
35};
36
32bool stfm1000_detect(void); 37bool stfm1000_detect(void);
33void stfm1000_init(void); 38void stfm1000_init(void);
34int stfm1000_set(int setting, int value); 39int stfm1000_set(int setting, int value);
35int stfm1000_get(int setting); 40int stfm1000_get(int setting);
41void stfm1000_dbg_info(struct stfm1000_dbg_info *nfo);
36 42
37#ifndef CONFIG_TUNER_MULTI 43#ifndef CONFIG_TUNER_MULTI
38#define tuner_set stfm1000_set 44#define tuner_set stfm1000_set
diff --git a/firmware/target/arm/imx233/creative-zenxfi3/fmradio-i2c-zenxfi3.c b/firmware/target/arm/imx233/creative-zenxfi3/fmradio-i2c-zenxfi3.c
new file mode 100644
index 0000000000..58ac8e6a08
--- /dev/null
+++ b/firmware/target/arm/imx233/creative-zenxfi3/fmradio-i2c-zenxfi3.c
@@ -0,0 +1,40 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2012 by Amaury Pouly
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#include "config.h"
23#include "system.h"
24#include "fmradio_i2c.h"
25#include "pinctrl-imx233.h"
26#include "i2c.h"
27
28void fmradio_i2c_init(void)
29{
30}
31
32int fmradio_i2c_write(unsigned char address, const unsigned char* buf, int count)
33{
34 return i2c_write(address, buf, count);
35}
36
37int fmradio_i2c_read(unsigned char address, unsigned char* buf, int count)
38{
39 return i2c_read(address, buf, count);
40}
diff --git a/firmware/target/arm/imx233/system-imx233.c b/firmware/target/arm/imx233/system-imx233.c
index 5ef52c7957..a24927f9a5 100644
--- a/firmware/target/arm/imx233/system-imx233.c
+++ b/firmware/target/arm/imx233/system-imx233.c
@@ -110,7 +110,8 @@ void system_init(void)
110 imx233_pwm_init(); 110 imx233_pwm_init();
111 imx233_lradc_init(); 111 imx233_lradc_init();
112 imx233_i2c_init(); 112 imx233_i2c_init();
113#if defined(SANSA_FUZEPLUS) && !defined(BOOTLOADER) 113#if !defined(BOOTLOADER) && \
114 (defined(SANSA_FUZEPLUS) || defined(CREATIVE_ZENXFI3))
114 fmradio_i2c_init(); 115 fmradio_i2c_init();
115#endif 116#endif
116} 117}