blob: e6700aab849a014eb3fc3a6cbb48969db1a7801f [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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 Kingd052d1b2005-10-29 19:07:23 +010014#include <linux/platform_device.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070015#include <linux/dma-mapping.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070016#include <linux/string.h>
17#include <linux/sysdev.h>
Russell Kinga62c80e2006-01-07 13:52:45 +000018#include <linux/amba/bus.h>
19#include <linux/amba/kmi.h>
20#include <linux/amba/clcd.h>
Linus Walleij6ef297f2009-09-22 14:29:36 +010021#include <linux/amba/mmci.h>
Russell Kingfced80c2008-09-06 12:10:45 +010022#include <linux/io.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090023#include <linux/gfp.h>
Jean-Christop PLAGNIOL-VILLARD6d803ba2010-11-17 10:04:33 +010024#include <linux/clkdev.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070025
Russell Kinga09e64f2008-08-05 16:14:15 +010026#include <mach/hardware.h>
Russell Kinga285edc2010-01-14 19:59:37 +000027#include <mach/platform.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070028#include <asm/irq.h>
29#include <asm/setup.h>
30#include <asm/mach-types.h>
Russell King5a463342010-01-16 23:52:12 +000031#include <asm/hardware/arm_timer.h>
Russell Kingc5a0adb2010-01-16 20:16:10 +000032#include <asm/hardware/icst.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070033
Russell Kinga09e64f2008-08-05 16:14:15 +010034#include <mach/cm.h>
35#include <mach/lm.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070036
37#include <asm/mach/arch.h>
38#include <asm/mach/flash.h>
39#include <asm/mach/irq.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070040#include <asm/mach/map.h>
41#include <asm/mach/time.h>
42
Rob Herring8a9618f2010-10-06 16:18:08 +010043#include <asm/hardware/timer-sp.h>
Russell King5a463342010-01-16 23:52:12 +000044
Russell King9dfec4f2011-01-18 20:10:10 +000045#include <plat/clcd.h>
46
Russell King98c672c2010-05-22 18:18:57 +010047#include "common.h"
48
Linus Torvalds1da177e2005-04-16 15:20:36 -070049#define INTCP_PA_FLASH_BASE 0x24000000
50#define INTCP_FLASH_SIZE SZ_32M
51
52#define INTCP_PA_CLCD_BASE 0xc0000000
53
Russell Kingb830b9b2010-01-17 20:45:12 +000054#define INTCP_VA_CIC_BASE IO_ADDRESS(INTEGRATOR_HDR_BASE + 0x40)
Catalin Marinas365f7a42009-07-24 12:34:57 +010055#define INTCP_VA_PIC_BASE IO_ADDRESS(INTEGRATOR_IC_BASE)
Russell Kingda7ba952010-01-17 19:59:58 +000056#define INTCP_VA_SIC_BASE IO_ADDRESS(INTEGRATOR_CP_SIC_BASE)
Linus Torvalds1da177e2005-04-16 15:20:36 -070057
Linus Torvalds1da177e2005-04-16 15:20:36 -070058#define INTCP_ETH_SIZE 0x10
59
Russell Kingda7ba952010-01-17 19:59:58 +000060#define INTCP_VA_CTRL_BASE IO_ADDRESS(INTEGRATOR_CP_CTL_BASE)
Linus Torvalds1da177e2005-04-16 15:20:36 -070061#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 Kingda7ba952010-01-17 19:59:58 +000075 * fc900000 c9000000 GPIO
76 * fca00000 ca000000 SIC
77 * fcb00000 cb000000 CP system control
Linus Torvalds1da177e2005-04-16 15:20:36 -070078 */
79
80static struct map_desc intcp_io_desc[] __initdata = {
Deepak Saxenac8d27292005-10-28 15:19:10 +010081 {
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 Kingda7ba952010-01-17 19:59:58 +0000122 .virtual = IO_ADDRESS(INTEGRATOR_CP_GPIO_BASE),
123 .pfn = __phys_to_pfn(INTEGRATOR_CP_GPIO_BASE),
Deepak Saxenac8d27292005-10-28 15:19:10 +0100124 .length = SZ_4K,
125 .type = MT_DEVICE
126 }, {
Russell Kingda7ba952010-01-17 19:59:58 +0000127 .virtual = IO_ADDRESS(INTEGRATOR_CP_SIC_BASE),
128 .pfn = __phys_to_pfn(INTEGRATOR_CP_SIC_BASE),
Deepak Saxenac8d27292005-10-28 15:19:10 +0100129 .length = SZ_4K,
130 .type = MT_DEVICE
131 }, {
Russell Kingda7ba952010-01-17 19:59:58 +0000132 .virtual = IO_ADDRESS(INTEGRATOR_CP_CTL_BASE),
133 .pfn = __phys_to_pfn(INTEGRATOR_CP_CTL_BASE),
Deepak Saxenac8d27292005-10-28 15:19:10 +0100134 .length = SZ_4K,
135 .type = MT_DEVICE
136 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137};
138
139static 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 Buytenhekc3ef3cc2010-11-29 10:31:33 +0100151static void cic_mask_irq(struct irq_data *d)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700152{
Lennert Buytenhekc3ef3cc2010-11-29 10:31:33 +0100153 unsigned int irq = d->irq - IRQ_CIC_START;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700154 cic_writel(1 << irq, INTCP_VA_CIC_BASE + IRQ_ENABLE_CLEAR);
155}
156
Lennert Buytenhekc3ef3cc2010-11-29 10:31:33 +0100157static void cic_unmask_irq(struct irq_data *d)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700158{
Lennert Buytenhekc3ef3cc2010-11-29 10:31:33 +0100159 unsigned int irq = d->irq - IRQ_CIC_START;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700160 cic_writel(1 << irq, INTCP_VA_CIC_BASE + IRQ_ENABLE_SET);
161}
162
David Brownell38c677c2006-08-01 22:26:25 +0100163static struct irq_chip cic_chip = {
Lennert Buytenhekc3ef3cc2010-11-29 10:31:33 +0100164 .name = "CIC",
165 .irq_ack = cic_mask_irq,
166 .irq_mask = cic_mask_irq,
167 .irq_unmask = cic_unmask_irq,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700168};
169
Lennert Buytenhekc3ef3cc2010-11-29 10:31:33 +0100170static void pic_mask_irq(struct irq_data *d)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700171{
Lennert Buytenhekc3ef3cc2010-11-29 10:31:33 +0100172 unsigned int irq = d->irq - IRQ_PIC_START;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700173 pic_writel(1 << irq, INTCP_VA_PIC_BASE + IRQ_ENABLE_CLEAR);
174}
175
Lennert Buytenhekc3ef3cc2010-11-29 10:31:33 +0100176static void pic_unmask_irq(struct irq_data *d)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700177{
Lennert Buytenhekc3ef3cc2010-11-29 10:31:33 +0100178 unsigned int irq = d->irq - IRQ_PIC_START;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700179 pic_writel(1 << irq, INTCP_VA_PIC_BASE + IRQ_ENABLE_SET);
180}
181
David Brownell38c677c2006-08-01 22:26:25 +0100182static struct irq_chip pic_chip = {
Lennert Buytenhekc3ef3cc2010-11-29 10:31:33 +0100183 .name = "PIC",
184 .irq_ack = pic_mask_irq,
185 .irq_mask = pic_mask_irq,
186 .irq_unmask = pic_unmask_irq,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700187};
188
Lennert Buytenhekc3ef3cc2010-11-29 10:31:33 +0100189static void sic_mask_irq(struct irq_data *d)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700190{
Lennert Buytenhekc3ef3cc2010-11-29 10:31:33 +0100191 unsigned int irq = d->irq - IRQ_SIC_START;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700192 sic_writel(1 << irq, INTCP_VA_SIC_BASE + IRQ_ENABLE_CLEAR);
193}
194
Lennert Buytenhekc3ef3cc2010-11-29 10:31:33 +0100195static void sic_unmask_irq(struct irq_data *d)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700196{
Lennert Buytenhekc3ef3cc2010-11-29 10:31:33 +0100197 unsigned int irq = d->irq - IRQ_SIC_START;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700198 sic_writel(1 << irq, INTCP_VA_SIC_BASE + IRQ_ENABLE_SET);
199}
200
David Brownell38c677c2006-08-01 22:26:25 +0100201static struct irq_chip sic_chip = {
Lennert Buytenhekc3ef3cc2010-11-29 10:31:33 +0100202 .name = "SIC",
203 .irq_ack = sic_mask_irq,
204 .irq_mask = sic_mask_irq,
205 .irq_unmask = sic_unmask_irq,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700206};
207
208static void
Russell King10dd5ce2006-11-23 11:41:32 +0000209sic_handle_irq(unsigned int irq, struct irq_desc *desc)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210{
211 unsigned long status = sic_readl(INTCP_VA_SIC_BASE + IRQ_STATUS);
212
213 if (status == 0) {
Linus Torvalds0cd61b62006-10-06 10:53:39 -0700214 do_bad_IRQ(irq, desc);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700215 return;
216 }
217
218 do {
219 irq = ffs(status) - 1;
220 status &= ~(1 << irq);
221
222 irq += IRQ_SIC_START;
223
Dmitry Baryshkovd8aa0252008-10-09 13:36:24 +0100224 generic_handle_irq(irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700225 } while (status);
226}
227
228static 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 Torvalds1da177e2005-04-16 15:20:36 -0700241 if (i == 29)
242 break;
243 set_irq_chip(i, &pic_chip);
Russell King10dd5ce2006-11-23 11:41:32 +0000244 set_irq_handler(i, handle_level_irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700245 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 King10dd5ce2006-11-23 11:41:32 +0000253 set_irq_handler(i, handle_level_irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700254 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 King10dd5ce2006-11-23 11:41:32 +0000262 set_irq_handler(i, handle_level_irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700263 set_irq_flags(i, IRQF_VALID | IRQF_PROBE);
264 }
265
Russell King56f1319e2006-06-10 12:42:12 +0100266 set_irq_chained_handler(IRQ_CP_CPPLDINT, sic_handle_irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700267}
268
269/*
270 * Clock handling
271 */
Russell Kingd1914c72010-01-14 20:09:34 +0000272#define CM_LOCK (__io_address(INTEGRATOR_HDR_BASE)+INTEGRATOR_HDR_LOCK_OFFSET)
273#define CM_AUXOSC (__io_address(INTEGRATOR_HDR_BASE)+0x1c)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700274
Russell King39c0cb02010-01-16 16:27:28 +0000275static const struct icst_params cp_auxvco_params = {
Russell King64fceb12010-01-16 17:28:44 +0000276 .ref = 24000000,
Russell King4de2edb2010-01-16 18:08:47 +0000277 .vco_max = ICST525_VCO_MAX_5V,
Russell Kinge73a46a2010-01-16 19:49:39 +0000278 .vco_min = ICST525_VCO_MIN,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700279 .vd_min = 8,
280 .vd_max = 263,
281 .rd_min = 3,
282 .rd_max = 65,
Russell King232eaf72010-01-16 19:46:19 +0000283 .s2div = icst525_s2div,
284 .idx2s = icst525_idx2s,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700285};
286
Russell King39c0cb02010-01-16 16:27:28 +0000287static void cp_auxvco_set(struct clk *clk, struct icst_vco vco)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700288{
289 u32 val;
290
Russell Kingd1914c72010-01-14 20:09:34 +0000291 val = readl(clk->vcoreg) & ~0x7ffff;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700292 val |= vco.v | (vco.r << 9) | (vco.s << 16);
293
294 writel(0xa05f, CM_LOCK);
Russell Kingd1914c72010-01-14 20:09:34 +0000295 writel(val, clk->vcoreg);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700296 writel(0, CM_LOCK);
297}
298
Russell King9bf5b2e2010-03-01 16:18:39 +0000299static 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 Kingd72fbdf2008-11-08 20:08:08 +0000305static struct clk cp_auxclk = {
Russell King9bf5b2e2010-03-01 16:18:39 +0000306 .ops = &cp_auxclk_ops,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700307 .params = &cp_auxvco_params,
Russell Kingd1914c72010-01-14 20:09:34 +0000308 .vcoreg = CM_AUXOSC,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309};
310
Russell Kingd72fbdf2008-11-08 20:08:08 +0000311static struct clk_lookup cp_lookups[] = {
312 { /* CLCD */
313 .dev_id = "mb:c0",
314 .clk = &cp_auxclk,
315 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700316};
317
318/*
319 * Flash handling.
320 */
321static 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
332static 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
341static 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
353static 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
361static 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
367static 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
377static struct resource smc91x_resources[] = {
378 [0] = {
Russell Kingda7ba952010-01-17 19:59:58 +0000379 .start = INTEGRATOR_CP_ETH_BASE,
380 .end = INTEGRATOR_CP_ETH_BASE + INTCP_ETH_SIZE - 1,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700381 .flags = IORESOURCE_MEM,
382 },
383 [1] = {
384 .start = IRQ_CP_ETHINT,
385 .end = IRQ_CP_ETHINT,
386 .flags = IORESOURCE_IRQ,
387 },
388};
389
390static struct platform_device smc91x_device = {
391 .name = "smc91x",
392 .id = 0,
393 .num_resources = ARRAY_SIZE(smc91x_resources),
394 .resource = smc91x_resources,
395};
396
397static 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 */
408static unsigned int mmc_status(struct device *dev)
409{
Russell Kingb830b9b2010-01-17 20:45:12 +0000410 unsigned int status = readl(IO_ADDRESS(0xca000000 + 4));
411 writel(8, IO_ADDRESS(INTEGRATOR_CP_CTL_BASE + 8));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700412
413 return status & 8;
414}
415
Linus Walleij6ef297f2009-09-22 14:29:36 +0100416static struct mmci_platform_data mmc_data = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700417 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
418 .status = mmc_status,
Russell King7fb2bbf2009-07-09 15:15:12 +0100419 .gpio_wp = -1,
420 .gpio_cd = -1,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700421};
422
423static struct amba_device mmc_device = {
424 .dev = {
Kay Sievers1d559e22009-01-06 10:44:43 -0800425 .init_name = "mb:1c",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700426 .platform_data = &mmc_data,
427 },
428 .res = {
Russell Kingda7ba952010-01-17 19:59:58 +0000429 .start = INTEGRATOR_CP_MMC_BASE,
430 .end = INTEGRATOR_CP_MMC_BASE + SZ_4K - 1,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700431 .flags = IORESOURCE_MEM,
432 },
433 .irq = { IRQ_CP_MMCIINT0, IRQ_CP_MMCIINT1 },
434 .periphid = 0,
435};
436
437static struct amba_device aaci_device = {
438 .dev = {
Kay Sievers1d559e22009-01-06 10:44:43 -0800439 .init_name = "mb:1d",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700440 },
441 .res = {
Russell Kingda7ba952010-01-17 19:59:58 +0000442 .start = INTEGRATOR_CP_AACI_BASE,
443 .end = INTEGRATOR_CP_AACI_BASE + SZ_4K - 1,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700444 .flags = IORESOURCE_MEM,
445 },
446 .irq = { IRQ_CP_AACIINT, NO_IRQ },
447 .periphid = 0,
448};
449
450
451/*
452 * CLCD support
453 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700454/*
455 * Ensure VGA is selected.
456 */
457static void cp_clcd_enable(struct clcd_fb *fb)
458{
Russell Kinge6b9c1f2011-01-22 11:02:10 +0000459 struct fb_var_screeninfo *var = &fb->fb.var;
460 u32 val = CM_CTRL_STATIC1 | CM_CTRL_STATIC2;
Russell King4774e222005-04-30 23:32:38 +0100461
Russell Kinge6b9c1f2011-01-22 11:02:10 +0000462 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 King4774e222005-04-30 23:32:38 +0100466 else if (fb->fb.var.bits_per_pixel <= 16)
Russell Kinge6b9c1f2011-01-22 11:02:10 +0000467 /* truecolor RGB565 */
468 val |= CM_CTRL_LCDMUXSEL_VGA565_TFT555;
Russell King4774e222005-04-30 23:32:38 +0100469 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 Torvalds1da177e2005-04-16 15:20:36 -0700479}
480
Linus Torvalds1da177e2005-04-16 15:20:36 -0700481static int cp_clcd_setup(struct clcd_fb *fb)
482{
Russell King9dfec4f2011-01-18 20:10:10 +0000483 fb->panel = versatile_clcd_get_panel("VGA");
484 if (!fb->panel)
485 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700486
Russell King9dfec4f2011-01-18 20:10:10 +0000487 return versatile_clcd_setup_dma(fb, SZ_1M);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700488}
489
490static struct clcd_board clcd_data = {
491 .name = "Integrator/CP",
Russell King9dfec4f2011-01-18 20:10:10 +0000492 .caps = CLCD_CAP_5551 | CLCD_CAP_RGB565 | CLCD_CAP_888,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700493 .check = clcdfb_check,
494 .decode = clcdfb_decode,
495 .enable = cp_clcd_enable,
496 .setup = cp_clcd_setup,
Russell King9dfec4f2011-01-18 20:10:10 +0000497 .mmap = versatile_clcd_mmap_dma,
498 .remove = versatile_clcd_remove_dma,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700499};
500
501static struct amba_device clcd_device = {
502 .dev = {
Kay Sievers1d559e22009-01-06 10:44:43 -0800503 .init_name = "mb:c0",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700504 .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
517static struct amba_device *amba_devs[] __initdata = {
518 &mmc_device,
519 &aaci_device,
520 &clcd_device,
521};
522
Russell Kingc735c982011-01-11 13:00:04 +0000523static void __init intcp_init_early(void)
524{
525 clkdev_add_table(cp_lookups, ARRAY_SIZE(cp_lookups));
526
527 integrator_init_early();
528}
529
Linus Torvalds1da177e2005-04-16 15:20:36 -0700530static void __init intcp_init(void)
531{
532 int i;
533
Linus Torvalds1da177e2005-04-16 15:20:36 -0700534 platform_add_devices(intcp_devs, ARRAY_SIZE(intcp_devs));
535
536 for (i = 0; i < ARRAY_SIZE(amba_devs); i++) {
537 struct amba_device *d = amba_devs[i];
538 amba_device_register(d, &iomem_resource);
539 }
540}
541
Russell King5a463342010-01-16 23:52:12 +0000542#define TIMER0_VA_BASE __io_address(INTEGRATOR_TIMER0_BASE)
543#define TIMER1_VA_BASE __io_address(INTEGRATOR_TIMER1_BASE)
544#define TIMER2_VA_BASE __io_address(INTEGRATOR_TIMER2_BASE)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700545
546static void __init intcp_timer_init(void)
547{
Russell King5a463342010-01-16 23:52:12 +0000548 writel(0, TIMER0_VA_BASE + TIMER_CTRL);
549 writel(0, TIMER1_VA_BASE + TIMER_CTRL);
550 writel(0, TIMER2_VA_BASE + TIMER_CTRL);
551
552 sp804_clocksource_init(TIMER2_VA_BASE);
553 sp804_clockevents_init(TIMER1_VA_BASE, IRQ_TIMERINT1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700554}
555
556static struct sys_timer cp_timer = {
557 .init = intcp_timer_init,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700558};
559
560MACHINE_START(CINTEGRATOR, "ARM-IntegratorCP")
Russell Kinge9dea0c2005-07-03 17:38:58 +0100561 /* Maintainer: ARM Ltd/Deep Blue Solutions Ltd */
Russell Kinge9dea0c2005-07-03 17:38:58 +0100562 .boot_params = 0x00000100,
Russell King98c672c2010-05-22 18:18:57 +0100563 .reserve = integrator_reserve,
Russell Kingc735c982011-01-11 13:00:04 +0000564 .map_io = intcp_map_io,
565 .init_early = intcp_init_early,
Russell Kinge9dea0c2005-07-03 17:38:58 +0100566 .init_irq = intcp_init_irq,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700567 .timer = &cp_timer,
Russell Kinge9dea0c2005-07-03 17:38:58 +0100568 .init_machine = intcp_init,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700569MACHINE_END