Version:  2.0.40 2.2.26 2.4.37 2.6.39 3.0 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9 3.10 3.11 3.12 3.13 3.14 3.15

Linux/arch/powerpc/platforms/44x/currituck.c

  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/of.h>
 25 #include <linux/of_platform.h>
 26 #include <linux/rtc.h>
 27 
 28 #include <asm/machdep.h>
 29 #include <asm/prom.h>
 30 #include <asm/udbg.h>
 31 #include <asm/time.h>
 32 #include <asm/uic.h>
 33 #include <asm/ppc4xx.h>
 34 #include <asm/mpic.h>
 35 #include <asm/mmu.h>
 36 
 37 #include <linux/pci.h>
 38 
 39 static __initdata struct of_device_id ppc47x_of_bus[] = {
 40         { .compatible = "ibm,plb4", },
 41         { .compatible = "ibm,plb6", },
 42         { .compatible = "ibm,opb", },
 43         { .compatible = "ibm,ebc", },
 44         {},
 45 };
 46 
 47 /* The EEPROM is missing and the default values are bogus.  This forces USB in
 48  * to EHCI mode */
 49 static void quirk_ppc_currituck_usb_fixup(struct pci_dev *dev)
 50 {
 51         if (of_machine_is_compatible("ibm,currituck")) {
 52                 pci_write_config_dword(dev, 0xe0, 0x0114231f);
 53                 pci_write_config_dword(dev, 0xe4, 0x00006c40);
 54         }
 55 }
 56 DECLARE_PCI_FIXUP_HEADER(0x1033, 0x0035, quirk_ppc_currituck_usb_fixup);
 57 
 58 static int __init ppc47x_device_probe(void)
 59 {
 60         of_platform_bus_probe(NULL, ppc47x_of_bus, NULL);
 61 
 62         return 0;
 63 }
 64 machine_device_initcall(ppc47x, ppc47x_device_probe);
 65 
 66 /* We can have either UICs or MPICs */
 67 static void __init ppc47x_init_irq(void)
 68 {
 69         struct device_node *np;
 70 
 71         /* Find top level interrupt controller */
 72         for_each_node_with_property(np, "interrupt-controller") {
 73                 if (of_get_property(np, "interrupts", NULL) == NULL)
 74                         break;
 75         }
 76         if (np == NULL)
 77                 panic("Can't find top level interrupt controller");
 78 
 79         /* Check type and do appropriate initialization */
 80         if (of_device_is_compatible(np, "chrp,open-pic")) {
 81                 /* The MPIC driver will get everything it needs from the
 82                  * device-tree, just pass 0 to all arguments
 83                  */
 84                 struct mpic *mpic =
 85                         mpic_alloc(np, 0, MPIC_NO_RESET, 0, 0, " MPIC     ");
 86                 BUG_ON(mpic == NULL);
 87                 mpic_init(mpic);
 88                 ppc_md.get_irq = mpic_get_irq;
 89         } else
 90                 panic("Unrecognized top level interrupt controller");
 91 }
 92 
 93 #ifdef CONFIG_SMP
 94 static void smp_ppc47x_setup_cpu(int cpu)
 95 {
 96         mpic_setup_this_cpu();
 97 }
 98 
 99 static int smp_ppc47x_kick_cpu(int cpu)
