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> |
| 29 | #include <asm/arch/mmc.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 | |
| 33 | DECLARE_GLOBAL_DATA_PTR; |
Chander Kashyap | 0aee53b | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 34 | |
Chander Kashyap | bf93621 | 2012-02-09 01:26:19 +0000 | [diff] [blame] | 35 | #ifdef CONFIG_SMC911X |
Rajeshwari Shinde | c6baaa6 | 2012-06-06 19:54:30 +0000 | [diff] [blame] | 36 | static int smc9115_pre_init(void) |
Chander Kashyap | bf93621 | 2012-02-09 01:26:19 +0000 | [diff] [blame] | 37 | { |
| 38 | u32 smc_bw_conf, smc_bc_conf; |
Rajeshwari Shinde | c6baaa6 | 2012-06-06 19:54:30 +0000 | [diff] [blame] | 39 | int err; |
Chander Kashyap | bf93621 | 2012-02-09 01:26:19 +0000 | [diff] [blame] | 40 | |
| 41 | /* Ethernet needs data bus width of 16 bits */ |
| 42 | smc_bw_conf = SROMC_DATA16_WIDTH(CONFIG_ENV_SROM_BANK) |
| 43 | | SROMC_BYTE_ENABLE(CONFIG_ENV_SROM_BANK); |
| 44 | |
| 45 | smc_bc_conf = SROMC_BC_TACS(0x01) | SROMC_BC_TCOS(0x01) |
| 46 | | SROMC_BC_TACC(0x06) | SROMC_BC_TCOH(0x01) |
| 47 | | SROMC_BC_TAH(0x0C) | SROMC_BC_TACP(0x09) |
| 48 | | SROMC_BC_PMC(0x01); |
| 49 | |
| 50 | /* Select and configure the SROMC bank */ |
Rajeshwari Shinde | c6baaa6 | 2012-06-06 19:54:30 +0000 | [diff] [blame] | 51 | err = exynos_pinmux_config(PERIPH_ID_SROMC, |
| 52 | CONFIG_ENV_SROM_BANK | PINMUX_FLAG_16BIT); |
| 53 | if (err) { |
| 54 | debug("SROMC not configured\n"); |
| 55 | return err; |
| 56 | } |
| 57 | |
Chander Kashyap | bf93621 | 2012-02-09 01:26:19 +0000 | [diff] [blame] | 58 | 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] | 59 | return 0; |
Chander Kashyap | bf93621 | 2012-02-09 01:26:19 +0000 | [diff] [blame] | 60 | } |
| 61 | #endif |
| 62 | |
Chander Kashyap | 0aee53b | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 63 | int board_init(void) |
| 64 | { |
Chander Kashyap | 0aee53b | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 65 | gd->bd->bi_boot_params = (PHYS_SDRAM_1 + 0x100UL); |
| 66 | return 0; |
| 67 | } |
| 68 | |
| 69 | int dram_init(void) |
| 70 | { |
| 71 | gd->ram_size = get_ram_size((long *)PHYS_SDRAM_1, PHYS_SDRAM_1_SIZE) |
| 72 | + get_ram_size((long *)PHYS_SDRAM_2, PHYS_SDRAM_2_SIZE) |
| 73 | + get_ram_size((long *)PHYS_SDRAM_3, PHYS_SDRAM_3_SIZE) |
| 74 | + get_ram_size((long *)PHYS_SDRAM_4, PHYS_SDRAM_4_SIZE) |
| 75 | + get_ram_size((long *)PHYS_SDRAM_5, PHYS_SDRAM_7_SIZE) |
| 76 | + get_ram_size((long *)PHYS_SDRAM_6, PHYS_SDRAM_7_SIZE) |
| 77 | + get_ram_size((long *)PHYS_SDRAM_7, PHYS_SDRAM_7_SIZE) |
| 78 | + get_ram_size((long *)PHYS_SDRAM_8, PHYS_SDRAM_8_SIZE); |
| 79 | return 0; |
| 80 | } |
| 81 | |
| 82 | void dram_init_banksize(void) |
| 83 | { |
| 84 | gd->bd->bi_dram[0].start = PHYS_SDRAM_1; |
| 85 | gd->bd->bi_dram[0].size = get_ram_size((long *)PHYS_SDRAM_1, |
| 86 | PHYS_SDRAM_1_SIZE); |
| 87 | gd->bd->bi_dram[1].start = PHYS_SDRAM_2; |
| 88 | gd->bd->bi_dram[1].size = get_ram_size((long *)PHYS_SDRAM_2, |
| 89 | PHYS_SDRAM_2_SIZE); |
| 90 | gd->bd->bi_dram[2].start = PHYS_SDRAM_3; |
| 91 | gd->bd->bi_dram[2].size = get_ram_size((long *)PHYS_SDRAM_3, |
| 92 | PHYS_SDRAM_3_SIZE); |
| 93 | gd->bd->bi_dram[3].start = PHYS_SDRAM_4; |
| 94 | gd->bd->bi_dram[3].size = get_ram_size((long *)PHYS_SDRAM_4, |
| 95 | PHYS_SDRAM_4_SIZE); |
| 96 | gd->bd->bi_dram[4].start = PHYS_SDRAM_5; |
| 97 | gd->bd->bi_dram[4].size = get_ram_size((long *)PHYS_SDRAM_5, |
| 98 | PHYS_SDRAM_5_SIZE); |
| 99 | gd->bd->bi_dram[5].start = PHYS_SDRAM_6; |
| 100 | gd->bd->bi_dram[5].size = get_ram_size((long *)PHYS_SDRAM_6, |
| 101 | PHYS_SDRAM_6_SIZE); |
| 102 | gd->bd->bi_dram[6].start = PHYS_SDRAM_7; |
| 103 | gd->bd->bi_dram[6].size = get_ram_size((long *)PHYS_SDRAM_7, |
| 104 | PHYS_SDRAM_7_SIZE); |
| 105 | gd->bd->bi_dram[7].start = PHYS_SDRAM_8; |
| 106 | gd->bd->bi_dram[7].size = get_ram_size((long *)PHYS_SDRAM_8, |
| 107 | PHYS_SDRAM_8_SIZE); |
| 108 | } |
| 109 | |
Chander Kashyap | bf93621 | 2012-02-09 01:26:19 +0000 | [diff] [blame] | 110 | int board_eth_init(bd_t *bis) |
| 111 | { |
| 112 | #ifdef CONFIG_SMC911X |
Rajeshwari Shinde | c6baaa6 | 2012-06-06 19:54:30 +0000 | [diff] [blame] | 113 | if (smc9115_pre_init()) |
| 114 | return -1; |
Chander Kashyap | bf93621 | 2012-02-09 01:26:19 +0000 | [diff] [blame] | 115 | return smc911x_initialize(0, CONFIG_SMC911X_BASE); |
| 116 | #endif |
| 117 | return 0; |
| 118 | } |
| 119 | |
Chander Kashyap | 0aee53b | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 120 | #ifdef CONFIG_DISPLAY_BOARDINFO |
| 121 | int checkboard(void) |
| 122 | { |
| 123 | printf("\nBoard: SMDK5250\n"); |
| 124 | |
| 125 | return 0; |
| 126 | } |
| 127 | #endif |
| 128 | |
| 129 | #ifdef CONFIG_GENERIC_MMC |
| 130 | int board_mmc_init(bd_t *bis) |
| 131 | { |
Rajeshwari Shinde | c6baaa6 | 2012-06-06 19:54:30 +0000 | [diff] [blame] | 132 | int err; |
Chander Kashyap | 0aee53b | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 133 | |
Rajeshwari Shinde | 41222c2 | 2012-07-03 20:03:00 +0000 | [diff] [blame] | 134 | err = exynos_pinmux_config(PERIPH_ID_SDMMC0, PINMUX_FLAG_8BIT_MODE); |
Rajeshwari Shinde | c6baaa6 | 2012-06-06 19:54:30 +0000 | [diff] [blame] | 135 | if (err) { |
Rajeshwari Shinde | 41222c2 | 2012-07-03 20:03:00 +0000 | [diff] [blame] | 136 | debug("SDMMC0 not configured\n"); |
Rajeshwari Shinde | c6baaa6 | 2012-06-06 19:54:30 +0000 | [diff] [blame] | 137 | return err; |
Chander Kashyap | 0aee53b | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 138 | } |
| 139 | |
Rajeshwari Shinde | 41222c2 | 2012-07-03 20:03:00 +0000 | [diff] [blame] | 140 | err = s5p_mmc_init(0, 8); |
Chander Kashyap | 0aee53b | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 141 | return err; |
| 142 | } |
| 143 | #endif |
| 144 | |
Rajeshwari Shinde | c6baaa6 | 2012-06-06 19:54:30 +0000 | [diff] [blame] | 145 | static int board_uart_init(void) |
Chander Kashyap | 0aee53b | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 146 | { |
Rajeshwari Shinde | c6baaa6 | 2012-06-06 19:54:30 +0000 | [diff] [blame] | 147 | int err; |
Chander Kashyap | 0aee53b | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 148 | |
Rajeshwari Shinde | c6baaa6 | 2012-06-06 19:54:30 +0000 | [diff] [blame] | 149 | err = exynos_pinmux_config(PERIPH_ID_UART0, PINMUX_FLAG_NONE); |
| 150 | if (err) { |
| 151 | debug("UART0 not configured\n"); |
| 152 | return err; |
Chander Kashyap | 0aee53b | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 153 | } |
Doug Anderson | 813fcb8 | 2012-02-13 07:38:05 +0000 | [diff] [blame] | 154 | |
Rajeshwari Shinde | c6baaa6 | 2012-06-06 19:54:30 +0000 | [diff] [blame] | 155 | err = exynos_pinmux_config(PERIPH_ID_UART1, PINMUX_FLAG_NONE); |
| 156 | if (err) { |
| 157 | debug("UART1 not configured\n"); |
| 158 | return err; |
Doug Anderson | 813fcb8 | 2012-02-13 07:38:05 +0000 | [diff] [blame] | 159 | } |
| 160 | |
Rajeshwari Shinde | c6baaa6 | 2012-06-06 19:54:30 +0000 | [diff] [blame] | 161 | err = exynos_pinmux_config(PERIPH_ID_UART2, PINMUX_FLAG_NONE); |
| 162 | if (err) { |
| 163 | debug("UART2 not configured\n"); |
| 164 | return err; |
Doug Anderson | 813fcb8 | 2012-02-13 07:38:05 +0000 | [diff] [blame] | 165 | } |
| 166 | |
Rajeshwari Shinde | c6baaa6 | 2012-06-06 19:54:30 +0000 | [diff] [blame] | 167 | err = exynos_pinmux_config(PERIPH_ID_UART3, PINMUX_FLAG_NONE); |
| 168 | if (err) { |
| 169 | debug("UART3 not configured\n"); |
| 170 | return err; |
Doug Anderson | 813fcb8 | 2012-02-13 07:38:05 +0000 | [diff] [blame] | 171 | } |
| 172 | |
Rajeshwari Shinde | c6baaa6 | 2012-06-06 19:54:30 +0000 | [diff] [blame] | 173 | return 0; |
Chander Kashyap | 0aee53b | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 174 | } |
| 175 | |
Rajeshwari Shinde | c82b050 | 2012-07-23 21:23:55 +0000 | [diff] [blame] | 176 | #ifdef CONFIG_SYS_I2C_INIT_BOARD |
| 177 | static int board_i2c_init(void) |
| 178 | { |
| 179 | int i, err; |
| 180 | |
| 181 | for (i = 0; i < CONFIG_MAX_I2C_NUM; i++) { |
| 182 | err = exynos_pinmux_config((PERIPH_ID_I2C0 + i), |
| 183 | PINMUX_FLAG_NONE); |
| 184 | if (err) { |
| 185 | debug("I2C%d not configured\n", (PERIPH_ID_I2C0 + i)); |
| 186 | return err; |
| 187 | } |
| 188 | } |
| 189 | i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE); |
| 190 | return 0; |
| 191 | } |
| 192 | #endif |
| 193 | |
Chander Kashyap | 0aee53b | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 194 | #ifdef CONFIG_BOARD_EARLY_INIT_F |
| 195 | int board_early_init_f(void) |
| 196 | { |
Rajeshwari Shinde | c82b050 | 2012-07-23 21:23:55 +0000 | [diff] [blame] | 197 | int err; |
| 198 | err = board_uart_init(); |
| 199 | if (err) { |
| 200 | debug("UART init failed\n"); |
| 201 | return err; |
| 202 | } |
| 203 | #ifdef CONFIG_SYS_I2C_INIT_BOARD |
| 204 | err = board_i2c_init(); |
| 205 | #endif |
| 206 | return err; |
Chander Kashyap | 0aee53b | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 207 | } |
| 208 | #endif |