From 6486e7819ccf4acf923d934d4293861f394cc065 Mon Sep 17 00:00:00 2001 From: Julius Werner Date: Fri, 14 Jul 2017 14:30:29 -0700 Subject: google/gru: Add support for Scarlet rev1 This patch adds the necessary changes to support Scarlet revision 1. Since the differences to revision 0 are so deep, we have decided not to continue support for it in the same image. Therefore, this patch will break Scarlet rev0. All the deviations from other Gru boards are currently guarded by CONFIG_BOARD_GOOGLE_SCARLET. This should be changed later if we introduce more variants based on the newer Scarlet board design. Change-Id: I7a7cc11d9387ac1d856663326e35cfa5371e0af2 Signed-off-by: Julius Werner Reviewed-on: https://review.coreboot.org/20587 Tested-by: build bot (Jenkins) Reviewed-by: David Schneider --- src/mainboard/google/gru/pwm_regulator.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'src/mainboard/google/gru/pwm_regulator.c') diff --git a/src/mainboard/google/gru/pwm_regulator.c b/src/mainboard/google/gru/pwm_regulator.c index b85f41ff45..696f09a206 100644 --- a/src/mainboard/google/gru/pwm_regulator.c +++ b/src/mainboard/google/gru/pwm_regulator.c @@ -47,10 +47,23 @@ int pwm_design_voltage[][2] = { [PWM_REGULATOR_CENTERLOG] = {7994, 10499} }; +int pwm_enum_to_pwm_number[] = { + [PWM_REGULATOR_GPU] = 0, + [PWM_REGULATOR_LIT] = 2, +#if IS_ENABLED(CONFIG_BOARD_GOOGLE_SCARLET) + [PWM_REGULATOR_BIG] = 3, + [PWM_REGULATOR_CENTERLOG] = -1, /* fixed regulator on Scarlet */ +#else + [PWM_REGULATOR_BIG] = 1, + [PWM_REGULATOR_CENTERLOG] = 3, +#endif +}; + void pwm_regulator_configure(enum pwm_regulator pwm, int millivolt) { int duty_ns, voltage_max, voltage_min; int voltage = millivolt * 10; /* for higer calculation accuracy */ + int pwm_number = pwm_enum_to_pwm_number[pwm]; voltage_min = pwm_design_voltage[pwm][0]; voltage_max = pwm_design_voltage[pwm][1]; @@ -75,24 +88,26 @@ void pwm_regulator_configure(enum pwm_regulator pwm, int millivolt) duty_ns = PWM_PERIOD * (voltage_max - voltage) / (voltage_max - voltage_min); - pwm_init(pwm, PWM_PERIOD, duty_ns); + pwm_init(pwm_number, PWM_PERIOD, duty_ns); - switch (pwm) { - case PWM_REGULATOR_GPU: + switch (pwm_number) { + case 0: gpio_input(GPIO(4, C, 2)); /* PWM0 remove pull-down */ write32(&rk3399_grf->iomux_pwm_0, IOMUX_PWM_0); break; - case PWM_REGULATOR_BIG: + case 1: gpio_input(GPIO(4, C, 6)); /* PWM1 remove pull-down */ write32(&rk3399_grf->iomux_pwm_1, IOMUX_PWM_1); break; - case PWM_REGULATOR_LIT: + case 2: gpio_input(GPIO(1, C, 3)); /* PWM2 remove pull-down */ write32(&rk3399_pmugrf->iomux_pwm_2, IOMUX_PWM_2); break; - case PWM_REGULATOR_CENTERLOG: + case 3: gpio_input(GPIO(0, A, 6)); /* PWM3 remove pull-down */ write32(&rk3399_pmugrf->iomux_pwm_3a, IOMUX_PWM_3_A); break; + default: + die("incorrect board configuration"); } } -- cgit v1.2.3