blob: e9327da1382e7a5d5f56c55b09f6bc829e02f290 [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 King98c672c2010-05-22 18:18:57 +010045#include "common.h"
46
Linus Torvalds1da177e2005-04-16 15:20:36 -070047#define INTCP_PA_FLASH_BASE 0x24000000
48#define INTCP_FLASH_SIZE SZ_32M
49
50#define INTCP_PA_CLCD_BASE 0xc0000000
51
Russell Kingb830b9b2010-01-17 20:45:12 +000052#define INTCP_VA_CIC_BASE IO_ADDRESS(INTEGRATOR_HDR_BASE + 0x40)
Catalin Marinas365f7a42009-07-24 12:34:57 +010053#define INTCP_VA_PIC_BASE IO_ADDRESS(INTEGRATOR_IC_BASE)
Russell Kingda7ba952010-01-17 19:59:58 +000054#define INTCP_VA_SIC_BASE IO_ADDRESS(INTEGRATOR_CP_SIC_BASE)
Linus Torvalds1da177e2005-04-16 15:20:36 -070055
Linus Torvalds1da177e2005-04-16 15:20:36 -070056#define INTCP_ETH_SIZE 0x10
57
Russell Kingda7ba952010-01-17 19:59:58 +000058#define INTCP_VA_CTRL_BASE IO_ADDRESS(INTEGRATOR_CP_CTL_BASE)
Linus Torvalds1da177e2005-04-16 15:20:36 -070059#define INTCP_FLASHPROG 0x04
60#define CINTEGRATOR_FLASHPROG_FLVPPEN (1 << 0)
61#define CINTEGRATOR_FLASHPROG_FLWREN (1 << 1)
62
63/*
64 * Logical Physical
65 * f1000000 10000000 Core module registers
66 * f1100000 11000000 System controller registers
67 * f1200000 12000000 EBI registers
68 * f1300000 13000000 Counter/Timer
69 * f1400000 14000000 Interrupt controller
70 * f1600000 16000000 UART 0
71 * f1700000 17000000 UART 1
72 * f1a00000 1a000000 Debug LEDs
Russell Kingda7ba952010-01-17 19:59:58 +000073 * fc900000 c9000000 GPIO
74 * fca00000 ca000000 SIC
75 * fcb00000 cb000000 CP system control
Linus Torvalds1da177e2005-04-16 15:20:36 -070076 */
77
78static struct map_desc intcp_io_desc[] __initdata = {
Deepak Saxenac8d27292005-10-28 15:19:10 +010079 {
80 .virtual = IO_ADDRESS(INTEGRATOR_HDR_BASE),
81 .pfn = __phys_to_pfn(INTEGRATOR_HDR_BASE),
82 .length = SZ_4K,
83 .type = MT_DEVICE
84 }, {
85 .virtual = IO_ADDRESS(INTEGRATOR_SC_BASE),
86 .pfn = __phys_to_pfn(INTEGRATOR_SC_BASE),
87 .length = SZ_4K,
88 .type = MT_DEVICE
89 }, {
90 .virtual = IO_ADDRESS(INTEGRATOR_EBI_BASE),
91 .pfn = __phys_to_pfn(INTEGRATOR_EBI_BASE),
92 .length = SZ_4K,
93 .type = MT_DEVICE
94 }, {
95 .virtual = IO_ADDRESS(INTEGRATOR_CT_BASE),
96 .pfn = __phys_to_pfn(INTEGRATOR_CT_BASE),
97 .length = SZ_4K,
98 .type = MT_DEVICE
99 }, {
100 .virtual = IO_ADDRESS(INTEGRATOR_IC_BASE),
101 .pfn = __phys_to_pfn(INTEGRATOR_IC_BASE),
102 .length = SZ_4K,
103 .type = MT_DEVICE
104 }, {
105 .virtual = IO_ADDRESS(INTEGRATOR_UART0_BASE),
106 .pfn = __phys_to_pfn(INTEGRATOR_UART0_BASE),
107 .length = SZ_4K,
108 .type = MT_DEVICE
109 }, {
110 .virtual = IO_ADDRESS(INTEGRATOR_UART1_BASE),
111 .pfn = __phys_to_pfn(INTEGRATOR_UART1_BASE),
112 .length = SZ_4K,
113 .type = MT_DEVICE
114 }, {
115 .virtual = IO_ADDRESS(INTEGRATOR_DBG_BASE),
116 .pfn = __phys_to_pfn(INTEGRATOR_DBG_BASE),
117 .length = SZ_4K,
118 .type = MT_DEVICE
119 }, {
Russell Kingda7ba952010-01-17 19:59:58 +0000120 .virtual = IO_ADDRESS(INTEGRATOR_CP_GPIO_BASE),
121 .pfn = __phys_to_pfn(INTEGRATOR_CP_GPIO_BASE),
Deepak Saxenac8d27292005-10-28 15:19:10 +0100122 .length = SZ_4K,
123 .type = MT_DEVICE
124 }, {
Russell Kingda7ba952010-01-17 19:59:58 +0000125 .virtual = IO_ADDRESS(INTEGRATOR_CP_SIC_BASE),
126 .pfn = __phys_to_pfn(INTEGRATOR_CP_SIC_BASE),
Deepak Saxenac8d27292005-10-28 15:19:10 +0100127 .length = SZ_4K,
128 .type = MT_DEVICE
129 }, {
Russell Kingda7ba952010-01-17 19:59:58 +0000130 .virtual = IO_ADDRESS(INTEGRATOR_CP_CTL_BASE),
131 .pfn = __phys_to_pfn(INTEGRATOR_CP_CTL_BASE),
Deepak Saxenac8d27292005-10-28 15:19:10 +0100132 .length = SZ_4K,
133 .type = MT_DEVICE
134 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700135};
136
137static void __init intcp_map_io(void)
138{
139 iotable_init(intcp_io_desc, ARRAY_SIZE(intcp_io_desc));
140}
141
142#define cic_writel __raw_writel
143#define cic_readl __raw_readl
144#define pic_writel __raw_writel
145#define pic_readl __raw_readl
146#define sic_writel __raw_writel
147#define sic_readl __raw_readl
148
Lennert Buytenhekc3ef3cc2010-11-29 10:31:33 +0100149static void cic_mask_irq(struct irq_data *d)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700150{
Lennert Buytenhekc3ef3cc2010-11-29 10:31:33 +0100151 unsigned int irq = d->irq - IRQ_CIC_START;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700152 cic_writel(1 << irq, INTCP_VA_CIC_BASE + IRQ_ENABLE_CLEAR);
153}
154
Lennert Buytenhekc3ef3cc2010-11-29 10:31:33 +0100155static void cic_unmask_irq(struct irq_data *d)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700156{
Lennert Buytenhekc3ef3cc2010-11-29 10:31:33 +0100157 unsigned int irq = d->irq - IRQ_CIC_START;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700158 cic_writel(1 << irq, INTCP_VA_CIC_BASE + IRQ_ENABLE_SET);
159}
160
David Brownell38c677c2006-08-01 22:26:25 +0100161static struct irq_chip cic_chip = {
Lennert Buytenhekc3ef3cc2010-11-29 10:31:33 +0100162 .name = "CIC",
163 .irq_ack = cic_mask_irq,
164 .irq_mask = cic_mask_irq,
165 .irq_unmask = cic_unmask_irq,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700166};
167
Lennert Buytenhekc3ef3cc2010-11-29 10:31:33 +0100168static void pic_mask_irq(struct irq_data *d)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700169{
Lennert Buytenhekc3ef3cc2010-11-29 10:31:33 +0100170 unsigned int irq = d->irq - IRQ_PIC_START;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700171 pic_writel(1 << irq, INTCP_VA_PIC_BASE + IRQ_ENABLE_CLEAR);
172}
173
Lennert Buytenhekc3ef3cc2010-11-29 10:31:33 +0100174static void pic_unmask_irq(struct irq_data *d)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700175{
Lennert Buytenhekc3ef3cc2010-11-29 10:31:33 +0100176 unsigned int irq = d->irq - IRQ_PIC_START;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700177 pic_writel(1 << irq, INTCP_VA_PIC_BASE + IRQ_ENABLE_SET);
178}
179
David Brownell38c677c2006-08-01 22:26:25 +0100180static struct irq_chip pic_chip = {
Lennert Buytenhekc3ef3cc2010-11-29 10:31:33 +0100181 .name = "PIC",
182 .irq_ack = pic_mask_irq,
183 .irq_mask = pic_mask_irq,
184 .irq_unmask = pic_unmask_irq,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185};
186
Lennert Buytenhekc3ef3cc2010-11-29 10:31:33 +0100187static void sic_mask_irq(struct irq_data *d)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700188{
Lennert Buytenhekc3ef3cc2010-11-29 10:31:33 +0100189 unsigned int irq = d->irq - IRQ_SIC_START;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700190 sic_writel(1 << irq, INTCP_VA_SIC_BASE + IRQ_ENABLE_CLEAR);
191}
192
Lennert Buytenhekc3ef3cc2010-11-29 10:31:33 +0100193static void sic_unmask_irq(struct irq_data *d)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700194{
Lennert Buytenhekc3ef3cc2010-11-29 10:31:33 +0100195 unsigned int irq = d->irq - IRQ_SIC_START;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700196 sic_writel(1 << irq, INTCP_VA_SIC_BASE + IRQ_ENABLE_SET);
197}
198
David Brownell38c677c2006-08-01 22:26:25 +0100199static struct irq_chip sic_chip = {
Lennert Buytenhekc3ef3cc2010-11-29 10:31:33 +0100200 .name = "SIC",
201 .irq_ack = sic_mask_irq,
202 .irq_mask = sic_mask_irq,
203 .irq_unmask = sic_unmask_irq,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700204};
205
206static void
Russell King10dd5ce2006-11-23 11:41:32 +0000207sic_handle_irq(unsigned int irq, struct irq_desc *desc)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700208{
209 unsigned long status = sic_readl(INTCP_VA_SIC_BASE + IRQ_STATUS);
210
211 if (status == 0) {
Linus Torvalds0cd61b62006-10-06 10:53:39 -0700212 do_bad_IRQ(irq, desc);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700213 return;
214 }
215
216 do {
217 irq = ffs(status) - 1;
218 status &= ~(1 << irq);
219
220 irq += IRQ_SIC_START;
221
Dmitry Baryshkovd8aa0252008-10-09 13:36:24 +0100222 generic_handle_irq(irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700223 } while (status);
224}
225
226static void __init intcp_init_irq(void)
227{
228 unsigned int i;
229
230 /*
231 * Disable all interrupt sources
232 */
233 pic_writel(0xffffffff, INTCP_VA_PIC_BASE + IRQ_ENABLE_CLEAR);
234 pic_writel(0xffffffff, INTCP_VA_PIC_BASE + FIQ_ENABLE_CLEAR);
235
236 for (i = IRQ_PIC_START; i <= IRQ_PIC_END; i++) {
237 if (i == 11)
238 i = 22;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700239 if (i == 29)
240 break;
241 set_irq_chip(i, &pic_chip);
Russell King10dd5ce2006-11-23 11:41:32 +0000242 set_irq_handler(i, handle_level_irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700243 set_irq_flags(i, IRQF_VALID | IRQF_PROBE);
244 }
245
246 cic_writel(0xffffffff, INTCP_VA_CIC_BASE + IRQ_ENABLE_CLEAR);
247 cic_writel(0xffffffff, INTCP_VA_CIC_BASE + FIQ_ENABLE_CLEAR);
248
249 for (i = IRQ_CIC_START; i <= IRQ_CIC_END; i++) {
250 set_irq_chip(i, &cic_chip);
Russell King10dd5ce2006-11-23 11:41:32 +0000251 set_irq_handler(i, handle_level_irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700252 set_irq_flags(i, IRQF_VALID);
253 }
254
255 sic_writel(0x00000fff, INTCP_VA_SIC_BASE + IRQ_ENABLE_CLEAR);
256 sic_writel(0x00000fff, INTCP_VA_SIC_BASE + FIQ_ENABLE_CLEAR);
257
258 for (i = IRQ_SIC_START; i <= IRQ_SIC_END; i++) {
259 set_irq_chip(i, &sic_chip);
Russell King10dd5ce2006-11-23 11:41:32 +0000260 set_irq_handler(i, handle_level_irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700261 set_irq_flags(i, IRQF_VALID | IRQF_PROBE);
262 }
263
Russell King56f1319e2006-06-10 12:42:12 +0100264 set_irq_chained_handler(IRQ_CP_CPPLDINT, sic_handle_irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700265}
266
267/*
268 * Clock handling
269 */
Russell Kingd1914c72010-01-14 20:09:34 +0000270#define CM_LOCK (__io_address(INTEGRATOR_HDR_BASE)+INTEGRATOR_HDR_LOCK_OFFSET)
271#define CM_AUXOSC (__io_address(INTEGRATOR_HDR_BASE)+0x1c)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700272
Russell King39c0cb02010-01-16 16:27:28 +0000273static const struct icst_params cp_auxvco_params = {
Russell King64fceb12010-01-16 17:28:44 +0000274 .ref = 24000000,
Russell King4de2edb2010-01-16 18:08:47 +0000275 .vco_max = ICST525_VCO_MAX_5V,
Russell Kinge73a46a2010-01-16 19:49:39 +0000276 .vco_min = ICST525_VCO_MIN,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700277 .vd_min = 8,
278 .vd_max = 263,
279 .rd_min = 3,
280 .rd_max = 65,
Russell King232eaf72010-01-16 19:46:19 +0000281 .s2div = icst525_s2div,
282 .idx2s = icst525_idx2s,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700283};
284
Russell King39c0cb02010-01-16 16:27:28 +0000285static void cp_auxvco_set(struct clk *clk, struct icst_vco vco)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700286{
287 u32 val;
288
Russell Kingd1914c72010-01-14 20:09:34 +0000289 val = readl(clk->vcoreg) & ~0x7ffff;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700290 val |= vco.v | (vco.r << 9) | (vco.s << 16);
291
292 writel(0xa05f, CM_LOCK);
Russell Kingd1914c72010-01-14 20:09:34 +0000293 writel(val, clk->vcoreg);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700294 writel(0, CM_LOCK);
295}
296
Russell King9bf5b2e2010-03-01 16:18:39 +0000297static const struct clk_ops cp_auxclk_ops = {
298 .round = icst_clk_round,
299 .set = icst_clk_set,
300 .setvco = cp_auxvco_set,
301};
302
Russell Kingd72fbdf2008-11-08 20:08:08 +0000303static struct clk cp_auxclk = {
Russell King9bf5b2e2010-03-01 16:18:39 +0000304 .ops = &cp_auxclk_ops,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700305 .params = &cp_auxvco_params,
Russell Kingd1914c72010-01-14 20:09:34 +0000306 .vcoreg = CM_AUXOSC,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700307};
308
Russell Kingd72fbdf2008-11-08 20:08:08 +0000309static struct clk_lookup cp_lookups[] = {
310 { /* CLCD */
311 .dev_id = "mb:c0",
312 .clk = &cp_auxclk,
313 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700314};
315
316/*
317 * Flash handling.
318 */
319static int intcp_flash_init(void)
320{
321 u32 val;
322
323 val = readl(INTCP_VA_CTRL_BASE + INTCP_FLASHPROG);
324 val |= CINTEGRATOR_FLASHPROG_FLWREN;
325 writel(val, INTCP_VA_CTRL_BASE + INTCP_FLASHPROG);
326
327 return 0;
328}
329
330static void intcp_flash_exit(void)
331{
332 u32 val;
333
334 val = readl(INTCP_VA_CTRL_BASE + INTCP_FLASHPROG);
335 val &= ~(CINTEGRATOR_FLASHPROG_FLVPPEN|CINTEGRATOR_FLASHPROG_FLWREN);
336 writel(val, INTCP_VA_CTRL_BASE + INTCP_FLASHPROG);
337}
338
339static void intcp_flash_set_vpp(int on)
340{
341 u32 val;
342
343 val = readl(INTCP_VA_CTRL_BASE + INTCP_FLASHPROG);
344 if (on)
345 val |= CINTEGRATOR_FLASHPROG_FLVPPEN;
346 else
347 val &= ~CINTEGRATOR_FLASHPROG_FLVPPEN;
348 writel(val, INTCP_VA_CTRL_BASE + INTCP_FLASHPROG);
349}
350
351static struct flash_platform_data intcp_flash_data = {
352 .map_name = "cfi_probe",
353 .width = 4,
354 .init = intcp_flash_init,
355 .exit = intcp_flash_exit,
356 .set_vpp = intcp_flash_set_vpp,
357};
358
359static struct resource intcp_flash_resource = {
360 .start = INTCP_PA_FLASH_BASE,
361 .end = INTCP_PA_FLASH_BASE + INTCP_FLASH_SIZE - 1,
362 .flags = IORESOURCE_MEM,
363};
364
365static struct platform_device intcp_flash_device = {
366 .name = "armflash",
367 .id = 0,
368 .dev = {
369 .platform_data = &intcp_flash_data,
370 },
371 .num_resources = 1,
372 .resource = &intcp_flash_resource,
373};
374
375static struct resource smc91x_resources[] = {
376 [0] = {
Russell Kingda7ba952010-01-17 19:59:58 +0000377 .start = INTEGRATOR_CP_ETH_BASE,
378 .end = INTEGRATOR_CP_ETH_BASE + INTCP_ETH_SIZE - 1,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700379 .flags = IORESOURCE_MEM,
380 },
381 [1] = {
382 .start = IRQ_CP_ETHINT,
383 .end = IRQ_CP_ETHINT,
384 .flags = IORESOURCE_IRQ,
385 },
386};
387
388static struct platform_device smc91x_device = {
389 .name = "smc91x",
390 .id = 0,
391 .num_resources = ARRAY_SIZE(smc91x_resources),
392 .resource = smc91x_resources,
393};
394
395static struct platform_device *intcp_devs[] __initdata = {
396 &intcp_flash_device,
397 &smc91x_device,
398};
399
400/*
401 * It seems that the card insertion interrupt remains active after
402 * we've acknowledged it. We therefore ignore the interrupt, and
403 * rely on reading it from the SIC. This also means that we must
404 * clear the latched interrupt.
405 */
406static unsigned int mmc_status(struct device *dev)
407{
Russell Kingb830b9b2010-01-17 20:45:12 +0000408 unsigned int status = readl(IO_ADDRESS(0xca000000 + 4));
409 writel(8, IO_ADDRESS(INTEGRATOR_CP_CTL_BASE + 8));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700410
411 return status & 8;
412}
413
Linus Walleij6ef297f2009-09-22 14:29:36 +0100414static struct mmci_platform_data mmc_data = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700415 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
416 .status = mmc_status,
Russell King7fb2bbf2009-07-09 15:15:12 +0100417 .gpio_wp = -1,
418 .gpio_cd = -1,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700419};
420
421static struct amba_device mmc_device = {
422 .dev = {
Kay Sievers1d559e22009-01-06 10:44:43 -0800423 .init_name = "mb:1c",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700424 .platform_data = &mmc_data,
425 },
426 .res = {
Russell Kingda7ba952010-01-17 19:59:58 +0000427 .start = INTEGRATOR_CP_MMC_BASE,
428 .end = INTEGRATOR_CP_MMC_BASE + SZ_4K - 1,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700429 .flags = IORESOURCE_MEM,
430 },
431 .irq = { IRQ_CP_MMCIINT0, IRQ_CP_MMCIINT1 },
432 .periphid = 0,
433};
434
435static struct amba_device aaci_device = {
436 .dev = {
Kay Sievers1d559e22009-01-06 10:44:43 -0800437 .init_name = "mb:1d",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700438 },
439 .res = {
Russell Kingda7ba952010-01-17 19:59:58 +0000440 .start = INTEGRATOR_CP_AACI_BASE,
441 .end = INTEGRATOR_CP_AACI_BASE + SZ_4K - 1,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700442 .flags = IORESOURCE_MEM,
443 },
444 .irq = { IRQ_CP_AACIINT, NO_IRQ },
445 .periphid = 0,
446};
447
448
449/*
450 * CLCD support
451 */
452static struct clcd_panel vga = {
453 .mode = {
454 .name = "VGA",
455 .refresh = 60,
456 .xres = 640,
457 .yres = 480,
458 .pixclock = 39721,
459 .left_margin = 40,
460 .right_margin = 24,
461 .upper_margin = 32,
462 .lower_margin = 11,
463 .hsync_len = 96,
464 .vsync_len = 2,
465 .sync = 0,
466 .vmode = FB_VMODE_NONINTERLACED,
467 },
468 .width = -1,
469 .height = -1,
470 .tim2 = TIM2_BCD | TIM2_IPC,
471 .cntl = CNTL_LCDTFT | CNTL_LCDVCOMP(1),
472 .bpp = 16,
473 .grayscale = 0,
474};
475
476/*
477 * Ensure VGA is selected.
478 */
479static void cp_clcd_enable(struct clcd_fb *fb)
480{
Russell King4774e222005-04-30 23:32:38 +0100481 u32 val;
482
483 if (fb->fb.var.bits_per_pixel <= 8)
484 val = CM_CTRL_LCDMUXSEL_VGA_8421BPP;
485 else if (fb->fb.var.bits_per_pixel <= 16)
Catalin Marinas14e54cc2006-01-28 20:54:50 +0000486 val = CM_CTRL_LCDMUXSEL_VGA_16BPP
487 | CM_CTRL_LCDEN0 | CM_CTRL_LCDEN1
488 | CM_CTRL_STATIC1 | CM_CTRL_STATIC2;
Russell King4774e222005-04-30 23:32:38 +0100489 else
490 val = 0; /* no idea for this, don't trust the docs */
491
492 cm_control(CM_CTRL_LCDMUXSEL_MASK|
493 CM_CTRL_LCDEN0|
494 CM_CTRL_LCDEN1|
495 CM_CTRL_STATIC1|
496 CM_CTRL_STATIC2|
497 CM_CTRL_STATIC|
498 CM_CTRL_n24BITEN, val);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700499}
500
501static unsigned long framesize = SZ_1M;
502
503static int cp_clcd_setup(struct clcd_fb *fb)
504{
505 dma_addr_t dma;
506
507 fb->panel = &vga;
508
509 fb->fb.screen_base = dma_alloc_writecombine(&fb->dev->dev, framesize,
510 &dma, GFP_KERNEL);
511 if (!fb->fb.screen_base) {
512 printk(KERN_ERR "CLCD: unable to map framebuffer\n");
513 return -ENOMEM;
514 }
515
516 fb->fb.fix.smem_start = dma;
517 fb->fb.fix.smem_len = framesize;
518
519 return 0;
520}
521
522static int cp_clcd_mmap(struct clcd_fb *fb, struct vm_area_struct *vma)
523{
524 return dma_mmap_writecombine(&fb->dev->dev, vma,
525 fb->fb.screen_base,
526 fb->fb.fix.smem_start,
527 fb->fb.fix.smem_len);
528}
529
530static void cp_clcd_remove(struct clcd_fb *fb)
531{
532 dma_free_writecombine(&fb->dev->dev, fb->fb.fix.smem_len,
533 fb->fb.screen_base, fb->fb.fix.smem_start);
534}
535
536static struct clcd_board clcd_data = {
537 .name = "Integrator/CP",
538 .check = clcdfb_check,
539 .decode = clcdfb_decode,
540 .enable = cp_clcd_enable,
541 .setup = cp_clcd_setup,
542 .mmap = cp_clcd_mmap,
543 .remove = cp_clcd_remove,
544};
545
546static struct amba_device clcd_device = {
547 .dev = {
Kay Sievers1d559e22009-01-06 10:44:43 -0800548 .init_name = "mb:c0",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700549 .coherent_dma_mask = ~0,
550 .platform_data = &clcd_data,
551 },
552 .res = {
553 .start = INTCP_PA_CLCD_BASE,
554 .end = INTCP_PA_CLCD_BASE + SZ_4K - 1,
555 .flags = IORESOURCE_MEM,
556 },
557 .dma_mask = ~0,
558 .irq = { IRQ_CP_CLCDCINT, NO_IRQ },
559 .periphid = 0,
560};
561
562static struct amba_device *amba_devs[] __initdata = {
563 &mmc_device,
564 &aaci_device,
565 &clcd_device,
566};
567
568static void __init intcp_init(void)
569{
570 int i;
571
Russell King0a0300d2010-01-12 12:28:00 +0000572 clkdev_add_table(cp_lookups, ARRAY_SIZE(cp_lookups));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700573 platform_add_devices(intcp_devs, ARRAY_SIZE(intcp_devs));
574
575 for (i = 0; i < ARRAY_SIZE(amba_devs); i++) {
576 struct amba_device *d = amba_devs[i];
577 amba_device_register(d, &iomem_resource);
578 }
579}
580
Russell King5a463342010-01-16 23:52:12 +0000581#define TIMER0_VA_BASE __io_address(INTEGRATOR_TIMER0_BASE)
582#define TIMER1_VA_BASE __io_address(INTEGRATOR_TIMER1_BASE)
583#define TIMER2_VA_BASE __io_address(INTEGRATOR_TIMER2_BASE)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700584
585static void __init intcp_timer_init(void)
586{
Russell King5a463342010-01-16 23:52:12 +0000587 writel(0, TIMER0_VA_BASE + TIMER_CTRL);
588 writel(0, TIMER1_VA_BASE + TIMER_CTRL);
589 writel(0, TIMER2_VA_BASE + TIMER_CTRL);
590
591 sp804_clocksource_init(TIMER2_VA_BASE);
592 sp804_clockevents_init(TIMER1_VA_BASE, IRQ_TIMERINT1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700593}
594
595static struct sys_timer cp_timer = {
596 .init = intcp_timer_init,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700597};
598
599MACHINE_START(CINTEGRATOR, "ARM-IntegratorCP")
Russell Kinge9dea0c2005-07-03 17:38:58 +0100600 /* Maintainer: ARM Ltd/Deep Blue Solutions Ltd */
Russell Kinge9dea0c2005-07-03 17:38:58 +0100601 .boot_params = 0x00000100,
602 .map_io = intcp_map_io,
Russell King98c672c2010-05-22 18:18:57 +0100603 .reserve = integrator_reserve,
Russell Kinge9dea0c2005-07-03 17:38:58 +0100604 .init_irq = intcp_init_irq,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700605 .timer = &cp_timer,
Russell Kinge9dea0c2005-07-03 17:38:58 +0100606 .init_machine = intcp_init,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700607MACHINE_END