wdenk | 1fe2c70 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2002 |
| 3 | * Sysgo Real-Time Solutions, GmbH <www.elinos.com> |
| 4 | * Marius Groeger <mgroeger@sysgo.de> |
| 5 | * |
David Müller (ELSOFT AG) | d3a4d25 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 6 | * (C) Copyright 2002, 2010 |
wdenk | 1fe2c70 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 7 | * David Mueller, ELSOFT AG, <d.mueller@elsoft.ch> |
| 8 | * |
| 9 | * See file CREDITS for list of people who contributed to this |
| 10 | * project. |
| 11 | * |
| 12 | * This program is free software; you can redistribute it and/or |
| 13 | * modify it under the terms of the GNU General Public License as |
| 14 | * published by the Free Software Foundation; either version 2 of |
| 15 | * the License, or (at your option) any later version. |
| 16 | * |
| 17 | * This program is distributed in the hope that it will be useful, |
| 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 20 | * GNU General Public License for more details. |
| 21 | * |
| 22 | * You should have received a copy of the GNU General Public License |
| 23 | * along with this program; if not, write to the Free Software |
| 24 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 25 | * MA 02111-1307 USA |
| 26 | */ |
| 27 | |
| 28 | #include <common.h> |
Ben Warren | 3bf5d83 | 2009-08-25 13:09:37 -0700 | [diff] [blame] | 29 | #include <netdev.h> |
wdenk | 1fe2c70 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 30 | #include <i2c.h> |
David Müller (ELSOFT AG) | d3a4d25 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 31 | #include <asm/io.h> |
| 32 | #include <asm/arch/s3c24x0_cpu.h> |
wdenk | 1fe2c70 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 33 | |
| 34 | #include "vcma9.h" |
| 35 | #include "../common/common_util.h" |
| 36 | |
Wolfgang Denk | 6405a15 | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 37 | DECLARE_GLOBAL_DATA_PTR; |
wdenk | 1fe2c70 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 38 | |
wdenk | 1fe2c70 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 39 | /* |
| 40 | * Miscellaneous platform dependent initialisations |
| 41 | */ |
| 42 | |
David Müller (ELSOFT AG) | d3a4d25 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 43 | int board_early_init_f(void) |
wdenk | 1fe2c70 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 44 | { |
kevin.morfitt@fearnside-systems.co.uk | 1464f4d | 2009-10-10 13:33:11 +0900 | [diff] [blame] | 45 | struct s3c24x0_gpio * const gpio = s3c24x0_get_base_gpio(); |
wdenk | 1fe2c70 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 46 | |
wdenk | 1fe2c70 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 47 | /* set up the I/O ports */ |
David Müller (ELSOFT AG) | d3a4d25 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 48 | writel(0x007FFFFF, &gpio->gpacon); |
| 49 | writel(0x002AAAAA, &gpio->gpbcon); |
| 50 | writel(0x000002BF, &gpio->gpbup); |
| 51 | writel(0xAAAAAAAA, &gpio->gpccon); |
| 52 | writel(0x0000FFFF, &gpio->gpcup); |
| 53 | writel(0xAAAAAAAA, &gpio->gpdcon); |
| 54 | writel(0x0000FFFF, &gpio->gpdup); |
| 55 | writel(0xAAAAAAAA, &gpio->gpecon); |
| 56 | writel(0x000037F7, &gpio->gpeup); |
| 57 | writel(0x00000000, &gpio->gpfcon); |
| 58 | writel(0x00000000, &gpio->gpfup); |
| 59 | writel(0xFFEAFF5A, &gpio->gpgcon); |
| 60 | writel(0x0000F0DC, &gpio->gpgup); |
| 61 | writel(0x0028AAAA, &gpio->gphcon); |
| 62 | writel(0x00000656, &gpio->gphup); |
wdenk | 1fe2c70 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 63 | |
David Müller (ELSOFT AG) | d3a4d25 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 64 | /* setup correct IRQ modes for NIC (rising edge mode) */ |
| 65 | writel((readl(&gpio->extint2) & ~(7<<8)) | (4<<8), &gpio->extint2); |
wdenk | 7539dea | 2003-06-19 23:01:32 +0000 | [diff] [blame] | 66 | |
David Müller (ELSOFT AG) | d3a4d25 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 67 | /* select USB port 2 to be host or device (setup as host for now) */ |
| 68 | writel(readl(&gpio->misccr) | 0x08, &gpio->misccr); |
wdenk | 1fe2c70 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 69 | |
David Müller (ELSOFT AG) | d3a4d25 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 70 | return 0; |
| 71 | } |
wdenk | 1fe2c70 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 72 | |
David Müller (ELSOFT AG) | d3a4d25 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 73 | int board_init(void) |
| 74 | { |
wdenk | 1fe2c70 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 75 | /* arch number of VCMA9-Board */ |
wdenk | 767fbd4 | 2004-10-10 18:41:04 +0000 | [diff] [blame] | 76 | gd->bd->bi_arch_number = MACH_TYPE_MPL_VCMA9; |
wdenk | 1fe2c70 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 77 | |
| 78 | /* adress of boot parameters */ |
| 79 | gd->bd->bi_boot_params = 0x30000100; |
| 80 | |
| 81 | icache_enable(); |
| 82 | dcache_enable(); |
| 83 | |
| 84 | return 0; |
| 85 | } |
| 86 | |
wdenk | 7539dea | 2003-06-19 23:01:32 +0000 | [diff] [blame] | 87 | /* |
wdenk | 1fe2c70 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 88 | * Get some Board/PLD Info |
| 89 | */ |
| 90 | |
David Müller (ELSOFT AG) | d3a4d25 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 91 | static u8 get_pld_reg(enum vcma9_pld_regs reg) |
wdenk | 1fe2c70 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 92 | { |
David Müller (ELSOFT AG) | d3a4d25 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 93 | return readb(VCMA9_PLD_BASE + reg); |
wdenk | 1fe2c70 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 94 | } |
| 95 | |
David Müller (ELSOFT AG) | d3a4d25 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 96 | static u8 get_pld_version(void) |
wdenk | 1fe2c70 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 97 | { |
David Müller (ELSOFT AG) | d3a4d25 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 98 | return (get_pld_reg(VCMA9_PLD_ID) >> 4) & 0x0F; |
wdenk | 1fe2c70 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 99 | } |
| 100 | |
David Müller (ELSOFT AG) | d3a4d25 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 101 | static u8 get_pld_revision(void) |
wdenk | 1fe2c70 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 102 | { |
David Müller (ELSOFT AG) | d3a4d25 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 103 | return get_pld_reg(VCMA9_PLD_ID) & 0x0F; |
wdenk | 1fe2c70 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 104 | } |
| 105 | |
David Müller (ELSOFT AG) | d3a4d25 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 106 | static uchar get_board_pcb(void) |
wdenk | 1fe2c70 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 107 | { |
David Müller (ELSOFT AG) | d3a4d25 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 108 | return ((get_pld_reg(VCMA9_PLD_BOARD) >> 4) & 0x03) + 'A'; |
wdenk | 1fe2c70 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 109 | } |
| 110 | |
David Müller (ELSOFT AG) | d3a4d25 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 111 | static u8 get_nr_chips(void) |
wdenk | 2552190 | 2003-09-13 19:01:12 +0000 | [diff] [blame] | 112 | { |
David Müller (ELSOFT AG) | d3a4d25 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 113 | switch ((get_pld_reg(VCMA9_PLD_SDRAM) >> 4) & 0x0F) { |
wdenk | 2552190 | 2003-09-13 19:01:12 +0000 | [diff] [blame] | 114 | case 0: return 4; |
| 115 | case 1: return 1; |
| 116 | case 2: return 2; |
| 117 | default: return 0; |
| 118 | } |
| 119 | } |
| 120 | |
David Müller (ELSOFT AG) | d3a4d25 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 121 | static ulong get_chip_size(void) |
wdenk | 2552190 | 2003-09-13 19:01:12 +0000 | [diff] [blame] | 122 | { |
David Müller (ELSOFT AG) | d3a4d25 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 123 | switch (get_pld_reg(VCMA9_PLD_SDRAM) & 0x0F) { |
wdenk | 2552190 | 2003-09-13 19:01:12 +0000 | [diff] [blame] | 124 | case 0: return 16 * (1024*1024); |
| 125 | case 1: return 32 * (1024*1024); |
| 126 | case 2: return 8 * (1024*1024); |
| 127 | case 3: return 8 * (1024*1024); |
| 128 | default: return 0; |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 129 | } |
wdenk | 2552190 | 2003-09-13 19:01:12 +0000 | [diff] [blame] | 130 | } |
David Müller (ELSOFT AG) | d3a4d25 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 131 | |
| 132 | static const char *get_chip_geom(void) |
wdenk | 2552190 | 2003-09-13 19:01:12 +0000 | [diff] [blame] | 133 | { |
David Müller (ELSOFT AG) | d3a4d25 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 134 | switch (get_pld_reg(VCMA9_PLD_SDRAM) & 0x0F) { |
wdenk | 2552190 | 2003-09-13 19:01:12 +0000 | [diff] [blame] | 135 | case 0: return "4Mx8x4"; |
| 136 | case 1: return "8Mx8x4"; |
| 137 | case 2: return "2Mx8x4"; |
| 138 | case 3: return "4Mx8x2"; |
| 139 | default: return "unknown"; |
| 140 | } |
| 141 | } |
| 142 | |
David Müller (ELSOFT AG) | d3a4d25 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 143 | static void vcma9_show_info(char *board_name, char *serial) |
wdenk | 2552190 | 2003-09-13 19:01:12 +0000 | [diff] [blame] | 144 | { |
| 145 | printf("Board: %s SN: %s PCB Rev: %c PLD(%d,%d)\n", |
David Müller (ELSOFT AG) | d3a4d25 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 146 | board_name, serial, |
| 147 | get_board_pcb(), get_pld_version(), get_pld_revision()); |
| 148 | printf("SDRAM: %d chips %s\n", get_nr_chips(), get_chip_geom()); |
wdenk | 2552190 | 2003-09-13 19:01:12 +0000 | [diff] [blame] | 149 | } |
| 150 | |
| 151 | int dram_init(void) |
| 152 | { |
David Müller (ELSOFT AG) | d3a4d25 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 153 | /* dram_init must store complete ramsize in gd->ram_size */ |
| 154 | gd->ram_size = get_chip_size() * get_nr_chips(); |
wdenk | 2552190 | 2003-09-13 19:01:12 +0000 | [diff] [blame] | 155 | return 0; |
| 156 | } |
| 157 | |
wdenk | 1fe2c70 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 158 | /* |
| 159 | * Check Board Identity: |
| 160 | */ |
| 161 | |
| 162 | int checkboard(void) |
| 163 | { |
Wolfgang Denk | 585f088 | 2007-10-13 23:51:14 +0200 | [diff] [blame] | 164 | char s[50]; |
wdenk | 1fe2c70 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 165 | int i; |
| 166 | backup_t *b = (backup_t *) s; |
| 167 | |
Wolfgang Denk | 76af278 | 2010-07-24 21:55:43 +0200 | [diff] [blame] | 168 | i = getenv_f("serial#", s, 32); |
wdenk | 1fe2c70 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 169 | if ((i < 0) || strncmp (s, "VCMA9", 5)) { |
| 170 | get_backup_values (b); |
| 171 | if (strncmp (b->signature, "MPL\0", 4) != 0) { |
| 172 | puts ("### No HW ID - assuming VCMA9"); |
| 173 | } else { |
| 174 | b->serial_name[5] = 0; |
David Müller (ELSOFT AG) | d3a4d25 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 175 | vcma9_show_info(b->serial_name, &b->serial_name[6]); |
wdenk | 1fe2c70 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 176 | } |
| 177 | } else { |
| 178 | s[5] = 0; |
David Müller (ELSOFT AG) | d3a4d25 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 179 | vcma9_show_info(s, &s[6]); |
wdenk | 1fe2c70 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 180 | } |
wdenk | 1fe2c70 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 181 | |
wdenk | 1fe2c70 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 182 | return 0; |
| 183 | } |
| 184 | |
David Müller (ELSOFT AG) | d3a4d25 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 185 | int board_late_init(void) |
wdenk | 1fe2c70 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 186 | { |
David Müller (ELSOFT AG) | d3a4d25 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 187 | /* |
| 188 | * check if environment is healthy, otherwise restore values |
| 189 | * from shadow copy |
| 190 | */ |
| 191 | check_env(); |
wdenk | 1fe2c70 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 192 | return 0; |
| 193 | } |
wdenk | 1fe2c70 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 194 | |
David Müller (ELSOFT AG) | d3a4d25 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 195 | void vcma9_print_info(void) |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 196 | { |
David Müller (ELSOFT AG) | d3a4d25 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 197 | char *s = getenv("serial#"); |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 198 | |
David Müller (ELSOFT AG) | d3a4d25 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 199 | if (!s) { |
wdenk | 2552190 | 2003-09-13 19:01:12 +0000 | [diff] [blame] | 200 | puts ("### No HW ID - assuming VCMA9"); |
wdenk | 2552190 | 2003-09-13 19:01:12 +0000 | [diff] [blame] | 201 | } else { |
| 202 | s[5] = 0; |
David Müller (ELSOFT AG) | d3a4d25 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 203 | vcma9_show_info(s, &s[6]); |
wdenk | 2552190 | 2003-09-13 19:01:12 +0000 | [diff] [blame] | 204 | } |
wdenk | 1fe2c70 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 205 | } |
Ben Warren | 3bf5d83 | 2009-08-25 13:09:37 -0700 | [diff] [blame] | 206 | |
| 207 | #ifdef CONFIG_CMD_NET |
| 208 | int board_eth_init(bd_t *bis) |
| 209 | { |
| 210 | int rc = 0; |
| 211 | #ifdef CONFIG_CS8900 |
| 212 | rc = cs8900_initialize(0, CONFIG_CS8900_BASE); |
| 213 | #endif |
| 214 | return rc; |
| 215 | } |
| 216 | #endif |
David Müller (ELSOFT AG) | 7fbcd3b | 2011-05-01 21:52:50 +0000 | [diff] [blame] | 217 | |
| 218 | /* |
| 219 | * Hardcoded flash setup: |
| 220 | * Flash 0 is a non-CFI AMD AM29F400BB flash. |
| 221 | */ |
| 222 | ulong board_flash_get_legacy(ulong base, int banknum, flash_info_t *info) |
| 223 | { |
| 224 | info->portwidth = FLASH_CFI_16BIT; |
| 225 | info->chipwidth = FLASH_CFI_BY16; |
| 226 | info->interface = FLASH_CFI_X16; |
| 227 | return 1; |
| 228 | } |