diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2015-01-27 23:11:23 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2015-02-03 09:23:47 +0100 |
commit | 4d70da63a4847bebbaa4437ef78d4675ae44d0c1 (patch) | |
tree | 1814a0ba4871287fdc1a7ef5af6ec7bc08f350d7 /arch/arm/mach-mxs | |
parent | 1a63678cb2be569865079a5c2663dd4a454857aa (diff) | |
download | barebox-4d70da63a4847bebbaa4437ef78d4675ae44d0c1.tar.gz |
ARM: MXS: power-init: Add parameters to mx28_power_init()
Instead of introducing new functions each time a new power supply
situation is to be added, this patch adds parameters to mx28_power_init.
Right now there are three parameters:
- has_battery - true when this board has a battery.
- use_battery_input - true when this board is supplied from the
battery input, but has a DC source instead of a real battery
- use_5v_input - true when this board can use the 5V input
The third one is introduced with this patch and allow to boot a board from 5v
(USB) source only. The main necessary change this needs is that the DC-DC
converter must always be sourced from DCDC_4P2 (DROPOUT_CTRL field of
HW_POWER_DCDC4P2)
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/arm/mach-mxs')
-rw-r--r-- | arch/arm/mach-mxs/include/mach/init.h | 8 | ||||
-rw-r--r-- | arch/arm/mach-mxs/power-init.c | 67 |
2 files changed, 45 insertions, 30 deletions
diff --git a/arch/arm/mach-mxs/include/mach/init.h b/arch/arm/mach-mxs/include/mach/init.h index 1f9d8d48c0..90b413e47e 100644 --- a/arch/arm/mach-mxs/include/mach/init.h +++ b/arch/arm/mach-mxs/include/mach/init.h @@ -12,10 +12,10 @@ void mxs_early_delay(int delay); -void mx23_power_init(void); -void mx23_power_init_battery_input(void); -void mx28_power_init(void); -void mx28_power_init_battery_input(void); +void mx23_power_init(int __has_battery, int __use_battery_input, + int __use_5v_input); +void mx28_power_init(int __has_battery, int __use_battery_input, + int __use_5v_input); void mxs_power_wait_pswitch(void); extern uint32_t mx28_dram_vals[]; diff --git a/arch/arm/mach-mxs/power-init.c b/arch/arm/mach-mxs/power-init.c index 5d4d0892d8..595b51c5ba 100644 --- a/arch/arm/mach-mxs/power-init.c +++ b/arch/arm/mach-mxs/power-init.c @@ -24,6 +24,22 @@ #include <mach/regs-rtc.h> #include <mach/regs-lradc.h> +/* + * has_battery - true when this board has a battery. + */ +static int has_battery; + +/* + * use_battery_input - true when this board is supplied from the + * battery input, but has a DC source instead of a real battery + */ +static int use_battery_input; + +/* + * use_5v_input - true when this board can use the 5V input + */ +static int use_5v_input; + static void mxs_power_status(void) { struct mxs_power_regs *power_regs = @@ -472,7 +488,7 @@ static void mxs_power_enable_4p2(void) struct mxs_power_regs *power_regs = (struct mxs_power_regs *)IMX_POWER_BASE; uint32_t vdddctrl, vddactrl, vddioctrl; - uint32_t tmp, tmp2; + uint32_t tmp, tmp2, dropout_ctrl; vdddctrl = readl(&power_regs->hw_power_vdddctrl); vddactrl = readl(&power_regs->hw_power_vddactrl); @@ -498,10 +514,15 @@ static void mxs_power_enable_4p2(void) POWER_5VCTRL_HEADROOM_ADJ_MASK, 0x4 << POWER_5VCTRL_HEADROOM_ADJ_OFFSET); + if (has_battery || use_battery_input) + dropout_ctrl = POWER_DCDC4P2_DROPOUT_CTRL_SRC_SEL; + else + dropout_ctrl = POWER_DCDC4P2_DROPOUT_CTRL_SRC_4P2; + clrsetbits_le32(&power_regs->hw_power_dcdc4p2, POWER_DCDC4P2_DROPOUT_CTRL_MASK, POWER_DCDC4P2_DROPOUT_CTRL_100MV | - POWER_DCDC4P2_DROPOUT_CTRL_SRC_SEL); + dropout_ctrl); clrsetbits_le32(&power_regs->hw_power_5vctrl, POWER_5VCTRL_CHARGE_4P2_ILIMIT_MASK, @@ -1162,11 +1183,16 @@ static void mx23_ungate_power(void) * This function calls all the power block initialization functions in * proper sequence to start the power block. */ -static void __mx23_power_init(int has_battery) +void mx23_power_init(int __has_battery, int __use_battery_input, + int __use_5v_input) { struct mxs_power_regs *power_regs = (struct mxs_power_regs *)IMX_POWER_BASE; + has_battery = __has_battery; + use_battery_input = __use_battery_input; + use_5v_input = __use_5v_input; + mx23_ungate_power(); mxs_power_clock2xtal(); @@ -1180,8 +1206,10 @@ static void __mx23_power_init(int has_battery) if (has_battery) mxs_power_configure_power_source(); - else + else if (use_battery_input) mxs_enable_battery_input(); + else if (use_5v_input) + mxs_boot_valid_5v(); mxs_power_clock2pll(); @@ -1210,27 +1238,22 @@ static void __mx23_power_init(int has_battery) mxs_early_delay(1000); } -void mx23_power_init(void) -{ - __mx23_power_init(1); -} - -void mx23_power_init_battery_input(void) -{ - __mx23_power_init(0); -} - /** * mx28_power_init() - The power block init main function * * This function calls all the power block initialization functions in * proper sequence to start the power block. */ -static void __mx28_power_init(int has_battery) +void mx28_power_init(int __has_battery, int __use_battery_input, + int __use_5v_input) { struct mxs_power_regs *power_regs = (struct mxs_power_regs *)IMX_POWER_BASE; + has_battery = __has_battery; + use_battery_input = __use_battery_input; + use_5v_input = __use_5v_input; + mxs_power_status(); mxs_power_clock2xtal(); mxs_power_set_auto_restart(); @@ -1243,8 +1266,10 @@ static void __mx28_power_init(int has_battery) if (has_battery) mxs_power_configure_power_source(); - else + else if (use_battery_input) mxs_enable_battery_input(); + else if (use_5v_input) + mxs_boot_valid_5v(); mxs_power_clock2pll(); @@ -1270,16 +1295,6 @@ static void __mx28_power_init(int has_battery) mxs_power_status(); } -void mx28_power_init(void) -{ - __mx28_power_init(1); -} - -void mx28_power_init_battery_input(void) -{ - __mx28_power_init(0); -} - /** * mxs_power_wait_pswitch() - Wait for power switch to be pressed * |