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