blob: 9194a4f3339c9153ad9231f87bbe182510567cb9 [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>
Kay Sieversedbaa602011-12-21 16:26:03 -080017#include <linux/device.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>
Marc Zyngier046dfa02011-05-18 10:51:53 +010024#include <linux/mtd/physmap.h>
Linus Walleija6131632012-06-11 17:33:12 +020025#include <linux/platform_data/clk-integrator.h>
Linus Walleij4980f9b2012-09-06 09:08:24 +010026#include <linux/of_irq.h>
27#include <linux/of_address.h>
Linus Walleij4672cdd2012-09-06 09:08:47 +010028#include <linux/of_platform.h>
Linus Walleij64100a02012-11-02 01:20:43 +010029#include <linux/sys_soc.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070030
Russell Kinga09e64f2008-08-05 16:14:15 +010031#include <mach/hardware.h>
Russell Kinga285edc2010-01-14 19:59:37 +000032#include <mach/platform.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070033#include <asm/setup.h>
34#include <asm/mach-types.h>
Russell King5a463342010-01-16 23:52:12 +000035#include <asm/hardware/arm_timer.h>
Russell Kingc5a0adb2010-01-16 20:16:10 +000036#include <asm/hardware/icst.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070037
Russell Kinga09e64f2008-08-05 16:14:15 +010038#include <mach/cm.h>
39#include <mach/lm.h>
Linus Walleij695436e2012-02-26 10:46:48 +010040#include <mach/irqs.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070041
42#include <asm/mach/arch.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070043#include <asm/mach/irq.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070044#include <asm/mach/map.h>
45#include <asm/mach/time.h>
46
Rob Herring8a9618f2010-10-06 16:18:08 +010047#include <asm/hardware/timer-sp.h>
Russell King5a463342010-01-16 23:52:12 +000048
Russell King9dfec4f2011-01-18 20:10:10 +000049#include <plat/clcd.h>
Russell Kingc41b16f2011-01-19 15:32:15 +000050#include <plat/fpga-irq.h>
Russell Kingd77e2702011-01-22 11:37:54 +000051#include <plat/sched_clock.h>
Russell King9dfec4f2011-01-18 20:10:10 +000052
Russell King98c672c2010-05-22 18:18:57 +010053#include "common.h"
54
Linus Torvalds1da177e2005-04-16 15:20:36 -070055#define INTCP_PA_FLASH_BASE 0x24000000
Linus Torvalds1da177e2005-04-16 15:20:36 -070056
57#define INTCP_PA_CLCD_BASE 0xc0000000
58
Arnd Bergmannb7a3f8d2012-09-14 20:16:39 +000059#define INTCP_VA_CTRL_BASE __io_address(INTEGRATOR_CP_CTL_BASE)
Linus Torvalds1da177e2005-04-16 15:20:36 -070060#define INTCP_FLASHPROG 0x04
61#define CINTEGRATOR_FLASHPROG_FLVPPEN (1 << 0)
62#define CINTEGRATOR_FLASHPROG_FLWREN (1 << 1)
63
64/*
65 * Logical Physical
66 * f1000000 10000000 Core module registers
67 * f1100000 11000000 System controller registers
68 * f1200000 12000000 EBI registers
69 * f1300000 13000000 Counter/Timer
70 * f1400000 14000000 Interrupt controller
71 * f1600000 16000000 UART 0
72 * f1700000 17000000 UART 1
73 * f1a00000 1a000000 Debug LEDs
Russell Kingda7ba952010-01-17 19:59:58 +000074 * fc900000 c9000000 GPIO
75 * fca00000 ca000000 SIC
76 * fcb00000 cb000000 CP system control
Linus Torvalds1da177e2005-04-16 15:20:36 -070077 */
78
79static struct map_desc intcp_io_desc[] __initdata = {
Deepak Saxenac8d27292005-10-28 15:19:10 +010080 {
81 .virtual = IO_ADDRESS(INTEGRATOR_HDR_BASE),
82 .pfn = __phys_to_pfn(INTEGRATOR_HDR_BASE),
83 .length = SZ_4K,
84 .type = MT_DEVICE
85 }, {
86 .virtual = IO_ADDRESS(INTEGRATOR_SC_BASE),
87 .pfn = __phys_to_pfn(INTEGRATOR_SC_BASE),
88 .length = SZ_4K,
89 .type = MT_DEVICE
90 }, {
91 .virtual = IO_ADDRESS(INTEGRATOR_EBI_BASE),
92 .pfn = __phys_to_pfn(INTEGRATOR_EBI_BASE),
93 .length = SZ_4K,
94 .type = MT_DEVICE
95 }, {
96 .virtual = IO_ADDRESS(INTEGRATOR_CT_BASE),
97 .pfn = __phys_to_pfn(INTEGRATOR_CT_BASE),
98 .length = SZ_4K,
99 .type = MT_DEVICE
100 }, {
101 .virtual = IO_ADDRESS(INTEGRATOR_IC_BASE),
102 .pfn = __phys_to_pfn(INTEGRATOR_IC_BASE),
103 .length = SZ_4K,
104 .type = MT_DEVICE
105 }, {
106 .virtual = IO_ADDRESS(INTEGRATOR_UART0_BASE),
107 .pfn = __phys_to_pfn(INTEGRATOR_UART0_BASE),
108 .length = SZ_4K,
109 .type = MT_DEVICE
110 }, {
111 .virtual = IO_ADDRESS(INTEGRATOR_UART1_BASE),
112 .pfn = __phys_to_pfn(INTEGRATOR_UART1_BASE),
113 .length = SZ_4K,
114 .type = MT_DEVICE
115 }, {
116 .virtual = IO_ADDRESS(INTEGRATOR_DBG_BASE),
117 .pfn = __phys_to_pfn(INTEGRATOR_DBG_BASE),
118 .length = SZ_4K,
119 .type = MT_DEVICE
120 }, {
Russell Kingda7ba952010-01-17 19:59:58 +0000121 .virtual = IO_ADDRESS(INTEGRATOR_CP_GPIO_BASE),
122 .pfn = __phys_to_pfn(INTEGRATOR_CP_GPIO_BASE),
Deepak Saxenac8d27292005-10-28 15:19:10 +0100123 .length = SZ_4K,
124 .type = MT_DEVICE
125 }, {
Russell Kingda7ba952010-01-17 19:59:58 +0000126 .virtual = IO_ADDRESS(INTEGRATOR_CP_SIC_BASE),
127 .pfn = __phys_to_pfn(INTEGRATOR_CP_SIC_BASE),
Deepak Saxenac8d27292005-10-28 15:19:10 +0100128 .length = SZ_4K,
129 .type = MT_DEVICE
130 }, {
Russell Kingda7ba952010-01-17 19:59:58 +0000131 .virtual = IO_ADDRESS(INTEGRATOR_CP_CTL_BASE),
132 .pfn = __phys_to_pfn(INTEGRATOR_CP_CTL_BASE),
Deepak Saxenac8d27292005-10-28 15:19:10 +0100133 .length = SZ_4K,
134 .type = MT_DEVICE
135 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700136};
137
138static void __init intcp_map_io(void)
139{
140 iotable_init(intcp_io_desc, ARRAY_SIZE(intcp_io_desc));
141}
142
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143/*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144 * Flash handling.
145 */
Marc Zyngier046dfa02011-05-18 10:51:53 +0100146static int intcp_flash_init(struct platform_device *dev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147{
148 u32 val;
149
150 val = readl(INTCP_VA_CTRL_BASE + INTCP_FLASHPROG);
151 val |= CINTEGRATOR_FLASHPROG_FLWREN;
152 writel(val, INTCP_VA_CTRL_BASE + INTCP_FLASHPROG);
153
154 return 0;
155}
156
Marc Zyngier046dfa02011-05-18 10:51:53 +0100157static void intcp_flash_exit(struct platform_device *dev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700158{
159 u32 val;
160
161 val = readl(INTCP_VA_CTRL_BASE + INTCP_FLASHPROG);
162 val &= ~(CINTEGRATOR_FLASHPROG_FLVPPEN|CINTEGRATOR_FLASHPROG_FLWREN);
163 writel(val, INTCP_VA_CTRL_BASE + INTCP_FLASHPROG);
164}
165
Marc Zyngier667f3902011-05-18 10:51:55 +0100166static void intcp_flash_set_vpp(struct platform_device *pdev, int on)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700167{
168 u32 val;
169
170 val = readl(INTCP_VA_CTRL_BASE + INTCP_FLASHPROG);
171 if (on)
172 val |= CINTEGRATOR_FLASHPROG_FLVPPEN;
173 else
174 val &= ~CINTEGRATOR_FLASHPROG_FLVPPEN;
175 writel(val, INTCP_VA_CTRL_BASE + INTCP_FLASHPROG);
176}
177
Marc Zyngier046dfa02011-05-18 10:51:53 +0100178static struct physmap_flash_data intcp_flash_data = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700179 .width = 4,
180 .init = intcp_flash_init,
181 .exit = intcp_flash_exit,
182 .set_vpp = intcp_flash_set_vpp,
183};
184
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185/*
186 * It seems that the card insertion interrupt remains active after
187 * we've acknowledged it. We therefore ignore the interrupt, and
188 * rely on reading it from the SIC. This also means that we must
189 * clear the latched interrupt.
190 */
191static unsigned int mmc_status(struct device *dev)
192{
Arnd Bergmannb7a3f8d2012-09-14 20:16:39 +0000193 unsigned int status = readl(__io_address(0xca000000 + 4));
194 writel(8, __io_address(INTEGRATOR_CP_CTL_BASE + 8));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700195
196 return status & 8;
197}
198
Linus Walleij6ef297f2009-09-22 14:29:36 +0100199static struct mmci_platform_data mmc_data = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700200 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
201 .status = mmc_status,
Russell King7fb2bbf2009-07-09 15:15:12 +0100202 .gpio_wp = -1,
203 .gpio_cd = -1,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700204};
205
Linus Torvalds1da177e2005-04-16 15:20:36 -0700206/*
207 * CLCD support
208 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700209/*
210 * Ensure VGA is selected.
211 */
212static void cp_clcd_enable(struct clcd_fb *fb)
213{
Russell Kinge6b9c1f2011-01-22 11:02:10 +0000214 struct fb_var_screeninfo *var = &fb->fb.var;
215 u32 val = CM_CTRL_STATIC1 | CM_CTRL_STATIC2;
Russell King4774e222005-04-30 23:32:38 +0100216
Russell Kinge6b9c1f2011-01-22 11:02:10 +0000217 if (var->bits_per_pixel <= 8 ||
218 (var->bits_per_pixel == 16 && var->green.length == 5))
219 /* Pseudocolor, RGB555, BGR555 */
220 val |= CM_CTRL_LCDMUXSEL_VGA555_TFT555;
Russell King4774e222005-04-30 23:32:38 +0100221 else if (fb->fb.var.bits_per_pixel <= 16)
Russell Kinge6b9c1f2011-01-22 11:02:10 +0000222 /* truecolor RGB565 */
223 val |= CM_CTRL_LCDMUXSEL_VGA565_TFT555;
Russell King4774e222005-04-30 23:32:38 +0100224 else
225 val = 0; /* no idea for this, don't trust the docs */
226
227 cm_control(CM_CTRL_LCDMUXSEL_MASK|
228 CM_CTRL_LCDEN0|
229 CM_CTRL_LCDEN1|
230 CM_CTRL_STATIC1|
231 CM_CTRL_STATIC2|
232 CM_CTRL_STATIC|
233 CM_CTRL_n24BITEN, val);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700234}
235
Linus Torvalds1da177e2005-04-16 15:20:36 -0700236static int cp_clcd_setup(struct clcd_fb *fb)
237{
Russell King9dfec4f2011-01-18 20:10:10 +0000238 fb->panel = versatile_clcd_get_panel("VGA");
239 if (!fb->panel)
240 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700241
Russell King9dfec4f2011-01-18 20:10:10 +0000242 return versatile_clcd_setup_dma(fb, SZ_1M);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700243}
244
245static struct clcd_board clcd_data = {
246 .name = "Integrator/CP",
Russell King9dfec4f2011-01-18 20:10:10 +0000247 .caps = CLCD_CAP_5551 | CLCD_CAP_RGB565 | CLCD_CAP_888,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700248 .check = clcdfb_check,
249 .decode = clcdfb_decode,
250 .enable = cp_clcd_enable,
251 .setup = cp_clcd_setup,
Russell King9dfec4f2011-01-18 20:10:10 +0000252 .mmap = versatile_clcd_mmap_dma,
253 .remove = versatile_clcd_remove_dma,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700254};
255
Russell Kingd77e2702011-01-22 11:37:54 +0000256#define REFCOUNTER (__io_address(INTEGRATOR_HDR_BASE) + 0x28)
257
Russell Kingc735c982011-01-11 13:00:04 +0000258static void __init intcp_init_early(void)
259{
Russell Kingd77e2702011-01-22 11:37:54 +0000260#ifdef CONFIG_PLAT_VERSATILE_SCHED_CLOCK
261 versatile_sched_clock_init(REFCOUNTER, 24000000);
262#endif
Russell Kingc735c982011-01-11 13:00:04 +0000263}
264
Olof Johansson6e3a78d2012-10-07 10:42:40 -0700265#ifdef CONFIG_OF
266
Linus Walleij4980f9b2012-09-06 09:08:24 +0100267static void __init intcp_timer_init_of(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700268{
Linus Walleij4980f9b2012-09-06 09:08:24 +0100269 struct device_node *node;
270 const char *path;
271 void __iomem *base;
272 int err;
273 int irq;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700274
Linus Walleij4980f9b2012-09-06 09:08:24 +0100275 err = of_property_read_string(of_aliases,
276 "arm,timer-primary", &path);
277 if (WARN_ON(err))
278 return;
279 node = of_find_node_by_path(path);
280 base = of_iomap(node, 0);
281 if (WARN_ON(!base))
282 return;
283 writel(0, base + TIMER_CTRL);
284 sp804_clocksource_init(base, node->name);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700285
Linus Walleij4980f9b2012-09-06 09:08:24 +0100286 err = of_property_read_string(of_aliases,
287 "arm,timer-secondary", &path);
288 if (WARN_ON(err))
289 return;
290 node = of_find_node_by_path(path);
291 base = of_iomap(node, 0);
292 if (WARN_ON(!base))
293 return;
294 irq = irq_of_parse_and_map(node, 0);
295 writel(0, base + TIMER_CTRL);
296 sp804_clockevents_init(base, irq, node->name);
297}
298
299static struct sys_timer cp_of_timer = {
300 .init = intcp_timer_init_of,
301};
302
Linus Walleij4980f9b2012-09-06 09:08:24 +0100303static const struct of_device_id fpga_irq_of_match[] __initconst = {
304 { .compatible = "arm,versatile-fpga-irq", .data = fpga_irq_of_init, },
305 { /* Sentinel */ }
306};
307
308static void __init intcp_init_irq_of(void)
309{
310 of_irq_init(fpga_irq_of_match);
311 integrator_clk_init(true);
312}
313
Linus Walleij4672cdd2012-09-06 09:08:47 +0100314/*
315 * For the Device Tree, add in the UART, MMC and CLCD specifics as AUXDATA
316 * and enforce the bus names since these are used for clock lookups.
317 */
318static struct of_dev_auxdata intcp_auxdata_lookup[] __initdata = {
319 OF_DEV_AUXDATA("arm,primecell", INTEGRATOR_RTC_BASE,
320 "rtc", NULL),
321 OF_DEV_AUXDATA("arm,primecell", INTEGRATOR_UART0_BASE,
322 "uart0", &integrator_uart_data),
323 OF_DEV_AUXDATA("arm,primecell", INTEGRATOR_UART1_BASE,
324 "uart1", &integrator_uart_data),
325 OF_DEV_AUXDATA("arm,primecell", KMI0_BASE,
326 "kmi0", NULL),
327 OF_DEV_AUXDATA("arm,primecell", KMI1_BASE,
328 "kmi1", NULL),
329 OF_DEV_AUXDATA("arm,primecell", INTEGRATOR_CP_MMC_BASE,
330 "mmci", &mmc_data),
331 OF_DEV_AUXDATA("arm,primecell", INTEGRATOR_CP_AACI_BASE,
332 "aaci", &mmc_data),
333 OF_DEV_AUXDATA("arm,primecell", INTCP_PA_CLCD_BASE,
334 "clcd", &clcd_data),
Linus Walleij73efd532012-09-06 09:09:11 +0100335 OF_DEV_AUXDATA("cfi-flash", INTCP_PA_FLASH_BASE,
336 "physmap-flash", &intcp_flash_data),
Linus Walleij4672cdd2012-09-06 09:08:47 +0100337 { /* sentinel */ },
338};
339
Linus Walleij64100a02012-11-02 01:20:43 +0100340/* Base address to the CP controller */
341static void __iomem *intcp_con_base;
342
Linus Walleij4672cdd2012-09-06 09:08:47 +0100343static void __init intcp_init_of(void)
344{
Linus Walleij64100a02012-11-02 01:20:43 +0100345 struct device_node *root;
346 struct device_node *cpcon;
347 struct device *parent;
348 struct soc_device *soc_dev;
349 struct soc_device_attribute *soc_dev_attr;
350 u32 intcp_sc_id;
351 int err;
352
353 /* Here we create an SoC device for the root node */
354 root = of_find_node_by_path("/");
355 if (!root)
356 return;
357 cpcon = of_find_node_by_path("/cpcon");
358 if (!cpcon)
359 return;
360
361 intcp_con_base = of_iomap(cpcon, 0);
362 if (!intcp_con_base)
363 return;
364
365 intcp_sc_id = readl(intcp_con_base);
366
367 soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL);
368 if (!soc_dev_attr)
369 return;
370
371 err = of_property_read_string(root, "compatible",
372 &soc_dev_attr->soc_id);
373 if (err)
374 return;
375 err = of_property_read_string(root, "model", &soc_dev_attr->machine);
376 if (err)
377 return;
378 soc_dev_attr->family = "Integrator";
379 soc_dev_attr->revision = kasprintf(GFP_KERNEL, "%c",
380 'A' + (intcp_sc_id & 0x0f));
381
382 soc_dev = soc_device_register(soc_dev_attr);
383 if (IS_ERR_OR_NULL(soc_dev)) {
384 kfree(soc_dev_attr->revision);
385 kfree(soc_dev_attr);
386 return;
387 }
388
389 parent = soc_device_to_device(soc_dev);
390
391 if (!IS_ERR_OR_NULL(parent))
392 integrator_init_sysfs(parent, intcp_sc_id);
393
394 of_platform_populate(root, of_default_bus_match_table,
395 intcp_auxdata_lookup, parent);
Linus Walleij4672cdd2012-09-06 09:08:47 +0100396}
397
Linus Walleij4980f9b2012-09-06 09:08:24 +0100398static const char * intcp_dt_board_compat[] = {
399 "arm,integrator-cp",
400 NULL,
401};
402
403DT_MACHINE_START(INTEGRATOR_CP_DT, "ARM Integrator/CP (Device Tree)")
404 .reserve = integrator_reserve,
405 .map_io = intcp_map_io,
406 .nr_irqs = NR_IRQS_INTEGRATOR_CP,
407 .init_early = intcp_init_early,
408 .init_irq = intcp_init_irq_of,
409 .handle_irq = fpga_handle_irq,
410 .timer = &cp_of_timer,
Linus Walleij4672cdd2012-09-06 09:08:47 +0100411 .init_machine = intcp_init_of,
Linus Walleij4980f9b2012-09-06 09:08:24 +0100412 .restart = integrator_restart,
413 .dt_compat = intcp_dt_board_compat,
414MACHINE_END
415
416#endif
417
418#ifdef CONFIG_ATAGS
419
420/*
421 * This is where non-devicetree initialization code is collected and stashed
422 * for eventual deletion.
423 */
424
Linus Walleij73efd532012-09-06 09:09:11 +0100425#define INTCP_FLASH_SIZE SZ_32M
426
427static struct resource intcp_flash_resource = {
428 .start = INTCP_PA_FLASH_BASE,
429 .end = INTCP_PA_FLASH_BASE + INTCP_FLASH_SIZE - 1,
430 .flags = IORESOURCE_MEM,
431};
432
433static struct platform_device intcp_flash_device = {
434 .name = "physmap-flash",
435 .id = 0,
436 .dev = {
437 .platform_data = &intcp_flash_data,
438 },
439 .num_resources = 1,
440 .resource = &intcp_flash_resource,
441};
442
443#define INTCP_ETH_SIZE 0x10
444
445static struct resource smc91x_resources[] = {
446 [0] = {
447 .start = INTEGRATOR_CP_ETH_BASE,
448 .end = INTEGRATOR_CP_ETH_BASE + INTCP_ETH_SIZE - 1,
449 .flags = IORESOURCE_MEM,
450 },
451 [1] = {
452 .start = IRQ_CP_ETHINT,
453 .end = IRQ_CP_ETHINT,
454 .flags = IORESOURCE_IRQ,
455 },
456};
457
458static struct platform_device smc91x_device = {
459 .name = "smc91x",
460 .id = 0,
461 .num_resources = ARRAY_SIZE(smc91x_resources),
462 .resource = smc91x_resources,
463};
464
465static struct platform_device *intcp_devs[] __initdata = {
466 &intcp_flash_device,
467 &smc91x_device,
468};
469
Linus Walleij4980f9b2012-09-06 09:08:24 +0100470#define INTCP_VA_CIC_BASE __io_address(INTEGRATOR_HDR_BASE + 0x40)
471#define INTCP_VA_PIC_BASE __io_address(INTEGRATOR_IC_BASE)
472#define INTCP_VA_SIC_BASE __io_address(INTEGRATOR_CP_SIC_BASE)
473
474static void __init intcp_init_irq(void)
475{
476 u32 pic_mask, cic_mask, sic_mask;
477
478 /* These masks are for the HW IRQ registers */
479 pic_mask = ~((~0u) << (11 - IRQ_PIC_START));
480 pic_mask |= (~((~0u) << (29 - 22))) << 22;
481 cic_mask = ~((~0u) << (1 + IRQ_CIC_END - IRQ_CIC_START));
482 sic_mask = ~((~0u) << (1 + IRQ_SIC_END - IRQ_SIC_START));
483
484 /*
485 * Disable all interrupt sources
486 */
487 writel(0xffffffff, INTCP_VA_PIC_BASE + IRQ_ENABLE_CLEAR);
488 writel(0xffffffff, INTCP_VA_PIC_BASE + FIQ_ENABLE_CLEAR);
489 writel(0xffffffff, INTCP_VA_CIC_BASE + IRQ_ENABLE_CLEAR);
490 writel(0xffffffff, INTCP_VA_CIC_BASE + FIQ_ENABLE_CLEAR);
491 writel(sic_mask, INTCP_VA_SIC_BASE + IRQ_ENABLE_CLEAR);
492 writel(sic_mask, INTCP_VA_SIC_BASE + FIQ_ENABLE_CLEAR);
493
494 fpga_irq_init(INTCP_VA_PIC_BASE, "PIC", IRQ_PIC_START,
495 -1, pic_mask, NULL);
496
497 fpga_irq_init(INTCP_VA_CIC_BASE, "CIC", IRQ_CIC_START,
498 -1, cic_mask, NULL);
499
500 fpga_irq_init(INTCP_VA_SIC_BASE, "SIC", IRQ_SIC_START,
501 IRQ_CP_CPPLDINT, sic_mask, NULL);
502
503 integrator_clk_init(true);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700504}
505
Russell King5a463342010-01-16 23:52:12 +0000506#define TIMER0_VA_BASE __io_address(INTEGRATOR_TIMER0_BASE)
507#define TIMER1_VA_BASE __io_address(INTEGRATOR_TIMER1_BASE)
508#define TIMER2_VA_BASE __io_address(INTEGRATOR_TIMER2_BASE)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700509
510static void __init intcp_timer_init(void)
511{
Russell King5a463342010-01-16 23:52:12 +0000512 writel(0, TIMER0_VA_BASE + TIMER_CTRL);
513 writel(0, TIMER1_VA_BASE + TIMER_CTRL);
514 writel(0, TIMER2_VA_BASE + TIMER_CTRL);
515
Russell Kingfb593cf2011-05-12 12:08:23 +0100516 sp804_clocksource_init(TIMER2_VA_BASE, "timer2");
Russell King57cc4f72011-05-12 15:31:13 +0100517 sp804_clockevents_init(TIMER1_VA_BASE, IRQ_TIMERINT1, "timer1");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700518}
519
520static struct sys_timer cp_timer = {
521 .init = intcp_timer_init,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700522};
523
Linus Walleij4672cdd2012-09-06 09:08:47 +0100524#define INTEGRATOR_CP_MMC_IRQS { IRQ_CP_MMCIINT0, IRQ_CP_MMCIINT1 }
525#define INTEGRATOR_CP_AACI_IRQS { IRQ_CP_AACIINT }
526
527static AMBA_APB_DEVICE(mmc, "mmci", 0, INTEGRATOR_CP_MMC_BASE,
528 INTEGRATOR_CP_MMC_IRQS, &mmc_data);
529
530static AMBA_APB_DEVICE(aaci, "aaci", 0, INTEGRATOR_CP_AACI_BASE,
531 INTEGRATOR_CP_AACI_IRQS, NULL);
532
533static AMBA_AHB_DEVICE(clcd, "clcd", 0, INTCP_PA_CLCD_BASE,
534 { IRQ_CP_CLCDCINT }, &clcd_data);
535
536static struct amba_device *amba_devs[] __initdata = {
537 &mmc_device,
538 &aaci_device,
539 &clcd_device,
540};
541
542static void __init intcp_init(void)
543{
544 int i;
545
546 platform_add_devices(intcp_devs, ARRAY_SIZE(intcp_devs));
547
548 for (i = 0; i < ARRAY_SIZE(amba_devs); i++) {
549 struct amba_device *d = amba_devs[i];
550 amba_device_register(d, &iomem_resource);
551 }
552 integrator_init(true);
553}
554
Linus Torvalds1da177e2005-04-16 15:20:36 -0700555MACHINE_START(CINTEGRATOR, "ARM-IntegratorCP")
Russell Kinge9dea0c2005-07-03 17:38:58 +0100556 /* Maintainer: ARM Ltd/Deep Blue Solutions Ltd */
Nicolas Pitrec5e587a2011-07-05 22:38:12 -0400557 .atag_offset = 0x100,
Russell King98c672c2010-05-22 18:18:57 +0100558 .reserve = integrator_reserve,
Russell Kingc735c982011-01-11 13:00:04 +0000559 .map_io = intcp_map_io,
Linus Walleij695436e2012-02-26 10:46:48 +0100560 .nr_irqs = NR_IRQS_INTEGRATOR_CP,
Russell Kingc735c982011-01-11 13:00:04 +0000561 .init_early = intcp_init_early,
Russell Kinge9dea0c2005-07-03 17:38:58 +0100562 .init_irq = intcp_init_irq,
Linus Walleij3108e6a2012-04-28 14:33:47 +0100563 .handle_irq = fpga_handle_irq,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700564 .timer = &cp_timer,
Russell Kinge9dea0c2005-07-03 17:38:58 +0100565 .init_machine = intcp_init,
Russell King6338b662011-11-03 19:54:37 +0000566 .restart = integrator_restart,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700567MACHINE_END
Linus Walleij4980f9b2012-09-06 09:08:24 +0100568
569#endif