2 * (C) Copyright 2010,2011
3 * NVIDIA Corporation <www.nvidia.com>
5 * See file CREDITS for list of people who contributed to this
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
27 #include <asm/arch/tegra2.h>
28 #include <asm/arch/sys_proto.h>
30 #include <asm/arch/clk_rst.h>
31 #include <asm/arch/pinmux.h>
32 #include <asm/arch/uart.h>
35 DECLARE_GLOBAL_DATA_PTR;
37 const struct tegra2_sysinfo sysinfo = {
38 CONFIG_TEGRA2_BOARD_STRING
41 #ifdef CONFIG_BOARD_EARLY_INIT_F
42 int board_early_init_f(void)
44 /* Initialize periph clocks */
47 /* Initialize periph pinmuxes */
50 /* Initialize periph GPIOs */
53 /* Init UART, scratch regs, and start CPU */
57 #endif /* EARLY_INIT */
61 * Description: init the timestamp and lastinc value
70 * Routine: clock_init_uart
71 * Description: init the PLL and clock for the UART(s)
73 static void clock_init_uart(void)
75 struct clk_rst_ctlr *clkrst = (struct clk_rst_ctlr *)NV_PA_CLK_RST_BASE;
78 reg = readl(&clkrst->crc_pllp_base);
79 if (!(reg & PLL_BASE_OVRRIDE)) {
80 /* Override pllp setup for 216MHz operation. */
81 reg = (PLL_BYPASS | PLL_BASE_OVRRIDE | PLL_DIVP);
82 reg |= (((NVRM_PLLP_FIXED_FREQ_KHZ/500) << 8) | PLL_DIVM);
83 writel(reg, &clkrst->crc_pllp_base);
86 writel(reg, &clkrst->crc_pllp_base);
89 writel(reg, &clkrst->crc_pllp_base);
92 /* Now do the UART reset/clock enable */
93 #if defined(CONFIG_TEGRA2_ENABLE_UARTA)
94 /* Assert Reset to UART */
95 reg = readl(&clkrst->crc_rst_dev_l);
96 reg |= SWR_UARTA_RST; /* SWR_UARTA_RST = 1 */
97 writel(reg, &clkrst->crc_rst_dev_l);
99 /* Enable clk to UART */
100 reg = readl(&clkrst->crc_clk_out_enb_l);
101 reg |= CLK_ENB_UARTA; /* CLK_ENB_UARTA = 1 */
102 writel(reg, &clkrst->crc_clk_out_enb_l);
104 /* Enable pllp_out0 to UART */
105 reg = readl(&clkrst->crc_clk_src_uarta);
106 reg &= 0x3FFFFFFF; /* UARTA_CLK_SRC = 00, PLLP_OUT0 */
107 writel(reg, &clkrst->crc_clk_src_uarta);
112 /* De-assert reset to UART */
113 reg = readl(&clkrst->crc_rst_dev_l);
114 reg &= ~SWR_UARTA_RST; /* SWR_UARTA_RST = 0 */
115 writel(reg, &clkrst->crc_rst_dev_l);
116 #endif /* CONFIG_TEGRA2_ENABLE_UARTA */
117 #if defined(CONFIG_TEGRA2_ENABLE_UARTD)
118 /* Assert Reset to UART */
119 reg = readl(&clkrst->crc_rst_dev_u);
120 reg |= SWR_UARTD_RST; /* SWR_UARTD_RST = 1 */
121 writel(reg, &clkrst->crc_rst_dev_u);
123 /* Enable clk to UART */
124 reg = readl(&clkrst->crc_clk_out_enb_u);
125 reg |= CLK_ENB_UARTD; /* CLK_ENB_UARTD = 1 */
126 writel(reg, &clkrst->crc_clk_out_enb_u);
128 /* Enable pllp_out0 to UART */
129 reg = readl(&clkrst->crc_clk_src_uartd);
130 reg &= 0x3FFFFFFF; /* UARTD_CLK_SRC = 00, PLLP_OUT0 */
131 writel(reg, &clkrst->crc_clk_src_uartd);
136 /* De-assert reset to UART */
137 reg = readl(&clkrst->crc_rst_dev_u);
138 reg &= ~SWR_UARTD_RST; /* SWR_UARTD_RST = 0 */
139 writel(reg, &clkrst->crc_rst_dev_u);
140 #endif /* CONFIG_TEGRA2_ENABLE_UARTD */
144 * Routine: pin_mux_uart
145 * Description: setup the pin muxes/tristate values for the UART(s)
147 static void pin_mux_uart(void)
149 struct pmux_tri_ctlr *pmt = (struct pmux_tri_ctlr *)NV_PA_APB_MISC_BASE;
152 #if defined(CONFIG_TEGRA2_ENABLE_UARTA)
153 reg = readl(&pmt->pmt_ctl_c);
154 reg &= 0xFFF0FFFF; /* IRRX_/IRTX_SEL [19:16] = 00 UARTA */
155 writel(reg, &pmt->pmt_ctl_c);
157 reg = readl(&pmt->pmt_tri_a);
158 reg &= ~Z_IRRX; /* Z_IRRX = normal (0) */
159 reg &= ~Z_IRTX; /* Z_IRTX = normal (0) */
160 writel(reg, &pmt->pmt_tri_a);
161 #endif /* CONFIG_TEGRA2_ENABLE_UARTA */
162 #if defined(CONFIG_TEGRA2_ENABLE_UARTD)
163 reg = readl(&pmt->pmt_ctl_b);
164 reg &= 0xFFFFFFF3; /* GMC_SEL [3:2] = 00, UARTD */
165 writel(reg, &pmt->pmt_ctl_b);
167 reg = readl(&pmt->pmt_tri_a);
168 reg &= ~Z_GMC; /* Z_GMC = normal (0) */
169 writel(reg, &pmt->pmt_tri_a);
170 #endif /* CONFIG_TEGRA2_ENABLE_UARTD */
174 * Routine: clock_init
175 * Description: Do individual peripheral clock reset/enables
177 void clock_init(void)
183 * Routine: pinmux_init
184 * Description: Do individual peripheral pinmux configs
186 void pinmux_init(void)
193 * Description: Do individual peripheral GPIO configs
201 * Routine: board_init
202 * Description: Early hardware init.
206 /* boot param addr */
207 gd->bd->bi_boot_params = (NV_PA_SDRAM_BASE + 0x100);
208 /* board id for Linux */
209 gd->bd->bi_arch_number = CONFIG_MACH_TYPE;