1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24#include <common.h>
25#include <mpc824x.h>
26#include <net.h>
27#include <pci.h>
28#include <i2c.h>
29#include <netdev.h>
30
31DECLARE_GLOBAL_DATA_PTR;
32
33int checkboard (void)
34{
35
36
37 puts ( "Board: Debris "
38#ifdef CONFIG_MPC8240
39 "8240"
40#endif
41#ifdef CONFIG_MPC8245
42 "8245"
43#endif
44 " ##Test not implemented yet##\n");
45 return 0;
46}
47
48#if 0
49int checkflash (void)
50{
51
52 printf ("## Test not implemented yet ##\n");
53
54 return (0);
55}
56#endif
57
58phys_size_t initdram (int board_type)
59{
60 int m, row, col, bank, i;
61 unsigned long start, end;
62 uint32_t mccr1;
63 uint32_t mear1 = 0, emear1 = 0, msar1 = 0, emsar1 = 0;
64 uint32_t mear2 = 0, emear2 = 0, msar2 = 0, emsar2 = 0;
65 uint8_t mber = 0;
66
67 i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
68
69 if (i2c_reg_read (0x50, 2) != 0x04) return 0;
70 m = i2c_reg_read (0x50, 5);
71 row = i2c_reg_read (0x50, 3);
72 col = i2c_reg_read (0x50, 4);
73 bank = i2c_reg_read (0x50, 17);
74
75 CONFIG_READ_WORD(MCCR1, mccr1);
76 mccr1 &= 0xffff0000;
77
78 start = CONFIG_SYS_SDRAM_BASE;
79 end = start + (1 << (col + row + 3) ) * bank - 1;
80
81 for (i = 0; i < m; i++) {
82 mccr1 |= ((row == 13)? 2 : (bank == 4)? 0 : 3) << i * 2;
83 if (i < 4) {
84 msar1 |= ((start >> 20) & 0xff) << i * 8;
85 emsar1 |= ((start >> 28) & 0xff) << i * 8;
86 mear1 |= ((end >> 20) & 0xff) << i * 8;
87 emear1 |= ((end >> 28) & 0xff) << i * 8;
88 } else {
89 msar2 |= ((start >> 20) & 0xff) << (i-4) * 8;
90 emsar2 |= ((start >> 28) & 0xff) << (i-4) * 8;
91 mear2 |= ((end >> 20) & 0xff) << (i-4) * 8;
92 emear2 |= ((end >> 28) & 0xff) << (i-4) * 8;
93 }
94 mber |= 1 << i;
95 start += (1 << (col + row + 3) ) * bank;
96 end += (1 << (col + row + 3) ) * bank;
97 }
98 for (; i < 8; i++) {
99 if (i < 4) {
100 msar1 |= 0xff << i * 8;
101 emsar1 |= 0x30 << i * 8;
102 mear1 |= 0xff << i * 8;
103 emear1 |= 0x30 << i * 8;
104 } else {
105 msar2 |= 0xff << (i-4) * 8;
106 emsar2 |= 0x30 << (i-4) * 8;
107 mear2 |= 0xff << (i-4) * 8;
108 emear2 |= 0x30 << (i-4) * 8;
109 }
110 }
111
112 CONFIG_WRITE_WORD(MCCR1, mccr1);
113 CONFIG_WRITE_WORD(MSAR1, msar1);
114 CONFIG_WRITE_WORD(EMSAR1, emsar1);
115 CONFIG_WRITE_WORD(MEAR1, mear1);
116 CONFIG_WRITE_WORD(EMEAR1, emear1);
117 CONFIG_WRITE_WORD(MSAR2, msar2);
118 CONFIG_WRITE_WORD(EMSAR2, emsar2);
119 CONFIG_WRITE_WORD(MEAR2, mear2);
120 CONFIG_WRITE_WORD(EMEAR2, emear2);
121 CONFIG_WRITE_BYTE(MBER, mber);
122
123 return (1 << (col + row + 3) ) * bank * m;
124}
125
126
127
128
129#ifndef CONFIG_PCI_PNP
130static struct pci_config_table pci_debris_config_table[] = {
131 { PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, 0x0f, PCI_ANY_ID,
132 pci_cfgfunc_config_device, { PCI_ENET0_IOADDR,
133 PCI_ENET0_MEMADDR,
134 PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER }},
135 { PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, 0x10, PCI_ANY_ID,
136 pci_cfgfunc_config_device, { PCI_ENET1_IOADDR,
137 PCI_ENET1_MEMADDR,
138 PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER }},
139 { }
140};
141#endif
142
143struct pci_controller hose = {
144#ifndef CONFIG_PCI_PNP
145 config_table: pci_debris_config_table,
146#endif
147};
148
149void pci_init_board(void)
150{
151 pci_mpc824x_init(&hose);
152}
153
154void *nvram_read(void *dest, const long src, size_t count)
155{
156 volatile uchar *d = (volatile uchar*) dest;
157 volatile uchar *s = (volatile uchar*) src;
158 while(count--) {
159 *d++ = *s++;
160 asm volatile("sync");
161 }
162 return dest;
163}
164
165void nvram_write(long dest, const void *src, size_t count)
166{
167 volatile uchar *d = (volatile uchar*)dest;
168 volatile uchar *s = (volatile uchar*)src;
169 while(count--) {
170 *d++ = *s++;
171 asm volatile("sync");
172 }
173}
174
175int misc_init_r(void)
176{
177 uchar ethaddr[6];
178
179 if (eth_getenv_enetaddr("ethaddr", ethaddr))
180
181 nvram_write(CONFIG_ENV_ADDR + CONFIG_SYS_NVRAM_VXWORKS_OFFS,
182 ethaddr, 6);
183
184 return 0;
185}
186
187int board_eth_init(bd_t *bis)
188{
189 return pci_eth_init(bis);
190}
191