2011-01-27 19:58:05 +09:00
|
|
|
/*
|
|
|
|
* (C) Copyright 2010,2011
|
|
|
|
* NVIDIA Corporation <www.nvidia.com>
|
|
|
|
*
|
2013-07-08 16:37:19 +09:00
|
|
|
* SPDX-License-Identifier: GPL-2.0+
|
2011-01-27 19:58:05 +09:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
2014-11-11 09:16:51 +09:00
|
|
|
#include <dm.h>
|
2011-01-27 19:58:05 +09:00
|
|
|
#include <ns16550.h>
|
2012-04-10 14:17:06 +09:00
|
|
|
#include <linux/compiler.h>
|
2011-01-27 19:58:05 +09:00
|
|
|
#include <asm/io.h>
|
2011-08-30 15:23:13 +09:00
|
|
|
#include <asm/arch/clock.h>
|
2012-12-11 22:34:17 +09:00
|
|
|
#ifdef CONFIG_LCD
|
2012-10-17 22:24:52 +09:00
|
|
|
#include <asm/arch/display.h>
|
2012-12-11 22:34:17 +09:00
|
|
|
#endif
|
2012-09-29 19:02:09 +09:00
|
|
|
#include <asm/arch/funcmux.h>
|
2011-01-27 19:58:05 +09:00
|
|
|
#include <asm/arch/pinmux.h>
|
2012-04-02 22:18:54 +09:00
|
|
|
#include <asm/arch/pmu.h>
|
2012-12-11 22:34:17 +09:00
|
|
|
#ifdef CONFIG_PWM_TEGRA
|
2012-10-17 22:24:49 +09:00
|
|
|
#include <asm/arch/pwm.h>
|
2012-12-11 22:34:17 +09:00
|
|
|
#endif
|
2012-09-20 07:50:56 +09:00
|
|
|
#include <asm/arch/tegra.h>
|
2015-01-20 08:25:52 +09:00
|
|
|
#include <asm/arch-tegra/ap.h>
|
2012-09-20 07:50:56 +09:00
|
|
|
#include <asm/arch-tegra/board.h>
|
|
|
|
#include <asm/arch-tegra/clk_rst.h>
|
|
|
|
#include <asm/arch-tegra/pmc.h>
|
|
|
|
#include <asm/arch-tegra/sys_proto.h>
|
|
|
|
#include <asm/arch-tegra/uart.h>
|
|
|
|
#include <asm/arch-tegra/warmboot.h>
|
2012-12-11 22:34:17 +09:00
|
|
|
#ifdef CONFIG_TEGRA_CLOCK_SCALING
|
|
|
|
#include <asm/arch/emc.h>
|
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_USB_EHCI_TEGRA
|
2013-02-07 16:16:29 +09:00
|
|
|
#include <asm/arch-tegra/usb.h>
|
2013-10-05 02:22:26 +09:00
|
|
|
#include <usb.h>
|
2012-12-11 22:34:17 +09:00
|
|
|
#endif
|
2013-02-21 21:31:30 +09:00
|
|
|
#ifdef CONFIG_TEGRA_MMC
|
2013-02-27 04:26:55 +09:00
|
|
|
#include <asm/arch-tegra/tegra_mmc.h>
|
2013-02-21 21:31:30 +09:00
|
|
|
#include <asm/arch-tegra/mmc.h>
|
|
|
|
#endif
|
2014-12-10 14:25:09 +09:00
|
|
|
#include <asm/arch-tegra/xusb-padctl.h>
|
2012-02-04 00:13:57 +09:00
|
|
|
#include <i2c.h>
|
2012-12-11 22:34:17 +09:00
|
|
|
#include <spi.h>
|
2012-04-10 14:17:06 +09:00
|
|
|
#include "emc.h"
|
2011-01-27 19:58:05 +09:00
|
|
|
|
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
|
2014-11-11 09:16:51 +09:00
|
|
|
#ifdef CONFIG_SPL_BUILD
|
|
|
|
/* TODO(sjg@chromium.org): Remove once SPL supports device tree */
|
|
|
|
U_BOOT_DEVICE(tegra_gpios) = {
|
|
|
|
"gpio_tegra"
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2012-09-05 09:00:24 +09:00
|
|
|
const struct tegra_sysinfo sysinfo = {
|
|
|
|
CONFIG_TEGRA_BOARD_STRING
|
2011-01-27 19:58:05 +09:00
|
|
|
};
|
|
|
|
|
2014-10-09 05:57:46 +09:00
|
|
|
__weak void pinmux_init(void) {}
|
|
|
|
__weak void pin_mux_usb(void) {}
|
|
|
|
__weak void pin_mux_spi(void) {}
|
|
|
|
__weak void gpio_early_init_uart(void) {}
|
|
|
|
__weak void pin_mux_display(void) {}
|
2012-09-26 05:21:14 +09:00
|
|
|
|
2014-01-25 04:46:11 +09:00
|
|
|
#if defined(CONFIG_TEGRA_NAND)
|
2014-10-09 05:57:46 +09:00
|
|
|
__weak void pin_mux_nand(void)
|
2012-09-29 19:02:09 +09:00
|
|
|
{
|
|
|
|
funcmux_select(PERIPH_ID_NDFLASH, FUNCMUX_DEFAULT);
|
|
|
|
}
|
2014-01-25 04:46:11 +09:00
|
|
|
#endif
|
2012-09-29 19:02:09 +09:00
|
|
|
|
2012-04-02 22:18:58 +09:00
|
|
|
/*
|
|
|
|
* Routine: power_det_init
|
|
|
|
* Description: turn off power detects
|
|
|
|
*/
|
|
|
|
static void power_det_init(void)
|
|
|
|
{
|
2012-08-31 17:30:00 +09:00
|
|
|
#if defined(CONFIG_TEGRA20)
|
2012-09-05 09:00:24 +09:00
|
|
|
struct pmc_ctlr *const pmc = (struct pmc_ctlr *)NV_PA_PMC_BASE;
|
2012-04-02 22:18:58 +09:00
|
|
|
|
|
|
|
/* turn off power detects */
|
|
|
|
writel(0, &pmc->pmc_pwr_det_latch);
|
|
|
|
writel(0, &pmc->pmc_pwr_det);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2011-01-27 19:58:05 +09:00
|
|
|
/*
|
|
|
|
* Routine: board_init
|
|
|
|
* Description: Early hardware init.
|
|
|
|
*/
|
|
|
|
int board_init(void)
|
|
|
|
{
|
2012-04-10 14:17:06 +09:00
|
|
|
__maybe_unused int err;
|
|
|
|
|
2011-11-05 13:46:51 +09:00
|
|
|
/* Do clocks and UART first so that printf() works */
|
2011-09-21 21:40:04 +09:00
|
|
|
clock_init();
|
|
|
|
clock_verify();
|
|
|
|
|
2014-10-14 14:42:13 +09:00
|
|
|
#ifdef CONFIG_TEGRA_SPI
|
2012-06-12 17:33:40 +09:00
|
|
|
pin_mux_spi();
|
2012-10-17 22:24:49 +09:00
|
|
|
#endif
|
2013-01-29 22:51:28 +09:00
|
|
|
|
2012-10-17 22:24:49 +09:00
|
|
|
#ifdef CONFIG_PWM_TEGRA
|
|
|
|
if (pwm_init(gd->fdt_blob))
|
|
|
|
debug("%s: Failed to init pwm\n", __func__);
|
2012-10-17 22:24:52 +09:00
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_LCD
|
2012-11-25 20:26:11 +09:00
|
|
|
pin_mux_display();
|
2012-10-17 22:24:52 +09:00
|
|
|
tegra_lcd_check_next_stage(gd->fdt_blob, 0);
|
2011-11-05 18:48:11 +09:00
|
|
|
#endif
|
2011-01-27 19:58:05 +09:00
|
|
|
/* boot param addr */
|
|
|
|
gd->bd->bi_boot_params = (NV_PA_SDRAM_BASE + 0x100);
|
2012-04-02 22:18:58 +09:00
|
|
|
|
|
|
|
power_det_init();
|
|
|
|
|
2012-10-30 16:28:53 +09:00
|
|
|
#ifdef CONFIG_SYS_I2C_TEGRA
|
2012-04-02 22:18:54 +09:00
|
|
|
# ifdef CONFIG_TEGRA_PMU
|
|
|
|
if (pmu_set_nominal())
|
|
|
|
debug("Failed to select nominal voltages\n");
|
2012-04-10 14:17:06 +09:00
|
|
|
# ifdef CONFIG_TEGRA_CLOCK_SCALING
|
|
|
|
err = board_emc_init();
|
|
|
|
if (err)
|
|
|
|
debug("Memory controller init failed: %d\n", err);
|
|
|
|
# endif
|
|
|
|
# endif /* CONFIG_TEGRA_PMU */
|
2012-10-30 16:28:53 +09:00
|
|
|
#endif /* CONFIG_SYS_I2C_TEGRA */
|
2011-01-27 19:58:05 +09:00
|
|
|
|
2012-02-27 19:52:50 +09:00
|
|
|
#ifdef CONFIG_USB_EHCI_TEGRA
|
|
|
|
pin_mux_usb();
|
2013-10-05 02:22:26 +09:00
|
|
|
usb_process_devicetree(gd->fdt_blob);
|
2012-02-27 19:52:50 +09:00
|
|
|
#endif
|
2013-10-05 02:22:26 +09:00
|
|
|
|
2012-10-17 22:24:52 +09:00
|
|
|
#ifdef CONFIG_LCD
|
|
|
|
tegra_lcd_check_next_stage(gd->fdt_blob, 0);
|
|
|
|
#endif
|
2012-02-27 19:52:50 +09:00
|
|
|
|
2012-09-29 19:02:09 +09:00
|
|
|
#ifdef CONFIG_TEGRA_NAND
|
|
|
|
pin_mux_nand();
|
|
|
|
#endif
|
|
|
|
|
2014-12-10 14:25:09 +09:00
|
|
|
tegra_xusb_padctl_init(gd->fdt_blob);
|
|
|
|
|
2012-09-05 09:00:24 +09:00
|
|
|
#ifdef CONFIG_TEGRA_LP0
|
2012-08-31 17:30:11 +09:00
|
|
|
/* save Sdram params to PMC 2, 4, and 24 for WB0 */
|
|
|
|
warmboot_save_sdram_params();
|
|
|
|
|
2012-04-02 22:18:57 +09:00
|
|
|
/* prepare the WB code to LP0 location */
|
|
|
|
warmboot_prepare_code(TEGRA_LP0_ADDR, TEGRA_LP0_SIZE);
|
|
|
|
#endif
|
|
|
|
|
2011-01-27 19:58:05 +09:00
|
|
|
return 0;
|
|
|
|
}
|
2011-05-31 19:30:37 +09:00
|
|
|
|
2011-09-21 21:40:03 +09:00
|
|
|
#ifdef CONFIG_BOARD_EARLY_INIT_F
|
2012-06-05 05:02:27 +09:00
|
|
|
static void __gpio_early_init(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void gpio_early_init(void) __attribute__((weak, alias("__gpio_early_init")));
|
|
|
|
|
2011-09-21 21:40:03 +09:00
|
|
|
int board_early_init_f(void)
|
|
|
|
{
|
2012-12-11 22:34:17 +09:00
|
|
|
pinmux_init();
|
2011-11-29 00:04:40 +09:00
|
|
|
board_init_uart_f();
|
2011-09-21 21:40:03 +09:00
|
|
|
|
|
|
|
/* Initialize periph GPIOs */
|
2012-06-05 05:02:27 +09:00
|
|
|
gpio_early_init();
|
2011-11-05 13:46:51 +09:00
|
|
|
gpio_early_init_uart();
|
2012-10-17 22:24:52 +09:00
|
|
|
#ifdef CONFIG_LCD
|
|
|
|
tegra_lcd_early_init(gd->fdt_blob);
|
|
|
|
#endif
|
2012-09-26 05:21:14 +09:00
|
|
|
|
2011-09-21 21:40:03 +09:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif /* EARLY_INIT */
|
2012-10-17 22:24:52 +09:00
|
|
|
|
|
|
|
int board_late_init(void)
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_LCD
|
|
|
|
/* Make sure we finish initing the LCD */
|
|
|
|
tegra_lcd_check_next_stage(gd->fdt_blob, 1);
|
2015-01-20 08:25:52 +09:00
|
|
|
#endif
|
|
|
|
#if defined(CONFIG_TEGRA_SUPPORT_NON_SECURE)
|
|
|
|
if (tegra_cpu_is_non_secure()) {
|
|
|
|
printf("CPU is in NS mode\n");
|
|
|
|
setenv("cpu_ns_mode", "1");
|
|
|
|
} else {
|
|
|
|
setenv("cpu_ns_mode", "");
|
|
|
|
}
|
2012-10-17 22:24:52 +09:00
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|
2013-02-21 21:31:30 +09:00
|
|
|
|
|
|
|
#if defined(CONFIG_TEGRA_MMC)
|
2014-10-09 05:57:46 +09:00
|
|
|
__weak void pin_mux_mmc(void)
|
2013-02-21 21:31:30 +09:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/* this is a weak define that we are overriding */
|
|
|
|
int board_mmc_init(bd_t *bd)
|
|
|
|
{
|
|
|
|
debug("%s called\n", __func__);
|
|
|
|
|
|
|
|
/* Enable muxes, etc. for SDMMC controllers */
|
|
|
|
pin_mux_mmc();
|
|
|
|
|
|
|
|
debug("%s: init MMC\n", __func__);
|
|
|
|
tegra_mmc_init();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2013-02-27 04:26:55 +09:00
|
|
|
|
|
|
|
void pad_init_mmc(struct mmc_host *host)
|
|
|
|
{
|
|
|
|
#if defined(CONFIG_TEGRA30)
|
|
|
|
enum periph_id id = host->mmc_id;
|
|
|
|
u32 val;
|
|
|
|
|
|
|
|
debug("%s: sdmmc address = %08x, id = %d\n", __func__,
|
|
|
|
(unsigned int)host->reg, id);
|
|
|
|
|
|
|
|
/* Set the pad drive strength for SDMMC1 or 3 only */
|
|
|
|
if (id != PERIPH_ID_SDMMC1 && id != PERIPH_ID_SDMMC3) {
|
|
|
|
debug("%s: settings are only valid for SDMMC1/SDMMC3!\n",
|
|
|
|
__func__);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
val = readl(&host->reg->sdmemcmppadctl);
|
|
|
|
val &= 0xFFFFFFF0;
|
|
|
|
val |= MEMCOMP_PADCTRL_VREF;
|
|
|
|
writel(val, &host->reg->sdmemcmppadctl);
|
|
|
|
|
|
|
|
val = readl(&host->reg->autocalcfg);
|
|
|
|
val &= 0xFFFF0000;
|
|
|
|
val |= AUTO_CAL_PU_OFFSET | AUTO_CAL_PD_OFFSET | AUTO_CAL_ENABLED;
|
|
|
|
writel(val, &host->reg->autocalcfg);
|
|
|
|
#endif /* T30 */
|
|
|
|
}
|
|
|
|
#endif /* MMC */
|