From 7ce78fbadc31b71450b33d84b9e3f596013b6cdc Mon Sep 17 00:00:00 2001 From: jethead71 Date: Sun, 21 Dec 2008 19:39:11 +0000 Subject: [PATCH] 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 --- firmware/export/fmradio_i2c.h | 1 + .../arm/imx31/gigabeat-s/fmradio-i2c-gigabeat-s.c | 7 ++++++- firmware/target/arm/imx31/gigabeat-s/power-imx31.c | 19 ++++++++++++++----- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/firmware/export/fmradio_i2c.h b/firmware/export/fmradio_i2c.h index 5d1252768..ac3095ebc 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 5e5c4853d..154e13f9a 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 39724c7b7..727b38bd9 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 */ -- 2.11.4.GIT