aboutsummaryrefslogtreecommitdiff
path: root/src/mainboard/google/gru/mainboard.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mainboard/google/gru/mainboard.c')
-rw-r--r--src/mainboard/google/gru/mainboard.c58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/mainboard/google/gru/mainboard.c b/src/mainboard/google/gru/mainboard.c
index 6824cbf546..0ccedd327e 100644
--- a/src/mainboard/google/gru/mainboard.c
+++ b/src/mainboard/google/gru/mainboard.c
@@ -15,11 +15,15 @@
*/
#include <boardid.h>
+#include <delay.h>
#include <device/device.h>
+#include <device/i2c.h>
#include <gpio.h>
#include <soc/clock.h>
+#include <soc/display.h>
#include <soc/emmc.h>
#include <soc/grf.h>
+#include <soc/i2c.h>
static void configure_emmc(void)
{
@@ -86,10 +90,64 @@ static void configure_sdmmc(void)
write32(&rk3399_grf->iomux_sdmmc, IOMUX_SDMMC);
}
+static void configure_display(void)
+{
+ /* set pinmux for edp HPD*/
+ gpio_input_pulldown(GPIO(4, C, 7));
+ write32(&rk3399_grf->iomux_edp_hotplug, IOMUX_EDP_HOTPLUG);
+
+ gpio_output(GPIO(4, D, 3), 1); /* CPU3_EDP_VDDEN for P3.3V_DISP */
+}
+
static void mainboard_init(device_t dev)
{
configure_sdmmc();
configure_emmc();
+ configure_display();
+}
+
+static void enable_backlight_booster(void)
+{
+ const struct {
+ uint8_t reg;
+ uint8_t value;
+ } i2c_writes[] = {
+ {1, 0x84},
+ {1, 0x85},
+ {0, 0x26}
+ };
+ int i;
+ const int booster_i2c_port = 0;
+ uint8_t i2c_buf[2];
+ struct i2c_seg i2c_command = { .read = 0, .chip = 0x2c,
+ .buf = i2c_buf, .len = sizeof(i2c_buf)
+ };
+
+ /*
+ * This function is called on Gru right after BL_EN is asserted. It
+ * takes time for the switcher chip to come online, let's wait a bit
+ * to let the voltage settle, so that the chip can be accessed.
+ */
+ udelay(1000);
+
+ /* Select pinmux for i2c0, which is the display backlight booster. */
+ write32(&rk3399_pmugrf->iomux_i2c0_sda, IOMUX_I2C0_SDA);
+ write32(&rk3399_pmugrf->iomux_i2c0_scl, IOMUX_I2C0_SCL);
+ i2c_init(0, 100*KHz);
+
+ for (i = 0; i < ARRAY_SIZE(i2c_writes); i++) {
+ i2c_buf[0] = i2c_writes[i].reg;
+ i2c_buf[1] = i2c_writes[i].value;
+ i2c_transfer(booster_i2c_port, &i2c_command, 1);
+ }
+}
+
+void mainboard_power_on_backlight(void)
+{
+ gpio_output(GPIO(1, C, 1), 1); /* BL_EN */
+
+ if (IS_ENABLED(CONFIG_BOARD_GOOGLE_GRU))
+ enable_backlight_booster();
}
static void mainboard_enable(device_t dev)