1// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright (C) 2013 Samsung Electronics
4 */
5
6#include <common.h>
7#include <cpu_func.h>
8#include <init.h>
9#include <log.h>
10#include <usb.h>
11#include <asm/global_data.h>
12#include <asm/gpio.h>
13#include <asm/arch/pinmux.h>
14#include <asm/arch/dwmmc.h>
15#include <asm/arch/power.h>
16
17DECLARE_GLOBAL_DATA_PTR;
18
19#ifdef CONFIG_USB_EHCI_EXYNOS
20int board_usb_init(int index, enum usb_init_type init)
21{
22	/* Configure gpios for usb 3503 hub:
23	 * disconnect, toggle reset and connect
24	 */
25	gpio_request(EXYNOS5_GPIO_D17, "usb_connect");
26	gpio_request(EXYNOS5_GPIO_X35, "usb_reset");
27	gpio_direction_output(EXYNOS5_GPIO_D17, 0);
28	gpio_direction_output(EXYNOS5_GPIO_X35, 0);
29
30	gpio_direction_output(EXYNOS5_GPIO_X35, 1);
31	gpio_direction_output(EXYNOS5_GPIO_D17, 1);
32
33	return 0;
34}
35#endif
36
37int board_init(void)
38{
39	gd->bd->bi_boot_params = (PHYS_SDRAM_1 + 0x100UL);
40	return 0;
41}
42
43int dram_init(void)
44{
45	int i;
46	u32 addr;
47
48	for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
49		addr = CFG_SYS_SDRAM_BASE + (i * SDRAM_BANK_SIZE);
50		gd->ram_size += get_ram_size((long *)addr, SDRAM_BANK_SIZE);
51	}
52	return 0;
53}
54
55int power_init_board(void)
56{
57	set_ps_hold_ctrl();
58	return 0;
59}
60
61int dram_init_banksize(void)
62{
63	int i;
64	u32 addr, size;
65
66	for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
67		addr = CFG_SYS_SDRAM_BASE + (i * SDRAM_BANK_SIZE);
68		size = get_ram_size((long *)addr, SDRAM_BANK_SIZE);
69
70		gd->bd->bi_dram[i].start = addr;
71		gd->bd->bi_dram[i].size = size;
72	}
73
74	return 0;
75}
76
77static int board_uart_init(void)
78{
79	int err = 0, uart_id;
80
81	for (uart_id = PERIPH_ID_UART0; uart_id <= PERIPH_ID_UART3; uart_id++) {
82		err = exynos_pinmux_config(uart_id, PINMUX_FLAG_NONE);
83		if (err) {
84			debug("UART%d not configured\n",
85			      (uart_id - PERIPH_ID_UART0));
86			return err;
87		}
88	}
89	return err;
90}
91
92#ifdef CONFIG_BOARD_EARLY_INIT_F
93int board_early_init_f(void)
94{
95	int err;
96
97	err = board_uart_init();
98	if (err) {
99		debug("UART init failed\n");
100		return err;
101	}
102	return err;
103}
104#endif
105
106#ifdef CONFIG_DISPLAY_BOARDINFO
107int checkboard(void)
108{
109	printf("\nBoard: Arndale\n");
110
111	return 0;
112}
113#endif
114
115#ifdef CFG_SMP_PEN_ADDR
116void smp_set_core_boot_addr(unsigned long addr, int corenr)
117{
118	writel(addr, CFG_SMP_PEN_ADDR);
119
120	/* make sure this write is really executed */
121	__asm__ volatile ("dsb\n");
122}
123#endif
124