diff options
Diffstat (limited to 'arch/powerpc/platforms/44x/currituck.c')
| -rw-r--r-- | arch/powerpc/platforms/44x/currituck.c | 204 |
1 files changed, 204 insertions, 0 deletions
diff --git a/arch/powerpc/platforms/44x/currituck.c b/arch/powerpc/platforms/44x/currituck.c new file mode 100644 index 000000000000..3f6229b5dee0 --- /dev/null +++ b/arch/powerpc/platforms/44x/currituck.c | |||
| @@ -0,0 +1,204 @@ | |||
| 1 | /* | ||
| 2 | * Currituck board specific routines | ||
| 3 | * | ||
| 4 | * Copyright © 2011 Tony Breeds IBM Corporation | ||
| 5 | * | ||
| 6 | * Based on earlier code: | ||
| 7 | * Matt Porter <mporter@kernel.crashing.org> | ||
| 8 | * Copyright 2002-2005 MontaVista Software Inc. | ||
| 9 | * | ||
| 10 | * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net> | ||
| 11 | * Copyright (c) 2003-2005 Zultys Technologies | ||
| 12 | * | ||
| 13 | * Rewritten and ported to the merged powerpc tree: | ||
| 14 | * Copyright 2007 David Gibson <dwg@au1.ibm.com>, IBM Corporation. | ||
| 15 | * Copyright © 2011 David Kliekamp IBM Corporation | ||
| 16 | * | ||
| 17 | * This program is free software; you can redistribute it and/or modify it | ||
| 18 | * under the terms of the GNU General Public License as published by the | ||
| 19 | * Free Software Foundation; either version 2 of the License, or (at your | ||
| 20 | * option) any later version. | ||
| 21 | */ | ||
| 22 | |||
| 23 | #include <linux/init.h> | ||
| 24 | #include <linux/memblock.h> | ||
| 25 | #include <linux/of.h> | ||
| 26 | #include <linux/of_platform.h> | ||
| 27 | #include <linux/rtc.h> | ||
| 28 | |||
| 29 | #include <asm/machdep.h> | ||
| 30 | #include <asm/prom.h> | ||
| 31 | #include <asm/udbg.h> | ||
| 32 | #include <asm/time.h> | ||
| 33 | #include <asm/uic.h> | ||
| 34 | #include <asm/ppc4xx.h> | ||
| 35 | #include <asm/mpic.h> | ||
| 36 | #include <asm/mmu.h> | ||
| 37 | |||
| 38 | #include <linux/pci.h> | ||
| 39 | |||
| 40 | static __initdata struct of_device_id ppc47x_of_bus[] = { | ||
| 41 | { .compatible = "ibm,plb4", }, | ||
| 42 | { .compatible = "ibm,plb6", }, | ||
| 43 | { .compatible = "ibm,opb", }, | ||
| 44 | { .compatible = "ibm,ebc", }, | ||
| 45 | {}, | ||
| 46 | }; | ||
| 47 | |||
| 48 | /* The EEPROM is missing and the default values are bogus. This forces USB in | ||
| 49 | * to EHCI mode */ | ||
| 50 | static void __devinit quirk_ppc_currituck_usb_fixup(struct pci_dev *dev) | ||
| 51 | { | ||
| 52 | if (of_machine_is_compatible("ibm,currituck")) { | ||
| 53 | pci_write_config_dword(dev, 0xe0, 0x0114231f); | ||
| 54 | pci_write_config_dword(dev, 0xe4, 0x00006c40); | ||
| 55 | } | ||
| 56 | } | ||
| 57 | DECLARE_PCI_FIXUP_HEADER(0x1033, 0x0035, quirk_ppc_currituck_usb_fixup); | ||
| 58 | |||
| 59 | static int __init ppc47x_device_probe(void) | ||
| 60 | { | ||
| 61 | of_platform_bus_probe(NULL, ppc47x_of_bus, NULL); | ||
| 62 | |||
| 63 | return 0; | ||
| 64 | } | ||
| 65 | machine_device_initcall(ppc47x, ppc47x_device_probe); | ||
| 66 | |||
| 67 | /* We can have either UICs or MPICs */ | ||
| 68 | static void __init ppc47x_init_irq(void) | ||
| 69 | { | ||
| 70 | struct device_node *np; | ||
| 71 | |||
| 72 | /* Find top level interrupt controller */ | ||
| 73 | for_each_node_with_property(np, "interrupt-controller") { | ||
| 74 | if (of_get_property(np, "interrupts", NULL) == NULL) | ||
| 75 | break; | ||
| 76 | } | ||
| 77 | if (np == NULL) | ||
| 78 | panic("Can't find top level interrupt controller"); | ||
| 79 | |||
| 80 | /* Check type and do appropriate initialization */ | ||
| 81 | if (of_device_is_compatible(np, "chrp,open-pic")) { | ||
| 82 | /* The MPIC driver will get everything it needs from the | ||
| 83 | * device-tree, just pass 0 to all arguments | ||
| 84 | */ | ||
| 85 | struct mpic *mpic = | ||
| 86 | mpic_alloc(np, 0, 0, 0, 0, " MPIC "); | ||
| 87 | BUG_ON(mpic == NULL); | ||
| 88 | mpic_init(mpic); | ||
| 89 | ppc_md.get_irq = mpic_get_irq; | ||
| 90 | } else | ||
| 91 | panic("Unrecognized top level interrupt controller"); | ||
| 92 | } | ||
| 93 | |||
| 94 | #ifdef CONFIG_SMP | ||
| 95 | static void __cpuinit smp_ppc47x_setup_cpu(int cpu) | ||
| 96 | { | ||
| 97 | mpic_setup_this_cpu(); | ||
| 98 | } | ||
| 99 | |||
| 100 | static int __cpuinit smp_ppc47x_kick_cpu(int cpu) | ||
| 101 | { | ||
| 102 | struct device_node *cpunode = of_get_cpu_node(cpu, NULL); | ||
| 103 | const u64 *spin_table_addr_prop; | ||
| 104 | u32 *spin_table; | ||
| 105 | extern void start_secondary_47x(void); | ||
| 106 | |||
| 107 | BUG_ON(cpunode == NULL); | ||
| 108 | |||
| 109 | /* Assume spin table. We could test for the enable-method in | ||
| 110 | * the device-tree but currently there's little point as it's | ||
| 111 | * our only supported method | ||
| 112 | */ | ||
| 113 | spin_table_addr_prop = | ||
| 114 | of_get_property(cpunode, "cpu-release-addr", NULL); | ||
| 115 | |||
| 116 | if (spin_table_addr_prop == NULL) { | ||
| 117 | pr_err("CPU%d: Can't start, missing cpu-release-addr !\n", | ||
| 118 | cpu); | ||
| 119 | return 1; | ||
| 120 | } | ||
| 121 | |||
| 122 | /* Assume it's mapped as part of the linear mapping. This is a bit | ||
| 123 | * fishy but will work fine for now | ||
| 124 | * | ||
| 125 | * XXX: Is there any reason to assume differently? | ||
| 126 | */ | ||
| 127 | spin_table = (u32 *)__va(*spin_table_addr_prop); | ||
| 128 | pr_debug("CPU%d: Spin table mapped at %p\n", cpu, spin_table); | ||
| 129 | |||
| 130 | spin_table[3] = cpu; | ||
| 131 | smp_wmb(); | ||
| 132 | spin_table[1] = __pa(start_secondary_47x); | ||
| 133 | mb(); | ||
| 134 | |||
| 135 | return 0; | ||
| 136 | } | ||
| 137 | |||
| 138 | static struct smp_ops_t ppc47x_smp_ops = { | ||
| 139 | .probe = smp_mpic_probe, | ||
| 140 | .message_pass = smp_mpic_message_pass, | ||
| 141 | .setup_cpu = smp_ppc47x_setup_cpu, | ||
| 142 | .kick_cpu = smp_ppc47x_kick_cpu, | ||
| 143 | .give_timebase = smp_generic_give_timebase, | ||
| 144 | .take_timebase = smp_generic_take_timebase, | ||
| 145 | }; | ||
| 146 | |||
| 147 | static void __init ppc47x_smp_init(void) | ||
| 148 | { | ||
| 149 | if (mmu_has_feature(MMU_FTR_TYPE_47x)) | ||
| 150 | smp_ops = &ppc47x_smp_ops; | ||
| 151 | } | ||
| 152 | |||
| 153 | #else /* CONFIG_SMP */ | ||
| 154 | static void __init ppc47x_smp_init(void) { } | ||
| 155 | #endif /* CONFIG_SMP */ | ||
| 156 | |||
| 157 | static void __init ppc47x_setup_arch(void) | ||
| 158 | { | ||
| 159 | |||
| 160 | /* No need to check the DMA config as we /know/ our windows are all of | ||
| 161 | * RAM. Lets hope that doesn't change */ | ||
| 162 | #ifdef CONFIG_SWIOTLB | ||
| 163 | if (memblock_end_of_DRAM() > 0xffffffff) { | ||
| 164 | ppc_swiotlb_enable = 1; | ||
| 165 | set_pci_dma_ops(&swiotlb_dma_ops); | ||
| 166 | ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb; | ||
| 167 | } | ||
| 168 | #endif | ||
| 169 | ppc47x_smp_init(); | ||
| 170 | } | ||
| 171 | |||
| 172 | /* | ||
| 173 | * Called very early, MMU is off, device-tree isn't unflattened | ||
| 174 | */ | ||
| 175 | static int __init ppc47x_probe(void) | ||
| 176 | { | ||
| 177 | unsigned long root = of_get_flat_dt_root(); | ||
| 178 | |||
| 179 | if (!of_flat_dt_is_compatible(root, "ibm,currituck")) | ||
| 180 | return 0; | ||
| 181 | |||
| 182 | return 1; | ||
| 183 | } | ||
| 184 | |||
| 185 | /* Use USB controller should have been hardware swizzled but it wasn't :( */ | ||
| 186 | static void ppc47x_pci_irq_fixup(struct pci_dev *dev) | ||
| 187 | { | ||
| 188 | if (dev->vendor == 0x1033 && (dev->device == 0x0035 || | ||
| 189 | dev->device == 0x00e0)) { | ||
| 190 | dev->irq = irq_create_mapping(NULL, 47); | ||
| 191 | pr_info("%s: Mapping irq 47 %d\n", __func__, dev->irq); | ||
| 192 | } | ||
| 193 | } | ||
| 194 | |||
| 195 | define_machine(ppc47x) { | ||
| 196 | .name = "PowerPC 47x", | ||
| 197 | .probe = ppc47x_probe, | ||
| 198 | .progress = udbg_progress, | ||
| 199 | .init_IRQ = ppc47x_init_irq, | ||
| 200 | .setup_arch = ppc47x_setup_arch, | ||
| 201 | .pci_irq_fixup = ppc47x_pci_irq_fixup, | ||
| 202 | .restart = ppc4xx_reset_system, | ||
| 203 | .calibrate_decr = generic_calibrate_decr, | ||
| 204 | }; | ||
