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