wdenk | 1cb8e98 | 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) | f310830 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 6 | * (C) Copyright 2002, 2010 |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 7 | * David Mueller, ELSOFT AG, <d.mueller@elsoft.ch> |
| 8 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 9 | * SPDX-License-Identifier: GPL-2.0+ |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 10 | */ |
| 11 | |
| 12 | #include <common.h> |
Ben Warren | b1c0eaa | 2009-08-25 13:09:37 -0700 | [diff] [blame] | 13 | #include <netdev.h> |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 14 | #include <i2c.h> |
David Müller (ELSOFT AG) | f310830 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 15 | #include <asm/io.h> |
| 16 | #include <asm/arch/s3c24x0_cpu.h> |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 17 | |
| 18 | #include "vcma9.h" |
| 19 | #include "../common/common_util.h" |
| 20 | |
Wolfgang Denk | d87080b | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 21 | DECLARE_GLOBAL_DATA_PTR; |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 22 | |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 23 | /* |
| 24 | * Miscellaneous platform dependent initialisations |
| 25 | */ |
| 26 | |
David Müller (ELSOFT AG) | f310830 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 27 | int board_early_init_f(void) |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 28 | { |
kevin.morfitt@fearnside-systems.co.uk | eb0ae7f | 2009-10-10 13:33:11 +0900 | [diff] [blame] | 29 | struct s3c24x0_gpio * const gpio = s3c24x0_get_base_gpio(); |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 30 | |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 31 | /* set up the I/O ports */ |
David Müller (ELSOFT AG) | f310830 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 32 | writel(0x007FFFFF, &gpio->gpacon); |
| 33 | writel(0x002AAAAA, &gpio->gpbcon); |
| 34 | writel(0x000002BF, &gpio->gpbup); |
| 35 | writel(0xAAAAAAAA, &gpio->gpccon); |
| 36 | writel(0x0000FFFF, &gpio->gpcup); |
| 37 | writel(0xAAAAAAAA, &gpio->gpdcon); |
| 38 | writel(0x0000FFFF, &gpio->gpdup); |
| 39 | writel(0xAAAAAAAA, &gpio->gpecon); |
| 40 | writel(0x000037F7, &gpio->gpeup); |
| 41 | writel(0x00000000, &gpio->gpfcon); |
| 42 | writel(0x00000000, &gpio->gpfup); |
| 43 | writel(0xFFEAFF5A, &gpio->gpgcon); |
| 44 | writel(0x0000F0DC, &gpio->gpgup); |
| 45 | writel(0x0028AAAA, &gpio->gphcon); |
| 46 | writel(0x00000656, &gpio->gphup); |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 47 | |
David Müller (ELSOFT AG) | f310830 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 48 | /* setup correct IRQ modes for NIC (rising edge mode) */ |
| 49 | writel((readl(&gpio->extint2) & ~(7<<8)) | (4<<8), &gpio->extint2); |
wdenk | 48b4261 | 2003-06-19 23:01:32 +0000 | [diff] [blame] | 50 | |
David Müller (ELSOFT AG) | f310830 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 51 | /* select USB port 2 to be host or device (setup as host for now) */ |
| 52 | writel(readl(&gpio->misccr) | 0x08, &gpio->misccr); |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 53 | |
David Müller (ELSOFT AG) | f310830 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 54 | return 0; |
| 55 | } |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 56 | |
David Müller (ELSOFT AG) | f310830 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 57 | int board_init(void) |
| 58 | { |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 59 | /* adress of boot parameters */ |
| 60 | gd->bd->bi_boot_params = 0x30000100; |
| 61 | |
| 62 | icache_enable(); |
| 63 | dcache_enable(); |
| 64 | |
| 65 | return 0; |
| 66 | } |
| 67 | |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 68 | /* |
| 69 | * Get some Board/PLD Info |
| 70 | */ |
| 71 | |
David Müller (ELSOFT AG) | f310830 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 72 | static u8 get_pld_reg(enum vcma9_pld_regs reg) |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 73 | { |
David Müller (ELSOFT AG) | f310830 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 74 | return readb(VCMA9_PLD_BASE + reg); |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 75 | } |
| 76 | |
David Müller (ELSOFT AG) | f310830 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 77 | static u8 get_pld_version(void) |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 78 | { |
David Müller (ELSOFT AG) | f310830 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 79 | return (get_pld_reg(VCMA9_PLD_ID) >> 4) & 0x0F; |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 80 | } |
| 81 | |
David Müller (ELSOFT AG) | f310830 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 82 | static u8 get_pld_revision(void) |
wdenk | 531716e | 2003-09-13 19:01:12 +0000 | [diff] [blame] | 83 | { |
David Müller (ELSOFT AG) | f310830 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 84 | return get_pld_reg(VCMA9_PLD_ID) & 0x0F; |
wdenk | 531716e | 2003-09-13 19:01:12 +0000 | [diff] [blame] | 85 | } |
| 86 | |
David Müller (ELSOFT AG) | f310830 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 87 | static uchar get_board_pcb(void) |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 88 | { |
David Müller (ELSOFT AG) | f310830 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 89 | return ((get_pld_reg(VCMA9_PLD_BOARD) >> 4) & 0x03) + 'A'; |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 90 | } |
| 91 | |
David Müller (ELSOFT AG) | f310830 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 92 | static u8 get_nr_chips(void) |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 93 | { |
David Müller (ELSOFT AG) | f310830 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 94 | switch ((get_pld_reg(VCMA9_PLD_SDRAM) >> 4) & 0x0F) { |
wdenk | 531716e | 2003-09-13 19:01:12 +0000 | [diff] [blame] | 95 | case 0: return 4; |
| 96 | case 1: return 1; |
| 97 | case 2: return 2; |
| 98 | default: return 0; |
| 99 | } |
| 100 | } |
| 101 | |
David Müller (ELSOFT AG) | f310830 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 102 | static ulong get_chip_size(void) |
wdenk | 531716e | 2003-09-13 19:01:12 +0000 | [diff] [blame] | 103 | { |
David Müller (ELSOFT AG) | f310830 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 104 | switch (get_pld_reg(VCMA9_PLD_SDRAM) & 0x0F) { |
wdenk | 531716e | 2003-09-13 19:01:12 +0000 | [diff] [blame] | 105 | case 0: return 16 * (1024*1024); |
| 106 | case 1: return 32 * (1024*1024); |
| 107 | case 2: return 8 * (1024*1024); |
| 108 | case 3: return 8 * (1024*1024); |
| 109 | default: return 0; |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 110 | } |
wdenk | 531716e | 2003-09-13 19:01:12 +0000 | [diff] [blame] | 111 | } |
David Müller (ELSOFT AG) | f310830 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 112 | |
| 113 | static const char *get_chip_geom(void) |
wdenk | 531716e | 2003-09-13 19:01:12 +0000 | [diff] [blame] | 114 | { |
David Müller (ELSOFT AG) | f310830 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 115 | switch (get_pld_reg(VCMA9_PLD_SDRAM) & 0x0F) { |
wdenk | 531716e | 2003-09-13 19:01:12 +0000 | [diff] [blame] | 116 | case 0: return "4Mx8x4"; |
| 117 | case 1: return "8Mx8x4"; |
| 118 | case 2: return "2Mx8x4"; |
| 119 | case 3: return "4Mx8x2"; |
| 120 | default: return "unknown"; |
| 121 | } |
| 122 | } |
| 123 | |
David Müller (ELSOFT AG) | f310830 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 124 | static void vcma9_show_info(char *board_name, char *serial) |
wdenk | 531716e | 2003-09-13 19:01:12 +0000 | [diff] [blame] | 125 | { |
| 126 | printf("Board: %s SN: %s PCB Rev: %c PLD(%d,%d)\n", |
David Müller (ELSOFT AG) | f310830 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 127 | board_name, serial, |
| 128 | get_board_pcb(), get_pld_version(), get_pld_revision()); |
| 129 | printf("SDRAM: %d chips %s\n", get_nr_chips(), get_chip_geom()); |
wdenk | 531716e | 2003-09-13 19:01:12 +0000 | [diff] [blame] | 130 | } |
| 131 | |
| 132 | int dram_init(void) |
| 133 | { |
David Müller (ELSOFT AG) | f310830 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 134 | /* dram_init must store complete ramsize in gd->ram_size */ |
| 135 | gd->ram_size = get_chip_size() * get_nr_chips(); |
wdenk | 531716e | 2003-09-13 19:01:12 +0000 | [diff] [blame] | 136 | return 0; |
| 137 | } |
| 138 | |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 139 | /* |
| 140 | * Check Board Identity: |
| 141 | */ |
| 142 | |
| 143 | int checkboard(void) |
| 144 | { |
Wolfgang Denk | fc19e36 | 2007-10-13 23:51:14 +0200 | [diff] [blame] | 145 | char s[50]; |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 146 | int i; |
| 147 | backup_t *b = (backup_t *) s; |
| 148 | |
Wolfgang Denk | cdb7497 | 2010-07-24 21:55:43 +0200 | [diff] [blame] | 149 | i = getenv_f("serial#", s, 32); |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 150 | if ((i < 0) || strncmp (s, "VCMA9", 5)) { |
| 151 | get_backup_values (b); |
| 152 | if (strncmp (b->signature, "MPL\0", 4) != 0) { |
| 153 | puts ("### No HW ID - assuming VCMA9"); |
| 154 | } else { |
| 155 | b->serial_name[5] = 0; |
David Müller (ELSOFT AG) | f310830 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 156 | vcma9_show_info(b->serial_name, &b->serial_name[6]); |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 157 | } |
| 158 | } else { |
| 159 | s[5] = 0; |
David Müller (ELSOFT AG) | f310830 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 160 | vcma9_show_info(s, &s[6]); |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 161 | } |
David Müller (ELSOFT AG) | f310830 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 162 | |
| 163 | return 0; |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 164 | } |
| 165 | |
David Müller (ELSOFT AG) | f310830 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 166 | int board_late_init(void) |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 167 | { |
David Müller (ELSOFT AG) | f310830 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 168 | /* |
| 169 | * check if environment is healthy, otherwise restore values |
| 170 | * from shadow copy |
| 171 | */ |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 172 | check_env(); |
| 173 | return 0; |
| 174 | } |
| 175 | |
David Müller (ELSOFT AG) | f310830 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 176 | void vcma9_print_info(void) |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 177 | { |
David Müller (ELSOFT AG) | f310830 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 178 | char *s = getenv("serial#"); |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 179 | |
David Müller (ELSOFT AG) | f310830 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 180 | if (!s) { |
wdenk | 531716e | 2003-09-13 19:01:12 +0000 | [diff] [blame] | 181 | puts ("### No HW ID - assuming VCMA9"); |
wdenk | 531716e | 2003-09-13 19:01:12 +0000 | [diff] [blame] | 182 | } else { |
| 183 | s[5] = 0; |
David Müller (ELSOFT AG) | f310830 | 2011-05-01 21:52:51 +0000 | [diff] [blame] | 184 | vcma9_show_info(s, &s[6]); |
wdenk | 531716e | 2003-09-13 19:01:12 +0000 | [diff] [blame] | 185 | } |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 186 | } |
Ben Warren | b1c0eaa | 2009-08-25 13:09:37 -0700 | [diff] [blame] | 187 | |
| 188 | #ifdef CONFIG_CMD_NET |
| 189 | int board_eth_init(bd_t *bis) |
| 190 | { |
| 191 | int rc = 0; |
| 192 | #ifdef CONFIG_CS8900 |
| 193 | rc = cs8900_initialize(0, CONFIG_CS8900_BASE); |
| 194 | #endif |
| 195 | return rc; |
| 196 | } |
| 197 | #endif |
David Müller (ELSOFT AG) | 6d75484 | 2011-05-01 21:52:50 +0000 | [diff] [blame] | 198 | |
| 199 | /* |
| 200 | * Hardcoded flash setup: |
| 201 | * Flash 0 is a non-CFI AMD AM29F400BB flash. |
| 202 | */ |
| 203 | ulong board_flash_get_legacy(ulong base, int banknum, flash_info_t *info) |
| 204 | { |
| 205 | info->portwidth = FLASH_CFI_16BIT; |
| 206 | info->chipwidth = FLASH_CFI_BY16; |
| 207 | info->interface = FLASH_CFI_X16; |
| 208 | return 1; |
| 209 | } |