aboutsummaryrefslogtreecommitdiff
path: root/src/mainboard/google/gru/pwm_regulator.c
diff options
context:
space:
mode:
authorJulius Werner <jwerner@chromium.org>2017-07-14 14:30:29 -0700
committerJulius Werner <jwerner@chromium.org>2017-07-19 18:15:15 +0000
commit6486e7819ccf4acf923d934d4293861f394cc065 (patch)
tree5b90d178a021829b9e268b9229b5e9e843668b32 /src/mainboard/google/gru/pwm_regulator.c
parent4ed8b305539f661895d9fa950bb32fc653e37f47 (diff)
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 <jwerner@chromium.org> Reviewed-on: https://review.coreboot.org/20587 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: David Schneider <dnschneid@chromium.org>
Diffstat (limited to 'src/mainboard/google/gru/pwm_regulator.c')
-rw-r--r--src/mainboard/google/gru/pwm_regulator.c27
1 files changed, 21 insertions, 6 deletions
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");
}
}