tegra124: use pll_c_out1 as sclk parent Reviewed-on: https://chromium-review.googlesource.com/180865 (cherry picked from commit 418337a5bde70df6a770222201c51bf3e8892d5f) tegra124: take LP cluster out of reset Reviewed-on: https://chromium-review.googlesource.com/180866 (cherry picked from commit 74cdc68ea9b29da9af313635787e82bacb9e23e3) tegra124: norrin: display code clean up Reviewed-on: https://chromium-review.googlesource.com/181003 (cherry picked from commit 63843ec61b3b47ffc985edcb589771591c5c9f17) tegra124: Change the display hack to use window A Reviewed-on: https://chromium-review.googlesource.com/182001 (cherry picked from commit ef245e42eb17b2eb0e8712f252353a95ee6fc01a) tegra124: norrin: Initialize frame buffer Reviewed-on: https://chromium-review.googlesource.com/182090 (cherry picked from commit b7c1d1b3c9519cbbe1615737aed4c4c0efed2167) nyan: do not enable pull-ups on SPI1 (EC) data pins Reviewed-on: https://chromium-review.googlesource.com/181063 (cherry picked from commit 2f55188501ebcae9e01b12831f152d4520c7047c) tegra124: Add source for the LP0 resume blob. Reviewed-on: https://chromium-review.googlesource.com/183152 (cherry picked from commit a00d099bf710c297320d7edff7f7c608283d1b0b) tegra124: Revise Memory Controller registers structure definition. Reviewed-on: https://chromium-review.googlesource.com/182992 (cherry picked from commit ae83564cdd1d46c8166df1a95703e8cb1060c0a1) tegra124: Add more PMC register details. Reviewed-on: https://chromium-review.googlesource.com/183231 (cherry picked from commit d62ed2c19693284f10c2a12f4295091de3ace829) tegra124: Add SDRAM configuration header file from cbootimage. Reviewed-on: https://chromium-review.googlesource.com/182613 (cherry picked from commit 193ed2a104af38f6c41a332a649ce06a3238e0a4) tegra124: Revise sdram_param.h for Coreboot. Reviewed-on: https://chromium-review.googlesource.com/182614 (cherry picked from commit 311b0568c5de627435a5b035a7a1e40ecc2672f8) tegra124: Fix EMC base address. Reviewed-on: https://chromium-review.googlesource.com/183602 (cherry picked from commit 587c8969292ccecfa29c7720bcf24c704ed4ac4e) tegra124: Add EMC registers definition. Reviewed-on: https://chromium-review.googlesource.com/183622 (cherry picked from commit 67a8e5c7e87a1cc6bf006ad806751b549ffd3d5a) tegra124: Never touch MEM(MC)/EMC clocks in ramstage. Reviewed-on: https://chromium-review.googlesource.com/183623 (cherry picked from commit 8e3bb34d4ae37feae89b4a39850b2988a334d023) tegra124: use RAM_CODE[3:2] for ram code Reviewed-on: https://chromium-review.googlesource.com/183833 (cherry picked from commit 0154239467064ffcbdb82fc4c6b629f5d0c3568d) tegra124: Allow setting PLLM (clock for SDRAM). Reviewed-on: https://chromium-review.googlesource.com/183621 (cherry picked from commit a534e5b7c61d655eedd409dbd7780a4f90d40683) tegra124: SDRAM Initialization. Reviewed-on: https://chromium-review.googlesource.com/182615 (cherry picked from commit 5a60ae93b0603ee0d4806132be0360f3b1612bce) tegra124: Get RAM_CODE for SDRAM initialization. Reviewed-on: https://chromium-review.googlesource.com/183781 (cherry picked from commit a5b7ce70525d7ffef3fac90b8eb14b3f3787f4d8) Squashed 18 nyan/tegra commits for memory and display. Change-Id: I59a781ee8dc2fd9c9085373f5a9bb7c8108b094c Signed-off-by: Isaac Christensen <isaac.christensen@se-eng.com> Reviewed-on: http://review.coreboot.org/6914 Reviewed-by: Ronald G. Minnich <rminnich@gmail.com> Tested-by: build bot (Jenkins)
307 lines
9.9 KiB
C
307 lines
9.9 KiB
C
/*
|
|
* This file is part of the coreboot project.
|
|
*
|
|
* Copyright 2013 Google Inc.
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; version 2 of the License.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
*/
|
|
|
|
#include <arch/io.h>
|
|
#include <device/device.h>
|
|
#include <boot/coreboot_tables.h>
|
|
#include <soc/addressmap.h>
|
|
#include <soc/clock.h>
|
|
#include <soc/nvidia/tegra/i2c.h>
|
|
#include <soc/nvidia/tegra124/clk_rst.h>
|
|
#include <soc/nvidia/tegra124/gpio.h>
|
|
#include <soc/nvidia/tegra124/mc.h>
|
|
#include <soc/nvidia/tegra124/pmc.h>
|
|
#include <soc/nvidia/tegra124/spi.h>
|
|
#include <soc/nvidia/tegra124/usb.h>
|
|
|
|
static struct clk_rst_ctlr *clk_rst = (void *)TEGRA_CLK_RST_BASE;
|
|
|
|
static void set_clock_sources(void)
|
|
{
|
|
clock_configure_source(i2c1, CLK_M, 1333);
|
|
clock_configure_source(i2c2, CLK_M, 1333);
|
|
clock_configure_source(i2c3, CLK_M, 1333);
|
|
clock_configure_source(i2c4, CLK_M, 1333);
|
|
|
|
clock_configure_source(sbc1, PLLP, 5000);
|
|
|
|
/*
|
|
* MMC3 and MMC4: Set base clock frequency for SD Clock to Tegra MMC's
|
|
* maximum speed (48MHz) so we can change SDCLK by second stage divisor
|
|
* in payloads, without touching base clock.
|
|
*/
|
|
clock_configure_source(sdmmc3, PLLP, 48000);
|
|
clock_configure_source(sdmmc4, PLLP, 48000);
|
|
|
|
/* External peripheral 1: audio codec (max98090) using 12MHz CLK1.
|
|
* Note the source id of CLK_M for EXTPERIPH1 is 3. */
|
|
clock_configure_irregular_source(extperiph1, CLK_M, 12000, 3);
|
|
|
|
/*
|
|
* I2S1 can use either PLLP or PLLA. Using PLLP is sufficient now since
|
|
* we only need 4.8MHz. Note the source id of PLLP for I2S is 4.
|
|
*/
|
|
clock_configure_irregular_source(i2s1, PLLP, 4800, 4);
|
|
|
|
/* Note source id of PLLP for HOST1x is 4. */
|
|
clock_configure_irregular_source(host1x, PLLP, 408000, 4);
|
|
|
|
/* Use PLLD_OUT0 as clock source for disp1 */
|
|
clrsetbits_le32(&clk_rst->clk_src_disp1,
|
|
CLK_SOURCE_MASK | CLK_DIVISOR_MASK,
|
|
2 /*PLLD_OUT0 */ << CLK_SOURCE_SHIFT);
|
|
|
|
}
|
|
|
|
static void setup_pinmux(void)
|
|
{
|
|
// Write protect.
|
|
gpio_input_pullup(GPIO(R1));
|
|
// Recovery mode.
|
|
gpio_input_pullup(GPIO(Q7));
|
|
// Lid switch.
|
|
gpio_input_pullup(GPIO(R4));
|
|
// Power switch.
|
|
gpio_input_pullup(GPIO(Q0));
|
|
// Developer mode.
|
|
gpio_input_pullup(GPIO(Q6));
|
|
// EC in RW.
|
|
gpio_input_pullup(GPIO(U4));
|
|
|
|
// SOC and TPM reset GPIO, active low.
|
|
gpio_output(GPIO(I5), 1);
|
|
|
|
// SPI1 MOSI
|
|
pinmux_set_config(PINMUX_ULPI_CLK_INDEX, PINMUX_ULPI_CLK_FUNC_SPI1 |
|
|
PINMUX_PULL_NONE |
|
|
PINMUX_INPUT_ENABLE);
|
|
// SPI1 MISO
|
|
pinmux_set_config(PINMUX_ULPI_DIR_INDEX, PINMUX_ULPI_DIR_FUNC_SPI1 |
|
|
PINMUX_PULL_NONE |
|
|
PINMUX_INPUT_ENABLE);
|
|
// SPI1 SCLK
|
|
pinmux_set_config(PINMUX_ULPI_NXT_INDEX, PINMUX_ULPI_NXT_FUNC_SPI1 |
|
|
PINMUX_PULL_NONE |
|
|
PINMUX_INPUT_ENABLE);
|
|
// SPI1 CS0
|
|
pinmux_set_config(PINMUX_ULPI_STP_INDEX, PINMUX_ULPI_STP_FUNC_SPI1 |
|
|
PINMUX_PULL_NONE |
|
|
PINMUX_INPUT_ENABLE);
|
|
|
|
// I2C1 clock.
|
|
pinmux_set_config(PINMUX_GEN1_I2C_SCL_INDEX,
|
|
PINMUX_GEN1_I2C_SCL_FUNC_I2C1 | PINMUX_INPUT_ENABLE);
|
|
// I2C1 data.
|
|
pinmux_set_config(PINMUX_GEN1_I2C_SDA_INDEX,
|
|
PINMUX_GEN1_I2C_SDA_FUNC_I2C1 | PINMUX_INPUT_ENABLE);
|
|
// I2C2 clock.
|
|
pinmux_set_config(PINMUX_GEN2_I2C_SCL_INDEX,
|
|
PINMUX_GEN2_I2C_SCL_FUNC_I2C2 | PINMUX_INPUT_ENABLE);
|
|
// I2C2 data.
|
|
pinmux_set_config(PINMUX_GEN2_I2C_SDA_INDEX,
|
|
PINMUX_GEN2_I2C_SDA_FUNC_I2C2 | PINMUX_INPUT_ENABLE);
|
|
// I2C3 (cam) clock.
|
|
pinmux_set_config(PINMUX_CAM_I2C_SCL_INDEX,
|
|
PINMUX_CAM_I2C_SCL_FUNC_I2C3 | PINMUX_INPUT_ENABLE);
|
|
// I2C3 (cam) data.
|
|
pinmux_set_config(PINMUX_CAM_I2C_SDA_INDEX,
|
|
PINMUX_CAM_I2C_SDA_FUNC_I2C3 | PINMUX_INPUT_ENABLE);
|
|
// I2C4 (DDC) clock.
|
|
pinmux_set_config(PINMUX_DDC_SCL_INDEX,
|
|
PINMUX_DDC_SCL_FUNC_I2C4 | PINMUX_INPUT_ENABLE);
|
|
// I2C4 (DDC) data.
|
|
pinmux_set_config(PINMUX_DDC_SDA_INDEX,
|
|
PINMUX_DDC_SDA_FUNC_I2C4 | PINMUX_INPUT_ENABLE);
|
|
|
|
// TODO(hungte) Revice pinmux setup, make nice little SoC functions for
|
|
// every single logical thing instead of dumping a wall of code below.
|
|
uint32_t pin_up = PINMUX_PULL_UP | PINMUX_INPUT_ENABLE,
|
|
pin_up3 = (PINMUX_PULL_UP | PINMUX_INPUT_ENABLE |
|
|
PINMUX_TRISTATE),
|
|
pin_down = PINMUX_PULL_DOWN | PINMUX_INPUT_ENABLE,
|
|
pin_none = PINMUX_PULL_NONE | PINMUX_INPUT_ENABLE;
|
|
|
|
// MMC3
|
|
pinmux_set_config(PINMUX_SDMMC3_CLK_INDEX,
|
|
PINMUX_SDMMC3_CLK_FUNC_SDMMC3 | pin_none);
|
|
pinmux_set_config(PINMUX_SDMMC3_CMD_INDEX,
|
|
PINMUX_SDMMC3_CMD_FUNC_SDMMC3 | pin_up);
|
|
pinmux_set_config(PINMUX_SDMMC3_DAT0_INDEX,
|
|
PINMUX_SDMMC3_DAT0_FUNC_SDMMC3 | pin_up);
|
|
pinmux_set_config(PINMUX_SDMMC3_DAT1_INDEX,
|
|
PINMUX_SDMMC3_DAT1_FUNC_SDMMC3 | pin_up);
|
|
pinmux_set_config(PINMUX_SDMMC3_DAT2_INDEX,
|
|
PINMUX_SDMMC3_DAT2_FUNC_SDMMC3 | pin_up);
|
|
pinmux_set_config(PINMUX_SDMMC3_DAT3_INDEX,
|
|
PINMUX_SDMMC3_DAT3_FUNC_SDMMC3 | pin_up);
|
|
pinmux_set_config(PINMUX_SDMMC3_CLK_LB_IN_INDEX,
|
|
PINMUX_SDMMC3_CLK_LB_IN_FUNC_SDMMC3 | pin_up3);
|
|
pinmux_set_config(PINMUX_SDMMC3_CLK_LB_OUT_INDEX,
|
|
PINMUX_SDMMC3_CLK_LB_OUT_FUNC_SDMMC3 | pin_down);
|
|
|
|
// MMC3 Card Detect pin.
|
|
gpio_input_pullup(GPIO(V2));
|
|
// Enable MMC power.
|
|
gpio_output(GPIO(R0), 1);
|
|
|
|
// MMC4
|
|
pinmux_set_config(PINMUX_SDMMC4_CLK_INDEX,
|
|
PINMUX_SDMMC4_CLK_FUNC_SDMMC4 | pin_none);
|
|
pinmux_set_config(PINMUX_SDMMC4_CMD_INDEX,
|
|
PINMUX_SDMMC4_CMD_FUNC_SDMMC4 | pin_up);
|
|
pinmux_set_config(PINMUX_SDMMC4_DAT0_INDEX,
|
|
PINMUX_SDMMC4_DAT0_FUNC_SDMMC4 | pin_up);
|
|
pinmux_set_config(PINMUX_SDMMC4_DAT1_INDEX,
|
|
PINMUX_SDMMC4_DAT1_FUNC_SDMMC4 | pin_up);
|
|
pinmux_set_config(PINMUX_SDMMC4_DAT2_INDEX,
|
|
PINMUX_SDMMC4_DAT2_FUNC_SDMMC4 | pin_up);
|
|
pinmux_set_config(PINMUX_SDMMC4_DAT3_INDEX,
|
|
PINMUX_SDMMC4_DAT3_FUNC_SDMMC4 | pin_up);
|
|
pinmux_set_config(PINMUX_SDMMC4_DAT4_INDEX,
|
|
PINMUX_SDMMC4_DAT4_FUNC_SDMMC4 | pin_up);
|
|
pinmux_set_config(PINMUX_SDMMC4_DAT5_INDEX,
|
|
PINMUX_SDMMC4_DAT5_FUNC_SDMMC4 | pin_up);
|
|
pinmux_set_config(PINMUX_SDMMC4_DAT6_INDEX,
|
|
PINMUX_SDMMC4_DAT6_FUNC_SDMMC4 | pin_up);
|
|
pinmux_set_config(PINMUX_SDMMC4_DAT7_INDEX,
|
|
PINMUX_SDMMC4_DAT7_FUNC_SDMMC4 | pin_up);
|
|
|
|
/* We pull the USB VBUS signals up but keep them as inputs since the
|
|
* voltage source likes to drive them low on overcurrent conditions */
|
|
gpio_input_pullup(GPIO(N4)); /* USB VBUS EN0 */
|
|
gpio_input_pullup(GPIO(N5)); /* USB VBUS EN1 */
|
|
|
|
/* Clock output 1 (for external peripheral) */
|
|
pinmux_set_config(PINMUX_DAP_MCLK1_INDEX,
|
|
PINMUX_DAP_MCLK1_FUNC_EXTPERIPH1 | PINMUX_PULL_NONE);
|
|
|
|
/* I2S1 */
|
|
pinmux_set_config(PINMUX_DAP2_DIN_INDEX,
|
|
PINMUX_DAP2_DIN_FUNC_I2S1 | PINMUX_TRISTATE |
|
|
PINMUX_INPUT_ENABLE);
|
|
pinmux_set_config(PINMUX_DAP2_DOUT_INDEX,
|
|
PINMUX_DAP2_DOUT_FUNC_I2S1 | PINMUX_INPUT_ENABLE);
|
|
pinmux_set_config(PINMUX_DAP2_FS_INDEX,
|
|
PINMUX_DAP2_FS_FUNC_I2S1 | PINMUX_INPUT_ENABLE);
|
|
pinmux_set_config(PINMUX_DAP2_SCLK_INDEX,
|
|
PINMUX_DAP2_SCLK_FUNC_I2S1 | PINMUX_INPUT_ENABLE);
|
|
}
|
|
|
|
static void setup_kernel_info(void)
|
|
{
|
|
// Setup required information for Linux kernel.
|
|
|
|
// pmc.odmdata: [18:19]: console type, [15:17]: UART id.
|
|
// TODO(hungte) This should be done by filling BCT values, or derived
|
|
// from CONFIG_CONSOLE_SERIAL_UART[A-E]. Right now we simply copy the
|
|
// value defined in BCT.
|
|
struct tegra_pmc_regs *pmc = (void*)TEGRA_PMC_BASE;
|
|
writel(0x80080000, &pmc->odmdata);
|
|
|
|
// Not strictly info, but kernel graphics driver needs this region locked down
|
|
struct tegra_mc_regs *mc = (void *)TEGRA_MC_BASE;
|
|
writel(0, &mc->video_protect_bom);
|
|
writel(0, &mc->video_protect_size_mb);
|
|
writel(1, &mc->video_protect_reg_ctrl);
|
|
}
|
|
|
|
static void setup_ec_spi(void)
|
|
{
|
|
struct tegra_spi_channel *spi;
|
|
|
|
spi = tegra_spi_init(CONFIG_EC_GOOGLE_CHROMEEC_SPI_BUS);
|
|
|
|
/* Set frame header for use by CrOS EC */
|
|
spi->frame_header = 0xec;
|
|
spi->rx_frame_header_enable = 1;
|
|
}
|
|
|
|
static void mainboard_init(device_t dev)
|
|
{
|
|
set_clock_sources();
|
|
|
|
clock_external_output(1); /* For external MAX98090 audio codec. */
|
|
|
|
/*
|
|
* Confirmed by NVIDIA hardware team, we need to take ALL audio devices
|
|
* conntected to AHUB (AUDIO, APBIF, I2S, DAM, AMX, ADX, SPDIF, AFC) out
|
|
* of reset and clock-enabled, otherwise reading AHUB devices (In our
|
|
* case, I2S/APBIF/AUDIO<XBAR>) will hang.
|
|
*
|
|
* Note that CLK_H_MEM (MC) and CLK_H_EMC should be already either
|
|
* initialized by BootROM, or in romstage SDRAM initialization.
|
|
*/
|
|
clock_enable_clear_reset(CLK_L_GPIO | CLK_L_I2C1 | CLK_L_SDMMC4 |
|
|
CLK_L_I2S0 | CLK_L_I2S1 | CLK_L_I2S2 |
|
|
CLK_L_SPDIF | CLK_L_USBD | CLK_L_DISP1 |
|
|
CLK_L_HOST1X,
|
|
|
|
CLK_H_I2C2 | CLK_H_SBC1 | CLK_H_PMC |
|
|
CLK_H_USB3,
|
|
|
|
CLK_U_I2C3 | CLK_U_CSITE | CLK_U_SDMMC3,
|
|
|
|
CLK_V_I2C4 | CLK_V_EXTPERIPH1 | CLK_V_APBIF |
|
|
CLK_V_AUDIO | CLK_V_I2S3 | CLK_V_I2S4 |
|
|
CLK_V_DAM0 | CLK_V_DAM1 | CLK_V_DAM2,
|
|
|
|
CLK_W_DVFS | CLK_W_AMX0 | CLK_W_ADX0,
|
|
|
|
CLK_X_DPAUX | CLK_X_SOR0 | CLK_X_AMX1 |
|
|
CLK_X_ADX1 | CLK_X_AFC0 | CLK_X_AFC1 |
|
|
CLK_X_AFC2 | CLK_X_AFC3 | CLK_X_AFC4 |
|
|
CLK_X_AFC5);
|
|
|
|
usb_setup_utmip1();
|
|
/* USB2 is the camera, we don't need it in firmware */
|
|
usb_setup_utmip3();
|
|
|
|
setup_pinmux();
|
|
|
|
i2c_init(0);
|
|
i2c_init(1);
|
|
i2c_init(2);
|
|
i2c_init(3);
|
|
|
|
setup_kernel_info();
|
|
clock_init_arm_generic_timer();
|
|
setup_ec_spi();
|
|
}
|
|
|
|
static void mainboard_enable(device_t dev)
|
|
{
|
|
dev->ops->init = &mainboard_init;
|
|
}
|
|
|
|
struct chip_operations mainboard_ops = {
|
|
.name = "nyan",
|
|
.enable_dev = mainboard_enable,
|
|
};
|
|
|
|
void lb_board(struct lb_header *header)
|
|
{
|
|
struct lb_range *dma;
|
|
|
|
dma = (struct lb_range *)lb_new_record(header);
|
|
dma->tag = LB_TAB_DMA;
|
|
dma->size = sizeof(*dma);
|
|
dma->range_start = CONFIG_DRAM_DMA_START;
|
|
dma->range_size = CONFIG_DRAM_DMA_SIZE;
|
|
}
|