blob: 4c2f1439b66f2d8b3073043c6006e4300ffe8ba4 [file] [log] [blame]
Katie Roberts-Hoffmanb262c722014-10-23 19:14:30 -07001/*
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-Hoffmanb262c722014-10-23 19:14:30 -070015 */
16
Kyösti Mälkki13f66502019-03-03 08:01:05 +020017#include <device/mmio.h>
Julius Wernerdf5bf2b2014-11-25 13:36:17 -080018#include <assert.h>
Katie Roberts-Hoffmanb262c722014-10-23 19:14:30 -070019#include <bootblock_common.h>
Julius Werner63451c72014-11-10 19:53:45 -080020#include <delay.h>
Julius Werner2460a552014-11-24 13:50:46 -080021#include <reset.h>
Katie Roberts-Hoffmanb262c722014-10-23 19:14:30 -070022#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 Wernerdf5bf2b2014-11-25 13:36:17 -080032void bootblock_mainboard_early_init()
33{
Nico Huber755db952018-11-11 01:42:17 +010034 if (IS_ENABLED(CONFIG_CONSOLE_SERIAL)) {
Julius Wernerdf5bf2b2014-11-25 13:36:17 -080035 assert(CONFIG_CONSOLE_SERIAL_UART_ADDRESS == UART2_BASE);
Julius Werner2f37bd62015-02-19 14:51:15 -080036 write32(&rk3288_grf->iomux_uart2, IOMUX_UART2);
Julius Wernerdf5bf2b2014-11-25 13:36:17 -080037 }
Julius Wernerdf5bf2b2014-11-25 13:36:17 -080038}
39
Katie Roberts-Hoffmanb262c722014-10-23 19:14:30 -070040void bootblock_mainboard_init(void)
41{
huang lin0c253b62015-01-29 19:50:59 +080042 if (rkclk_was_watchdog_reset())
43 reboot_from_watchdog();
44
Julius Werner63451c72014-11-10 19:53:45 -080045 /* Up VDD_CPU (BUCK1) to 1.4V to support max CPU frequency (1.8GHz). */
Katie Roberts-Hoffmanb262c722014-10-23 19:14:30 -070046 setbits_le32(&rk3288_pmu->iomux_i2c0scl, IOMUX_I2C0SCL);
47 setbits_le32(&rk3288_pmu->iomux_i2c0sda, IOMUX_I2C0SDA);
David Hendricks4d244212015-01-12 13:13:30 -080048 assert(CONFIG_PMIC_BUS == 0); /* must correspond with IOMUX */
49 i2c_init(CONFIG_PMIC_BUS, 400*KHz);
Julius Werner63451c72014-11-10 19:53:45 -080050
51 /* Slowly raise to max CPU voltage to prevent overshoot */
David Hendricks4d244212015-01-12 13:13:30 -080052 rk808_configure_buck(1, 1200);
Julius Werner63451c72014-11-10 19:53:45 -080053 udelay(175);/* Must wait for voltage to stabilize,2mV/us */
David Hendricks4d244212015-01-12 13:13:30 -080054 rk808_configure_buck(1, 1400);
Julius Werner63451c72014-11-10 19:53:45 -080055 udelay(100);/* Must wait for voltage to stabilize,2mV/us */
David Hendricks4bd65e12015-09-02 18:10:14 -070056 rkclk_configure_cpu(APLL_1800_MHZ);
Katie Roberts-Hoffmanb262c722014-10-23 19:14:30 -070057
Katie Roberts-Hoffmanb262c722014-10-23 19:14:30 -070058 /* i2c1 for tpm */
Julius Werner2f37bd62015-02-19 14:51:15 -080059 write32(&rk3288_grf->iomux_i2c1, IOMUX_I2C1);
Julius Werner908ceef2014-12-17 17:38:38 -080060 i2c_init(1, 400*KHz);
Katie Roberts-Hoffmanb262c722014-10-23 19:14:30 -070061
62 /* spi2 for firmware ROM */
Julius Werner2f37bd62015-02-19 14:51:15 -080063 write32(&rk3288_grf->iomux_spi2csclk, IOMUX_SPI2_CSCLK);
64 write32(&rk3288_grf->iomux_spi2txrx, IOMUX_SPI2_TXRX);
Aaron Durbin08e842c2016-08-11 14:40:09 -050065 rockchip_spi_init(CONFIG_BOOT_DEVICE_SPI_FLASH_BUS, 24750*KHz);
Katie Roberts-Hoffmanb262c722014-10-23 19:14:30 -070066
67 /* spi0 for chrome ec */
Julius Werner2f37bd62015-02-19 14:51:15 -080068 write32(&rk3288_grf->iomux_spi0, IOMUX_SPI0);
Julius Werner97ab4252015-03-24 16:12:08 -070069 rockchip_spi_init(CONFIG_EC_GOOGLE_CHROMEEC_SPI_BUS, 8250*KHz);
Katie Roberts-Hoffmanb262c722014-10-23 19:14:30 -070070
71 setup_chromeos_gpios();
72}