100 {
101         struct device_node *cpunode = of_get_cpu_node(cpu, NULL);
102         const u64 *spin_table_addr_prop;
103         u32 *spin_table;
104         extern void start_secondary_47x(void);
105 
106         BUG_ON(cpunode == NULL);
107 
108         /* Assume spin table. We could test for the enable-method in
109          * the device-tree but currently there's little point as it's
110          * our only supported method
111          */
112         spin_table_addr_prop =
113                 of_get_property(cpunode, "cpu-release-addr", NULL);
114 
115         if (spin_table_addr_prop == NULL) {
116                 pr_err("CPU%d: Can't start, missing cpu-release-addr !\n",
117                        cpu);
118                 return 1;
119         }
120 
121         /* Assume it's mapped as part of the linear mapping. This is a bit
122          * fishy but will work fine for now
123          *
124          * XXX: Is there any reason to assume differently?
125          */
126         spin_table = (u32 *)__va(*spin_table_addr_prop);
127         pr_debug("CPU%d: Spin table mapped at %p\n", cpu, spin_table);
128 
129         spin_table[3] = cpu;
130         smp_wmb();
131         spin_table[1] = __pa(start_secondary_47x);
132         mb();
133 
134         return 0;
135 }
136 
137 static struct smp_ops_t ppc47x_smp_ops = {
138         .probe          = smp_mpic_probe,
139         .message_pass   = smp_mpic_message_pass,
140         .setup_cpu      = smp_ppc47x_setup_cpu,
141         .kick_cpu       = smp_ppc47x_kick_cpu,
142         .give_timebase  = smp_generic_give_timebase,
143         .take_timebase  = smp_generic_take_timebase,
144 };
145 
146 static void __init ppc47x_smp_init(void)
147 {
148         if (mmu_has_feature(MMU_FTR_TYPE_47x))
149                 smp_ops = &ppc47x_smp_ops;
150 }
151 
152 #else /* CONFIG_SMP */
153 static void __init ppc47x_smp_init(void) { }
154 #endif /* CONFIG_SMP */
155 
156 static void __init ppc47x_setup_arch(void)
157 {
158 
159         /* No need to check the DMA config as we /know/ our windows are all of
160          * RAM.  Lets hope that doesn't change */
161         swiotlb_detect_4g();
162 
163         ppc47x_smp_init();
164 }
165 
166 /*
167  * Called very early, MMU is off, device-tree isn't unflattened
168  */
169 static int __init ppc47x_probe(void)
170 {
171         unsigned long root = of_get_flat_dt_root();
172 
173         if (!of_flat_dt_is_compatible(root, "ibm,currituck"))
174                 return 0;
175 
176         return 1;
177 }
178 
179 static int board_rev = -1;
180 static int __init ppc47x_get_board_rev(void)
181 {
182         u8 fpga_reg0;
183         void *fpga;
184         struct device_node *np;
185 
186         np = of_find_compatible_node(NULL, NULL, "ibm,currituck-fpga");
187         if (!np)
188                 goto fail;
189 
190         fpga = of_iomap(np, 0);
191         of_node_put(np);
192         if (!fpga)
193                 goto fail;
194 
195         fpga_reg0 = ioread8(fpga);
196         board_rev = fpga_reg0 & 0x03;
197         pr_info("%s: Found board revision %d\n", __func__, board_rev);
198         iounmap(fpga);
199         return 0;
200 
201 fail:
202         pr_info("%s: Unable to find board revision\n", __func__);
203         return 0;
204 }
205 machine_arch_initcall(ppc47x, ppc47x_get_board_rev);
206 
207 /* Use USB controller should have been hardware swizzled but it wasn't :( */
208 static void ppc47x_pci_irq_fixup(struct pci_dev *dev)
209 {
210         if (dev->vendor == 0x1033 && (dev->device == 0x0035 ||
211                                       dev->device == 0x00e0)) {
212                 if (board_rev == 0) {
213                         dev->irq = irq_create_mapping(NULL, 47);
214                         pr_info("%s: Mapping irq %d\n", __func__, dev->irq);
215                 } else if (board_rev == 2) {
216                         dev->irq = irq_create_mapping(NULL, 49);
217                         pr_info("%s: Mapping irq %d\n", __func__, dev->irq);
218                 } else {
219                         pr_alert("%s: Unknown board revision\n", __func__);
220                 }
221         }
222 }
223 
224 define_machine(ppc47x) {
225         .name                   = "PowerPC 47x",
226         .probe                  = ppc47x_probe,
227         .progress               = udbg_progress,
228         .init_IRQ               = ppc47x_init_irq,
229         .setup_arch             = ppc47x_setup_arch,
230         .pci_irq_fixup          = ppc47x_pci_irq_fixup,
231         .restart                = ppc4xx_reset_system,
232         .calibrate_decr         = generic_calibrate_decr,
233 };
234 

This page was automatically generated by LXR 0.3.1 (source).  •  Linux is a registered trademark of Linus Torvalds  •  Contact us