rk3288: support edp HPD function
[coreboot.git] / src / mainboard / google / veyron_jerry / mainboard.c
blob937b1ad1e6677feb3d8915d1b5713d29a2aa8875
1 /*
2 * This file is part of the coreboot project.
4 * Copyright 2014 Rockchip Inc.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 #include <arch/cache.h>
21 #include <arch/io.h>
22 #include <boot/coreboot_tables.h>
23 #include <console/console.h>
24 #include <delay.h>
25 #include <device/device.h>
26 #include <device/i2c.h>
27 #include <edid.h>
28 #include <gpio.h>
29 #include <soc/display.h>
30 #include <soc/grf.h>
31 #include <soc/soc.h>
32 #include <soc/pmu.h>
33 #include <soc/clock.h>
34 #include <soc/rk808.h>
35 #include <soc/spi.h>
36 #include <soc/i2c.h>
37 #include <symbols.h>
38 #include <vbe.h>
40 #include "board.h"
42 static void configure_usb(void)
44 gpio_output(GPIO(0, B, 3), 1); /* HOST1_PWR_EN */
45 gpio_output(GPIO(0, B, 4), 1); /* USBOTG_PWREN_H */
46 gpio_output(GPIO(7, C, 5), 1); /* 5V_DRV */
49 static void configure_sdmmc(void)
51 writel(IOMUX_SDMMC0, &rk3288_grf->iomux_sdmmc0);
53 /* use sdmmc0 io, disable JTAG function */
54 writel(RK_CLRBITS(1 << 12), &rk3288_grf->soc_con0);
56 /* Note: these power rail definitions are copied in romstage.c */
57 rk808_configure_ldo(4, 3300); /* VCCIO_SD */
58 rk808_configure_ldo(5, 3300); /* VCC33_SD */
60 gpio_input(GPIO(7, A, 5)); /* SD_DET */
63 static void configure_emmc(void)
65 writel(IOMUX_EMMCDATA, &rk3288_grf->iomux_emmcdata);
66 writel(IOMUX_EMMCPWREN, &rk3288_grf->iomux_emmcpwren);
67 writel(IOMUX_EMMCCMD, &rk3288_grf->iomux_emmccmd);
69 gpio_output(GPIO(2, B, 1), 1); /* EMMC_RST_L */
72 static void configure_codec(void)
74 writel(IOMUX_I2C2, &rk3288_grf->iomux_i2c2); /* CODEC I2C */
75 i2c_init(2, 400*KHz); /* CODEC I2C */
77 writel(IOMUX_I2S, &rk3288_grf->iomux_i2s);
78 writel(IOMUX_I2SCLK, &rk3288_grf->iomux_i2sclk);
80 rk808_configure_ldo(6, 1800); /* VCC18_CODEC */
82 /* AUDIO IO domain 1.8V voltage selection */
83 writel(RK_SETBITS(1 << 6), &rk3288_grf->io_vsel);
84 rkclk_configure_i2s(12288000);
87 static void configure_vop(void)
89 writel(IOMUX_LCDC, &rk3288_grf->iomux_lcdc);
91 /* lcdc(vop) iodomain select 1.8V */
92 writel(RK_SETBITS(1 << 0), &rk3288_grf->io_vsel);
94 switch (board_id()) {
95 case 2:
96 rk808_configure_switch(2, 1); /* VCC18_LCD */
97 rk808_configure_ldo(7, 2500); /* VCC10_LCD_PWREN_H */
98 rk808_configure_switch(1, 1); /* VCC33_LCD */
99 break;
100 default:
101 gpio_output(GPIO(2, B, 5), 1); /* AVDD_1V8_DISP_EN */
102 rk808_configure_ldo(7, 2500); /* VCC10_LCD_PWREN_H */
103 gpio_output(GPIO(7, B, 6), 1); /* LCD_EN */
104 rk808_configure_switch(1, 1); /* VCC33_LCD */
106 /* enable edp HPD */
107 gpio_input_pulldown(GPIO(7, B, 3));
108 writel(IOMUX_EDP_HOTPLUG, &rk3288_grf->iomux_edp_hotplug);
109 break;
113 static void mainboard_init(device_t dev)
115 gpio_output(GPIO_RESET, 0);
117 configure_usb();
118 configure_sdmmc();
119 configure_emmc();
120 configure_codec();
121 configure_vop();
124 static void mainboard_enable(device_t dev)
126 dev->ops->init = &mainboard_init;
129 struct chip_operations mainboard_ops = {
130 .enable_dev = mainboard_enable,
133 void lb_board(struct lb_header *header)
135 struct lb_range *dma;
137 dma = (struct lb_range *)lb_new_record(header);
138 dma->tag = LB_TAB_DMA;
139 dma->size = sizeof(*dma);
140 dma->range_start = (uintptr_t)_dma_coherent;
141 dma->range_size = _dma_coherent_size;
144 void mainboard_power_on_backlight(void)
146 switch (board_id()) {
147 case 2:
148 gpio_output(GPIO_BACKLIGHT, 0); /* BL_EN */
149 gpio_output(GPIO(7, A, 2), 1); /* LCD_BL */
150 mdelay(10);
151 gpio_output(GPIO_BACKLIGHT, 1); /* BL_EN */
152 break;
153 default:
154 gpio_output(GPIO(2, B, 4), 1); /* BL_PWR_EN */
155 mdelay(20);
156 gpio_output(GPIO_BACKLIGHT, 1); /* LCD_BL */
157 mdelay(10);
158 gpio_output(GPIO(7, A, 2), 1); /* BL_EN */
159 break;