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,
30 DECLARE_GLOBAL_DATA_PTR
;
34 puts ( "Board: OXC8240\n" );
38 phys_size_t
initdram (int board_type
)
40 #ifndef CONFIG_SYS_RAMBOOT
46 size
= get_ram_size(CONFIG_SYS_SDRAM_BASE
, CONFIG_SYS_MAX_RAM_SIZE
);
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
);
60 /* if U-Boot starts from RAM, then suppose we have 16Mb of RAM */
66 * Initialize PCI Devices, report devices found.
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
,
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
,
77 PCI_COMMAND_MEMORY
| PCI_COMMAND_MASTER
}},
82 static struct pci_controller hose
= {
83 #ifndef CONFIG_PCI_PNP
84 config_table
: pci_oxc_config_table
,
88 void pci_init_board (void)
90 pci_mpc824x_init(&hose
);
93 int board_early_init_f (void)
95 *(volatile unsigned char *)(CONFIG_SYS_CPLD_RESET
) = 0x89;
99 #ifdef CONFIG_WATCHDOG
100 void oxc_wdt_reset(void)
102 *(volatile unsigned char *)(CONFIG_SYS_CPLD_WATCHDOG
) = 0xff;
105 void watchdog_reset(void)
107 int re_enable
= disable_interrupts();
115 static int oxc_get_expander(unsigned char addr
, unsigned char * val
)
117 return i2c_read(addr
, 0, 0, val
, 1);
120 static int oxc_set_expander(unsigned char addr
, unsigned char val
)
122 return i2c_write(addr
, 0, 0, &val
, 1);
125 static int expander0alive
= 0;
127 #ifdef CONFIG_SHOW_ACTIVITY
128 static int ledtoggle
= 0;
129 static int ledstatus
= 1;
131 void oxc_toggle_activeled(void)
136 void board_show_activity (ulong timestamp
)
138 if ((timestamp
% (CONFIG_SYS_HZ
/ 10)) == 0)
139 oxc_toggle_activeled ();
142 void show_activity(int arg
)
144 static unsigned char led
= 0;
147 if (!expander0alive
) return;
149 if ((ledtoggle
> (2 * arg
)) && ledstatus
) {
151 oxc_get_expander(CONFIG_SYS_I2C_EXPANDER0_ADDR
, &val
);
153 oxc_set_expander(CONFIG_SYS_I2C_EXPANDER0_ADDR
, (val
& 0x7F) | led
);
159 #ifdef CONFIG_SHOW_BOOT_PROGRESS
160 void show_boot_progress(int arg
)
164 if (!expander0alive
) return;
166 if (arg
> 0 && ledstatus
) {
168 oxc_get_expander(CONFIG_SYS_I2C_EXPANDER0_ADDR
, &val
);
170 oxc_set_expander(CONFIG_SYS_I2C_EXPANDER0_ADDR
, val
| 0x80);
171 } else if (arg
< 0) {
172 oxc_get_expander(CONFIG_SYS_I2C_EXPANDER0_ADDR
, &val
);
174 oxc_set_expander(CONFIG_SYS_I2C_EXPANDER0_ADDR
, val
& 0x7F);
180 int misc_init_r (void)
182 /* check whether the i2c expander #0 is accessible */
183 if (!oxc_set_expander(CONFIG_SYS_I2C_EXPANDER0_ADDR
, 0x7F)) {
188 #ifdef CONFIG_SYS_OXC_GENERATE_IP
191 unsigned long ip
= CONFIG_SYS_OXC_IPMASK
;
194 if (expander0alive
) {
197 if (!oxc_get_expander(CONFIG_SYS_I2C_EXPANDER0_ADDR
, &val
)) {
198 ip
= (ip
& 0xffffff00) | ((val
& 0x7c) >> 2);
202 if ((ip
& 0xff) < 3) {
203 /* if fail, set x.x.x.254 */
204 ip
= (ip
& 0xffffff00) | 0xfe;
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
);
220 int board_eth_init(bd_t
*bis
)
222 return pci_eth_init(bis
);