summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--firmware/SOURCES13
-rw-r--r--firmware/target/arm/imx233/creative-zen/fmradio-target.h (renamed from firmware/target/arm/imx233/sony-nwz/power-nwz.c)32
-rw-r--r--firmware/target/arm/imx233/creative-zen/power-zen.c38
-rw-r--r--firmware/target/arm/imx233/creative-zenxfi2/fmradio-i2c-zenxfi2.c40
-rw-r--r--firmware/target/arm/imx233/creative-zenxfi2/fmradio-target.h (renamed from firmware/target/arm/imx233/creative-zenxfi3/power-zenxfi3.c)26
-rw-r--r--firmware/target/arm/imx233/creative-zenxfi3/fmradio-i2c-zenxfi3.c40
-rw-r--r--firmware/target/arm/imx233/creative-zenxfi3/fmradio-target.h (renamed from firmware/target/arm/imx233/creative-zenxfi2/power-zenxfi2.c)26
-rw-r--r--firmware/target/arm/imx233/fmradio-imx233.c162
-rw-r--r--firmware/target/arm/imx233/fmradio-imx233.h64
-rw-r--r--firmware/target/arm/imx233/sansa-fuzeplus/fmradio-i2c-fuzeplus.c76
-rw-r--r--firmware/target/arm/imx233/sansa-fuzeplus/fmradio-target.h (renamed from firmware/target/arm/imx233/creative-zen/fmradio-i2c-zen.c)29
-rw-r--r--firmware/target/arm/imx233/sansa-fuzeplus/power-fuzeplus.c53
-rw-r--r--firmware/target/arm/imx233/sony-nwz/fmradio-target.h (renamed from firmware/target/arm/imx233/sony-nwz/fmradio-i2c-nwz.c)22
13 files changed, 274 insertions, 347 deletions
diff --git a/firmware/SOURCES b/firmware/SOURCES
index 5cdc37976a..8429b7e85b 100644
--- a/firmware/SOURCES
+++ b/firmware/SOURCES
@@ -1165,7 +1165,7 @@ target/arm/tms320dm320/creative-zvm/usb-creativezvm.c
#if defined(CREATIVE_ZEN) || defined(CREATIVE_ZENXFI) || defined(CREATIVE_ZENMOZAIC) \
|| defined(CREATIVE_ZENV)
-target/arm/imx233/creative-zen/fmradio-i2c-zen.c
+target/arm/imx233/fmradio-imx233.c
target/arm/imx233/creative-zen/backlight-zen.c
# if defined(CREATIVE_ZEN) || defined(CREATIVE_ZENXFI)
target/arm/imx233/creative-zen/lcd-zen.c
@@ -1182,33 +1182,30 @@ target/arm/imx233/button-lradc-imx233.c
#endif
#ifdef CREATIVE_ZENXFI2
-target/arm/imx233/creative-zenxfi2/fmradio-i2c-zenxfi2.c
+target/arm/imx233/fmradio-imx233.c
target/arm/imx233/creative-zenxfi2/backlight-zenxfi2.c
target/arm/imx233/creative-zenxfi2/lcd-zenxfi2.c
target/arm/imx233/creative-zenxfi2/button-zenxfi2.c
target/arm/imx233/creative-zenxfi2/debug-zenxfi2.c
-target/arm/imx233/creative-zenxfi2/power-zenxfi2.c
target/arm/imx233/creative-zenxfi2/powermgmt-zenxfi2.c
#endif
#ifdef CREATIVE_ZENXFI3
drivers/mpr121.c
-target/arm/imx233/creative-zenxfi3/fmradio-i2c-zenxfi3.c
+target/arm/imx233/fmradio-imx233.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
target/arm/imx233/creative-zenxfi3/debug-zenxfi3.c
-target/arm/imx233/creative-zenxfi3/power-zenxfi3.c
target/arm/imx233/creative-zenxfi3/powermgmt-zenxfi3.c
#endif
#if defined(SONY_NWZE360) || defined(SONY_NWZE370)
target/arm/imx233/button-lradc-imx233.c
-target/arm/imx233/sony-nwz/fmradio-i2c-nwz.c
+target/arm/imx233/fmradio-imx233.c
target/arm/imx233/sony-nwz/backlight-nwz.c
target/arm/imx233/sony-nwz/button-nwz.c
target/arm/imx233/sony-nwz/debug-nwz.c
-target/arm/imx233/sony-nwz/power-nwz.c
# if defined(SONY_NWZE360)
target/arm/imx233/sony-nwz/lcd-nwze360.c
target/arm/imx233/sony-nwz/powermgmt-nwze360.c
@@ -1427,12 +1424,12 @@ target/arm/as3525/lcd-as-e200v2-fuze-fuzev2.S
#ifdef SANSA_FUZEPLUS
drivers/synaptics-rmi.c
drivers/generic_i2c.c
+target/arm/imx233/fmradio-imx233.c
target/arm/imx233/sansa-fuzeplus/fmradio-i2c-fuzeplus.c
target/arm/imx233/sansa-fuzeplus/backlight-fuzeplus.c
target/arm/imx233/sansa-fuzeplus/lcd-fuzeplus.c
target/arm/imx233/sansa-fuzeplus/button-fuzeplus.c
target/arm/imx233/sansa-fuzeplus/debug-fuzeplus.c
-target/arm/imx233/sansa-fuzeplus/power-fuzeplus.c
target/arm/imx233/sansa-fuzeplus/powermgmt-fuzeplus.c
#endif
diff --git a/firmware/target/arm/imx233/sony-nwz/power-nwz.c b/firmware/target/arm/imx233/creative-zen/fmradio-target.h
index 88644919ad..c2b75b3ed4 100644
--- a/firmware/target/arm/imx233/sony-nwz/power-nwz.c
+++ b/firmware/target/arm/imx233/creative-zen/fmradio-target.h
@@ -18,25 +18,19 @@
* KIND, either express or implied.
*
****************************************************************************/
+#ifndef _FMRADIO_TARGET_H_
+#define _FMRADIO_TARGET_H_
-#include "system.h"
-#include "power.h"
-#include "tuner.h"
-#include "fmradio_i2c.h"
-#include "pinctrl-imx233.h"
+#define IMX233_FMRADIO_I2C FMI_HW
-static bool tuner_enable = false;
+#ifdef CREATIVE_ZENMOZAIC
+#define IMX233_FMRADIO_POWER FMP_GPIO
+#define FMP_GPIO_BANK 2
+#define FMP_GPIO_PIN 15
+#define FMP_GPIO_DELAY (HZ / 5)
+#else
+#define IMX233_FMRADIO_POWER FMP_NONE
+#endif
-bool tuner_power(bool enable)
-{
- if(enable != tuner_enable)
- {
- tuner_enable = enable;
- }
- return tuner_enable;
-}
-
-bool tuner_powered(void)
-{
- return tuner_enable;
-}
+#endif /* _FMRADIO_TARGET_H_ */
+ \ No newline at end of file
diff --git a/firmware/target/arm/imx233/creative-zen/power-zen.c b/firmware/target/arm/imx233/creative-zen/power-zen.c
index c1ad5989c0..15da6ab201 100644
--- a/firmware/target/arm/imx233/creative-zen/power-zen.c
+++ b/firmware/target/arm/imx233/creative-zen/power-zen.c
@@ -21,44 +21,6 @@
#include "system.h"
#include "power.h"
-#include "tuner.h"
-#include "fmradio_i2c.h"
-#include "pinctrl-imx233.h"
-#include "power-imx233.h"
-
-static bool tuner_enable = false;
-static bool initialised = false;
-
-static void init(void)
-{
-#ifdef CREATIVE_ZENMOZAIC
- /* CE is B2P15 (active high) */
- imx233_pinctrl_acquire(2, 15, "tuner power");
- imx233_pinctrl_set_function(2, 15, PINCTRL_FUNCTION_GPIO);
- imx233_pinctrl_enable_gpio(2, 15, true);
-#endif
- initialised = true;
-}
-
-bool tuner_power(bool enable)
-{
- if(!initialised)
- init();
- if(tuner_enable != enable)
- {
-#ifdef CREATIVE_ZENMOZAIC
- imx233_pinctrl_set_gpio(2, 15, enable);
- sleep(HZ / 5);
-#endif
- tuner_enable = enable;
- }
- return tuner_enable;
-}
-
-bool tuner_powered(void)
-{
- return tuner_enable;
-}
void ide_power_enable(bool on)
{
diff --git a/firmware/target/arm/imx233/creative-zenxfi2/fmradio-i2c-zenxfi2.c b/firmware/target/arm/imx233/creative-zenxfi2/fmradio-i2c-zenxfi2.c
deleted file mode 100644
index 58ac8e6a08..0000000000
--- a/firmware/target/arm/imx233/creative-zenxfi2/fmradio-i2c-zenxfi2.c
+++ /dev/null
@@ -1,40 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * 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/creative-zenxfi3/power-zenxfi3.c b/firmware/target/arm/imx233/creative-zenxfi2/fmradio-target.h
index 26f2159cec..e6869dc2a5 100644
--- a/firmware/target/arm/imx233/creative-zenxfi3/power-zenxfi3.c
+++ b/firmware/target/arm/imx233/creative-zenxfi2/fmradio-target.h
@@ -7,7 +7,7 @@
* \/ \/ \/ \/ \/
* $Id$
*
- * Copyright (C) 2012 by Amaury Pouly
+ * Copyright (C) 2013 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
@@ -18,25 +18,11 @@
* KIND, either express or implied.
*
****************************************************************************/
+#ifndef _FMRADIO_TARGET_H_
+#define _FMRADIO_TARGET_H_
-#include "system.h"
-#include "power.h"
-#include "tuner.h"
-#include "fmradio_i2c.h"
-#include "pinctrl-imx233.h"
+#define IMX233_FMRADIO_I2C FMI_HW
-static bool tuner_enable = false;
+#define IMX233_FMRADIO_POWER FMP_NONE
-bool tuner_power(bool enable)
-{
- if(enable != tuner_enable)
- {
- tuner_enable = enable;
- }
- return tuner_enable;
-}
-
-bool tuner_powered(void)
-{
- return tuner_enable;
-}
+#endif /* _FMRADIO_TARGET_H_ */
diff --git a/firmware/target/arm/imx233/creative-zenxfi3/fmradio-i2c-zenxfi3.c b/firmware/target/arm/imx233/creative-zenxfi3/fmradio-i2c-zenxfi3.c
deleted file mode 100644
index 58ac8e6a08..0000000000
--- a/firmware/target/arm/imx233/creative-zenxfi3/fmradio-i2c-zenxfi3.c
+++ /dev/null
@@ -1,40 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * 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/creative-zenxfi2/power-zenxfi2.c b/firmware/target/arm/imx233/creative-zenxfi3/fmradio-target.h
index 180b7f9d4c..e6869dc2a5 100644
--- a/firmware/target/arm/imx233/creative-zenxfi2/power-zenxfi2.c
+++ b/firmware/target/arm/imx233/creative-zenxfi3/fmradio-target.h
@@ -7,7 +7,7 @@
* \/ \/ \/ \/ \/
* $Id$
*
- * Copyright (C) 2011 by Amaury Pouly
+ * Copyright (C) 2013 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
@@ -18,25 +18,11 @@
* KIND, either express or implied.
*
****************************************************************************/
+#ifndef _FMRADIO_TARGET_H_
+#define _FMRADIO_TARGET_H_
-#include "system.h"
-#include "power.h"
-#include "tuner.h"
-#include "fmradio_i2c.h"
-#include "pinctrl-imx233.h"
+#define IMX233_FMRADIO_I2C FMI_HW
-static bool tuner_enable = false;
+#define IMX233_FMRADIO_POWER FMP_NONE
-bool tuner_power(bool enable)
-{
- if(enable != tuner_enable)
- {
- tuner_enable = enable;
- }
- return tuner_enable;
-}
-
-bool tuner_powered(void)
-{
- return tuner_enable;
-}
+#endif /* _FMRADIO_TARGET_H_ */
diff --git a/firmware/target/arm/imx233/fmradio-imx233.c b/firmware/target/arm/imx233/fmradio-imx233.c
new file mode 100644
index 0000000000..28ac4a4893
--- /dev/null
+++ b/firmware/target/arm/imx233/fmradio-imx233.c
@@ -0,0 +1,162 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2013 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 "fmradio-imx233.h"
+#include "fmradio-target.h"
+#include "pinctrl-imx233.h"
+#include "i2c.h"
+#include "generic_i2c.h"
+
+#ifndef IMX233_FMRADIO_I2C
+#error You must define IMX233_FMRADIO_I2C in fmradio-target.h
+#endif
+
+#ifndef IMX233_FMRADIO_POWER
+#error You must define IMX233_FMRADIO_POWER in fmradio-target.h
+#endif
+
+/** Hardware I2C */
+#if IMX233_FMRADIO_I2C == FMI_HW
+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);
+}
+/** Software I2C */
+#elif IMX233_FMRADIO_I2C == FMI_SW
+#if !defined(FMI_SW_SDA_BANK) || !defined(FMI_SW_SDA_PIN) || \
+ !defined(FMI_SW_SCL_BANK) || !defined(FMI_SW_SCL_PIN)
+#error You must define FMI_SW_SDA_BANK, FMI_SW_SDA_PIN, FMI_SW_SCL_BANK and FMI_SW_SCL_PIN
+#endif
+static int fmradio_i2c_bus = -1;
+
+static void i2c_scl_dir(bool out)
+{
+ imx233_pinctrl_enable_gpio(FMI_SW_SCL_BANK, FMI_SW_SCL_PIN, out);
+}
+
+static void i2c_sda_dir(bool out)
+{
+ imx233_pinctrl_enable_gpio(FMI_SW_SDA_BANK, FMI_SW_SDA_PIN, out);
+}
+
+static void i2c_scl_out(bool high)
+{
+ imx233_pinctrl_set_gpio(FMI_SW_SCL_BANK, FMI_SW_SCL_PIN, high);
+}
+
+static void i2c_sda_out(bool high)
+{
+ imx233_pinctrl_set_gpio(FMI_SW_SDA_BANK, FMI_SW_SDA_PIN, high);
+}
+
+static bool i2c_scl_in(void)
+{
+ return imx233_pinctrl_get_gpio(FMI_SW_SCL_BANK, FMI_SW_SCL_PIN);
+}
+
+static bool i2c_sda_in(void)
+{
+ return imx233_pinctrl_get_gpio(FMI_SW_SDA_BANK, FMI_SW_SDA_PIN);
+}
+
+static void i2c_delay(int d)
+{
+ udelay(d);
+}
+
+struct i2c_interface fmradio_i2c =
+{
+ .scl_dir = i2c_scl_dir,
+ .sda_dir = i2c_sda_dir,
+ .scl_out = i2c_scl_out,
+ .sda_out = i2c_sda_out,
+ .scl_in = i2c_scl_in,
+ .sda_in = i2c_sda_in,
+ .delay = i2c_delay,
+ .delay_hd_sta = 4,
+ .delay_hd_dat = 5,
+ .delay_su_dat = 1,
+ .delay_su_sto = 4,
+ .delay_su_sta = 5,
+ .delay_thigh = 4
+};
+
+void fmradio_i2c_init(void)
+{
+ imx233_pinctrl_acquire(FMI_SW_SDA_BANK, FMI_SW_SDA_PIN, "fmradio_i2c_sda");
+ imx233_pinctrl_acquire(FMI_SW_SCL_BANK, FMI_SW_SCL_BANK, "fmradio_i2c_scl");
+ imx233_pinctrl_set_function(FMI_SW_SDA_BANK, FMI_SW_SDA_PIN, PINCTRL_FUNCTION_GPIO);
+ imx233_pinctrl_set_function(FMI_SW_SCL_BANK, FMI_SW_SCL_BANK, PINCTRL_FUNCTION_GPIO);
+ fmradio_i2c_bus = i2c_add_node(&fmradio_i2c);
+}
+
+int fmradio_i2c_write(unsigned char address, const unsigned char* buf, int count)
+{
+ return i2c_write_data(fmradio_i2c_bus, address, -1, buf, count);
+}
+
+int fmradio_i2c_read(unsigned char address, unsigned char* buf, int count)
+{
+ return i2c_read_data(fmradio_i2c_bus, address, -1, buf, count);
+}
+#else
+#error Invalid value for IMX233_FMRADIO_I2C
+#endif
+
+static bool tuner_enable = false;
+
+bool tuner_power(bool enable)
+{
+ if(enable != tuner_enable)
+ {
+ tuner_enable = enable;
+#if IMX233_FMRADIO_POWER == FMP_GPIO
+ static bool init = false;
+ if(!init)
+ {
+ /* CE is B0P29 (active high) */
+ imx233_pinctrl_acquire(FMP_GPIO_BANK, FMP_GPIO_PIN, "tuner_power");
+ imx233_pinctrl_set_function(FMP_GPIO_BANK, FMP_GPIO_PIN, PINCTRL_FUNCTION_GPIO);
+ imx233_pinctrl_enable_gpio(FMP_GPIO_BANK, FMP_GPIO_PIN, true);
+ }
+ imx233_pinctrl_set_gpio(FMP_GPIO_BANK, FMP_GPIO_PIN, enable);
+ /* power up delay */
+ sleep(FMP_GPIO_DELAY);
+#elif IMX233_FMRADIO_POWER == FMP_NONE
+#else
+#error Invalid value for IMX233_FMRADIO_POWER
+#endif
+ }
+ return tuner_enable;
+}
+
+bool tuner_powered(void)
+{
+ return tuner_enable;
+}
diff --git a/firmware/target/arm/imx233/fmradio-imx233.h b/firmware/target/arm/imx233/fmradio-imx233.h
new file mode 100644
index 0000000000..d53336dd40
--- /dev/null
+++ b/firmware/target/arm/imx233/fmradio-imx233.h
@@ -0,0 +1,64 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2013 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.
+ *
+ ****************************************************************************/
+#ifndef __fmradio_imx233__
+#define __fmradio_imx233__
+
+#include "config.h"
+#include "tuner.h"
+#include "fmradio_i2c.h"
+#include "tuner.h"
+
+/** This driver implements fmradio i2c and tuner power in a generic way. It
+ * currently provides two possible implementation of i2c:
+ * - hardware using i2c-imx233 driver
+ * - software using generic-i2c driver
+ * And it provides tuner power by toggling an optional GPIO.
+ * It can be tweaked using the following defines
+ * and variables:
+ * - IMX233_FMRADIO_I2C
+ * - IMX233_FMRADIO_POWER
+ *
+ * The available values of IMX233_FMRADIO_I2C are:
+ * - FMI_HW: use hardware i2c driver
+ * - FMI_SW: use software i2c driver, needs additional defines:
+ * + FMI_SW_SDA_BANK: the SDA pin bank
+ * + FMI_SW_SDA_PIN: the SDA pin within bank
+ * + FMI_SW_SCL_BANK: the SCL pin bank
+ * + FMI_SW_SCL_PIN: the SCL pin bank
+ * The available values of IMX233_FMRADIO_POWER are:
+ * - FMP_NONE: tuner has no power control
+ * - FMP_GPIO: tuner power is controlled by a GPIO, needs additional defines:
+ * + FMP_GPIO_BANK: pin bank
+ * + FMP_GPIO_PIN: pin within bank
+ * + FMP_GPIO_INVERTED: define if inverted, default is active high
+ * + FMP_GPIO_DELAY: delay to power up/down (in ticks)
+ */
+
+/* i2c method */
+#define FMI_HW 0
+#define FMI_SW 1
+
+/* power method */
+#define FMP_NONE 0
+#define FMP_GPIO 1
+
+#endif /* __fmradio_imx233__ */
+
diff --git a/firmware/target/arm/imx233/sansa-fuzeplus/fmradio-i2c-fuzeplus.c b/firmware/target/arm/imx233/sansa-fuzeplus/fmradio-i2c-fuzeplus.c
index 15e061103f..2167bb6897 100644
--- a/firmware/target/arm/imx233/sansa-fuzeplus/fmradio-i2c-fuzeplus.c
+++ b/firmware/target/arm/imx233/sansa-fuzeplus/fmradio-i2c-fuzeplus.c
@@ -21,91 +21,17 @@
#include "config.h"
#include "system.h"
-#include "fmradio_i2c.h"
#include "pinctrl-imx233.h"
-#include "generic_i2c.h"
#include "rds.h"
#include "si4700.h"
/**
* Sansa Fuze+ fmradio uses the following pins:
- * - B0P29 as CE apparently (active high)
+ * - B0P29 as CE (active high)
* - B1P24 as SDA
* - B1P22 as SCL
* - B2P27 as STC/RDS
*/
-static int fmradio_i2c_bus = -1;
-
-static void i2c_scl_dir(bool out)
-{
- imx233_pinctrl_enable_gpio(1, 22, out);
-}
-
-static void i2c_sda_dir(bool out)
-{
- imx233_pinctrl_enable_gpio(1, 24, out);
-}
-
-static void i2c_scl_out(bool high)
-{
- imx233_pinctrl_set_gpio(1, 22, high);
-}
-
-static void i2c_sda_out(bool high)
-{
- imx233_pinctrl_set_gpio(1, 24, high);
-}
-
-static bool i2c_scl_in(void)
-{
- return imx233_pinctrl_get_gpio(1, 22);
-}
-
-static bool i2c_sda_in(void)
-{
- return imx233_pinctrl_get_gpio(1, 24);
-}
-
-static void i2c_delay(int d)
-{
- udelay(d);
-}
-
-struct i2c_interface fmradio_i2c =
-{
- .scl_dir = i2c_scl_dir,
- .sda_dir = i2c_sda_dir,
- .scl_out = i2c_scl_out,
- .sda_out = i2c_sda_out,
- .scl_in = i2c_scl_in,
- .sda_in = i2c_sda_in,
- .delay = i2c_delay,
- .delay_hd_sta = 4,
- .delay_hd_dat = 5,
- .delay_su_dat = 1,
- .delay_su_sto = 4,
- .delay_su_sta = 5,
- .delay_thigh = 4
-};
-
-void fmradio_i2c_init(void)
-{
- imx233_pinctrl_acquire(1, 24, "fmradio i2c");
- imx233_pinctrl_acquire(1, 22, "fmradio i2c");
- imx233_pinctrl_set_function(1, 24, PINCTRL_FUNCTION_GPIO);
- imx233_pinctrl_set_function(1, 22, PINCTRL_FUNCTION_GPIO);
- fmradio_i2c_bus = i2c_add_node(&fmradio_i2c);
-}
-
-int fmradio_i2c_write(unsigned char address, const unsigned char* buf, int count)
-{
- return i2c_write_data(fmradio_i2c_bus, address, -1, buf, count);
-}
-
-int fmradio_i2c_read(unsigned char address, unsigned char* buf, int count)
-{
- return i2c_read_data(fmradio_i2c_bus, address, -1, buf, count);
-}
#ifdef HAVE_RDS_CAP
/* Low-level RDS Support */
diff --git a/firmware/target/arm/imx233/creative-zen/fmradio-i2c-zen.c b/firmware/target/arm/imx233/sansa-fuzeplus/fmradio-target.h
index a1377ce1f2..4c3aa0b4e5 100644
--- a/firmware/target/arm/imx233/creative-zen/fmradio-i2c-zen.c
+++ b/firmware/target/arm/imx233/sansa-fuzeplus/fmradio-target.h
@@ -18,23 +18,18 @@
* KIND, either express or implied.
*
****************************************************************************/
+#ifndef _FMRADIO_TARGET_H_
+#define _FMRADIO_TARGET_H_
-#include "config.h"
-#include "system.h"
-#include "fmradio_i2c.h"
-#include "pinctrl-imx233.h"
-#include "i2c.h"
+#define IMX233_FMRADIO_I2C FMI_SW
+#define FMI_SW_SDA_BANK 1
+#define FMI_SW_SDA_PIN 24
+#define FMI_SW_SCL_BANK 1
+#define FMI_SW_SCL_PIN 22
-void fmradio_i2c_init(void)
-{
-}
+#define IMX233_FMRADIO_POWER FMP_GPIO
+#define FMP_GPIO_BANK 0
+#define FMP_GPIO_PIN 29
+#define FMP_GPIO_DELAY (HZ / 10)
-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);
-}
+#endif /* _FMRADIO_TARGET_H_ */
diff --git a/firmware/target/arm/imx233/sansa-fuzeplus/power-fuzeplus.c b/firmware/target/arm/imx233/sansa-fuzeplus/power-fuzeplus.c
deleted file mode 100644
index be087eb140..0000000000
--- a/firmware/target/arm/imx233/sansa-fuzeplus/power-fuzeplus.c
+++ /dev/null
@@ -1,53 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2011 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 "system.h"
-#include "power.h"
-#include "tuner.h"
-#include "fmradio_i2c.h"
-#include "pinctrl-imx233.h"
-#include "power-imx233.h"
-
-static bool tuner_enable = false;
-
-bool tuner_power(bool enable)
-{
- if(enable != tuner_enable)
- {
- /* CE is B0P29 (active high) */
- imx233_pinctrl_acquire(0, 29, "tuner power");
- imx233_pinctrl_set_function(0, 29, PINCTRL_FUNCTION_GPIO);
- imx233_pinctrl_set_drive(0, 29, PINCTRL_DRIVE_4mA);
- imx233_pinctrl_enable_gpio(0, 29, enable);
- imx233_pinctrl_set_gpio(0, 29, enable);
- tuner_enable = enable;
- /* give time to power up, datasheet states than minimum timing time is
- * around 100µs so 1 tick should do */
- sleep(1);
- //imx233_power_set_dcdc_freq(enable, HW_POWER_MISC__FREQSEL__24MHz);
- }
- return tuner_enable;
-}
-
-bool tuner_powered(void)
-{
- return tuner_enable;
-}
diff --git a/firmware/target/arm/imx233/sony-nwz/fmradio-i2c-nwz.c b/firmware/target/arm/imx233/sony-nwz/fmradio-target.h
index a1377ce1f2..e6869dc2a5 100644
--- a/firmware/target/arm/imx233/sony-nwz/fmradio-i2c-nwz.c
+++ b/firmware/target/arm/imx233/sony-nwz/fmradio-target.h
@@ -18,23 +18,11 @@
* KIND, either express or implied.
*
****************************************************************************/
+#ifndef _FMRADIO_TARGET_H_
+#define _FMRADIO_TARGET_H_
-#include "config.h"
-#include "system.h"
-#include "fmradio_i2c.h"
-#include "pinctrl-imx233.h"
-#include "i2c.h"
+#define IMX233_FMRADIO_I2C FMI_HW
-void fmradio_i2c_init(void)
-{
-}
+#define IMX233_FMRADIO_POWER FMP_NONE
-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);
-}
+#endif /* _FMRADIO_TARGET_H_ */