2011-01-27 10:58:05 +00:00
|
|
|
/*
|
|
|
|
* (C) Copyright 2010,2011
|
|
|
|
* NVIDIA Corporation <www.nvidia.com>
|
|
|
|
*
|
2013-07-08 07:37:19 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0+
|
2011-01-27 10:58:05 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
2014-11-11 00:16:51 +00:00
|
|
|
#include <dm.h>
|
2015-04-15 03:03:28 +00:00
|
|
|
#include <errno.h>
|
2011-01-27 10:58:05 +00:00
|
|
|
#include <ns16550.h>
|
2012-04-10 05:17:06 +00:00
|
|
|
#include <linux/compiler.h>
|
2011-01-27 10:58:05 +00:00
|
|
|
#include <asm/io.h>
|
2011-08-30 06:23:13 +00:00
|
|
|
#include <asm/arch/clock.h>
|
2012-12-11 13:34:17 +00:00
|
|
|
#ifdef CONFIG_LCD
|
2012-10-17 13:24:52 +00:00
|
|
|
#include <asm/arch/display.h>
|
2012-12-11 13:34:17 +00:00
|
|
|
#endif
|
2012-09-29 10:02:09 +00:00
|
|
|
#include <asm/arch/funcmux.h>
|
2011-01-27 10:58:05 +00:00
|
|
|
#include <asm/arch/pinmux.h>
|
2012-04-02 13:18:54 +00:00
|
|
|
#include <asm/arch/pmu.h>
|
2012-12-11 13:34:17 +00:00
|
|
|
#ifdef CONFIG_PWM_TEGRA
|
2012-10-17 13:24:49 +00:00
|
|
|
#include <asm/arch/pwm.h>
|
2012-12-11 13:34:17 +00:00
|
|
|
#endif
|
2012-09-19 22:50:56 +00:00
|
|
|
#include <asm/arch/tegra.h>
|
2015-01-19 23:25:52 +00:00
|
|
|
#include <asm/arch-tegra/ap.h>
|
2012-09-19 22:50:56 +00: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 13:34:17 +00:00
|
|
|
#ifdef CONFIG_TEGRA_CLOCK_SCALING
|
|
|
|
#include <asm/arch/emc.h>
|
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_USB_EHCI_TEGRA
|
2013-02-07 07:16:29 +00:00
|
|
|
#include <asm/arch-tegra/usb.h>
|
2013-10-04 17:22:26 +00:00
|
|
|
#include <usb.h>
|
2012-12-11 13:34:17 +00:00
|
|
|
#endif
|
2013-02-21 12:31:30 +00:00
|
|
|
#ifdef CONFIG_TEGRA_MMC
|
2013-02-26 19:26:55 +00:00
|
|
|
#include <asm/arch-tegra/tegra_mmc.h>
|
2013-02-21 12:31:30 +00:00
|
|
|
#include <asm/arch-tegra/mmc.h>
|
|
|
|
#endif
|
2014-12-10 05:25:09 +00:00
|
|
|
#include <asm/arch-tegra/xusb-padctl.h>
|
2015-04-15 03:03:28 +00:00
|
|
|
#include <power/as3722.h>
|
2012-02-03 15:13:57 +00:00
|
|
|
#include <i2c.h>
|
2012-12-11 13:34:17 +00:00
|
|
|
#include <spi.h>
|
2012-04-10 05:17:06 +00:00
|
|
|
#include "emc.h"
|
2011-01-27 10:58:05 +00:00
|
|
|
|
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
|
2014-11-11 00:16:51 +00:00
|
|
|
#ifdef CONFIG_SPL_BUILD
|
|
|
|
/* TODO(sjg@chromium.org): Remove once SPL supports device tree */
|
|
|
|
U_BOOT_DEVICE(tegra_gpios) = {
|
|
|
|
"gpio_tegra"
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2014-10-08 20:57:46 +00: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-25 20:21:14 +00:00
|
|
|
|
2014-01-24 19:46:11 +00:00
|
|
|
#if defined(CONFIG_TEGRA_NAND)
|
2014-10-08 20:57:46 +00:00
|
|
|
__weak void pin_mux_nand(void)
|
2012-09-29 10:02:09 +00:00
|
|
|
{
|
|
|
|
funcmux_select(PERIPH_ID_NDFLASH, FUNCMUX_DEFAULT);
|
|
|
|
}
|
2014-01-24 19:46:11 +00:00
|
|
|
#endif
|
2012-09-29 10:02:09 +00:00
|
|
|
|
2012-04-02 13:18:58 +00:00
|
|
|
/*
|
|
|
|
* Routine: power_det_init
|
|
|
|
* Description: turn off power detects
|
|
|
|
*/
|
|
|
|
static void power_det_init(void)
|
|
|
|
{
|
2012-08-31 08:30:00 +00:00
|
|
|
#if defined(CONFIG_TEGRA20)
|
2012-09-05 00:00:24 +00:00
|
|
|
struct pmc_ctlr *const pmc = (struct pmc_ctlr *)NV_PA_PMC_BASE;
|
2012-04-02 13:18:58 +00:00
|
|
|
|
|
|
|
/* turn off power detects */
|
|
|
|
writel(0, &pmc->pmc_pwr_det_latch);
|
|
|
|
writel(0, &pmc->pmc_pwr_det);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2015-04-15 03:03:25 +00:00
|
|
|
__weak int tegra_board_id(void)
|
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2015-04-15 03:03:24 +00:00
|
|
|
#ifdef CONFIG_DISPLAY_BOARDINFO
|
|
|
|
int checkboard(void)
|
|
|
|
{
|
2015-04-15 03:03:25 +00:00
|
|
|
int board_id = tegra_board_id();
|
|
|
|
|
|
|
|
printf("Board: %s", CONFIG_TEGRA_BOARD_STRING);
|
|
|
|
if (board_id != -1)
|
|
|
|
printf(", ID: %d\n", board_id);
|
|
|
|
printf("\n");
|
2015-04-15 03:03:24 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_DISPLAY_BOARDINFO */
|
|
|
|
|
2015-04-15 03:03:27 +00:00
|
|
|
__weak int tegra_lcd_pmic_init(int board_it)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-01-27 10:58:05 +00:00
|
|
|
/*
|
|
|
|
* Routine: board_init
|
|
|
|
* Description: Early hardware init.
|
|
|
|
*/
|
|
|
|
int board_init(void)
|
|
|
|
{
|
2012-04-10 05:17:06 +00:00
|
|
|
__maybe_unused int err;
|
2015-04-15 03:03:27 +00:00
|
|
|
__maybe_unused int board_id;
|
2012-04-10 05:17:06 +00:00
|
|
|
|
2011-11-05 04:46:51 +00:00
|
|
|
/* Do clocks and UART first so that printf() works */
|
2011-09-21 12:40:04 +00:00
|
|
|
clock_init();
|
|
|
|
clock_verify();
|
|
|
|
|
2014-10-14 05:42:13 +00:00
|
|
|
#ifdef CONFIG_TEGRA_SPI
|
2012-06-12 08:33:40 +00:00
|
|
|
pin_mux_spi();
|
2012-10-17 13:24:49 +00:00
|
|
|
#endif
|
2013-01-29 13:51:28 +00:00
|
|
|
|
2012-10-17 13:24:49 +00:00
|
|
|
#ifdef CONFIG_PWM_TEGRA
|
|
|
|
if (pwm_init(gd->fdt_blob))
|
|
|
|
debug("%s: Failed to init pwm\n", __func__);
|
2012-10-17 13:24:52 +00:00
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_LCD
|
2012-11-25 11:26:11 +00:00
|
|
|
pin_mux_display();
|
2012-10-17 13:24:52 +00:00
|
|
|
tegra_lcd_check_next_stage(gd->fdt_blob, 0);
|
2011-11-05 09:48:11 +00:00
|
|
|
#endif
|
2011-01-27 10:58:05 +00:00
|
|
|
/* boot param addr */
|
|
|
|
gd->bd->bi_boot_params = (NV_PA_SDRAM_BASE + 0x100);
|
2012-04-02 13:18:58 +00:00
|
|
|
|
|
|
|
power_det_init();
|
|
|
|
|
2012-10-30 07:28:53 +00:00
|
|
|
#ifdef CONFIG_SYS_I2C_TEGRA
|
2012-04-02 13:18:54 +00:00
|
|
|
# ifdef CONFIG_TEGRA_PMU
|
|
|
|
if (pmu_set_nominal())
|
|
|
|
debug("Failed to select nominal voltages\n");
|
2012-04-10 05:17:06 +00: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 */
|
2015-04-15 03:03:28 +00:00
|
|
|
#ifdef CONFIG_AS3722_POWER
|
|
|
|
err = as3722_init(NULL);
|
|
|
|
if (err && err != -ENODEV)
|
|
|
|
return err;
|
|
|
|
#endif
|
2012-10-30 07:28:53 +00:00
|
|
|
#endif /* CONFIG_SYS_I2C_TEGRA */
|
2011-01-27 10:58:05 +00:00
|
|
|
|
2012-02-27 10:52:50 +00:00
|
|
|
#ifdef CONFIG_USB_EHCI_TEGRA
|
|
|
|
pin_mux_usb();
|
2013-10-04 17:22:26 +00:00
|
|
|
usb_process_devicetree(gd->fdt_blob);
|
2012-02-27 10:52:50 +00:00
|
|
|
#endif
|
2013-10-04 17:22:26 +00:00
|
|
|
|
2012-10-17 13:24:52 +00:00
|
|
|
#ifdef CONFIG_LCD
|
2015-04-15 03:03:27 +00:00
|
|
|
board_id = tegra_board_id();
|
|
|
|
err = tegra_lcd_pmic_init(board_id);
|
|
|
|
if (err)
|
|
|
|
return err;
|
2012-10-17 13:24:52 +00:00
|
|
|
tegra_lcd_check_next_stage(gd->fdt_blob, 0);
|
|
|
|
#endif
|
2012-02-27 10:52:50 +00:00
|
|
|
|
2012-09-29 10:02:09 +00:00
|
|
|
#ifdef CONFIG_TEGRA_NAND
|
|
|
|
pin_mux_nand();
|
|
|
|
#endif
|
|
|
|
|
2014-12-10 05:25:09 +00:00
|
|
|
tegra_xusb_padctl_init(gd->fdt_blob);
|
|
|
|
|
2012-09-05 00:00:24 +00:00
|
|
|
#ifdef CONFIG_TEGRA_LP0
|
2012-08-31 08:30:11 +00:00
|
|
|
/* save Sdram params to PMC 2, 4, and 24 for WB0 */
|
|
|
|
warmboot_save_sdram_params();
|
|
|
|
|
2012-04-02 13:18:57 +00:00
|
|
|
/* prepare the WB code to LP0 location */
|
|
|
|
warmboot_prepare_code(TEGRA_LP0_ADDR, TEGRA_LP0_SIZE);
|
|
|
|
#endif
|
|
|
|
|
2011-01-27 10:58:05 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2011-05-31 10:30:37 +00:00
|
|
|
|
2011-09-21 12:40:03 +00:00
|
|
|
#ifdef CONFIG_BOARD_EARLY_INIT_F
|
2012-06-04 20:02:27 +00:00
|
|
|
static void __gpio_early_init(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void gpio_early_init(void) __attribute__((weak, alias("__gpio_early_init")));
|
|
|
|
|
2011-09-21 12:40:03 +00:00
|
|
|
int board_early_init_f(void)
|
|
|
|
{
|
2012-12-11 13:34:17 +00:00
|
|
|
pinmux_init();
|
2011-11-28 15:04:40 +00:00
|
|
|
board_init_uart_f();
|
2011-09-21 12:40:03 +00:00
|
|
|
|
|
|
|
/* Initialize periph GPIOs */
|
2012-06-04 20:02:27 +00:00
|
|
|
gpio_early_init();
|
2011-11-05 04:46:51 +00:00
|
|
|
gpio_early_init_uart();
|
2012-10-17 13:24:52 +00:00
|
|
|
#ifdef CONFIG_LCD
|
|
|
|
tegra_lcd_early_init(gd->fdt_blob);
|
|
|
|
#endif
|
2012-09-25 20:21:14 +00:00
|
|
|
|
2011-09-21 12:40:03 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif /* EARLY_INIT */
|
2012-10-17 13:24:52 +00: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-19 23:25:52 +00: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 13:24:52 +00:00
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|
2013-02-21 12:31:30 +00:00
|
|
|
|
|
|
|
#if defined(CONFIG_TEGRA_MMC)
|
2014-10-08 20:57:46 +00:00
|
|
|
__weak void pin_mux_mmc(void)
|
2013-02-21 12:31:30 +00: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-26 19:26:55 +00: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 */
|