Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * linux/arch/arm/mach-integrator/integrator_cp.c |
| 3 | * |
| 4 | * Copyright (C) 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. |
| 9 | */ |
| 10 | #include <linux/types.h> |
| 11 | #include <linux/kernel.h> |
| 12 | #include <linux/init.h> |
| 13 | #include <linux/list.h> |
Russell King | d052d1b | 2005-10-29 19:07:23 +0100 | [diff] [blame] | 14 | #include <linux/platform_device.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | #include <linux/dma-mapping.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | #include <linux/string.h> |
Kay Sievers | edbaa60 | 2011-12-21 16:26:03 -0800 | [diff] [blame] | 17 | #include <linux/device.h> |
Russell King | a62c80e | 2006-01-07 13:52:45 +0000 | [diff] [blame] | 18 | #include <linux/amba/bus.h> |
| 19 | #include <linux/amba/kmi.h> |
| 20 | #include <linux/amba/clcd.h> |
Linus Walleij | 6ef297f | 2009-09-22 14:29:36 +0100 | [diff] [blame] | 21 | #include <linux/amba/mmci.h> |
Russell King | fced80c | 2008-09-06 12:10:45 +0100 | [diff] [blame] | 22 | #include <linux/io.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 23 | #include <linux/gfp.h> |
Marc Zyngier | 046dfa0 | 2011-05-18 10:51:53 +0100 | [diff] [blame] | 24 | #include <linux/mtd/physmap.h> |
Linus Walleij | a613163 | 2012-06-11 17:33:12 +0200 | [diff] [blame] | 25 | #include <linux/platform_data/clk-integrator.h> |
Linus Walleij | 4980f9b | 2012-09-06 09:08:24 +0100 | [diff] [blame] | 26 | #include <linux/of_irq.h> |
| 27 | #include <linux/of_address.h> |
Linus Walleij | 4672cdd | 2012-09-06 09:08:47 +0100 | [diff] [blame] | 28 | #include <linux/of_platform.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 30 | #include <mach/hardware.h> |
Russell King | a285edc | 2010-01-14 19:59:37 +0000 | [diff] [blame] | 31 | #include <mach/platform.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | #include <asm/setup.h> |
| 33 | #include <asm/mach-types.h> |
Russell King | 5a46334 | 2010-01-16 23:52:12 +0000 | [diff] [blame] | 34 | #include <asm/hardware/arm_timer.h> |
Russell King | c5a0adb | 2010-01-16 20:16:10 +0000 | [diff] [blame] | 35 | #include <asm/hardware/icst.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 37 | #include <mach/cm.h> |
| 38 | #include <mach/lm.h> |
Linus Walleij | 695436e | 2012-02-26 10:46:48 +0100 | [diff] [blame] | 39 | #include <mach/irqs.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | |
| 41 | #include <asm/mach/arch.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | #include <asm/mach/irq.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | #include <asm/mach/map.h> |
| 44 | #include <asm/mach/time.h> |
| 45 | |
Rob Herring | 8a9618f | 2010-10-06 16:18:08 +0100 | [diff] [blame] | 46 | #include <asm/hardware/timer-sp.h> |
Russell King | 5a46334 | 2010-01-16 23:52:12 +0000 | [diff] [blame] | 47 | |
Russell King | 9dfec4f | 2011-01-18 20:10:10 +0000 | [diff] [blame] | 48 | #include <plat/clcd.h> |
Russell King | c41b16f | 2011-01-19 15:32:15 +0000 | [diff] [blame] | 49 | #include <plat/fpga-irq.h> |
Russell King | d77e270 | 2011-01-22 11:37:54 +0000 | [diff] [blame] | 50 | #include <plat/sched_clock.h> |
Russell King | 9dfec4f | 2011-01-18 20:10:10 +0000 | [diff] [blame] | 51 | |
Russell King | 98c672c | 2010-05-22 18:18:57 +0100 | [diff] [blame] | 52 | #include "common.h" |
| 53 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | #define INTCP_PA_FLASH_BASE 0x24000000 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | |
| 56 | #define INTCP_PA_CLCD_BASE 0xc0000000 |
| 57 | |
Arnd Bergmann | b7a3f8d | 2012-09-14 20:16:39 +0000 | [diff] [blame] | 58 | #define INTCP_VA_CTRL_BASE __io_address(INTEGRATOR_CP_CTL_BASE) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | #define INTCP_FLASHPROG 0x04 |
| 60 | #define CINTEGRATOR_FLASHPROG_FLVPPEN (1 << 0) |
| 61 | #define CINTEGRATOR_FLASHPROG_FLWREN (1 << 1) |
| 62 | |
| 63 | /* |
| 64 | * Logical Physical |
| 65 | * f1000000 10000000 Core module registers |
| 66 | * f1100000 11000000 System controller registers |
| 67 | * f1200000 12000000 EBI registers |
| 68 | * f1300000 13000000 Counter/Timer |
| 69 | * f1400000 14000000 Interrupt controller |
| 70 | * f1600000 16000000 UART 0 |
| 71 | * f1700000 17000000 UART 1 |
| 72 | * f1a00000 1a000000 Debug LEDs |
Russell King | da7ba95 | 2010-01-17 19:59:58 +0000 | [diff] [blame] | 73 | * fc900000 c9000000 GPIO |
| 74 | * fca00000 ca000000 SIC |
| 75 | * fcb00000 cb000000 CP system control |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | */ |
| 77 | |
| 78 | static struct map_desc intcp_io_desc[] __initdata = { |
Deepak Saxena | c8d2729 | 2005-10-28 15:19:10 +0100 | [diff] [blame] | 79 | { |
| 80 | .virtual = IO_ADDRESS(INTEGRATOR_HDR_BASE), |
| 81 | .pfn = __phys_to_pfn(INTEGRATOR_HDR_BASE), |
| 82 | .length = SZ_4K, |
| 83 | .type = MT_DEVICE |
| 84 | }, { |
| 85 | .virtual = IO_ADDRESS(INTEGRATOR_SC_BASE), |
| 86 | .pfn = __phys_to_pfn(INTEGRATOR_SC_BASE), |
| 87 | .length = SZ_4K, |
| 88 | .type = MT_DEVICE |
| 89 | }, { |
| 90 | .virtual = IO_ADDRESS(INTEGRATOR_EBI_BASE), |
| 91 | .pfn = __phys_to_pfn(INTEGRATOR_EBI_BASE), |
| 92 | .length = SZ_4K, |
| 93 | .type = MT_DEVICE |
| 94 | }, { |
| 95 | .virtual = IO_ADDRESS(INTEGRATOR_CT_BASE), |
| 96 | .pfn = __phys_to_pfn(INTEGRATOR_CT_BASE), |
| 97 | .length = SZ_4K, |
| 98 | .type = MT_DEVICE |
| 99 | }, { |
| 100 | .virtual = IO_ADDRESS(INTEGRATOR_IC_BASE), |
| 101 | .pfn = __phys_to_pfn(INTEGRATOR_IC_BASE), |
| 102 | .length = SZ_4K, |
| 103 | .type = MT_DEVICE |
| 104 | }, { |
| 105 | .virtual = IO_ADDRESS(INTEGRATOR_UART0_BASE), |
| 106 | .pfn = __phys_to_pfn(INTEGRATOR_UART0_BASE), |
| 107 | .length = SZ_4K, |
| 108 | .type = MT_DEVICE |
| 109 | }, { |
| 110 | .virtual = IO_ADDRESS(INTEGRATOR_UART1_BASE), |
| 111 | .pfn = __phys_to_pfn(INTEGRATOR_UART1_BASE), |
| 112 | .length = SZ_4K, |
| 113 | .type = MT_DEVICE |
| 114 | }, { |
| 115 | .virtual = IO_ADDRESS(INTEGRATOR_DBG_BASE), |
| 116 | .pfn = __phys_to_pfn(INTEGRATOR_DBG_BASE), |
| 117 | .length = SZ_4K, |
| 118 | .type = MT_DEVICE |
| 119 | }, { |
Russell King | da7ba95 | 2010-01-17 19:59:58 +0000 | [diff] [blame] | 120 | .virtual = IO_ADDRESS(INTEGRATOR_CP_GPIO_BASE), |
| 121 | .pfn = __phys_to_pfn(INTEGRATOR_CP_GPIO_BASE), |
Deepak Saxena | c8d2729 | 2005-10-28 15:19:10 +0100 | [diff] [blame] | 122 | .length = SZ_4K, |
| 123 | .type = MT_DEVICE |
| 124 | }, { |
Russell King | da7ba95 | 2010-01-17 19:59:58 +0000 | [diff] [blame] | 125 | .virtual = IO_ADDRESS(INTEGRATOR_CP_SIC_BASE), |
| 126 | .pfn = __phys_to_pfn(INTEGRATOR_CP_SIC_BASE), |
Deepak Saxena | c8d2729 | 2005-10-28 15:19:10 +0100 | [diff] [blame] | 127 | .length = SZ_4K, |
| 128 | .type = MT_DEVICE |
| 129 | }, { |
Russell King | da7ba95 | 2010-01-17 19:59:58 +0000 | [diff] [blame] | 130 | .virtual = IO_ADDRESS(INTEGRATOR_CP_CTL_BASE), |
| 131 | .pfn = __phys_to_pfn(INTEGRATOR_CP_CTL_BASE), |
Deepak Saxena | c8d2729 | 2005-10-28 15:19:10 +0100 | [diff] [blame] | 132 | .length = SZ_4K, |
| 133 | .type = MT_DEVICE |
| 134 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 135 | }; |
| 136 | |
| 137 | static void __init intcp_map_io(void) |
| 138 | { |
| 139 | iotable_init(intcp_io_desc, ARRAY_SIZE(intcp_io_desc)); |
| 140 | } |
| 141 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 142 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 143 | * Flash handling. |
| 144 | */ |
Marc Zyngier | 046dfa0 | 2011-05-18 10:51:53 +0100 | [diff] [blame] | 145 | static int intcp_flash_init(struct platform_device *dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | { |
| 147 | u32 val; |
| 148 | |
| 149 | val = readl(INTCP_VA_CTRL_BASE + INTCP_FLASHPROG); |
| 150 | val |= CINTEGRATOR_FLASHPROG_FLWREN; |
| 151 | writel(val, INTCP_VA_CTRL_BASE + INTCP_FLASHPROG); |
| 152 | |
| 153 | return 0; |
| 154 | } |
| 155 | |
Marc Zyngier | 046dfa0 | 2011-05-18 10:51:53 +0100 | [diff] [blame] | 156 | static void intcp_flash_exit(struct platform_device *dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 157 | { |
| 158 | u32 val; |
| 159 | |
| 160 | val = readl(INTCP_VA_CTRL_BASE + INTCP_FLASHPROG); |
| 161 | val &= ~(CINTEGRATOR_FLASHPROG_FLVPPEN|CINTEGRATOR_FLASHPROG_FLWREN); |
| 162 | writel(val, INTCP_VA_CTRL_BASE + INTCP_FLASHPROG); |
| 163 | } |
| 164 | |
Marc Zyngier | 667f390 | 2011-05-18 10:51:55 +0100 | [diff] [blame] | 165 | static void intcp_flash_set_vpp(struct platform_device *pdev, int on) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 166 | { |
| 167 | u32 val; |
| 168 | |
| 169 | val = readl(INTCP_VA_CTRL_BASE + INTCP_FLASHPROG); |
| 170 | if (on) |
| 171 | val |= CINTEGRATOR_FLASHPROG_FLVPPEN; |
| 172 | else |
| 173 | val &= ~CINTEGRATOR_FLASHPROG_FLVPPEN; |
| 174 | writel(val, INTCP_VA_CTRL_BASE + INTCP_FLASHPROG); |
| 175 | } |
| 176 | |
Marc Zyngier | 046dfa0 | 2011-05-18 10:51:53 +0100 | [diff] [blame] | 177 | static struct physmap_flash_data intcp_flash_data = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 178 | .width = 4, |
| 179 | .init = intcp_flash_init, |
| 180 | .exit = intcp_flash_exit, |
| 181 | .set_vpp = intcp_flash_set_vpp, |
| 182 | }; |
| 183 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 184 | /* |
| 185 | * It seems that the card insertion interrupt remains active after |
| 186 | * we've acknowledged it. We therefore ignore the interrupt, and |
| 187 | * rely on reading it from the SIC. This also means that we must |
| 188 | * clear the latched interrupt. |
| 189 | */ |
| 190 | static unsigned int mmc_status(struct device *dev) |
| 191 | { |
Arnd Bergmann | b7a3f8d | 2012-09-14 20:16:39 +0000 | [diff] [blame] | 192 | unsigned int status = readl(__io_address(0xca000000 + 4)); |
| 193 | writel(8, __io_address(INTEGRATOR_CP_CTL_BASE + 8)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 194 | |
| 195 | return status & 8; |
| 196 | } |
| 197 | |
Linus Walleij | 6ef297f | 2009-09-22 14:29:36 +0100 | [diff] [blame] | 198 | static struct mmci_platform_data mmc_data = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 199 | .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, |
| 200 | .status = mmc_status, |
Russell King | 7fb2bbf | 2009-07-09 15:15:12 +0100 | [diff] [blame] | 201 | .gpio_wp = -1, |
| 202 | .gpio_cd = -1, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 203 | }; |
| 204 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 205 | /* |
| 206 | * CLCD support |
| 207 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 208 | /* |
| 209 | * Ensure VGA is selected. |
| 210 | */ |
| 211 | static void cp_clcd_enable(struct clcd_fb *fb) |
| 212 | { |
Russell King | e6b9c1f | 2011-01-22 11:02:10 +0000 | [diff] [blame] | 213 | struct fb_var_screeninfo *var = &fb->fb.var; |
| 214 | u32 val = CM_CTRL_STATIC1 | CM_CTRL_STATIC2; |
Russell King | 4774e22 | 2005-04-30 23:32:38 +0100 | [diff] [blame] | 215 | |
Russell King | e6b9c1f | 2011-01-22 11:02:10 +0000 | [diff] [blame] | 216 | if (var->bits_per_pixel <= 8 || |
| 217 | (var->bits_per_pixel == 16 && var->green.length == 5)) |
| 218 | /* Pseudocolor, RGB555, BGR555 */ |
| 219 | val |= CM_CTRL_LCDMUXSEL_VGA555_TFT555; |
Russell King | 4774e22 | 2005-04-30 23:32:38 +0100 | [diff] [blame] | 220 | else if (fb->fb.var.bits_per_pixel <= 16) |
Russell King | e6b9c1f | 2011-01-22 11:02:10 +0000 | [diff] [blame] | 221 | /* truecolor RGB565 */ |
| 222 | val |= CM_CTRL_LCDMUXSEL_VGA565_TFT555; |
Russell King | 4774e22 | 2005-04-30 23:32:38 +0100 | [diff] [blame] | 223 | else |
| 224 | val = 0; /* no idea for this, don't trust the docs */ |
| 225 | |
| 226 | cm_control(CM_CTRL_LCDMUXSEL_MASK| |
| 227 | CM_CTRL_LCDEN0| |
| 228 | CM_CTRL_LCDEN1| |
| 229 | CM_CTRL_STATIC1| |
| 230 | CM_CTRL_STATIC2| |
| 231 | CM_CTRL_STATIC| |
| 232 | CM_CTRL_n24BITEN, val); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 233 | } |
| 234 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 235 | static int cp_clcd_setup(struct clcd_fb *fb) |
| 236 | { |
Russell King | 9dfec4f | 2011-01-18 20:10:10 +0000 | [diff] [blame] | 237 | fb->panel = versatile_clcd_get_panel("VGA"); |
| 238 | if (!fb->panel) |
| 239 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 240 | |
Russell King | 9dfec4f | 2011-01-18 20:10:10 +0000 | [diff] [blame] | 241 | return versatile_clcd_setup_dma(fb, SZ_1M); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 242 | } |
| 243 | |
| 244 | static struct clcd_board clcd_data = { |
| 245 | .name = "Integrator/CP", |
Russell King | 9dfec4f | 2011-01-18 20:10:10 +0000 | [diff] [blame] | 246 | .caps = CLCD_CAP_5551 | CLCD_CAP_RGB565 | CLCD_CAP_888, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 247 | .check = clcdfb_check, |
| 248 | .decode = clcdfb_decode, |
| 249 | .enable = cp_clcd_enable, |
| 250 | .setup = cp_clcd_setup, |
Russell King | 9dfec4f | 2011-01-18 20:10:10 +0000 | [diff] [blame] | 251 | .mmap = versatile_clcd_mmap_dma, |
| 252 | .remove = versatile_clcd_remove_dma, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 253 | }; |
| 254 | |
Russell King | d77e270 | 2011-01-22 11:37:54 +0000 | [diff] [blame] | 255 | #define REFCOUNTER (__io_address(INTEGRATOR_HDR_BASE) + 0x28) |
| 256 | |
Russell King | c735c98 | 2011-01-11 13:00:04 +0000 | [diff] [blame] | 257 | static void __init intcp_init_early(void) |
| 258 | { |
Russell King | d77e270 | 2011-01-22 11:37:54 +0000 | [diff] [blame] | 259 | #ifdef CONFIG_PLAT_VERSATILE_SCHED_CLOCK |
| 260 | versatile_sched_clock_init(REFCOUNTER, 24000000); |
| 261 | #endif |
Russell King | c735c98 | 2011-01-11 13:00:04 +0000 | [diff] [blame] | 262 | } |
| 263 | |
Olof Johansson | 6e3a78d | 2012-10-07 10:42:40 -0700 | [diff] [blame] | 264 | #ifdef CONFIG_OF |
| 265 | |
Linus Walleij | 4980f9b | 2012-09-06 09:08:24 +0100 | [diff] [blame] | 266 | static void __init intcp_timer_init_of(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 267 | { |
Linus Walleij | 4980f9b | 2012-09-06 09:08:24 +0100 | [diff] [blame] | 268 | struct device_node *node; |
| 269 | const char *path; |
| 270 | void __iomem *base; |
| 271 | int err; |
| 272 | int irq; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 273 | |
Linus Walleij | 4980f9b | 2012-09-06 09:08:24 +0100 | [diff] [blame] | 274 | err = of_property_read_string(of_aliases, |
| 275 | "arm,timer-primary", &path); |
| 276 | if (WARN_ON(err)) |
| 277 | return; |
| 278 | node = of_find_node_by_path(path); |
| 279 | base = of_iomap(node, 0); |
| 280 | if (WARN_ON(!base)) |
| 281 | return; |
| 282 | writel(0, base + TIMER_CTRL); |
| 283 | sp804_clocksource_init(base, node->name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 284 | |
Linus Walleij | 4980f9b | 2012-09-06 09:08:24 +0100 | [diff] [blame] | 285 | err = of_property_read_string(of_aliases, |
| 286 | "arm,timer-secondary", &path); |
| 287 | if (WARN_ON(err)) |
| 288 | return; |
| 289 | node = of_find_node_by_path(path); |
| 290 | base = of_iomap(node, 0); |
| 291 | if (WARN_ON(!base)) |
| 292 | return; |
| 293 | irq = irq_of_parse_and_map(node, 0); |
| 294 | writel(0, base + TIMER_CTRL); |
| 295 | sp804_clockevents_init(base, irq, node->name); |
| 296 | } |
| 297 | |
| 298 | static struct sys_timer cp_of_timer = { |
| 299 | .init = intcp_timer_init_of, |
| 300 | }; |
| 301 | |
Linus Walleij | 4980f9b | 2012-09-06 09:08:24 +0100 | [diff] [blame] | 302 | static const struct of_device_id fpga_irq_of_match[] __initconst = { |
| 303 | { .compatible = "arm,versatile-fpga-irq", .data = fpga_irq_of_init, }, |
| 304 | { /* Sentinel */ } |
| 305 | }; |
| 306 | |
| 307 | static void __init intcp_init_irq_of(void) |
| 308 | { |
| 309 | of_irq_init(fpga_irq_of_match); |
| 310 | integrator_clk_init(true); |
| 311 | } |
| 312 | |
Linus Walleij | 4672cdd | 2012-09-06 09:08:47 +0100 | [diff] [blame] | 313 | /* |
| 314 | * For the Device Tree, add in the UART, MMC and CLCD specifics as AUXDATA |
| 315 | * and enforce the bus names since these are used for clock lookups. |
| 316 | */ |
| 317 | static struct of_dev_auxdata intcp_auxdata_lookup[] __initdata = { |
| 318 | OF_DEV_AUXDATA("arm,primecell", INTEGRATOR_RTC_BASE, |
| 319 | "rtc", NULL), |
| 320 | OF_DEV_AUXDATA("arm,primecell", INTEGRATOR_UART0_BASE, |
| 321 | "uart0", &integrator_uart_data), |
| 322 | OF_DEV_AUXDATA("arm,primecell", INTEGRATOR_UART1_BASE, |
| 323 | "uart1", &integrator_uart_data), |
| 324 | OF_DEV_AUXDATA("arm,primecell", KMI0_BASE, |
| 325 | "kmi0", NULL), |
| 326 | OF_DEV_AUXDATA("arm,primecell", KMI1_BASE, |
| 327 | "kmi1", NULL), |
| 328 | OF_DEV_AUXDATA("arm,primecell", INTEGRATOR_CP_MMC_BASE, |
| 329 | "mmci", &mmc_data), |
| 330 | OF_DEV_AUXDATA("arm,primecell", INTEGRATOR_CP_AACI_BASE, |
| 331 | "aaci", &mmc_data), |
| 332 | OF_DEV_AUXDATA("arm,primecell", INTCP_PA_CLCD_BASE, |
| 333 | "clcd", &clcd_data), |
Linus Walleij | 73efd53 | 2012-09-06 09:09:11 +0100 | [diff] [blame] | 334 | OF_DEV_AUXDATA("cfi-flash", INTCP_PA_FLASH_BASE, |
| 335 | "physmap-flash", &intcp_flash_data), |
Linus Walleij | 4672cdd | 2012-09-06 09:08:47 +0100 | [diff] [blame] | 336 | { /* sentinel */ }, |
| 337 | }; |
| 338 | |
| 339 | static void __init intcp_init_of(void) |
| 340 | { |
| 341 | of_platform_populate(NULL, of_default_bus_match_table, |
| 342 | intcp_auxdata_lookup, NULL); |
Linus Walleij | 4672cdd | 2012-09-06 09:08:47 +0100 | [diff] [blame] | 343 | } |
| 344 | |
Linus Walleij | 4980f9b | 2012-09-06 09:08:24 +0100 | [diff] [blame] | 345 | static const char * intcp_dt_board_compat[] = { |
| 346 | "arm,integrator-cp", |
| 347 | NULL, |
| 348 | }; |
| 349 | |
| 350 | DT_MACHINE_START(INTEGRATOR_CP_DT, "ARM Integrator/CP (Device Tree)") |
| 351 | .reserve = integrator_reserve, |
| 352 | .map_io = intcp_map_io, |
Linus Walleij | 4980f9b | 2012-09-06 09:08:24 +0100 | [diff] [blame] | 353 | .init_early = intcp_init_early, |
| 354 | .init_irq = intcp_init_irq_of, |
| 355 | .handle_irq = fpga_handle_irq, |
| 356 | .timer = &cp_of_timer, |
Linus Walleij | 4672cdd | 2012-09-06 09:08:47 +0100 | [diff] [blame] | 357 | .init_machine = intcp_init_of, |
Linus Walleij | 4980f9b | 2012-09-06 09:08:24 +0100 | [diff] [blame] | 358 | .restart = integrator_restart, |
| 359 | .dt_compat = intcp_dt_board_compat, |
| 360 | MACHINE_END |
| 361 | |
| 362 | #endif |
| 363 | |
| 364 | #ifdef CONFIG_ATAGS |
| 365 | |
| 366 | /* |
| 367 | * This is where non-devicetree initialization code is collected and stashed |
| 368 | * for eventual deletion. |
| 369 | */ |
| 370 | |
Linus Walleij | 73efd53 | 2012-09-06 09:09:11 +0100 | [diff] [blame] | 371 | #define INTCP_FLASH_SIZE SZ_32M |
| 372 | |
| 373 | static struct resource intcp_flash_resource = { |
| 374 | .start = INTCP_PA_FLASH_BASE, |
| 375 | .end = INTCP_PA_FLASH_BASE + INTCP_FLASH_SIZE - 1, |
| 376 | .flags = IORESOURCE_MEM, |
| 377 | }; |
| 378 | |
| 379 | static struct platform_device intcp_flash_device = { |
| 380 | .name = "physmap-flash", |
| 381 | .id = 0, |
| 382 | .dev = { |
| 383 | .platform_data = &intcp_flash_data, |
| 384 | }, |
| 385 | .num_resources = 1, |
| 386 | .resource = &intcp_flash_resource, |
| 387 | }; |
| 388 | |
| 389 | #define INTCP_ETH_SIZE 0x10 |
| 390 | |
| 391 | static struct resource smc91x_resources[] = { |
| 392 | [0] = { |
| 393 | .start = INTEGRATOR_CP_ETH_BASE, |
| 394 | .end = INTEGRATOR_CP_ETH_BASE + INTCP_ETH_SIZE - 1, |
| 395 | .flags = IORESOURCE_MEM, |
| 396 | }, |
| 397 | [1] = { |
| 398 | .start = IRQ_CP_ETHINT, |
| 399 | .end = IRQ_CP_ETHINT, |
| 400 | .flags = IORESOURCE_IRQ, |
| 401 | }, |
| 402 | }; |
| 403 | |
| 404 | static struct platform_device smc91x_device = { |
| 405 | .name = "smc91x", |
| 406 | .id = 0, |
| 407 | .num_resources = ARRAY_SIZE(smc91x_resources), |
| 408 | .resource = smc91x_resources, |
| 409 | }; |
| 410 | |
| 411 | static struct platform_device *intcp_devs[] __initdata = { |
| 412 | &intcp_flash_device, |
| 413 | &smc91x_device, |
| 414 | }; |
| 415 | |
Linus Walleij | 4980f9b | 2012-09-06 09:08:24 +0100 | [diff] [blame] | 416 | #define INTCP_VA_CIC_BASE __io_address(INTEGRATOR_HDR_BASE + 0x40) |
| 417 | #define INTCP_VA_PIC_BASE __io_address(INTEGRATOR_IC_BASE) |
| 418 | #define INTCP_VA_SIC_BASE __io_address(INTEGRATOR_CP_SIC_BASE) |
| 419 | |
| 420 | static void __init intcp_init_irq(void) |
| 421 | { |
| 422 | u32 pic_mask, cic_mask, sic_mask; |
| 423 | |
| 424 | /* These masks are for the HW IRQ registers */ |
Linus Walleij | da72a66 | 2012-10-27 01:24:29 +0200 | [diff] [blame^] | 425 | pic_mask = ~((~0u) << (11 - 0)); |
Linus Walleij | 4980f9b | 2012-09-06 09:08:24 +0100 | [diff] [blame] | 426 | pic_mask |= (~((~0u) << (29 - 22))) << 22; |
| 427 | cic_mask = ~((~0u) << (1 + IRQ_CIC_END - IRQ_CIC_START)); |
| 428 | sic_mask = ~((~0u) << (1 + IRQ_SIC_END - IRQ_SIC_START)); |
| 429 | |
| 430 | /* |
| 431 | * Disable all interrupt sources |
| 432 | */ |
| 433 | writel(0xffffffff, INTCP_VA_PIC_BASE + IRQ_ENABLE_CLEAR); |
| 434 | writel(0xffffffff, INTCP_VA_PIC_BASE + FIQ_ENABLE_CLEAR); |
| 435 | writel(0xffffffff, INTCP_VA_CIC_BASE + IRQ_ENABLE_CLEAR); |
| 436 | writel(0xffffffff, INTCP_VA_CIC_BASE + FIQ_ENABLE_CLEAR); |
| 437 | writel(sic_mask, INTCP_VA_SIC_BASE + IRQ_ENABLE_CLEAR); |
| 438 | writel(sic_mask, INTCP_VA_SIC_BASE + FIQ_ENABLE_CLEAR); |
| 439 | |
| 440 | fpga_irq_init(INTCP_VA_PIC_BASE, "PIC", IRQ_PIC_START, |
| 441 | -1, pic_mask, NULL); |
| 442 | |
| 443 | fpga_irq_init(INTCP_VA_CIC_BASE, "CIC", IRQ_CIC_START, |
| 444 | -1, cic_mask, NULL); |
| 445 | |
| 446 | fpga_irq_init(INTCP_VA_SIC_BASE, "SIC", IRQ_SIC_START, |
| 447 | IRQ_CP_CPPLDINT, sic_mask, NULL); |
| 448 | |
| 449 | integrator_clk_init(true); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 450 | } |
| 451 | |
Russell King | 5a46334 | 2010-01-16 23:52:12 +0000 | [diff] [blame] | 452 | #define TIMER0_VA_BASE __io_address(INTEGRATOR_TIMER0_BASE) |
| 453 | #define TIMER1_VA_BASE __io_address(INTEGRATOR_TIMER1_BASE) |
| 454 | #define TIMER2_VA_BASE __io_address(INTEGRATOR_TIMER2_BASE) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 455 | |
| 456 | static void __init intcp_timer_init(void) |
| 457 | { |
Russell King | 5a46334 | 2010-01-16 23:52:12 +0000 | [diff] [blame] | 458 | writel(0, TIMER0_VA_BASE + TIMER_CTRL); |
| 459 | writel(0, TIMER1_VA_BASE + TIMER_CTRL); |
| 460 | writel(0, TIMER2_VA_BASE + TIMER_CTRL); |
| 461 | |
Russell King | fb593cf | 2011-05-12 12:08:23 +0100 | [diff] [blame] | 462 | sp804_clocksource_init(TIMER2_VA_BASE, "timer2"); |
Russell King | 57cc4f7 | 2011-05-12 15:31:13 +0100 | [diff] [blame] | 463 | sp804_clockevents_init(TIMER1_VA_BASE, IRQ_TIMERINT1, "timer1"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 464 | } |
| 465 | |
| 466 | static struct sys_timer cp_timer = { |
| 467 | .init = intcp_timer_init, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 468 | }; |
| 469 | |
Linus Walleij | 4672cdd | 2012-09-06 09:08:47 +0100 | [diff] [blame] | 470 | #define INTEGRATOR_CP_MMC_IRQS { IRQ_CP_MMCIINT0, IRQ_CP_MMCIINT1 } |
| 471 | #define INTEGRATOR_CP_AACI_IRQS { IRQ_CP_AACIINT } |
| 472 | |
| 473 | static AMBA_APB_DEVICE(mmc, "mmci", 0, INTEGRATOR_CP_MMC_BASE, |
| 474 | INTEGRATOR_CP_MMC_IRQS, &mmc_data); |
| 475 | |
| 476 | static AMBA_APB_DEVICE(aaci, "aaci", 0, INTEGRATOR_CP_AACI_BASE, |
| 477 | INTEGRATOR_CP_AACI_IRQS, NULL); |
| 478 | |
| 479 | static AMBA_AHB_DEVICE(clcd, "clcd", 0, INTCP_PA_CLCD_BASE, |
| 480 | { IRQ_CP_CLCDCINT }, &clcd_data); |
| 481 | |
| 482 | static struct amba_device *amba_devs[] __initdata = { |
| 483 | &mmc_device, |
| 484 | &aaci_device, |
| 485 | &clcd_device, |
| 486 | }; |
| 487 | |
| 488 | static void __init intcp_init(void) |
| 489 | { |
| 490 | int i; |
| 491 | |
| 492 | platform_add_devices(intcp_devs, ARRAY_SIZE(intcp_devs)); |
| 493 | |
| 494 | for (i = 0; i < ARRAY_SIZE(amba_devs); i++) { |
| 495 | struct amba_device *d = amba_devs[i]; |
| 496 | amba_device_register(d, &iomem_resource); |
| 497 | } |
| 498 | integrator_init(true); |
| 499 | } |
| 500 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 501 | MACHINE_START(CINTEGRATOR, "ARM-IntegratorCP") |
Russell King | e9dea0c | 2005-07-03 17:38:58 +0100 | [diff] [blame] | 502 | /* Maintainer: ARM Ltd/Deep Blue Solutions Ltd */ |
Nicolas Pitre | c5e587a | 2011-07-05 22:38:12 -0400 | [diff] [blame] | 503 | .atag_offset = 0x100, |
Russell King | 98c672c | 2010-05-22 18:18:57 +0100 | [diff] [blame] | 504 | .reserve = integrator_reserve, |
Russell King | c735c98 | 2011-01-11 13:00:04 +0000 | [diff] [blame] | 505 | .map_io = intcp_map_io, |
| 506 | .init_early = intcp_init_early, |
Russell King | e9dea0c | 2005-07-03 17:38:58 +0100 | [diff] [blame] | 507 | .init_irq = intcp_init_irq, |
Linus Walleij | 3108e6a | 2012-04-28 14:33:47 +0100 | [diff] [blame] | 508 | .handle_irq = fpga_handle_irq, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 509 | .timer = &cp_timer, |
Russell King | e9dea0c | 2005-07-03 17:38:58 +0100 | [diff] [blame] | 510 | .init_machine = intcp_init, |
Russell King | 6338b66 | 2011-11-03 19:54:37 +0000 | [diff] [blame] | 511 | .restart = integrator_restart, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 512 | MACHINE_END |
Linus Walleij | 4980f9b | 2012-09-06 09:08:24 +0100 | [diff] [blame] | 513 | |
| 514 | #endif |