common: Move RAM-sizing functions to init.h
[platform/kernel/u-boot.git] / board / samsung / arndale / arndale.c
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 <usb.h>
10 #include <asm/gpio.h>
11 #include <asm/arch/pinmux.h>
12 #include <asm/arch/dwmmc.h>
13 #include <asm/arch/power.h>
14
15 DECLARE_GLOBAL_DATA_PTR;
16
17 #ifdef CONFIG_USB_EHCI_EXYNOS
18 int board_usb_init(int index, enum usb_init_type init)
19 {
20         /* Configure gpios for usb 3503 hub:
21          * disconnect, toggle reset and connect
22          */
23         gpio_request(EXYNOS5_GPIO_D17, "usb_connect");
24         gpio_request(EXYNOS5_GPIO_X35, "usb_reset");
25         gpio_direction_output(EXYNOS5_GPIO_D17, 0);
26         gpio_direction_output(EXYNOS5_GPIO_X35, 0);
27
28         gpio_direction_output(EXYNOS5_GPIO_X35, 1);
29         gpio_direction_output(EXYNOS5_GPIO_D17, 1);
30
31         return 0;
32 }
33 #endif
34
35 int board_init(void)
36 {
37         gd->bd->bi_boot_params = (PHYS_SDRAM_1 + 0x100UL);
38         return 0;
39 }
40
41 int dram_init(void)
42 {
43         int i;
44         u32 addr;
45
46         for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
47                 addr = CONFIG_SYS_SDRAM_BASE + (i * SDRAM_BANK_SIZE);
48                 gd->ram_size += get_ram_size((long *)addr, SDRAM_BANK_SIZE);
49         }
50         return 0;
51 }
52
53 int power_init_board(void)
54 {
55         set_ps_hold_ctrl();
56         return 0;
57 }
58
59 int dram_init_banksize(void)
60 {
61         int i;
62         u32 addr, size;
63
64         for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
65                 addr = CONFIG_SYS_SDRAM_BASE + (i * SDRAM_BANK_SIZE);
66                 size = get_ram_size((long *)addr, SDRAM_BANK_SIZE);
67
68                 gd->bd->bi_dram[i].start = addr;
69                 gd->bd->bi_dram[i].size = size;
70         }
71
72         return 0;
73 }
74
75 #ifdef CONFIG_MMC
76 int board_mmc_init(bd_t *bis)
77 {
78         int ret;
79         /* dwmmc initializattion for available channels */
80         ret = exynos_dwmmc_init(gd->fdt_blob);
81         if (ret)
82                 debug("dwmmc init failed\n");
83
84         return ret;
85 }
86 #endif
87
88 static int board_uart_init(void)
89 {
90         int err = 0, uart_id;
91
92         for (uart_id = PERIPH_ID_UART0; uart_id <= PERIPH_ID_UART3; uart_id++) {
93                 err = exynos_pinmux_config(uart_id, PINMUX_FLAG_NONE);
94                 if (err) {
95                         debug("UART%d not configured\n",
96                               (uart_id - PERIPH_ID_UART0));
97                         return err;
98                 }
99         }
100         return err;
101 }
102
103 #ifdef CONFIG_BOARD_EARLY_INIT_F
104 int board_early_init_f(void)
105 {
106         int err;
107
108         err = board_uart_init();
109         if (err) {
110                 debug("UART init failed\n");
111                 return err;
112         }
113         return err;
114 }
115 #endif
116
117 #ifdef CONFIG_DISPLAY_BOARDINFO
118 int checkboard(void)
119 {
120         printf("\nBoard: Arndale\n");
121
122         return 0;
123 }
124 #endif
125
126 #ifdef CONFIG_S5P_PA_SYSRAM
127 void smp_set_core_boot_addr(unsigned long addr, int corenr)
128 {
129         writel(addr, CONFIG_S5P_PA_SYSRAM);
130
131         /* make sure this write is really executed */
132         __asm__ volatile ("dsb\n");
133 }
134 #endif