GUI: Fix Tomato RAF theme for all builds. Compilation typo.
[tomato.git] / release / src-rt-6.x.4708 / linux / linux-2.6.36 / arch / sh / cchips / hd6446x / hd64461.c
blobbcb31ae84a5183118b07d5e6bc25c2d10bc8ba31
1 /*
2 * Copyright (C) 2000 YAEGASHI Takeshi
3 * Hitachi HD64461 companion chip support
4 */
6 #include <linux/sched.h>
7 #include <linux/module.h>
8 #include <linux/kernel.h>
9 #include <linux/param.h>
10 #include <linux/interrupt.h>
11 #include <linux/init.h>
12 #include <linux/irq.h>
13 #include <linux/io.h>
14 #include <asm/irq.h>
15 #include <asm/hd64461.h>
17 /* This belongs in cpu specific */
18 #define INTC_ICR1 0xA4140010UL
20 static void hd64461_mask_irq(unsigned int irq)
22 unsigned short nimr;
23 unsigned short mask = 1 << (irq - HD64461_IRQBASE);
25 nimr = __raw_readw(HD64461_NIMR);
26 nimr |= mask;
27 __raw_writew(nimr, HD64461_NIMR);
30 static void hd64461_unmask_irq(unsigned int irq)
32 unsigned short nimr;
33 unsigned short mask = 1 << (irq - HD64461_IRQBASE);
35 nimr = __raw_readw(HD64461_NIMR);
36 nimr &= ~mask;
37 __raw_writew(nimr, HD64461_NIMR);
40 static void hd64461_mask_and_ack_irq(unsigned int irq)
42 hd64461_mask_irq(irq);
43 #ifdef CONFIG_HD64461_ENABLER
44 if (irq == HD64461_IRQBASE + 13)
45 __raw_writeb(0x00, HD64461_PCC1CSCR);
46 #endif
49 static struct irq_chip hd64461_irq_chip = {
50 .name = "HD64461-IRQ",
51 .mask = hd64461_mask_irq,
52 .mask_ack = hd64461_mask_and_ack_irq,
53 .unmask = hd64461_unmask_irq,
56 static void hd64461_irq_demux(unsigned int irq, struct irq_desc *desc)
58 unsigned short intv = __raw_readw(HD64461_NIRR);
59 unsigned int ext_irq = HD64461_IRQBASE;
61 intv &= (1 << HD64461_IRQ_NUM) - 1;
63 for (; intv; intv >>= 1, ext_irq++) {
64 if (!(intv & 1))
65 continue;
67 generic_handle_irq(ext_irq);
71 int __init setup_hd64461(void)
73 int i, nid = cpu_to_node(boot_cpu_data);
75 if (!MACH_HD64461)
76 return 0;
78 printk(KERN_INFO
79 "HD64461 configured at 0x%x on irq %d(mapped into %d to %d)\n",
80 HD64461_IOBASE, CONFIG_HD64461_IRQ, HD64461_IRQBASE,
81 HD64461_IRQBASE + 15);
83 /* Should be at processor specific part.. */
84 #if defined(CONFIG_CPU_SUBTYPE_SH7709)
85 __raw_writew(0x2240, INTC_ICR1);
86 #endif
87 __raw_writew(0xffff, HD64461_NIMR);
89 /* IRQ 80 -> 95 belongs to HD64461 */
90 for (i = HD64461_IRQBASE; i < HD64461_IRQBASE + 16; i++) {
91 unsigned int irq;
93 irq = create_irq_nr(i, nid);
94 if (unlikely(irq == 0)) {
95 pr_err("%s: failed hooking irq %d for HD64461\n",
96 __func__, i);
97 return -EBUSY;
100 if (unlikely(irq != i)) {
101 pr_err("%s: got irq %d but wanted %d, bailing.\n",
102 __func__, irq, i);
103 destroy_irq(irq);
104 return -EINVAL;
107 set_irq_chip_and_handler(i, &hd64461_irq_chip,
108 handle_level_irq);
111 set_irq_chained_handler(CONFIG_HD64461_IRQ, hd64461_irq_demux);
112 set_irq_type(CONFIG_HD64461_IRQ, IRQ_TYPE_LEVEL_LOW);
114 #ifdef CONFIG_HD64461_ENABLER
115 printk(KERN_INFO "HD64461: enabling PCMCIA devices\n");
116 __raw_writeb(0x4c, HD64461_PCC1CSCIER);
117 __raw_writeb(0x00, HD64461_PCC1CSCR);
118 #endif
120 return 0;
123 module_init(setup_hd64461);