summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 @@
23#define FMRADIO_I2C_H 23#define FMRADIO_I2C_H
24 24
25void fmradio_i2c_init(void); 25void fmradio_i2c_init(void);
26void fmradio_i2c_enable(bool enable);
26int fmradio_i2c_write(unsigned char address, const unsigned char* buf, int count); 27int fmradio_i2c_write(unsigned char address, const unsigned char* buf, int count);
27int fmradio_i2c_read(unsigned char address, unsigned char* buf, int count); 28int fmradio_i2c_read(unsigned char address, unsigned char* buf, int count);
28 29
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 @@
24#include "i2c-imx31.h" 24#include "i2c-imx31.h"
25#include "fmradio_i2c.h" 25#include "fmradio_i2c.h"
26 26
27struct i2c_node si4700_i2c_node = 27static struct i2c_node si4700_i2c_node =
28{ 28{
29 .num = I2C2_NUM, 29 .num = I2C2_NUM,
30 .ifdr = I2C_IFDR_DIV192, /* 66MHz/.4MHz = 165, closest = 192 = 343750Hz */ 30 .ifdr = I2C_IFDR_DIV192, /* 66MHz/.4MHz = 165, closest = 192 = 343750Hz */
@@ -33,6 +33,11 @@ struct i2c_node si4700_i2c_node =
33 .addr = (0x20), 33 .addr = (0x20),
34}; 34};
35 35
36void fmradio_i2c_enable(bool enable)
37{
38 i2c_enable_node(&si4700_i2c_node, enable);
39}
40
36int fmradio_i2c_write(unsigned char address, const unsigned char* buf, int count) 41int fmradio_i2c_write(unsigned char address, const unsigned char* buf, int count)
37{ 42{
38 (void)address; 43 (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 @@
28#include "backlight-target.h" 28#include "backlight-target.h"
29#include "avic-imx31.h" 29#include "avic-imx31.h"
30#include "mc13783.h" 30#include "mc13783.h"
31#include "i2c-imx31.h" 31#if CONFIG_TUNER
32#include "fmradio_i2c.h"
33#endif
32 34
33extern struct i2c_node si4700_i2c_node;
34static unsigned int power_status = POWER_INPUT_NONE; 35static unsigned int power_status = POWER_INPUT_NONE;
35 36
36/* Detect which power sources are present. */ 37/* Detect which power sources are present. */
@@ -99,11 +100,18 @@ bool ide_powered(void)
99#if CONFIG_TUNER 100#if CONFIG_TUNER
100bool tuner_power(bool status) 101bool tuner_power(bool status)
101{ 102{
103 static bool tuner_powered = false;
104
105 if (status == tuner_powered)
106 return status;
107
108 tuner_powered = status;
109
102 if (status) 110 if (status)
103 { 111 {
104 /* the si4700 is the only thing connected to i2c2 so 112 /* the si4700 is the only thing connected to i2c2 so
105 we can diable the i2c module when not in use */ 113 we can diable the i2c module when not in use */
106 i2c_enable_node(&si4700_i2c_node, true); 114 fmradio_i2c_enable(true);
107 /* enable the fm chip */ 115 /* enable the fm chip */
108 imx31_regset32(&GPIO1_DR, (1 << 26)); 116 imx31_regset32(&GPIO1_DR, (1 << 26));
109 /* enable CLK32KMCU clock */ 117 /* enable CLK32KMCU clock */
@@ -113,13 +121,14 @@ bool tuner_power(bool status)
113 { 121 {
114 /* the si4700 is the only thing connected to i2c2 so 122 /* the si4700 is the only thing connected to i2c2 so
115 we can diable the i2c module when not in use */ 123 we can diable the i2c module when not in use */
116 i2c_enable_node(&si4700_i2c_node, false); 124 fmradio_i2c_enable(false);
117 /* disable the fm chip */ 125 /* disable the fm chip */
118 imx31_regclr32(&GPIO1_DR, (1 << 26)); 126 imx31_regclr32(&GPIO1_DR, (1 << 26));
119 /* disable CLK32KMCU clock */ 127 /* disable CLK32KMCU clock */
120 mc13783_clear(MC13783_POWER_CONTROL0, MC13783_CLK32KMCUEN); 128 mc13783_clear(MC13783_POWER_CONTROL0, MC13783_CLK32KMCUEN);
121 } 129 }
122 return true; 130
131 return !status;
123} 132}
124#endif /* #if CONFIG_TUNER */ 133#endif /* #if CONFIG_TUNER */
125 134