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