3 * Rob Taylor, Flying Pig Systems. robt@flyingpig.com.
5 * See file CREDITS for list of people who contributed to this
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.
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.
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,
31 puts ( "Board: OXC8240\n" );
35 long int initdram (int board_type)
39 volatile uchar * base= CFG_SDRAM_BASE;
40 volatile ulong * addr;
44 for (i=0, cnt=(CFG_MAX_RAM_SIZE / sizeof(long)) >> 1; cnt > 0; cnt >>= 1) {
45 addr = (volatile ulong *)base + cnt;
50 addr = (volatile ulong *)base;
59 for (cnt = 1; cnt <= CFG_MAX_RAM_SIZE / sizeof(long); cnt <<= 1) {
60 addr = (volatile ulong *)base + cnt;
64 ulong new_bank0_end = cnt * sizeof(long) - 1;
65 ulong mear1 = mpc824x_mpc107_getreg(MEAR1);
66 ulong emear1 = mpc824x_mpc107_getreg(EMEAR1);
67 mear1 = (mear1 & 0xFFFFFF00) |
68 ((new_bank0_end & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT);
69 emear1 = (emear1 & 0xFFFFFF00) |
70 ((new_bank0_end & MICR_ADDR_MASK) >> MICR_EADDR_SHIFT);
71 mpc824x_mpc107_setreg(MEAR1, mear1);
72 mpc824x_mpc107_setreg(EMEAR1, emear1);
74 ret = cnt * sizeof(long);
79 ret = CFG_MAX_RAM_SIZE;
83 /* if U-Boot starts from RAM, then suppose we have 16Mb of RAM */
89 * Initialize PCI Devices, report devices found.
91 #ifndef CONFIG_PCI_PNP
92 static struct pci_config_table pci_oxc_config_table[] = {
93 { PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, 0x14, PCI_ANY_ID,
94 pci_cfgfunc_config_device, { PCI_ENET0_IOADDR,
96 PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER }},
97 { PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, 0x15, PCI_ANY_ID,
98 pci_cfgfunc_config_device, { PCI_ENET1_IOADDR,
100 PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER }},
105 static struct pci_controller hose = {
106 #ifndef CONFIG_PCI_PNP
107 config_table: pci_oxc_config_table,
111 void pci_init_board (void)
113 pci_mpc824x_init(&hose);
116 int board_pre_init (void)
118 *(volatile unsigned char *)(CFG_CPLD_RESET) = 0x89;
122 #ifdef CONFIG_WATCHDOG
123 void oxc_wdt_reset(void)
125 *(volatile unsigned char *)(CFG_CPLD_WATCHDOG) = 0xff;
128 void watchdog_reset(void)
130 int re_enable = disable_interrupts();
138 static int oxc_get_expander(unsigned char addr, unsigned char * val)
140 return i2c_read(addr, 0, 0, val, 1);
143 static int oxc_set_expander(unsigned char addr, unsigned char val)
145 return i2c_write(addr, 0, 0, &val, 1);
148 static int expander0alive = 0;
150 #ifdef CONFIG_SHOW_ACTIVITY
151 static int ledtoggle = 0;
152 static int ledstatus = 1;
154 void oxc_toggle_activeled(void)
159 void show_activity(int arg)
161 static unsigned char led = 0;
164 if (!expander0alive) return;
166 if ((ledtoggle > (2 * arg)) && ledstatus) {
168 oxc_get_expander(CFG_I2C_EXPANDER0_ADDR, &val);
170 oxc_set_expander(CFG_I2C_EXPANDER0_ADDR, (val & 0x7F) | led);
176 #ifdef CONFIG_SHOW_BOOT_PROGRESS
177 void show_boot_progress(int arg)
181 if (!expander0alive) return;
183 if (arg > 0 && ledstatus) {
185 oxc_get_expander(CFG_I2C_EXPANDER0_ADDR, &val);
187 oxc_set_expander(CFG_I2C_EXPANDER0_ADDR, val | 0x80);
188 } else if (arg < 0) {
189 oxc_get_expander(CFG_I2C_EXPANDER0_ADDR, &val);
191 oxc_set_expander(CFG_I2C_EXPANDER0_ADDR, val & 0x7F);
197 int misc_init_r (void)
199 /* check whether the i2c expander #0 is accessible */
200 if (!oxc_set_expander(CFG_I2C_EXPANDER0_ADDR, 0x7F)) {
205 #ifdef CFG_OXC_GENERATE_IP
207 DECLARE_GLOBAL_DATA_PTR;
210 unsigned long ip = CFG_OXC_IPMASK;
213 if (expander0alive) {
216 if (!oxc_get_expander(CFG_I2C_EXPANDER0_ADDR, &val)) {
217 ip = (ip & 0xffffff00) | ((val & 0x7c) >> 2);
221 if ((ip & 0xff) < 3) {
222 /* if fail, set x.x.x.254 */
223 ip = (ip & 0xffffff00) | 0xfe;
227 sprintf(str, "%ld.%ld.%ld.%ld",
228 (bd->bi_ip_addr & 0xff000000) >> 24,
229 (bd->bi_ip_addr & 0x00ff0000) >> 16,
230 (bd->bi_ip_addr & 0x0000ff00) >> 8,
231 (bd->bi_ip_addr & 0x000000ff));
232 setenv("ipaddr", str);
233 printf("ip: %s\n", str);