Thomas Gleixner | 4505153 | 2019-05-29 16:57:47 -0700 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-only |
Olof Johansson | 1e76875 | 2006-09-06 14:42:08 -0500 | [diff] [blame] | 2 | /* |
Olof Johansson | 31c56d8 | 2007-02-04 16:36:55 -0600 | [diff] [blame] | 3 | * Copyright (C) 2006-2007 PA Semi, Inc |
Olof Johansson | 1e76875 | 2006-09-06 14:42:08 -0500 | [diff] [blame] | 4 | * |
| 5 | * Authors: Kip Walker, PA Semi |
| 6 | * Olof Johansson, PA Semi |
| 7 | * |
| 8 | * Maintained by: Olof Johansson <olof@lixom.net> |
| 9 | * |
| 10 | * Based on arch/powerpc/platforms/maple/setup.c |
Olof Johansson | 1e76875 | 2006-09-06 14:42:08 -0500 | [diff] [blame] | 11 | */ |
| 12 | |
Olof Johansson | 1e76875 | 2006-09-06 14:42:08 -0500 | [diff] [blame] | 13 | #include <linux/errno.h> |
| 14 | #include <linux/kernel.h> |
| 15 | #include <linux/delay.h> |
| 16 | #include <linux/console.h> |
Paul Gortmaker | 66b15db | 2011-05-27 10:46:24 -0400 | [diff] [blame] | 17 | #include <linux/export.h> |
Benjamin Herrenschmidt | 12d04ee | 2006-11-11 17:25:02 +1100 | [diff] [blame] | 18 | #include <linux/pci.h> |
Jon Loeliger | 5f867dc | 2007-11-14 04:13:03 +1100 | [diff] [blame] | 19 | #include <linux/of_platform.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 20 | #include <linux/gfp.h> |
Olof Johansson | 1e76875 | 2006-09-06 14:42:08 -0500 | [diff] [blame] | 21 | |
| 22 | #include <asm/prom.h> |
Olof Johansson | 1e76875 | 2006-09-06 14:42:08 -0500 | [diff] [blame] | 23 | #include <asm/iommu.h> |
| 24 | #include <asm/machdep.h> |
Darren Stevens | 0428a5f | 2018-08-19 21:21:47 +0100 | [diff] [blame] | 25 | #include <asm/i8259.h> |
Olof Johansson | 1e76875 | 2006-09-06 14:42:08 -0500 | [diff] [blame] | 26 | #include <asm/mpic.h> |
| 27 | #include <asm/smp.h> |
| 28 | #include <asm/time.h> |
Michael Neuling | 584f8b7 | 2007-12-06 17:24:48 +1100 | [diff] [blame] | 29 | #include <asm/mmu.h> |
David Howells | ae3a197 | 2012-03-28 18:30:02 +0100 | [diff] [blame] | 30 | #include <asm/debug.h> |
Olof Johansson | 1e76875 | 2006-09-06 14:42:08 -0500 | [diff] [blame] | 31 | |
Olof Johansson | 2b571a0 | 2007-10-16 23:26:20 -0700 | [diff] [blame] | 32 | #include <pcmcia/ss.h> |
| 33 | #include <pcmcia/cistpl.h> |
| 34 | #include <pcmcia/ds.h> |
| 35 | |
Olof Johansson | 1e76875 | 2006-09-06 14:42:08 -0500 | [diff] [blame] | 36 | #include "pasemi.h" |
| 37 | |
Olof Johansson | cd78341 | 2007-09-05 12:09:23 +1000 | [diff] [blame] | 38 | /* SDC reset register, must be pre-mapped at reset time */ |
Olof Johansson | f620be9 | 2007-02-04 16:36:52 -0600 | [diff] [blame] | 39 | static void __iomem *reset_reg; |
| 40 | |
Olof Johansson | cd78341 | 2007-09-05 12:09:23 +1000 | [diff] [blame] | 41 | /* Various error status registers, must be pre-mapped at MCE time */ |
| 42 | |
| 43 | #define MAX_MCE_REGS 32 |
| 44 | struct mce_regs { |
| 45 | char *name; |
| 46 | void __iomem *addr; |
| 47 | }; |
| 48 | |
| 49 | static struct mce_regs mce_regs[MAX_MCE_REGS]; |
| 50 | static int num_mce_regs; |
Michael Ellerman | ef24ba7 | 2016-09-06 21:53:24 +1000 | [diff] [blame] | 51 | static int nmi_virq = 0; |
Olof Johansson | cd78341 | 2007-09-05 12:09:23 +1000 | [diff] [blame] | 52 | |
| 53 | |
Daniel Axtens | 95ec77c | 2016-07-12 10:54:52 +1000 | [diff] [blame] | 54 | static void __noreturn pas_restart(char *cmd) |
Olof Johansson | 1e76875 | 2006-09-06 14:42:08 -0500 | [diff] [blame] | 55 | { |
Olof Johansson | 32e2b55 | 2007-11-07 09:31:06 -0600 | [diff] [blame] | 56 | /* Need to put others cpu in hold loop so they're not sleeping */ |
| 57 | smp_send_stop(); |
| 58 | udelay(10000); |
Olof Johansson | f620be9 | 2007-02-04 16:36:52 -0600 | [diff] [blame] | 59 | printk("Restarting...\n"); |
| 60 | while (1) |
| 61 | out_le32(reset_reg, 0x6000000); |
Olof Johansson | 1e76875 | 2006-09-06 14:42:08 -0500 | [diff] [blame] | 62 | } |
| 63 | |
Darren Stevens | 656fdf3 | 2018-08-19 21:23:57 +0100 | [diff] [blame] | 64 | #ifdef CONFIG_PPC_PASEMI_NEMO |
| 65 | void pas_shutdown(void) |
| 66 | { |
| 67 | /* Set the PLD bit that makes the SB600 think the power button is being pressed */ |
| 68 | void __iomem *pld_map = ioremap(0xf5000000,4096); |
| 69 | while (1) |
| 70 | out_8(pld_map+7,0x01); |
| 71 | } |
| 72 | |
| 73 | /* RTC platform device structure as is not in device tree */ |
| 74 | static struct resource rtc_resource[] = {{ |
| 75 | .name = "rtc", |
| 76 | .start = 0x70, |
| 77 | .end = 0x71, |
| 78 | .flags = IORESOURCE_IO, |
| 79 | }, { |
| 80 | .name = "rtc", |
| 81 | .start = 8, |
| 82 | .end = 8, |
| 83 | .flags = IORESOURCE_IRQ, |
| 84 | }}; |
| 85 | |
| 86 | static inline void nemo_init_rtc(void) |
| 87 | { |
| 88 | platform_device_register_simple("rtc_cmos", -1, rtc_resource, 2); |
| 89 | } |
| 90 | |
| 91 | #else |
| 92 | |
| 93 | static inline void nemo_init_rtc(void) |
| 94 | { |
| 95 | } |
| 96 | #endif |
| 97 | |
Olof Johansson | 1e76875 | 2006-09-06 14:42:08 -0500 | [diff] [blame] | 98 | #ifdef CONFIG_SMP |
Thomas Gleixner | 445c895 | 2009-12-02 19:49:50 +0100 | [diff] [blame] | 99 | static arch_spinlock_t timebase_lock; |
Olof Johansson | dc559f7 | 2007-08-22 12:26:43 +1000 | [diff] [blame] | 100 | static unsigned long timebase; |
Olof Johansson | c388cfe | 2007-02-04 16:36:53 -0600 | [diff] [blame] | 101 | |
Greg Kroah-Hartman | cad5cef | 2012-12-21 14:04:10 -0800 | [diff] [blame] | 102 | static void pas_give_timebase(void) |
Olof Johansson | c388cfe | 2007-02-04 16:36:53 -0600 | [diff] [blame] | 103 | { |
Benjamin Herrenschmidt | 6893ce6 | 2009-06-16 16:42:51 +0000 | [diff] [blame] | 104 | unsigned long flags; |
| 105 | |
| 106 | local_irq_save(flags); |
| 107 | hard_irq_disable(); |
Thomas Gleixner | 0199c4e | 2009-12-02 20:01:25 +0100 | [diff] [blame] | 108 | arch_spin_lock(&timebase_lock); |
Olof Johansson | c388cfe | 2007-02-04 16:36:53 -0600 | [diff] [blame] | 109 | mtspr(SPRN_TBCTL, TBCTL_FREEZE); |
Olof Johansson | dc559f7 | 2007-08-22 12:26:43 +1000 | [diff] [blame] | 110 | isync(); |
| 111 | timebase = get_tb(); |
Thomas Gleixner | 0199c4e | 2009-12-02 20:01:25 +0100 | [diff] [blame] | 112 | arch_spin_unlock(&timebase_lock); |
Olof Johansson | dc559f7 | 2007-08-22 12:26:43 +1000 | [diff] [blame] | 113 | |
| 114 | while (timebase) |
| 115 | barrier(); |
| 116 | mtspr(SPRN_TBCTL, TBCTL_RESTART); |
Benjamin Herrenschmidt | 6893ce6 | 2009-06-16 16:42:51 +0000 | [diff] [blame] | 117 | local_irq_restore(flags); |
Olof Johansson | c388cfe | 2007-02-04 16:36:53 -0600 | [diff] [blame] | 118 | } |
| 119 | |
Greg Kroah-Hartman | cad5cef | 2012-12-21 14:04:10 -0800 | [diff] [blame] | 120 | static void pas_take_timebase(void) |
Olof Johansson | c388cfe | 2007-02-04 16:36:53 -0600 | [diff] [blame] | 121 | { |
Olof Johansson | dc559f7 | 2007-08-22 12:26:43 +1000 | [diff] [blame] | 122 | while (!timebase) |
| 123 | smp_rmb(); |
| 124 | |
Thomas Gleixner | 0199c4e | 2009-12-02 20:01:25 +0100 | [diff] [blame] | 125 | arch_spin_lock(&timebase_lock); |
Olof Johansson | dc559f7 | 2007-08-22 12:26:43 +1000 | [diff] [blame] | 126 | set_tb(timebase >> 32, timebase & 0xffffffff); |
| 127 | timebase = 0; |
Thomas Gleixner | 0199c4e | 2009-12-02 20:01:25 +0100 | [diff] [blame] | 128 | arch_spin_unlock(&timebase_lock); |
Olof Johansson | c388cfe | 2007-02-04 16:36:53 -0600 | [diff] [blame] | 129 | } |
| 130 | |
Daniel Axtens | 7c98bd7 | 2016-09-06 15:32:40 +1000 | [diff] [blame] | 131 | static struct smp_ops_t pas_smp_ops = { |
Olof Johansson | 1e76875 | 2006-09-06 14:42:08 -0500 | [diff] [blame] | 132 | .probe = smp_mpic_probe, |
| 133 | .message_pass = smp_mpic_message_pass, |
| 134 | .kick_cpu = smp_generic_kick_cpu, |
| 135 | .setup_cpu = smp_mpic_setup_cpu, |
Olof Johansson | c388cfe | 2007-02-04 16:36:53 -0600 | [diff] [blame] | 136 | .give_timebase = pas_give_timebase, |
| 137 | .take_timebase = pas_take_timebase, |
Olof Johansson | 1e76875 | 2006-09-06 14:42:08 -0500 | [diff] [blame] | 138 | }; |
| 139 | #endif /* CONFIG_SMP */ |
| 140 | |
Daniel Axtens | 7c98bd7 | 2016-09-06 15:32:40 +1000 | [diff] [blame] | 141 | static void __init pas_setup_arch(void) |
Olof Johansson | 1e76875 | 2006-09-06 14:42:08 -0500 | [diff] [blame] | 142 | { |
| 143 | #ifdef CONFIG_SMP |
| 144 | /* Setup SMP callback */ |
| 145 | smp_ops = &pas_smp_ops; |
| 146 | #endif |
Olof Johansson | 1e76875 | 2006-09-06 14:42:08 -0500 | [diff] [blame] | 147 | |
Olof Johansson | f620be9 | 2007-02-04 16:36:52 -0600 | [diff] [blame] | 148 | /* Remap SDC register for doing reset */ |
| 149 | /* XXXOJN This should maybe come out of the device tree */ |
| 150 | reset_reg = ioremap(0xfc101100, 4); |
Olof Johansson | 1e76875 | 2006-09-06 14:42:08 -0500 | [diff] [blame] | 151 | } |
| 152 | |
Olof Johansson | cd78341 | 2007-09-05 12:09:23 +1000 | [diff] [blame] | 153 | static int __init pas_setup_mce_regs(void) |
| 154 | { |
| 155 | struct pci_dev *dev; |
| 156 | int reg; |
| 157 | |
Olof Johansson | cd78341 | 2007-09-05 12:09:23 +1000 | [diff] [blame] | 158 | /* Remap various SoC status registers for use by the MCE handler */ |
| 159 | |
| 160 | reg = 0; |
| 161 | |
| 162 | dev = pci_get_device(PCI_VENDOR_ID_PASEMI, 0xa00a, NULL); |
| 163 | while (dev && reg < MAX_MCE_REGS) { |
| 164 | mce_regs[reg].name = kasprintf(GFP_KERNEL, |
| 165 | "mc%d_mcdebug_errsta", reg); |
| 166 | mce_regs[reg].addr = pasemi_pci_getcfgaddr(dev, 0x730); |
| 167 | dev = pci_get_device(PCI_VENDOR_ID_PASEMI, 0xa00a, dev); |
| 168 | reg++; |
| 169 | } |
| 170 | |
| 171 | dev = pci_get_device(PCI_VENDOR_ID_PASEMI, 0xa001, NULL); |
| 172 | if (dev && reg+4 < MAX_MCE_REGS) { |
| 173 | mce_regs[reg].name = "iobdbg_IntStatus1"; |
| 174 | mce_regs[reg].addr = pasemi_pci_getcfgaddr(dev, 0x438); |
| 175 | reg++; |
| 176 | mce_regs[reg].name = "iobdbg_IOCTbusIntDbgReg"; |
| 177 | mce_regs[reg].addr = pasemi_pci_getcfgaddr(dev, 0x454); |
| 178 | reg++; |
| 179 | mce_regs[reg].name = "iobiom_IntStatus"; |
| 180 | mce_regs[reg].addr = pasemi_pci_getcfgaddr(dev, 0xc10); |
| 181 | reg++; |
| 182 | mce_regs[reg].name = "iobiom_IntDbgReg"; |
| 183 | mce_regs[reg].addr = pasemi_pci_getcfgaddr(dev, 0xc1c); |
| 184 | reg++; |
| 185 | } |
| 186 | |
| 187 | dev = pci_get_device(PCI_VENDOR_ID_PASEMI, 0xa009, NULL); |
| 188 | if (dev && reg+2 < MAX_MCE_REGS) { |
| 189 | mce_regs[reg].name = "l2csts_IntStatus"; |
| 190 | mce_regs[reg].addr = pasemi_pci_getcfgaddr(dev, 0x200); |
| 191 | reg++; |
| 192 | mce_regs[reg].name = "l2csts_Cnt"; |
| 193 | mce_regs[reg].addr = pasemi_pci_getcfgaddr(dev, 0x214); |
| 194 | reg++; |
| 195 | } |
| 196 | |
| 197 | num_mce_regs = reg; |
| 198 | |
| 199 | return 0; |
| 200 | } |
Grant Likely | bdddec4 | 2008-01-02 12:32:28 -0700 | [diff] [blame] | 201 | machine_device_initcall(pasemi, pas_setup_mce_regs); |
Olof Johansson | cd78341 | 2007-09-05 12:09:23 +1000 | [diff] [blame] | 202 | |
Darren Stevens | 0428a5f | 2018-08-19 21:21:47 +0100 | [diff] [blame] | 203 | #ifdef CONFIG_PPC_PASEMI_NEMO |
| 204 | static void sb600_8259_cascade(struct irq_desc *desc) |
| 205 | { |
| 206 | struct irq_chip *chip = irq_desc_get_chip(desc); |
| 207 | unsigned int cascade_irq = i8259_irq(); |
| 208 | |
| 209 | if (cascade_irq) |
| 210 | generic_handle_irq(cascade_irq); |
| 211 | |
| 212 | chip->irq_eoi(&desc->irq_data); |
| 213 | } |
| 214 | |
Nick Child | e37e06a | 2021-12-16 17:00:24 -0500 | [diff] [blame] | 215 | static void __init nemo_init_IRQ(struct mpic *mpic) |
Darren Stevens | 0428a5f | 2018-08-19 21:21:47 +0100 | [diff] [blame] | 216 | { |
| 217 | struct device_node *np; |
| 218 | int gpio_virq; |
| 219 | /* Connect the SB600's legacy i8259 controller */ |
| 220 | np = of_find_node_by_path("/pxp@0,e0000000"); |
| 221 | i8259_init(np, 0); |
| 222 | of_node_put(np); |
| 223 | |
| 224 | gpio_virq = irq_create_mapping(NULL, 3); |
| 225 | irq_set_irq_type(gpio_virq, IRQ_TYPE_LEVEL_HIGH); |
| 226 | irq_set_chained_handler(gpio_virq, sb600_8259_cascade); |
| 227 | mpic_unmask_irq(irq_get_irq_data(gpio_virq)); |
| 228 | |
| 229 | irq_set_default_host(mpic->irqhost); |
| 230 | } |
| 231 | |
| 232 | #else |
| 233 | |
| 234 | static inline void nemo_init_IRQ(struct mpic *mpic) |
| 235 | { |
| 236 | } |
| 237 | #endif |
| 238 | |
Olof Johansson | 1e76875 | 2006-09-06 14:42:08 -0500 | [diff] [blame] | 239 | static __init void pas_init_IRQ(void) |
| 240 | { |
| 241 | struct device_node *np; |
| 242 | struct device_node *root, *mpic_node; |
| 243 | unsigned long openpic_addr; |
| 244 | const unsigned int *opprop; |
| 245 | int naddr, opplen; |
Olof Johansson | f365355 | 2007-12-20 13:11:18 -0600 | [diff] [blame] | 246 | int mpic_flags; |
| 247 | const unsigned int *nmiprop; |
Olof Johansson | 1e76875 | 2006-09-06 14:42:08 -0500 | [diff] [blame] | 248 | struct mpic *mpic; |
| 249 | |
| 250 | mpic_node = NULL; |
| 251 | |
| 252 | for_each_node_by_type(np, "interrupt-controller") |
Stephen Rothwell | 55b61fe | 2007-05-03 17:26:52 +1000 | [diff] [blame] | 253 | if (of_device_is_compatible(np, "open-pic")) { |
Olof Johansson | 1e76875 | 2006-09-06 14:42:08 -0500 | [diff] [blame] | 254 | mpic_node = np; |
| 255 | break; |
| 256 | } |
| 257 | if (!mpic_node) |
| 258 | for_each_node_by_type(np, "open-pic") { |
| 259 | mpic_node = np; |
| 260 | break; |
| 261 | } |
| 262 | if (!mpic_node) { |
Darren Stevens | e13606d | 2018-08-03 21:15:10 +1000 | [diff] [blame] | 263 | pr_err("Failed to locate the MPIC interrupt controller\n"); |
Olof Johansson | 1e76875 | 2006-09-06 14:42:08 -0500 | [diff] [blame] | 264 | return; |
| 265 | } |
| 266 | |
| 267 | /* Find address list in /platform-open-pic */ |
| 268 | root = of_find_node_by_path("/"); |
Stephen Rothwell | a8bda5d | 2007-04-03 10:56:50 +1000 | [diff] [blame] | 269 | naddr = of_n_addr_cells(root); |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 270 | opprop = of_get_property(root, "platform-open-pic", &opplen); |
Olof Johansson | 1e76875 | 2006-09-06 14:42:08 -0500 | [diff] [blame] | 271 | if (!opprop) { |
Darren Stevens | e13606d | 2018-08-03 21:15:10 +1000 | [diff] [blame] | 272 | pr_err("No platform-open-pic property.\n"); |
Olof Johansson | 1e76875 | 2006-09-06 14:42:08 -0500 | [diff] [blame] | 273 | of_node_put(root); |
| 274 | return; |
| 275 | } |
| 276 | openpic_addr = of_read_number(opprop, naddr); |
Darren Stevens | e13606d | 2018-08-03 21:15:10 +1000 | [diff] [blame] | 277 | pr_debug("OpenPIC addr: %lx\n", openpic_addr); |
Olof Johansson | 1e76875 | 2006-09-06 14:42:08 -0500 | [diff] [blame] | 278 | |
Kyle Moffett | e55d7f7 | 2011-12-22 10:19:14 +0000 | [diff] [blame] | 279 | mpic_flags = MPIC_LARGE_VECTORS | MPIC_NO_BIAS | MPIC_NO_RESET; |
Olof Johansson | f365355 | 2007-12-20 13:11:18 -0600 | [diff] [blame] | 280 | |
| 281 | nmiprop = of_get_property(mpic_node, "nmi-source", NULL); |
| 282 | if (nmiprop) |
| 283 | mpic_flags |= MPIC_ENABLE_MCK; |
| 284 | |
Olof Johansson | 7df2457d | 2007-01-28 23:33:18 -0600 | [diff] [blame] | 285 | mpic = mpic_alloc(mpic_node, openpic_addr, |
Olof Johansson | f365355 | 2007-12-20 13:11:18 -0600 | [diff] [blame] | 286 | mpic_flags, 0, 0, "PASEMI-OPIC"); |
Olof Johansson | 1e76875 | 2006-09-06 14:42:08 -0500 | [diff] [blame] | 287 | BUG_ON(!mpic); |
| 288 | |
Kyle Moffett | e7a9867 | 2011-12-02 06:28:01 +0000 | [diff] [blame] | 289 | mpic_assign_isu(mpic, 0, mpic->paddr + 0x10000); |
Olof Johansson | 1e76875 | 2006-09-06 14:42:08 -0500 | [diff] [blame] | 290 | mpic_init(mpic); |
Olof Johansson | f365355 | 2007-12-20 13:11:18 -0600 | [diff] [blame] | 291 | /* The NMI/MCK source needs to be prio 15 */ |
| 292 | if (nmiprop) { |
| 293 | nmi_virq = irq_create_mapping(NULL, *nmiprop); |
| 294 | mpic_irq_set_priority(nmi_virq, 15); |
Thomas Gleixner | ec775d0 | 2011-03-25 16:45:20 +0100 | [diff] [blame] | 295 | irq_set_irq_type(nmi_virq, IRQ_TYPE_EDGE_RISING); |
Lennert Buytenhek | 835c0553 | 2011-03-08 22:26:43 +0000 | [diff] [blame] | 296 | mpic_unmask_irq(irq_get_irq_data(nmi_virq)); |
Olof Johansson | f365355 | 2007-12-20 13:11:18 -0600 | [diff] [blame] | 297 | } |
| 298 | |
Darren Stevens | 51f4cc2 | 2018-08-19 21:26:28 +0100 | [diff] [blame] | 299 | nemo_init_IRQ(mpic); |
| 300 | |
Olof Johansson | 1e76875 | 2006-09-06 14:42:08 -0500 | [diff] [blame] | 301 | of_node_put(mpic_node); |
| 302 | of_node_put(root); |
| 303 | } |
| 304 | |
| 305 | static void __init pas_progress(char *s, unsigned short hex) |
| 306 | { |
| 307 | printk("[%04x] : %s\n", hex, s ? s : ""); |
| 308 | } |
| 309 | |
| 310 | |
Olof Johansson | bfed9d3 | 2007-02-04 16:36:50 -0600 | [diff] [blame] | 311 | static int pas_machine_check_handler(struct pt_regs *regs) |
| 312 | { |
| 313 | int cpu = smp_processor_id(); |
| 314 | unsigned long srr0, srr1, dsisr; |
Olof Johansson | cd78341 | 2007-09-05 12:09:23 +1000 | [diff] [blame] | 315 | int dump_slb = 0; |
| 316 | int i; |
Olof Johansson | bfed9d3 | 2007-02-04 16:36:50 -0600 | [diff] [blame] | 317 | |
| 318 | srr0 = regs->nip; |
| 319 | srr1 = regs->msr; |
Olof Johansson | f365355 | 2007-12-20 13:11:18 -0600 | [diff] [blame] | 320 | |
Michael Ellerman | ef24ba7 | 2016-09-06 21:53:24 +1000 | [diff] [blame] | 321 | if (nmi_virq && mpic_get_mcirq() == nmi_virq) { |
Darren Stevens | e13606d | 2018-08-03 21:15:10 +1000 | [diff] [blame] | 322 | pr_err("NMI delivered\n"); |
Olof Johansson | f365355 | 2007-12-20 13:11:18 -0600 | [diff] [blame] | 323 | debugger(regs); |
Lennert Buytenhek | 835c0553 | 2011-03-08 22:26:43 +0000 | [diff] [blame] | 324 | mpic_end_irq(irq_get_irq_data(nmi_virq)); |
Olof Johansson | f365355 | 2007-12-20 13:11:18 -0600 | [diff] [blame] | 325 | goto out; |
| 326 | } |
| 327 | |
Olof Johansson | bfed9d3 | 2007-02-04 16:36:50 -0600 | [diff] [blame] | 328 | dsisr = mfspr(SPRN_DSISR); |
Darren Stevens | e13606d | 2018-08-03 21:15:10 +1000 | [diff] [blame] | 329 | pr_err("Machine Check on CPU %d\n", cpu); |
| 330 | pr_err("SRR0 0x%016lx SRR1 0x%016lx\n", srr0, srr1); |
| 331 | pr_err("DSISR 0x%016lx DAR 0x%016lx\n", dsisr, regs->dar); |
| 332 | pr_err("BER 0x%016lx MER 0x%016lx\n", mfspr(SPRN_PA6T_BER), |
Olof Johansson | cd78341 | 2007-09-05 12:09:23 +1000 | [diff] [blame] | 333 | mfspr(SPRN_PA6T_MER)); |
Darren Stevens | e13606d | 2018-08-03 21:15:10 +1000 | [diff] [blame] | 334 | pr_err("IER 0x%016lx DER 0x%016lx\n", mfspr(SPRN_PA6T_IER), |
Olof Johansson | cd78341 | 2007-09-05 12:09:23 +1000 | [diff] [blame] | 335 | mfspr(SPRN_PA6T_DER)); |
Darren Stevens | e13606d | 2018-08-03 21:15:10 +1000 | [diff] [blame] | 336 | pr_err("Cause:\n"); |
Olof Johansson | bfed9d3 | 2007-02-04 16:36:50 -0600 | [diff] [blame] | 337 | |
| 338 | if (srr1 & 0x200000) |
Darren Stevens | e13606d | 2018-08-03 21:15:10 +1000 | [diff] [blame] | 339 | pr_err("Signalled by SDC\n"); |
Olof Johansson | cd78341 | 2007-09-05 12:09:23 +1000 | [diff] [blame] | 340 | |
Olof Johansson | bfed9d3 | 2007-02-04 16:36:50 -0600 | [diff] [blame] | 341 | if (srr1 & 0x100000) { |
Darren Stevens | e13606d | 2018-08-03 21:15:10 +1000 | [diff] [blame] | 342 | pr_err("Load/Store detected error:\n"); |
Olof Johansson | bfed9d3 | 2007-02-04 16:36:50 -0600 | [diff] [blame] | 343 | if (dsisr & 0x8000) |
Darren Stevens | e13606d | 2018-08-03 21:15:10 +1000 | [diff] [blame] | 344 | pr_err("D-cache ECC double-bit error or bus error\n"); |
Olof Johansson | bfed9d3 | 2007-02-04 16:36:50 -0600 | [diff] [blame] | 345 | if (dsisr & 0x4000) |
Darren Stevens | e13606d | 2018-08-03 21:15:10 +1000 | [diff] [blame] | 346 | pr_err("LSU snoop response error\n"); |
Olof Johansson | cd78341 | 2007-09-05 12:09:23 +1000 | [diff] [blame] | 347 | if (dsisr & 0x2000) { |
Darren Stevens | e13606d | 2018-08-03 21:15:10 +1000 | [diff] [blame] | 348 | pr_err("MMU SLB multi-hit or invalid B field\n"); |
Olof Johansson | cd78341 | 2007-09-05 12:09:23 +1000 | [diff] [blame] | 349 | dump_slb = 1; |
| 350 | } |
Olof Johansson | bfed9d3 | 2007-02-04 16:36:50 -0600 | [diff] [blame] | 351 | if (dsisr & 0x1000) |
Darren Stevens | e13606d | 2018-08-03 21:15:10 +1000 | [diff] [blame] | 352 | pr_err("Recoverable Duptags\n"); |
Olof Johansson | bfed9d3 | 2007-02-04 16:36:50 -0600 | [diff] [blame] | 353 | if (dsisr & 0x800) |
Darren Stevens | e13606d | 2018-08-03 21:15:10 +1000 | [diff] [blame] | 354 | pr_err("Recoverable D-cache parity error count overflow\n"); |
Olof Johansson | bfed9d3 | 2007-02-04 16:36:50 -0600 | [diff] [blame] | 355 | if (dsisr & 0x400) |
Darren Stevens | e13606d | 2018-08-03 21:15:10 +1000 | [diff] [blame] | 356 | pr_err("TLB parity error count overflow\n"); |
Olof Johansson | bfed9d3 | 2007-02-04 16:36:50 -0600 | [diff] [blame] | 357 | } |
Olof Johansson | cd78341 | 2007-09-05 12:09:23 +1000 | [diff] [blame] | 358 | |
Olof Johansson | bfed9d3 | 2007-02-04 16:36:50 -0600 | [diff] [blame] | 359 | if (srr1 & 0x80000) |
Darren Stevens | e13606d | 2018-08-03 21:15:10 +1000 | [diff] [blame] | 360 | pr_err("Bus Error\n"); |
Olof Johansson | cd78341 | 2007-09-05 12:09:23 +1000 | [diff] [blame] | 361 | |
| 362 | if (srr1 & 0x40000) { |
Darren Stevens | e13606d | 2018-08-03 21:15:10 +1000 | [diff] [blame] | 363 | pr_err("I-side SLB multiple hit\n"); |
Olof Johansson | cd78341 | 2007-09-05 12:09:23 +1000 | [diff] [blame] | 364 | dump_slb = 1; |
| 365 | } |
| 366 | |
Olof Johansson | bfed9d3 | 2007-02-04 16:36:50 -0600 | [diff] [blame] | 367 | if (srr1 & 0x20000) |
Darren Stevens | e13606d | 2018-08-03 21:15:10 +1000 | [diff] [blame] | 368 | pr_err("I-cache parity error hit\n"); |
Olof Johansson | bfed9d3 | 2007-02-04 16:36:50 -0600 | [diff] [blame] | 369 | |
Olof Johansson | cd78341 | 2007-09-05 12:09:23 +1000 | [diff] [blame] | 370 | if (num_mce_regs == 0) |
Darren Stevens | e13606d | 2018-08-03 21:15:10 +1000 | [diff] [blame] | 371 | pr_err("No MCE registers mapped yet, can't dump\n"); |
Olof Johansson | cd78341 | 2007-09-05 12:09:23 +1000 | [diff] [blame] | 372 | else |
Darren Stevens | e13606d | 2018-08-03 21:15:10 +1000 | [diff] [blame] | 373 | pr_err("SoC debug registers:\n"); |
Olof Johansson | cd78341 | 2007-09-05 12:09:23 +1000 | [diff] [blame] | 374 | |
| 375 | for (i = 0; i < num_mce_regs; i++) |
Darren Stevens | e13606d | 2018-08-03 21:15:10 +1000 | [diff] [blame] | 376 | pr_err("%s: 0x%08x\n", mce_regs[i].name, |
Olof Johansson | cd78341 | 2007-09-05 12:09:23 +1000 | [diff] [blame] | 377 | in_le32(mce_regs[i].addr)); |
| 378 | |
| 379 | if (dump_slb) { |
| 380 | unsigned long e, v; |
| 381 | int i; |
| 382 | |
Darren Stevens | e13606d | 2018-08-03 21:15:10 +1000 | [diff] [blame] | 383 | pr_err("slb contents:\n"); |
Michael Neuling | 584f8b7 | 2007-12-06 17:24:48 +1100 | [diff] [blame] | 384 | for (i = 0; i < mmu_slb_size; i++) { |
Olof Johansson | cd78341 | 2007-09-05 12:09:23 +1000 | [diff] [blame] | 385 | asm volatile("slbmfee %0,%1" : "=r" (e) : "r" (i)); |
| 386 | asm volatile("slbmfev %0,%1" : "=r" (v) : "r" (i)); |
Darren Stevens | e13606d | 2018-08-03 21:15:10 +1000 | [diff] [blame] | 387 | pr_err("%02d %016lx %016lx\n", i, e, v); |
Olof Johansson | cd78341 | 2007-09-05 12:09:23 +1000 | [diff] [blame] | 388 | } |
| 389 | } |
| 390 | |
Olof Johansson | f365355 | 2007-12-20 13:11:18 -0600 | [diff] [blame] | 391 | out: |
Olof Johansson | bfed9d3 | 2007-02-04 16:36:50 -0600 | [diff] [blame] | 392 | /* SRR1[62] is from MSR[62] if recoverable, so pass that back */ |
| 393 | return !!(srr1 & 0x2); |
| 394 | } |
| 395 | |
Uwe Kleine-König | ce6d73c | 2014-09-10 21:56:38 +0200 | [diff] [blame] | 396 | static const struct of_device_id pasemi_bus_ids[] = { |
Olof Johansson | 0d08a84 | 2007-11-04 20:57:45 -0600 | [diff] [blame] | 397 | /* Unfortunately needed for legacy firmwares */ |
Olof Johansson | 2b571a0 | 2007-10-16 23:26:20 -0700 | [diff] [blame] | 398 | { .type = "localbus", }, |
Olof Johansson | b97d279 | 2007-04-18 16:39:54 +1000 | [diff] [blame] | 399 | { .type = "sdc", }, |
Olof Johansson | 0d08a84 | 2007-11-04 20:57:45 -0600 | [diff] [blame] | 400 | /* These are the proper entries, which newer firmware uses */ |
| 401 | { .compatible = "pasemi,localbus", }, |
| 402 | { .compatible = "pasemi,sdc", }, |
Olof Johansson | b97d279 | 2007-04-18 16:39:54 +1000 | [diff] [blame] | 403 | {}, |
| 404 | }; |
| 405 | |
| 406 | static int __init pasemi_publish_devices(void) |
| 407 | { |
Olof Johansson | 90f7afe | 2007-05-01 14:43:39 +1000 | [diff] [blame] | 408 | /* Publish OF platform devices for SDC and other non-PCI devices */ |
Olof Johansson | b97d279 | 2007-04-18 16:39:54 +1000 | [diff] [blame] | 409 | of_platform_bus_probe(NULL, pasemi_bus_ids, NULL); |
| 410 | |
Darren Stevens | 51f4cc2 | 2018-08-19 21:26:28 +0100 | [diff] [blame] | 411 | nemo_init_rtc(); |
| 412 | |
Olof Johansson | b97d279 | 2007-04-18 16:39:54 +1000 | [diff] [blame] | 413 | return 0; |
| 414 | } |
Grant Likely | bdddec4 | 2008-01-02 12:32:28 -0700 | [diff] [blame] | 415 | machine_device_initcall(pasemi, pasemi_publish_devices); |
Olof Johansson | b97d279 | 2007-04-18 16:39:54 +1000 | [diff] [blame] | 416 | |
Olof Johansson | bfed9d3 | 2007-02-04 16:36:50 -0600 | [diff] [blame] | 417 | |
Olof Johansson | 1e76875 | 2006-09-06 14:42:08 -0500 | [diff] [blame] | 418 | /* |
| 419 | * Called very early, MMU is off, device-tree isn't unflattened |
| 420 | */ |
| 421 | static int __init pas_probe(void) |
| 422 | { |
Benjamin Herrenschmidt | 406b0b6 | 2016-07-05 15:04:00 +1000 | [diff] [blame] | 423 | if (!of_machine_is_compatible("PA6T-1682M") && |
| 424 | !of_machine_is_compatible("pasemi,pwrficient")) |
Olof Johansson | 1e76875 | 2006-09-06 14:42:08 -0500 | [diff] [blame] | 425 | return 0; |
| 426 | |
Darren Stevens | 51f4cc2 | 2018-08-19 21:26:28 +0100 | [diff] [blame] | 427 | #ifdef CONFIG_PPC_PASEMI_NEMO |
| 428 | /* |
| 429 | * Check for the Nemo motherboard here, if we are running on one |
| 430 | * change the machine definition to fit |
| 431 | */ |
| 432 | if (of_machine_is_compatible("pasemi,nemo")) { |
| 433 | pm_power_off = pas_shutdown; |
| 434 | ppc_md.name = "A-EON Amigaone X1000"; |
| 435 | } |
| 436 | #endif |
| 437 | |
Benjamin Herrenschmidt | f2d5769 | 2016-07-05 15:04:06 +1000 | [diff] [blame] | 438 | iommu_init_early_pasemi(); |
| 439 | |
Olof Johansson | 1e76875 | 2006-09-06 14:42:08 -0500 | [diff] [blame] | 440 | return 1; |
| 441 | } |
| 442 | |
Olof Johansson | d4875a2 | 2007-07-06 00:49:04 +1000 | [diff] [blame] | 443 | define_machine(pasemi) { |
Olof Johansson | 0d08a84 | 2007-11-04 20:57:45 -0600 | [diff] [blame] | 444 | .name = "PA Semi PWRficient", |
Olof Johansson | 1e76875 | 2006-09-06 14:42:08 -0500 | [diff] [blame] | 445 | .probe = pas_probe, |
| 446 | .setup_arch = pas_setup_arch, |
Oliver O'Halloran | c144bc7 | 2020-11-03 15:35:22 +1100 | [diff] [blame] | 447 | .discover_phbs = pas_pci_init, |
Olof Johansson | 1e76875 | 2006-09-06 14:42:08 -0500 | [diff] [blame] | 448 | .init_IRQ = pas_init_IRQ, |
| 449 | .get_irq = mpic_get_irq, |
Olof Johansson | 1e76875 | 2006-09-06 14:42:08 -0500 | [diff] [blame] | 450 | .restart = pas_restart, |
Olof Johansson | 1e76875 | 2006-09-06 14:42:08 -0500 | [diff] [blame] | 451 | .get_boot_time = pas_get_boot_time, |
| 452 | .calibrate_decr = generic_calibrate_decr, |
Olof Johansson | 1e76875 | 2006-09-06 14:42:08 -0500 | [diff] [blame] | 453 | .progress = pas_progress, |
Olof Johansson | bfed9d3 | 2007-02-04 16:36:50 -0600 | [diff] [blame] | 454 | .machine_check_exception = pas_machine_check_handler, |
Olof Johansson | 1e76875 | 2006-09-06 14:42:08 -0500 | [diff] [blame] | 455 | }; |