wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2000 |
| 3 | * Rob Taylor, Flying Pig Systems. robt@flyingpig.com. |
| 4 | * |
| 5 | * See file CREDITS for list of people who contributed to this |
| 6 | * project. |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or |
| 9 | * modify it under the terms of the GNU General Public License as |
| 10 | * published by the Free Software Foundation; either version 2 of |
| 11 | * the License, or (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 21 | * MA 02111-1307 USA |
| 22 | */ |
| 23 | |
| 24 | #include <common.h> |
| 25 | #include <mpc824x.h> |
| 26 | #include <pci.h> |
| 27 | #include <i2c.h> |
Ben Warren | 052a5ea | 2008-08-31 20:37:00 -0700 | [diff] [blame] | 28 | #include <netdev.h> |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 29 | |
Wolfgang Denk | 6405a15 | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 30 | DECLARE_GLOBAL_DATA_PTR; |
| 31 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 32 | int checkboard (void) |
| 33 | { |
| 34 | puts ( "Board: OXC8240\n" ); |
| 35 | return 0; |
| 36 | } |
| 37 | |
Becky Bruce | bd99ae7 | 2008-06-09 16:03:40 -0500 | [diff] [blame] | 38 | phys_size_t initdram (int board_type) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 39 | { |
| 40 | #ifndef CFG_RAMBOOT |
wdenk | 87249ba | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 41 | long size; |
| 42 | long new_bank0_end; |
| 43 | long mear1; |
| 44 | long emear1; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 45 | |
wdenk | 87249ba | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 46 | size = get_ram_size(CFG_SDRAM_BASE, CFG_MAX_RAM_SIZE); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 47 | |
wdenk | 87249ba | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 48 | new_bank0_end = size - 1; |
| 49 | mear1 = mpc824x_mpc107_getreg(MEAR1); |
| 50 | emear1 = mpc824x_mpc107_getreg(EMEAR1); |
| 51 | mear1 = (mear1 & 0xFFFFFF00) | |
| 52 | ((new_bank0_end & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT); |
| 53 | emear1 = (emear1 & 0xFFFFFF00) | |
| 54 | ((new_bank0_end & MICR_ADDR_MASK) >> MICR_EADDR_SHIFT); |
| 55 | mpc824x_mpc107_setreg(MEAR1, mear1); |
| 56 | mpc824x_mpc107_setreg(EMEAR1, emear1); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 57 | |
wdenk | 87249ba | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 58 | return (size); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 59 | #else |
| 60 | /* if U-Boot starts from RAM, then suppose we have 16Mb of RAM */ |
| 61 | return (16 << 20); |
| 62 | #endif |
| 63 | } |
| 64 | |
| 65 | /* |
| 66 | * Initialize PCI Devices, report devices found. |
| 67 | */ |
| 68 | #ifndef CONFIG_PCI_PNP |
| 69 | static struct pci_config_table pci_oxc_config_table[] = { |
| 70 | { PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, 0x14, PCI_ANY_ID, |
| 71 | pci_cfgfunc_config_device, { PCI_ENET0_IOADDR, |
| 72 | PCI_ENET0_MEMADDR, |
| 73 | PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER }}, |
| 74 | { PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, 0x15, PCI_ANY_ID, |
| 75 | pci_cfgfunc_config_device, { PCI_ENET1_IOADDR, |
| 76 | PCI_ENET1_MEMADDR, |
| 77 | PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER }}, |
| 78 | { } |
| 79 | }; |
| 80 | #endif |
| 81 | |
| 82 | static struct pci_controller hose = { |
| 83 | #ifndef CONFIG_PCI_PNP |
| 84 | config_table: pci_oxc_config_table, |
| 85 | #endif |
| 86 | }; |
| 87 | |
stroese | f5dd410 | 2003-02-14 11:21:23 +0000 | [diff] [blame] | 88 | void pci_init_board (void) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 89 | { |
| 90 | pci_mpc824x_init(&hose); |
| 91 | } |
| 92 | |
wdenk | da55c6e | 2004-01-20 23:12:12 +0000 | [diff] [blame] | 93 | int board_early_init_f (void) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 94 | { |
| 95 | *(volatile unsigned char *)(CFG_CPLD_RESET) = 0x89; |
| 96 | return 0; |
| 97 | } |
| 98 | |
| 99 | #ifdef CONFIG_WATCHDOG |
| 100 | void oxc_wdt_reset(void) |
| 101 | { |
| 102 | *(volatile unsigned char *)(CFG_CPLD_WATCHDOG) = 0xff; |
| 103 | } |
| 104 | |
| 105 | void watchdog_reset(void) |
| 106 | { |
| 107 | int re_enable = disable_interrupts(); |
| 108 | |
| 109 | oxc_wdt_reset(); |
| 110 | if (re_enable) |
| 111 | enable_interrupts(); |
| 112 | } |
| 113 | #endif |
| 114 | |
| 115 | static int oxc_get_expander(unsigned char addr, unsigned char * val) |
| 116 | { |
| 117 | return i2c_read(addr, 0, 0, val, 1); |
| 118 | } |
| 119 | |
| 120 | static int oxc_set_expander(unsigned char addr, unsigned char val) |
| 121 | { |
| 122 | return i2c_write(addr, 0, 0, &val, 1); |
| 123 | } |
| 124 | |
| 125 | static int expander0alive = 0; |
| 126 | |
| 127 | #ifdef CONFIG_SHOW_ACTIVITY |
| 128 | static int ledtoggle = 0; |
| 129 | static int ledstatus = 1; |
| 130 | |
| 131 | void oxc_toggle_activeled(void) |
| 132 | { |
| 133 | ledtoggle++; |
| 134 | } |
| 135 | |
wdenk | c0aa5c5 | 2003-12-06 19:49:23 +0000 | [diff] [blame] | 136 | void board_show_activity (ulong timestamp) |
| 137 | { |
| 138 | if ((timestamp % (CFG_HZ / 10)) == 0) |
| 139 | oxc_toggle_activeled (); |
| 140 | } |
| 141 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 142 | void show_activity(int arg) |
| 143 | { |
| 144 | static unsigned char led = 0; |
| 145 | unsigned char val; |
| 146 | |
| 147 | if (!expander0alive) return; |
| 148 | |
| 149 | if ((ledtoggle > (2 * arg)) && ledstatus) { |
| 150 | led ^= 0x80; |
| 151 | oxc_get_expander(CFG_I2C_EXPANDER0_ADDR, &val); |
| 152 | udelay(200); |
| 153 | oxc_set_expander(CFG_I2C_EXPANDER0_ADDR, (val & 0x7F) | led); |
| 154 | ledtoggle = 0; |
| 155 | } |
| 156 | } |
| 157 | #endif |
| 158 | |
| 159 | #ifdef CONFIG_SHOW_BOOT_PROGRESS |
| 160 | void show_boot_progress(int arg) |
| 161 | { |
| 162 | unsigned char val; |
| 163 | |
| 164 | if (!expander0alive) return; |
| 165 | |
| 166 | if (arg > 0 && ledstatus) { |
| 167 | ledstatus = 0; |
| 168 | oxc_get_expander(CFG_I2C_EXPANDER0_ADDR, &val); |
| 169 | udelay(200); |
| 170 | oxc_set_expander(CFG_I2C_EXPANDER0_ADDR, val | 0x80); |
| 171 | } else if (arg < 0) { |
| 172 | oxc_get_expander(CFG_I2C_EXPANDER0_ADDR, &val); |
| 173 | udelay(200); |
| 174 | oxc_set_expander(CFG_I2C_EXPANDER0_ADDR, val & 0x7F); |
| 175 | ledstatus = 1; |
| 176 | } |
| 177 | } |
| 178 | #endif |
| 179 | |
| 180 | int misc_init_r (void) |
| 181 | { |
| 182 | /* check whether the i2c expander #0 is accessible */ |
| 183 | if (!oxc_set_expander(CFG_I2C_EXPANDER0_ADDR, 0x7F)) { |
| 184 | udelay(200); |
| 185 | expander0alive = 1; |
| 186 | } |
| 187 | |
| 188 | #ifdef CFG_OXC_GENERATE_IP |
| 189 | { |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 190 | char str[32]; |
| 191 | unsigned long ip = CFG_OXC_IPMASK; |
| 192 | bd_t *bd = gd->bd; |
| 193 | |
| 194 | if (expander0alive) { |
| 195 | unsigned char val; |
| 196 | |
| 197 | if (!oxc_get_expander(CFG_I2C_EXPANDER0_ADDR, &val)) { |
| 198 | ip = (ip & 0xffffff00) | ((val & 0x7c) >> 2); |
| 199 | } |
| 200 | } |
| 201 | |
| 202 | if ((ip & 0xff) < 3) { |
| 203 | /* if fail, set x.x.x.254 */ |
| 204 | ip = (ip & 0xffffff00) | 0xfe; |
| 205 | } |
| 206 | |
| 207 | bd->bi_ip_addr = ip; |
| 208 | sprintf(str, "%ld.%ld.%ld.%ld", |
| 209 | (bd->bi_ip_addr & 0xff000000) >> 24, |
| 210 | (bd->bi_ip_addr & 0x00ff0000) >> 16, |
| 211 | (bd->bi_ip_addr & 0x0000ff00) >> 8, |
| 212 | (bd->bi_ip_addr & 0x000000ff)); |
| 213 | setenv("ipaddr", str); |
| 214 | printf("ip: %s\n", str); |
| 215 | } |
| 216 | #endif |
| 217 | return (0); |
| 218 | } |
Ben Warren | 052a5ea | 2008-08-31 20:37:00 -0700 | [diff] [blame] | 219 | |
| 220 | int board_eth_init(bd_t *bis) |
| 221 | { |
| 222 | return pci_eth_init(bis); |
| 223 | } |