Angel Pons | 94d079ac | 2020-04-05 13:23:04 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
David Hendricks | 113ef81 | 2015-05-13 13:58:24 -0700 | [diff] [blame] | 2 | |
Kyösti Mälkki | 13f6650 | 2019-03-03 08:01:05 +0200 | [diff] [blame] | 3 | #include <device/mmio.h> |
David Hendricks | 113ef81 | 2015-05-13 13:58:24 -0700 | [diff] [blame] | 4 | #include <boot/coreboot_tables.h> |
David Hendricks | 113ef81 | 2015-05-13 13:58:24 -0700 | [diff] [blame] | 5 | #include <device/device.h> |
Nico Huber | 0f2dd1e | 2017-08-01 14:02:40 +0200 | [diff] [blame] | 6 | #include <device/i2c_simple.h> |
David Hendricks | 113ef81 | 2015-05-13 13:58:24 -0700 | [diff] [blame] | 7 | #include <edid.h> |
David Hendricks | 113ef81 | 2015-05-13 13:58:24 -0700 | [diff] [blame] | 8 | #include <gpio.h> |
| 9 | #include <soc/display.h> |
| 10 | #include <soc/grf.h> |
| 11 | #include <soc/soc.h> |
| 12 | #include <soc/pmu.h> |
| 13 | #include <soc/clock.h> |
| 14 | #include <soc/rk808.h> |
| 15 | #include <soc/spi.h> |
| 16 | #include <soc/i2c.h> |
| 17 | #include <symbols.h> |
David Hendricks | 113ef81 | 2015-05-13 13:58:24 -0700 | [diff] [blame] | 18 | |
| 19 | #include "board.h" |
| 20 | |
| 21 | static void configure_usb(void) |
| 22 | { |
| 23 | gpio_output(GPIO(0, B, 4), 1); /* USB2_PWR_EN */ |
| 24 | } |
| 25 | |
| 26 | static void configure_emmc(void) |
| 27 | { |
| 28 | write32(&rk3288_grf->iomux_emmcdata, IOMUX_EMMCDATA); |
| 29 | write32(&rk3288_grf->iomux_emmcpwren, IOMUX_EMMCPWREN); |
| 30 | write32(&rk3288_grf->iomux_emmccmd, IOMUX_EMMCCMD); |
| 31 | |
| 32 | gpio_output(GPIO(2, B, 1), 1); /* EMMC_RST_L */ |
| 33 | } |
| 34 | |
huang lin | ad8382a | 2015-06-04 16:41:27 +0800 | [diff] [blame] | 35 | static void configure_i2s(void) |
David Hendricks | 113ef81 | 2015-05-13 13:58:24 -0700 | [diff] [blame] | 36 | { |
David Hendricks | 113ef81 | 2015-05-13 13:58:24 -0700 | [diff] [blame] | 37 | write32(&rk3288_grf->iomux_i2s, IOMUX_I2S); |
| 38 | write32(&rk3288_grf->iomux_i2sclk, IOMUX_I2SCLK); |
| 39 | |
David Hendricks | 113ef81 | 2015-05-13 13:58:24 -0700 | [diff] [blame] | 40 | /* AUDIO IO domain 1.8V voltage selection */ |
| 41 | write32(&rk3288_grf->io_vsel, RK_SETBITS(1 << 6)); |
| 42 | rkclk_configure_i2s(12288000); |
| 43 | } |
| 44 | |
| 45 | static void configure_vop(void) |
| 46 | { |
| 47 | write32(&rk3288_grf->iomux_lcdc, IOMUX_LCDC); |
| 48 | |
| 49 | /* lcdc(vop) iodomain select 1.8V */ |
| 50 | write32(&rk3288_grf->io_vsel, RK_SETBITS(1 << 0)); |
| 51 | |
huang lin | ad8382a | 2015-06-04 16:41:27 +0800 | [diff] [blame] | 52 | rk808_configure_ldo(8, 1800); /* VCC18_LCD (HDMI_AVDD_1V8) */ |
David Hendricks | 113ef81 | 2015-05-13 13:58:24 -0700 | [diff] [blame] | 53 | rk808_configure_ldo(7, 1000); /* VDD10_LCD (HDMI_AVDD_1V0) */ |
| 54 | rk808_configure_switch(1, 1); /* VCC33_LCD */ |
| 55 | } |
| 56 | |
huang lin | ad8382a | 2015-06-04 16:41:27 +0800 | [diff] [blame] | 57 | static void configure_hdmi(void) |
| 58 | { |
huang lin | ad8382a | 2015-06-04 16:41:27 +0800 | [diff] [blame] | 59 | gpio_output(GPIO(7, B, 3), 1); /* POWER_HDMI_ON */ |
| 60 | } |
| 61 | |
Elyes HAOUAS | d129d43 | 2018-05-04 20:23:33 +0200 | [diff] [blame] | 62 | static void mainboard_init(struct device *dev) |
David Hendricks | 113ef81 | 2015-05-13 13:58:24 -0700 | [diff] [blame] | 63 | { |
| 64 | gpio_output(GPIO_RESET, 0); |
| 65 | |
| 66 | configure_usb(); |
| 67 | configure_emmc(); |
huang lin | ad8382a | 2015-06-04 16:41:27 +0800 | [diff] [blame] | 68 | configure_i2s(); |
David Hendricks | 113ef81 | 2015-05-13 13:58:24 -0700 | [diff] [blame] | 69 | configure_vop(); |
huang lin | ad8382a | 2015-06-04 16:41:27 +0800 | [diff] [blame] | 70 | configure_hdmi(); |
David Hendricks | 113ef81 | 2015-05-13 13:58:24 -0700 | [diff] [blame] | 71 | } |
| 72 | |
Elyes HAOUAS | d129d43 | 2018-05-04 20:23:33 +0200 | [diff] [blame] | 73 | static void mainboard_enable(struct device *dev) |
David Hendricks | 113ef81 | 2015-05-13 13:58:24 -0700 | [diff] [blame] | 74 | { |
| 75 | dev->ops->init = &mainboard_init; |
| 76 | } |
| 77 | |
| 78 | struct chip_operations mainboard_ops = { |
| 79 | .enable_dev = mainboard_enable, |
| 80 | }; |
| 81 | |
| 82 | void lb_board(struct lb_header *header) |
| 83 | { |
| 84 | struct lb_range *dma; |
| 85 | |
| 86 | dma = (struct lb_range *)lb_new_record(header); |
Patrick Georgi | 68999a8 | 2019-05-23 12:44:00 +0200 | [diff] [blame] | 87 | dma->tag = LB_TAG_DMA; |
David Hendricks | 113ef81 | 2015-05-13 13:58:24 -0700 | [diff] [blame] | 88 | dma->size = sizeof(*dma); |
| 89 | dma->range_start = (uintptr_t)_dma_coherent; |
Julius Werner | 7e0dea6 | 2019-02-20 18:39:22 -0800 | [diff] [blame] | 90 | dma->range_size = REGION_SIZE(dma_coherent); |
David Hendricks | 113ef81 | 2015-05-13 13:58:24 -0700 | [diff] [blame] | 91 | } |
huang lin | ad8382a | 2015-06-04 16:41:27 +0800 | [diff] [blame] | 92 | |
| 93 | void mainboard_power_on_backlight(void) |
| 94 | { |
| 95 | return; |
| 96 | } |