2 * MPC85xx setup and early boot code plus other random bits.
4 * Maintained by Kumar Gala (see MAINTAINERS for contact information)
6 * Copyright 2005 Freescale Semiconductor Inc.
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
14 #include <linux/config.h>
15 #include <linux/stddef.h>
16 #include <linux/kernel.h>
17 #include <linux/init.h>
18 #include <linux/errno.h>
19 #include <linux/reboot.h>
20 #include <linux/pci.h>
21 #include <linux/kdev_t.h>
22 #include <linux/major.h>
23 #include <linux/console.h>
24 #include <linux/delay.h>
25 #include <linux/seq_file.h>
26 #include <linux/root_dev.h>
27 #include <linux/initrd.h>
28 #include <linux/module.h>
29 #include <linux/fsl_devices.h>
31 #include <asm/system.h>
32 #include <asm/pgtable.h>
34 #include <asm/atomic.h>
37 #include <asm/machdep.h>
39 #include <asm/bootinfo.h>
40 #include <asm/pci-bridge.h>
41 #include <asm/mpc85xx.h>
43 #include <mm/mmu_decl.h>
47 #include <asm/i8259.h>
49 #include <sysdev/fsl_soc.h>
53 unsigned long isa_io_base
= 0;
54 unsigned long isa_mem_base
= 0;
57 static int cds_pci_slot
= 2;
58 static volatile u8
*cadmus
;
61 * Internal interrupts are all Level Sensitive, and Positive Polarity
63 * Note: Likely, this table and the following function should be
64 * obtained and derived from the OF Device Tree.
66 static u_char mpc85xx_cds_openpic_initsenses
[] __initdata
= {
67 MPC85XX_INTERNAL_IRQ_SENSES
,
68 #if defined(CONFIG_PCI)
69 (IRQ_SENSE_LEVEL
| IRQ_POLARITY_POSITIVE
), /* Ext 0: PCI slot 0 */
70 (IRQ_SENSE_LEVEL
| IRQ_POLARITY_NEGATIVE
), /* Ext 1: PCI slot 1 */
71 (IRQ_SENSE_LEVEL
| IRQ_POLARITY_NEGATIVE
), /* Ext 2: PCI slot 2 */
72 (IRQ_SENSE_LEVEL
| IRQ_POLARITY_NEGATIVE
), /* Ext 3: PCI slot 3 */
74 0x0, /* External 0: */
75 0x0, /* External 1: */
76 0x0, /* External 2: */
77 0x0, /* External 3: */
79 (IRQ_SENSE_LEVEL
| IRQ_POLARITY_NEGATIVE
), /* External 5: PHY */
80 0x0, /* External 6: */
81 0x0, /* External 7: */
82 0x0, /* External 8: */
83 0x0, /* External 9: */
84 0x0, /* External 10: */
86 (IRQ_SENSE_LEVEL
| IRQ_POLARITY_NEGATIVE
), /* Ext 11: PCI2 slot 0 */
88 0x0, /* External 11: */
98 mpc85xx_map_irq(struct pci_dev
*dev
, unsigned char idsel
, unsigned char pin
)
100 struct pci_controller
*hose
= pci_bus_to_hose(dev
->bus
->number
);
104 /* Handle PCI1 interrupts */
105 char pci_irq_table
[][4] =
107 * PCI IDSEL/INTPIN->INTLINE
111 /* Note IRQ assignment for slots is based on which slot the elysium is
112 * in -- in this setup elysium is in slot #2 (this PIRQA as first
113 * interrupt on slot */
115 { 0, 1, 2, 3 }, /* 16 - PMC */
116 { 0, 1, 2, 3 }, /* 17 P2P (Tsi320) */
117 { 0, 1, 2, 3 }, /* 18 - Slot 1 */
118 { 1, 2, 3, 0 }, /* 19 - Slot 2 */
119 { 2, 3, 0, 1 }, /* 20 - Slot 3 */
120 { 3, 0, 1, 2 }, /* 21 - Slot 4 */
123 const long min_idsel
= 16, max_idsel
= 21, irqs_per_slot
= 4;
126 for (i
= 0; i
< 6; i
++)
127 for (j
= 0; j
< 4; j
++)
128 pci_irq_table
[i
][j
] =
129 ((pci_irq_table
[i
][j
] + 5 -
130 cds_pci_slot
) & 0x3) + PIRQ0A
;
132 return PCI_IRQ_TABLE_LOOKUP
;
134 /* Handle PCI2 interrupts (if we have one) */
135 char pci_irq_table
[][4] =
138 * We only have one slot and one interrupt
139 * going to PIRQA - PIRQD */
140 { PIRQ1A
, PIRQ1A
, PIRQ1A
, PIRQ1A
}, /* 21 - slot 0 */
143 const long min_idsel
= 21, max_idsel
= 21, irqs_per_slot
= 4;
145 return PCI_IRQ_TABLE_LOOKUP
;
149 #define ARCADIA_HOST_BRIDGE_IDSEL 17
150 #define ARCADIA_2ND_BRIDGE_IDSEL 3
152 extern int mpc85xx_pci2_busno
;
155 mpc85xx_exclude_device(u_char bus
, u_char devfn
)
157 if (bus
== 0 && PCI_SLOT(devfn
) == 0)
158 return PCIBIOS_DEVICE_NOT_FOUND
;
159 if (mpc85xx_pci2_busno
)
160 if (bus
== (mpc85xx_pci2_busno
) && PCI_SLOT(devfn
) == 0)
161 return PCIBIOS_DEVICE_NOT_FOUND
;
162 /* We explicitly do not go past the Tundra 320 Bridge */
163 if ((bus
== 1) && (PCI_SLOT(devfn
) == ARCADIA_2ND_BRIDGE_IDSEL
))
164 return PCIBIOS_DEVICE_NOT_FOUND
;
165 if ((bus
== 0) && (PCI_SLOT(devfn
) == ARCADIA_2ND_BRIDGE_IDSEL
))
166 return PCIBIOS_DEVICE_NOT_FOUND
;
168 return PCIBIOS_SUCCESSFUL
;
172 mpc85xx_cds_pcibios_fixup(void)
177 if ((dev
= pci_get_device(PCI_VENDOR_ID_VIA
,
178 PCI_DEVICE_ID_VIA_82C586_1
, NULL
))) {
180 * U-Boot does not set the enable bits
181 * for the IDE device. Force them on here.
183 pci_read_config_byte(dev
, 0x40, &c
);
184 c
|= 0x03; /* IDE: Chip Enable Bits */
185 pci_write_config_byte(dev
, 0x40, c
);
188 * Since only primary interface works, force the
189 * IDE function to standard primary IDE interrupt
193 pci_write_config_byte(dev
, PCI_INTERRUPT_LINE
, dev
->irq
);
198 * Force legacy USB interrupt routing
200 if ((dev
= pci_get_device(PCI_VENDOR_ID_VIA
,
201 PCI_DEVICE_ID_VIA_82C586_2
, NULL
))) {
203 pci_write_config_byte(dev
, PCI_INTERRUPT_LINE
, 10);
207 if ((dev
= pci_get_device(PCI_VENDOR_ID_VIA
,
208 PCI_DEVICE_ID_VIA_82C586_2
, dev
))) {
210 pci_write_config_byte(dev
, PCI_INTERRUPT_LINE
, 11);
214 #endif /* CONFIG_PCI */
216 void __init
mpc85xx_cds_pic_init(void)
219 phys_addr_t OpenPIC_PAddr
;
221 /* Determine the Physical Address of the OpenPIC regs */
222 OpenPIC_PAddr
= get_immrbase() + MPC85xx_OPENPIC_OFFSET
;
224 mpic1
= mpic_alloc(OpenPIC_PAddr
,
225 MPIC_PRIMARY
| MPIC_WANTS_RESET
| MPIC_BIG_ENDIAN
,
226 4, MPC85xx_OPENPIC_IRQ_OFFSET
, 0, 250,
227 mpc85xx_cds_openpic_initsenses
,
228 sizeof(mpc85xx_cds_openpic_initsenses
), " OpenPIC ");
229 BUG_ON(mpic1
== NULL
);
230 mpic_assign_isu(mpic1
, 0, OpenPIC_PAddr
+ 0x10200);
231 mpic_assign_isu(mpic1
, 1, OpenPIC_PAddr
+ 0x10280);
232 mpic_assign_isu(mpic1
, 2, OpenPIC_PAddr
+ 0x10300);
233 mpic_assign_isu(mpic1
, 3, OpenPIC_PAddr
+ 0x10380);
234 mpic_assign_isu(mpic1
, 4, OpenPIC_PAddr
+ 0x10400);
235 mpic_assign_isu(mpic1
, 5, OpenPIC_PAddr
+ 0x10480);
236 mpic_assign_isu(mpic1
, 6, OpenPIC_PAddr
+ 0x10500);
237 mpic_assign_isu(mpic1
, 7, OpenPIC_PAddr
+ 0x10580);
239 /* dummy mappings to get to 48 */
240 mpic_assign_isu(mpic1
, 8, OpenPIC_PAddr
+ 0x10600);
241 mpic_assign_isu(mpic1
, 9, OpenPIC_PAddr
+ 0x10680);
242 mpic_assign_isu(mpic1
, 10, OpenPIC_PAddr
+ 0x10700);
243 mpic_assign_isu(mpic1
, 11, OpenPIC_PAddr
+ 0x10780);
246 mpic_assign_isu(mpic1
, 12, OpenPIC_PAddr
+ 0x10000);
247 mpic_assign_isu(mpic1
, 13, OpenPIC_PAddr
+ 0x10080);
248 mpic_assign_isu(mpic1
, 14, OpenPIC_PAddr
+ 0x10100);
253 mpic_setup_cascade(PIRQ0A
, i8259_irq_cascade
, NULL
);
261 * Setup the architecture
264 mpc85xx_cds_setup_arch(void)
266 struct device_node
*cpu
;
268 struct device_node
*np
;
272 ppc_md
.progress("mpc85xx_cds_setup_arch()", 0);
274 cpu
= of_find_node_by_type(NULL
, "cpu");
278 fp
= (int *)get_property(cpu
, "clock-frequency", NULL
);
280 loops_per_jiffy
= *fp
/ HZ
;
282 loops_per_jiffy
= 500000000 / HZ
;
286 cadmus
= ioremap(CADMUS_BASE
, CADMUS_SIZE
);
287 cds_pci_slot
= ((cadmus
[CM_CSR
] >> 6) & 0x3) + 1;
289 if (ppc_md
.progress
) {
291 snprintf(buf
, 40, "CDS Version = 0x%x in slot %d\n",
292 cadmus
[CM_VER
], cds_pci_slot
);
293 ppc_md
.progress(buf
, 0);
297 for (np
= NULL
; (np
= of_find_node_by_type(np
, "pci")) != NULL
;)
300 ppc_md
.pcibios_fixup
= mpc85xx_cds_pcibios_fixup
;
301 ppc_md
.pci_swizzle
= common_swizzle
;
302 ppc_md
.pci_map_irq
= mpc85xx_map_irq
;
303 ppc_md
.pci_exclude_device
= mpc85xx_exclude_device
;
306 #ifdef CONFIG_ROOT_NFS
309 ROOT_DEV
= Root_HDA1
;
315 mpc85xx_cds_show_cpuinfo(struct seq_file
*m
)
317 uint pvid
, svid
, phid1
;
318 uint memsize
= total_memory
;
320 pvid
= mfspr(SPRN_PVR
);
321 svid
= mfspr(SPRN_SVR
);
323 seq_printf(m
, "Vendor\t\t: Freescale Semiconductor\n");
324 seq_printf(m
, "Machine\t\t: MPC85xx CDS (0x%x)\n", cadmus
[CM_VER
]);
325 seq_printf(m
, "PVR\t\t: 0x%x\n", pvid
);
326 seq_printf(m
, "SVR\t\t: 0x%x\n", svid
);
328 /* Display cpu Pll setting */
329 phid1
= mfspr(SPRN_HID1
);
330 seq_printf(m
, "PLL setting\t: 0x%x\n", ((phid1
>> 24) & 0x3f));
332 /* Display the amount of memory */
333 seq_printf(m
, "Memory\t\t: %d MB\n", memsize
/ (1024 * 1024));
338 * Called very early, device-tree isn't unflattened
340 static int __init
mpc85xx_cds_probe(void)
342 /* We always match for now, eventually we should look at
343 * the flat dev tree to ensure this is the board we are
349 define_machine(mpc85xx_cds
) {
350 .name
= "MPC85xx CDS",
351 .probe
= mpc85xx_cds_probe
,
352 .setup_arch
= mpc85xx_cds_setup_arch
,
353 .init_IRQ
= mpc85xx_cds_pic_init
,
354 .show_cpuinfo
= mpc85xx_cds_show_cpuinfo
,
355 .get_irq
= mpic_get_irq
,
356 .restart
= mpc85xx_restart
,
357 .calibrate_decr
= generic_calibrate_decr
,
358 .progress
= udbg_progress
,