1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25#include <common.h>
26#include <asm/io.h>
27#include <asm/arch/cpu.h>
28#include <asm/arch/gpio.h>
29#include <asm/arch/mmc.h>
30#include <asm/arch/clock.h>
31#include <asm/arch/watchdog.h>
32#include <asm/arch/power.h>
33#include <pmic.h>
34#include <usb/s3c_udc.h>
35#include <max8998_pmic.h>
36
37#include "setup.h"
38
39DECLARE_GLOBAL_DATA_PTR;
40
41unsigned int board_rev;
42
43#ifdef CONFIG_REVISION_TAG
44u32 get_board_rev(void)
45{
46 return board_rev;
47}
48#endif
49
50static void check_hw_revision(void);
51
52int board_init(void)
53{
54 gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
55
56 check_hw_revision();
57 printf("HW Revision:\t0x%x\n", board_rev);
58
59#if defined(CONFIG_PMIC)
60 pmic_init();
61#endif
62
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
71 return 0;
72}
73
74void dram_init_banksize(void)
75{
76 gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
77 gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
78 gd->bd->bi_dram[1].start = PHYS_SDRAM_2;
79 gd->bd->bi_dram[1].size = PHYS_SDRAM_2_SIZE;
80}
81
82static unsigned int get_hw_revision(void)
83{
84 struct exynos4_gpio_part1 *gpio =
85 (struct exynos4_gpio_part1 *)samsung_get_base_gpio_part1();
86 int hwrev = 0;
87 int i;
88
89
90 for (i = 0; i < 4; i++) {
91 s5p_gpio_cfg_pin(&gpio->e1, i, GPIO_INPUT);
92 s5p_gpio_set_pull(&gpio->e1, i, GPIO_PULL_NONE);
93 }
94
95 udelay(1);
96
97 for (i = 0; i < 4; i++)
98 hwrev |= (s5p_gpio_get_value(&gpio->e1, i) << i);
99
100 debug("hwrev 0x%x\n", hwrev);
101
102 return hwrev;
103}
104
105static void check_hw_revision(void)
106{
107 int hwrev;
108
109 hwrev = get_hw_revision();
110
111 board_rev |= hwrev;
112}
113
114#ifdef CONFIG_DISPLAY_BOARDINFO
115int checkboard(void)
116{
117 puts("Board:\tTRATS\n");
118 return 0;
119}
120#endif
121
122#ifdef CONFIG_GENERIC_MMC
123int board_mmc_init(bd_t *bis)
124{
125 struct exynos4_gpio_part2 *gpio =
126 (struct exynos4_gpio_part2 *)samsung_get_base_gpio_part2();
127 int i, err;
128
129
130 s5p_gpio_direction_output(&gpio->k0, 2, 1);
131 s5p_gpio_set_pull(&gpio->k0, 2, GPIO_PULL_NONE);
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149 for (i = 0; i < 7; i++) {
150 if (i == 2)
151 continue;
152
153 s5p_gpio_cfg_pin(&gpio->k0, i, 0x2);
154
155 s5p_gpio_set_pull(&gpio->k0, i, GPIO_PULL_NONE);
156
157 s5p_gpio_set_drv(&gpio->k0, i, GPIO_DRV_4X);
158 }
159
160 for (i = 3; i < 7; i++) {
161
162 s5p_gpio_cfg_pin(&gpio->k1, i, 0x3);
163
164 s5p_gpio_set_pull(&gpio->k1, i, GPIO_PULL_NONE);
165
166 s5p_gpio_set_drv(&gpio->k1, i, GPIO_DRV_4X);
167 }
168
169
170
171
172
173
174 err = s5p_mmc_init(0, 8);
175
176
177 s5p_gpio_cfg_pin(&gpio->x3, 4, 0xf);
178 s5p_gpio_set_pull(&gpio->x3, 4, GPIO_PULL_UP);
179
180
181
182
183
184 if (!s5p_gpio_get_value(&gpio->x3, 4)) {
185
186
187
188
189
190
191
192 for (i = 0; i < 7; i++) {
193 if (i == 2)
194 continue;
195
196 s5p_gpio_cfg_pin(&gpio->k2, i, 0x2);
197
198 s5p_gpio_set_pull(&gpio->k2, i, GPIO_PULL_NONE);
199
200 s5p_gpio_set_drv(&gpio->k2, i, GPIO_DRV_4X);
201 }
202 err = s5p_mmc_init(2, 4);
203 }
204
205 return err;
206}
207#endif
208
209#ifdef CONFIG_USB_GADGET
210static int s5pc210_phy_control(int on)
211{
212 int ret = 0;
213 struct pmic *p = get_pmic();
214
215 if (pmic_probe(p))
216 return -1;
217
218 if (on) {
219 ret |= pmic_set_output(p,
220 MAX8998_REG_BUCK_ACTIVE_DISCHARGE3,
221 MAX8998_SAFEOUT1, LDO_ON);
222 ret |= pmic_set_output(p, MAX8998_REG_ONOFF1,
223 MAX8998_LDO3, LDO_ON);
224 ret |= pmic_set_output(p, MAX8998_REG_ONOFF2,
225 MAX8998_LDO8, LDO_ON);
226
227 } else {
228 ret |= pmic_set_output(p, MAX8998_REG_ONOFF2,
229 MAX8998_LDO8, LDO_OFF);
230 ret |= pmic_set_output(p, MAX8998_REG_ONOFF1,
231 MAX8998_LDO3, LDO_OFF);
232 ret |= pmic_set_output(p,
233 MAX8998_REG_BUCK_ACTIVE_DISCHARGE3,
234 MAX8998_SAFEOUT1, LDO_OFF);
235 }
236
237 if (ret) {
238 puts("MAX8998 LDO setting error!\n");
239 return -1;
240 }
241
242 return 0;
243}
244
245struct s3c_plat_otg_data s5pc210_otg_data = {
246 .phy_control = s5pc210_phy_control,
247 .regs_phy = EXYNOS4_USBPHY_BASE,
248 .regs_otg = EXYNOS4_USBOTG_BASE,
249 .usb_phy_ctrl = EXYNOS4_USBPHY_CONTROL,
250 .usb_flags = PHY0_SLEEP,
251};
252#endif
253
254static void pmic_reset(void)
255{
256 struct exynos4_gpio_part2 *gpio =
257 (struct exynos4_gpio_part2 *)samsung_get_base_gpio_part2();
258
259 s5p_gpio_direction_output(&gpio->x0, 7, 1);
260 s5p_gpio_set_pull(&gpio->x2, 7, GPIO_PULL_NONE);
261}
262
263static void board_clock_init(void)
264{
265 struct exynos4_clock *clk =
266 (struct exynos4_clock *)samsung_get_base_clock();
267
268 writel(CLK_SRC_CPU_VAL, (unsigned int)&clk->src_cpu);
269 writel(CLK_SRC_TOP0_VAL, (unsigned int)&clk->src_top0);
270 writel(CLK_SRC_FSYS_VAL, (unsigned int)&clk->src_fsys);
271 writel(CLK_SRC_PERIL0_VAL, (unsigned int)&clk->src_peril0);
272
273 writel(CLK_DIV_CPU0_VAL, (unsigned int)&clk->div_cpu0);
274 writel(CLK_DIV_CPU1_VAL, (unsigned int)&clk->div_cpu1);
275 writel(CLK_DIV_DMC0_VAL, (unsigned int)&clk->div_dmc0);
276 writel(CLK_DIV_DMC1_VAL, (unsigned int)&clk->div_dmc1);
277 writel(CLK_DIV_LEFTBUS_VAL, (unsigned int)&clk->div_leftbus);
278 writel(CLK_DIV_RIGHTBUS_VAL, (unsigned int)&clk->div_rightbus);
279 writel(CLK_DIV_TOP_VAL, (unsigned int)&clk->div_top);
280 writel(CLK_DIV_FSYS1_VAL, (unsigned int)&clk->div_fsys1);
281 writel(CLK_DIV_FSYS2_VAL, (unsigned int)&clk->div_fsys2);
282 writel(CLK_DIV_FSYS3_VAL, (unsigned int)&clk->div_fsys3);
283 writel(CLK_DIV_PERIL0_VAL, (unsigned int)&clk->div_peril0);
284 writel(CLK_DIV_PERIL3_VAL, (unsigned int)&clk->div_peril3);
285
286 writel(PLL_LOCKTIME, (unsigned int)&clk->apll_lock);
287 writel(PLL_LOCKTIME, (unsigned int)&clk->mpll_lock);
288 writel(PLL_LOCKTIME, (unsigned int)&clk->epll_lock);
289 writel(PLL_LOCKTIME, (unsigned int)&clk->vpll_lock);
290 writel(APLL_CON1_VAL, (unsigned int)&clk->apll_con1);
291 writel(APLL_CON0_VAL, (unsigned int)&clk->apll_con0);
292 writel(MPLL_CON1_VAL, (unsigned int)&clk->mpll_con1);
293 writel(MPLL_CON0_VAL, (unsigned int)&clk->mpll_con0);
294 writel(EPLL_CON1_VAL, (unsigned int)&clk->epll_con1);
295 writel(EPLL_CON0_VAL, (unsigned int)&clk->epll_con0);
296 writel(VPLL_CON1_VAL, (unsigned int)&clk->vpll_con1);
297 writel(VPLL_CON0_VAL, (unsigned int)&clk->vpll_con0);
298
299 writel(CLK_GATE_IP_CAM_VAL, (unsigned int)&clk->gate_ip_cam);
300 writel(CLK_GATE_IP_VP_VAL, (unsigned int)&clk->gate_ip_tv);
301 writel(CLK_GATE_IP_MFC_VAL, (unsigned int)&clk->gate_ip_mfc);
302 writel(CLK_GATE_IP_G3D_VAL, (unsigned int)&clk->gate_ip_g3d);
303 writel(CLK_GATE_IP_IMAGE_VAL, (unsigned int)&clk->gate_ip_image);
304 writel(CLK_GATE_IP_LCD0_VAL, (unsigned int)&clk->gate_ip_lcd0);
305 writel(CLK_GATE_IP_LCD1_VAL, (unsigned int)&clk->gate_ip_lcd1);
306 writel(CLK_GATE_IP_FSYS_VAL, (unsigned int)&clk->gate_ip_fsys);
307 writel(CLK_GATE_IP_GPS_VAL, (unsigned int)&clk->gate_ip_gps);
308 writel(CLK_GATE_IP_PERIL_VAL, (unsigned int)&clk->gate_ip_peril);
309 writel(CLK_GATE_IP_PERIR_VAL, (unsigned int)&clk->gate_ip_perir);
310 writel(CLK_GATE_BLOCK_VAL, (unsigned int)&clk->gate_block);
311}
312
313static void board_power_init(void)
314{
315 struct exynos4_power *pwr =
316 (struct exynos4_power *)samsung_get_base_power();
317
318
319 writel(EXYNOS4_PS_HOLD_CON_VAL, (unsigned int)&pwr->ps_hold_control);
320
321
322 writel(0, (unsigned int)&pwr->cam_configuration);
323 writel(0, (unsigned int)&pwr->tv_configuration);
324 writel(0, (unsigned int)&pwr->mfc_configuration);
325 writel(0, (unsigned int)&pwr->g3d_configuration);
326 writel(0, (unsigned int)&pwr->lcd1_configuration);
327 writel(0, (unsigned int)&pwr->gps_configuration);
328 writel(0, (unsigned int)&pwr->gps_alive_configuration);
329}
330
331static void board_uart_init(void)
332{
333 struct exynos4_gpio_part1 *gpio1 =
334 (struct exynos4_gpio_part1 *)samsung_get_base_gpio_part1();
335 struct exynos4_gpio_part2 *gpio2 =
336 (struct exynos4_gpio_part2 *)samsung_get_base_gpio_part2();
337 int i;
338
339
340
341
342
343
344
345
346
347 for (i = 0; i < 4; i++) {
348 s5p_gpio_set_pull(&gpio1->a1, i, GPIO_PULL_NONE);
349 s5p_gpio_cfg_pin(&gpio1->a1, i, GPIO_FUNC((i > 1) ? 0x3 : 0x2));
350 }
351
352
353 s5p_gpio_set_pull(&gpio2->y4, 7, GPIO_PULL_UP);
354 s5p_gpio_direction_output(&gpio2->y4, 7, 1);
355}
356
357int board_early_init_f(void)
358{
359 wdt_stop();
360 pmic_reset();
361 board_clock_init();
362 board_uart_init();
363 board_power_init();
364
365 return 0;
366}
367