blob: c3554106a463f11a08aae76e07aa1ab5d1c40822 [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
17#include <arch/io.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 Werner2460a552014-11-24 13:50:46 -080020#include <console/console.h>
Julius Werner63451c72014-11-10 19:53:45 -080021#include <delay.h>
Julius Werner2460a552014-11-24 13:50:46 -080022#include <reset.h>
Katie Roberts-Hoffmanb262c722014-10-23 19:14:30 -070023#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 Wernerdf5bf2b2014-11-25 13:36:17 -080033void bootblock_mainboard_early_init()
34{
Patrick Georgi01368ed2015-04-16 15:27:52 +020035 if (IS_ENABLED(CONFIG_DRIVERS_UART)) {
Julius Wernerdf5bf2b2014-11-25 13:36:17 -080036 assert(CONFIG_CONSOLE_SERIAL_UART_ADDRESS == UART2_BASE);
Julius Werner2f37bd62015-02-19 14:51:15 -080037 write32(&rk3288_grf->iomux_uart2, IOMUX_UART2);
Julius Wernerdf5bf2b2014-11-25 13:36:17 -080038 }
39
40}
41
Katie Roberts-Hoffmanb262c722014-10-23 19:14:30 -070042void bootblock_mainboard_init(void)
43{
huang lin0c253b62015-01-29 19:50:59 +080044 if (rkclk_was_watchdog_reset())
45 reboot_from_watchdog();
46
Julius Werner63451c72014-11-10 19:53:45 -080047 /* Up VDD_CPU (BUCK1) to 1.4V to support max CPU frequency (1.8GHz). */
Katie Roberts-Hoffmanb262c722014-10-23 19:14:30 -070048 setbits_le32(&rk3288_pmu->iomux_i2c0scl, IOMUX_I2C0SCL);
49 setbits_le32(&rk3288_pmu->iomux_i2c0sda, IOMUX_I2C0SDA);
David Hendricks4d244212015-01-12 13:13:30 -080050 assert(CONFIG_PMIC_BUS == 0); /* must correspond with IOMUX */
51 i2c_init(CONFIG_PMIC_BUS, 400*KHz);
Julius Werner63451c72014-11-10 19:53:45 -080052
53 /* Slowly raise to max CPU voltage to prevent overshoot */
David Hendricks4d244212015-01-12 13:13:30 -080054 rk808_configure_buck(1, 1200);
Julius Werner63451c72014-11-10 19:53:45 -080055 udelay(175);/* Must wait for voltage to stabilize,2mV/us */
David Hendricks4d244212015-01-12 13:13:30 -080056 rk808_configure_buck(1, 1400);
Julius Werner63451c72014-11-10 19:53:45 -080057 udelay(100);/* Must wait for voltage to stabilize,2mV/us */
David Hendricks4bd65e12015-09-02 18:10:14 -070058 rkclk_configure_cpu(APLL_1800_MHZ);
Katie Roberts-Hoffmanb262c722014-10-23 19:14:30 -070059
Katie Roberts-Hoffmanb262c722014-10-23 19:14:30 -070060 /* i2c1 for tpm */
Julius Werner2f37bd62015-02-19 14:51:15 -080061 write32(&rk3288_grf->iomux_i2c1, IOMUX_I2C1);
Julius Werner908ceef2014-12-17 17:38:38 -080062 i2c_init(1, 400*KHz);
Katie Roberts-Hoffmanb262c722014-10-23 19:14:30 -070063
64 /* spi2 for firmware ROM */
Julius Werner2f37bd62015-02-19 14:51:15 -080065 write32(&rk3288_grf->iomux_spi2csclk, IOMUX_SPI2_CSCLK);
66 write32(&rk3288_grf->iomux_spi2txrx, IOMUX_SPI2_TXRX);
Julius Werneree426cf2015-03-24 16:54:38 -070067 rockchip_spi_init(CONFIG_BOOT_MEDIA_SPI_BUS, 24750*KHz);
Katie Roberts-Hoffmanb262c722014-10-23 19:14:30 -070068
69 /* spi0 for chrome ec */
Julius Werner2f37bd62015-02-19 14:51:15 -080070 write32(&rk3288_grf->iomux_spi0, IOMUX_SPI0);
Julius Werner97ab4252015-03-24 16:12:08 -070071 rockchip_spi_init(CONFIG_EC_GOOGLE_CHROMEEC_SPI_BUS, 8250*KHz);
Katie Roberts-Hoffmanb262c722014-10-23 19:14:30 -070072
73 setup_chromeos_gpios();
74}