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
This commit is contained in:
Michael Sevakis 2008-12-21 19:39:11 +00:00
parent 19413fc806
commit 491ed5ed6a
3 changed files with 21 additions and 6 deletions

View file

@ -23,6 +23,7 @@
#define FMRADIO_I2C_H #define FMRADIO_I2C_H
void fmradio_i2c_init(void); 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_write(unsigned char address, const unsigned char* buf, int count);
int fmradio_i2c_read(unsigned char address, unsigned char* buf, int count); int fmradio_i2c_read(unsigned char address, unsigned char* buf, int count);

View file

@ -24,7 +24,7 @@
#include "i2c-imx31.h" #include "i2c-imx31.h"
#include "fmradio_i2c.h" #include "fmradio_i2c.h"
struct i2c_node si4700_i2c_node = static struct i2c_node si4700_i2c_node =
{ {
.num = I2C2_NUM, .num = I2C2_NUM,
.ifdr = I2C_IFDR_DIV192, /* 66MHz/.4MHz = 165, closest = 192 = 343750Hz */ .ifdr = I2C_IFDR_DIV192, /* 66MHz/.4MHz = 165, closest = 192 = 343750Hz */
@ -33,6 +33,11 @@ struct i2c_node si4700_i2c_node =
.addr = (0x20), .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) int fmradio_i2c_write(unsigned char address, const unsigned char* buf, int count)
{ {
(void)address; (void)address;

View file

@ -28,9 +28,10 @@
#include "backlight-target.h" #include "backlight-target.h"
#include "avic-imx31.h" #include "avic-imx31.h"
#include "mc13783.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; static unsigned int power_status = POWER_INPUT_NONE;
/* Detect which power sources are present. */ /* Detect which power sources are present. */
@ -99,11 +100,18 @@ bool ide_powered(void)
#if CONFIG_TUNER #if CONFIG_TUNER
bool tuner_power(bool status) bool tuner_power(bool status)
{ {
static bool tuner_powered = false;
if (status == tuner_powered)
return status;
tuner_powered = status;
if (status) if (status)
{ {
/* the si4700 is the only thing connected to i2c2 so /* the si4700 is the only thing connected to i2c2 so
we can diable the i2c module when not in use */ 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 */ /* enable the fm chip */
imx31_regset32(&GPIO1_DR, (1 << 26)); imx31_regset32(&GPIO1_DR, (1 << 26));
/* enable CLK32KMCU clock */ /* enable CLK32KMCU clock */
@ -113,13 +121,14 @@ bool tuner_power(bool status)
{ {
/* the si4700 is the only thing connected to i2c2 so /* the si4700 is the only thing connected to i2c2 so
we can diable the i2c module when not in use */ 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 */ /* disable the fm chip */
imx31_regclr32(&GPIO1_DR, (1 << 26)); imx31_regclr32(&GPIO1_DR, (1 << 26));
/* disable CLK32KMCU clock */ /* disable CLK32KMCU clock */
mc13783_clear(MC13783_POWER_CONTROL0, MC13783_CLK32KMCUEN); mc13783_clear(MC13783_POWER_CONTROL0, MC13783_CLK32KMCUEN);
} }
return true;
return !status;
} }
#endif /* #if CONFIG_TUNER */ #endif /* #if CONFIG_TUNER */