Angel Pons | 2e53038 | 2020-04-05 13:23:08 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
jinkun.hong | 692a2c0 | 2015-01-07 08:57:48 +0800 | [diff] [blame] | 2 | |
Kyösti Mälkki | 13f6650 | 2019-03-03 08:01:05 +0200 | [diff] [blame] | 3 | #include <device/mmio.h> |
jinkun.hong | 692a2c0 | 2015-01-07 08:57:48 +0800 | [diff] [blame] | 4 | #include <boot/coreboot_tables.h> |
| 5 | #include <console/console.h> |
jinkun.hong | 692a2c0 | 2015-01-07 08:57:48 +0800 | [diff] [blame] | 6 | #include <device/device.h> |
Nico Huber | 0f2dd1e | 2017-08-01 14:02:40 +0200 | [diff] [blame] | 7 | #include <device/i2c_simple.h> |
jinkun.hong | 692a2c0 | 2015-01-07 08:57:48 +0800 | [diff] [blame] | 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> |
Philipp Deppenwiese | fea2429 | 2017-10-17 17:02:29 +0200 | [diff] [blame] | 19 | #include <security/vboot/vboot_common.h> |
jinkun.hong | 692a2c0 | 2015-01-07 08:57:48 +0800 | [diff] [blame] | 20 | |
| 21 | #include "board.h" |
| 22 | |
| 23 | static void configure_usb(void) |
| 24 | { |
Alexandru M Stan | 3746465 | 2015-08-20 11:45:26 -0700 | [diff] [blame] | 25 | gpio_output(GPIO(0, B, 4), 1); /* USB2_PWR_EN */ |
jinkun.hong | 692a2c0 | 2015-01-07 08:57:48 +0800 | [diff] [blame] | 26 | } |
| 27 | |
| 28 | static void configure_emmc(void) |
| 29 | { |
Julius Werner | 2f37bd6 | 2015-02-19 14:51:15 -0800 | [diff] [blame] | 30 | write32(&rk3288_grf->iomux_emmcdata, IOMUX_EMMCDATA); |
| 31 | write32(&rk3288_grf->iomux_emmcpwren, IOMUX_EMMCPWREN); |
| 32 | write32(&rk3288_grf->iomux_emmccmd, IOMUX_EMMCCMD); |
jinkun.hong | 692a2c0 | 2015-01-07 08:57:48 +0800 | [diff] [blame] | 33 | |
| 34 | gpio_output(GPIO(2, B, 1), 1); /* EMMC_RST_L */ |
| 35 | } |
| 36 | |
| 37 | static void configure_codec(void) |
| 38 | { |
Julius Werner | 2f37bd6 | 2015-02-19 14:51:15 -0800 | [diff] [blame] | 39 | write32(&rk3288_grf->iomux_i2c2, IOMUX_I2C2); /* CODEC I2C */ |
jinkun.hong | 692a2c0 | 2015-01-07 08:57:48 +0800 | [diff] [blame] | 40 | i2c_init(2, 400*KHz); /* CODEC I2C */ |
| 41 | |
Julius Werner | 2f37bd6 | 2015-02-19 14:51:15 -0800 | [diff] [blame] | 42 | write32(&rk3288_grf->iomux_i2s, IOMUX_I2S); |
| 43 | write32(&rk3288_grf->iomux_i2sclk, IOMUX_I2SCLK); |
jinkun.hong | 692a2c0 | 2015-01-07 08:57:48 +0800 | [diff] [blame] | 44 | |
| 45 | rk808_configure_ldo(6, 1800); /* VCC18_CODEC */ |
| 46 | |
| 47 | /* AUDIO IO domain 1.8V voltage selection */ |
Julius Werner | 2f37bd6 | 2015-02-19 14:51:15 -0800 | [diff] [blame] | 48 | write32(&rk3288_grf->io_vsel, RK_SETBITS(1 << 6)); |
jinkun.hong | 692a2c0 | 2015-01-07 08:57:48 +0800 | [diff] [blame] | 49 | rkclk_configure_i2s(12288000); |
| 50 | } |
| 51 | |
David Hendricks | bf62b8c | 2015-08-05 14:13:34 -0700 | [diff] [blame] | 52 | static void configure_3g(void) |
| 53 | { |
| 54 | /* Force 3G modem off to avoid confusing the EHCI host and |
| 55 | * causing problems during enumeration/init */ |
| 56 | gpio_output(GPIO(5, C, 1), 1); /* 3G_SHUTDOWN */ |
| 57 | gpio_output(GPIO(4, D, 2), 0); /* 3G_ON_OFF */ |
| 58 | } |
| 59 | |
Elyes HAOUAS | d129d43 | 2018-05-04 20:23:33 +0200 | [diff] [blame] | 60 | static void mainboard_init(struct device *dev) |
jinkun.hong | 692a2c0 | 2015-01-07 08:57:48 +0800 | [diff] [blame] | 61 | { |
| 62 | gpio_output(GPIO_RESET, 0); |
| 63 | |
| 64 | configure_usb(); |
| 65 | configure_emmc(); |
| 66 | configure_codec(); |
David Hendricks | bf62b8c | 2015-08-05 14:13:34 -0700 | [diff] [blame] | 67 | configure_3g(); |
jinkun.hong | 692a2c0 | 2015-01-07 08:57:48 +0800 | [diff] [blame] | 68 | /* No video. */ |
David Hendricks | efe279d | 2015-02-02 17:23:29 -0800 | [diff] [blame] | 69 | |
David Hendricks | ccecd45 | 2015-09-25 15:27:46 -0700 | [diff] [blame] | 70 | /* If recovery mode is detected, reduce frequency and voltage to reduce |
| 71 | * heat in case machine is left unattended. chrome-os-partner:41201. */ |
Furquan Shaikh | 0325dc6 | 2016-07-25 13:02:36 -0700 | [diff] [blame] | 72 | if (vboot_recovery_mode_enabled()) { |
David Hendricks | ccecd45 | 2015-09-25 15:27:46 -0700 | [diff] [blame] | 73 | printk(BIOS_DEBUG, "Reducing APLL freq for recovery mode.\n"); |
| 74 | rkclk_configure_cpu(APLL_600_MHZ); |
| 75 | rk808_configure_buck(1, 900); |
| 76 | } |
jinkun.hong | 692a2c0 | 2015-01-07 08:57:48 +0800 | [diff] [blame] | 77 | } |
| 78 | |
Elyes HAOUAS | d129d43 | 2018-05-04 20:23:33 +0200 | [diff] [blame] | 79 | static void mainboard_enable(struct device *dev) |
jinkun.hong | 692a2c0 | 2015-01-07 08:57:48 +0800 | [diff] [blame] | 80 | { |
| 81 | dev->ops->init = &mainboard_init; |
| 82 | } |
| 83 | |
| 84 | struct chip_operations mainboard_ops = { |
| 85 | .enable_dev = mainboard_enable, |
| 86 | }; |
| 87 | |
| 88 | void lb_board(struct lb_header *header) |
| 89 | { |
| 90 | struct lb_range *dma; |
| 91 | |
| 92 | dma = (struct lb_range *)lb_new_record(header); |
Patrick Georgi | 68999a8 | 2019-05-23 12:44:00 +0200 | [diff] [blame] | 93 | dma->tag = LB_TAG_DMA; |
jinkun.hong | 692a2c0 | 2015-01-07 08:57:48 +0800 | [diff] [blame] | 94 | dma->size = sizeof(*dma); |
| 95 | dma->range_start = (uintptr_t)_dma_coherent; |
Julius Werner | 7e0dea6 | 2019-02-20 18:39:22 -0800 | [diff] [blame] | 96 | dma->range_size = REGION_SIZE(dma_coherent); |
jinkun.hong | 692a2c0 | 2015-01-07 08:57:48 +0800 | [diff] [blame] | 97 | } |
| 98 | |
| 99 | void mainboard_power_on_backlight(void) |
| 100 | { |
jinkun.hong | 692a2c0 | 2015-01-07 08:57:48 +0800 | [diff] [blame] | 101 | } |