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