Katie Roberts-Hoffman | b262c72 | 2014-10-23 19:14:30 -0700 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright 2014 Rockchip Inc. |
| 5 | * Copyright 2014 Google Inc. |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; version 2 of the License. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
Katie Roberts-Hoffman | b262c72 | 2014-10-23 19:14:30 -0700 | [diff] [blame] | 15 | */ |
| 16 | |
| 17 | #include <arch/io.h> |
Julius Werner | df5bf2b | 2014-11-25 13:36:17 -0800 | [diff] [blame] | 18 | #include <assert.h> |
Katie Roberts-Hoffman | b262c72 | 2014-10-23 19:14:30 -0700 | [diff] [blame] | 19 | #include <bootblock_common.h> |
Julius Werner | 2460a55 | 2014-11-24 13:50:46 -0800 | [diff] [blame] | 20 | #include <console/console.h> |
Julius Werner | 63451c7 | 2014-11-10 19:53:45 -0800 | [diff] [blame] | 21 | #include <delay.h> |
Julius Werner | 2460a55 | 2014-11-24 13:50:46 -0800 | [diff] [blame] | 22 | #include <reset.h> |
Katie Roberts-Hoffman | b262c72 | 2014-10-23 19:14:30 -0700 | [diff] [blame] | 23 | #include <soc/clock.h> |
| 24 | #include <soc/i2c.h> |
| 25 | #include <soc/grf.h> |
| 26 | #include <soc/pmu.h> |
| 27 | #include <soc/rk808.h> |
| 28 | #include <soc/spi.h> |
| 29 | #include <vendorcode/google/chromeos/chromeos.h> |
| 30 | |
| 31 | #include "board.h" |
| 32 | |
Julius Werner | df5bf2b | 2014-11-25 13:36:17 -0800 | [diff] [blame] | 33 | void bootblock_mainboard_early_init() |
| 34 | { |
Patrick Georgi | 01368ed | 2015-04-16 15:27:52 +0200 | [diff] [blame] | 35 | if (IS_ENABLED(CONFIG_DRIVERS_UART)) { |
Julius Werner | df5bf2b | 2014-11-25 13:36:17 -0800 | [diff] [blame] | 36 | assert(CONFIG_CONSOLE_SERIAL_UART_ADDRESS == UART2_BASE); |
Julius Werner | 2f37bd6 | 2015-02-19 14:51:15 -0800 | [diff] [blame] | 37 | write32(&rk3288_grf->iomux_uart2, IOMUX_UART2); |
Julius Werner | df5bf2b | 2014-11-25 13:36:17 -0800 | [diff] [blame] | 38 | } |
| 39 | |
| 40 | } |
| 41 | |
Katie Roberts-Hoffman | b262c72 | 2014-10-23 19:14:30 -0700 | [diff] [blame] | 42 | void bootblock_mainboard_init(void) |
| 43 | { |
huang lin | 0c253b6 | 2015-01-29 19:50:59 +0800 | [diff] [blame] | 44 | if (rkclk_was_watchdog_reset()) |
| 45 | reboot_from_watchdog(); |
| 46 | |
Julius Werner | 63451c7 | 2014-11-10 19:53:45 -0800 | [diff] [blame] | 47 | /* Up VDD_CPU (BUCK1) to 1.4V to support max CPU frequency (1.8GHz). */ |
Katie Roberts-Hoffman | b262c72 | 2014-10-23 19:14:30 -0700 | [diff] [blame] | 48 | setbits_le32(&rk3288_pmu->iomux_i2c0scl, IOMUX_I2C0SCL); |
| 49 | setbits_le32(&rk3288_pmu->iomux_i2c0sda, IOMUX_I2C0SDA); |
David Hendricks | 4d24421 | 2015-01-12 13:13:30 -0800 | [diff] [blame] | 50 | assert(CONFIG_PMIC_BUS == 0); /* must correspond with IOMUX */ |
| 51 | i2c_init(CONFIG_PMIC_BUS, 400*KHz); |
Julius Werner | 63451c7 | 2014-11-10 19:53:45 -0800 | [diff] [blame] | 52 | |
| 53 | /* Slowly raise to max CPU voltage to prevent overshoot */ |
David Hendricks | 4d24421 | 2015-01-12 13:13:30 -0800 | [diff] [blame] | 54 | rk808_configure_buck(1, 1200); |
Julius Werner | 63451c7 | 2014-11-10 19:53:45 -0800 | [diff] [blame] | 55 | udelay(175);/* Must wait for voltage to stabilize,2mV/us */ |
David Hendricks | 4d24421 | 2015-01-12 13:13:30 -0800 | [diff] [blame] | 56 | rk808_configure_buck(1, 1400); |
Julius Werner | 63451c7 | 2014-11-10 19:53:45 -0800 | [diff] [blame] | 57 | udelay(100);/* Must wait for voltage to stabilize,2mV/us */ |
David Hendricks | 4bd65e1 | 2015-09-02 18:10:14 -0700 | [diff] [blame] | 58 | rkclk_configure_cpu(APLL_1800_MHZ); |
Katie Roberts-Hoffman | b262c72 | 2014-10-23 19:14:30 -0700 | [diff] [blame] | 59 | |
Katie Roberts-Hoffman | b262c72 | 2014-10-23 19:14:30 -0700 | [diff] [blame] | 60 | /* i2c1 for tpm */ |
Julius Werner | 2f37bd6 | 2015-02-19 14:51:15 -0800 | [diff] [blame] | 61 | write32(&rk3288_grf->iomux_i2c1, IOMUX_I2C1); |
Julius Werner | 908ceef | 2014-12-17 17:38:38 -0800 | [diff] [blame] | 62 | i2c_init(1, 400*KHz); |
Katie Roberts-Hoffman | b262c72 | 2014-10-23 19:14:30 -0700 | [diff] [blame] | 63 | |
| 64 | /* spi2 for firmware ROM */ |
Julius Werner | 2f37bd6 | 2015-02-19 14:51:15 -0800 | [diff] [blame] | 65 | write32(&rk3288_grf->iomux_spi2csclk, IOMUX_SPI2_CSCLK); |
| 66 | write32(&rk3288_grf->iomux_spi2txrx, IOMUX_SPI2_TXRX); |
Julius Werner | ee426cf | 2015-03-24 16:54:38 -0700 | [diff] [blame] | 67 | rockchip_spi_init(CONFIG_BOOT_MEDIA_SPI_BUS, 24750*KHz); |
Katie Roberts-Hoffman | b262c72 | 2014-10-23 19:14:30 -0700 | [diff] [blame] | 68 | |
| 69 | /* spi0 for chrome ec */ |
Julius Werner | 2f37bd6 | 2015-02-19 14:51:15 -0800 | [diff] [blame] | 70 | write32(&rk3288_grf->iomux_spi0, IOMUX_SPI0); |
Julius Werner | 97ab425 | 2015-03-24 16:12:08 -0700 | [diff] [blame] | 71 | rockchip_spi_init(CONFIG_EC_GOOGLE_CHROMEEC_SPI_BUS, 8250*KHz); |
Katie Roberts-Hoffman | b262c72 | 2014-10-23 19:14:30 -0700 | [diff] [blame] | 72 | |
| 73 | setup_chromeos_gpios(); |
| 74 | } |