blob: 3d7bd50b9095ba30abc98130c86a0efd9ae86bfd [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/* arch/arm/mach-lh7a40x/arch-kev7a400.c
2 *
3 * Copyright (C) 2004 Logic Product Development
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * version 2 as published by the Free Software Foundation.
8 *
9 */
10
11#include <linux/tty.h>
12#include <linux/init.h>
13#include <linux/device.h>
14#include <linux/interrupt.h>
15
Russell Kinga09e64f2008-08-05 16:14:15 +010016#include <mach/hardware.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070017#include <asm/setup.h>
18#include <asm/mach-types.h>
19#include <asm/mach/arch.h>
20#include <asm/irq.h>
21#include <asm/mach/irq.h>
22#include <asm/mach/map.h>
23
24#include "common.h"
25
26 /* This function calls the board specific IRQ initialization function. */
27
28static struct map_desc kev7a400_io_desc[] __initdata = {
Deepak Saxena36d28c02005-10-28 15:18:59 +010029 {
30 .virtual = IO_VIRT,
31 .pfn = __phys_to_pfn(IO_PHYS),
32 .length = IO_SIZE,
33 .type = MT_DEVICE
34 }, {
35 .virtual = CPLD_VIRT,
36 .pfn = __phys_to_pfn(CPLD_PHYS),
37 .length = CPLD_SIZE,
38 .type = MT_DEVICE
39 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070040};
41
42void __init kev7a400_map_io(void)
43{
44 iotable_init (kev7a400_io_desc, ARRAY_SIZE (kev7a400_io_desc));
45}
46
47static u16 CPLD_IRQ_mask; /* Mask for CPLD IRQs, 1 == unmasked */
48
49static void kev7a400_ack_cpld_irq (u32 irq)
50{
51 CPLD_CL_INT = 1 << (irq - IRQ_KEV7A400_CPLD);
52}
53
54static void kev7a400_mask_cpld_irq (u32 irq)
55{
56 CPLD_IRQ_mask &= ~(1 << (irq - IRQ_KEV7A400_CPLD));
57 CPLD_WR_PB_INT_MASK = CPLD_IRQ_mask;
58}
59
60static void kev7a400_unmask_cpld_irq (u32 irq)
61{
62 CPLD_IRQ_mask |= 1 << (irq - IRQ_KEV7A400_CPLD);
63 CPLD_WR_PB_INT_MASK = CPLD_IRQ_mask;
64}
65
David Brownell38c677c2006-08-01 22:26:25 +010066static struct irq_chip kev7a400_cpld_chip = {
67 .name = "CPLD",
Linus Torvalds1da177e2005-04-16 15:20:36 -070068 .ack = kev7a400_ack_cpld_irq,
69 .mask = kev7a400_mask_cpld_irq,
70 .unmask = kev7a400_unmask_cpld_irq,
71};
72
73
Russell King10dd5ce2006-11-23 11:41:32 +000074static void kev7a400_cpld_handler (unsigned int irq, struct irq_desc *desc)
Linus Torvalds1da177e2005-04-16 15:20:36 -070075{
76 u32 mask = CPLD_LATCHED_INTS;
77 irq = IRQ_KEV7A400_CPLD;
Russell Kingd8d90752008-04-20 16:40:47 +010078 for (; mask; mask >>= 1, ++irq)
Linus Torvalds1da177e2005-04-16 15:20:36 -070079 if (mask & 1)
Dmitry Baryshkovd8aa0252008-10-09 13:36:24 +010080 generic_handle_irq(irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -070081}
82
83void __init lh7a40x_init_board_irq (void)
84{
85 int irq;
86
87 for (irq = IRQ_KEV7A400_CPLD;
88 irq < IRQ_KEV7A400_CPLD + NR_IRQ_BOARD; ++irq) {
89 set_irq_chip (irq, &kev7a400_cpld_chip);
Russell King10dd5ce2006-11-23 11:41:32 +000090 set_irq_handler (irq, handle_edge_irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -070091 set_irq_flags (irq, IRQF_VALID);
92 }
93 set_irq_chained_handler (IRQ_CPLD, kev7a400_cpld_handler);
94
95 /* Clear all CPLD interrupts */
96 CPLD_CL_INT = 0xff; /* CPLD_INTR_MMC_CD | CPLD_INTR_ETH_INT; */
97
98 GPIO_GPIOINTEN = 0; /* Disable all GPIO interrupts */
99 barrier();
100
101#if 0
102 GPIO_INTTYPE1
103 = (GPIO_INTR_PCC1_CD | GPIO_INTR_PCC1_CD); /* Edge trig. */
104 GPIO_INTTYPE2 = 0; /* Falling edge & low-level */
105 GPIO_GPIOFEOI = 0xff; /* Clear all GPIO interrupts */
106 GPIO_GPIOINTEN = 0xff; /* Enable all GPIO interrupts */
107
108 init_FIQ();
109#endif
110}
111
112MACHINE_START (KEV7A400, "Sharp KEV7a400")
Russell Kinge9dea0c2005-07-03 17:38:58 +0100113 /* Maintainer: Marc Singer */
Russell Kinge9dea0c2005-07-03 17:38:58 +0100114 .phys_io = 0x80000000,
115 .io_pg_offst = ((io_p2v (0x80000000))>>18) & 0xfffc,
116 .boot_params = 0xc0000100,
117 .map_io = kev7a400_map_io,
118 .init_irq = lh7a400_init_irq,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700119 .timer = &lh7a40x_timer,
120MACHINE_END