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
This commit is contained in:
parent
e863f9a0ce
commit
3f17745930
9 changed files with 25 additions and 23 deletions
|
@ -28,10 +28,8 @@ void i2c_init(void);
|
||||||
int i2c_write(int bus, unsigned char slave, int address, int len, const unsigned char *data);
|
int i2c_write(int bus, unsigned char slave, int address, int len, const unsigned char *data);
|
||||||
int i2c_read(int bus, unsigned char slave, int address, int len, unsigned char *data);
|
int i2c_read(int bus, unsigned char slave, int address, int len, unsigned char *data);
|
||||||
|
|
||||||
#ifdef BOOTLOADER
|
|
||||||
void i2c_preinit(int bus);
|
void i2c_preinit(int bus);
|
||||||
int i2c_wr(int bus, unsigned char slave, int address, int len, const unsigned char *data);
|
int i2c_wr(int bus, unsigned char slave, int address, int len, const unsigned char *data);
|
||||||
int i2c_rd(int bus, unsigned char slave, int address, int len, unsigned char *data);
|
int i2c_rd(int bus, unsigned char slave, int address, int len, unsigned char *data);
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* _I2C_S5l8702_H */
|
#endif /* _I2C_S5l8702_H */
|
||||||
|
|
|
@ -213,6 +213,14 @@ void set_clocking_level(int level)
|
||||||
udelay(50); /* TBC: probably not needed */
|
udelay(50); /* TBC: probably not needed */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void clockgate_enable(int gate, bool enable)
|
||||||
|
{
|
||||||
|
int i = (gate >> 5) & 1;
|
||||||
|
uint32_t bit = 1 << (gate & 0x1f);
|
||||||
|
if (enable) PWRCON(i) &= ~bit;
|
||||||
|
else PWRCON(i) |= bit;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef BOOTLOADER
|
#ifdef BOOTLOADER
|
||||||
int pll_config(int pll, int op_mode, int p, int m, int s, int lock_time)
|
int pll_config(int pll, int op_mode, int p, int m, int s, int lock_time)
|
||||||
{
|
{
|
||||||
|
@ -299,14 +307,6 @@ void cg16_config(volatile uint16_t* cg16,
|
||||||
while (*cg16 != val16);
|
while (*cg16 != val16);
|
||||||
}
|
}
|
||||||
|
|
||||||
void clockgate_enable(int gate, bool enable)
|
|
||||||
{
|
|
||||||
int i = (gate >> 5) & 1;
|
|
||||||
uint32_t bit = 1 << (gate & 0x1f);
|
|
||||||
if (enable) PWRCON(i) &= ~bit;
|
|
||||||
else PWRCON(i) |= bit;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Configures EClk for USEC_TIMER. DRAM refresh also depends on EClk,
|
/* Configures EClk for USEC_TIMER. DRAM refresh also depends on EClk,
|
||||||
* this clock should be initialized by the bootloader, so USEC_TIMER
|
* this clock should be initialized by the bootloader, so USEC_TIMER
|
||||||
* is ready to use for RB.
|
* is ready to use for RB.
|
||||||
|
|
|
@ -426,6 +426,7 @@ struct clocking_mode
|
||||||
void clocking_init(struct clocking_mode *modes, int init_level);
|
void clocking_init(struct clocking_mode *modes, int init_level);
|
||||||
void set_clocking_level(int level);
|
void set_clocking_level(int level);
|
||||||
unsigned get_system_freqs(unsigned *cclk, unsigned *hclk, unsigned *pclk);
|
unsigned get_system_freqs(unsigned *cclk, unsigned *hclk, unsigned *pclk);
|
||||||
|
void clockgate_enable(int gate, bool enable);
|
||||||
|
|
||||||
/* debug */
|
/* debug */
|
||||||
unsigned pll_get_cfg_freq(int pll);
|
unsigned pll_get_cfg_freq(int pll);
|
||||||
|
@ -437,7 +438,6 @@ int soc_get_hsdiv(void);
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
void usec_timer_init(void);
|
void usec_timer_init(void);
|
||||||
void clockgate_enable(int gate, bool enable);
|
|
||||||
|
|
||||||
void soc_set_system_divs(unsigned cdiv, unsigned hdiv, unsigned hprat);
|
void soc_set_system_divs(unsigned cdiv, unsigned hdiv, unsigned hprat);
|
||||||
unsigned soc_get_system_divs(unsigned *cdiv, unsigned *hdiv, unsigned *pdiv);
|
unsigned soc_get_system_divs(unsigned *cdiv, unsigned *hdiv, unsigned *pdiv);
|
||||||
|
|
|
@ -215,7 +215,6 @@ void ICODE_ATTR INT_EXT6(void)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef BOOTLOADER
|
|
||||||
static uint32_t gpio_data[16] =
|
static uint32_t gpio_data[16] =
|
||||||
{
|
{
|
||||||
0x5322222F, 0xEEEEEE00, 0x2332EEEE, 0x3333E222,
|
0x5322222F, 0xEEEEEE00, 0x2332EEEE, 0x3333E222,
|
||||||
|
@ -232,4 +231,3 @@ void gpio_preinit(void)
|
||||||
PUNC(i) = 0;
|
PUNC(i) = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
|
@ -142,8 +142,6 @@ void gpio_int_disable(int gpio_n);
|
||||||
uint32_t gpio_group_get(int group);
|
uint32_t gpio_group_get(int group);
|
||||||
void gpio_group_set(int group, uint32_t mask, uint32_t cfg);
|
void gpio_group_set(int group, uint32_t mask, uint32_t cfg);
|
||||||
|
|
||||||
#ifdef BOOTLOADER
|
|
||||||
void gpio_preinit(void);
|
void gpio_preinit(void);
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* __GPIO_S5L8702_H__ */
|
#endif /* __GPIO_S5L8702_H__ */
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
#include "kernel.h"
|
#include "kernel.h"
|
||||||
#include "i2c-s5l8702.h"
|
#include "i2c-s5l8702.h"
|
||||||
|
#include "clocking-s5l8702.h"
|
||||||
|
|
||||||
/* Driver for the s5l8700 built-in I2C controller in master mode
|
/* Driver for the s5l8700 built-in I2C controller in master mode
|
||||||
|
|
||||||
|
@ -180,9 +181,6 @@ int i2c_read(int bus, unsigned char slave, int address, int len, unsigned char *
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef BOOTLOADER
|
|
||||||
#include "clocking-s5l8702.h"
|
|
||||||
|
|
||||||
static void wait_rdy(int bus)
|
static void wait_rdy(int bus)
|
||||||
{
|
{
|
||||||
while (IICUNK10(bus));
|
while (IICUNK10(bus));
|
||||||
|
@ -206,4 +204,3 @@ void i2c_preinit(int bus)
|
||||||
wait_rdy(bus);
|
wait_rdy(bus);
|
||||||
clockgate_enable(I2CCLKGATE(bus), false);
|
clockgate_enable(I2CCLKGATE(bus), false);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
|
@ -143,7 +143,9 @@ void pmu_write_rtc(unsigned char* buffer)
|
||||||
pmu_write_multiple(0x59, 7, buffer);
|
pmu_write_multiple(0x59, 7, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef BOOTLOADER
|
/*
|
||||||
|
* preinit
|
||||||
|
*/
|
||||||
int pmu_rd_multiple(int address, int count, unsigned char* buffer)
|
int pmu_rd_multiple(int address, int count, unsigned char* buffer)
|
||||||
{
|
{
|
||||||
return i2c_rd(0, 0xe6, address, count, buffer);
|
return i2c_rd(0, 0xe6, address, count, buffer);
|
||||||
|
@ -225,7 +227,9 @@ void pmu_preinit(void)
|
||||||
/* AUTOLDO (HDD): 3400 mV, disabled,
|
/* AUTOLDO (HDD): 3400 mV, disabled,
|
||||||
limit = 1000 mA (40mA*0x19), limit always active */
|
limit = 1000 mA (40mA*0x19), limit always active */
|
||||||
PCF5063X_REG_AUTOOUT, 0x6f,
|
PCF5063X_REG_AUTOOUT, 0x6f,
|
||||||
|
#ifdef BOOTLOADER
|
||||||
PCF5063X_REG_AUTOENA, 0x0,
|
PCF5063X_REG_AUTOENA, 0x0,
|
||||||
|
#endif
|
||||||
PCF5063X_REG_AUTOCTL, 0x0,
|
PCF5063X_REG_AUTOCTL, 0x0,
|
||||||
PCF5063X_REG_AUTOMXC, 0x59,
|
PCF5063X_REG_AUTOMXC, 0x59,
|
||||||
|
|
||||||
|
@ -257,7 +261,9 @@ void pmu_preinit(void)
|
||||||
PCF5063X_REG_GPOCFG, 0x1,
|
PCF5063X_REG_GPOCFG, 0x1,
|
||||||
/* LED converter OFF, overvoltage protection enabled,
|
/* LED converter OFF, overvoltage protection enabled,
|
||||||
OCP limit is 500 mA, led_dimstep = 16*0x6/32768 */
|
OCP limit is 500 mA, led_dimstep = 16*0x6/32768 */
|
||||||
|
#ifdef BOOTLOADER
|
||||||
PCF5063X_REG_LEDENA, 0x0,
|
PCF5063X_REG_LEDENA, 0x0,
|
||||||
|
#endif
|
||||||
PCF5063X_REG_LEDCTL, 0x5,
|
PCF5063X_REG_LEDCTL, 0x5,
|
||||||
PCF5063X_REG_LEDDIM, 0x6,
|
PCF5063X_REG_LEDDIM, 0x6,
|
||||||
|
|
||||||
|
@ -274,4 +280,3 @@ void pmu_preinit(void)
|
||||||
pmu_rd_multiple(PCF5063X_REG_INT1, 5, rd_buf);
|
pmu_rd_multiple(PCF5063X_REG_INT1, 5, rd_buf);
|
||||||
pmu_rd(PCF50635_REG_INT6);
|
pmu_rd(PCF50635_REG_INT6);
|
||||||
}
|
}
|
||||||
#endif /* BOOTLOADER */
|
|
||||||
|
|
|
@ -77,12 +77,12 @@ void pmu_read_rtc(unsigned char* buffer);
|
||||||
void pmu_write_rtc(unsigned char* buffer);
|
void pmu_write_rtc(unsigned char* buffer);
|
||||||
void pmu_hdd_power(bool on);
|
void pmu_hdd_power(bool on);
|
||||||
|
|
||||||
|
void pmu_preinit(void);
|
||||||
#ifdef BOOTLOADER
|
#ifdef BOOTLOADER
|
||||||
unsigned char pmu_rd(int address);
|
unsigned char pmu_rd(int address);
|
||||||
int pmu_wr(int address, unsigned char val);
|
int pmu_wr(int address, unsigned char val);
|
||||||
int pmu_rd_multiple(int address, int count, unsigned char* buffer);
|
int pmu_rd_multiple(int address, int count, unsigned char* buffer);
|
||||||
int pmu_wr_multiple(int address, int count, unsigned char* buffer);
|
int pmu_wr_multiple(int address, int count, unsigned char* buffer);
|
||||||
void pmu_preinit(void);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* __PMU_TARGET_H__ */
|
#endif /* __PMU_TARGET_H__ */
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
#include "panic.h"
|
#include "panic.h"
|
||||||
#include "system-target.h"
|
#include "system-target.h"
|
||||||
|
#include "i2c-s5l8702.h"
|
||||||
#include "pmu-target.h"
|
#include "pmu-target.h"
|
||||||
#include "uart-target.h"
|
#include "uart-target.h"
|
||||||
#include "gpio-s5l8702.h"
|
#include "gpio-s5l8702.h"
|
||||||
|
@ -199,6 +200,11 @@ enum {
|
||||||
void system_init(void)
|
void system_init(void)
|
||||||
{
|
{
|
||||||
clocking_init(clk_modes, 0);
|
clocking_init(clk_modes, 0);
|
||||||
|
#ifndef BOOTLOADER
|
||||||
|
gpio_preinit();
|
||||||
|
i2c_preinit(0);
|
||||||
|
pmu_preinit();
|
||||||
|
#endif
|
||||||
gpio_init();
|
gpio_init();
|
||||||
pmu_init();
|
pmu_init();
|
||||||
dma_init();
|
dma_init();
|
||||||
|
@ -279,7 +285,7 @@ void memory_init(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef BOOTLOADER
|
#ifdef BOOTLOADER
|
||||||
#include "i2c-s5l8702.h"
|
#include <stdbool.h>
|
||||||
|
|
||||||
static void syscon_preinit(void)
|
static void syscon_preinit(void)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue