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