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 | |
Kyösti Mälkki | 13f6650 | 2019-03-03 08:01:05 +0200 | [diff] [blame] | 17 | #include <device/mmio.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 | 63451c7 | 2014-11-10 19:53:45 -0800 | [diff] [blame] | 20 | #include <delay.h> |
Julius Werner | 2460a55 | 2014-11-24 13:50:46 -0800 | [diff] [blame] | 21 | #include <reset.h> |
Katie Roberts-Hoffman | b262c72 | 2014-10-23 19:14:30 -0700 | [diff] [blame] | 22 | #include <soc/clock.h> |
| 23 | #include <soc/i2c.h> |
| 24 | #include <soc/grf.h> |
| 25 | #include <soc/pmu.h> |
| 26 | #include <soc/rk808.h> |
| 27 | #include <soc/spi.h> |
| 28 | #include <vendorcode/google/chromeos/chromeos.h> |
| 29 | |
| 30 | #include "board.h" |
| 31 | |
Julius Werner | df5bf2b | 2014-11-25 13:36:17 -0800 | [diff] [blame] | 32 | void bootblock_mainboard_early_init() |
| 33 | { |
Nico Huber | 755db95 | 2018-11-11 01:42:17 +0100 | [diff] [blame] | 34 | if (IS_ENABLED(CONFIG_CONSOLE_SERIAL)) { |
Julius Werner | df5bf2b | 2014-11-25 13:36:17 -0800 | [diff] [blame] | 35 | assert(CONFIG_CONSOLE_SERIAL_UART_ADDRESS == UART2_BASE); |
Julius Werner | 2f37bd6 | 2015-02-19 14:51:15 -0800 | [diff] [blame] | 36 | write32(&rk3288_grf->iomux_uart2, IOMUX_UART2); |
Julius Werner | df5bf2b | 2014-11-25 13:36:17 -0800 | [diff] [blame] | 37 | } |
Julius Werner | df5bf2b | 2014-11-25 13:36:17 -0800 | [diff] [blame] | 38 | } |
| 39 | |
Katie Roberts-Hoffman | b262c72 | 2014-10-23 19:14:30 -0700 | [diff] [blame] | 40 | void bootblock_mainboard_init(void) |
| 41 | { |
huang lin | 0c253b6 | 2015-01-29 19:50:59 +0800 | [diff] [blame] | 42 | if (rkclk_was_watchdog_reset()) |
| 43 | reboot_from_watchdog(); |
| 44 | |
Julius Werner | 63451c7 | 2014-11-10 19:53:45 -0800 | [diff] [blame] | 45 | /* 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] | 46 | setbits_le32(&rk3288_pmu->iomux_i2c0scl, IOMUX_I2C0SCL); |
| 47 | setbits_le32(&rk3288_pmu->iomux_i2c0sda, IOMUX_I2C0SDA); |
David Hendricks | 4d24421 | 2015-01-12 13:13:30 -0800 | [diff] [blame] | 48 | assert(CONFIG_PMIC_BUS == 0); /* must correspond with IOMUX */ |
| 49 | i2c_init(CONFIG_PMIC_BUS, 400*KHz); |
Julius Werner | 63451c7 | 2014-11-10 19:53:45 -0800 | [diff] [blame] | 50 | |
| 51 | /* Slowly raise to max CPU voltage to prevent overshoot */ |
David Hendricks | 4d24421 | 2015-01-12 13:13:30 -0800 | [diff] [blame] | 52 | rk808_configure_buck(1, 1200); |
Julius Werner | 63451c7 | 2014-11-10 19:53:45 -0800 | [diff] [blame] | 53 | udelay(175);/* Must wait for voltage to stabilize,2mV/us */ |
David Hendricks | 4d24421 | 2015-01-12 13:13:30 -0800 | [diff] [blame] | 54 | rk808_configure_buck(1, 1400); |
Julius Werner | 63451c7 | 2014-11-10 19:53:45 -0800 | [diff] [blame] | 55 | udelay(100);/* Must wait for voltage to stabilize,2mV/us */ |
David Hendricks | 4bd65e1 | 2015-09-02 18:10:14 -0700 | [diff] [blame] | 56 | rkclk_configure_cpu(APLL_1800_MHZ); |
Katie Roberts-Hoffman | b262c72 | 2014-10-23 19:14:30 -0700 | [diff] [blame] | 57 | |
Katie Roberts-Hoffman | b262c72 | 2014-10-23 19:14:30 -0700 | [diff] [blame] | 58 | /* i2c1 for tpm */ |
Julius Werner | 2f37bd6 | 2015-02-19 14:51:15 -0800 | [diff] [blame] | 59 | write32(&rk3288_grf->iomux_i2c1, IOMUX_I2C1); |
Julius Werner | 908ceef | 2014-12-17 17:38:38 -0800 | [diff] [blame] | 60 | i2c_init(1, 400*KHz); |
Katie Roberts-Hoffman | b262c72 | 2014-10-23 19:14:30 -0700 | [diff] [blame] | 61 | |
| 62 | /* spi2 for firmware ROM */ |
Julius Werner | 2f37bd6 | 2015-02-19 14:51:15 -0800 | [diff] [blame] | 63 | write32(&rk3288_grf->iomux_spi2csclk, IOMUX_SPI2_CSCLK); |
| 64 | write32(&rk3288_grf->iomux_spi2txrx, IOMUX_SPI2_TXRX); |
Aaron Durbin | 08e842c | 2016-08-11 14:40:09 -0500 | [diff] [blame] | 65 | rockchip_spi_init(CONFIG_BOOT_DEVICE_SPI_FLASH_BUS, 24750*KHz); |
Katie Roberts-Hoffman | b262c72 | 2014-10-23 19:14:30 -0700 | [diff] [blame] | 66 | |
| 67 | /* spi0 for chrome ec */ |
Julius Werner | 2f37bd6 | 2015-02-19 14:51:15 -0800 | [diff] [blame] | 68 | write32(&rk3288_grf->iomux_spi0, IOMUX_SPI0); |
Julius Werner | 97ab425 | 2015-03-24 16:12:08 -0700 | [diff] [blame] | 69 | rockchip_spi_init(CONFIG_EC_GOOGLE_CHROMEEC_SPI_BUS, 8250*KHz); |
Katie Roberts-Hoffman | b262c72 | 2014-10-23 19:14:30 -0700 | [diff] [blame] | 70 | |
| 71 | setup_chromeos_gpios(); |
| 72 | } |