summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2008-12-21 19:39:11 +0000
committerMichael Sevakis <jethead71@rockbox.org>2008-12-21 19:39:11 +0000
commit491ed5ed6a6496b61fe34910a27e6e5416815929 (patch)
tree66bcae56cacc8634864944d7c2f783593dca8de9
parent19413fc8060fb80eae668ddfdf3c4fa7e751e5b4 (diff)
Gigabeat S: Make tuner_power have the expected behavior (return old state). Static i2c node structure and add fmradio_i2c_enable to the fmradio i2c API for those that can implement it.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19550 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/export/fmradio_i2c.h1
-rw-r--r--firmware/target/arm/imx31/gigabeat-s/fmradio-i2c-gigabeat-s.c7
-rw-r--r--firmware/target/arm/imx31/gigabeat-s/power-imx31.c19
3 files changed, 21 insertions, 6 deletions
diff --git a/firmware/export/fmradio_i2c.h b/firmware/export/fmradio_i2c.h
index 5d1252768c..ac3095ebcd 100644
--- a/firmware/export/fmradio_i2c.h
+++ b/firmware/export/fmradio_i2c.h
@@ -23,6 +23,7 @@
#define FMRADIO_I2C_H
void fmradio_i2c_init(void);
+void fmradio_i2c_enable(bool enable);
int fmradio_i2c_write(unsigned char address, const unsigned char* buf, int count);
int fmradio_i2c_read(unsigned char address, unsigned char* buf, int count);
diff --git a/firmware/target/arm/imx31/gigabeat-s/fmradio-i2c-gigabeat-s.c b/firmware/target/arm/imx31/gigabeat-s/fmradio-i2c-gigabeat-s.c
index 5e5c4853dd..154e13f9a7 100644
--- a/firmware/target/arm/imx31/gigabeat-s/fmradio-i2c-gigabeat-s.c
+++ b/firmware/target/arm/imx31/gigabeat-s/fmradio-i2c-gigabeat-s.c
@@ -24,7 +24,7 @@
#include "i2c-imx31.h"
#include "fmradio_i2c.h"
-struct i2c_node si4700_i2c_node =
+static struct i2c_node si4700_i2c_node =
{
.num = I2C2_NUM,
.ifdr = I2C_IFDR_DIV192, /* 66MHz/.4MHz = 165, closest = 192 = 343750Hz */
@@ -33,6 +33,11 @@ struct i2c_node si4700_i2c_node =
.addr = (0x20),
};
+void fmradio_i2c_enable(bool enable)
+{
+ i2c_enable_node(&si4700_i2c_node, enable);
+}
+
int fmradio_i2c_write(unsigned char address, const unsigned char* buf, int count)
{
(void)address;
diff --git a/firmware/target/arm/imx31/gigabeat-s/power-imx31.c b/firmware/target/arm/imx31/gigabeat-s/power-imx31.c
index 39724c7b75..727b38bd96 100644
--- a/firmware/target/arm/imx31/gigabeat-s/power-imx31.c
+++ b/firmware/target/arm/imx31/gigabeat-s/power-imx31.c
@@ -28,9 +28,10 @@
#include "backlight-target.h"
#include "avic-imx31.h"
#include "mc13783.h"
-#include "i2c-imx31.h"
+#if CONFIG_TUNER
+#include "fmradio_i2c.h"
+#endif
-extern struct i2c_node si4700_i2c_node;
static unsigned int power_status = POWER_INPUT_NONE;
/* Detect which power sources are present. */
@@ -99,11 +100,18 @@ bool ide_powered(void)
#if CONFIG_TUNER
bool tuner_power(bool status)
{
+ static bool tuner_powered = false;
+
+ if (status == tuner_powered)
+ return status;
+
+ tuner_powered = status;
+
if (status)
{
/* the si4700 is the only thing connected to i2c2 so
we can diable the i2c module when not in use */
- i2c_enable_node(&si4700_i2c_node, true);
+ fmradio_i2c_enable(true);
/* enable the fm chip */
imx31_regset32(&GPIO1_DR, (1 << 26));
/* enable CLK32KMCU clock */
@@ -113,13 +121,14 @@ bool tuner_power(bool status)
{
/* the si4700 is the only thing connected to i2c2 so
we can diable the i2c module when not in use */
- i2c_enable_node(&si4700_i2c_node, false);
+ fmradio_i2c_enable(false);
/* disable the fm chip */
imx31_regclr32(&GPIO1_DR, (1 << 26));
/* disable CLK32KMCU clock */
mc13783_clear(MC13783_POWER_CONTROL0, MC13783_CLK32KMCUEN);
}
- return true;
+
+ return !status;
}
#endif /* #if CONFIG_TUNER */