Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * linux/arch/arm/mach-integrator/integrator_ap.c |
| 3 | * |
| 4 | * Copyright (C) 2000-2003 Deep Blue Solutions Ltd |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 2 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 19 | */ |
| 20 | #include <linux/types.h> |
| 21 | #include <linux/kernel.h> |
| 22 | #include <linux/init.h> |
| 23 | #include <linux/list.h> |
Russell King | d052d1b | 2005-10-29 19:07:23 +0100 | [diff] [blame] | 24 | #include <linux/platform_device.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | #include <linux/slab.h> |
| 26 | #include <linux/string.h> |
Rafael J. Wysocki | b780805 | 2011-04-22 22:02:55 +0200 | [diff] [blame] | 27 | #include <linux/syscore_ops.h> |
Russell King | a62c80e | 2006-01-07 13:52:45 +0000 | [diff] [blame] | 28 | #include <linux/amba/bus.h> |
| 29 | #include <linux/amba/kmi.h> |
Russell King | fced80c | 2008-09-06 12:10:45 +0100 | [diff] [blame] | 30 | #include <linux/io.h> |
Rob Herring | 44fa72d | 2014-05-29 16:44:27 -0500 | [diff] [blame] | 31 | #include <linux/irqchip.h> |
Marc Zyngier | f07e762 | 2011-05-18 10:51:52 +0100 | [diff] [blame] | 32 | #include <linux/mtd/physmap.h> |
Linus Walleij | a613163 | 2012-06-11 17:33:12 +0200 | [diff] [blame] | 33 | #include <linux/platform_data/clk-integrator.h> |
Linus Walleij | 4980f9b | 2012-09-06 09:08:24 +0100 | [diff] [blame] | 34 | #include <linux/of_irq.h> |
| 35 | #include <linux/of_address.h> |
Linus Walleij | 4672cdd | 2012-09-06 09:08:47 +0100 | [diff] [blame] | 36 | #include <linux/of_platform.h> |
Linus Walleij | e67ae6b | 2012-11-02 01:31:10 +0100 | [diff] [blame] | 37 | #include <linux/stat.h> |
Linus Walleij | 379df27 | 2012-11-17 19:24:23 +0100 | [diff] [blame] | 38 | #include <linux/termios.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | #include <asm/setup.h> |
Tim Schmielau | 4e57b68 | 2005-10-30 15:03:48 -0800 | [diff] [blame] | 41 | #include <asm/param.h> /* HZ */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | #include <asm/mach-types.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | #include <asm/mach/arch.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | #include <asm/mach/irq.h> |
| 46 | #include <asm/mach/map.h> |
| 47 | #include <asm/mach/time.h> |
| 48 | |
Linus Walleij | 1b1ef75 | 2014-02-13 21:26:24 +0100 | [diff] [blame] | 49 | #include "hardware.h" |
Linus Walleij | bb4dbef | 2013-06-16 02:44:27 +0200 | [diff] [blame] | 50 | #include "cm.h" |
Russell King | 98c672c | 2010-05-22 18:18:57 +0100 | [diff] [blame] | 51 | #include "common.h" |
Linus Walleij | ae9daf2 | 2013-03-19 19:58:49 +0100 | [diff] [blame] | 52 | #include "pci_v3.h" |
Linus Walleij | c36928a | 2014-02-13 20:01:41 +0100 | [diff] [blame] | 53 | #include "lm.h" |
Russell King | 98c672c | 2010-05-22 18:18:57 +0100 | [diff] [blame] | 54 | |
Linus Walleij | 83feba5 | 2012-11-04 20:49:15 +0100 | [diff] [blame] | 55 | /* Base address to the AP system controller */ |
Linus Walleij | 379df27 | 2012-11-17 19:24:23 +0100 | [diff] [blame] | 56 | void __iomem *ap_syscon_base; |
Linus Walleij | 307b966 | 2013-06-17 23:58:25 +0200 | [diff] [blame] | 57 | /* Base address to the external bus interface */ |
| 58 | static void __iomem *ebi_base; |
Linus Walleij | 83feba5 | 2012-11-04 20:49:15 +0100 | [diff] [blame] | 59 | |
Linus Walleij | 83feba5 | 2012-11-04 20:49:15 +0100 | [diff] [blame] | 60 | |
| 61 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | * All IO addresses are mapped onto VA 0xFFFx.xxxx, where x.xxxx |
| 63 | * is the (PA >> 12). |
| 64 | * |
| 65 | * Setup a VA for the Integrator interrupt controller (for header #0, |
| 66 | * just for now). |
| 67 | */ |
Russell King | c41b16f | 2011-01-19 15:32:15 +0000 | [diff] [blame] | 68 | #define VA_IC_BASE __io_address(INTEGRATOR_IC_BASE) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | |
| 70 | /* |
| 71 | * Logical Physical |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | * ef000000 Cache flush |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | * f1100000 11000000 System controller registers |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | * f1300000 13000000 Counter/Timer |
| 75 | * f1400000 14000000 Interrupt controller |
| 76 | * f1600000 16000000 UART 0 |
| 77 | * f1700000 17000000 UART 1 |
| 78 | * f1a00000 1a000000 Debug LEDs |
| 79 | * f1b00000 1b000000 GPIO |
| 80 | */ |
| 81 | |
Arnd Bergmann | 060fd1b | 2013-02-14 13:50:57 +0100 | [diff] [blame] | 82 | static struct map_desc ap_io_desc[] __initdata __maybe_unused = { |
Deepak Saxena | c8d2729 | 2005-10-28 15:19:10 +0100 | [diff] [blame] | 83 | { |
Deepak Saxena | c8d2729 | 2005-10-28 15:19:10 +0100 | [diff] [blame] | 84 | .virtual = IO_ADDRESS(INTEGRATOR_IC_BASE), |
| 85 | .pfn = __phys_to_pfn(INTEGRATOR_IC_BASE), |
| 86 | .length = SZ_4K, |
| 87 | .type = MT_DEVICE |
| 88 | }, { |
| 89 | .virtual = IO_ADDRESS(INTEGRATOR_UART0_BASE), |
| 90 | .pfn = __phys_to_pfn(INTEGRATOR_UART0_BASE), |
| 91 | .length = SZ_4K, |
| 92 | .type = MT_DEVICE |
| 93 | }, { |
Deepak Saxena | c8d2729 | 2005-10-28 15:19:10 +0100 | [diff] [blame] | 94 | .virtual = IO_ADDRESS(INTEGRATOR_DBG_BASE), |
| 95 | .pfn = __phys_to_pfn(INTEGRATOR_DBG_BASE), |
| 96 | .length = SZ_4K, |
| 97 | .type = MT_DEVICE |
| 98 | }, { |
Russell King | da7ba95 | 2010-01-17 19:59:58 +0000 | [diff] [blame] | 99 | .virtual = IO_ADDRESS(INTEGRATOR_AP_GPIO_BASE), |
| 100 | .pfn = __phys_to_pfn(INTEGRATOR_AP_GPIO_BASE), |
Deepak Saxena | c8d2729 | 2005-10-28 15:19:10 +0100 | [diff] [blame] | 101 | .length = SZ_4K, |
| 102 | .type = MT_DEVICE |
Deepak Saxena | c8d2729 | 2005-10-28 15:19:10 +0100 | [diff] [blame] | 103 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 104 | }; |
| 105 | |
| 106 | static void __init ap_map_io(void) |
| 107 | { |
| 108 | iotable_init(ap_io_desc, ARRAY_SIZE(ap_io_desc)); |
Linus Walleij | ae9daf2 | 2013-03-19 19:58:49 +0100 | [diff] [blame] | 109 | pci_v3_early_init(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 110 | } |
| 111 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 112 | #ifdef CONFIG_PM |
| 113 | static unsigned long ic_irq_enable; |
| 114 | |
Rafael J. Wysocki | b780805 | 2011-04-22 22:02:55 +0200 | [diff] [blame] | 115 | static int irq_suspend(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 116 | { |
| 117 | ic_irq_enable = readl(VA_IC_BASE + IRQ_ENABLE); |
| 118 | return 0; |
| 119 | } |
| 120 | |
Rafael J. Wysocki | b780805 | 2011-04-22 22:02:55 +0200 | [diff] [blame] | 121 | static void irq_resume(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 122 | { |
| 123 | /* disable all irq sources */ |
Linus Walleij | bb4dbef | 2013-06-16 02:44:27 +0200 | [diff] [blame] | 124 | cm_clear_irqs(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 125 | writel(-1, VA_IC_BASE + IRQ_ENABLE_CLEAR); |
| 126 | writel(-1, VA_IC_BASE + FIQ_ENABLE_CLEAR); |
| 127 | |
| 128 | writel(ic_irq_enable, VA_IC_BASE + IRQ_ENABLE_SET); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 129 | } |
| 130 | #else |
| 131 | #define irq_suspend NULL |
| 132 | #define irq_resume NULL |
| 133 | #endif |
| 134 | |
Rafael J. Wysocki | b780805 | 2011-04-22 22:02:55 +0200 | [diff] [blame] | 135 | static struct syscore_ops irq_syscore_ops = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 136 | .suspend = irq_suspend, |
| 137 | .resume = irq_resume, |
| 138 | }; |
| 139 | |
Rafael J. Wysocki | b780805 | 2011-04-22 22:02:55 +0200 | [diff] [blame] | 140 | static int __init irq_syscore_init(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 141 | { |
Rafael J. Wysocki | b780805 | 2011-04-22 22:02:55 +0200 | [diff] [blame] | 142 | register_syscore_ops(&irq_syscore_ops); |
| 143 | |
| 144 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 145 | } |
| 146 | |
Rafael J. Wysocki | b780805 | 2011-04-22 22:02:55 +0200 | [diff] [blame] | 147 | device_initcall(irq_syscore_init); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 148 | |
| 149 | /* |
| 150 | * Flash handling. |
| 151 | */ |
Marc Zyngier | f07e762 | 2011-05-18 10:51:52 +0100 | [diff] [blame] | 152 | static int ap_flash_init(struct platform_device *dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 153 | { |
| 154 | u32 tmp; |
| 155 | |
Linus Walleij | 83feba5 | 2012-11-04 20:49:15 +0100 | [diff] [blame] | 156 | writel(INTEGRATOR_SC_CTRL_nFLVPPEN | INTEGRATOR_SC_CTRL_nFLWP, |
| 157 | ap_syscon_base + INTEGRATOR_SC_CTRLC_OFFSET); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 158 | |
Linus Walleij | 307b966 | 2013-06-17 23:58:25 +0200 | [diff] [blame] | 159 | tmp = readl(ebi_base + INTEGRATOR_EBI_CSR1_OFFSET) | |
| 160 | INTEGRATOR_EBI_WRITE_ENABLE; |
| 161 | writel(tmp, ebi_base + INTEGRATOR_EBI_CSR1_OFFSET); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 162 | |
Linus Walleij | 307b966 | 2013-06-17 23:58:25 +0200 | [diff] [blame] | 163 | if (!(readl(ebi_base + INTEGRATOR_EBI_CSR1_OFFSET) |
| 164 | & INTEGRATOR_EBI_WRITE_ENABLE)) { |
| 165 | writel(0xa05f, ebi_base + INTEGRATOR_EBI_LOCK_OFFSET); |
| 166 | writel(tmp, ebi_base + INTEGRATOR_EBI_CSR1_OFFSET); |
| 167 | writel(0, ebi_base + INTEGRATOR_EBI_LOCK_OFFSET); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 168 | } |
| 169 | return 0; |
| 170 | } |
| 171 | |
Marc Zyngier | f07e762 | 2011-05-18 10:51:52 +0100 | [diff] [blame] | 172 | static void ap_flash_exit(struct platform_device *dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 173 | { |
| 174 | u32 tmp; |
| 175 | |
Linus Walleij | 83feba5 | 2012-11-04 20:49:15 +0100 | [diff] [blame] | 176 | writel(INTEGRATOR_SC_CTRL_nFLVPPEN | INTEGRATOR_SC_CTRL_nFLWP, |
| 177 | ap_syscon_base + INTEGRATOR_SC_CTRLC_OFFSET); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 178 | |
Linus Walleij | 307b966 | 2013-06-17 23:58:25 +0200 | [diff] [blame] | 179 | tmp = readl(ebi_base + INTEGRATOR_EBI_CSR1_OFFSET) & |
| 180 | ~INTEGRATOR_EBI_WRITE_ENABLE; |
| 181 | writel(tmp, ebi_base + INTEGRATOR_EBI_CSR1_OFFSET); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 182 | |
Linus Walleij | 307b966 | 2013-06-17 23:58:25 +0200 | [diff] [blame] | 183 | if (readl(ebi_base + INTEGRATOR_EBI_CSR1_OFFSET) & |
| 184 | INTEGRATOR_EBI_WRITE_ENABLE) { |
| 185 | writel(0xa05f, ebi_base + INTEGRATOR_EBI_LOCK_OFFSET); |
| 186 | writel(tmp, ebi_base + INTEGRATOR_EBI_CSR1_OFFSET); |
| 187 | writel(0, ebi_base + INTEGRATOR_EBI_LOCK_OFFSET); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 188 | } |
| 189 | } |
| 190 | |
Marc Zyngier | 667f390 | 2011-05-18 10:51:55 +0100 | [diff] [blame] | 191 | static void ap_flash_set_vpp(struct platform_device *pdev, int on) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 192 | { |
Linus Walleij | 83feba5 | 2012-11-04 20:49:15 +0100 | [diff] [blame] | 193 | if (on) |
| 194 | writel(INTEGRATOR_SC_CTRL_nFLVPPEN, |
| 195 | ap_syscon_base + INTEGRATOR_SC_CTRLS_OFFSET); |
| 196 | else |
| 197 | writel(INTEGRATOR_SC_CTRL_nFLVPPEN, |
| 198 | ap_syscon_base + INTEGRATOR_SC_CTRLC_OFFSET); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 199 | } |
| 200 | |
Marc Zyngier | f07e762 | 2011-05-18 10:51:52 +0100 | [diff] [blame] | 201 | static struct physmap_flash_data ap_flash_data = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 202 | .width = 4, |
| 203 | .init = ap_flash_init, |
| 204 | .exit = ap_flash_exit, |
| 205 | .set_vpp = ap_flash_set_vpp, |
| 206 | }; |
| 207 | |
Russell King | 6be4826 | 2010-01-17 16:20:56 +0000 | [diff] [blame] | 208 | /* |
Linus Walleij | 379df27 | 2012-11-17 19:24:23 +0100 | [diff] [blame] | 209 | * For the PL010 found in the Integrator/AP some of the UART control is |
| 210 | * implemented in the system controller and accessed using a callback |
| 211 | * from the driver. |
| 212 | */ |
| 213 | static void integrator_uart_set_mctrl(struct amba_device *dev, |
| 214 | void __iomem *base, unsigned int mctrl) |
| 215 | { |
| 216 | unsigned int ctrls = 0, ctrlc = 0, rts_mask, dtr_mask; |
| 217 | u32 phybase = dev->res.start; |
| 218 | |
| 219 | if (phybase == INTEGRATOR_UART0_BASE) { |
| 220 | /* UART0 */ |
| 221 | rts_mask = 1 << 4; |
| 222 | dtr_mask = 1 << 5; |
| 223 | } else { |
| 224 | /* UART1 */ |
| 225 | rts_mask = 1 << 6; |
| 226 | dtr_mask = 1 << 7; |
| 227 | } |
| 228 | |
| 229 | if (mctrl & TIOCM_RTS) |
| 230 | ctrlc |= rts_mask; |
| 231 | else |
| 232 | ctrls |= rts_mask; |
| 233 | |
| 234 | if (mctrl & TIOCM_DTR) |
| 235 | ctrlc |= dtr_mask; |
| 236 | else |
| 237 | ctrls |= dtr_mask; |
| 238 | |
| 239 | __raw_writel(ctrls, ap_syscon_base + INTEGRATOR_SC_CTRLS_OFFSET); |
| 240 | __raw_writel(ctrlc, ap_syscon_base + INTEGRATOR_SC_CTRLC_OFFSET); |
| 241 | } |
| 242 | |
| 243 | struct amba_pl010_data ap_uart_data = { |
| 244 | .set_mctrl = integrator_uart_set_mctrl, |
| 245 | }; |
| 246 | |
Linus Walleij | a613163 | 2012-06-11 17:33:12 +0200 | [diff] [blame] | 247 | void __init ap_init_early(void) |
| 248 | { |
| 249 | } |
| 250 | |
Linus Walleij | 4980f9b | 2012-09-06 09:08:24 +0100 | [diff] [blame] | 251 | static void __init ap_init_irq_of(void) |
| 252 | { |
Linus Walleij | bb4dbef | 2013-06-16 02:44:27 +0200 | [diff] [blame] | 253 | cm_init(); |
Rob Herring | 44fa72d | 2014-05-29 16:44:27 -0500 | [diff] [blame] | 254 | irqchip_init(); |
Linus Walleij | 4980f9b | 2012-09-06 09:08:24 +0100 | [diff] [blame] | 255 | } |
| 256 | |
Linus Walleij | 4672cdd | 2012-09-06 09:08:47 +0100 | [diff] [blame] | 257 | /* For the Device Tree, add in the UART callbacks as AUXDATA */ |
| 258 | static struct of_dev_auxdata ap_auxdata_lookup[] __initdata = { |
| 259 | OF_DEV_AUXDATA("arm,primecell", INTEGRATOR_RTC_BASE, |
| 260 | "rtc", NULL), |
| 261 | OF_DEV_AUXDATA("arm,primecell", INTEGRATOR_UART0_BASE, |
Linus Walleij | 379df27 | 2012-11-17 19:24:23 +0100 | [diff] [blame] | 262 | "uart0", &ap_uart_data), |
Linus Walleij | 4672cdd | 2012-09-06 09:08:47 +0100 | [diff] [blame] | 263 | OF_DEV_AUXDATA("arm,primecell", INTEGRATOR_UART1_BASE, |
Linus Walleij | 379df27 | 2012-11-17 19:24:23 +0100 | [diff] [blame] | 264 | "uart1", &ap_uart_data), |
Linus Walleij | 4672cdd | 2012-09-06 09:08:47 +0100 | [diff] [blame] | 265 | OF_DEV_AUXDATA("arm,primecell", KMI0_BASE, |
| 266 | "kmi0", NULL), |
| 267 | OF_DEV_AUXDATA("arm,primecell", KMI1_BASE, |
| 268 | "kmi1", NULL), |
Linus Walleij | 73efd53 | 2012-09-06 09:09:11 +0100 | [diff] [blame] | 269 | OF_DEV_AUXDATA("cfi-flash", INTEGRATOR_FLASH_BASE, |
| 270 | "physmap-flash", &ap_flash_data), |
Linus Walleij | 4672cdd | 2012-09-06 09:08:47 +0100 | [diff] [blame] | 271 | { /* sentinel */ }, |
| 272 | }; |
| 273 | |
Linus Walleij | df36680 | 2013-10-10 18:24:58 +0200 | [diff] [blame] | 274 | static const struct of_device_id ap_syscon_match[] = { |
| 275 | { .compatible = "arm,integrator-ap-syscon"}, |
| 276 | { }, |
| 277 | }; |
| 278 | |
Linus Walleij | 307b966 | 2013-06-17 23:58:25 +0200 | [diff] [blame] | 279 | static const struct of_device_id ebi_match[] = { |
| 280 | { .compatible = "arm,external-bus-interface"}, |
| 281 | { }, |
| 282 | }; |
| 283 | |
Linus Walleij | 4672cdd | 2012-09-06 09:08:47 +0100 | [diff] [blame] | 284 | static void __init ap_init_of(void) |
| 285 | { |
| 286 | unsigned long sc_dec; |
Linus Walleij | e67ae6b | 2012-11-02 01:31:10 +0100 | [diff] [blame] | 287 | struct device_node *syscon; |
Linus Walleij | 307b966 | 2013-06-17 23:58:25 +0200 | [diff] [blame] | 288 | struct device_node *ebi; |
Linus Walleij | 4672cdd | 2012-09-06 09:08:47 +0100 | [diff] [blame] | 289 | int i; |
| 290 | |
Linus Walleij | 11f9323 | 2014-06-24 14:08:07 +0200 | [diff] [blame] | 291 | syscon = of_find_matching_node(NULL, ap_syscon_match); |
Linus Walleij | e67ae6b | 2012-11-02 01:31:10 +0100 | [diff] [blame] | 292 | if (!syscon) |
| 293 | return; |
Linus Walleij | 11f9323 | 2014-06-24 14:08:07 +0200 | [diff] [blame] | 294 | ebi = of_find_matching_node(NULL, ebi_match); |
Linus Walleij | 307b966 | 2013-06-17 23:58:25 +0200 | [diff] [blame] | 295 | if (!ebi) |
| 296 | return; |
Linus Walleij | e67ae6b | 2012-11-02 01:31:10 +0100 | [diff] [blame] | 297 | |
| 298 | ap_syscon_base = of_iomap(syscon, 0); |
| 299 | if (!ap_syscon_base) |
| 300 | return; |
Linus Walleij | 307b966 | 2013-06-17 23:58:25 +0200 | [diff] [blame] | 301 | ebi_base = of_iomap(ebi, 0); |
| 302 | if (!ebi_base) |
| 303 | return; |
Linus Walleij | e67ae6b | 2012-11-02 01:31:10 +0100 | [diff] [blame] | 304 | |
Linus Walleij | 11f9323 | 2014-06-24 14:08:07 +0200 | [diff] [blame] | 305 | of_platform_populate(NULL, of_default_bus_match_table, |
| 306 | ap_auxdata_lookup, NULL); |
| 307 | |
Linus Walleij | 83feba5 | 2012-11-04 20:49:15 +0100 | [diff] [blame] | 308 | sc_dec = readl(ap_syscon_base + INTEGRATOR_SC_DEC_OFFSET); |
Linus Walleij | 4672cdd | 2012-09-06 09:08:47 +0100 | [diff] [blame] | 309 | for (i = 0; i < 4; i++) { |
| 310 | struct lm_device *lmdev; |
| 311 | |
| 312 | if ((sc_dec & (16 << i)) == 0) |
| 313 | continue; |
| 314 | |
| 315 | lmdev = kzalloc(sizeof(struct lm_device), GFP_KERNEL); |
| 316 | if (!lmdev) |
| 317 | continue; |
| 318 | |
| 319 | lmdev->resource.start = 0xc0000000 + 0x10000000 * i; |
| 320 | lmdev->resource.end = lmdev->resource.start + 0x0fffffff; |
| 321 | lmdev->resource.flags = IORESOURCE_MEM; |
Linus Walleij | a672025 | 2013-06-15 23:56:32 +0200 | [diff] [blame] | 322 | lmdev->irq = irq_of_parse_and_map(syscon, i); |
Linus Walleij | 4672cdd | 2012-09-06 09:08:47 +0100 | [diff] [blame] | 323 | lmdev->id = i; |
| 324 | |
| 325 | lm_device_register(lmdev); |
| 326 | } |
| 327 | } |
| 328 | |
Linus Walleij | 4980f9b | 2012-09-06 09:08:24 +0100 | [diff] [blame] | 329 | static const char * ap_dt_board_compat[] = { |
| 330 | "arm,integrator-ap", |
| 331 | NULL, |
| 332 | }; |
| 333 | |
| 334 | DT_MACHINE_START(INTEGRATOR_AP_DT, "ARM Integrator/AP (Device Tree)") |
| 335 | .reserve = integrator_reserve, |
| 336 | .map_io = ap_map_io, |
Linus Walleij | 4980f9b | 2012-09-06 09:08:24 +0100 | [diff] [blame] | 337 | .init_early = ap_init_early, |
| 338 | .init_irq = ap_init_irq_of, |
Linus Walleij | 4672cdd | 2012-09-06 09:08:47 +0100 | [diff] [blame] | 339 | .init_machine = ap_init_of, |
Linus Walleij | 4980f9b | 2012-09-06 09:08:24 +0100 | [diff] [blame] | 340 | .dt_compat = ap_dt_board_compat, |
| 341 | MACHINE_END |