blob: 18dd5d248ecc7c69478b63b2c8a30555a2566721 [file] [log] [blame]
Chander Kashyap0aee53b2012-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 Shindec82b0502012-07-23 21:23:55 +000025#include <i2c.h>
Chander Kashyap0aee53b2012-02-05 23:01:47 +000026#include <netdev.h>
27#include <asm/arch/cpu.h>
28#include <asm/arch/gpio.h>
29#include <asm/arch/mmc.h>
Rajeshwari Shindec6baaa62012-06-06 19:54:30 +000030#include <asm/arch/pinmux.h>
Chander Kashyap0aee53b2012-02-05 23:01:47 +000031#include <asm/arch/sromc.h>
Rajeshwari Shinde0d146a52012-08-24 00:39:24 +000032#include <pmic.h>
Chander Kashyap0aee53b2012-02-05 23:01:47 +000033
34DECLARE_GLOBAL_DATA_PTR;
Chander Kashyap0aee53b2012-02-05 23:01:47 +000035
Chander Kashyapbf936212012-02-09 01:26:19 +000036#ifdef CONFIG_SMC911X
Rajeshwari Shindec6baaa62012-06-06 19:54:30 +000037static int smc9115_pre_init(void)
Chander Kashyapbf936212012-02-09 01:26:19 +000038{
39 u32 smc_bw_conf, smc_bc_conf;
Rajeshwari Shindec6baaa62012-06-06 19:54:30 +000040 int err;
Chander Kashyapbf936212012-02-09 01:26:19 +000041
42 /* Ethernet needs data bus width of 16 bits */
43 smc_bw_conf = SROMC_DATA16_WIDTH(CONFIG_ENV_SROM_BANK)
44 | SROMC_BYTE_ENABLE(CONFIG_ENV_SROM_BANK);
45
46 smc_bc_conf = SROMC_BC_TACS(0x01) | SROMC_BC_TCOS(0x01)
47 | SROMC_BC_TACC(0x06) | SROMC_BC_TCOH(0x01)
48 | SROMC_BC_TAH(0x0C) | SROMC_BC_TACP(0x09)
49 | SROMC_BC_PMC(0x01);
50
51 /* Select and configure the SROMC bank */
Rajeshwari Shindec6baaa62012-06-06 19:54:30 +000052 err = exynos_pinmux_config(PERIPH_ID_SROMC,
53 CONFIG_ENV_SROM_BANK | PINMUX_FLAG_16BIT);
54 if (err) {
55 debug("SROMC not configured\n");
56 return err;
57 }
58
Chander Kashyapbf936212012-02-09 01:26:19 +000059 s5p_config_sromc(CONFIG_ENV_SROM_BANK, smc_bw_conf, smc_bc_conf);
Rajeshwari Shindec6baaa62012-06-06 19:54:30 +000060 return 0;
Chander Kashyapbf936212012-02-09 01:26:19 +000061}
62#endif
63
Chander Kashyap0aee53b2012-02-05 23:01:47 +000064int board_init(void)
65{
Chander Kashyap0aee53b2012-02-05 23:01:47 +000066 gd->bd->bi_boot_params = (PHYS_SDRAM_1 + 0x100UL);
Rajeshwari Shinde0d146a52012-08-24 00:39:24 +000067#if defined(CONFIG_PMIC)
68 pmic_init();
69#endif
Chander Kashyap0aee53b2012-02-05 23:01:47 +000070 return 0;
71}
72
73int dram_init(void)
74{
75 gd->ram_size = get_ram_size((long *)PHYS_SDRAM_1, PHYS_SDRAM_1_SIZE)
76 + get_ram_size((long *)PHYS_SDRAM_2, PHYS_SDRAM_2_SIZE)
77 + get_ram_size((long *)PHYS_SDRAM_3, PHYS_SDRAM_3_SIZE)
78 + get_ram_size((long *)PHYS_SDRAM_4, PHYS_SDRAM_4_SIZE)
79 + get_ram_size((long *)PHYS_SDRAM_5, PHYS_SDRAM_7_SIZE)
80 + get_ram_size((long *)PHYS_SDRAM_6, PHYS_SDRAM_7_SIZE)
81 + get_ram_size((long *)PHYS_SDRAM_7, PHYS_SDRAM_7_SIZE)
82 + get_ram_size((long *)PHYS_SDRAM_8, PHYS_SDRAM_8_SIZE);
83 return 0;
84}
85
86void dram_init_banksize(void)
87{
88 gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
89 gd->bd->bi_dram[0].size = get_ram_size((long *)PHYS_SDRAM_1,
90 PHYS_SDRAM_1_SIZE);
91 gd->bd->bi_dram[1].start = PHYS_SDRAM_2;
92 gd->bd->bi_dram[1].size = get_ram_size((long *)PHYS_SDRAM_2,
93 PHYS_SDRAM_2_SIZE);
94 gd->bd->bi_dram[2].start = PHYS_SDRAM_3;
95 gd->bd->bi_dram[2].size = get_ram_size((long *)PHYS_SDRAM_3,
96 PHYS_SDRAM_3_SIZE);
97 gd->bd->bi_dram[3].start = PHYS_SDRAM_4;
98 gd->bd->bi_dram[3].size = get_ram_size((long *)PHYS_SDRAM_4,
99 PHYS_SDRAM_4_SIZE);
100 gd->bd->bi_dram[4].start = PHYS_SDRAM_5;
101 gd->bd->bi_dram[4].size = get_ram_size((long *)PHYS_SDRAM_5,
102 PHYS_SDRAM_5_SIZE);
103 gd->bd->bi_dram[5].start = PHYS_SDRAM_6;
104 gd->bd->bi_dram[5].size = get_ram_size((long *)PHYS_SDRAM_6,
105 PHYS_SDRAM_6_SIZE);
106 gd->bd->bi_dram[6].start = PHYS_SDRAM_7;
107 gd->bd->bi_dram[6].size = get_ram_size((long *)PHYS_SDRAM_7,
108 PHYS_SDRAM_7_SIZE);
109 gd->bd->bi_dram[7].start = PHYS_SDRAM_8;
110 gd->bd->bi_dram[7].size = get_ram_size((long *)PHYS_SDRAM_8,
111 PHYS_SDRAM_8_SIZE);
112}
113
Chander Kashyapbf936212012-02-09 01:26:19 +0000114int board_eth_init(bd_t *bis)
115{
116#ifdef CONFIG_SMC911X
Rajeshwari Shindec6baaa62012-06-06 19:54:30 +0000117 if (smc9115_pre_init())
118 return -1;
Chander Kashyapbf936212012-02-09 01:26:19 +0000119 return smc911x_initialize(0, CONFIG_SMC911X_BASE);
120#endif
121 return 0;
122}
123
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000124#ifdef CONFIG_DISPLAY_BOARDINFO
125int checkboard(void)
126{
127 printf("\nBoard: SMDK5250\n");
128
129 return 0;
130}
131#endif
132
133#ifdef CONFIG_GENERIC_MMC
134int board_mmc_init(bd_t *bis)
135{
Rajeshwari Shindec6baaa62012-06-06 19:54:30 +0000136 int err;
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000137
Rajeshwari Shinde41222c22012-07-03 20:03:00 +0000138 err = exynos_pinmux_config(PERIPH_ID_SDMMC0, PINMUX_FLAG_8BIT_MODE);
Rajeshwari Shindec6baaa62012-06-06 19:54:30 +0000139 if (err) {
Rajeshwari Shinde41222c22012-07-03 20:03:00 +0000140 debug("SDMMC0 not configured\n");
Rajeshwari Shindec6baaa62012-06-06 19:54:30 +0000141 return err;
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000142 }
143
Rajeshwari Shinde41222c22012-07-03 20:03:00 +0000144 err = s5p_mmc_init(0, 8);
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000145 return err;
146}
147#endif
148
Rajeshwari Shindec6baaa62012-06-06 19:54:30 +0000149static int board_uart_init(void)
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000150{
Rajeshwari Shindec6baaa62012-06-06 19:54:30 +0000151 int err;
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000152
Rajeshwari Shindec6baaa62012-06-06 19:54:30 +0000153 err = exynos_pinmux_config(PERIPH_ID_UART0, PINMUX_FLAG_NONE);
154 if (err) {
155 debug("UART0 not configured\n");
156 return err;
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000157 }
Doug Anderson813fcb82012-02-13 07:38:05 +0000158
Rajeshwari Shindec6baaa62012-06-06 19:54:30 +0000159 err = exynos_pinmux_config(PERIPH_ID_UART1, PINMUX_FLAG_NONE);
160 if (err) {
161 debug("UART1 not configured\n");
162 return err;
Doug Anderson813fcb82012-02-13 07:38:05 +0000163 }
164
Rajeshwari Shindec6baaa62012-06-06 19:54:30 +0000165 err = exynos_pinmux_config(PERIPH_ID_UART2, PINMUX_FLAG_NONE);
166 if (err) {
167 debug("UART2 not configured\n");
168 return err;
Doug Anderson813fcb82012-02-13 07:38:05 +0000169 }
170
Rajeshwari Shindec6baaa62012-06-06 19:54:30 +0000171 err = exynos_pinmux_config(PERIPH_ID_UART3, PINMUX_FLAG_NONE);
172 if (err) {
173 debug("UART3 not configured\n");
174 return err;
Doug Anderson813fcb82012-02-13 07:38:05 +0000175 }
176
Rajeshwari Shindec6baaa62012-06-06 19:54:30 +0000177 return 0;
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000178}
179
Rajeshwari Shindec82b0502012-07-23 21:23:55 +0000180#ifdef CONFIG_SYS_I2C_INIT_BOARD
181static int board_i2c_init(void)
182{
183 int i, err;
184
185 for (i = 0; i < CONFIG_MAX_I2C_NUM; i++) {
186 err = exynos_pinmux_config((PERIPH_ID_I2C0 + i),
187 PINMUX_FLAG_NONE);
188 if (err) {
189 debug("I2C%d not configured\n", (PERIPH_ID_I2C0 + i));
190 return err;
191 }
192 }
193 i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
194 return 0;
195}
196#endif
197
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000198#ifdef CONFIG_BOARD_EARLY_INIT_F
199int board_early_init_f(void)
200{
Rajeshwari Shindec82b0502012-07-23 21:23:55 +0000201 int err;
202 err = board_uart_init();
203 if (err) {
204 debug("UART init failed\n");
205 return err;
206 }
207#ifdef CONFIG_SYS_I2C_INIT_BOARD
208 err = board_i2c_init();
209#endif
210 return err;
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000211}
212#endif