wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2002 Wolfgang Grandegger <wg@denx.de> |
| 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 <mpc824x.h> |
| 25 | #include <pci.h> |
Ben Warren | e309053 | 2008-08-31 10:08:43 -0700 | [diff] [blame] | 26 | #include <netdev.h> |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 27 | |
| 28 | #include "pn62.h" |
| 29 | |
Wolfgang Denk | d87080b | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 30 | DECLARE_GLOBAL_DATA_PTR; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 31 | |
| 32 | static int get_serial_number (char *string, int size); |
Mike Frysinger | b6b4625 | 2009-02-11 18:38:38 -0500 | [diff] [blame^] | 33 | static void get_mac_address(int id, u8 *mac); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 34 | |
| 35 | #ifdef CONFIG_SHOW_BOOT_PROGRESS |
| 36 | void show_boot_progress (int phase) |
| 37 | { |
| 38 | /* |
| 39 | * Show phases of the bootm command on the front panel |
| 40 | * LEDs and the scratchpad register #3 as well. We use |
| 41 | * blinking LEDs for logical "1". |
| 42 | */ |
| 43 | if (phase > 0) { |
| 44 | set_led (8, (phase & 0x1) ? LED_SLOW_CLOCK : LED_0); |
| 45 | set_led (9, (phase & 0x2) ? LED_SLOW_CLOCK : LED_0); |
| 46 | set_led (10, (phase & 0x4) ? LED_SLOW_CLOCK : LED_0); |
| 47 | set_led (11, (phase & 0x8) ? LED_SLOW_CLOCK : LED_0); |
| 48 | } |
| 49 | i2155x_write_scrapad (BOOT_STATUS, phase); |
| 50 | if (phase < 0) |
| 51 | i2155x_write_scrapad (BOOT_DONE, BOOT_DONE_ERROR); |
| 52 | } |
| 53 | #endif |
| 54 | |
| 55 | void show_startup_phase (int phase) |
| 56 | { |
| 57 | /* |
| 58 | * Show the phase of U-Boot startup on the front panel |
| 59 | * LEDs and the scratchpad register #3 as well. |
| 60 | */ |
| 61 | if (phase > 0) { |
| 62 | set_led (8, (phase & 0x1) ? LED_1 : LED_0); |
| 63 | set_led (9, (phase & 0x2) ? LED_1 : LED_0); |
| 64 | set_led (10, (phase & 0x4) ? LED_1 : LED_0); |
| 65 | set_led (11, (phase & 0x8) ? LED_1 : LED_0); |
| 66 | } |
| 67 | i2155x_write_scrapad (BOOT_STATUS, phase); |
| 68 | if (phase < 0) |
| 69 | i2155x_write_scrapad (BOOT_DONE, BOOT_DONE_ERROR); |
| 70 | } |
| 71 | |
| 72 | int checkboard (void) |
| 73 | { |
| 74 | show_startup_phase (1); |
| 75 | puts ("Board: PN62\n"); |
| 76 | return 0; |
| 77 | } |
| 78 | |
Becky Bruce | 9973e3c | 2008-06-09 16:03:40 -0500 | [diff] [blame] | 79 | phys_size_t initdram (int board_type) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 80 | { |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 81 | long size; |
| 82 | long new_bank0_end; |
| 83 | long mear1; |
| 84 | long emear1; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 85 | |
| 86 | show_startup_phase (2); |
| 87 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 88 | size = get_ram_size(CONFIG_SYS_SDRAM_BASE, CONFIG_SYS_MAX_RAM_SIZE); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 89 | |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 90 | new_bank0_end = size - 1; |
| 91 | mear1 = mpc824x_mpc107_getreg (MEAR1); |
| 92 | emear1 = mpc824x_mpc107_getreg (EMEAR1); |
| 93 | mear1 = (mear1 & 0xFFFFFF00) | |
| 94 | ((new_bank0_end & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT); |
| 95 | emear1 = (emear1 & 0xFFFFFF00) | |
| 96 | ((new_bank0_end & MICR_ADDR_MASK) >> MICR_EADDR_SHIFT); |
| 97 | mpc824x_mpc107_setreg (MEAR1, mear1); |
| 98 | mpc824x_mpc107_setreg (EMEAR1, emear1); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 99 | |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 100 | return (size); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 101 | } |
| 102 | |
| 103 | /* |
| 104 | * Initialize PCI Devices. We rely on auto-configuration. |
| 105 | */ |
| 106 | #ifndef CONFIG_PCI_PNP |
| 107 | #error "CONFIG_PCI_PNP is not defined, please correct!" |
| 108 | #endif |
| 109 | |
| 110 | struct pci_controller hose = { |
| 111 | }; |
| 112 | |
stroese | ad10dd9 | 2003-02-14 11:21:23 +0000 | [diff] [blame] | 113 | void pci_init_board (void) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 114 | { |
| 115 | show_startup_phase (4); |
| 116 | pci_mpc824x_init (&hose); |
| 117 | |
| 118 | show_startup_phase (5); |
| 119 | i2155x_init (); |
| 120 | show_startup_phase (6); |
| 121 | am79c95x_init (); |
| 122 | show_startup_phase (7); |
| 123 | } |
| 124 | |
| 125 | int misc_init_r (void) |
| 126 | { |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 127 | char str[20]; |
| 128 | u8 mac[6]; |
| 129 | |
| 130 | show_startup_phase (8); |
| 131 | /* |
| 132 | * Get serial number and ethernet addresses if not already defined |
| 133 | * and update the board info structure and the environment. |
| 134 | */ |
| 135 | if (getenv ("serial#") == NULL && |
| 136 | get_serial_number (str, strlen (str)) > 0) { |
| 137 | setenv ("serial#", str); |
| 138 | } |
| 139 | show_startup_phase (9); |
| 140 | |
Mike Frysinger | b6b4625 | 2009-02-11 18:38:38 -0500 | [diff] [blame^] | 141 | if (!eth_getenv_enetaddr("ethaddr", mac)) { |
| 142 | get_mac_address(0, mac); |
| 143 | eth_setenv_enetaddr("ethaddr", mac); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 144 | } |
| 145 | show_startup_phase (10); |
| 146 | |
wdenk | e2ffd59 | 2004-12-31 09:32:47 +0000 | [diff] [blame] | 147 | #ifdef CONFIG_HAS_ETH1 |
Mike Frysinger | b6b4625 | 2009-02-11 18:38:38 -0500 | [diff] [blame^] | 148 | if (!eth_getenv_enetaddr("eth1addr", mac)) { |
| 149 | get_mac_address(1, mac); |
| 150 | eth_setenv_enetaddr("eth1addr", mac); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 151 | } |
wdenk | e2ffd59 | 2004-12-31 09:32:47 +0000 | [diff] [blame] | 152 | #endif /* CONFIG_HAS_ETH1 */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 153 | show_startup_phase (11); |
| 154 | |
| 155 | /* Tell everybody that U-Boot is up and runnig */ |
| 156 | i2155x_write_scrapad (0, 0x12345678); |
| 157 | return (0); |
| 158 | } |
| 159 | |
| 160 | static int get_serial_number (char *string, int size) |
| 161 | { |
| 162 | int i; |
| 163 | char c; |
| 164 | |
| 165 | if (size < I2155X_VPD_SN_SIZE) |
| 166 | size = I2155X_VPD_SN_SIZE; |
| 167 | for (i = 0; i < (size - 1); i++) { |
Wolfgang Denk | 77ddac9 | 2005-10-13 16:45:02 +0200 | [diff] [blame] | 168 | i2155x_read_vpd (I2155X_VPD_SN_START + i, 1, (uchar *)&c); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 169 | if (c == '\0') |
| 170 | break; |
| 171 | string[i] = c; |
| 172 | } |
| 173 | string[i] = '\0'; /* make sure it's terminated */ |
| 174 | |
| 175 | return i; |
| 176 | } |
| 177 | |
Mike Frysinger | b6b4625 | 2009-02-11 18:38:38 -0500 | [diff] [blame^] | 178 | static void get_mac_address(int id, u8 *mac) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 179 | { |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 180 | i2155x_read_vpd (I2155X_VPD_MAC0_START + 6 * id, 6, mac); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 181 | } |
Ben Warren | e309053 | 2008-08-31 10:08:43 -0700 | [diff] [blame] | 182 | |
| 183 | int board_eth_init(bd_t *bis) |
| 184 | { |
| 185 | return pci_eth_init(bis); |
| 186 | } |