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