2011-01-27 10:58:05 +00:00
|
|
|
/*
|
|
|
|
* (C) Copyright 2010,2011
|
|
|
|
* NVIDIA Corporation <www.nvidia.com>
|
|
|
|
*
|
|
|
|
* See file CREDITS for list of people who contributed to this
|
|
|
|
* project.
|
|
|
|
*
|
|
|
|
* 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; either version 2 of
|
|
|
|
* the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* 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., 59 Temple Place, Suite 330, Boston,
|
|
|
|
* MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#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-04-10 05:17:06 +00:00
|
|
|
#include <asm/arch/emc.h>
|
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-09-19 22:50:56 +00:00
|
|
|
#include <asm/arch/tegra.h>
|
2012-02-27 10:52:50 +00:00
|
|
|
#include <asm/arch/usb.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>
|
|
|
|
#include <spi.h>
|
2012-02-03 15:13:57 +00:00
|
|
|
#include <i2c.h>
|
2012-04-10 05:17:06 +00:00
|
|
|
#include "emc.h"
|
2011-01-27 10:58:05 +00:00
|
|
|
|
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
|
2012-09-05 00:00:24 +00:00
|
|
|
const struct tegra_sysinfo sysinfo = {
|
|
|
|
CONFIG_TEGRA_BOARD_STRING
|
2011-01-27 10:58:05 +00:00
|
|
|
};
|
|
|
|
|
2012-08-31 08:30:08 +00:00
|
|
|
#ifndef CONFIG_SPL_BUILD
|
2011-01-27 10:58:05 +00:00
|
|
|
/*
|
|
|
|
* Routine: timer_init
|
|
|
|
* Description: init the timestamp and lastinc value
|
|
|
|
*/
|
|
|
|
int timer_init(void)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2012-08-31 08:30:08 +00:00
|
|
|
#endif
|
2011-01-27 10:58:05 +00:00
|
|
|
|
2012-02-27 10:52:50 +00:00
|
|
|
void __pin_mux_usb(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void pin_mux_usb(void) __attribute__((weak, alias("__pin_mux_usb")));
|
|
|
|
|
2012-06-12 08:33:40 +00:00
|
|
|
void __pin_mux_spi(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void pin_mux_spi(void) __attribute__((weak, alias("__pin_mux_spi")));
|
|
|
|
|
2012-09-25 20:21:14 +00:00
|
|
|
void __gpio_early_init_uart(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void gpio_early_init_uart(void)
|
|
|
|
__attribute__((weak, alias("__gpio_early_init_uart")));
|
|
|
|
|
2012-09-29 10:02:09 +00:00
|
|
|
void __pin_mux_nand(void)
|
|
|
|
{
|
|
|
|
funcmux_select(PERIPH_ID_NDFLASH, FUNCMUX_DEFAULT);
|
|
|
|
}
|
|
|
|
|
|
|
|
void pin_mux_nand(void) __attribute__((weak, alias("__pin_mux_nand")));
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
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();
|
|
|
|
|
2011-11-05 04:46:51 +00:00
|
|
|
#ifdef CONFIG_SPI_UART_SWITCH
|
|
|
|
gpio_config_uart();
|
|
|
|
#endif
|
2012-06-01 08:22:14 +00:00
|
|
|
#ifdef CONFIG_TEGRA_SPI
|
2012-06-12 08:33:40 +00:00
|
|
|
pin_mux_spi();
|
2011-11-05 09:48:11 +00:00
|
|
|
spi_init();
|
|
|
|
#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-02-03 15:13:57 +00:00
|
|
|
#ifdef CONFIG_TEGRA_I2C
|
|
|
|
#ifndef CONFIG_SYS_I2C_INIT_BOARD
|
|
|
|
#error "You must define CONFIG_SYS_I2C_INIT_BOARD to use i2c on Nvidia boards"
|
|
|
|
#endif
|
|
|
|
i2c_init_board();
|
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 */
|
|
|
|
#endif /* CONFIG_TEGRA_I2C */
|
2011-01-27 10:58:05 +00:00
|
|
|
|
2012-02-27 10:52:50 +00:00
|
|
|
#ifdef CONFIG_USB_EHCI_TEGRA
|
|
|
|
pin_mux_usb();
|
|
|
|
board_usb_init(gd->fdt_blob);
|
|
|
|
#endif
|
|
|
|
|
2012-09-29 10:02:09 +00:00
|
|
|
#ifdef CONFIG_TEGRA_NAND
|
|
|
|
pin_mux_nand();
|
|
|
|
#endif
|
|
|
|
|
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)
|
|
|
|
{
|
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-09-25 20:21:14 +00:00
|
|
|
|
2011-09-21 12:40:03 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif /* EARLY_INIT */
|