Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Paul Mackerras | 0cb7b2a | 2005-10-29 22:07:56 +1000 | [diff] [blame] | 2 | * Maple (970 eval board) setup code |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 | * |
| 4 | * (c) Copyright 2004 Benjamin Herrenschmidt (benh@kernel.crashing.org), |
| 5 | * IBM Corp. |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU General Public License |
| 9 | * as published by the Free Software Foundation; either version |
| 10 | * 2 of the License, or (at your option) any later version. |
| 11 | * |
| 12 | */ |
| 13 | |
Benjamin Herrenschmidt | 980a651 | 2006-07-03 17:22:05 +1000 | [diff] [blame] | 14 | #undef DEBUG |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | #include <linux/init.h> |
| 17 | #include <linux/errno.h> |
| 18 | #include <linux/sched.h> |
| 19 | #include <linux/kernel.h> |
Paul Gortmaker | 66b15db | 2011-05-27 10:46:24 -0400 | [diff] [blame] | 20 | #include <linux/export.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | #include <linux/mm.h> |
| 22 | #include <linux/stddef.h> |
| 23 | #include <linux/unistd.h> |
| 24 | #include <linux/ptrace.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | #include <linux/user.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | #include <linux/tty.h> |
| 27 | #include <linux/string.h> |
| 28 | #include <linux/delay.h> |
| 29 | #include <linux/ioport.h> |
| 30 | #include <linux/major.h> |
| 31 | #include <linux/initrd.h> |
| 32 | #include <linux/vt_kern.h> |
| 33 | #include <linux/console.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | #include <linux/pci.h> |
| 35 | #include <linux/adb.h> |
| 36 | #include <linux/cuda.h> |
| 37 | #include <linux/pmu.h> |
| 38 | #include <linux/irq.h> |
| 39 | #include <linux/seq_file.h> |
| 40 | #include <linux/root_dev.h> |
| 41 | #include <linux/serial.h> |
| 42 | #include <linux/smp.h> |
Jiri Slaby | 1977f03 | 2007-10-18 23:40:25 -0700 | [diff] [blame] | 43 | #include <linux/bitops.h> |
Jon Loeliger | 0173d42 | 2008-01-08 05:07:15 +1100 | [diff] [blame] | 44 | #include <linux/of_device.h> |
Yinghai Lu | 95f72d1 | 2010-07-12 14:36:09 +1000 | [diff] [blame] | 45 | #include <linux/memblock.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | |
| 47 | #include <asm/processor.h> |
| 48 | #include <asm/sections.h> |
| 49 | #include <asm/prom.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | #include <asm/pgtable.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | #include <asm/io.h> |
| 52 | #include <asm/pci-bridge.h> |
| 53 | #include <asm/iommu.h> |
| 54 | #include <asm/machdep.h> |
| 55 | #include <asm/dma.h> |
| 56 | #include <asm/cputable.h> |
| 57 | #include <asm/time.h> |
Stephen Rothwell | bbeb3f4 | 2005-09-27 13:51:59 +1000 | [diff] [blame] | 58 | #include <asm/mpic.h> |
Nathan Lynch | 9e254c4 | 2006-12-06 18:50:46 -0600 | [diff] [blame] | 59 | #include <asm/rtas.h> |
Paul Mackerras | 40ef8cb | 2005-10-10 22:50:37 +1000 | [diff] [blame] | 60 | #include <asm/udbg.h> |
Nathan Lynch | 4297c98 | 2007-02-05 20:01:15 -0600 | [diff] [blame] | 61 | #include <asm/nvram.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | |
Paul Mackerras | 0cb7b2a | 2005-10-29 22:07:56 +1000 | [diff] [blame] | 63 | #include "maple.h" |
| 64 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | #ifdef DEBUG |
| 66 | #define DBG(fmt...) udbg_printf(fmt) |
| 67 | #else |
| 68 | #define DBG(fmt...) |
| 69 | #endif |
| 70 | |
Benjamin Herrenschmidt | 4c882b0 | 2006-01-14 16:35:35 +1100 | [diff] [blame] | 71 | static unsigned long maple_find_nvram_base(void) |
| 72 | { |
| 73 | struct device_node *rtcs; |
| 74 | unsigned long result = 0; |
| 75 | |
| 76 | /* find NVRAM device */ |
| 77 | rtcs = of_find_compatible_node(NULL, "nvram", "AMD8111"); |
| 78 | if (rtcs) { |
| 79 | struct resource r; |
| 80 | if (of_address_to_resource(rtcs, 0, &r)) { |
| 81 | printk(KERN_EMERG "Maple: Unable to translate NVRAM" |
| 82 | " address\n"); |
| 83 | goto bail; |
| 84 | } |
| 85 | if (!(r.flags & IORESOURCE_IO)) { |
| 86 | printk(KERN_EMERG "Maple: NVRAM address isn't PIO!\n"); |
| 87 | goto bail; |
| 88 | } |
| 89 | result = r.start; |
| 90 | } else |
| 91 | printk(KERN_EMERG "Maple: Unable to find NVRAM\n"); |
| 92 | bail: |
| 93 | of_node_put(rtcs); |
| 94 | return result; |
| 95 | } |
| 96 | |
Daniel Axtens | 95ec77c | 2016-07-12 10:54:52 +1000 | [diff] [blame] | 97 | static void __noreturn maple_restart(char *cmd) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 98 | { |
David Gibson | d7152fe | 2005-06-23 17:14:39 +1000 | [diff] [blame] | 99 | unsigned int maple_nvram_base; |
Jeremy Kerr | eeb2b72 | 2006-07-12 15:40:17 +1000 | [diff] [blame] | 100 | const unsigned int *maple_nvram_offset, *maple_nvram_command; |
Benjamin Herrenschmidt | 4c882b0 | 2006-01-14 16:35:35 +1100 | [diff] [blame] | 101 | struct device_node *sp; |
David Gibson | d7152fe | 2005-06-23 17:14:39 +1000 | [diff] [blame] | 102 | |
Benjamin Herrenschmidt | 4c882b0 | 2006-01-14 16:35:35 +1100 | [diff] [blame] | 103 | maple_nvram_base = maple_find_nvram_base(); |
| 104 | if (maple_nvram_base == 0) |
| 105 | goto fail; |
David Gibson | d7152fe | 2005-06-23 17:14:39 +1000 | [diff] [blame] | 106 | |
| 107 | /* find service processor device */ |
Benjamin Herrenschmidt | 4c882b0 | 2006-01-14 16:35:35 +1100 | [diff] [blame] | 108 | sp = of_find_node_by_name(NULL, "service-processor"); |
| 109 | if (!sp) { |
David Gibson | d7152fe | 2005-06-23 17:14:39 +1000 | [diff] [blame] | 110 | printk(KERN_EMERG "Maple: Unable to find Service Processor\n"); |
Benjamin Herrenschmidt | 4c882b0 | 2006-01-14 16:35:35 +1100 | [diff] [blame] | 111 | goto fail; |
David Gibson | d7152fe | 2005-06-23 17:14:39 +1000 | [diff] [blame] | 112 | } |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 113 | maple_nvram_offset = of_get_property(sp, "restart-addr", NULL); |
| 114 | maple_nvram_command = of_get_property(sp, "restart-value", NULL); |
Benjamin Herrenschmidt | 4c882b0 | 2006-01-14 16:35:35 +1100 | [diff] [blame] | 115 | of_node_put(sp); |
David Gibson | d7152fe | 2005-06-23 17:14:39 +1000 | [diff] [blame] | 116 | |
| 117 | /* send command */ |
Jeremy Kerr | eeb2b72 | 2006-07-12 15:40:17 +1000 | [diff] [blame] | 118 | outb_p(*maple_nvram_command, maple_nvram_base + *maple_nvram_offset); |
David Gibson | d7152fe | 2005-06-23 17:14:39 +1000 | [diff] [blame] | 119 | for (;;) ; |
Benjamin Herrenschmidt | 4c882b0 | 2006-01-14 16:35:35 +1100 | [diff] [blame] | 120 | fail: |
| 121 | printk(KERN_EMERG "Maple: Manual Restart Required\n"); |
Daniel Axtens | 95ec77c | 2016-07-12 10:54:52 +1000 | [diff] [blame] | 122 | for (;;) ; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 123 | } |
| 124 | |
Daniel Axtens | 95ec77c | 2016-07-12 10:54:52 +1000 | [diff] [blame] | 125 | static void __noreturn maple_power_off(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 126 | { |
David Gibson | d7152fe | 2005-06-23 17:14:39 +1000 | [diff] [blame] | 127 | unsigned int maple_nvram_base; |
Jeremy Kerr | eeb2b72 | 2006-07-12 15:40:17 +1000 | [diff] [blame] | 128 | const unsigned int *maple_nvram_offset, *maple_nvram_command; |
Benjamin Herrenschmidt | 4c882b0 | 2006-01-14 16:35:35 +1100 | [diff] [blame] | 129 | struct device_node *sp; |
David Gibson | d7152fe | 2005-06-23 17:14:39 +1000 | [diff] [blame] | 130 | |
Benjamin Herrenschmidt | 4c882b0 | 2006-01-14 16:35:35 +1100 | [diff] [blame] | 131 | maple_nvram_base = maple_find_nvram_base(); |
| 132 | if (maple_nvram_base == 0) |
| 133 | goto fail; |
David Gibson | d7152fe | 2005-06-23 17:14:39 +1000 | [diff] [blame] | 134 | |
| 135 | /* find service processor device */ |
Benjamin Herrenschmidt | 4c882b0 | 2006-01-14 16:35:35 +1100 | [diff] [blame] | 136 | sp = of_find_node_by_name(NULL, "service-processor"); |
| 137 | if (!sp) { |
David Gibson | d7152fe | 2005-06-23 17:14:39 +1000 | [diff] [blame] | 138 | printk(KERN_EMERG "Maple: Unable to find Service Processor\n"); |
Benjamin Herrenschmidt | 4c882b0 | 2006-01-14 16:35:35 +1100 | [diff] [blame] | 139 | goto fail; |
David Gibson | d7152fe | 2005-06-23 17:14:39 +1000 | [diff] [blame] | 140 | } |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 141 | maple_nvram_offset = of_get_property(sp, "power-off-addr", NULL); |
| 142 | maple_nvram_command = of_get_property(sp, "power-off-value", NULL); |
Benjamin Herrenschmidt | 4c882b0 | 2006-01-14 16:35:35 +1100 | [diff] [blame] | 143 | of_node_put(sp); |
David Gibson | d7152fe | 2005-06-23 17:14:39 +1000 | [diff] [blame] | 144 | |
| 145 | /* send command */ |
Jeremy Kerr | eeb2b72 | 2006-07-12 15:40:17 +1000 | [diff] [blame] | 146 | outb_p(*maple_nvram_command, maple_nvram_base + *maple_nvram_offset); |
David Gibson | d7152fe | 2005-06-23 17:14:39 +1000 | [diff] [blame] | 147 | for (;;) ; |
Benjamin Herrenschmidt | 4c882b0 | 2006-01-14 16:35:35 +1100 | [diff] [blame] | 148 | fail: |
| 149 | printk(KERN_EMERG "Maple: Manual Power-Down Required\n"); |
Daniel Axtens | 95ec77c | 2016-07-12 10:54:52 +1000 | [diff] [blame] | 150 | for (;;) ; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 151 | } |
| 152 | |
Daniel Axtens | 95ec77c | 2016-07-12 10:54:52 +1000 | [diff] [blame] | 153 | static void __noreturn maple_halt(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 154 | { |
David Gibson | d7152fe | 2005-06-23 17:14:39 +1000 | [diff] [blame] | 155 | maple_power_off(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 156 | } |
| 157 | |
| 158 | #ifdef CONFIG_SMP |
Daniel Axtens | 7c98bd7 | 2016-09-06 15:32:40 +1000 | [diff] [blame] | 159 | static struct smp_ops_t maple_smp_ops = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 160 | .probe = smp_mpic_probe, |
| 161 | .message_pass = smp_mpic_message_pass, |
| 162 | .kick_cpu = smp_generic_kick_cpu, |
| 163 | .setup_cpu = smp_mpic_setup_cpu, |
| 164 | .give_timebase = smp_generic_give_timebase, |
| 165 | .take_timebase = smp_generic_take_timebase, |
| 166 | }; |
| 167 | #endif /* CONFIG_SMP */ |
| 168 | |
Nathan Lynch | 9e254c4 | 2006-12-06 18:50:46 -0600 | [diff] [blame] | 169 | static void __init maple_use_rtas_reboot_and_halt_if_present(void) |
| 170 | { |
| 171 | if (rtas_service_present("system-reboot") && |
| 172 | rtas_service_present("power-off")) { |
| 173 | ppc_md.restart = rtas_restart; |
Alexander Graf | 9178ba2 | 2014-10-13 16:01:09 +0200 | [diff] [blame] | 174 | pm_power_off = rtas_power_off; |
Nathan Lynch | 9e254c4 | 2006-12-06 18:50:46 -0600 | [diff] [blame] | 175 | ppc_md.halt = rtas_halt; |
| 176 | } |
| 177 | } |
| 178 | |
Daniel Axtens | 7c98bd7 | 2016-09-06 15:32:40 +1000 | [diff] [blame] | 179 | static void __init maple_setup_arch(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 180 | { |
| 181 | /* init to some ~sane value until calibrate_delay() runs */ |
| 182 | loops_per_jiffy = 50000000; |
| 183 | |
| 184 | /* Setup SMP callback */ |
| 185 | #ifdef CONFIG_SMP |
| 186 | smp_ops = &maple_smp_ops; |
| 187 | #endif |
| 188 | /* Lookup PCI hosts */ |
| 189 | maple_pci_init(); |
| 190 | |
| 191 | #ifdef CONFIG_DUMMY_CONSOLE |
| 192 | conswitchp = &dummy_con; |
| 193 | #endif |
Nathan Lynch | 9e254c4 | 2006-12-06 18:50:46 -0600 | [diff] [blame] | 194 | maple_use_rtas_reboot_and_halt_if_present(); |
Michael Ellerman | 62d60e9 | 2005-07-07 17:56:30 -0700 | [diff] [blame] | 195 | |
Olof Johansson | 4baaf0c | 2006-04-12 15:23:22 -0500 | [diff] [blame] | 196 | printk(KERN_DEBUG "Using native/NAP idle loop\n"); |
Nathan Lynch | 4297c98 | 2007-02-05 20:01:15 -0600 | [diff] [blame] | 197 | |
| 198 | mmio_nvram_init(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 199 | } |
| 200 | |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 201 | /* |
| 202 | * This is almost identical to pSeries and CHRP. We need to make that |
| 203 | * code generic at one point, with appropriate bits in the device-tree to |
| 204 | * identify the presence of an HT APIC |
| 205 | */ |
| 206 | static void __init maple_init_IRQ(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 207 | { |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 208 | struct device_node *root, *np, *mpic_node = NULL; |
Jeremy Kerr | eeb2b72 | 2006-07-12 15:40:17 +1000 | [diff] [blame] | 209 | const unsigned int *opprop; |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 210 | unsigned long openpic_addr = 0; |
| 211 | int naddr, n, i, opplen, has_isus = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 212 | struct mpic *mpic; |
Kyle Moffett | be8bec5 | 2011-12-02 06:28:03 +0000 | [diff] [blame] | 213 | unsigned int flags = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 214 | |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 215 | /* Locate MPIC in the device-tree. Note that there is a bug |
| 216 | * in Maple device-tree where the type of the controller is |
| 217 | * open-pic and not interrupt-controller |
| 218 | */ |
Segher Boessenkool | 96278d2 | 2006-07-08 02:37:20 +0200 | [diff] [blame] | 219 | |
| 220 | for_each_node_by_type(np, "interrupt-controller") |
Stephen Rothwell | 55b61fe | 2007-05-03 17:26:52 +1000 | [diff] [blame] | 221 | if (of_device_is_compatible(np, "open-pic")) { |
Segher Boessenkool | 96278d2 | 2006-07-08 02:37:20 +0200 | [diff] [blame] | 222 | mpic_node = np; |
| 223 | break; |
| 224 | } |
| 225 | if (mpic_node == NULL) |
| 226 | for_each_node_by_type(np, "open-pic") { |
| 227 | mpic_node = np; |
| 228 | break; |
| 229 | } |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 230 | if (mpic_node == NULL) { |
| 231 | printk(KERN_ERR |
| 232 | "Failed to locate the MPIC interrupt controller\n"); |
| 233 | return; |
| 234 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 235 | |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 236 | /* Find address list in /platform-open-pic */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 237 | root = of_find_node_by_path("/"); |
Stephen Rothwell | a8bda5d | 2007-04-03 10:56:50 +1000 | [diff] [blame] | 238 | naddr = of_n_addr_cells(root); |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 239 | opprop = of_get_property(root, "platform-open-pic", &opplen); |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 240 | if (opprop != 0) { |
| 241 | openpic_addr = of_read_number(opprop, naddr); |
| 242 | has_isus = (opplen > naddr); |
| 243 | printk(KERN_DEBUG "OpenPIC addr: %lx, has ISUs: %d\n", |
| 244 | openpic_addr, has_isus); |
| 245 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 246 | |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 247 | BUG_ON(openpic_addr == 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 248 | |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 249 | /* Check for a big endian MPIC */ |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 250 | if (of_get_property(np, "big-endian", NULL) != NULL) |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 251 | flags |= MPIC_BIG_ENDIAN; |
| 252 | |
| 253 | /* XXX Maple specific bits */ |
Kyle Moffett | e55d7f7 | 2011-12-22 10:19:14 +0000 | [diff] [blame] | 254 | flags |= MPIC_U3_HT_IRQS; |
Segher Boessenkool | d319a03 | 2006-07-08 02:37:23 +0200 | [diff] [blame] | 255 | /* All U3/U4 are big-endian, older SLOF firmware doesn't encode this */ |
| 256 | flags |= MPIC_BIG_ENDIAN; |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 257 | |
| 258 | /* Setup the openpic driver. More device-tree junks, we hard code no |
| 259 | * ISUs for now. I'll have to revisit some stuffs with the folks doing |
| 260 | * the firmware for those |
| 261 | */ |
| 262 | mpic = mpic_alloc(mpic_node, openpic_addr, flags, |
| 263 | /*has_isus ? 16 :*/ 0, 0, " MPIC "); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 264 | BUG_ON(mpic == NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 265 | |
Benjamin Herrenschmidt | 0ebfff1 | 2006-07-03 21:36:01 +1000 | [diff] [blame] | 266 | /* Add ISUs */ |
| 267 | opplen /= sizeof(u32); |
| 268 | for (n = 0, i = naddr; i < opplen; i += naddr, n++) { |
| 269 | unsigned long isuaddr = of_read_number(opprop + i, naddr); |
| 270 | mpic_assign_isu(mpic, n, isuaddr); |
| 271 | } |
| 272 | |
| 273 | /* All ISUs are setup, complete initialization */ |
| 274 | mpic_init(mpic); |
| 275 | ppc_md.get_irq = mpic_get_irq; |
| 276 | of_node_put(mpic_node); |
| 277 | of_node_put(root); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 278 | } |
| 279 | |
| 280 | static void __init maple_progress(char *s, unsigned short hex) |
| 281 | { |
| 282 | printk("*** %04x : %s\n", hex, s ? s : ""); |
| 283 | } |
| 284 | |
| 285 | |
| 286 | /* |
| 287 | * Called very early, MMU is off, device-tree isn't unflattened |
| 288 | */ |
Benjamin Herrenschmidt | e822250 | 2006-03-28 23:15:54 +1100 | [diff] [blame] | 289 | static int __init maple_probe(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 290 | { |
Benjamin Herrenschmidt | 406b0b6 | 2016-07-05 15:04:00 +1000 | [diff] [blame] | 291 | if (!of_machine_is_compatible("Momentum,Maple") && |
| 292 | !of_machine_is_compatible("Momentum,Apache")) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 293 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 294 | |
Alexander Graf | 9178ba2 | 2014-10-13 16:01:09 +0200 | [diff] [blame] | 295 | pm_power_off = maple_power_off; |
Michael Ellerman | 7d0daae | 2006-06-23 18:16:38 +1000 | [diff] [blame] | 296 | |
Benjamin Herrenschmidt | f2d5769 | 2016-07-05 15:04:06 +1000 | [diff] [blame] | 297 | iommu_init_early_dart(&maple_pci_controller_ops); |
| 298 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 299 | return 1; |
| 300 | } |
| 301 | |
Nathan Lynch | 53378c2 | 2008-03-13 10:43:03 +1100 | [diff] [blame] | 302 | define_machine(maple) { |
Benjamin Herrenschmidt | e822250 | 2006-03-28 23:15:54 +1100 | [diff] [blame] | 303 | .name = "Maple", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 304 | .probe = maple_probe, |
| 305 | .setup_arch = maple_setup_arch, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 306 | .init_IRQ = maple_init_IRQ, |
Benjamin Herrenschmidt | f90bb15 | 2006-11-11 17:24:51 +1100 | [diff] [blame] | 307 | .pci_irq_fixup = maple_pci_irq_fixup, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 308 | .pci_get_legacy_ide_irq = maple_pci_get_legacy_ide_irq, |
| 309 | .restart = maple_restart, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 310 | .halt = maple_halt, |
| 311 | .get_boot_time = maple_get_boot_time, |
| 312 | .set_rtc_time = maple_set_rtc_time, |
| 313 | .get_rtc_time = maple_get_rtc_time, |
Arnd Bergmann | 10f7e7c | 2005-06-23 09:43:07 +1000 | [diff] [blame] | 314 | .calibrate_decr = generic_calibrate_decr, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 315 | .progress = maple_progress, |
Paul Mackerras | a0652fc | 2006-03-27 15:03:03 +1100 | [diff] [blame] | 316 | .power_save = power4_idle, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 317 | }; |
Harry Ciao | 8f101a0 | 2009-06-17 16:28:00 -0700 | [diff] [blame] | 318 | |
| 319 | #ifdef CONFIG_EDAC |
| 320 | /* |
| 321 | * Register a platform device for CPC925 memory controller on |
Dmitry Eremin-Solenikov | 8a0360a | 2011-06-17 02:51:46 +0000 | [diff] [blame] | 322 | * all boards with U3H (CPC925) bridge. |
Harry Ciao | 8f101a0 | 2009-06-17 16:28:00 -0700 | [diff] [blame] | 323 | */ |
Harry Ciao | 8f101a0 | 2009-06-17 16:28:00 -0700 | [diff] [blame] | 324 | static int __init maple_cpc925_edac_setup(void) |
| 325 | { |
| 326 | struct platform_device *pdev; |
| 327 | struct device_node *np = NULL; |
| 328 | struct resource r; |
Harry Ciao | 8f101a0 | 2009-06-17 16:28:00 -0700 | [diff] [blame] | 329 | int ret; |
Dmitry Eremin-Solenikov | 8a0360a | 2011-06-17 02:51:46 +0000 | [diff] [blame] | 330 | volatile void __iomem *mem; |
| 331 | u32 rev; |
Harry Ciao | 8f101a0 | 2009-06-17 16:28:00 -0700 | [diff] [blame] | 332 | |
| 333 | np = of_find_node_by_type(NULL, "memory-controller"); |
| 334 | if (!np) { |
| 335 | printk(KERN_ERR "%s: Unable to find memory-controller node\n", |
| 336 | __func__); |
| 337 | return -ENODEV; |
| 338 | } |
| 339 | |
| 340 | ret = of_address_to_resource(np, 0, &r); |
| 341 | of_node_put(np); |
| 342 | |
| 343 | if (ret < 0) { |
| 344 | printk(KERN_ERR "%s: Unable to get memory-controller reg\n", |
| 345 | __func__); |
| 346 | return -ENODEV; |
| 347 | } |
| 348 | |
Dmitry Eremin-Solenikov | 8a0360a | 2011-06-17 02:51:46 +0000 | [diff] [blame] | 349 | mem = ioremap(r.start, resource_size(&r)); |
| 350 | if (!mem) { |
| 351 | printk(KERN_ERR "%s: Unable to map memory-controller memory\n", |
| 352 | __func__); |
| 353 | return -ENOMEM; |
| 354 | } |
| 355 | |
| 356 | rev = __raw_readl(mem); |
| 357 | iounmap(mem); |
| 358 | |
| 359 | if (rev < 0x34 || rev > 0x3f) { /* U3H */ |
| 360 | printk(KERN_ERR "%s: Non-CPC925(U3H) bridge revision: %02x\n", |
| 361 | __func__, rev); |
| 362 | return 0; |
| 363 | } |
| 364 | |
Harry Ciao | 8f101a0 | 2009-06-17 16:28:00 -0700 | [diff] [blame] | 365 | pdev = platform_device_register_simple("cpc925_edac", 0, &r, 1); |
| 366 | if (IS_ERR(pdev)) |
| 367 | return PTR_ERR(pdev); |
| 368 | |
| 369 | printk(KERN_INFO "%s: CPC925 platform device created\n", __func__); |
| 370 | |
| 371 | return 0; |
| 372 | } |
| 373 | machine_device_initcall(maple, maple_cpc925_edac_setup); |
| 374 | #endif |