From 2b1159dda06b7c47e7c208a521c3ca8114da78a9 Mon Sep 17 00:00:00 2001 From: Amaury Pouly Date: Sat, 29 Dec 2012 01:33:55 +0100 Subject: [PATCH] imx233: move power init to system init Do low level power init in system_init(). This can be needed since imx233 must be able to frequecy scale atfer system_init() and kernel_init() and this is only possible if power system was initialised. Change-Id: I27c66ec0dccd60bda26a45be24683c0bfe72c6da --- firmware/target/arm/imx233/power-imx233.c | 6 +++++- firmware/target/arm/imx233/power-imx233.h | 2 ++ firmware/target/arm/imx233/system-imx233.c | 15 +++++++++++---- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/firmware/target/arm/imx233/power-imx233.c b/firmware/target/arm/imx233/power-imx233.c index 186256f7b8..49323f6ffd 100644 --- a/firmware/target/arm/imx233/power-imx233.c +++ b/firmware/target/arm/imx233/power-imx233.c @@ -81,7 +81,7 @@ void INT_VDD5V(void) } } -void power_init(void) +void imx233_power_init(void) { /* setup vbusvalid parameters: set threshold to 4v and power up comparators */ __REG_CLR(HW_POWER_5VCTRL) = HW_POWER_5VCTRL__VBUSVALID_TRSH_BM; @@ -110,6 +110,10 @@ void power_init(void) __FIELD_SET(HW_POWER_LOOPCTRL, EN_RCSCALE, HW_POWER_LOOPCTRL__EN_RCSCALE__2X); } +void power_init(void) +{ +} + void power_off(void) { /* wait a bit, useful for the user to stop touching anything */ diff --git a/firmware/target/arm/imx233/power-imx233.h b/firmware/target/arm/imx233/power-imx233.h index 786a450972..5379326969 100644 --- a/firmware/target/arm/imx233/power-imx233.h +++ b/firmware/target/arm/imx233/power-imx233.h @@ -177,6 +177,8 @@ #define HW_POWER_RESET__UNLOCK 0x3E770000 #define HW_POWER_RESET__PWD 0x1 +void imx233_power_init(void); + void imx233_power_set_charge_current(unsigned current); /* in mA */ void imx233_power_set_stop_current(unsigned current); /* in mA */ void imx233_power_enable_batadj(bool enable); diff --git a/firmware/target/arm/imx233/system-imx233.c b/firmware/target/arm/imx233/system-imx233.c index 85a6a96402..1d75cd4c9c 100644 --- a/firmware/target/arm/imx233/system-imx233.c +++ b/firmware/target/arm/imx233/system-imx233.c @@ -101,6 +101,10 @@ void memory_init(void) void system_init(void) { + /* NOTE: don't use anything here that might require tick task ! + * It is initialized by kernel_init *after* system_init(). + * The main() will naturally set cpu speed to normal after kernel_init() + * so don't bother if the cpu is running at 24MHz here. */ imx233_clkctrl_enable_clock(CLK_PLL, true); imx233_rtc_init(); imx233_icoll_init(); @@ -111,11 +115,9 @@ void system_init(void) imx233_dcp_init(); imx233_pwm_init(); imx233_lradc_init(); + imx233_power_init(); imx233_i2c_init(); -#if !defined(BOOTLOADER) &&(defined(SANSA_FUZEPLUS) || \ - defined(CREATIVE_ZENXFI3) || defined(CREATIVE_ZENXFI2)) - fmradio_i2c_init(); -#endif + imx233_clkctrl_enable_auto_slow_monitor(AS_CPU_INSTR, true); imx233_clkctrl_enable_auto_slow_monitor(AS_CPU_DATA, true); imx233_clkctrl_enable_auto_slow_monitor(AS_TRAFFIC, true); @@ -124,6 +126,11 @@ void system_init(void) imx233_clkctrl_enable_auto_slow_monitor(AS_APBHDMA, true); imx233_clkctrl_set_auto_slow_divisor(AS_DIV_8); imx233_clkctrl_enable_auto_slow(true); + +#if !defined(BOOTLOADER) &&(defined(SANSA_FUZEPLUS) || \ + defined(CREATIVE_ZENXFI3) || defined(CREATIVE_ZENXFI2)) + fmradio_i2c_init(); +#endif } bool imx233_us_elapsed(uint32_t ref, unsigned us_delay)