2 * Copyright (C) 2011 Samsung Electronics
6 * See file CREDITS for list of people who contributed to this
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2 of
12 * the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
27 #include <asm/arch/cpu.h>
28 #include <asm/arch/gpio.h>
29 #include <asm/arch/mmc.h>
30 #include <asm/arch/clock.h>
31 #include <asm/arch/watchdog.h>
32 #include <asm/arch/power.h>
34 #include <usb/s3c_udc.h>
35 #include <max8998_pmic.h>
39 DECLARE_GLOBAL_DATA_PTR;
41 unsigned int board_rev;
43 #ifdef CONFIG_REVISION_TAG
44 u32 get_board_rev(void)
50 static void check_hw_revision(void);
54 gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
57 printf("HW Revision:\t0x%x\n", board_rev);
59 #if defined(CONFIG_PMIC)
68 gd->ram_size = get_ram_size((long *)PHYS_SDRAM_1, PHYS_SDRAM_1_SIZE) +
69 get_ram_size((long *)PHYS_SDRAM_2, PHYS_SDRAM_2_SIZE);
74 void dram_init_banksize(void)
76 gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
77 gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
78 gd->bd->bi_dram[1].start = PHYS_SDRAM_2;
79 gd->bd->bi_dram[1].size = PHYS_SDRAM_2_SIZE;
82 static unsigned int get_hw_revision(void)
84 struct exynos4_gpio_part1 *gpio =
85 (struct exynos4_gpio_part1 *)samsung_get_base_gpio_part1();
89 /* hw_rev[3:0] == GPE1[3:0] */
90 for (i = 0; i < 4; i++) {
91 s5p_gpio_cfg_pin(&gpio->e1, i, GPIO_INPUT);
92 s5p_gpio_set_pull(&gpio->e1, i, GPIO_PULL_NONE);
97 for (i = 0; i < 4; i++)
98 hwrev |= (s5p_gpio_get_value(&gpio->e1, i) << i);
100 debug("hwrev 0x%x\n", hwrev);
105 static void check_hw_revision(void)
109 hwrev = get_hw_revision();
114 #ifdef CONFIG_DISPLAY_BOARDINFO
117 puts("Board:\tTRATS\n");
122 #ifdef CONFIG_GENERIC_MMC
123 int board_mmc_init(bd_t *bis)
125 struct exynos4_gpio_part2 *gpio =
126 (struct exynos4_gpio_part2 *)samsung_get_base_gpio_part2();
129 /* eMMC_EN: SD_0_CDn: GPK0[2] Output High */
130 s5p_gpio_direction_output(&gpio->k0, 2, 1);
131 s5p_gpio_set_pull(&gpio->k0, 2, GPIO_PULL_NONE);
135 * SDR 8-bit@48MHz at MMC0
136 * GPK0[0] SD_0_CLK(2)
137 * GPK0[1] SD_0_CMD(2)
138 * GPK0[2] SD_0_CDn -> Not used
139 * GPK0[3:6] SD_0_DATA[0:3](2)
140 * GPK1[3:6] SD_0_DATA[0:3](3)
142 * DDR 4-bit@26MHz at MMC4
143 * GPK0[0] SD_4_CLK(3)
144 * GPK0[1] SD_4_CMD(3)
145 * GPK0[2] SD_4_CDn -> Not used
146 * GPK0[3:6] SD_4_DATA[0:3](3)
147 * GPK1[3:6] SD_4_DATA[4:7](4)
149 for (i = 0; i < 7; i++) {
152 /* GPK0[0:6] special function 2 */
153 s5p_gpio_cfg_pin(&gpio->k0, i, 0x2);
154 /* GPK0[0:6] pull disable */
155 s5p_gpio_set_pull(&gpio->k0, i, GPIO_PULL_NONE);
156 /* GPK0[0:6] drv 4x */
157 s5p_gpio_set_drv(&gpio->k0, i, GPIO_DRV_4X);
160 for (i = 3; i < 7; i++) {
161 /* GPK1[3:6] special function 3 */
162 s5p_gpio_cfg_pin(&gpio->k1, i, 0x3);
163 /* GPK1[3:6] pull disable */
164 s5p_gpio_set_pull(&gpio->k1, i, GPIO_PULL_NONE);
165 /* GPK1[3:6] drv 4x */
166 s5p_gpio_set_drv(&gpio->k1, i, GPIO_DRV_4X);
171 * mmc0 : eMMC (8-bit buswidth)
172 * mmc2 : SD card (4-bit buswidth)
174 err = s5p_mmc_init(0, 8);
177 s5p_gpio_cfg_pin(&gpio->x3, 4, 0xf);
178 s5p_gpio_set_pull(&gpio->x3, 4, GPIO_PULL_UP);
181 * Check the T-flash detect pin
182 * GPX3[4] T-flash detect pin
184 if (!s5p_gpio_get_value(&gpio->x3, 4)) {
187 * GPK2[0] SD_2_CLK(2)
188 * GPK2[1] SD_2_CMD(2)
189 * GPK2[2] SD_2_CDn -> Not used
190 * GPK2[3:6] SD_2_DATA[0:3](2)
192 for (i = 0; i < 7; i++) {
195 /* GPK2[0:6] special function 2 */
196 s5p_gpio_cfg_pin(&gpio->k2, i, 0x2);
197 /* GPK2[0:6] pull disable */
198 s5p_gpio_set_pull(&gpio->k2, i, GPIO_PULL_NONE);
199 /* GPK2[0:6] drv 4x */
200 s5p_gpio_set_drv(&gpio->k2, i, GPIO_DRV_4X);
202 err = s5p_mmc_init(2, 4);
209 #ifdef CONFIG_USB_GADGET
210 static int s5pc210_phy_control(int on)
213 struct pmic *p = get_pmic();
219 ret |= pmic_set_output(p,
220 MAX8998_REG_BUCK_ACTIVE_DISCHARGE3,
221 MAX8998_SAFEOUT1, LDO_ON);
222 ret |= pmic_set_output(p, MAX8998_REG_ONOFF1,
223 MAX8998_LDO3, LDO_ON);
224 ret |= pmic_set_output(p, MAX8998_REG_ONOFF2,
225 MAX8998_LDO8, LDO_ON);
228 ret |= pmic_set_output(p, MAX8998_REG_ONOFF2,
229 MAX8998_LDO8, LDO_OFF);
230 ret |= pmic_set_output(p, MAX8998_REG_ONOFF1,
231 MAX8998_LDO3, LDO_OFF);
232 ret |= pmic_set_output(p,
233 MAX8998_REG_BUCK_ACTIVE_DISCHARGE3,
234 MAX8998_SAFEOUT1, LDO_OFF);
238 puts("MAX8998 LDO setting error!\n");
245 struct s3c_plat_otg_data s5pc210_otg_data = {
246 .phy_control = s5pc210_phy_control,
247 .regs_phy = EXYNOS4_USBPHY_BASE,
248 .regs_otg = EXYNOS4_USBOTG_BASE,
249 .usb_phy_ctrl = EXYNOS4_USBPHY_CONTROL,
250 .usb_flags = PHY0_SLEEP,
254 static void pmic_reset(void)
256 struct exynos4_gpio_part2 *gpio =
257 (struct exynos4_gpio_part2 *)samsung_get_base_gpio_part2();
259 s5p_gpio_direction_output(&gpio->x0, 7, 1);
260 s5p_gpio_set_pull(&gpio->x2, 7, GPIO_PULL_NONE);
263 static void board_clock_init(void)
265 struct exynos4_clock *clk =
266 (struct exynos4_clock *)samsung_get_base_clock();
268 writel(CLK_SRC_CPU_VAL, (unsigned int)&clk->src_cpu);
269 writel(CLK_SRC_TOP0_VAL, (unsigned int)&clk->src_top0);
270 writel(CLK_SRC_FSYS_VAL, (unsigned int)&clk->src_fsys);
271 writel(CLK_SRC_PERIL0_VAL, (unsigned int)&clk->src_peril0);
273 writel(CLK_DIV_CPU0_VAL, (unsigned int)&clk->div_cpu0);
274 writel(CLK_DIV_CPU1_VAL, (unsigned int)&clk->div_cpu1);
275 writel(CLK_DIV_DMC0_VAL, (unsigned int)&clk->div_dmc0);
276 writel(CLK_DIV_DMC1_VAL, (unsigned int)&clk->div_dmc1);
277 writel(CLK_DIV_LEFTBUS_VAL, (unsigned int)&clk->div_leftbus);
278 writel(CLK_DIV_RIGHTBUS_VAL, (unsigned int)&clk->div_rightbus);
279 writel(CLK_DIV_TOP_VAL, (unsigned int)&clk->div_top);
280 writel(CLK_DIV_FSYS1_VAL, (unsigned int)&clk->div_fsys1);
281 writel(CLK_DIV_FSYS2_VAL, (unsigned int)&clk->div_fsys2);
282 writel(CLK_DIV_FSYS3_VAL, (unsigned int)&clk->div_fsys3);
283 writel(CLK_DIV_PERIL0_VAL, (unsigned int)&clk->div_peril0);
284 writel(CLK_DIV_PERIL3_VAL, (unsigned int)&clk->div_peril3);
286 writel(PLL_LOCKTIME, (unsigned int)&clk->apll_lock);
287 writel(PLL_LOCKTIME, (unsigned int)&clk->mpll_lock);
288 writel(PLL_LOCKTIME, (unsigned int)&clk->epll_lock);
289 writel(PLL_LOCKTIME, (unsigned int)&clk->vpll_lock);
290 writel(APLL_CON1_VAL, (unsigned int)&clk->apll_con1);
291 writel(APLL_CON0_VAL, (unsigned int)&clk->apll_con0);
292 writel(MPLL_CON1_VAL, (unsigned int)&clk->mpll_con1);
293 writel(MPLL_CON0_VAL, (unsigned int)&clk->mpll_con0);
294 writel(EPLL_CON1_VAL, (unsigned int)&clk->epll_con1);
295 writel(EPLL_CON0_VAL, (unsigned int)&clk->epll_con0);
296 writel(VPLL_CON1_VAL, (unsigned int)&clk->vpll_con1);
297 writel(VPLL_CON0_VAL, (unsigned int)&clk->vpll_con0);
299 writel(CLK_GATE_IP_CAM_VAL, (unsigned int)&clk->gate_ip_cam);
300 writel(CLK_GATE_IP_VP_VAL, (unsigned int)&clk->gate_ip_tv);
301 writel(CLK_GATE_IP_MFC_VAL, (unsigned int)&clk->gate_ip_mfc);
302 writel(CLK_GATE_IP_G3D_VAL, (unsigned int)&clk->gate_ip_g3d);
303 writel(CLK_GATE_IP_IMAGE_VAL, (unsigned int)&clk->gate_ip_image);
304 writel(CLK_GATE_IP_LCD0_VAL, (unsigned int)&clk->gate_ip_lcd0);
305 writel(CLK_GATE_IP_LCD1_VAL, (unsigned int)&clk->gate_ip_lcd1);
306 writel(CLK_GATE_IP_FSYS_VAL, (unsigned int)&clk->gate_ip_fsys);
307 writel(CLK_GATE_IP_GPS_VAL, (unsigned int)&clk->gate_ip_gps);
308 writel(CLK_GATE_IP_PERIL_VAL, (unsigned int)&clk->gate_ip_peril);
309 writel(CLK_GATE_IP_PERIR_VAL, (unsigned int)&clk->gate_ip_perir);
310 writel(CLK_GATE_BLOCK_VAL, (unsigned int)&clk->gate_block);
313 static void board_power_init(void)
315 struct exynos4_power *pwr =
316 (struct exynos4_power *)samsung_get_base_power();
319 writel(EXYNOS4_PS_HOLD_CON_VAL, (unsigned int)&pwr->ps_hold_control);
322 writel(0, (unsigned int)&pwr->cam_configuration);
323 writel(0, (unsigned int)&pwr->tv_configuration);
324 writel(0, (unsigned int)&pwr->mfc_configuration);
325 writel(0, (unsigned int)&pwr->g3d_configuration);
326 writel(0, (unsigned int)&pwr->lcd1_configuration);
327 writel(0, (unsigned int)&pwr->gps_configuration);
328 writel(0, (unsigned int)&pwr->gps_alive_configuration);
331 static void board_uart_init(void)
333 struct exynos4_gpio_part1 *gpio1 =
334 (struct exynos4_gpio_part1 *)samsung_get_base_gpio_part1();
335 struct exynos4_gpio_part2 *gpio2 =
336 (struct exynos4_gpio_part2 *)samsung_get_base_gpio_part2();
341 * GPA1CON[0] = UART_2_RXD(2)
342 * GPA1CON[1] = UART_2_TXD(2)
343 * GPA1CON[2] = I2C_3_SDA (3)
344 * GPA1CON[3] = I2C_3_SCL (3)
347 for (i = 0; i < 4; i++) {
348 s5p_gpio_set_pull(&gpio1->a1, i, GPIO_PULL_NONE);
349 s5p_gpio_cfg_pin(&gpio1->a1, i, GPIO_FUNC((i > 1) ? 0x3 : 0x2));
352 /* UART_SEL GPY4[7] (part2) at EXYNOS4 */
353 s5p_gpio_set_pull(&gpio2->y4, 7, GPIO_PULL_UP);
354 s5p_gpio_direction_output(&gpio2->y4, 7, 1);
357 int board_early_init_f(void)