blob: 9024b6c66a9e9d5371430001422afe4354cb3a02 [file] [log] [blame]
David Hendricks113ef812015-05-13 13:58:24 -07001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright 2014 Rockchip Inc.
5 *
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.
9 *
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.
David Hendricks113ef812015-05-13 13:58:24 -070014 */
15
16#include <arch/cache.h>
Kyösti Mälkki13f66502019-03-03 08:01:05 +020017#include <device/mmio.h>
David Hendricks113ef812015-05-13 13:58:24 -070018#include <boot/coreboot_tables.h>
David Hendricks113ef812015-05-13 13:58:24 -070019#include <device/device.h>
Nico Huber0f2dd1e2017-08-01 14:02:40 +020020#include <device/i2c_simple.h>
David Hendricks113ef812015-05-13 13:58:24 -070021#include <edid.h>
22#include <elog.h>
23#include <gpio.h>
24#include <soc/display.h>
25#include <soc/grf.h>
26#include <soc/soc.h>
27#include <soc/pmu.h>
28#include <soc/clock.h>
29#include <soc/rk808.h>
30#include <soc/spi.h>
31#include <soc/i2c.h>
32#include <symbols.h>
33#include <vbe.h>
34#include <vendorcode/google/chromeos/chromeos.h>
35
36#include "board.h"
37
38static void configure_usb(void)
39{
40 gpio_output(GPIO(0, B, 4), 1); /* USB2_PWR_EN */
41}
42
43static void configure_emmc(void)
44{
45 write32(&rk3288_grf->iomux_emmcdata, IOMUX_EMMCDATA);
46 write32(&rk3288_grf->iomux_emmcpwren, IOMUX_EMMCPWREN);
47 write32(&rk3288_grf->iomux_emmccmd, IOMUX_EMMCCMD);
48
49 gpio_output(GPIO(2, B, 1), 1); /* EMMC_RST_L */
50}
51
huang linad8382a2015-06-04 16:41:27 +080052static void configure_i2s(void)
David Hendricks113ef812015-05-13 13:58:24 -070053{
David Hendricks113ef812015-05-13 13:58:24 -070054 write32(&rk3288_grf->iomux_i2s, IOMUX_I2S);
55 write32(&rk3288_grf->iomux_i2sclk, IOMUX_I2SCLK);
56
David Hendricks113ef812015-05-13 13:58:24 -070057 /* AUDIO IO domain 1.8V voltage selection */
58 write32(&rk3288_grf->io_vsel, RK_SETBITS(1 << 6));
59 rkclk_configure_i2s(12288000);
60}
61
62static void configure_vop(void)
63{
64 write32(&rk3288_grf->iomux_lcdc, IOMUX_LCDC);
65
66 /* lcdc(vop) iodomain select 1.8V */
67 write32(&rk3288_grf->io_vsel, RK_SETBITS(1 << 0));
68
huang linad8382a2015-06-04 16:41:27 +080069 rk808_configure_ldo(8, 1800); /* VCC18_LCD (HDMI_AVDD_1V8) */
David Hendricks113ef812015-05-13 13:58:24 -070070 rk808_configure_ldo(7, 1000); /* VDD10_LCD (HDMI_AVDD_1V0) */
71 rk808_configure_switch(1, 1); /* VCC33_LCD */
72}
73
huang linad8382a2015-06-04 16:41:27 +080074static void configure_hdmi(void)
75{
huang linad8382a2015-06-04 16:41:27 +080076 gpio_output(GPIO(7, B, 3), 1); /* POWER_HDMI_ON */
77}
78
Elyes HAOUASd129d432018-05-04 20:23:33 +020079static void mainboard_init(struct device *dev)
David Hendricks113ef812015-05-13 13:58:24 -070080{
81 gpio_output(GPIO_RESET, 0);
82
83 configure_usb();
84 configure_emmc();
huang linad8382a2015-06-04 16:41:27 +080085 configure_i2s();
David Hendricks113ef812015-05-13 13:58:24 -070086 configure_vop();
huang linad8382a2015-06-04 16:41:27 +080087 configure_hdmi();
David Hendricks113ef812015-05-13 13:58:24 -070088}
89
Elyes HAOUASd129d432018-05-04 20:23:33 +020090static void mainboard_enable(struct device *dev)
David Hendricks113ef812015-05-13 13:58:24 -070091{
92 dev->ops->init = &mainboard_init;
93}
94
95struct chip_operations mainboard_ops = {
96 .enable_dev = mainboard_enable,
97};
98
99void lb_board(struct lb_header *header)
100{
101 struct lb_range *dma;
102
103 dma = (struct lb_range *)lb_new_record(header);
Patrick Georgi68999a82019-05-23 12:44:00 +0200104 dma->tag = LB_TAG_DMA;
David Hendricks113ef812015-05-13 13:58:24 -0700105 dma->size = sizeof(*dma);
106 dma->range_start = (uintptr_t)_dma_coherent;
Julius Werner7e0dea62019-02-20 18:39:22 -0800107 dma->range_size = REGION_SIZE(dma_coherent);
David Hendricks113ef812015-05-13 13:58:24 -0700108}
huang linad8382a2015-06-04 16:41:27 +0800109
110void mainboard_power_on_backlight(void)
111{
112 return;
113}