Chander Kashyap | 0aee53b | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2012 Samsung Electronics |
| 3 | * |
| 4 | * See file CREDITS for list of people who contributed to this |
| 5 | * project. |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU General Public License as |
| 9 | * published by the Free Software Foundation; either version 2 of |
| 10 | * the License, or (at your option) any later version. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this program; if not, write to the Free Software |
| 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 20 | * MA 02111-1307 USA |
| 21 | */ |
| 22 | |
| 23 | #include <common.h> |
| 24 | #include <asm/io.h> |
Rajeshwari Shinde | c82b050 | 2012-07-23 21:23:55 +0000 | [diff] [blame] | 25 | #include <i2c.h> |
Chander Kashyap | 0aee53b | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 26 | #include <netdev.h> |
| 27 | #include <asm/arch/cpu.h> |
| 28 | #include <asm/arch/gpio.h> |
Girish K S | 79b5cbd | 2012-09-25 17:16:40 +0900 | [diff] [blame] | 29 | #include <asm/arch/dwmmc.h> |
Rajeshwari Shinde | c6baaa6 | 2012-06-06 19:54:30 +0000 | [diff] [blame] | 30 | #include <asm/arch/pinmux.h> |
Chander Kashyap | 0aee53b | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 31 | #include <asm/arch/sromc.h> |
| 32 | |
Christoffer Dall | 3d28a18 | 2012-11-17 22:46:19 -0500 | [diff] [blame^] | 33 | #include "setup.h" |
| 34 | |
Chander Kashyap | 0aee53b | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 35 | DECLARE_GLOBAL_DATA_PTR; |
Chander Kashyap | 0aee53b | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 36 | |
Chander Kashyap | bf93621 | 2012-02-09 01:26:19 +0000 | [diff] [blame] | 37 | #ifdef CONFIG_SMC911X |
Rajeshwari Shinde | c6baaa6 | 2012-06-06 19:54:30 +0000 | [diff] [blame] | 38 | static int smc9115_pre_init(void) |
Chander Kashyap | bf93621 | 2012-02-09 01:26:19 +0000 | [diff] [blame] | 39 | { |
| 40 | u32 smc_bw_conf, smc_bc_conf; |
Rajeshwari Shinde | c6baaa6 | 2012-06-06 19:54:30 +0000 | [diff] [blame] | 41 | int err; |
Chander Kashyap | bf93621 | 2012-02-09 01:26:19 +0000 | [diff] [blame] | 42 | |
| 43 | /* Ethernet needs data bus width of 16 bits */ |
| 44 | smc_bw_conf = SROMC_DATA16_WIDTH(CONFIG_ENV_SROM_BANK) |
| 45 | | SROMC_BYTE_ENABLE(CONFIG_ENV_SROM_BANK); |
| 46 | |
| 47 | smc_bc_conf = SROMC_BC_TACS(0x01) | SROMC_BC_TCOS(0x01) |
| 48 | | SROMC_BC_TACC(0x06) | SROMC_BC_TCOH(0x01) |
| 49 | | SROMC_BC_TAH(0x0C) | SROMC_BC_TACP(0x09) |
| 50 | | SROMC_BC_PMC(0x01); |
| 51 | |
| 52 | /* Select and configure the SROMC bank */ |
Rajeshwari Shinde | c6baaa6 | 2012-06-06 19:54:30 +0000 | [diff] [blame] | 53 | err = exynos_pinmux_config(PERIPH_ID_SROMC, |
| 54 | CONFIG_ENV_SROM_BANK | PINMUX_FLAG_16BIT); |
| 55 | if (err) { |
| 56 | debug("SROMC not configured\n"); |
| 57 | return err; |
| 58 | } |
| 59 | |
Chander Kashyap | bf93621 | 2012-02-09 01:26:19 +0000 | [diff] [blame] | 60 | s5p_config_sromc(CONFIG_ENV_SROM_BANK, smc_bw_conf, smc_bc_conf); |
Rajeshwari Shinde | c6baaa6 | 2012-06-06 19:54:30 +0000 | [diff] [blame] | 61 | return 0; |
Chander Kashyap | bf93621 | 2012-02-09 01:26:19 +0000 | [diff] [blame] | 62 | } |
| 63 | #endif |
| 64 | |
Chander Kashyap | 0aee53b | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 65 | int board_init(void) |
| 66 | { |
Chander Kashyap | 0aee53b | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 67 | gd->bd->bi_boot_params = (PHYS_SDRAM_1 + 0x100UL); |
| 68 | return 0; |
| 69 | } |
| 70 | |
| 71 | int dram_init(void) |
| 72 | { |
| 73 | gd->ram_size = get_ram_size((long *)PHYS_SDRAM_1, PHYS_SDRAM_1_SIZE) |
| 74 | + get_ram_size((long *)PHYS_SDRAM_2, PHYS_SDRAM_2_SIZE) |
| 75 | + get_ram_size((long *)PHYS_SDRAM_3, PHYS_SDRAM_3_SIZE) |
| 76 | + get_ram_size((long *)PHYS_SDRAM_4, PHYS_SDRAM_4_SIZE) |
| 77 | + get_ram_size((long *)PHYS_SDRAM_5, PHYS_SDRAM_7_SIZE) |
| 78 | + get_ram_size((long *)PHYS_SDRAM_6, PHYS_SDRAM_7_SIZE) |
| 79 | + get_ram_size((long *)PHYS_SDRAM_7, PHYS_SDRAM_7_SIZE) |
| 80 | + get_ram_size((long *)PHYS_SDRAM_8, PHYS_SDRAM_8_SIZE); |
| 81 | return 0; |
| 82 | } |
| 83 | |
| 84 | void dram_init_banksize(void) |
| 85 | { |
| 86 | gd->bd->bi_dram[0].start = PHYS_SDRAM_1; |
| 87 | gd->bd->bi_dram[0].size = get_ram_size((long *)PHYS_SDRAM_1, |
| 88 | PHYS_SDRAM_1_SIZE); |
| 89 | gd->bd->bi_dram[1].start = PHYS_SDRAM_2; |
| 90 | gd->bd->bi_dram[1].size = get_ram_size((long *)PHYS_SDRAM_2, |
| 91 | PHYS_SDRAM_2_SIZE); |
| 92 | gd->bd->bi_dram[2].start = PHYS_SDRAM_3; |
| 93 | gd->bd->bi_dram[2].size = get_ram_size((long *)PHYS_SDRAM_3, |
| 94 | PHYS_SDRAM_3_SIZE); |
| 95 | gd->bd->bi_dram[3].start = PHYS_SDRAM_4; |
| 96 | gd->bd->bi_dram[3].size = get_ram_size((long *)PHYS_SDRAM_4, |
| 97 | PHYS_SDRAM_4_SIZE); |
| 98 | gd->bd->bi_dram[4].start = PHYS_SDRAM_5; |
| 99 | gd->bd->bi_dram[4].size = get_ram_size((long *)PHYS_SDRAM_5, |
| 100 | PHYS_SDRAM_5_SIZE); |
| 101 | gd->bd->bi_dram[5].start = PHYS_SDRAM_6; |
| 102 | gd->bd->bi_dram[5].size = get_ram_size((long *)PHYS_SDRAM_6, |
| 103 | PHYS_SDRAM_6_SIZE); |
| 104 | gd->bd->bi_dram[6].start = PHYS_SDRAM_7; |
| 105 | gd->bd->bi_dram[6].size = get_ram_size((long *)PHYS_SDRAM_7, |
| 106 | PHYS_SDRAM_7_SIZE); |
| 107 | gd->bd->bi_dram[7].start = PHYS_SDRAM_8; |
| 108 | gd->bd->bi_dram[7].size = get_ram_size((long *)PHYS_SDRAM_8, |
| 109 | PHYS_SDRAM_8_SIZE); |
| 110 | } |
| 111 | |
Chander Kashyap | bf93621 | 2012-02-09 01:26:19 +0000 | [diff] [blame] | 112 | int board_eth_init(bd_t *bis) |
| 113 | { |
| 114 | #ifdef CONFIG_SMC911X |
Rajeshwari Shinde | c6baaa6 | 2012-06-06 19:54:30 +0000 | [diff] [blame] | 115 | if (smc9115_pre_init()) |
| 116 | return -1; |
Chander Kashyap | bf93621 | 2012-02-09 01:26:19 +0000 | [diff] [blame] | 117 | return smc911x_initialize(0, CONFIG_SMC911X_BASE); |
| 118 | #endif |
| 119 | return 0; |
| 120 | } |
| 121 | |
Chander Kashyap | 0aee53b | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 122 | #ifdef CONFIG_DISPLAY_BOARDINFO |
| 123 | int checkboard(void) |
| 124 | { |
Girish K S | 79b5cbd | 2012-09-25 17:16:40 +0900 | [diff] [blame] | 125 | printf("\nBoard: %s\n",CONFIG_IDENT_STRING); |
Chander Kashyap | 0aee53b | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 126 | |
| 127 | return 0; |
| 128 | } |
| 129 | #endif |
| 130 | |
| 131 | #ifdef CONFIG_GENERIC_MMC |
| 132 | int board_mmc_init(bd_t *bis) |
| 133 | { |
Rajeshwari Shinde | c6baaa6 | 2012-06-06 19:54:30 +0000 | [diff] [blame] | 134 | int err; |
Girish K S | 79b5cbd | 2012-09-25 17:16:40 +0900 | [diff] [blame] | 135 | |
| 136 | err = exynos_pinmux_config(PERIPH_ID_SDMMC2, PINMUX_FLAG_NONE); |
Rajeshwari Shinde | c6baaa6 | 2012-06-06 19:54:30 +0000 | [diff] [blame] | 137 | if (err) { |
Girish K S | 79b5cbd | 2012-09-25 17:16:40 +0900 | [diff] [blame] | 138 | debug("SDMMC2 not configured\n"); |
Rajeshwari Shinde | c6baaa6 | 2012-06-06 19:54:30 +0000 | [diff] [blame] | 139 | return err; |
Chander Kashyap | 0aee53b | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 140 | } |
Girish K S | 79b5cbd | 2012-09-25 17:16:40 +0900 | [diff] [blame] | 141 | |
| 142 | err = exynos_dwmmc_init(2, 4); |
Girish K S | 26c1532 | 2012-11-06 11:23:07 +0100 | [diff] [blame] | 143 | |
| 144 | err = exynos_pinmux_config(PERIPH_ID_SDMMC0, PINMUX_FLAG_8BIT_MODE); |
| 145 | if (err) { |
| 146 | debug("SDMMC0 not configured\n"); |
| 147 | return err; |
| 148 | } |
| 149 | |
| 150 | err = exynos_dwmmc_init(0, 8); |
| 151 | |
Chander Kashyap | 0aee53b | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 152 | return err; |
| 153 | } |
| 154 | #endif |
| 155 | |
Rajeshwari Shinde | c6baaa6 | 2012-06-06 19:54:30 +0000 | [diff] [blame] | 156 | static int board_uart_init(void) |
Chander Kashyap | 0aee53b | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 157 | { |
Rajeshwari Shinde | c6baaa6 | 2012-06-06 19:54:30 +0000 | [diff] [blame] | 158 | int err; |
Chander Kashyap | 0aee53b | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 159 | |
Rajeshwari Shinde | c6baaa6 | 2012-06-06 19:54:30 +0000 | [diff] [blame] | 160 | err = exynos_pinmux_config(PERIPH_ID_UART0, PINMUX_FLAG_NONE); |
| 161 | if (err) { |
| 162 | debug("UART0 not configured\n"); |
| 163 | return err; |
Chander Kashyap | 0aee53b | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 164 | } |
Doug Anderson | 813fcb8 | 2012-02-13 07:38:05 +0000 | [diff] [blame] | 165 | |
Rajeshwari Shinde | c6baaa6 | 2012-06-06 19:54:30 +0000 | [diff] [blame] | 166 | err = exynos_pinmux_config(PERIPH_ID_UART1, PINMUX_FLAG_NONE); |
| 167 | if (err) { |
| 168 | debug("UART1 not configured\n"); |
| 169 | return err; |
Doug Anderson | 813fcb8 | 2012-02-13 07:38:05 +0000 | [diff] [blame] | 170 | } |
| 171 | |
Rajeshwari Shinde | c6baaa6 | 2012-06-06 19:54:30 +0000 | [diff] [blame] | 172 | err = exynos_pinmux_config(PERIPH_ID_UART2, PINMUX_FLAG_NONE); |
| 173 | if (err) { |
| 174 | debug("UART2 not configured\n"); |
| 175 | return err; |
Doug Anderson | 813fcb8 | 2012-02-13 07:38:05 +0000 | [diff] [blame] | 176 | } |
| 177 | |
Rajeshwari Shinde | c6baaa6 | 2012-06-06 19:54:30 +0000 | [diff] [blame] | 178 | err = exynos_pinmux_config(PERIPH_ID_UART3, PINMUX_FLAG_NONE); |
| 179 | if (err) { |
| 180 | debug("UART3 not configured\n"); |
| 181 | return err; |
Doug Anderson | 813fcb8 | 2012-02-13 07:38:05 +0000 | [diff] [blame] | 182 | } |
| 183 | |
Rajeshwari Shinde | c6baaa6 | 2012-06-06 19:54:30 +0000 | [diff] [blame] | 184 | return 0; |
Chander Kashyap | 0aee53b | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 185 | } |
| 186 | |
Rajeshwari Shinde | c82b050 | 2012-07-23 21:23:55 +0000 | [diff] [blame] | 187 | #ifdef CONFIG_SYS_I2C_INIT_BOARD |
| 188 | static int board_i2c_init(void) |
| 189 | { |
| 190 | int i, err; |
| 191 | |
| 192 | for (i = 0; i < CONFIG_MAX_I2C_NUM; i++) { |
| 193 | err = exynos_pinmux_config((PERIPH_ID_I2C0 + i), |
| 194 | PINMUX_FLAG_NONE); |
| 195 | if (err) { |
| 196 | debug("I2C%d not configured\n", (PERIPH_ID_I2C0 + i)); |
| 197 | return err; |
| 198 | } |
| 199 | } |
| 200 | i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE); |
| 201 | return 0; |
| 202 | } |
| 203 | #endif |
| 204 | |
Chander Kashyap | 0aee53b | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 205 | #ifdef CONFIG_BOARD_EARLY_INIT_F |
| 206 | int board_early_init_f(void) |
| 207 | { |
Rajeshwari Shinde | c82b050 | 2012-07-23 21:23:55 +0000 | [diff] [blame] | 208 | int err; |
| 209 | err = board_uart_init(); |
| 210 | if (err) { |
| 211 | debug("UART init failed\n"); |
| 212 | return err; |
| 213 | } |
| 214 | #ifdef CONFIG_SYS_I2C_INIT_BOARD |
| 215 | err = board_i2c_init(); |
| 216 | #endif |
| 217 | return err; |
Chander Kashyap | 0aee53b | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 218 | } |
| 219 | #endif |
Christoffer Dall | 3d28a18 | 2012-11-17 22:46:19 -0500 | [diff] [blame^] | 220 | |
| 221 | void arch_preboot_os(void) |
| 222 | { |
| 223 | /* |
| 224 | * We should now long be done with accessing any peripherals or |
| 225 | * setting up any other hardware state that needs to be set up from |
| 226 | * the secure mode (TrustZone), so we can switch to non-secure mode |
| 227 | * and we rely on board-specific logic to put a board-specific monitor |
| 228 | * in place for stuff like L2 cache maintenance and power management. |
| 229 | */ |
| 230 | enter_ns(); |
| 231 | |
| 232 | /* |
| 233 | * Enter Hyp mode immediately before booting the kernel to allow |
| 234 | * the first Linux kernel access to and control of Hyp mode so that |
| 235 | * modules like KVM can run VMs. |
| 236 | * |
| 237 | * Without further ado... |
| 238 | */ |
| 239 | enter_hyp(); |
| 240 | } |