1e21185baSChander Kashyap /*
2e21185baSChander Kashyap  * Copyright (C) 2011 Samsung Electronics
3e21185baSChander Kashyap  *
4e21185baSChander Kashyap  * See file CREDITS for list of people who contributed to this
5e21185baSChander Kashyap  * project.
6e21185baSChander Kashyap  *
7e21185baSChander Kashyap  * This program is free software; you can redistribute it and/or
8e21185baSChander Kashyap  * modify it under the terms of the GNU General Public License as
9e21185baSChander Kashyap  * published by the Free Software Foundation; either version 2 of
10e21185baSChander Kashyap  * the License, or (at your option) any later version.
11e21185baSChander Kashyap  *
12e21185baSChander Kashyap  * This program is distributed in the hope that it will be useful,
13e21185baSChander Kashyap  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14e21185baSChander Kashyap  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15e21185baSChander Kashyap  * GNU General Public License for more details.
16e21185baSChander Kashyap  *
17e21185baSChander Kashyap  * You should have received a copy of the GNU General Public License
18e21185baSChander Kashyap  * along with this program; if not, write to the Free Software
19e21185baSChander Kashyap  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
20e21185baSChander Kashyap  * MA 02111-1307 USA
21e21185baSChander Kashyap  */
22e21185baSChander Kashyap 
23e21185baSChander Kashyap #include <common.h>
24e21185baSChander Kashyap #include <asm/io.h>
25e21185baSChander Kashyap #include <netdev.h>
26e21185baSChander Kashyap #include <asm/arch/cpu.h>
27e21185baSChander Kashyap #include <asm/arch/gpio.h>
28e21185baSChander Kashyap #include <asm/arch/mmc.h>
29e21185baSChander Kashyap #include <asm/arch/sromc.h>
30e21185baSChander Kashyap 
31e21185baSChander Kashyap DECLARE_GLOBAL_DATA_PTR;
32e21185baSChander Kashyap struct s5pc210_gpio_part1 *gpio1;
33e21185baSChander Kashyap struct s5pc210_gpio_part2 *gpio2;
34e21185baSChander Kashyap 
35e21185baSChander Kashyap static void smc9115_pre_init(void)
36e21185baSChander Kashyap {
37e21185baSChander Kashyap 	u32 smc_bw_conf, smc_bc_conf;
38e21185baSChander Kashyap 
39e21185baSChander Kashyap 	/* gpio configuration GPK0CON */
40ef5d9eb9SŁukasz Majewski 	s5p_gpio_cfg_pin(&gpio2->y0, CONFIG_ENV_SROM_BANK, GPIO_FUNC(2));
41e21185baSChander Kashyap 
42e21185baSChander Kashyap 	/* Ethernet needs bus width of 16 bits */
43e21185baSChander Kashyap 	smc_bw_conf = SROMC_DATA16_WIDTH(CONFIG_ENV_SROM_BANK);
44e21185baSChander Kashyap 	smc_bc_conf = SROMC_BC_TACS(0x0F) | SROMC_BC_TCOS(0x0F)
45e21185baSChander Kashyap 			| SROMC_BC_TACC(0x0F) | SROMC_BC_TCOH(0x0F)
46e21185baSChander Kashyap 			| SROMC_BC_TAH(0x0F)  | SROMC_BC_TACP(0x0F)
47e21185baSChander Kashyap 			| SROMC_BC_PMC(0x0F);
48e21185baSChander Kashyap 
49e21185baSChander Kashyap 	/* Select and configure the SROMC bank */
50e21185baSChander Kashyap 	s5p_config_sromc(CONFIG_ENV_SROM_BANK, smc_bw_conf, smc_bc_conf);
51e21185baSChander Kashyap }
52e21185baSChander Kashyap 
53e21185baSChander Kashyap int board_init(void)
54e21185baSChander Kashyap {
55e21185baSChander Kashyap 	gpio1 = (struct s5pc210_gpio_part1 *) S5PC210_GPIO_PART1_BASE;
56e21185baSChander Kashyap 	gpio2 = (struct s5pc210_gpio_part2 *) S5PC210_GPIO_PART2_BASE;
57e21185baSChander Kashyap 
58e21185baSChander Kashyap 	smc9115_pre_init();
59e21185baSChander Kashyap 
60e21185baSChander Kashyap 	gd->bd->bi_boot_params = (PHYS_SDRAM_1 + 0x100UL);
61e21185baSChander Kashyap 	return 0;
62e21185baSChander Kashyap }
63e21185baSChander Kashyap 
64e21185baSChander Kashyap int dram_init(void)
65e21185baSChander Kashyap {
66e21185baSChander Kashyap 	gd->ram_size	= get_ram_size((long *)PHYS_SDRAM_1, PHYS_SDRAM_1_SIZE)
67e21185baSChander Kashyap 			+ get_ram_size((long *)PHYS_SDRAM_2, PHYS_SDRAM_2_SIZE)
68e21185baSChander Kashyap 			+ get_ram_size((long *)PHYS_SDRAM_3, PHYS_SDRAM_3_SIZE)
69e21185baSChander Kashyap 			+ get_ram_size((long *)PHYS_SDRAM_4, PHYS_SDRAM_4_SIZE);
70e21185baSChander Kashyap 
71e21185baSChander Kashyap 	return 0;
72e21185baSChander Kashyap }
73e21185baSChander Kashyap 
74e21185baSChander Kashyap void dram_init_banksize(void)
75e21185baSChander Kashyap {
76e21185baSChander Kashyap 	gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
77*9436a0c9SChander Kashyap 	gd->bd->bi_dram[0].size = get_ram_size((long *)PHYS_SDRAM_1, \
78*9436a0c9SChander Kashyap 							PHYS_SDRAM_1_SIZE);
79e21185baSChander Kashyap 	gd->bd->bi_dram[1].start = PHYS_SDRAM_2;
80*9436a0c9SChander Kashyap 	gd->bd->bi_dram[1].size = get_ram_size((long *)PHYS_SDRAM_2, \
81*9436a0c9SChander Kashyap 							PHYS_SDRAM_2_SIZE);
82e21185baSChander Kashyap 	gd->bd->bi_dram[2].start = PHYS_SDRAM_3;
83*9436a0c9SChander Kashyap 	gd->bd->bi_dram[2].size = get_ram_size((long *)PHYS_SDRAM_3, \
84*9436a0c9SChander Kashyap 							PHYS_SDRAM_3_SIZE);
85e21185baSChander Kashyap 	gd->bd->bi_dram[3].start = PHYS_SDRAM_4;
86*9436a0c9SChander Kashyap 	gd->bd->bi_dram[3].size = get_ram_size((long *)PHYS_SDRAM_4, \
87*9436a0c9SChander Kashyap 							PHYS_SDRAM_4_SIZE);
88e21185baSChander Kashyap }
89e21185baSChander Kashyap 
90e21185baSChander Kashyap int board_eth_init(bd_t *bis)
91e21185baSChander Kashyap {
92e21185baSChander Kashyap 	int rc = 0;
93e21185baSChander Kashyap #ifdef CONFIG_SMC911X
94e21185baSChander Kashyap 	rc = smc911x_initialize(0, CONFIG_SMC911X_BASE);
95e21185baSChander Kashyap #endif
96e21185baSChander Kashyap 	return rc;
97e21185baSChander Kashyap }
98e21185baSChander Kashyap 
99e21185baSChander Kashyap #ifdef CONFIG_DISPLAY_BOARDINFO
100e21185baSChander Kashyap int checkboard(void)
101e21185baSChander Kashyap {
102e21185baSChander Kashyap 	printf("\nBoard: SMDKV310\n");
103e21185baSChander Kashyap 	return 0;
104e21185baSChander Kashyap }
105e21185baSChander Kashyap #endif
106e21185baSChander Kashyap 
107e21185baSChander Kashyap #ifdef CONFIG_GENERIC_MMC
108e21185baSChander Kashyap int board_mmc_init(bd_t *bis)
109e21185baSChander Kashyap {
110e21185baSChander Kashyap 	int i, err;
111e21185baSChander Kashyap 
112e21185baSChander Kashyap 	/*
113e21185baSChander Kashyap 	 * MMC2 SD card GPIO:
114e21185baSChander Kashyap 	 *
115e21185baSChander Kashyap 	 * GPK2[0]	SD_2_CLK(2)
116e21185baSChander Kashyap 	 * GPK2[1]	SD_2_CMD(2)
117e21185baSChander Kashyap 	 * GPK2[2]	SD_2_CDn
118e21185baSChander Kashyap 	 * GPK2[3:6]	SD_2_DATA[0:3](2)
119e21185baSChander Kashyap 	 */
120e21185baSChander Kashyap 	for (i = 0; i < 7; i++) {
121e21185baSChander Kashyap 		/* GPK2[0:6] special function 2 */
122ef5d9eb9SŁukasz Majewski 		s5p_gpio_cfg_pin(&gpio2->k2, i, GPIO_FUNC(0x2));
123e21185baSChander Kashyap 
124e21185baSChander Kashyap 		/* GPK2[0:6] drv 4x */
125ef5d9eb9SŁukasz Majewski 		s5p_gpio_set_drv(&gpio2->k2, i, GPIO_DRV_4X);
126e21185baSChander Kashyap 
127e21185baSChander Kashyap 		/* GPK2[0:1] pull disable */
128e21185baSChander Kashyap 		if (i == 0 || i == 1) {
1290e74b565SChander Kashyap 			s5p_gpio_set_pull(&gpio2->k2, i, GPIO_PULL_NONE);
130e21185baSChander Kashyap 			continue;
131e21185baSChander Kashyap 		}
132e21185baSChander Kashyap 
133e21185baSChander Kashyap 		/* GPK2[2:6] pull up */
134ef5d9eb9SŁukasz Majewski 		s5p_gpio_set_pull(&gpio2->k2, i, GPIO_PULL_UP);
135e21185baSChander Kashyap 	}
136e21185baSChander Kashyap 	err = s5p_mmc_init(2, 4);
137e21185baSChander Kashyap 	return err;
138e21185baSChander Kashyap }
139e21185baSChander Kashyap #endif
140