diff options
author | Cástor Muñoz <cmvidal@gmail.com> | 2016-05-22 00:43:18 +0200 |
---|---|---|
committer | Cástor Muñoz <cmvidal@gmail.com> | 2016-05-25 12:23:47 +0200 |
commit | 3f17745930ab0bee11555ab35318121dbec8fab1 (patch) | |
tree | f55eca9ef78772842b9f9e9dc448b04d9cefaef5 | |
parent | e863f9a0ce8d968b085252c3b093b17ca07b65dd (diff) | |
download | rockbox-3f17745930ab0bee11555ab35318121dbec8fab1.tar.gz rockbox-3f17745930ab0bee11555ab35318121dbec8fab1.zip |
iPod Classic: HW initialization for RB
Do not rely on a bootloader initializing the HW, RB initializes
and configures GPIO, I2C, and PMU at startup.
Change-Id: If7f856b1f345f63de584aa4e4fc22d130cd66c80
-rw-r--r-- | firmware/export/i2c-s5l8702.h | 2 | ||||
-rw-r--r-- | firmware/target/arm/s5l8702/clocking-s5l8702.c | 16 | ||||
-rw-r--r-- | firmware/target/arm/s5l8702/clocking-s5l8702.h | 2 | ||||
-rw-r--r-- | firmware/target/arm/s5l8702/gpio-s5l8702.c | 2 | ||||
-rw-r--r-- | firmware/target/arm/s5l8702/gpio-s5l8702.h | 2 | ||||
-rw-r--r-- | firmware/target/arm/s5l8702/i2c-s5l8702.c | 5 | ||||
-rw-r--r-- | firmware/target/arm/s5l8702/ipod6g/pmu-ipod6g.c | 9 | ||||
-rw-r--r-- | firmware/target/arm/s5l8702/ipod6g/pmu-target.h | 2 | ||||
-rw-r--r-- | firmware/target/arm/s5l8702/system-s5l8702.c | 8 |
9 files changed, 25 insertions, 23 deletions
diff --git a/firmware/export/i2c-s5l8702.h b/firmware/export/i2c-s5l8702.h index aef0e536bf..f671e4059e 100644 --- a/firmware/export/i2c-s5l8702.h +++ b/firmware/export/i2c-s5l8702.h | |||
@@ -28,10 +28,8 @@ void i2c_init(void); | |||
28 | int i2c_write(int bus, unsigned char slave, int address, int len, const unsigned char *data); | 28 | int i2c_write(int bus, unsigned char slave, int address, int len, const unsigned char *data); |
29 | int i2c_read(int bus, unsigned char slave, int address, int len, unsigned char *data); | 29 | int i2c_read(int bus, unsigned char slave, int address, int len, unsigned char *data); |
30 | 30 | ||
31 | #ifdef BOOTLOADER | ||
32 | void i2c_preinit(int bus); | 31 | void i2c_preinit(int bus); |
33 | int i2c_wr(int bus, unsigned char slave, int address, int len, const unsigned char *data); | 32 | int i2c_wr(int bus, unsigned char slave, int address, int len, const unsigned char *data); |
34 | int i2c_rd(int bus, unsigned char slave, int address, int len, unsigned char *data); | 33 | int i2c_rd(int bus, unsigned char slave, int address, int len, unsigned char *data); |
35 | #endif | ||
36 | 34 | ||
37 | #endif /* _I2C_S5l8702_H */ | 35 | #endif /* _I2C_S5l8702_H */ |
diff --git a/firmware/target/arm/s5l8702/clocking-s5l8702.c b/firmware/target/arm/s5l8702/clocking-s5l8702.c index 3ef70ba1de..b7fa45fcf5 100644 --- a/firmware/target/arm/s5l8702/clocking-s5l8702.c +++ b/firmware/target/arm/s5l8702/clocking-s5l8702.c | |||
@@ -213,6 +213,14 @@ void set_clocking_level(int level) | |||
213 | udelay(50); /* TBC: probably not needed */ | 213 | udelay(50); /* TBC: probably not needed */ |
214 | } | 214 | } |
215 | 215 | ||
216 | void clockgate_enable(int gate, bool enable) | ||
217 | { | ||
218 | int i = (gate >> 5) & 1; | ||
219 | uint32_t bit = 1 << (gate & 0x1f); | ||
220 | if (enable) PWRCON(i) &= ~bit; | ||
221 | else PWRCON(i) |= bit; | ||
222 | } | ||
223 | |||
216 | #ifdef BOOTLOADER | 224 | #ifdef BOOTLOADER |
217 | int pll_config(int pll, int op_mode, int p, int m, int s, int lock_time) | 225 | int pll_config(int pll, int op_mode, int p, int m, int s, int lock_time) |
218 | { | 226 | { |
@@ -299,14 +307,6 @@ void cg16_config(volatile uint16_t* cg16, | |||
299 | while (*cg16 != val16); | 307 | while (*cg16 != val16); |
300 | } | 308 | } |
301 | 309 | ||
302 | void clockgate_enable(int gate, bool enable) | ||
303 | { | ||
304 | int i = (gate >> 5) & 1; | ||
305 | uint32_t bit = 1 << (gate & 0x1f); | ||
306 | if (enable) PWRCON(i) &= ~bit; | ||
307 | else PWRCON(i) |= bit; | ||
308 | } | ||
309 | |||
310 | /* Configures EClk for USEC_TIMER. DRAM refresh also depends on EClk, | 310 | /* Configures EClk for USEC_TIMER. DRAM refresh also depends on EClk, |
311 | * this clock should be initialized by the bootloader, so USEC_TIMER | 311 | * this clock should be initialized by the bootloader, so USEC_TIMER |
312 | * is ready to use for RB. | 312 | * is ready to use for RB. |
diff --git a/firmware/target/arm/s5l8702/clocking-s5l8702.h b/firmware/target/arm/s5l8702/clocking-s5l8702.h index f21c25929b..7f5a7d3e6d 100644 --- a/firmware/target/arm/s5l8702/clocking-s5l8702.h +++ b/firmware/target/arm/s5l8702/clocking-s5l8702.h | |||
@@ -426,6 +426,7 @@ struct clocking_mode | |||
426 | void clocking_init(struct clocking_mode *modes, int init_level); | 426 | void clocking_init(struct clocking_mode *modes, int init_level); |
427 | void set_clocking_level(int level); | 427 | void set_clocking_level(int level); |
428 | unsigned get_system_freqs(unsigned *cclk, unsigned *hclk, unsigned *pclk); | 428 | unsigned get_system_freqs(unsigned *cclk, unsigned *hclk, unsigned *pclk); |
429 | void clockgate_enable(int gate, bool enable); | ||
429 | 430 | ||
430 | /* debug */ | 431 | /* debug */ |
431 | unsigned pll_get_cfg_freq(int pll); | 432 | unsigned pll_get_cfg_freq(int pll); |
@@ -437,7 +438,6 @@ int soc_get_hsdiv(void); | |||
437 | #include <stdbool.h> | 438 | #include <stdbool.h> |
438 | 439 | ||
439 | void usec_timer_init(void); | 440 | void usec_timer_init(void); |
440 | void clockgate_enable(int gate, bool enable); | ||
441 | 441 | ||
442 | void soc_set_system_divs(unsigned cdiv, unsigned hdiv, unsigned hprat); | 442 | void soc_set_system_divs(unsigned cdiv, unsigned hdiv, unsigned hprat); |
443 | unsigned soc_get_system_divs(unsigned *cdiv, unsigned *hdiv, unsigned *pdiv); | 443 | unsigned soc_get_system_divs(unsigned *cdiv, unsigned *hdiv, unsigned *pdiv); |
diff --git a/firmware/target/arm/s5l8702/gpio-s5l8702.c b/firmware/target/arm/s5l8702/gpio-s5l8702.c index 85033de78c..3b2c02861f 100644 --- a/firmware/target/arm/s5l8702/gpio-s5l8702.c +++ b/firmware/target/arm/s5l8702/gpio-s5l8702.c | |||
@@ -215,7 +215,6 @@ void ICODE_ATTR INT_EXT6(void) | |||
215 | } | 215 | } |
216 | #endif | 216 | #endif |
217 | 217 | ||
218 | #ifdef BOOTLOADER | ||
219 | static uint32_t gpio_data[16] = | 218 | static uint32_t gpio_data[16] = |
220 | { | 219 | { |
221 | 0x5322222F, 0xEEEEEE00, 0x2332EEEE, 0x3333E222, | 220 | 0x5322222F, 0xEEEEEE00, 0x2332EEEE, 0x3333E222, |
@@ -232,4 +231,3 @@ void gpio_preinit(void) | |||
232 | PUNC(i) = 0; | 231 | PUNC(i) = 0; |
233 | } | 232 | } |
234 | } | 233 | } |
235 | #endif | ||
diff --git a/firmware/target/arm/s5l8702/gpio-s5l8702.h b/firmware/target/arm/s5l8702/gpio-s5l8702.h index 108d8feb0d..19bc36a139 100644 --- a/firmware/target/arm/s5l8702/gpio-s5l8702.h +++ b/firmware/target/arm/s5l8702/gpio-s5l8702.h | |||
@@ -142,8 +142,6 @@ void gpio_int_disable(int gpio_n); | |||
142 | uint32_t gpio_group_get(int group); | 142 | uint32_t gpio_group_get(int group); |
143 | void gpio_group_set(int group, uint32_t mask, uint32_t cfg); | 143 | void gpio_group_set(int group, uint32_t mask, uint32_t cfg); |
144 | 144 | ||
145 | #ifdef BOOTLOADER | ||
146 | void gpio_preinit(void); | 145 | void gpio_preinit(void); |
147 | #endif | ||
148 | 146 | ||
149 | #endif /* __GPIO_S5L8702_H__ */ | 147 | #endif /* __GPIO_S5L8702_H__ */ |
diff --git a/firmware/target/arm/s5l8702/i2c-s5l8702.c b/firmware/target/arm/s5l8702/i2c-s5l8702.c index 13787d7357..d76bbe6c06 100644 --- a/firmware/target/arm/s5l8702/i2c-s5l8702.c +++ b/firmware/target/arm/s5l8702/i2c-s5l8702.c | |||
@@ -23,6 +23,7 @@ | |||
23 | #include "system.h" | 23 | #include "system.h" |
24 | #include "kernel.h" | 24 | #include "kernel.h" |
25 | #include "i2c-s5l8702.h" | 25 | #include "i2c-s5l8702.h" |
26 | #include "clocking-s5l8702.h" | ||
26 | 27 | ||
27 | /* Driver for the s5l8700 built-in I2C controller in master mode | 28 | /* Driver for the s5l8700 built-in I2C controller in master mode |
28 | 29 | ||
@@ -180,9 +181,6 @@ int i2c_read(int bus, unsigned char slave, int address, int len, unsigned char * | |||
180 | return ret; | 181 | return ret; |
181 | } | 182 | } |
182 | 183 | ||
183 | #ifdef BOOTLOADER | ||
184 | #include "clocking-s5l8702.h" | ||
185 | |||
186 | static void wait_rdy(int bus) | 184 | static void wait_rdy(int bus) |
187 | { | 185 | { |
188 | while (IICUNK10(bus)); | 186 | while (IICUNK10(bus)); |
@@ -206,4 +204,3 @@ void i2c_preinit(int bus) | |||
206 | wait_rdy(bus); | 204 | wait_rdy(bus); |
207 | clockgate_enable(I2CCLKGATE(bus), false); | 205 | clockgate_enable(I2CCLKGATE(bus), false); |
208 | } | 206 | } |
209 | #endif | ||
diff --git a/firmware/target/arm/s5l8702/ipod6g/pmu-ipod6g.c b/firmware/target/arm/s5l8702/ipod6g/pmu-ipod6g.c index 9c3ec8e711..920c93ad5d 100644 --- a/firmware/target/arm/s5l8702/ipod6g/pmu-ipod6g.c +++ b/firmware/target/arm/s5l8702/ipod6g/pmu-ipod6g.c | |||
@@ -143,7 +143,9 @@ void pmu_write_rtc(unsigned char* buffer) | |||
143 | pmu_write_multiple(0x59, 7, buffer); | 143 | pmu_write_multiple(0x59, 7, buffer); |
144 | } | 144 | } |
145 | 145 | ||
146 | #ifdef BOOTLOADER | 146 | /* |
147 | * preinit | ||
148 | */ | ||
147 | int pmu_rd_multiple(int address, int count, unsigned char* buffer) | 149 | int pmu_rd_multiple(int address, int count, unsigned char* buffer) |
148 | { | 150 | { |
149 | return i2c_rd(0, 0xe6, address, count, buffer); | 151 | return i2c_rd(0, 0xe6, address, count, buffer); |
@@ -225,7 +227,9 @@ void pmu_preinit(void) | |||
225 | /* AUTOLDO (HDD): 3400 mV, disabled, | 227 | /* AUTOLDO (HDD): 3400 mV, disabled, |
226 | limit = 1000 mA (40mA*0x19), limit always active */ | 228 | limit = 1000 mA (40mA*0x19), limit always active */ |
227 | PCF5063X_REG_AUTOOUT, 0x6f, | 229 | PCF5063X_REG_AUTOOUT, 0x6f, |
230 | #ifdef BOOTLOADER | ||
228 | PCF5063X_REG_AUTOENA, 0x0, | 231 | PCF5063X_REG_AUTOENA, 0x0, |
232 | #endif | ||
229 | PCF5063X_REG_AUTOCTL, 0x0, | 233 | PCF5063X_REG_AUTOCTL, 0x0, |
230 | PCF5063X_REG_AUTOMXC, 0x59, | 234 | PCF5063X_REG_AUTOMXC, 0x59, |
231 | 235 | ||
@@ -257,7 +261,9 @@ void pmu_preinit(void) | |||
257 | PCF5063X_REG_GPOCFG, 0x1, | 261 | PCF5063X_REG_GPOCFG, 0x1, |
258 | /* LED converter OFF, overvoltage protection enabled, | 262 | /* LED converter OFF, overvoltage protection enabled, |
259 | OCP limit is 500 mA, led_dimstep = 16*0x6/32768 */ | 263 | OCP limit is 500 mA, led_dimstep = 16*0x6/32768 */ |
264 | #ifdef BOOTLOADER | ||
260 | PCF5063X_REG_LEDENA, 0x0, | 265 | PCF5063X_REG_LEDENA, 0x0, |
266 | #endif | ||
261 | PCF5063X_REG_LEDCTL, 0x5, | 267 | PCF5063X_REG_LEDCTL, 0x5, |
262 | PCF5063X_REG_LEDDIM, 0x6, | 268 | PCF5063X_REG_LEDDIM, 0x6, |
263 | 269 | ||
@@ -274,4 +280,3 @@ void pmu_preinit(void) | |||
274 | pmu_rd_multiple(PCF5063X_REG_INT1, 5, rd_buf); | 280 | pmu_rd_multiple(PCF5063X_REG_INT1, 5, rd_buf); |
275 | pmu_rd(PCF50635_REG_INT6); | 281 | pmu_rd(PCF50635_REG_INT6); |
276 | } | 282 | } |
277 | #endif /* BOOTLOADER */ | ||
diff --git a/firmware/target/arm/s5l8702/ipod6g/pmu-target.h b/firmware/target/arm/s5l8702/ipod6g/pmu-target.h index e4bef6f47c..d090f72a67 100644 --- a/firmware/target/arm/s5l8702/ipod6g/pmu-target.h +++ b/firmware/target/arm/s5l8702/ipod6g/pmu-target.h | |||
@@ -77,12 +77,12 @@ void pmu_read_rtc(unsigned char* buffer); | |||
77 | void pmu_write_rtc(unsigned char* buffer); | 77 | void pmu_write_rtc(unsigned char* buffer); |
78 | void pmu_hdd_power(bool on); | 78 | void pmu_hdd_power(bool on); |
79 | 79 | ||
80 | void pmu_preinit(void); | ||
80 | #ifdef BOOTLOADER | 81 | #ifdef BOOTLOADER |
81 | unsigned char pmu_rd(int address); | 82 | unsigned char pmu_rd(int address); |
82 | int pmu_wr(int address, unsigned char val); | 83 | int pmu_wr(int address, unsigned char val); |
83 | int pmu_rd_multiple(int address, int count, unsigned char* buffer); | 84 | int pmu_rd_multiple(int address, int count, unsigned char* buffer); |
84 | int pmu_wr_multiple(int address, int count, unsigned char* buffer); | 85 | int pmu_wr_multiple(int address, int count, unsigned char* buffer); |
85 | void pmu_preinit(void); | ||
86 | #endif | 86 | #endif |
87 | 87 | ||
88 | #endif /* __PMU_TARGET_H__ */ | 88 | #endif /* __PMU_TARGET_H__ */ |
diff --git a/firmware/target/arm/s5l8702/system-s5l8702.c b/firmware/target/arm/s5l8702/system-s5l8702.c index d285efde78..e94e12a153 100644 --- a/firmware/target/arm/s5l8702/system-s5l8702.c +++ b/firmware/target/arm/s5l8702/system-s5l8702.c | |||
@@ -23,6 +23,7 @@ | |||
23 | #include "system.h" | 23 | #include "system.h" |
24 | #include "panic.h" | 24 | #include "panic.h" |
25 | #include "system-target.h" | 25 | #include "system-target.h" |
26 | #include "i2c-s5l8702.h" | ||
26 | #include "pmu-target.h" | 27 | #include "pmu-target.h" |
27 | #include "uart-target.h" | 28 | #include "uart-target.h" |
28 | #include "gpio-s5l8702.h" | 29 | #include "gpio-s5l8702.h" |
@@ -199,6 +200,11 @@ enum { | |||
199 | void system_init(void) | 200 | void system_init(void) |
200 | { | 201 | { |
201 | clocking_init(clk_modes, 0); | 202 | clocking_init(clk_modes, 0); |
203 | #ifndef BOOTLOADER | ||
204 | gpio_preinit(); | ||
205 | i2c_preinit(0); | ||
206 | pmu_preinit(); | ||
207 | #endif | ||
202 | gpio_init(); | 208 | gpio_init(); |
203 | pmu_init(); | 209 | pmu_init(); |
204 | dma_init(); | 210 | dma_init(); |
@@ -279,7 +285,7 @@ void memory_init(void) | |||
279 | } | 285 | } |
280 | 286 | ||
281 | #ifdef BOOTLOADER | 287 | #ifdef BOOTLOADER |
282 | #include "i2c-s5l8702.h" | 288 | #include <stdbool.h> |
283 | 289 | ||
284 | static void syscon_preinit(void) | 290 | static void syscon_preinit(void) |
285 | { | 291 | { |