From 491ed5ed6a6496b61fe34910a27e6e5416815929 Mon Sep 17 00:00:00 2001 From: Michael Sevakis Date: Sun, 21 Dec 2008 19:39:11 +0000 Subject: 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 --- .../arm/imx31/gigabeat-s/fmradio-i2c-gigabeat-s.c | 7 ++++++- firmware/target/arm/imx31/gigabeat-s/power-imx31.c | 19 ++++++++++++++----- 2 files changed, 20 insertions(+), 6 deletions(-) (limited to 'firmware/target/arm/imx31') 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 */ -- cgit v1.2.3