summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--firmware/export/i2c-s5l8702.h2
-rw-r--r--firmware/target/arm/s5l8702/clocking-s5l8702.c16
-rw-r--r--firmware/target/arm/s5l8702/clocking-s5l8702.h2
-rw-r--r--firmware/target/arm/s5l8702/gpio-s5l8702.c2
-rw-r--r--firmware/target/arm/s5l8702/gpio-s5l8702.h2
-rw-r--r--firmware/target/arm/s5l8702/i2c-s5l8702.c5
-rw-r--r--firmware/target/arm/s5l8702/ipod6g/pmu-ipod6g.c9
-rw-r--r--firmware/target/arm/s5l8702/ipod6g/pmu-target.h2
-rw-r--r--firmware/target/arm/s5l8702/system-s5l8702.c8
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);
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);
-#ifdef BOOTLOADER
void i2c_preinit(int bus);
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);
-#endif
#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)
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
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);
}
-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,
* this clock should be initialized by the bootloader, so USEC_TIMER
* 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
void clocking_init(struct clocking_mode *modes, int init_level);
void set_clocking_level(int level);
unsigned get_system_freqs(unsigned *cclk, unsigned *hclk, unsigned *pclk);
+void clockgate_enable(int gate, bool enable);
/* debug */
unsigned pll_get_cfg_freq(int pll);
@@ -437,7 +438,6 @@ int soc_get_hsdiv(void);
#include <stdbool.h>
void usec_timer_init(void);
-void clockgate_enable(int gate, bool enable);
void soc_set_system_divs(unsigned cdiv, unsigned hdiv, unsigned hprat);
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)
}
#endif
-#ifdef BOOTLOADER
static uint32_t gpio_data[16] =
{
0x5322222F, 0xEEEEEE00, 0x2332EEEE, 0x3333E222,
@@ -232,4 +231,3 @@ void gpio_preinit(void)
PUNC(i) = 0;
}
}
-#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);
uint32_t gpio_group_get(int group);
void gpio_group_set(int group, uint32_t mask, uint32_t cfg);
-#ifdef BOOTLOADER
void gpio_preinit(void);
-#endif
#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 @@
#include "system.h"
#include "kernel.h"
#include "i2c-s5l8702.h"
+#include "clocking-s5l8702.h"
/* 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;
}
-#ifdef BOOTLOADER
-#include "clocking-s5l8702.h"
-
static void wait_rdy(int bus)
{
while (IICUNK10(bus));
@@ -206,4 +204,3 @@ void i2c_preinit(int bus)
wait_rdy(bus);
clockgate_enable(I2CCLKGATE(bus), false);
}
-#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)
pmu_write_multiple(0x59, 7, buffer);
}
-#ifdef BOOTLOADER
+/*
+ * preinit
+ */
int pmu_rd_multiple(int address, int count, unsigned char* buffer)
{
return i2c_rd(0, 0xe6, address, count, buffer);
@@ -225,7 +227,9 @@ void pmu_preinit(void)
/* AUTOLDO (HDD): 3400 mV, disabled,
limit = 1000 mA (40mA*0x19), limit always active */
PCF5063X_REG_AUTOOUT, 0x6f,
+#ifdef BOOTLOADER
PCF5063X_REG_AUTOENA, 0x0,
+#endif
PCF5063X_REG_AUTOCTL, 0x0,
PCF5063X_REG_AUTOMXC, 0x59,
@@ -257,7 +261,9 @@ void pmu_preinit(void)
PCF5063X_REG_GPOCFG, 0x1,
/* LED converter OFF, overvoltage protection enabled,
OCP limit is 500 mA, led_dimstep = 16*0x6/32768 */
+#ifdef BOOTLOADER
PCF5063X_REG_LEDENA, 0x0,
+#endif
PCF5063X_REG_LEDCTL, 0x5,
PCF5063X_REG_LEDDIM, 0x6,
@@ -274,4 +280,3 @@ void pmu_preinit(void)
pmu_rd_multiple(PCF5063X_REG_INT1, 5, rd_buf);
pmu_rd(PCF50635_REG_INT6);
}
-#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);
void pmu_write_rtc(unsigned char* buffer);
void pmu_hdd_power(bool on);
+void pmu_preinit(void);
#ifdef BOOTLOADER
unsigned char pmu_rd(int address);
int pmu_wr(int address, unsigned char val);
int pmu_rd_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 /* __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 @@
#include "system.h"
#include "panic.h"
#include "system-target.h"
+#include "i2c-s5l8702.h"
#include "pmu-target.h"
#include "uart-target.h"
#include "gpio-s5l8702.h"
@@ -199,6 +200,11 @@ enum {
void system_init(void)
{
clocking_init(clk_modes, 0);
+#ifndef BOOTLOADER
+ gpio_preinit();
+ i2c_preinit(0);
+ pmu_preinit();
+#endif
gpio_init();
pmu_init();
dma_init();
@@ -279,7 +285,7 @@ void memory_init(void)
}
#ifdef BOOTLOADER
-#include "i2c-s5l8702.h"
+#include <stdbool.h>
static void syscon_preinit(void)
{