blob: 015b920ee271d37ce076f57e92da12ff587fabfb [file] [log] [blame]
Chander Kashyapbfef54d2011-05-24 20:02:56 +00001/*
2 * Copyright (C) 2011 Samsung Electronics
3 *
4 * See file CREDITS for list of people who contributed to this
5 * project.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of
10 * the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
20 * MA 02111-1307 USA
21 */
22
23#include <common.h>
24#include <asm/io.h>
25#include <netdev.h>
26#include <asm/arch/cpu.h>
27#include <asm/arch/gpio.h>
28#include <asm/arch/mmc.h>
Rajeshwari Shinde99ae9b82013-07-04 12:29:16 +053029#include <asm/arch/periph.h>
30#include <asm/arch/pinmux.h>
Chander Kashyapbfef54d2011-05-24 20:02:56 +000031#include <asm/arch/sromc.h>
32
33DECLARE_GLOBAL_DATA_PTR;
Chander Kashyap4131a772011-12-06 23:34:12 +000034struct exynos4_gpio_part1 *gpio1;
35struct exynos4_gpio_part2 *gpio2;
Chander Kashyapbfef54d2011-05-24 20:02:56 +000036
37static void smc9115_pre_init(void)
38{
39 u32 smc_bw_conf, smc_bc_conf;
40
41 /* gpio configuration GPK0CON */
Łukasz Majewski4d954cc2011-07-15 00:16:22 +000042 s5p_gpio_cfg_pin(&gpio2->y0, CONFIG_ENV_SROM_BANK, GPIO_FUNC(2));
Chander Kashyapbfef54d2011-05-24 20:02:56 +000043
44 /* Ethernet needs bus width of 16 bits */
45 smc_bw_conf = SROMC_DATA16_WIDTH(CONFIG_ENV_SROM_BANK);
46 smc_bc_conf = SROMC_BC_TACS(0x0F) | SROMC_BC_TCOS(0x0F)
47 | SROMC_BC_TACC(0x0F) | SROMC_BC_TCOH(0x0F)
48 | SROMC_BC_TAH(0x0F) | SROMC_BC_TACP(0x0F)
49 | SROMC_BC_PMC(0x0F);
50
51 /* Select and configure the SROMC bank */
52 s5p_config_sromc(CONFIG_ENV_SROM_BANK, smc_bw_conf, smc_bc_conf);
53}
54
55int board_init(void)
56{
Chander Kashyap4131a772011-12-06 23:34:12 +000057 gpio1 = (struct exynos4_gpio_part1 *) EXYNOS4_GPIO_PART1_BASE;
58 gpio2 = (struct exynos4_gpio_part2 *) EXYNOS4_GPIO_PART2_BASE;
Chander Kashyapbfef54d2011-05-24 20:02:56 +000059
60 smc9115_pre_init();
61
Chander Kashyapbfef54d2011-05-24 20:02:56 +000062 gd->bd->bi_boot_params = (PHYS_SDRAM_1 + 0x100UL);
63 return 0;
64}
65
66int dram_init(void)
67{
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)
70 + get_ram_size((long *)PHYS_SDRAM_3, PHYS_SDRAM_3_SIZE)
71 + get_ram_size((long *)PHYS_SDRAM_4, PHYS_SDRAM_4_SIZE);
72
73 return 0;
74}
75
76void dram_init_banksize(void)
77{
78 gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
Chander Kashyapf5ed2952011-09-20 21:25:02 +000079 gd->bd->bi_dram[0].size = get_ram_size((long *)PHYS_SDRAM_1, \
80 PHYS_SDRAM_1_SIZE);
Chander Kashyapbfef54d2011-05-24 20:02:56 +000081 gd->bd->bi_dram[1].start = PHYS_SDRAM_2;
Chander Kashyapf5ed2952011-09-20 21:25:02 +000082 gd->bd->bi_dram[1].size = get_ram_size((long *)PHYS_SDRAM_2, \
83 PHYS_SDRAM_2_SIZE);
Chander Kashyapbfef54d2011-05-24 20:02:56 +000084 gd->bd->bi_dram[2].start = PHYS_SDRAM_3;
Chander Kashyapf5ed2952011-09-20 21:25:02 +000085 gd->bd->bi_dram[2].size = get_ram_size((long *)PHYS_SDRAM_3, \
86 PHYS_SDRAM_3_SIZE);
Chander Kashyapbfef54d2011-05-24 20:02:56 +000087 gd->bd->bi_dram[3].start = PHYS_SDRAM_4;
Chander Kashyapf5ed2952011-09-20 21:25:02 +000088 gd->bd->bi_dram[3].size = get_ram_size((long *)PHYS_SDRAM_4, \
89 PHYS_SDRAM_4_SIZE);
Chander Kashyapbfef54d2011-05-24 20:02:56 +000090}
91
92int board_eth_init(bd_t *bis)
93{
94 int rc = 0;
95#ifdef CONFIG_SMC911X
96 rc = smc911x_initialize(0, CONFIG_SMC911X_BASE);
97#endif
98 return rc;
99}
100
101#ifdef CONFIG_DISPLAY_BOARDINFO
102int checkboard(void)
103{
104 printf("\nBoard: SMDKV310\n");
105 return 0;
106}
107#endif
108
109#ifdef CONFIG_GENERIC_MMC
110int board_mmc_init(bd_t *bis)
111{
112 int i, err;
113
114 /*
115 * MMC2 SD card GPIO:
116 *
117 * GPK2[0] SD_2_CLK(2)
118 * GPK2[1] SD_2_CMD(2)
119 * GPK2[2] SD_2_CDn
120 * GPK2[3:6] SD_2_DATA[0:3](2)
121 */
122 for (i = 0; i < 7; i++) {
123 /* GPK2[0:6] special function 2 */
Łukasz Majewski4d954cc2011-07-15 00:16:22 +0000124 s5p_gpio_cfg_pin(&gpio2->k2, i, GPIO_FUNC(0x2));
Chander Kashyapbfef54d2011-05-24 20:02:56 +0000125
126 /* GPK2[0:6] drv 4x */
Łukasz Majewski4d954cc2011-07-15 00:16:22 +0000127 s5p_gpio_set_drv(&gpio2->k2, i, GPIO_DRV_4X);
Chander Kashyapbfef54d2011-05-24 20:02:56 +0000128
129 /* GPK2[0:1] pull disable */
130 if (i == 0 || i == 1) {
Chander Kashyap1e887042011-07-25 23:04:07 +0000131 s5p_gpio_set_pull(&gpio2->k2, i, GPIO_PULL_NONE);
Chander Kashyapbfef54d2011-05-24 20:02:56 +0000132 continue;
133 }
134
135 /* GPK2[2:6] pull up */
Łukasz Majewski4d954cc2011-07-15 00:16:22 +0000136 s5p_gpio_set_pull(&gpio2->k2, i, GPIO_PULL_UP);
Chander Kashyapbfef54d2011-05-24 20:02:56 +0000137 }
138 err = s5p_mmc_init(2, 4);
139 return err;
140}
141#endif
Rajeshwari Shinde99ae9b82013-07-04 12:29:16 +0530142
143static int board_uart_init(void)
144{
145 int err;
146
147 err = exynos_pinmux_config(PERIPH_ID_UART0, PINMUX_FLAG_NONE);
148 if (err) {
149 debug("UART0 not configured\n");
150 return err;
151 }
152
153 err = exynos_pinmux_config(PERIPH_ID_UART1, PINMUX_FLAG_NONE);
154 if (err) {
155 debug("UART1 not configured\n");
156 return err;
157 }
158
159 err = exynos_pinmux_config(PERIPH_ID_UART2, PINMUX_FLAG_NONE);
160 if (err) {
161 debug("UART2 not configured\n");
162 return err;
163 }
164
165 err = exynos_pinmux_config(PERIPH_ID_UART3, PINMUX_FLAG_NONE);
166 if (err) {
167 debug("UART3 not configured\n");
168 return err;
169 }
170
171 return 0;
172}
173
174#ifdef CONFIG_BOARD_EARLY_INIT_F
175int board_early_init_f(void)
176{
177 int err;
178 err = board_uart_init();
179 if (err) {
180 debug("UART init failed\n");
181 return err;
182 }
183 return err;
184}
185#endif