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) } } #endif /* RDA55802 */ +#if (CONFIG_TUNER & STFM1000) + IF_TUNER_TYPE(STFM1000) + { + struct stfm1000_dbg_info nfo; + stfm1000_dbg_info(&nfo); + simplelist_addline(SIMPLELIST_ADD_LINE, "STFM1000 regs:"); + simplelist_addline(SIMPLELIST_ADD_LINE,"chipid: 0x%x", nfo.chipid); + } +#endif /* STFM1000 */ #ifdef HAVE_RDS_CAP 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 #ifdef CREATIVE_ZENXFI3 drivers/mpr121.c +target/arm/imx233/creative-zenxfi3/fmradio-i2c-zenxfi3.c target/arm/imx233/creative-zenxfi3/backlight-zenxfi3.c target/arm/imx233/creative-zenxfi3/lcd-zenxfi3.c target/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 @@ #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; +} + +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); +} + +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) { } 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 @@ #define HAVE_RADIO_REGION #define HAVE_RADIO_RSSI +struct stfm1000_dbg_info +{ + uint32_t chipid; +}; + bool stfm1000_detect(void); void stfm1000_init(void); int stfm1000_set(int setting, int value); int stfm1000_get(int setting); +void stfm1000_dbg_info(struct stfm1000_dbg_info *nfo); #ifndef CONFIG_TUNER_MULTI #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 @@ +/*************************************************************************** + * __________ __ ___. + * 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 "fmradio_i2c.h" +#include "pinctrl-imx233.h" +#include "i2c.h" + +void fmradio_i2c_init(void) +{ +} + +int fmradio_i2c_write(unsigned char address, const unsigned char* buf, int count) +{ + return i2c_write(address, buf, count); +} + +int fmradio_i2c_read(unsigned char address, unsigned char* buf, int count) +{ + return i2c_read(address, buf, count); +} 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) imx233_pwm_init(); imx233_lradc_init(); imx233_i2c_init(); -#if defined(SANSA_FUZEPLUS) && !defined(BOOTLOADER) +#if !defined(BOOTLOADER) && \ + (defined(SANSA_FUZEPLUS) || defined(CREATIVE_ZENXFI3)) fmradio_i2c_init(); #endif }