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> |
| 17 | #include <linux/sysdev.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> |
Jean-Christop PLAGNIOL-VILLARD | 6d803ba | 2010-11-17 10:04:33 +0100 | [diff] [blame] | 24 | #include <linux/clkdev.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 26 | #include <mach/hardware.h> |
Russell King | a285edc | 2010-01-14 19:59:37 +0000 | [diff] [blame] | 27 | #include <mach/platform.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | #include <asm/irq.h> |
| 29 | #include <asm/setup.h> |
| 30 | #include <asm/mach-types.h> |
Russell King | 5a46334 | 2010-01-16 23:52:12 +0000 | [diff] [blame] | 31 | #include <asm/hardware/arm_timer.h> |
Russell King | c5a0adb | 2010-01-16 20:16:10 +0000 | [diff] [blame] | 32 | #include <asm/hardware/icst.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 34 | #include <mach/cm.h> |
| 35 | #include <mach/lm.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | |
| 37 | #include <asm/mach/arch.h> |
| 38 | #include <asm/mach/flash.h> |
| 39 | #include <asm/mach/irq.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | #include <asm/mach/map.h> |
| 41 | #include <asm/mach/time.h> |
| 42 | |
Rob Herring | 8a9618f | 2010-10-06 16:18:08 +0100 | [diff] [blame] | 43 | #include <asm/hardware/timer-sp.h> |
Russell King | 5a46334 | 2010-01-16 23:52:12 +0000 | [diff] [blame] | 44 | |
Russell King | 9dfec4f | 2011-01-18 20:10:10 +0000 | [diff] [blame] | 45 | #include <plat/clcd.h> |
Russell King | c41b16f | 2011-01-19 15:32:15 +0000 | [diff] [blame^] | 46 | #include <plat/fpga-irq.h> |
Russell King | 9dfec4f | 2011-01-18 20:10:10 +0000 | [diff] [blame] | 47 | |
Russell King | 98c672c | 2010-05-22 18:18:57 +0100 | [diff] [blame] | 48 | #include "common.h" |
| 49 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | #define INTCP_PA_FLASH_BASE 0x24000000 |
| 51 | #define INTCP_FLASH_SIZE SZ_32M |
| 52 | |
| 53 | #define INTCP_PA_CLCD_BASE 0xc0000000 |
| 54 | |
Russell King | c41b16f | 2011-01-19 15:32:15 +0000 | [diff] [blame^] | 55 | #define INTCP_VA_CIC_BASE __io_address(INTEGRATOR_HDR_BASE + 0x40) |
| 56 | #define INTCP_VA_PIC_BASE __io_address(INTEGRATOR_IC_BASE) |
| 57 | #define INTCP_VA_SIC_BASE __io_address(INTEGRATOR_CP_SIC_BASE) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | #define INTCP_ETH_SIZE 0x10 |
| 60 | |
Russell King | da7ba95 | 2010-01-17 19:59:58 +0000 | [diff] [blame] | 61 | #define INTCP_VA_CTRL_BASE IO_ADDRESS(INTEGRATOR_CP_CTL_BASE) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | #define INTCP_FLASHPROG 0x04 |
| 63 | #define CINTEGRATOR_FLASHPROG_FLVPPEN (1 << 0) |
| 64 | #define CINTEGRATOR_FLASHPROG_FLWREN (1 << 1) |
| 65 | |
| 66 | /* |
| 67 | * Logical Physical |
| 68 | * f1000000 10000000 Core module registers |
| 69 | * f1100000 11000000 System controller registers |
| 70 | * f1200000 12000000 EBI registers |
| 71 | * f1300000 13000000 Counter/Timer |
| 72 | * f1400000 14000000 Interrupt controller |
| 73 | * f1600000 16000000 UART 0 |
| 74 | * f1700000 17000000 UART 1 |
| 75 | * f1a00000 1a000000 Debug LEDs |
Russell King | da7ba95 | 2010-01-17 19:59:58 +0000 | [diff] [blame] | 76 | * fc900000 c9000000 GPIO |
| 77 | * fca00000 ca000000 SIC |
| 78 | * fcb00000 cb000000 CP system control |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 79 | */ |
| 80 | |
| 81 | static struct map_desc intcp_io_desc[] __initdata = { |
Deepak Saxena | c8d2729 | 2005-10-28 15:19:10 +0100 | [diff] [blame] | 82 | { |
| 83 | .virtual = IO_ADDRESS(INTEGRATOR_HDR_BASE), |
| 84 | .pfn = __phys_to_pfn(INTEGRATOR_HDR_BASE), |
| 85 | .length = SZ_4K, |
| 86 | .type = MT_DEVICE |
| 87 | }, { |
| 88 | .virtual = IO_ADDRESS(INTEGRATOR_SC_BASE), |
| 89 | .pfn = __phys_to_pfn(INTEGRATOR_SC_BASE), |
| 90 | .length = SZ_4K, |
| 91 | .type = MT_DEVICE |
| 92 | }, { |
| 93 | .virtual = IO_ADDRESS(INTEGRATOR_EBI_BASE), |
| 94 | .pfn = __phys_to_pfn(INTEGRATOR_EBI_BASE), |
| 95 | .length = SZ_4K, |
| 96 | .type = MT_DEVICE |
| 97 | }, { |
| 98 | .virtual = IO_ADDRESS(INTEGRATOR_CT_BASE), |
| 99 | .pfn = __phys_to_pfn(INTEGRATOR_CT_BASE), |
| 100 | .length = SZ_4K, |
| 101 | .type = MT_DEVICE |
| 102 | }, { |
| 103 | .virtual = IO_ADDRESS(INTEGRATOR_IC_BASE), |
| 104 | .pfn = __phys_to_pfn(INTEGRATOR_IC_BASE), |
| 105 | .length = SZ_4K, |
| 106 | .type = MT_DEVICE |
| 107 | }, { |
| 108 | .virtual = IO_ADDRESS(INTEGRATOR_UART0_BASE), |
| 109 | .pfn = __phys_to_pfn(INTEGRATOR_UART0_BASE), |
| 110 | .length = SZ_4K, |
| 111 | .type = MT_DEVICE |
| 112 | }, { |
| 113 | .virtual = IO_ADDRESS(INTEGRATOR_UART1_BASE), |
| 114 | .pfn = __phys_to_pfn(INTEGRATOR_UART1_BASE), |
| 115 | .length = SZ_4K, |
| 116 | .type = MT_DEVICE |
| 117 | }, { |
| 118 | .virtual = IO_ADDRESS(INTEGRATOR_DBG_BASE), |
| 119 | .pfn = __phys_to_pfn(INTEGRATOR_DBG_BASE), |
| 120 | .length = SZ_4K, |
| 121 | .type = MT_DEVICE |
| 122 | }, { |
Russell King | da7ba95 | 2010-01-17 19:59:58 +0000 | [diff] [blame] | 123 | .virtual = IO_ADDRESS(INTEGRATOR_CP_GPIO_BASE), |
| 124 | .pfn = __phys_to_pfn(INTEGRATOR_CP_GPIO_BASE), |
Deepak Saxena | c8d2729 | 2005-10-28 15:19:10 +0100 | [diff] [blame] | 125 | .length = SZ_4K, |
| 126 | .type = MT_DEVICE |
| 127 | }, { |
Russell King | da7ba95 | 2010-01-17 19:59:58 +0000 | [diff] [blame] | 128 | .virtual = IO_ADDRESS(INTEGRATOR_CP_SIC_BASE), |
| 129 | .pfn = __phys_to_pfn(INTEGRATOR_CP_SIC_BASE), |
Deepak Saxena | c8d2729 | 2005-10-28 15:19:10 +0100 | [diff] [blame] | 130 | .length = SZ_4K, |
| 131 | .type = MT_DEVICE |
| 132 | }, { |
Russell King | da7ba95 | 2010-01-17 19:59:58 +0000 | [diff] [blame] | 133 | .virtual = IO_ADDRESS(INTEGRATOR_CP_CTL_BASE), |
| 134 | .pfn = __phys_to_pfn(INTEGRATOR_CP_CTL_BASE), |
Deepak Saxena | c8d2729 | 2005-10-28 15:19:10 +0100 | [diff] [blame] | 135 | .length = SZ_4K, |
| 136 | .type = MT_DEVICE |
| 137 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 138 | }; |
| 139 | |
| 140 | static void __init intcp_map_io(void) |
| 141 | { |
| 142 | iotable_init(intcp_io_desc, ARRAY_SIZE(intcp_io_desc)); |
| 143 | } |
| 144 | |
Russell King | c41b16f | 2011-01-19 15:32:15 +0000 | [diff] [blame^] | 145 | static struct fpga_irq_data cic_irq_data = { |
| 146 | .base = INTCP_VA_CIC_BASE, |
| 147 | .irq_start = IRQ_CIC_START, |
| 148 | .chip.name = "CIC", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 149 | }; |
| 150 | |
Russell King | c41b16f | 2011-01-19 15:32:15 +0000 | [diff] [blame^] | 151 | static struct fpga_irq_data pic_irq_data = { |
| 152 | .base = INTCP_VA_PIC_BASE, |
| 153 | .irq_start = IRQ_PIC_START, |
| 154 | .chip.name = "PIC", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 155 | }; |
| 156 | |
Russell King | c41b16f | 2011-01-19 15:32:15 +0000 | [diff] [blame^] | 157 | static struct fpga_irq_data sic_irq_data = { |
| 158 | .base = INTCP_VA_SIC_BASE, |
| 159 | .irq_start = IRQ_SIC_START, |
| 160 | .chip.name = "SIC", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 161 | }; |
| 162 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 163 | static void __init intcp_init_irq(void) |
| 164 | { |
Russell King | c41b16f | 2011-01-19 15:32:15 +0000 | [diff] [blame^] | 165 | u32 pic_mask, sic_mask; |
| 166 | |
| 167 | pic_mask = ~((~0u) << (11 - IRQ_PIC_START)); |
| 168 | pic_mask |= (~((~0u) << (29 - 22))) << 22; |
| 169 | sic_mask = ~((~0u) << (1 + IRQ_SIC_END - IRQ_SIC_START)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 170 | |
| 171 | /* |
| 172 | * Disable all interrupt sources |
| 173 | */ |
Russell King | c41b16f | 2011-01-19 15:32:15 +0000 | [diff] [blame^] | 174 | writel(0xffffffff, INTCP_VA_PIC_BASE + IRQ_ENABLE_CLEAR); |
| 175 | writel(0xffffffff, INTCP_VA_PIC_BASE + FIQ_ENABLE_CLEAR); |
| 176 | writel(0xffffffff, INTCP_VA_CIC_BASE + IRQ_ENABLE_CLEAR); |
| 177 | writel(0xffffffff, INTCP_VA_CIC_BASE + FIQ_ENABLE_CLEAR); |
| 178 | writel(sic_mask, INTCP_VA_SIC_BASE + IRQ_ENABLE_CLEAR); |
| 179 | writel(sic_mask, INTCP_VA_SIC_BASE + FIQ_ENABLE_CLEAR); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 180 | |
Russell King | c41b16f | 2011-01-19 15:32:15 +0000 | [diff] [blame^] | 181 | fpga_irq_init(-1, pic_mask, &pic_irq_data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 182 | |
Russell King | c41b16f | 2011-01-19 15:32:15 +0000 | [diff] [blame^] | 183 | fpga_irq_init(-1, ~((~0u) << (1 + IRQ_CIC_END - IRQ_CIC_START)), |
| 184 | &cic_irq_data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 185 | |
Russell King | c41b16f | 2011-01-19 15:32:15 +0000 | [diff] [blame^] | 186 | fpga_irq_init(IRQ_CP_CPPLDINT, sic_mask, &sic_irq_data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 187 | } |
| 188 | |
| 189 | /* |
| 190 | * Clock handling |
| 191 | */ |
Russell King | d1914c7 | 2010-01-14 20:09:34 +0000 | [diff] [blame] | 192 | #define CM_LOCK (__io_address(INTEGRATOR_HDR_BASE)+INTEGRATOR_HDR_LOCK_OFFSET) |
| 193 | #define CM_AUXOSC (__io_address(INTEGRATOR_HDR_BASE)+0x1c) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 194 | |
Russell King | 39c0cb0 | 2010-01-16 16:27:28 +0000 | [diff] [blame] | 195 | static const struct icst_params cp_auxvco_params = { |
Russell King | 64fceb1 | 2010-01-16 17:28:44 +0000 | [diff] [blame] | 196 | .ref = 24000000, |
Russell King | 4de2edb | 2010-01-16 18:08:47 +0000 | [diff] [blame] | 197 | .vco_max = ICST525_VCO_MAX_5V, |
Russell King | e73a46a | 2010-01-16 19:49:39 +0000 | [diff] [blame] | 198 | .vco_min = ICST525_VCO_MIN, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 199 | .vd_min = 8, |
| 200 | .vd_max = 263, |
| 201 | .rd_min = 3, |
| 202 | .rd_max = 65, |
Russell King | 232eaf7 | 2010-01-16 19:46:19 +0000 | [diff] [blame] | 203 | .s2div = icst525_s2div, |
| 204 | .idx2s = icst525_idx2s, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 205 | }; |
| 206 | |
Russell King | 39c0cb0 | 2010-01-16 16:27:28 +0000 | [diff] [blame] | 207 | static void cp_auxvco_set(struct clk *clk, struct icst_vco vco) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 208 | { |
| 209 | u32 val; |
| 210 | |
Russell King | d1914c7 | 2010-01-14 20:09:34 +0000 | [diff] [blame] | 211 | val = readl(clk->vcoreg) & ~0x7ffff; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 212 | val |= vco.v | (vco.r << 9) | (vco.s << 16); |
| 213 | |
| 214 | writel(0xa05f, CM_LOCK); |
Russell King | d1914c7 | 2010-01-14 20:09:34 +0000 | [diff] [blame] | 215 | writel(val, clk->vcoreg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 216 | writel(0, CM_LOCK); |
| 217 | } |
| 218 | |
Russell King | 9bf5b2e | 2010-03-01 16:18:39 +0000 | [diff] [blame] | 219 | static const struct clk_ops cp_auxclk_ops = { |
| 220 | .round = icst_clk_round, |
| 221 | .set = icst_clk_set, |
| 222 | .setvco = cp_auxvco_set, |
| 223 | }; |
| 224 | |
Russell King | d72fbdf | 2008-11-08 20:08:08 +0000 | [diff] [blame] | 225 | static struct clk cp_auxclk = { |
Russell King | 9bf5b2e | 2010-03-01 16:18:39 +0000 | [diff] [blame] | 226 | .ops = &cp_auxclk_ops, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 227 | .params = &cp_auxvco_params, |
Russell King | d1914c7 | 2010-01-14 20:09:34 +0000 | [diff] [blame] | 228 | .vcoreg = CM_AUXOSC, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 229 | }; |
| 230 | |
Russell King | d72fbdf | 2008-11-08 20:08:08 +0000 | [diff] [blame] | 231 | static struct clk_lookup cp_lookups[] = { |
| 232 | { /* CLCD */ |
| 233 | .dev_id = "mb:c0", |
| 234 | .clk = &cp_auxclk, |
| 235 | }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 236 | }; |
| 237 | |
| 238 | /* |
| 239 | * Flash handling. |
| 240 | */ |
| 241 | static int intcp_flash_init(void) |
| 242 | { |
| 243 | u32 val; |
| 244 | |
| 245 | val = readl(INTCP_VA_CTRL_BASE + INTCP_FLASHPROG); |
| 246 | val |= CINTEGRATOR_FLASHPROG_FLWREN; |
| 247 | writel(val, INTCP_VA_CTRL_BASE + INTCP_FLASHPROG); |
| 248 | |
| 249 | return 0; |
| 250 | } |
| 251 | |
| 252 | static void intcp_flash_exit(void) |
| 253 | { |
| 254 | u32 val; |
| 255 | |
| 256 | val = readl(INTCP_VA_CTRL_BASE + INTCP_FLASHPROG); |
| 257 | val &= ~(CINTEGRATOR_FLASHPROG_FLVPPEN|CINTEGRATOR_FLASHPROG_FLWREN); |
| 258 | writel(val, INTCP_VA_CTRL_BASE + INTCP_FLASHPROG); |
| 259 | } |
| 260 | |
| 261 | static void intcp_flash_set_vpp(int on) |
| 262 | { |
| 263 | u32 val; |
| 264 | |
| 265 | val = readl(INTCP_VA_CTRL_BASE + INTCP_FLASHPROG); |
| 266 | if (on) |
| 267 | val |= CINTEGRATOR_FLASHPROG_FLVPPEN; |
| 268 | else |
| 269 | val &= ~CINTEGRATOR_FLASHPROG_FLVPPEN; |
| 270 | writel(val, INTCP_VA_CTRL_BASE + INTCP_FLASHPROG); |
| 271 | } |
| 272 | |
| 273 | static struct flash_platform_data intcp_flash_data = { |
| 274 | .map_name = "cfi_probe", |
| 275 | .width = 4, |
| 276 | .init = intcp_flash_init, |
| 277 | .exit = intcp_flash_exit, |
| 278 | .set_vpp = intcp_flash_set_vpp, |
| 279 | }; |
| 280 | |
| 281 | static struct resource intcp_flash_resource = { |
| 282 | .start = INTCP_PA_FLASH_BASE, |
| 283 | .end = INTCP_PA_FLASH_BASE + INTCP_FLASH_SIZE - 1, |
| 284 | .flags = IORESOURCE_MEM, |
| 285 | }; |
| 286 | |
| 287 | static struct platform_device intcp_flash_device = { |
| 288 | .name = "armflash", |
| 289 | .id = 0, |
| 290 | .dev = { |
| 291 | .platform_data = &intcp_flash_data, |
| 292 | }, |
| 293 | .num_resources = 1, |
| 294 | .resource = &intcp_flash_resource, |
| 295 | }; |
| 296 | |
| 297 | static struct resource smc91x_resources[] = { |
| 298 | [0] = { |
Russell King | da7ba95 | 2010-01-17 19:59:58 +0000 | [diff] [blame] | 299 | .start = INTEGRATOR_CP_ETH_BASE, |
| 300 | .end = INTEGRATOR_CP_ETH_BASE + INTCP_ETH_SIZE - 1, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 301 | .flags = IORESOURCE_MEM, |
| 302 | }, |
| 303 | [1] = { |
| 304 | .start = IRQ_CP_ETHINT, |
| 305 | .end = IRQ_CP_ETHINT, |
| 306 | .flags = IORESOURCE_IRQ, |
| 307 | }, |
| 308 | }; |
| 309 | |
| 310 | static struct platform_device smc91x_device = { |
| 311 | .name = "smc91x", |
| 312 | .id = 0, |
| 313 | .num_resources = ARRAY_SIZE(smc91x_resources), |
| 314 | .resource = smc91x_resources, |
| 315 | }; |
| 316 | |
| 317 | static struct platform_device *intcp_devs[] __initdata = { |
| 318 | &intcp_flash_device, |
| 319 | &smc91x_device, |
| 320 | }; |
| 321 | |
| 322 | /* |
| 323 | * It seems that the card insertion interrupt remains active after |
| 324 | * we've acknowledged it. We therefore ignore the interrupt, and |
| 325 | * rely on reading it from the SIC. This also means that we must |
| 326 | * clear the latched interrupt. |
| 327 | */ |
| 328 | static unsigned int mmc_status(struct device *dev) |
| 329 | { |
Russell King | b830b9b | 2010-01-17 20:45:12 +0000 | [diff] [blame] | 330 | unsigned int status = readl(IO_ADDRESS(0xca000000 + 4)); |
| 331 | writel(8, IO_ADDRESS(INTEGRATOR_CP_CTL_BASE + 8)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 332 | |
| 333 | return status & 8; |
| 334 | } |
| 335 | |
Linus Walleij | 6ef297f | 2009-09-22 14:29:36 +0100 | [diff] [blame] | 336 | static struct mmci_platform_data mmc_data = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 337 | .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, |
| 338 | .status = mmc_status, |
Russell King | 7fb2bbf | 2009-07-09 15:15:12 +0100 | [diff] [blame] | 339 | .gpio_wp = -1, |
| 340 | .gpio_cd = -1, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 341 | }; |
| 342 | |
| 343 | static struct amba_device mmc_device = { |
| 344 | .dev = { |
Kay Sievers | 1d559e2 | 2009-01-06 10:44:43 -0800 | [diff] [blame] | 345 | .init_name = "mb:1c", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 346 | .platform_data = &mmc_data, |
| 347 | }, |
| 348 | .res = { |
Russell King | da7ba95 | 2010-01-17 19:59:58 +0000 | [diff] [blame] | 349 | .start = INTEGRATOR_CP_MMC_BASE, |
| 350 | .end = INTEGRATOR_CP_MMC_BASE + SZ_4K - 1, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 351 | .flags = IORESOURCE_MEM, |
| 352 | }, |
| 353 | .irq = { IRQ_CP_MMCIINT0, IRQ_CP_MMCIINT1 }, |
| 354 | .periphid = 0, |
| 355 | }; |
| 356 | |
| 357 | static struct amba_device aaci_device = { |
| 358 | .dev = { |
Kay Sievers | 1d559e2 | 2009-01-06 10:44:43 -0800 | [diff] [blame] | 359 | .init_name = "mb:1d", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 360 | }, |
| 361 | .res = { |
Russell King | da7ba95 | 2010-01-17 19:59:58 +0000 | [diff] [blame] | 362 | .start = INTEGRATOR_CP_AACI_BASE, |
| 363 | .end = INTEGRATOR_CP_AACI_BASE + SZ_4K - 1, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 364 | .flags = IORESOURCE_MEM, |
| 365 | }, |
| 366 | .irq = { IRQ_CP_AACIINT, NO_IRQ }, |
| 367 | .periphid = 0, |
| 368 | }; |
| 369 | |
| 370 | |
| 371 | /* |
| 372 | * CLCD support |
| 373 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 374 | /* |
| 375 | * Ensure VGA is selected. |
| 376 | */ |
| 377 | static void cp_clcd_enable(struct clcd_fb *fb) |
| 378 | { |
Russell King | e6b9c1f | 2011-01-22 11:02:10 +0000 | [diff] [blame] | 379 | struct fb_var_screeninfo *var = &fb->fb.var; |
| 380 | u32 val = CM_CTRL_STATIC1 | CM_CTRL_STATIC2; |
Russell King | 4774e22 | 2005-04-30 23:32:38 +0100 | [diff] [blame] | 381 | |
Russell King | e6b9c1f | 2011-01-22 11:02:10 +0000 | [diff] [blame] | 382 | if (var->bits_per_pixel <= 8 || |
| 383 | (var->bits_per_pixel == 16 && var->green.length == 5)) |
| 384 | /* Pseudocolor, RGB555, BGR555 */ |
| 385 | val |= CM_CTRL_LCDMUXSEL_VGA555_TFT555; |
Russell King | 4774e22 | 2005-04-30 23:32:38 +0100 | [diff] [blame] | 386 | else if (fb->fb.var.bits_per_pixel <= 16) |
Russell King | e6b9c1f | 2011-01-22 11:02:10 +0000 | [diff] [blame] | 387 | /* truecolor RGB565 */ |
| 388 | val |= CM_CTRL_LCDMUXSEL_VGA565_TFT555; |
Russell King | 4774e22 | 2005-04-30 23:32:38 +0100 | [diff] [blame] | 389 | else |
| 390 | val = 0; /* no idea for this, don't trust the docs */ |
| 391 | |
| 392 | cm_control(CM_CTRL_LCDMUXSEL_MASK| |
| 393 | CM_CTRL_LCDEN0| |
| 394 | CM_CTRL_LCDEN1| |
| 395 | CM_CTRL_STATIC1| |
| 396 | CM_CTRL_STATIC2| |
| 397 | CM_CTRL_STATIC| |
| 398 | CM_CTRL_n24BITEN, val); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 399 | } |
| 400 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 401 | static int cp_clcd_setup(struct clcd_fb *fb) |
| 402 | { |
Russell King | 9dfec4f | 2011-01-18 20:10:10 +0000 | [diff] [blame] | 403 | fb->panel = versatile_clcd_get_panel("VGA"); |
| 404 | if (!fb->panel) |
| 405 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 406 | |
Russell King | 9dfec4f | 2011-01-18 20:10:10 +0000 | [diff] [blame] | 407 | return versatile_clcd_setup_dma(fb, SZ_1M); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 408 | } |
| 409 | |
| 410 | static struct clcd_board clcd_data = { |
| 411 | .name = "Integrator/CP", |
Russell King | 9dfec4f | 2011-01-18 20:10:10 +0000 | [diff] [blame] | 412 | .caps = CLCD_CAP_5551 | CLCD_CAP_RGB565 | CLCD_CAP_888, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 413 | .check = clcdfb_check, |
| 414 | .decode = clcdfb_decode, |
| 415 | .enable = cp_clcd_enable, |
| 416 | .setup = cp_clcd_setup, |
Russell King | 9dfec4f | 2011-01-18 20:10:10 +0000 | [diff] [blame] | 417 | .mmap = versatile_clcd_mmap_dma, |
| 418 | .remove = versatile_clcd_remove_dma, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 419 | }; |
| 420 | |
| 421 | static struct amba_device clcd_device = { |
| 422 | .dev = { |
Kay Sievers | 1d559e2 | 2009-01-06 10:44:43 -0800 | [diff] [blame] | 423 | .init_name = "mb:c0", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 424 | .coherent_dma_mask = ~0, |
| 425 | .platform_data = &clcd_data, |
| 426 | }, |
| 427 | .res = { |
| 428 | .start = INTCP_PA_CLCD_BASE, |
| 429 | .end = INTCP_PA_CLCD_BASE + SZ_4K - 1, |
| 430 | .flags = IORESOURCE_MEM, |
| 431 | }, |
| 432 | .dma_mask = ~0, |
| 433 | .irq = { IRQ_CP_CLCDCINT, NO_IRQ }, |
| 434 | .periphid = 0, |
| 435 | }; |
| 436 | |
| 437 | static struct amba_device *amba_devs[] __initdata = { |
| 438 | &mmc_device, |
| 439 | &aaci_device, |
| 440 | &clcd_device, |
| 441 | }; |
| 442 | |
Russell King | c735c98 | 2011-01-11 13:00:04 +0000 | [diff] [blame] | 443 | static void __init intcp_init_early(void) |
| 444 | { |
| 445 | clkdev_add_table(cp_lookups, ARRAY_SIZE(cp_lookups)); |
| 446 | |
| 447 | integrator_init_early(); |
| 448 | } |
| 449 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 450 | static void __init intcp_init(void) |
| 451 | { |
| 452 | int i; |
| 453 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 454 | platform_add_devices(intcp_devs, ARRAY_SIZE(intcp_devs)); |
| 455 | |
| 456 | for (i = 0; i < ARRAY_SIZE(amba_devs); i++) { |
| 457 | struct amba_device *d = amba_devs[i]; |
| 458 | amba_device_register(d, &iomem_resource); |
| 459 | } |
| 460 | } |
| 461 | |
Russell King | 5a46334 | 2010-01-16 23:52:12 +0000 | [diff] [blame] | 462 | #define TIMER0_VA_BASE __io_address(INTEGRATOR_TIMER0_BASE) |
| 463 | #define TIMER1_VA_BASE __io_address(INTEGRATOR_TIMER1_BASE) |
| 464 | #define TIMER2_VA_BASE __io_address(INTEGRATOR_TIMER2_BASE) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 465 | |
| 466 | static void __init intcp_timer_init(void) |
| 467 | { |
Russell King | 5a46334 | 2010-01-16 23:52:12 +0000 | [diff] [blame] | 468 | writel(0, TIMER0_VA_BASE + TIMER_CTRL); |
| 469 | writel(0, TIMER1_VA_BASE + TIMER_CTRL); |
| 470 | writel(0, TIMER2_VA_BASE + TIMER_CTRL); |
| 471 | |
| 472 | sp804_clocksource_init(TIMER2_VA_BASE); |
| 473 | sp804_clockevents_init(TIMER1_VA_BASE, IRQ_TIMERINT1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 474 | } |
| 475 | |
| 476 | static struct sys_timer cp_timer = { |
| 477 | .init = intcp_timer_init, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 478 | }; |
| 479 | |
| 480 | MACHINE_START(CINTEGRATOR, "ARM-IntegratorCP") |
Russell King | e9dea0c | 2005-07-03 17:38:58 +0100 | [diff] [blame] | 481 | /* Maintainer: ARM Ltd/Deep Blue Solutions Ltd */ |
Russell King | e9dea0c | 2005-07-03 17:38:58 +0100 | [diff] [blame] | 482 | .boot_params = 0x00000100, |
Russell King | 98c672c | 2010-05-22 18:18:57 +0100 | [diff] [blame] | 483 | .reserve = integrator_reserve, |
Russell King | c735c98 | 2011-01-11 13:00:04 +0000 | [diff] [blame] | 484 | .map_io = intcp_map_io, |
| 485 | .init_early = intcp_init_early, |
Russell King | e9dea0c | 2005-07-03 17:38:58 +0100 | [diff] [blame] | 486 | .init_irq = intcp_init_irq, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 487 | .timer = &cp_timer, |
Russell King | e9dea0c | 2005-07-03 17:38:58 +0100 | [diff] [blame] | 488 | .init_machine = intcp_init, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 489 | MACHINE_END |