payloads/edk2: Disable the CPU Timer Lib unless supported
[coreboot.git] / src / mainboard / google / veyron / mainboard.c
blob7d17bcc2c7bf3782e230889a4226e2fc0e6b5420
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <device/mmio.h>
4 #include <boot/coreboot_tables.h>
5 #include <delay.h>
6 #include <device/device.h>
7 #include <device/i2c_simple.h>
8 #include <edid.h>
9 #include <gpio.h>
10 #include <soc/display.h>
11 #include <soc/grf.h>
12 #include <soc/soc.h>
13 #include <soc/pmu.h>
14 #include <soc/clock.h>
15 #include <soc/rk808.h>
16 #include <soc/spi.h>
17 #include <soc/i2c.h>
18 #include <symbols.h>
20 #include "board.h"
22 static void configure_usb(void)
24 gpio_output(GPIO(0, B, 3), 1); /* HOST1_PWR_EN */
25 gpio_output(GPIO(0, B, 4), 1); /* USBOTG_PWREN_H */
26 gpio_output(GPIO(7, C, 5), 1); /* 5V_DRV */
29 static void configure_sdmmc(void)
31 write32(&rk3288_grf->iomux_sdmmc0, IOMUX_SDMMC0);
33 /* use sdmmc0 io, disable JTAG function */
34 write32(&rk3288_grf->soc_con0, RK_CLRBITS(1 << 12));
36 /* Note: these power rail definitions are copied in romstage.c */
37 rk808_configure_ldo(4, 3300); /* VCCIO_SD */
38 rk808_configure_ldo(5, 3300); /* VCC33_SD */
40 gpio_input(GPIO(7, A, 5)); /* SD_DET */
43 static void configure_emmc(void)
45 write32(&rk3288_grf->iomux_emmcdata, IOMUX_EMMCDATA);
46 write32(&rk3288_grf->iomux_emmcpwren, IOMUX_EMMCPWREN);
47 write32(&rk3288_grf->iomux_emmccmd, IOMUX_EMMCCMD);
49 gpio_output(GPIO(2, B, 1), 1); /* EMMC_RST_L */
52 static void configure_codec(void)
54 write32(&rk3288_grf->iomux_i2c2, IOMUX_I2C2); /* CODEC I2C */
55 i2c_init(2, 400*KHz); /* CODEC I2C */
57 write32(&rk3288_grf->iomux_i2s, IOMUX_I2S);
58 write32(&rk3288_grf->iomux_i2sclk, IOMUX_I2SCLK);
60 rk808_configure_ldo(6, 1800); /* VCC18_CODEC */
62 /* AUDIO IO domain 1.8V voltage selection */
63 write32(&rk3288_grf->io_vsel, RK_SETBITS(1 << 6));
64 rkclk_configure_i2s(12288000);
67 static void configure_vop(void)
69 write32(&rk3288_grf->iomux_lcdc, IOMUX_LCDC);
71 /* lcdc(vop) iodomain select 1.8V */
72 write32(&rk3288_grf->io_vsel, RK_SETBITS(1 << 0));
74 gpio_output(GPIO(2, B, 5), 1); /* AVDD_1V8_DISP_EN */
75 rk808_configure_ldo(7, 2500); /* VCC10_LCD_PWREN_H */
76 gpio_output(GPIO(7, B, 6), 1); /* LCD_EN */
77 rk808_configure_switch(1, 1); /* VCC33_LCD */
79 /* enable edp HPD */
80 gpio_input_pulldown(GPIO(7, B, 3));
81 write32(&rk3288_grf->iomux_edp_hotplug, IOMUX_EDP_HOTPLUG);
84 static void mainboard_init(struct device *dev)
86 gpio_output(GPIO_RESET, 0);
88 configure_usb();
89 configure_sdmmc();
90 configure_emmc();
91 configure_codec();
92 configure_vop();
95 static void mainboard_enable(struct device *dev)
97 dev->ops->init = &mainboard_init;
100 struct chip_operations mainboard_ops = {
101 .enable_dev = mainboard_enable,
104 void lb_board(struct lb_header *header)
106 struct lb_range *dma;
108 dma = (struct lb_range *)lb_new_record(header);
109 dma->tag = LB_TAG_DMA;
110 dma->size = sizeof(*dma);
111 dma->range_start = (uintptr_t)_dma_coherent;
112 dma->range_size = REGION_SIZE(dma_coherent);
115 void mainboard_power_on_backlight(void)
117 gpio_output(GPIO(2, B, 4), 1); /* BL_PWR_EN */
118 mdelay(120);
119 gpio_output(GPIO(7, A, 0), 1); /* LCD_BL */
120 mdelay(10);
121 gpio_output(GPIO_BACKLIGHT, 1); /* BL_EN */