From 77acf42819ed93f77706089b024a771323d34c7a Mon Sep 17 00:00:00 2001 From: David Hendricks Date: Mon, 5 Aug 2013 21:04:16 -0700 Subject: pit: setup voltage rails before system clocks This moves the call to setup_power() before system_clock_init(). This causes the PMIC to set up the voltage rails earlier so that the CPU clock can be set up at a faster rate (in the follow-up patch). After system clock init, we re-initialize the PMIC's I2C bus since the input clock rate will have changed. Old-Change-Id: Ieb828ac25daad7ee95bfa4823aaaf161028c9c92 Reviewed-on: https://gerrit.chromium.org/gerrit/64744 Reviewed-by: Gabe Black Reviewed-by: Ronald G. Minnich Tested-by: David Hendricks Commit-Queue: David Hendricks (cherry picked from commit 6c133a84ef4a32c35577a266905e02af8c2d9278) pit: save setup_power() status and die later if needed Since system clock and console initialization now happen after power setup, we cannot print error messages in setup_power(). This patch re-factors the code a little bit to save the status of setup_power() so that if we get an error during setup_power() we will wait until we can actually print something before dying. Old-Change-Id: Id7ff477224b104b3c7e221c1d2df460ca9125f3b Reviewed-on: https://gerrit.chromium.org/gerrit/65009 Reviewed-by: Gabe Black Commit-Queue: David Hendricks Tested-by: David Hendricks (cherry picked from commit 0c89f922b20bc1291ac7ba7b2c22bdce911be7a4) Squashed two closely related commits. Change-Id: I3efe29412738959e698c89d26e682536ceabdff8 Signed-off-by: Isaac Christensen Reviewed-on: http://review.coreboot.org/6403 Tested-by: build bot (Jenkins) Reviewed-by: David Hendricks --- src/mainboard/google/pit/romstage.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/mainboard/google/pit/romstage.c b/src/mainboard/google/pit/romstage.c index c971d0cc90..7733eca1c7 100644 --- a/src/mainboard/google/pit/romstage.c +++ b/src/mainboard/google/pit/romstage.c @@ -42,6 +42,8 @@ #define MMC0_GPIO_PIN (58) +#define PMIC_I2C_BUS 4 + struct pmic_write { int or_orig; // Whether to or in the original value. @@ -75,7 +77,7 @@ struct pmic_write pmic_writes[] = { 0, MAX77802_REG_PMIC_BOOSTCTRL, MAX77802_BOOSTCTRL_OFF}, }; -static void setup_power(int is_resume) +static int setup_power(int is_resume) { int error = 0; int i; @@ -83,14 +85,12 @@ static void setup_power(int is_resume) power_init(); if (is_resume) { - return; + return 0; } /* Initialize I2C bus to configure PMIC. */ exynos_pinmux_i2c4(); - i2c_init(4, 1000000, 0x00); /* 1MHz */ - - printk(BIOS_DEBUG, "%s: Setting up PMIC...\n", __func__); + i2c_init(PMIC_I2C_BUS, 1000000, 0x00); /* 1MHz */ for (i = 0; i < ARRAY_SIZE(pmic_writes); i++) { uint8_t data = 0; @@ -106,8 +106,7 @@ static void setup_power(int is_resume) &data, sizeof(data)); } - if (error) - die("Failed to intialize PMIC.\n"); + return error; } static void setup_storage(void) @@ -245,6 +244,9 @@ void main(void) extern struct mem_timings mem_timings; void *entry; int is_resume = (get_wakeup_state() != IS_NOT_WAKEUP); + int power_init_failed; + + power_init_failed = setup_power(is_resume); /* Clock must be initialized before console_init, otherwise you may need * to re-initialize serial console drivers again. */ @@ -253,7 +255,12 @@ void main(void) exynos_pinmux_uart3(); console_init(); - setup_power(is_resume); + if (power_init_failed) + die("Failed to intialize power.\n"); + + /* re-initialize PMIC I2C channel after (re-)setting system clocks */ + i2c_init(PMIC_I2C_BUS, 1000000, 0x00); /* 1MHz */ + setup_memory(&mem_timings, is_resume); primitive_mem_test(); -- cgit v1.2.3