blob: 9c926d6ecf2e9ae6f1db1bc390633b6cf3cb14d0 [file] [log] [blame]
Chander Kashyaped2e25a2012-02-05 23:01:47 +00001/*
2 * Copyright (C) 2012 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>
Rajeshwari Shinde1d518e62012-07-23 21:23:55 +000025#include <i2c.h>
Chander Kashyaped2e25a2012-02-05 23:01:47 +000026#include <netdev.h>
Hatim RV000b5482012-11-02 01:15:37 +000027#include <spi.h>
Chander Kashyaped2e25a2012-02-05 23:01:47 +000028#include <asm/arch/cpu.h>
29#include <asm/arch/gpio.h>
30#include <asm/arch/mmc.h>
Rajeshwari Shinde5d2a8e22012-06-06 19:54:30 +000031#include <asm/arch/pinmux.h>
Chander Kashyaped2e25a2012-02-05 23:01:47 +000032#include <asm/arch/sromc.h>
Rajeshwari Shinde418eb7e2012-12-10 01:55:48 +000033#include <power/pmic.h>
Chander Kashyaped2e25a2012-02-05 23:01:47 +000034
35DECLARE_GLOBAL_DATA_PTR;
Chander Kashyaped2e25a2012-02-05 23:01:47 +000036
Chander Kashyap5ff8061e2012-02-09 01:26:19 +000037#ifdef CONFIG_SMC911X
Rajeshwari Shinde5d2a8e22012-06-06 19:54:30 +000038static int smc9115_pre_init(void)
Chander Kashyap5ff8061e2012-02-09 01:26:19 +000039{
40 u32 smc_bw_conf, smc_bc_conf;
Rajeshwari Shinde5d2a8e22012-06-06 19:54:30 +000041 int err;
Chander Kashyap5ff8061e2012-02-09 01:26:19 +000042
43 /* Ethernet needs data bus width of 16 bits */
44 smc_bw_conf = SROMC_DATA16_WIDTH(CONFIG_ENV_SROM_BANK)
45 | SROMC_BYTE_ENABLE(CONFIG_ENV_SROM_BANK);
46
47 smc_bc_conf = SROMC_BC_TACS(0x01) | SROMC_BC_TCOS(0x01)
48 | SROMC_BC_TACC(0x06) | SROMC_BC_TCOH(0x01)
49 | SROMC_BC_TAH(0x0C) | SROMC_BC_TACP(0x09)
50 | SROMC_BC_PMC(0x01);
51
52 /* Select and configure the SROMC bank */
Rajeshwari Shinde5d2a8e22012-06-06 19:54:30 +000053 err = exynos_pinmux_config(PERIPH_ID_SROMC,
54 CONFIG_ENV_SROM_BANK | PINMUX_FLAG_16BIT);
55 if (err) {
56 debug("SROMC not configured\n");
57 return err;
58 }
59
Chander Kashyap5ff8061e2012-02-09 01:26:19 +000060 s5p_config_sromc(CONFIG_ENV_SROM_BANK, smc_bw_conf, smc_bc_conf);
Rajeshwari Shinde5d2a8e22012-06-06 19:54:30 +000061 return 0;
Chander Kashyap5ff8061e2012-02-09 01:26:19 +000062}
63#endif
64
Chander Kashyaped2e25a2012-02-05 23:01:47 +000065int board_init(void)
66{
Chander Kashyaped2e25a2012-02-05 23:01:47 +000067 gd->bd->bi_boot_params = (PHYS_SDRAM_1 + 0x100UL);
Hatim RV000b5482012-11-02 01:15:37 +000068#ifdef CONFIG_EXYNOS_SPI
69 spi_init();
70#endif
Chander Kashyaped2e25a2012-02-05 23:01:47 +000071 return 0;
72}
73
74int dram_init(void)
75{
76 gd->ram_size = get_ram_size((long *)PHYS_SDRAM_1, PHYS_SDRAM_1_SIZE)
77 + get_ram_size((long *)PHYS_SDRAM_2, PHYS_SDRAM_2_SIZE)
78 + get_ram_size((long *)PHYS_SDRAM_3, PHYS_SDRAM_3_SIZE)
79 + get_ram_size((long *)PHYS_SDRAM_4, PHYS_SDRAM_4_SIZE)
80 + get_ram_size((long *)PHYS_SDRAM_5, PHYS_SDRAM_7_SIZE)
81 + get_ram_size((long *)PHYS_SDRAM_6, PHYS_SDRAM_7_SIZE)
82 + get_ram_size((long *)PHYS_SDRAM_7, PHYS_SDRAM_7_SIZE)
83 + get_ram_size((long *)PHYS_SDRAM_8, PHYS_SDRAM_8_SIZE);
84 return 0;
85}
86
Rajeshwari Shinde418eb7e2012-12-10 01:55:48 +000087#if defined(CONFIG_POWER)
88int power_init_board(void)
89{
90 if (pmic_init(I2C_PMIC))
91 return -1;
92 else
93 return 0;
94}
95#endif
96
Chander Kashyaped2e25a2012-02-05 23:01:47 +000097void dram_init_banksize(void)
98{
99 gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
100 gd->bd->bi_dram[0].size = get_ram_size((long *)PHYS_SDRAM_1,
101 PHYS_SDRAM_1_SIZE);
102 gd->bd->bi_dram[1].start = PHYS_SDRAM_2;
103 gd->bd->bi_dram[1].size = get_ram_size((long *)PHYS_SDRAM_2,
104 PHYS_SDRAM_2_SIZE);
105 gd->bd->bi_dram[2].start = PHYS_SDRAM_3;
106 gd->bd->bi_dram[2].size = get_ram_size((long *)PHYS_SDRAM_3,
107 PHYS_SDRAM_3_SIZE);
108 gd->bd->bi_dram[3].start = PHYS_SDRAM_4;
109 gd->bd->bi_dram[3].size = get_ram_size((long *)PHYS_SDRAM_4,
110 PHYS_SDRAM_4_SIZE);
111 gd->bd->bi_dram[4].start = PHYS_SDRAM_5;
112 gd->bd->bi_dram[4].size = get_ram_size((long *)PHYS_SDRAM_5,
113 PHYS_SDRAM_5_SIZE);
114 gd->bd->bi_dram[5].start = PHYS_SDRAM_6;
115 gd->bd->bi_dram[5].size = get_ram_size((long *)PHYS_SDRAM_6,
116 PHYS_SDRAM_6_SIZE);
117 gd->bd->bi_dram[6].start = PHYS_SDRAM_7;
118 gd->bd->bi_dram[6].size = get_ram_size((long *)PHYS_SDRAM_7,
119 PHYS_SDRAM_7_SIZE);
120 gd->bd->bi_dram[7].start = PHYS_SDRAM_8;
121 gd->bd->bi_dram[7].size = get_ram_size((long *)PHYS_SDRAM_8,
122 PHYS_SDRAM_8_SIZE);
123}
124
Chander Kashyap5ff8061e2012-02-09 01:26:19 +0000125int board_eth_init(bd_t *bis)
126{
127#ifdef CONFIG_SMC911X
Rajeshwari Shinde5d2a8e22012-06-06 19:54:30 +0000128 if (smc9115_pre_init())
129 return -1;
Chander Kashyap5ff8061e2012-02-09 01:26:19 +0000130 return smc911x_initialize(0, CONFIG_SMC911X_BASE);
131#endif
132 return 0;
133}
134
Chander Kashyaped2e25a2012-02-05 23:01:47 +0000135#ifdef CONFIG_DISPLAY_BOARDINFO
136int checkboard(void)
137{
138 printf("\nBoard: SMDK5250\n");
139
140 return 0;
141}
142#endif
143
144#ifdef CONFIG_GENERIC_MMC
145int board_mmc_init(bd_t *bis)
146{
Rajeshwari Shinde5d2a8e22012-06-06 19:54:30 +0000147 int err;
Chander Kashyaped2e25a2012-02-05 23:01:47 +0000148
Rajeshwari Shindee8bfeda2012-07-03 20:03:00 +0000149 err = exynos_pinmux_config(PERIPH_ID_SDMMC0, PINMUX_FLAG_8BIT_MODE);
Rajeshwari Shinde5d2a8e22012-06-06 19:54:30 +0000150 if (err) {
Rajeshwari Shindee8bfeda2012-07-03 20:03:00 +0000151 debug("SDMMC0 not configured\n");
Rajeshwari Shinde5d2a8e22012-06-06 19:54:30 +0000152 return err;
Chander Kashyaped2e25a2012-02-05 23:01:47 +0000153 }
154
Rajeshwari Shindee8bfeda2012-07-03 20:03:00 +0000155 err = s5p_mmc_init(0, 8);
Chander Kashyaped2e25a2012-02-05 23:01:47 +0000156 return err;
157}
158#endif
159
Rajeshwari Shinde5d2a8e22012-06-06 19:54:30 +0000160static int board_uart_init(void)
Chander Kashyaped2e25a2012-02-05 23:01:47 +0000161{
Rajeshwari Shinde5d2a8e22012-06-06 19:54:30 +0000162 int err;
Chander Kashyaped2e25a2012-02-05 23:01:47 +0000163
Rajeshwari Shinde5d2a8e22012-06-06 19:54:30 +0000164 err = exynos_pinmux_config(PERIPH_ID_UART0, PINMUX_FLAG_NONE);
165 if (err) {
166 debug("UART0 not configured\n");
167 return err;
Chander Kashyaped2e25a2012-02-05 23:01:47 +0000168 }
Doug Andersonf4219522012-02-13 07:38:05 +0000169
Rajeshwari Shinde5d2a8e22012-06-06 19:54:30 +0000170 err = exynos_pinmux_config(PERIPH_ID_UART1, PINMUX_FLAG_NONE);
171 if (err) {
172 debug("UART1 not configured\n");
173 return err;
Doug Andersonf4219522012-02-13 07:38:05 +0000174 }
175
Rajeshwari Shinde5d2a8e22012-06-06 19:54:30 +0000176 err = exynos_pinmux_config(PERIPH_ID_UART2, PINMUX_FLAG_NONE);
177 if (err) {
178 debug("UART2 not configured\n");
179 return err;
Doug Andersonf4219522012-02-13 07:38:05 +0000180 }
181
Rajeshwari Shinde5d2a8e22012-06-06 19:54:30 +0000182 err = exynos_pinmux_config(PERIPH_ID_UART3, PINMUX_FLAG_NONE);
183 if (err) {
184 debug("UART3 not configured\n");
185 return err;
Doug Andersonf4219522012-02-13 07:38:05 +0000186 }
187
Rajeshwari Shinde5d2a8e22012-06-06 19:54:30 +0000188 return 0;
Chander Kashyaped2e25a2012-02-05 23:01:47 +0000189}
190
Rajeshwari Shinde1d518e62012-07-23 21:23:55 +0000191#ifdef CONFIG_SYS_I2C_INIT_BOARD
192static int board_i2c_init(void)
193{
194 int i, err;
195
196 for (i = 0; i < CONFIG_MAX_I2C_NUM; i++) {
197 err = exynos_pinmux_config((PERIPH_ID_I2C0 + i),
198 PINMUX_FLAG_NONE);
199 if (err) {
200 debug("I2C%d not configured\n", (PERIPH_ID_I2C0 + i));
201 return err;
202 }
203 }
204 i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
205 return 0;
206}
207#endif
208
Chander Kashyaped2e25a2012-02-05 23:01:47 +0000209#ifdef CONFIG_BOARD_EARLY_INIT_F
210int board_early_init_f(void)
211{
Rajeshwari Shinde1d518e62012-07-23 21:23:55 +0000212 int err;
213 err = board_uart_init();
214 if (err) {
215 debug("UART init failed\n");
216 return err;
217 }
218#ifdef CONFIG_SYS_I2C_INIT_BOARD
219 err = board_i2c_init();
220#endif
221 return err;
Chander Kashyaped2e25a2012-02-05 23:01:47 +0000222}
223#endif