28 #include <linux/export.h>
31 #include <linux/slab.h>
39 #define IC_CFG0RD 0x40
40 #define IC_CFG0SET 0x40
41 #define IC_CFG0CLR 0x44
42 #define IC_CFG1RD 0x48
43 #define IC_CFG1SET 0x48
44 #define IC_CFG1CLR 0x4C
45 #define IC_CFG2RD 0x50
46 #define IC_CFG2SET 0x50
47 #define IC_CFG2CLR 0x54
48 #define IC_REQ0INT 0x54
50 #define IC_SRCSET 0x58
51 #define IC_SRCCLR 0x5C
52 #define IC_REQ1INT 0x5C
53 #define IC_ASSIGNRD 0x60
54 #define IC_ASSIGNSET 0x60
55 #define IC_ASSIGNCLR 0x64
56 #define IC_WAKERD 0x68
57 #define IC_WAKESET 0x68
58 #define IC_WAKECLR 0x6C
59 #define IC_MASKRD 0x70
60 #define IC_MASKSET 0x70
61 #define IC_MASKCLR 0x74
62 #define IC_RISINGRD 0x78
63 #define IC_RISINGCLR 0x78
64 #define IC_FALLINGRD 0x7C
65 #define IC_FALLINGCLR 0x7C
66 #define IC_TESTBIT 0x80
76 static int au1x_ic_settype(
struct irq_data *
d,
unsigned int type);
77 static int au1300_gpic_settype(
struct irq_data *
d,
unsigned int type);
288 static void au1x_ic0_unmask(
struct irq_data *
d)
298 static void au1x_ic1_unmask(
struct irq_data *d)
308 static void au1x_ic0_mask(
struct irq_data *d)
318 static void au1x_ic1_mask(
struct irq_data *d)
328 static void au1x_ic0_ack(
struct irq_data *d)
342 static void au1x_ic1_ack(
struct irq_data *d)
356 static void au1x_ic0_maskack(
struct irq_data *d)
368 static void au1x_ic1_maskack(
struct irq_data *d)
380 static int au1x_ic1_setwake(
struct irq_data *d,
unsigned int on)
383 unsigned long wakemsk,
flags;
388 if ((bit < 0) || (bit > 7))
396 wakemsk &= ~(1 <<
bit);
408 static struct irq_chip au1x_ic0_chip = {
409 .name =
"Alchemy-IC0",
410 .irq_ack = au1x_ic0_ack,
411 .irq_mask = au1x_ic0_mask,
412 .irq_mask_ack = au1x_ic0_maskack,
413 .irq_unmask = au1x_ic0_unmask,
414 .irq_set_type = au1x_ic_settype,
417 static struct irq_chip au1x_ic1_chip = {
418 .name =
"Alchemy-IC1",
419 .irq_ack = au1x_ic1_ack,
420 .irq_mask = au1x_ic1_mask,
421 .irq_mask_ack = au1x_ic1_maskack,
422 .irq_unmask = au1x_ic1_unmask,
423 .irq_set_type = au1x_ic_settype,
424 .irq_set_wake = au1x_ic1_setwake,
427 static int au1x_ic_settype(
struct irq_data *d,
unsigned int flow_type)
438 chip = &au1x_ic1_chip;
442 chip = &au1x_ic0_chip;
495 __irq_set_chip_handler_name_locked(d->
irq, chip, handler, name);
513 static inline void au1300_gpic_chgcfg(
unsigned int gpio,
586 if ((dchan >= 0) && (dchan <= 1)) {
588 r &= ~(0xff << (8 * dchan));
589 r |= (gpio & 0x7f) << (8 * dchan);
595 static inline void gpic_pin_set_idlewake(
unsigned int gpio,
int allow)
601 static void au1300_gpic_mask(
struct irq_data *d)
604 unsigned long bit, irq = d->
irq;
612 gpic_pin_set_idlewake(irq, 0);
615 static void au1300_gpic_unmask(
struct irq_data *d)
618 unsigned long bit, irq = d->
irq;
622 gpic_pin_set_idlewake(irq, 1);
630 static void au1300_gpic_maskack(
struct irq_data *d)
633 unsigned long bit, irq = d->
irq;
642 gpic_pin_set_idlewake(irq, 0);
645 static void au1300_gpic_ack(
struct irq_data *d)
648 unsigned long bit, irq = d->
irq;
657 static struct irq_chip au1300_gpic = {
659 .irq_ack = au1300_gpic_ack,
660 .irq_mask = au1300_gpic_mask,
661 .irq_mask_ack = au1300_gpic_maskack,
662 .irq_unmask = au1300_gpic_unmask,
663 .irq_set_type = au1300_gpic_settype,
666 static int au1300_gpic_settype(
struct irq_data *d,
unsigned int type)
669 unsigned char *name =
NULL;
707 __irq_set_chip_handler_name_locked(d->
irq, &au1300_gpic, hdl, name);
716 static inline void ic_init(
void __iomem *base)
734 static inline void alchemy_ic_suspend_one(
void __iomem *base,
unsigned long *d)
746 static inline void alchemy_ic_resume_one(
void __iomem *base,
unsigned long *d)
762 static int alchemy_ic_suspend(
void)
765 alchemy_gpic_pmdata);
767 &alchemy_gpic_pmdata[7]);
771 static void alchemy_ic_resume(
void)
774 &alchemy_gpic_pmdata[7]);
776 alchemy_gpic_pmdata);
779 static int alchemy_gpic_suspend(
void)
803 alchemy_gpic_pmdata[i + 5] =
__raw_readl(base + (i << 2));
810 static void alchemy_gpic_resume(
void)
825 __raw_writel(alchemy_gpic_pmdata[i + 5], base + (i << 2));
842 .suspend = alchemy_ic_suspend,
843 .resume = alchemy_ic_resume,
847 .suspend = alchemy_gpic_suspend,
848 .resume = alchemy_gpic_resume,
854 #define DISP(name, base, addr) \
855 static void au1000_##name##_dispatch(unsigned int irq, struct irq_desc *d) \
857 unsigned long r = __raw_readl((void __iomem *)KSEG1ADDR(addr)); \
859 generic_handle_irq(base + __ffs(r)); \
861 spurious_interrupt(); \
869 static
void alchemy_gpic_dispatch(
unsigned int irq,
struct irq_desc *d)
879 unsigned int bit, irq_nr;
890 for (irq_nr = AU1000_INTC0_INT_BASE;
891 (irq_nr < AU1000_INTC0_INT_BASE + 32); irq_nr++)
894 for (irq_nr = AU1000_INTC1_INT_BASE;
895 (irq_nr < AU1000_INTC1_INT_BASE + 32); irq_nr++)
901 while (map->
irq != -1) {
904 if (irq_nr >= AU1000_INTC1_INT_BASE) {
933 for (i = 0; i < 4; i++) {
948 while ((i = dints->
irq) != -1) {
968 switch (alchemy_get_cputype()) {
970 au1000_init_irq(au1000_irqmap);
973 au1000_init_irq(au1500_irqmap);
976 au1000_init_irq(au1100_irqmap);
979 au1000_init_irq(au1550_irqmap);
982 au1000_init_irq(au1200_irqmap);
985 alchemy_gpic_init_irq(au1300_irqmap);
988 pr_err(
"unknown Alchemy IRQ core\n");