Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Chander Kashyap | bfef54d | 2011-05-24 20:02:56 +0000 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2011 Samsung Electronics |
Chander Kashyap | bfef54d | 2011-05-24 20:02:56 +0000 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #include <common.h> |
Simon Glass | 8e16b1e | 2019-12-28 10:45:05 -0700 | [diff] [blame] | 7 | #include <init.h> |
Simon Glass | 0f2af88 | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 8 | #include <log.h> |
Simon Glass | 274e0b0 | 2020-05-10 11:39:56 -0600 | [diff] [blame] | 9 | #include <net.h> |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 10 | #include <asm/global_data.h> |
Simon Glass | 37f1162 | 2014-10-20 19:48:37 -0600 | [diff] [blame] | 11 | #include <asm/gpio.h> |
Chander Kashyap | bfef54d | 2011-05-24 20:02:56 +0000 | [diff] [blame] | 12 | #include <asm/io.h> |
| 13 | #include <netdev.h> |
| 14 | #include <asm/arch/cpu.h> |
Chander Kashyap | bfef54d | 2011-05-24 20:02:56 +0000 | [diff] [blame] | 15 | #include <asm/arch/mmc.h> |
Rajeshwari Shinde | 99ae9b8 | 2013-07-04 12:29:16 +0530 | [diff] [blame] | 16 | #include <asm/arch/periph.h> |
| 17 | #include <asm/arch/pinmux.h> |
Chander Kashyap | bfef54d | 2011-05-24 20:02:56 +0000 | [diff] [blame] | 18 | #include <asm/arch/sromc.h> |
| 19 | |
| 20 | DECLARE_GLOBAL_DATA_PTR; |
Chander Kashyap | bfef54d | 2011-05-24 20:02:56 +0000 | [diff] [blame] | 21 | |
| 22 | static void smc9115_pre_init(void) |
| 23 | { |
| 24 | u32 smc_bw_conf, smc_bc_conf; |
| 25 | |
| 26 | /* gpio configuration GPK0CON */ |
Tom Rini | 7e60cba | 2022-12-04 10:03:46 -0500 | [diff] [blame^] | 27 | gpio_cfg_pin(EXYNOS4_GPIO_Y00 + CFG_ENV_SROM_BANK, S5P_GPIO_FUNC(2)); |
Chander Kashyap | bfef54d | 2011-05-24 20:02:56 +0000 | [diff] [blame] | 28 | |
| 29 | /* Ethernet needs bus width of 16 bits */ |
Tom Rini | 7e60cba | 2022-12-04 10:03:46 -0500 | [diff] [blame^] | 30 | smc_bw_conf = SROMC_DATA16_WIDTH(CFG_ENV_SROM_BANK); |
Chander Kashyap | bfef54d | 2011-05-24 20:02:56 +0000 | [diff] [blame] | 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 */ |
Tom Rini | 7e60cba | 2022-12-04 10:03:46 -0500 | [diff] [blame^] | 37 | s5p_config_sromc(CFG_ENV_SROM_BANK, smc_bw_conf, smc_bc_conf); |
Chander Kashyap | bfef54d | 2011-05-24 20:02:56 +0000 | [diff] [blame] | 38 | } |
| 39 | |
| 40 | int board_init(void) |
| 41 | { |
Chander Kashyap | bfef54d | 2011-05-24 20:02:56 +0000 | [diff] [blame] | 42 | smc9115_pre_init(); |
| 43 | |
Chander Kashyap | bfef54d | 2011-05-24 20:02:56 +0000 | [diff] [blame] | 44 | gd->bd->bi_boot_params = (PHYS_SDRAM_1 + 0x100UL); |
| 45 | return 0; |
| 46 | } |
| 47 | |
| 48 | int 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 Glass | 2f949c3 | 2017-03-31 08:40:32 -0600 | [diff] [blame] | 58 | int dram_init_banksize(void) |
Chander Kashyap | bfef54d | 2011-05-24 20:02:56 +0000 | [diff] [blame] | 59 | { |
| 60 | gd->bd->bi_dram[0].start = PHYS_SDRAM_1; |
Minkyu Kang | d4e645b | 2015-10-23 15:59:37 +0900 | [diff] [blame] | 61 | gd->bd->bi_dram[0].size = get_ram_size((long *)PHYS_SDRAM_1, |
Chander Kashyap | f5ed295 | 2011-09-20 21:25:02 +0000 | [diff] [blame] | 62 | PHYS_SDRAM_1_SIZE); |
Chander Kashyap | bfef54d | 2011-05-24 20:02:56 +0000 | [diff] [blame] | 63 | gd->bd->bi_dram[1].start = PHYS_SDRAM_2; |
Minkyu Kang | d4e645b | 2015-10-23 15:59:37 +0900 | [diff] [blame] | 64 | gd->bd->bi_dram[1].size = get_ram_size((long *)PHYS_SDRAM_2, |
Chander Kashyap | f5ed295 | 2011-09-20 21:25:02 +0000 | [diff] [blame] | 65 | PHYS_SDRAM_2_SIZE); |
Chander Kashyap | bfef54d | 2011-05-24 20:02:56 +0000 | [diff] [blame] | 66 | gd->bd->bi_dram[2].start = PHYS_SDRAM_3; |
Minkyu Kang | d4e645b | 2015-10-23 15:59:37 +0900 | [diff] [blame] | 67 | gd->bd->bi_dram[2].size = get_ram_size((long *)PHYS_SDRAM_3, |
Chander Kashyap | f5ed295 | 2011-09-20 21:25:02 +0000 | [diff] [blame] | 68 | PHYS_SDRAM_3_SIZE); |
Chander Kashyap | bfef54d | 2011-05-24 20:02:56 +0000 | [diff] [blame] | 69 | gd->bd->bi_dram[3].start = PHYS_SDRAM_4; |
Minkyu Kang | d4e645b | 2015-10-23 15:59:37 +0900 | [diff] [blame] | 70 | gd->bd->bi_dram[3].size = get_ram_size((long *)PHYS_SDRAM_4, |
Chander Kashyap | f5ed295 | 2011-09-20 21:25:02 +0000 | [diff] [blame] | 71 | PHYS_SDRAM_4_SIZE); |
Simon Glass | 2f949c3 | 2017-03-31 08:40:32 -0600 | [diff] [blame] | 72 | |
| 73 | return 0; |
Chander Kashyap | bfef54d | 2011-05-24 20:02:56 +0000 | [diff] [blame] | 74 | } |
| 75 | |
Chander Kashyap | bfef54d | 2011-05-24 20:02:56 +0000 | [diff] [blame] | 76 | #ifdef CONFIG_DISPLAY_BOARDINFO |
| 77 | int checkboard(void) |
| 78 | { |
| 79 | printf("\nBoard: SMDKV310\n"); |
| 80 | return 0; |
| 81 | } |
| 82 | #endif |
| 83 | |
Masahiro Yamada | 0a78017 | 2017-05-09 20:31:39 +0900 | [diff] [blame] | 84 | #ifdef CONFIG_MMC |
Masahiro Yamada | f7ed78b | 2020-06-26 15:13:33 +0900 | [diff] [blame] | 85 | int board_mmc_init(struct bd_info *bis) |
Chander Kashyap | bfef54d | 2011-05-24 20:02:56 +0000 | [diff] [blame] | 86 | { |
| 87 | int i, err; |
| 88 | |
| 89 | /* |
| 90 | * MMC2 SD card GPIO: |
| 91 | * |
| 92 | * GPK2[0] SD_2_CLK(2) |
| 93 | * GPK2[1] SD_2_CMD(2) |
| 94 | * GPK2[2] SD_2_CDn |
| 95 | * GPK2[3:6] SD_2_DATA[0:3](2) |
| 96 | */ |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 97 | for (i = EXYNOS4_GPIO_K20; i < EXYNOS4_GPIO_K27; i++) { |
Chander Kashyap | bfef54d | 2011-05-24 20:02:56 +0000 | [diff] [blame] | 98 | /* GPK2[0:6] special function 2 */ |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 99 | gpio_cfg_pin(i, S5P_GPIO_FUNC(0x2)); |
Chander Kashyap | bfef54d | 2011-05-24 20:02:56 +0000 | [diff] [blame] | 100 | |
| 101 | /* GPK2[0:6] drv 4x */ |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 102 | gpio_set_drv(i, S5P_GPIO_DRV_4X); |
Chander Kashyap | bfef54d | 2011-05-24 20:02:56 +0000 | [diff] [blame] | 103 | |
| 104 | /* GPK2[0:1] pull disable */ |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 105 | if (i == EXYNOS4_GPIO_K20 || i == EXYNOS4_GPIO_K21) { |
| 106 | gpio_set_pull(i, S5P_GPIO_PULL_NONE); |
Chander Kashyap | bfef54d | 2011-05-24 20:02:56 +0000 | [diff] [blame] | 107 | continue; |
| 108 | } |
| 109 | |
| 110 | /* GPK2[2:6] pull up */ |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 111 | gpio_set_pull(i, S5P_GPIO_PULL_UP); |
Chander Kashyap | bfef54d | 2011-05-24 20:02:56 +0000 | [diff] [blame] | 112 | } |
| 113 | err = s5p_mmc_init(2, 4); |
| 114 | return err; |
| 115 | } |
| 116 | #endif |
Rajeshwari Shinde | 99ae9b8 | 2013-07-04 12:29:16 +0530 | [diff] [blame] | 117 | |
| 118 | static int board_uart_init(void) |
| 119 | { |
| 120 | int err; |
| 121 | |
| 122 | err = exynos_pinmux_config(PERIPH_ID_UART0, PINMUX_FLAG_NONE); |
| 123 | if (err) { |
| 124 | debug("UART0 not configured\n"); |
| 125 | return err; |
| 126 | } |
| 127 | |
| 128 | err = exynos_pinmux_config(PERIPH_ID_UART1, PINMUX_FLAG_NONE); |
| 129 | if (err) { |
| 130 | debug("UART1 not configured\n"); |
| 131 | return err; |
| 132 | } |
| 133 | |
| 134 | err = exynos_pinmux_config(PERIPH_ID_UART2, PINMUX_FLAG_NONE); |
| 135 | if (err) { |
| 136 | debug("UART2 not configured\n"); |
| 137 | return err; |
| 138 | } |
| 139 | |
| 140 | err = exynos_pinmux_config(PERIPH_ID_UART3, PINMUX_FLAG_NONE); |
| 141 | if (err) { |
| 142 | debug("UART3 not configured\n"); |
| 143 | return err; |
| 144 | } |
| 145 | |
| 146 | return 0; |
| 147 | } |
| 148 | |
| 149 | #ifdef CONFIG_BOARD_EARLY_INIT_F |
| 150 | int board_early_init_f(void) |
| 151 | { |
| 152 | int err; |
| 153 | err = board_uart_init(); |
| 154 | if (err) { |
| 155 | debug("UART init failed\n"); |
| 156 | return err; |
| 157 | } |
| 158 | return err; |
| 159 | } |
| 160 | #endif |