Patrick Georgi | 0232549 | 2015-07-01 21:56:47 +0200 | [diff] [blame] | 1 | /* |
| 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. |
Patrick Georgi | 0232549 | 2015-07-01 21:56:47 +0200 | [diff] [blame] | 14 | */ |
| 15 | |
| 16 | #include <arch/cache.h> |
| 17 | #include <arch/io.h> |
| 18 | #include <boot/coreboot_tables.h> |
| 19 | #include <console/console.h> |
| 20 | #include <delay.h> |
| 21 | #include <device/device.h> |
| 22 | #include <device/i2c.h> |
| 23 | #include <edid.h> |
| 24 | #include <elog.h> |
| 25 | #include <gpio.h> |
| 26 | #include <soc/display.h> |
| 27 | #include <soc/grf.h> |
| 28 | #include <soc/soc.h> |
| 29 | #include <soc/pmu.h> |
| 30 | #include <soc/clock.h> |
| 31 | #include <soc/rk808.h> |
| 32 | #include <soc/spi.h> |
| 33 | #include <soc/i2c.h> |
| 34 | #include <symbols.h> |
| 35 | #include <vbe.h> |
| 36 | #include <vendorcode/google/chromeos/chromeos.h> |
| 37 | |
| 38 | #include "board.h" |
| 39 | |
| 40 | static void configure_usb(void) |
| 41 | { |
| 42 | gpio_output(GPIO(0, B, 3), 1); /* HOST1_PWR_EN */ |
| 43 | gpio_output(GPIO(0, B, 4), 1); /* USBOTG_PWREN_H */ |
| 44 | gpio_output(GPIO(7, C, 5), 1); /* 5V_DRV */ |
| 45 | } |
| 46 | |
| 47 | static void configure_sdmmc(void) |
| 48 | { |
| 49 | write32(&rk3288_grf->iomux_sdmmc0, IOMUX_SDMMC0); |
| 50 | |
| 51 | /* use sdmmc0 io, disable JTAG function */ |
| 52 | write32(&rk3288_grf->soc_con0, RK_CLRBITS(1 << 12)); |
| 53 | |
| 54 | /* Note: these power rail definitions are copied in romstage.c */ |
| 55 | rk808_configure_ldo(4, 3300); /* VCCIO_SD */ |
| 56 | rk808_configure_ldo(5, 3300); /* VCC33_SD */ |
| 57 | |
| 58 | gpio_input(GPIO(7, A, 5)); /* SD_DET */ |
| 59 | } |
| 60 | |
| 61 | static void configure_emmc(void) |
| 62 | { |
| 63 | write32(&rk3288_grf->iomux_emmcdata, IOMUX_EMMCDATA); |
| 64 | write32(&rk3288_grf->iomux_emmcpwren, IOMUX_EMMCPWREN); |
| 65 | write32(&rk3288_grf->iomux_emmccmd, IOMUX_EMMCCMD); |
| 66 | |
| 67 | gpio_output(GPIO(2, B, 1), 1); /* EMMC_RST_L */ |
| 68 | } |
| 69 | |
| 70 | static void configure_codec(void) |
| 71 | { |
| 72 | write32(&rk3288_grf->iomux_i2c2, IOMUX_I2C2); /* CODEC I2C */ |
| 73 | i2c_init(2, 400*KHz); /* CODEC I2C */ |
| 74 | |
| 75 | write32(&rk3288_grf->iomux_i2s, IOMUX_I2S); |
| 76 | write32(&rk3288_grf->iomux_i2sclk, IOMUX_I2SCLK); |
| 77 | |
| 78 | rk808_configure_ldo(6, 1800); /* VCC18_CODEC */ |
| 79 | |
| 80 | /* AUDIO IO domain 1.8V voltage selection */ |
| 81 | write32(&rk3288_grf->io_vsel, RK_SETBITS(1 << 6)); |
| 82 | rkclk_configure_i2s(12288000); |
| 83 | } |
| 84 | |
| 85 | static void configure_vop(void) |
| 86 | { |
| 87 | write32(&rk3288_grf->iomux_lcdc, IOMUX_LCDC); |
| 88 | |
| 89 | /* lcdc(vop) iodomain select 1.8V */ |
| 90 | write32(&rk3288_grf->io_vsel, RK_SETBITS(1 << 0)); |
| 91 | |
| 92 | gpio_output(GPIO(2, B, 5), 1); /* AVDD_1V8_DISP_EN */ |
| 93 | rk808_configure_ldo(7, 2500); /* VCC10_LCD_PWREN_H */ |
| 94 | gpio_output(GPIO(7, B, 6), 1); /* LCD_EN */ |
| 95 | rk808_configure_switch(1, 1); /* VCC33_LCD */ |
| 96 | |
| 97 | /* enable edp HPD */ |
| 98 | gpio_input_pulldown(GPIO(7, B, 3)); |
| 99 | write32(&rk3288_grf->iomux_edp_hotplug, IOMUX_EDP_HOTPLUG); |
| 100 | } |
| 101 | |
| 102 | static void mainboard_init(device_t dev) |
| 103 | { |
| 104 | gpio_output(GPIO_RESET, 0); |
| 105 | |
| 106 | configure_usb(); |
| 107 | configure_sdmmc(); |
| 108 | configure_emmc(); |
| 109 | configure_codec(); |
| 110 | configure_vop(); |
| 111 | |
| 112 | elog_init(); |
| 113 | elog_add_watchdog_reset(); |
| 114 | elog_add_boot_reason(); |
| 115 | } |
| 116 | |
| 117 | static void mainboard_enable(device_t dev) |
| 118 | { |
| 119 | dev->ops->init = &mainboard_init; |
| 120 | } |
| 121 | |
| 122 | struct chip_operations mainboard_ops = { |
| 123 | .enable_dev = mainboard_enable, |
| 124 | }; |
| 125 | |
| 126 | void lb_board(struct lb_header *header) |
| 127 | { |
| 128 | struct lb_range *dma; |
| 129 | |
| 130 | dma = (struct lb_range *)lb_new_record(header); |
| 131 | dma->tag = LB_TAB_DMA; |
| 132 | dma->size = sizeof(*dma); |
| 133 | dma->range_start = (uintptr_t)_dma_coherent; |
| 134 | dma->range_size = _dma_coherent_size; |
| 135 | } |
| 136 | |
| 137 | void mainboard_power_on_backlight(void) |
| 138 | { |
| 139 | gpio_output(GPIO(2, B, 4), 1); /* BL_PWR_EN */ |
Julius Werner | dd07ef2 | 2015-08-28 14:34:09 -0700 | [diff] [blame] | 140 | mdelay(120); |
Patrick Georgi | 0232549 | 2015-07-01 21:56:47 +0200 | [diff] [blame] | 141 | gpio_output(GPIO(7, A, 0), 1); /* LCD_BL */ |
| 142 | mdelay(10); |
| 143 | gpio_output(GPIO_BACKLIGHT, 1); /* BL_EN */ |
| 144 | } |