Committer: Michael Beasley <mike@snafu.setup>
[mikesnafu-overlay.git] / arch / powerpc / platforms / 86xx / mpc8610_hpcd.c
blob0b07485641feb16bedab26e59e392d2bef111d27
1 /*
2 * MPC8610 HPCD board specific routines
4 * Initial author: Xianghua Xiao <x.xiao@freescale.com>
5 * Recode: Jason Jin <jason.jin@freescale.com>
7 * Rewrite the interrupt routing. remove the 8259PIC support,
8 * All the integrated device in ULI use sideband interrupt.
10 * Copyright 2007 Freescale Semiconductor Inc.
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version.
18 #include <linux/stddef.h>
19 #include <linux/kernel.h>
20 #include <linux/pci.h>
21 #include <linux/kdev_t.h>
22 #include <linux/delay.h>
23 #include <linux/seq_file.h>
24 #include <linux/of.h>
26 #include <asm/system.h>
27 #include <asm/time.h>
28 #include <asm/machdep.h>
29 #include <asm/pci-bridge.h>
30 #include <asm/mpc86xx.h>
31 #include <asm/prom.h>
32 #include <mm/mmu_decl.h>
33 #include <asm/udbg.h>
35 #include <asm/mpic.h>
37 #include <linux/of_platform.h>
38 #include <sysdev/fsl_pci.h>
39 #include <sysdev/fsl_soc.h>
41 static struct of_device_id __initdata mpc8610_ids[] = {
42 { .compatible = "fsl,mpc8610-immr", },
46 static int __init mpc8610_declare_of_platform_devices(void)
48 /* Without this call, the SSI device driver won't get probed. */
49 of_platform_bus_probe(NULL, mpc8610_ids, NULL);
51 return 0;
53 machine_device_initcall(mpc86xx_hpcd, mpc8610_declare_of_platform_devices);
55 void __init
56 mpc86xx_hpcd_init_irq(void)
58 struct mpic *mpic1;
59 struct device_node *np;
60 struct resource res;
62 /* Determine PIC address. */
63 np = of_find_node_by_type(NULL, "open-pic");
64 if (np == NULL)
65 return;
66 of_address_to_resource(np, 0, &res);
68 /* Alloc mpic structure and per isu has 16 INT entries. */
69 mpic1 = mpic_alloc(np, res.start,
70 MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
71 0, 256, " MPIC ");
72 BUG_ON(mpic1 == NULL);
74 mpic_init(mpic1);
77 #ifdef CONFIG_PCI
78 static void __devinit quirk_uli1575(struct pci_dev *dev)
80 u32 temp32;
82 /* Disable INTx */
83 pci_read_config_dword(dev, 0x48, &temp32);
84 pci_write_config_dword(dev, 0x48, (temp32 | 1<<26));
86 /* Enable sideband interrupt */
87 pci_read_config_dword(dev, 0x90, &temp32);
88 pci_write_config_dword(dev, 0x90, (temp32 | 1<<22));
91 static void __devinit quirk_uli5288(struct pci_dev *dev)
93 unsigned char c;
94 unsigned short temp;
96 /* Interrupt Disable, Needed when SATA disabled */
97 pci_read_config_word(dev, PCI_COMMAND, &temp);
98 temp |= 1<<10;
99 pci_write_config_word(dev, PCI_COMMAND, temp);
101 pci_read_config_byte(dev, 0x83, &c);
102 c |= 0x80;
103 pci_write_config_byte(dev, 0x83, c);
105 pci_write_config_byte(dev, PCI_CLASS_PROG, 0x01);
106 pci_write_config_byte(dev, PCI_CLASS_DEVICE, 0x06);
108 pci_read_config_byte(dev, 0x83, &c);
109 c &= 0x7f;
110 pci_write_config_byte(dev, 0x83, c);
114 * Since 8259PIC was disabled on the board, the IDE device can not
115 * use the legacy IRQ, we need to let the IDE device work under
116 * native mode and use the interrupt line like other PCI devices.
117 * IRQ14 is a sideband interrupt from IDE device to CPU and we use this
118 * as the interrupt for IDE device.
120 static void __devinit quirk_uli5229(struct pci_dev *dev)
122 unsigned char c;
124 pci_read_config_byte(dev, 0x4b, &c);
125 c |= 0x10;
126 pci_write_config_byte(dev, 0x4b, c);
130 * SATA interrupt pin bug fix
131 * There's a chip bug for 5288, The interrupt pin should be 2,
132 * not the read only value 1, So it use INTB#, not INTA# which
133 * actually used by the IDE device 5229.
134 * As of this bug, during the PCI initialization, 5288 read the
135 * irq of IDE device from the device tree, this function fix this
136 * bug by re-assigning a correct irq to 5288.
139 static void __devinit final_uli5288(struct pci_dev *dev)
141 struct pci_controller *hose = pci_bus_to_host(dev->bus);
142 struct device_node *hosenode = hose ? hose->dn : NULL;
143 struct of_irq oirq;
144 int virq, pin = 2;
145 u32 laddr[3];
147 if (!hosenode)
148 return;
150 laddr[0] = (hose->first_busno << 16) | (PCI_DEVFN(31, 0) << 8);
151 laddr[1] = laddr[2] = 0;
152 of_irq_map_raw(hosenode, &pin, 1, laddr, &oirq);
153 virq = irq_create_of_mapping(oirq.controller, oirq.specifier,
154 oirq.size);
155 dev->irq = virq;
158 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AL, 0x1575, quirk_uli1575);
159 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AL, 0x5288, quirk_uli5288);
160 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AL, 0x5229, quirk_uli5229);
161 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AL, 0x5288, final_uli5288);
162 #endif /* CONFIG_PCI */
164 static void __init
165 mpc86xx_hpcd_setup_arch(void)
167 #ifdef CONFIG_PCI
168 struct device_node *np;
169 #endif
170 if (ppc_md.progress)
171 ppc_md.progress("mpc86xx_hpcd_setup_arch()", 0);
173 #ifdef CONFIG_PCI
174 for_each_node_by_type(np, "pci") {
175 if (of_device_is_compatible(np, "fsl,mpc8610-pci")
176 || of_device_is_compatible(np, "fsl,mpc8641-pcie")) {
177 struct resource rsrc;
178 of_address_to_resource(np, 0, &rsrc);
179 if ((rsrc.start & 0xfffff) == 0xa000)
180 fsl_add_bridge(np, 1);
181 else
182 fsl_add_bridge(np, 0);
185 #endif
187 printk("MPC86xx HPCD board from Freescale Semiconductor\n");
191 * Called very early, device-tree isn't unflattened
193 static int __init mpc86xx_hpcd_probe(void)
195 unsigned long root = of_get_flat_dt_root();
197 if (of_flat_dt_is_compatible(root, "fsl,MPC8610HPCD"))
198 return 1; /* Looks good */
200 return 0;
203 long __init
204 mpc86xx_time_init(void)
206 unsigned int temp;
208 /* Set the time base to zero */
209 mtspr(SPRN_TBWL, 0);
210 mtspr(SPRN_TBWU, 0);
212 temp = mfspr(SPRN_HID0);
213 temp |= HID0_TBEN;
214 mtspr(SPRN_HID0, temp);
215 asm volatile("isync");
217 return 0;
220 define_machine(mpc86xx_hpcd) {
221 .name = "MPC86xx HPCD",
222 .probe = mpc86xx_hpcd_probe,
223 .setup_arch = mpc86xx_hpcd_setup_arch,
224 .init_IRQ = mpc86xx_hpcd_init_irq,
225 .get_irq = mpic_get_irq,
226 .restart = fsl_rstcr_restart,
227 .time_init = mpc86xx_time_init,
228 .calibrate_decr = generic_calibrate_decr,
229 .progress = udbg_progress,
230 .pcibios_fixup_bus = fsl_pcibios_fixup_bus,