summaryrefslogtreecommitdiff
path: root/firmware/target
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target')
-rw-r--r--firmware/target/arm/as3525/power-as3525.c16
-rw-r--r--firmware/target/arm/imx31/gigabeat-s/fmradio-i2c-gigabeat-s.c75
-rw-r--r--firmware/target/arm/imx31/gigabeat-s/power-imx31.c43
3 files changed, 105 insertions, 29 deletions
diff --git a/firmware/target/arm/as3525/power-as3525.c b/firmware/target/arm/as3525/power-as3525.c
index 07867546c2..2fbeab0bc6 100644
--- a/firmware/target/arm/as3525/power-as3525.c
+++ b/firmware/target/arm/as3525/power-as3525.c
@@ -54,9 +54,21 @@ void ide_power_enable(bool on)
54} 54}
55 55
56#if CONFIG_TUNER 56#if CONFIG_TUNER
57static bool tuner_on = false;
58
57bool tuner_power(bool status) 59bool tuner_power(bool status)
58{ 60{
59 (void)status; 61 if (status != tuner_on)
60 return false; 62 {
63 tuner_on = status;
64 status = !status;
65 }
66
67 return status;
68}
69
70bool tuner_powered(void)
71{
72 return tuner_on; /* No debug info */
61} 73}
62#endif 74#endif
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 154e13f9a7..7646402435 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
@@ -21,6 +21,7 @@
21 ****************************************************************************/ 21 ****************************************************************************/
22#include "config.h" 22#include "config.h"
23#include "system.h" 23#include "system.h"
24#include "mc13783.h"
24#include "i2c-imx31.h" 25#include "i2c-imx31.h"
25#include "fmradio_i2c.h" 26#include "fmradio_i2c.h"
26 27
@@ -33,9 +34,77 @@ static struct i2c_node si4700_i2c_node =
33 .addr = (0x20), 34 .addr = (0x20),
34}; 35};
35 36
37void fmradio_i2c_init(void)
38{
39 /* RST: LOW */
40 imx31_regclr32(&GPIO1_DR, (1 << 26));
41 /* RST: OUT */
42 imx31_regset32(&GPIO1_GDIR, (1 << 26));
43
44 /* I2C2 SCL: IN, I2C2: SDA IN */
45 imx31_regclr32(&GPIO2_GDIR, (3 << 14));
46 /* I2C2 SCL LO, I2C2 SDA LO */
47 imx31_regclr32(&GPIO2_DR, (3 << 14));
48
49 /* open-drain pins - external pullups on PCB. Pullup default but
50 * disabled */
51 imx31_regmod32(&SW_PAD_CTL_DSR_DTE1_RI_DTE1_DCD_DTE1,
52 /* RI_DTE1 (I2C2_SCLK) */
53 SW_PAD_CTL_IO2w(SW_PAD_CTL_PUE_PKE_DISABLE |
54 SW_PAD_CTL_PUS_UP_100K |
55 SW_PAD_CTL_HYS |
56 SW_PAD_CTL_ODE) |
57 /* DCD_DTE1 (I2C2_SDA) */
58 SW_PAD_CTL_IO1w(SW_PAD_CTL_PUE_PKE_DISABLE |
59 SW_PAD_CTL_PUS_UP_100K |
60 SW_PAD_CTL_HYS |
61 SW_PAD_CTL_ODE),
62 SW_PAD_CTL_IO2 | SW_PAD_CTL_IO1);
63 /* set outputs to I2C2 */
64 imx31_regmod32(&SW_MUX_CTL_RI_DTE1_DCD_DTE1_DTR_DCE2_RXD2,
65 /* RI_DTE1 => I2C2_SCLK */
66 SW_MUX_CTL_SIG4w(SW_MUX_OUT_ALT2 | SW_MUX_IN_ALT2) |
67 /* DCD_DTE1 => I2C2_SDA */
68 SW_MUX_CTL_SIG3w(SW_MUX_OUT_ALT2 | SW_MUX_IN_ALT2),
69 SW_MUX_CTL_SIG4 | SW_MUX_CTL_SIG3);
70}
71
36void fmradio_i2c_enable(bool enable) 72void fmradio_i2c_enable(bool enable)
37{ 73{
38 i2c_enable_node(&si4700_i2c_node, enable); 74 if (enable)
75 {
76 uint32_t io_pin_mux = SW_MUX_CTL_RI_DTE1_DCD_DTE1_DTR_DCE2_RXD2;
77 /* place in GPIO mode to hold SDIO low during RESET release,
78 * SEN1 should be high already (pullup) and GPIO3 left alone */
79 imx31_regset32(&GPIO2_GDIR, (1 << 15)); /* SDIO OUT */
80 /* I2C2_SDA => MCU2_15 */
81 imx31_regmod32(&SW_MUX_CTL_RI_DTE1_DCD_DTE1_DTR_DCE2_RXD2,
82 SW_MUX_CTL_SIG3w(SW_MUX_OUT_GPIO_DR | SW_MUX_IN_GPIO_PSR_ISR),
83 SW_MUX_CTL_SIG3);
84 /* enable CLK32KMCU clock */
85 mc13783_set(MC13783_POWER_CONTROL0, MC13783_CLK32KMCUEN);
86 /* enable the fm chip (release RESET) */
87 imx31_regset32(&GPIO1_DR, (1 << 26));
88 sleep(HZ/100);
89 /* busmode should be selected - OK to release SDIO */
90 imx31_regclr32(&GPIO2_GDIR, (1 << 15)); /* SDIO IN */
91 /* restore pin mux (DCD_DTE1 => I2C2_SDA) */
92 imx31_regmod32(&SW_MUX_CTL_RI_DTE1_DCD_DTE1_DTR_DCE2_RXD2,
93 io_pin_mux, SW_MUX_CTL_SIG3);
94 /* the si4700 is the only thing connected to i2c2 so
95 we can diable the i2c module when not in use */
96 i2c_enable_node(&si4700_i2c_node, true);
97 }
98 else
99 {
100 /* the si4700 is the only thing connected to i2c2 so
101 we can diable the i2c module when not in use */
102 i2c_enable_node(&si4700_i2c_node, false);
103 /* disable the fm chip */
104 imx31_regclr32(&GPIO1_DR, (1 << 26));
105 /* disable CLK32KMCU clock */
106 mc13783_clear(MC13783_POWER_CONTROL0, MC13783_CLK32KMCUEN);
107 }
39} 108}
40 109
41int fmradio_i2c_write(unsigned char address, const unsigned char* buf, int count) 110int fmradio_i2c_write(unsigned char address, const unsigned char* buf, int count)
@@ -52,3 +121,7 @@ int fmradio_i2c_read(unsigned char address, unsigned char* buf, int count)
52 return 0; 121 return 0;
53} 122}
54 123
124int si4700_st(void)
125{
126 return (GPIO1_DR & (1 << 28)) >> 28;
127}
diff --git a/firmware/target/arm/imx31/gigabeat-s/power-imx31.c b/firmware/target/arm/imx31/gigabeat-s/power-imx31.c
index 727b38bd96..b29d3cd0fb 100644
--- a/firmware/target/arm/imx31/gigabeat-s/power-imx31.c
+++ b/firmware/target/arm/imx31/gigabeat-s/power-imx31.c
@@ -98,37 +98,24 @@ bool ide_powered(void)
98} 98}
99 99
100#if CONFIG_TUNER 100#if CONFIG_TUNER
101static bool tuner_on = false;
102
101bool tuner_power(bool status) 103bool tuner_power(bool status)
102{ 104{
103 static bool tuner_powered = false; 105 if (status != tuner_on)
104
105 if (status == tuner_powered)
106 return status;
107
108 tuner_powered = status;
109
110 if (status)
111 {
112 /* the si4700 is the only thing connected to i2c2 so
113 we can diable the i2c module when not in use */
114 fmradio_i2c_enable(true);
115 /* enable the fm chip */
116 imx31_regset32(&GPIO1_DR, (1 << 26));
117 /* enable CLK32KMCU clock */
118 mc13783_set(MC13783_POWER_CONTROL0, MC13783_CLK32KMCUEN);
119 }
120 else
121 { 106 {
122 /* the si4700 is the only thing connected to i2c2 so 107 tuner_on = status;
123 we can diable the i2c module when not in use */ 108 /* Handle power and pin setup */
124 fmradio_i2c_enable(false); 109 fmradio_i2c_enable(status);
125 /* disable the fm chip */ 110 status = !status;
126 imx31_regclr32(&GPIO1_DR, (1 << 26));
127 /* disable CLK32KMCU clock */
128 mc13783_clear(MC13783_POWER_CONTROL0, MC13783_CLK32KMCUEN);
129 } 111 }
130 112
131 return !status; 113 return status;
114}
115
116bool tuner_powered(void)
117{
118 return tuner_on;
132} 119}
133#endif /* #if CONFIG_TUNER */ 120#endif /* #if CONFIG_TUNER */
134 121
@@ -151,6 +138,10 @@ void power_off(void)
151 138
152void power_init(void) 139void power_init(void)
153{ 140{
141#if CONFIG_TUNER
142 fmradio_i2c_init();
143#endif
144
154 /* Poll initial state */ 145 /* Poll initial state */
155 charger_main_detect_event(); 146 charger_main_detect_event();
156 147