blob: 8811cbb9ad0bb66d73f5c4b7ff015207c1e489ec [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Chander Kashyapbfef54d2011-05-24 20:02:56 +00002/*
3 * Copyright (C) 2011 Samsung Electronics
Chander Kashyapbfef54d2011-05-24 20:02:56 +00004 */
5
6#include <common.h>
Simon Glass8e16b1e2019-12-28 10:45:05 -07007#include <init.h>
Simon Glass0f2af882020-05-10 11:40:05 -06008#include <log.h>
Simon Glass274e0b02020-05-10 11:39:56 -06009#include <net.h>
Simon Glass3ba929a2020-10-30 21:38:53 -060010#include <asm/global_data.h>
Simon Glass37f11622014-10-20 19:48:37 -060011#include <asm/gpio.h>
Chander Kashyapbfef54d2011-05-24 20:02:56 +000012#include <asm/io.h>
13#include <netdev.h>
14#include <asm/arch/cpu.h>
Chander Kashyapbfef54d2011-05-24 20:02:56 +000015#include <asm/arch/mmc.h>
Rajeshwari Shinde99ae9b82013-07-04 12:29:16 +053016#include <asm/arch/periph.h>
17#include <asm/arch/pinmux.h>
Chander Kashyapbfef54d2011-05-24 20:02:56 +000018#include <asm/arch/sromc.h>
19
20DECLARE_GLOBAL_DATA_PTR;
Chander Kashyapbfef54d2011-05-24 20:02:56 +000021
22static void smc9115_pre_init(void)
23{
24 u32 smc_bw_conf, smc_bc_conf;
25
26 /* gpio configuration GPK0CON */
Akshay Saraswat1376cdd2014-05-13 10:30:14 +053027 gpio_cfg_pin(EXYNOS4_GPIO_Y00 + CONFIG_ENV_SROM_BANK, S5P_GPIO_FUNC(2));
Chander Kashyapbfef54d2011-05-24 20:02:56 +000028
29 /* Ethernet needs bus width of 16 bits */
30 smc_bw_conf = SROMC_DATA16_WIDTH(CONFIG_ENV_SROM_BANK);
31 smc_bc_conf = SROMC_BC_TACS(0x0F) | SROMC_BC_TCOS(0x0F)
32 | SROMC_BC_TACC(0x0F) | SROMC_BC_TCOH(0x0F)
33 | SROMC_BC_TAH(0x0F) | SROMC_BC_TACP(0x0F)
34 | SROMC_BC_PMC(0x0F);
35
36 /* Select and configure the SROMC bank */
37 s5p_config_sromc(CONFIG_ENV_SROM_BANK, smc_bw_conf, smc_bc_conf);
38}
39
40int board_init(void)
41{
Chander Kashyapbfef54d2011-05-24 20:02:56 +000042 smc9115_pre_init();
43
Chander Kashyapbfef54d2011-05-24 20:02:56 +000044 gd->bd->bi_boot_params = (PHYS_SDRAM_1 + 0x100UL);
45 return 0;
46}
47
48int dram_init(void)
49{
50 gd->ram_size = get_ram_size((long *)PHYS_SDRAM_1, PHYS_SDRAM_1_SIZE)
51 + get_ram_size((long *)PHYS_SDRAM_2, PHYS_SDRAM_2_SIZE)
52 + get_ram_size((long *)PHYS_SDRAM_3, PHYS_SDRAM_3_SIZE)
53 + get_ram_size((long *)PHYS_SDRAM_4, PHYS_SDRAM_4_SIZE);
54
55 return 0;
56}
57
Simon Glass2f949c32017-03-31 08:40:32 -060058int dram_init_banksize(void)
Chander Kashyapbfef54d2011-05-24 20:02:56 +000059{
60 gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
Minkyu Kangd4e645b2015-10-23 15:59:37 +090061 gd->bd->bi_dram[0].size = get_ram_size((long *)PHYS_SDRAM_1,
Chander Kashyapf5ed2952011-09-20 21:25:02 +000062 PHYS_SDRAM_1_SIZE);
Chander Kashyapbfef54d2011-05-24 20:02:56 +000063 gd->bd->bi_dram[1].start = PHYS_SDRAM_2;
Minkyu Kangd4e645b2015-10-23 15:59:37 +090064 gd->bd->bi_dram[1].size = get_ram_size((long *)PHYS_SDRAM_2,
Chander Kashyapf5ed2952011-09-20 21:25:02 +000065 PHYS_SDRAM_2_SIZE);
Chander Kashyapbfef54d2011-05-24 20:02:56 +000066 gd->bd->bi_dram[2].start = PHYS_SDRAM_3;
Minkyu Kangd4e645b2015-10-23 15:59:37 +090067 gd->bd->bi_dram[2].size = get_ram_size((long *)PHYS_SDRAM_3,
Chander Kashyapf5ed2952011-09-20 21:25:02 +000068 PHYS_SDRAM_3_SIZE);
Chander Kashyapbfef54d2011-05-24 20:02:56 +000069 gd->bd->bi_dram[3].start = PHYS_SDRAM_4;
Minkyu Kangd4e645b2015-10-23 15:59:37 +090070 gd->bd->bi_dram[3].size = get_ram_size((long *)PHYS_SDRAM_4,
Chander Kashyapf5ed2952011-09-20 21:25:02 +000071 PHYS_SDRAM_4_SIZE);
Simon Glass2f949c32017-03-31 08:40:32 -060072
73 return 0;
Chander Kashyapbfef54d2011-05-24 20:02:56 +000074}
75
Masahiro Yamadaf7ed78b2020-06-26 15:13:33 +090076int board_eth_init(struct bd_info *bis)
Chander Kashyapbfef54d2011-05-24 20:02:56 +000077{
78 int rc = 0;
79#ifdef CONFIG_SMC911X
80 rc = smc911x_initialize(0, CONFIG_SMC911X_BASE);
81#endif
82 return rc;
83}
84
85#ifdef CONFIG_DISPLAY_BOARDINFO
86int checkboard(void)
87{
88 printf("\nBoard: SMDKV310\n");
89 return 0;
90}
91#endif
92
Masahiro Yamada0a780172017-05-09 20:31:39 +090093#ifdef CONFIG_MMC
Masahiro Yamadaf7ed78b2020-06-26 15:13:33 +090094int board_mmc_init(struct bd_info *bis)
Chander Kashyapbfef54d2011-05-24 20:02:56 +000095{
96 int i, err;
97
98 /*
99 * MMC2 SD card GPIO:
100 *
101 * GPK2[0] SD_2_CLK(2)
102 * GPK2[1] SD_2_CMD(2)
103 * GPK2[2] SD_2_CDn
104 * GPK2[3:6] SD_2_DATA[0:3](2)
105 */
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530106 for (i = EXYNOS4_GPIO_K20; i < EXYNOS4_GPIO_K27; i++) {
Chander Kashyapbfef54d2011-05-24 20:02:56 +0000107 /* GPK2[0:6] special function 2 */
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530108 gpio_cfg_pin(i, S5P_GPIO_FUNC(0x2));
Chander Kashyapbfef54d2011-05-24 20:02:56 +0000109
110 /* GPK2[0:6] drv 4x */
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530111 gpio_set_drv(i, S5P_GPIO_DRV_4X);
Chander Kashyapbfef54d2011-05-24 20:02:56 +0000112
113 /* GPK2[0:1] pull disable */
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530114 if (i == EXYNOS4_GPIO_K20 || i == EXYNOS4_GPIO_K21) {
115 gpio_set_pull(i, S5P_GPIO_PULL_NONE);
Chander Kashyapbfef54d2011-05-24 20:02:56 +0000116 continue;
117 }
118
119 /* GPK2[2:6] pull up */
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530120 gpio_set_pull(i, S5P_GPIO_PULL_UP);
Chander Kashyapbfef54d2011-05-24 20:02:56 +0000121 }
122 err = s5p_mmc_init(2, 4);
123 return err;
124}
125#endif
Rajeshwari Shinde99ae9b82013-07-04 12:29:16 +0530126
127static int board_uart_init(void)
128{
129 int err;
130
131 err = exynos_pinmux_config(PERIPH_ID_UART0, PINMUX_FLAG_NONE);
132 if (err) {
133 debug("UART0 not configured\n");
134 return err;
135 }
136
137 err = exynos_pinmux_config(PERIPH_ID_UART1, PINMUX_FLAG_NONE);
138 if (err) {
139 debug("UART1 not configured\n");
140 return err;
141 }
142
143 err = exynos_pinmux_config(PERIPH_ID_UART2, PINMUX_FLAG_NONE);
144 if (err) {
145 debug("UART2 not configured\n");
146 return err;
147 }
148
149 err = exynos_pinmux_config(PERIPH_ID_UART3, PINMUX_FLAG_NONE);
150 if (err) {
151 debug("UART3 not configured\n");
152 return err;
153 }
154
155 return 0;
156}
157
158#ifdef CONFIG_BOARD_EARLY_INIT_F
159int board_early_init_f(void)
160{
161 int err;
162 err = board_uart_init();
163 if (err) {
164 debug("UART init failed\n");
165 return err;
166 }
167 return err;
168}
169#endif