aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-s3c24xx/irq.c
diff options
context:
space:
mode:
authorHeiko Stuebner <heiko@sntech.de>2013-02-12 13:09:13 -0500
committerKukjin Kim <kgene.kim@samsung.com>2013-03-05 06:21:04 -0500
commitd3d5a2c9e6cf9723fe7ba9ad918540ad53ae381c (patch)
tree2b8dbc05126bde2aa9fd6d2e314c72022e6800e4 /arch/arm/mach-s3c24xx/irq.c
parent592957085e3763b9339a6a281f1aeb1247cdd245 (diff)
ARM: S3C24XX: move s3c2412 irq init to common code
Base for further cleanups Signed-off-by: Heiko Stuebner <heiko@sntech.de> Signed-off-by: Kukjin Kim <kgene.kim@samsung.com>
Diffstat (limited to 'arch/arm/mach-s3c24xx/irq.c')
-rw-r--r--arch/arm/mach-s3c24xx/irq.c154
1 files changed, 154 insertions, 0 deletions
diff --git a/arch/arm/mach-s3c24xx/irq.c b/arch/arm/mach-s3c24xx/irq.c
index ddb6752e5948..2bb4a97e527e 100644
--- a/arch/arm/mach-s3c24xx/irq.c
+++ b/arch/arm/mach-s3c24xx/irq.c
@@ -626,6 +626,160 @@ void __init s3c24xx_init_irq(void)
626 s3c24xx_init_intc(NULL, &init_eint[0], main_intc, 0x560000a4); 626 s3c24xx_init_intc(NULL, &init_eint[0], main_intc, 0x560000a4);
627} 627}
628 628
629#ifdef CONFIG_CPU_S3C2412
630
631#define INTMSK(start, end) ((1 << ((end) + 1 - (start))) - 1)
632#define INTMSK_SUB(start, end) (INTMSK(start, end) << ((start - S3C2410_IRQSUB(0))))
633
634/* the s3c2412 changes the behaviour of IRQ_EINT0 through IRQ_EINT3 by
635 * having them turn up in both the INT* and the EINT* registers. Whilst
636 * both show the status, they both now need to be acked when the IRQs
637 * go off.
638*/
639
640static void
641s3c2412_irq_mask(struct irq_data *data)
642{
643 unsigned long bitval = 1UL << (data->irq - IRQ_EINT0);
644 unsigned long mask;
645
646 mask = __raw_readl(S3C2410_INTMSK);
647 __raw_writel(mask | bitval, S3C2410_INTMSK);
648
649 mask = __raw_readl(S3C2412_EINTMASK);
650 __raw_writel(mask | bitval, S3C2412_EINTMASK);
651}
652
653static inline void
654s3c2412_irq_ack(struct irq_data *data)
655{
656 unsigned long bitval = 1UL << (data->irq - IRQ_EINT0);
657
658 __raw_writel(bitval, S3C2412_EINTPEND);
659 __raw_writel(bitval, S3C2410_SRCPND);
660 __raw_writel(bitval, S3C2410_INTPND);
661}
662
663static inline void
664s3c2412_irq_maskack(struct irq_data *data)
665{
666 unsigned long bitval = 1UL << (data->irq - IRQ_EINT0);
667 unsigned long mask;
668
669 mask = __raw_readl(S3C2410_INTMSK);
670 __raw_writel(mask|bitval, S3C2410_INTMSK);
671
672 mask = __raw_readl(S3C2412_EINTMASK);
673 __raw_writel(mask | bitval, S3C2412_EINTMASK);
674
675 __raw_writel(bitval, S3C2412_EINTPEND);
676 __raw_writel(bitval, S3C2410_SRCPND);
677 __raw_writel(bitval, S3C2410_INTPND);
678}
679
680static void
681s3c2412_irq_unmask(struct irq_data *data)
682{
683 unsigned long bitval = 1UL << (data->irq - IRQ_EINT0);
684 unsigned long mask;
685
686 mask = __raw_readl(S3C2412_EINTMASK);
687 __raw_writel(mask & ~bitval, S3C2412_EINTMASK);
688
689 mask = __raw_readl(S3C2410_INTMSK);
690 __raw_writel(mask & ~bitval, S3C2410_INTMSK);
691}
692
693static struct irq_chip s3c2412_irq_eint0t4 = {
694 .irq_ack = s3c2412_irq_ack,
695 .irq_mask = s3c2412_irq_mask,
696 .irq_unmask = s3c2412_irq_unmask,
697 .irq_set_wake = s3c_irq_wake,
698 .irq_set_type = s3c_irqext_type,
699};
700
701#define INTBIT(x) (1 << ((x) - S3C2410_IRQSUB(0)))
702
703/* CF and SDI sub interrupts */
704
705static void s3c2412_irq_demux_cfsdi(unsigned int irq, struct irq_desc *desc)
706{
707 unsigned int subsrc, submsk;
708
709 subsrc = __raw_readl(S3C2410_SUBSRCPND);
710 submsk = __raw_readl(S3C2410_INTSUBMSK);
711
712 subsrc &= ~submsk;
713
714 if (subsrc & INTBIT(IRQ_S3C2412_SDI))
715 generic_handle_irq(IRQ_S3C2412_SDI);
716
717 if (subsrc & INTBIT(IRQ_S3C2412_CF))
718 generic_handle_irq(IRQ_S3C2412_CF);
719}
720
721#define INTMSK_CFSDI (1UL << (IRQ_S3C2412_CFSDI - IRQ_EINT0))
722#define SUBMSK_CFSDI INTMSK_SUB(IRQ_S3C2412_SDI, IRQ_S3C2412_CF)
723
724static void s3c2412_irq_cfsdi_mask(struct irq_data *data)
725{
726 s3c_irqsub_mask(data->irq, INTMSK_CFSDI, SUBMSK_CFSDI);
727}
728
729static void s3c2412_irq_cfsdi_unmask(struct irq_data *data)
730{
731 s3c_irqsub_unmask(data->irq, INTMSK_CFSDI);
732}
733
734static void s3c2412_irq_cfsdi_ack(struct irq_data *data)
735{
736 s3c_irqsub_maskack(data->irq, INTMSK_CFSDI, SUBMSK_CFSDI);
737}
738
739static struct irq_chip s3c2412_irq_cfsdi = {
740 .name = "s3c2412-cfsdi",
741 .irq_ack = s3c2412_irq_cfsdi_ack,
742 .irq_mask = s3c2412_irq_cfsdi_mask,
743 .irq_unmask = s3c2412_irq_cfsdi_unmask,
744};
745
746static int s3c2412_irq_add(struct device *dev, struct subsys_interface *sif)
747{
748 unsigned int irqno;
749
750 for (irqno = IRQ_EINT0; irqno <= IRQ_EINT3; irqno++) {
751 irq_set_chip_and_handler(irqno, &s3c2412_irq_eint0t4,
752 handle_edge_irq);
753 set_irq_flags(irqno, IRQF_VALID);
754 }
755
756 /* add demux support for CF/SDI */
757
758 irq_set_chained_handler(IRQ_S3C2412_CFSDI, s3c2412_irq_demux_cfsdi);
759
760 for (irqno = IRQ_S3C2412_SDI; irqno <= IRQ_S3C2412_CF; irqno++) {
761 irq_set_chip_and_handler(irqno, &s3c2412_irq_cfsdi,
762 handle_level_irq);
763 set_irq_flags(irqno, IRQF_VALID);
764 }
765
766 return 0;
767}
768
769static struct subsys_interface s3c2412_irq_interface = {
770 .name = "s3c2412_irq",
771 .subsys = &s3c2412_subsys,
772 .add_dev = s3c2412_irq_add,
773};
774
775static int s3c2412_irq_init(void)
776{
777 return subsys_interface_register(&s3c2412_irq_interface);
778}
779
780arch_initcall(s3c2412_irq_init);
781#endif
782
629#ifdef CONFIG_CPU_S3C2416 783#ifdef CONFIG_CPU_S3C2416
630static struct s3c_irq_data init_s3c2416base[32] = { 784static struct s3c_irq_data init_s3c2416base[32] = {
631 { .type = S3C_IRQTYPE_EINT, }, /* EINT0 */ 785 { .type = S3C_IRQTYPE_EINT, }, /* EINT0 */