2 * GNU General Public License for more details.
4 * MATRIX Vision GmbH / June 2002-Nov 2003
18 DECLARE_GLOBAL_DATA_PTR
;
20 u32
get_BoardType (void);
22 #define PCI_CONFIG(b,d,f,r) cpu_to_le32(0x80000000 | ((b&0xff)<<16) \
27 int mv_pci_read (int bus
, int dev
, int func
, int reg
)
29 *(u32
*) (0xfec00cf8) = PCI_CONFIG (bus
, dev
, func
, reg
);
31 return cpu_to_le32 (*(u32
*) (0xfee00cfc));
36 return (mv_pci_read (0, 0xe, 0, 0) == 0x06801095 ? 0 : 1);
39 void init_2nd_DUART (void)
41 NS16550_t console
= (NS16550_t
) CONFIG_SYS_NS16550_COM2
;
42 int clock_divisor
= CONFIG_SYS_NS16550_CLK
/ 16 / CONFIG_BAUDRATE
;
44 *(u8
*) (0xfc004511) = 0x1;
45 NS16550_init (console
, clock_divisor
);
47 void hw_watchdog_reset (void)
49 if (get_BoardType () == 0) {
50 *(u32
*) (0xff000005) = 0;
56 ulong busfreq
= get_bus_freq (0);
58 u32 BoardType
= get_BoardType ();
59 char *BoardName
[2] = { "mvBlueBOX", "mvBlueLYNX" };
65 printf ("U-Boot (%s) running on mvBLUE device.\n", MV_VERSION
);
66 printf (" Found %s running at %s MHz memory clock.\n",
67 BoardName
[BoardType
], strmhz (buf
, busfreq
));
71 if ((p
= getenv ("console_nr")) != NULL
) {
72 unsigned long con_nr
= simple_strtoul (p
, NULL
, 10) & 3;
74 bd
->bi_baudrate
&= ~3;
75 bd
->bi_baudrate
|= con_nr
& 3;
80 phys_size_t
initdram (int board_type
)
87 size
= get_ram_size(CONFIG_SYS_SDRAM_BASE
, CONFIG_SYS_MAX_RAM_SIZE
);
89 new_bank0_end
= size
- 1;
90 mear1
= mpc824x_mpc107_getreg(MEAR1
);
91 emear1
= mpc824x_mpc107_getreg(EMEAR1
);
92 mear1
= (mear1
& 0xFFFFFF00) |
93 ((new_bank0_end
& MICR_ADDR_MASK
) >> MICR_ADDR_SHIFT
);
94 emear1
= (emear1
& 0xFFFFFF00) |
95 ((new_bank0_end
& MICR_ADDR_MASK
) >> MICR_EADDR_SHIFT
);
96 mpc824x_mpc107_setreg(MEAR1
, mear1
);
97 mpc824x_mpc107_setreg(EMEAR1
, emear1
);
102 /* ------------------------------------------------------------------------- */
103 u8
*dhcp_vendorex_prep (u8
* e
)
107 /* DHCP vendor-class-identifier = 60 */
108 if ((ptr
= getenv ("dhcp_vendor-class-identifier"))) {
114 /* my DHCP_CLIENT_IDENTIFIER = 61 */
115 if ((ptr
= getenv ("dhcp_client_id"))) {
124 u8
*dhcp_vendorex_proc (u8
* popt
)
129 /* ------------------------------------------------------------------------- */
132 * Initialize PCI Devices
135 void pci_mvblue_clear_base (struct pci_controller
*hose
, pci_dev_t dev
)
139 printf ("clear base @ dev/func 0x%02x/0x%02x ... ", PCI_DEV (dev
),
141 for (cnt
= 0; cnt
< 6; cnt
++)
142 pci_hose_write_config_dword (hose
, dev
, 0x10 + (4 * cnt
),
147 void duart_setup (u32 base
, u16 divisor
)
149 printf ("duart setup ...");
150 out_8 ((u8
*) (CONFIG_SYS_ISA_IO
+ base
+ 3), 0x80);
151 out_8 ((u8
*) (CONFIG_SYS_ISA_IO
+ base
+ 0), divisor
& 0xff);
152 out_8 ((u8
*) (CONFIG_SYS_ISA_IO
+ base
+ 1), divisor
>> 8);
153 out_8 ((u8
*) (CONFIG_SYS_ISA_IO
+ base
+ 3), 0x03);
154 out_8 ((u8
*) (CONFIG_SYS_ISA_IO
+ base
+ 4), 0x03);
155 out_8 ((u8
*) (CONFIG_SYS_ISA_IO
+ base
+ 2), 0x07);
159 void pci_mvblue_fixup_irq_behind_bridge (struct pci_controller
*hose
,
160 pci_dev_t bridge
, unsigned char irq
)
164 unsigned short vendor
, class;
166 pci_hose_read_config_byte (hose
, bridge
, PCI_SECONDARY_BUS
, &bus
);
167 for (d
= PCI_BDF (bus
, 0, 0);
168 d
< PCI_BDF (bus
, PCI_MAX_PCI_DEVICES
- 1,
169 PCI_MAX_PCI_FUNCTIONS
- 1);
170 d
+= PCI_BDF (0, 0, 1)) {
171 pci_hose_read_config_word (hose
, d
, PCI_VENDOR_ID
, &vendor
);
172 if (vendor
!= 0xffff && vendor
!= 0x0000) {
173 pci_hose_read_config_word (hose
, d
, PCI_CLASS_DEVICE
,
175 if (class == PCI_CLASS_BRIDGE_PCI
)
176 pci_mvblue_fixup_irq_behind_bridge (hose
, d
,
179 pci_hose_write_config_byte (hose
, d
,
186 #define MV_MAX_PCI_BUSSES 3
189 void pci_mvblue_fixup_irq (struct pci_controller
*hose
, pci_dev_t dev
)
191 unsigned char line
= 0xff;
192 unsigned short class;
194 if (PCI_BUS (dev
) == 0) {
195 switch (PCI_DEV (dev
)) {
197 if (get_BoardType () == 0) {
206 pci_hose_write_config_byte (hose
, dev
, 0x8a, 0x20);
209 /* mvBB: Slot0 (Grabber) */
210 pci_hose_read_config_word (hose
, dev
,
211 PCI_CLASS_DEVICE
, &class);
212 if (class == PCI_CLASS_BRIDGE_PCI
) {
213 pci_mvblue_fixup_irq_behind_bridge (hose
, dev
,
221 pci_hose_read_config_word (hose
, dev
,
222 PCI_CLASS_DEVICE
, &class);
223 if (class == PCI_CLASS_BRIDGE_PCI
) {
224 pci_mvblue_fixup_irq_behind_bridge (hose
, dev
,
231 printf ("***pci_scan: illegal dev = 0x%08x\n",
236 pci_hose_write_config_byte (hose
, dev
, PCI_INTERRUPT_LINE
,
241 struct pci_controller hose
= {
242 fixup_irq
:pci_mvblue_fixup_irq
245 void pci_init_board (void)
247 pci_mpc824x_init (&hose
);
250 int board_eth_init(bd_t
*bis
)
252 return pci_eth_init(bis
);