Aaron Durbin | 072e0cc | 2014-07-14 19:09:23 -0500 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright 2014 Google 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. |
Aaron Durbin | 072e0cc | 2014-07-14 19:09:23 -0500 | [diff] [blame] | 14 | */ |
| 15 | |
| 16 | #include <arch/io.h> |
Julius Werner | f1e3210 | 2014-11-25 13:22:20 -0800 | [diff] [blame] | 17 | #include <bootblock_common.h> |
Aaron Durbin | 072e0cc | 2014-07-14 19:09:23 -0500 | [diff] [blame] | 18 | #include <console/console.h> |
| 19 | #include <device/i2c.h> |
| 20 | #include <soc/addressmap.h> |
Julius Werner | 96195ee | 2014-10-20 13:25:21 -0700 | [diff] [blame] | 21 | #include <soc/clk_rst.h> |
Aaron Durbin | 072e0cc | 2014-07-14 19:09:23 -0500 | [diff] [blame] | 22 | #include <soc/clock.h> |
Aaron Durbin | 65627dd | 2014-08-13 13:27:14 -0500 | [diff] [blame] | 23 | #include <soc/funitcfg.h> |
Aaron Durbin | 072e0cc | 2014-07-14 19:09:23 -0500 | [diff] [blame] | 24 | #include <soc/nvidia/tegra/i2c.h> |
Julius Werner | 96195ee | 2014-10-20 13:25:21 -0700 | [diff] [blame] | 25 | #include <soc/padconfig.h> |
Aaron Durbin | 072e0cc | 2014-07-14 19:09:23 -0500 | [diff] [blame] | 26 | |
| 27 | #include "pmic.h" |
| 28 | |
Aaron Durbin | 6ecf3f6 | 2014-08-01 15:11:11 -0500 | [diff] [blame] | 29 | static const struct pad_config uart_console_pads[] = { |
Aaron Durbin | e68ee3b | 2014-08-06 15:27:12 -0500 | [diff] [blame] | 30 | /* UARTA: tx and rx. */ |
| 31 | PAD_CFG_SFIO(KB_ROW9, PINMUX_PULL_NONE, UA3), |
Aaron Durbin | 6ecf3f6 | 2014-08-01 15:11:11 -0500 | [diff] [blame] | 32 | PAD_CFG_SFIO(KB_ROW10, PINMUX_INPUT_ENABLE | PINMUX_PULL_UP, UA3), |
| 33 | /* |
| 34 | * Disable UART2 pads as they are default connected to UARTA controller. |
| 35 | */ |
| 36 | PAD_CFG_UNUSED(UART2_RXD), |
| 37 | PAD_CFG_UNUSED(UART2_TXD), |
| 38 | PAD_CFG_UNUSED(UART2_RTS_N), |
| 39 | PAD_CFG_UNUSED(UART2_CTS_N), |
| 40 | }; |
| 41 | |
Aaron Durbin | 65627dd | 2014-08-13 13:27:14 -0500 | [diff] [blame] | 42 | static const struct pad_config pmic_pads[] = { |
| 43 | PAD_CFG_SFIO(PWR_I2C_SCL, PINMUX_INPUT_ENABLE, I2CPMU), |
| 44 | PAD_CFG_SFIO(PWR_I2C_SDA, PINMUX_INPUT_ENABLE, I2CPMU), |
| 45 | }; |
| 46 | |
| 47 | static const struct pad_config spiflash_pads[] = { |
| 48 | /* mosi, miso, clk, cs0 */ |
| 49 | PAD_CFG_SFIO(GPIO_PG6, PINMUX_INPUT_ENABLE | PINMUX_PULL_UP, SPI4), |
| 50 | PAD_CFG_SFIO(GPIO_PG7, PINMUX_INPUT_ENABLE | PINMUX_PULL_UP, SPI4), |
| 51 | PAD_CFG_SFIO(GPIO_PG5, PINMUX_INPUT_ENABLE, SPI4), |
| 52 | PAD_CFG_SFIO(GPIO_PI3, PINMUX_INPUT_ENABLE, SPI4), |
| 53 | }; |
| 54 | |
| 55 | static const struct funit_cfg funits[] = { |
| 56 | /* PMIC on I2C5 (PWR_I2C* pads) at 400kHz. */ |
| 57 | FUNIT_CFG(I2C5, PLLP, 400, pmic_pads, ARRAY_SIZE(pmic_pads)), |
| 58 | /* SPI flash at 33MHz on SPI4 controller. */ |
| 59 | FUNIT_CFG(SBC4, PLLP, 33333, spiflash_pads, ARRAY_SIZE(spiflash_pads)), |
| 60 | }; |
| 61 | |
Aaron Durbin | 6ecf3f6 | 2014-08-01 15:11:11 -0500 | [diff] [blame] | 62 | void bootblock_mainboard_early_init(void) |
| 63 | { |
| 64 | soc_configure_pads(uart_console_pads, ARRAY_SIZE(uart_console_pads)); |
| 65 | } |
| 66 | |
Aaron Durbin | 072e0cc | 2014-07-14 19:09:23 -0500 | [diff] [blame] | 67 | static void set_clock_sources(void) |
| 68 | { |
| 69 | /* UARTA gets PLLP, deactivate CLK_UART_DIV_OVERRIDE */ |
Julius Werner | 2f37bd6 | 2015-02-19 14:51:15 -0800 | [diff] [blame] | 70 | write32(CLK_RST_REG(clk_src_uarta), PLLP << CLK_SOURCE_SHIFT); |
Aaron Durbin | 072e0cc | 2014-07-14 19:09:23 -0500 | [diff] [blame] | 71 | } |
| 72 | |
Aaron Durbin | d0f9f74 | 2014-08-01 16:11:48 -0500 | [diff] [blame] | 73 | static const struct pad_config padcfgs[] = { |
| 74 | /* Board build id bits 1:0 */ |
| 75 | PAD_CFG_GPIO_INPUT(KB_COL4, PINMUX_PULL_NONE), |
| 76 | PAD_CFG_GPIO_INPUT(KB_COL3, PINMUX_PULL_NONE), |
Aaron Durbin | d0f9f74 | 2014-08-01 16:11:48 -0500 | [diff] [blame] | 77 | }; |
| 78 | |
Aaron Durbin | 072e0cc | 2014-07-14 19:09:23 -0500 | [diff] [blame] | 79 | void bootblock_mainboard_init(void) |
| 80 | { |
| 81 | set_clock_sources(); |
| 82 | |
Aaron Durbin | 65627dd | 2014-08-13 13:27:14 -0500 | [diff] [blame] | 83 | /* Set up controllers and pads to load romstage. */ |
| 84 | soc_configure_funits(funits, ARRAY_SIZE(funits)); |
Aaron Durbin | d0f9f74 | 2014-08-01 16:11:48 -0500 | [diff] [blame] | 85 | soc_configure_pads(padcfgs, ARRAY_SIZE(padcfgs)); |
Aaron Durbin | 072e0cc | 2014-07-14 19:09:23 -0500 | [diff] [blame] | 86 | |
Aaron Durbin | 175c636 | 2014-08-21 14:54:45 -0500 | [diff] [blame] | 87 | i2c_init(I2CPWR_BUS); |
| 88 | pmic_init(I2CPWR_BUS); |
Aaron Durbin | 072e0cc | 2014-07-14 19:09:23 -0500 | [diff] [blame] | 89 | } |