2 * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd.
3 * http://www.samsung.com
5 * Common Codes for EXYNOS
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
12 #include <linux/kernel.h>
13 #include <linux/interrupt.h>
14 #include <linux/irq.h>
16 #include <linux/device.h>
17 #include <linux/gpio.h>
18 #include <linux/sched.h>
19 #include <linux/serial_core.h>
21 #include <linux/of_irq.h>
23 #include <asm/proc-fns.h>
24 #include <asm/exception.h>
25 #include <asm/hardware/cache-l2x0.h>
26 #include <asm/hardware/gic.h>
27 #include <asm/mach/map.h>
28 #include <asm/mach/irq.h>
30 #include <mach/regs-irq.h>
31 #include <mach/regs-pmu.h>
32 #include <mach/regs-gpio.h>
35 #include <plat/clock.h>
36 #include <plat/devs.h>
38 #include <plat/sdhci.h>
39 #include <plat/gpio-cfg.h>
40 #include <plat/adc-core.h>
41 #include <plat/fb-core.h>
42 #include <plat/fimc-core.h>
43 #include <plat/iic-core.h>
44 #include <plat/tv-core.h>
45 #include <plat/regs-serial.h>
49 static const char name_exynos4210[] = "EXYNOS4210";
50 static const char name_exynos4212[] = "EXYNOS4212";
51 static const char name_exynos4412[] = "EXYNOS4412";
52 static const char name_exynos5250[] = "EXYNOS5250";
54 static void exynos4_map_io(void);
55 static void exynos5_map_io(void);
56 static void exynos4_init_clocks(int xtal);
57 static void exynos5_init_clocks(int xtal);
58 static void exynos_init_uarts(struct s3c2410_uartcfg *cfg, int no);
59 static int exynos_init(void);
61 static struct cpu_table cpu_ids[] __initdata = {
63 .idcode = EXYNOS4210_CPU_ID,
64 .idmask = EXYNOS4_CPU_MASK,
65 .map_io = exynos4_map_io,
66 .init_clocks = exynos4_init_clocks,
67 .init_uarts = exynos_init_uarts,
69 .name = name_exynos4210,
71 .idcode = EXYNOS4212_CPU_ID,
72 .idmask = EXYNOS4_CPU_MASK,
73 .map_io = exynos4_map_io,
74 .init_clocks = exynos4_init_clocks,
75 .init_uarts = exynos_init_uarts,
77 .name = name_exynos4212,
79 .idcode = EXYNOS4412_CPU_ID,
80 .idmask = EXYNOS4_CPU_MASK,
81 .map_io = exynos4_map_io,
82 .init_clocks = exynos4_init_clocks,
83 .init_uarts = exynos_init_uarts,
85 .name = name_exynos4412,
87 .idcode = EXYNOS5250_SOC_ID,
88 .idmask = EXYNOS5_SOC_MASK,
89 .map_io = exynos5_map_io,
90 .init_clocks = exynos5_init_clocks,
91 .init_uarts = exynos_init_uarts,
93 .name = name_exynos5250,
97 /* Initial IO mappings */
99 static struct map_desc exynos_iodesc[] __initdata = {
101 .virtual = (unsigned long)S5P_VA_CHIPID,
102 .pfn = __phys_to_pfn(EXYNOS_PA_CHIPID),
108 static struct map_desc exynos4_iodesc[] __initdata = {
110 .virtual = (unsigned long)S3C_VA_SYS,
111 .pfn = __phys_to_pfn(EXYNOS4_PA_SYSCON),
115 .virtual = (unsigned long)S3C_VA_TIMER,
116 .pfn = __phys_to_pfn(EXYNOS4_PA_TIMER),
120 .virtual = (unsigned long)S3C_VA_WATCHDOG,
121 .pfn = __phys_to_pfn(EXYNOS4_PA_WATCHDOG),
125 .virtual = (unsigned long)S5P_VA_SROMC,
126 .pfn = __phys_to_pfn(EXYNOS4_PA_SROMC),
130 .virtual = (unsigned long)S5P_VA_SYSTIMER,
131 .pfn = __phys_to_pfn(EXYNOS4_PA_SYSTIMER),
135 .virtual = (unsigned long)S5P_VA_PMU,
136 .pfn = __phys_to_pfn(EXYNOS4_PA_PMU),
140 .virtual = (unsigned long)S5P_VA_COMBINER_BASE,
141 .pfn = __phys_to_pfn(EXYNOS4_PA_COMBINER),
145 .virtual = (unsigned long)S5P_VA_GIC_CPU,
146 .pfn = __phys_to_pfn(EXYNOS4_PA_GIC_CPU),
150 .virtual = (unsigned long)S5P_VA_GIC_DIST,
151 .pfn = __phys_to_pfn(EXYNOS4_PA_GIC_DIST),
155 .virtual = (unsigned long)S3C_VA_UART,
156 .pfn = __phys_to_pfn(EXYNOS4_PA_UART),
160 .virtual = (unsigned long)S5P_VA_CMU,
161 .pfn = __phys_to_pfn(EXYNOS4_PA_CMU),
165 .virtual = (unsigned long)S5P_VA_COREPERI_BASE,
166 .pfn = __phys_to_pfn(EXYNOS4_PA_COREPERI),
170 .virtual = (unsigned long)S5P_VA_L2CC,
171 .pfn = __phys_to_pfn(EXYNOS4_PA_L2CC),
175 .virtual = (unsigned long)S5P_VA_GPIO1,
176 .pfn = __phys_to_pfn(EXYNOS4_PA_GPIO1),
180 .virtual = (unsigned long)S5P_VA_GPIO2,
181 .pfn = __phys_to_pfn(EXYNOS4_PA_GPIO2),
185 .virtual = (unsigned long)S5P_VA_GPIO3,
186 .pfn = __phys_to_pfn(EXYNOS4_PA_GPIO3),
190 .virtual = (unsigned long)S5P_VA_DMC0,
191 .pfn = __phys_to_pfn(EXYNOS4_PA_DMC0),
195 .virtual = (unsigned long)S3C_VA_USB_HSPHY,
196 .pfn = __phys_to_pfn(EXYNOS4_PA_HSPHY),
202 static struct map_desc exynos4_iodesc0[] __initdata = {
204 .virtual = (unsigned long)S5P_VA_SYSRAM,
205 .pfn = __phys_to_pfn(EXYNOS4_PA_SYSRAM0),
211 static struct map_desc exynos4_iodesc1[] __initdata = {
213 .virtual = (unsigned long)S5P_VA_SYSRAM,
214 .pfn = __phys_to_pfn(EXYNOS4_PA_SYSRAM1),
220 static struct map_desc exynos5_iodesc[] __initdata = {
222 .virtual = (unsigned long)S3C_VA_SYS,
223 .pfn = __phys_to_pfn(EXYNOS5_PA_SYSCON),
227 .virtual = (unsigned long)S3C_VA_TIMER,
228 .pfn = __phys_to_pfn(EXYNOS5_PA_TIMER),
232 .virtual = (unsigned long)S3C_VA_WATCHDOG,
233 .pfn = __phys_to_pfn(EXYNOS5_PA_WATCHDOG),
237 .virtual = (unsigned long)S5P_VA_SROMC,
238 .pfn = __phys_to_pfn(EXYNOS5_PA_SROMC),
242 .virtual = (unsigned long)S5P_VA_SYSTIMER,
243 .pfn = __phys_to_pfn(EXYNOS5_PA_SYSTIMER),
247 .virtual = (unsigned long)S5P_VA_SYSRAM,
248 .pfn = __phys_to_pfn(EXYNOS5_PA_SYSRAM),
252 .virtual = (unsigned long)S5P_VA_CMU,
253 .pfn = __phys_to_pfn(EXYNOS5_PA_CMU),
254 .length = 144 * SZ_1K,
257 .virtual = (unsigned long)S5P_VA_PMU,
258 .pfn = __phys_to_pfn(EXYNOS5_PA_PMU),
262 .virtual = (unsigned long)S5P_VA_COMBINER_BASE,
263 .pfn = __phys_to_pfn(EXYNOS5_PA_COMBINER),
267 .virtual = (unsigned long)S3C_VA_UART,
268 .pfn = __phys_to_pfn(EXYNOS5_PA_UART),
272 .virtual = (unsigned long)S5P_VA_GIC_CPU,
273 .pfn = __phys_to_pfn(EXYNOS5_PA_GIC_CPU),
277 .virtual = (unsigned long)S5P_VA_GIC_DIST,
278 .pfn = __phys_to_pfn(EXYNOS5_PA_GIC_DIST),
284 void exynos4_restart(char mode, const char *cmd)
286 __raw_writel(0x1, S5P_SWRESET);
289 void exynos5_restart(char mode, const char *cmd)
291 __raw_writel(0x1, EXYNOS_SWRESET);
297 * register the standard cpu IO areas
300 void __init exynos_init_io(struct map_desc *mach_desc, int size)
302 /* initialize the io descriptors we need for initialization */
303 iotable_init(exynos_iodesc, ARRAY_SIZE(exynos_iodesc));
305 iotable_init(mach_desc, size);
307 /* detect cpu id and rev. */
308 s5p_init_cpu(S5P_VA_CHIPID);
310 s3c_init_cpu(samsung_cpu_id, cpu_ids, ARRAY_SIZE(cpu_ids));
313 static void __init exynos4_map_io(void)
315 iotable_init(exynos4_iodesc, ARRAY_SIZE(exynos4_iodesc));
317 if (soc_is_exynos4210() && samsung_rev() == EXYNOS4210_REV_0)
318 iotable_init(exynos4_iodesc0, ARRAY_SIZE(exynos4_iodesc0));
320 iotable_init(exynos4_iodesc1, ARRAY_SIZE(exynos4_iodesc1));
322 /* initialize device information early */
323 exynos4_default_sdhci0();
324 exynos4_default_sdhci1();
325 exynos4_default_sdhci2();
326 exynos4_default_sdhci3();
328 s3c_adc_setname("samsung-adc-v3");
330 s3c_fimc_setname(0, "exynos4-fimc");
331 s3c_fimc_setname(1, "exynos4-fimc");
332 s3c_fimc_setname(2, "exynos4-fimc");
333 s3c_fimc_setname(3, "exynos4-fimc");
335 /* The I2C bus controllers are directly compatible with s3c2440 */
336 s3c_i2c0_setname("s3c2440-i2c");
337 s3c_i2c1_setname("s3c2440-i2c");
338 s3c_i2c2_setname("s3c2440-i2c");
340 s5p_fb_setname(0, "exynos4-fb");
341 s5p_hdmi_setname("exynos4-hdmi");
344 static void __init exynos5_map_io(void)
346 iotable_init(exynos5_iodesc, ARRAY_SIZE(exynos5_iodesc));
348 s3c_device_i2c0.resource[0].start = EXYNOS5_PA_IIC(0);
349 s3c_device_i2c0.resource[0].end = EXYNOS5_PA_IIC(0) + SZ_4K - 1;
350 s3c_device_i2c0.resource[1].start = EXYNOS5_IRQ_IIC;
351 s3c_device_i2c0.resource[1].end = EXYNOS5_IRQ_IIC;
353 /* The I2C bus controllers are directly compatible with s3c2440 */
354 s3c_i2c0_setname("s3c2440-i2c");
355 s3c_i2c1_setname("s3c2440-i2c");
356 s3c_i2c2_setname("s3c2440-i2c");
359 static void __init exynos4_init_clocks(int xtal)
361 printk(KERN_DEBUG "%s: initializing clocks\n", __func__);
363 s3c24xx_register_baseclocks(xtal);
364 s5p_register_clocks(xtal);
366 if (soc_is_exynos4210())
367 exynos4210_register_clocks();
368 else if (soc_is_exynos4212() || soc_is_exynos4412())
369 exynos4212_register_clocks();
371 exynos4_register_clocks();
372 exynos4_setup_clocks();
375 static void __init exynos5_init_clocks(int xtal)
377 printk(KERN_DEBUG "%s: initializing clocks\n", __func__);
379 s3c24xx_register_baseclocks(xtal);
380 s5p_register_clocks(xtal);
382 exynos5_register_clocks();
383 exynos5_setup_clocks();
386 #define COMBINER_ENABLE_SET 0x0
387 #define COMBINER_ENABLE_CLEAR 0x4
388 #define COMBINER_INT_STATUS 0xC
390 static DEFINE_SPINLOCK(irq_controller_lock);
392 struct combiner_chip_data {
393 unsigned int irq_offset;
394 unsigned int irq_mask;
398 static struct combiner_chip_data combiner_data[MAX_COMBINER_NR];
400 static inline void __iomem *combiner_base(struct irq_data *data)
402 struct combiner_chip_data *combiner_data =
403 irq_data_get_irq_chip_data(data);
405 return combiner_data->base;
408 static void combiner_mask_irq(struct irq_data *data)
410 u32 mask = 1 << (data->irq % 32);
412 __raw_writel(mask, combiner_base(data) + COMBINER_ENABLE_CLEAR);
415 static void combiner_unmask_irq(struct irq_data *data)
417 u32 mask = 1 << (data->irq % 32);
419 __raw_writel(mask, combiner_base(data) + COMBINER_ENABLE_SET);
422 static void combiner_handle_cascade_irq(unsigned int irq, struct irq_desc *desc)
424 struct combiner_chip_data *chip_data = irq_get_handler_data(irq);
425 struct irq_chip *chip = irq_get_chip(irq);
426 unsigned int cascade_irq, combiner_irq;
427 unsigned long status;
429 chained_irq_enter(chip, desc);
431 spin_lock(&irq_controller_lock);
432 status = __raw_readl(chip_data->base + COMBINER_INT_STATUS);
433 spin_unlock(&irq_controller_lock);
434 status &= chip_data->irq_mask;
439 combiner_irq = __ffs(status);
441 cascade_irq = combiner_irq + (chip_data->irq_offset & ~31);
442 if (unlikely(cascade_irq >= NR_IRQS))
443 do_bad_IRQ(cascade_irq, desc);
445 generic_handle_irq(cascade_irq);
448 chained_irq_exit(chip, desc);
451 static struct irq_chip combiner_chip = {
453 .irq_mask = combiner_mask_irq,
454 .irq_unmask = combiner_unmask_irq,
457 static void __init combiner_cascade_irq(unsigned int combiner_nr, unsigned int irq)
461 if (soc_is_exynos5250())
462 max_nr = EXYNOS5_MAX_COMBINER_NR;
464 max_nr = EXYNOS4_MAX_COMBINER_NR;
466 if (combiner_nr >= max_nr)
468 if (irq_set_handler_data(irq, &combiner_data[combiner_nr]) != 0)
470 irq_set_chained_handler(irq, combiner_handle_cascade_irq);
473 static void __init combiner_init(unsigned int combiner_nr, void __iomem *base,
474 unsigned int irq_start)
479 if (soc_is_exynos5250())
480 max_nr = EXYNOS5_MAX_COMBINER_NR;
482 max_nr = EXYNOS4_MAX_COMBINER_NR;
484 if (combiner_nr >= max_nr)
487 combiner_data[combiner_nr].base = base;
488 combiner_data[combiner_nr].irq_offset = irq_start;
489 combiner_data[combiner_nr].irq_mask = 0xff << ((combiner_nr % 4) << 3);
491 /* Disable all interrupts */
493 __raw_writel(combiner_data[combiner_nr].irq_mask,
494 base + COMBINER_ENABLE_CLEAR);
496 /* Setup the Linux IRQ subsystem */
498 for (i = irq_start; i < combiner_data[combiner_nr].irq_offset
499 + MAX_IRQ_IN_COMBINER; i++) {
500 irq_set_chip_and_handler(i, &combiner_chip, handle_level_irq);
501 irq_set_chip_data(i, &combiner_data[combiner_nr]);
502 set_irq_flags(i, IRQF_VALID | IRQF_PROBE);
507 static const struct of_device_id exynos4_dt_irq_match[] = {
508 { .compatible = "arm,cortex-a9-gic", .data = gic_of_init, },
513 void __init exynos4_init_irq(void)
516 unsigned int gic_bank_offset;
518 gic_bank_offset = soc_is_exynos4412() ? 0x4000 : 0x8000;
520 if (!of_have_populated_dt())
521 gic_init_bases(0, IRQ_PPI(0), S5P_VA_GIC_DIST, S5P_VA_GIC_CPU, gic_bank_offset);
524 of_irq_init(exynos4_dt_irq_match);
527 for (irq = 0; irq < EXYNOS4_MAX_COMBINER_NR; irq++) {
529 combiner_init(irq, (void __iomem *)S5P_VA_COMBINER(irq),
530 COMBINER_IRQ(irq, 0));
531 combiner_cascade_irq(irq, IRQ_SPI(irq));
535 * The parameters of s5p_init_irq() are for VIC init.
536 * Theses parameters should be NULL and 0 because EXYNOS4
537 * uses GIC instead of VIC.
539 s5p_init_irq(NULL, 0);
542 void __init exynos5_init_irq(void)
546 gic_init(0, IRQ_PPI(0), S5P_VA_GIC_DIST, S5P_VA_GIC_CPU);
548 for (irq = 0; irq < EXYNOS5_MAX_COMBINER_NR; irq++) {
549 combiner_init(irq, (void __iomem *)S5P_VA_COMBINER(irq),
550 COMBINER_IRQ(irq, 0));
551 combiner_cascade_irq(irq, IRQ_SPI(irq));
555 * The parameters of s5p_init_irq() are for VIC init.
556 * Theses parameters should be NULL and 0 because EXYNOS4
557 * uses GIC instead of VIC.
559 s5p_init_irq(NULL, 0);
562 struct bus_type exynos4_subsys = {
563 .name = "exynos4-core",
564 .dev_name = "exynos4-core",
567 struct bus_type exynos5_subsys = {
568 .name = "exynos5-core",
569 .dev_name = "exynos5-core",
572 static struct device exynos4_dev = {
573 .bus = &exynos4_subsys,
576 static struct device exynos5_dev = {
577 .bus = &exynos5_subsys,
580 static int __init exynos_core_init(void)
582 if (soc_is_exynos5250())
583 return subsys_system_register(&exynos5_subsys, NULL);
585 return subsys_system_register(&exynos4_subsys, NULL);
587 core_initcall(exynos_core_init);
589 #ifdef CONFIG_CACHE_L2X0
590 static int __init exynos4_l2x0_cache_init(void)
592 if (soc_is_exynos5250())
595 /* TAG, Data Latency Control: 2cycle */
596 __raw_writel(0x110, S5P_VA_L2CC + L2X0_TAG_LATENCY_CTRL);
598 if (soc_is_exynos4210())
599 __raw_writel(0x110, S5P_VA_L2CC + L2X0_DATA_LATENCY_CTRL);
600 else if (soc_is_exynos4212() || soc_is_exynos4412())
601 __raw_writel(0x120, S5P_VA_L2CC + L2X0_DATA_LATENCY_CTRL);
603 /* L2X0 Prefetch Control */
604 __raw_writel(0x30000007, S5P_VA_L2CC + L2X0_PREFETCH_CTRL);
606 /* L2X0 Power Control */
607 __raw_writel(L2X0_DYNAMIC_CLK_GATING_EN | L2X0_STNDBY_MODE_EN,
608 S5P_VA_L2CC + L2X0_POWER_CTRL);
610 l2x0_init(S5P_VA_L2CC, 0x7C470001, 0xC200ffff);
614 early_initcall(exynos4_l2x0_cache_init);
617 static int __init exynos5_l2_cache_init(void)
621 if (!soc_is_exynos5250())
624 asm volatile("mrc p15, 0, %0, c1, c0, 0\n"
625 "bic %0, %0, #(1 << 2)\n" /* cache disable */
626 "mcr p15, 0, %0, c1, c0, 0\n"
627 "mrc p15, 1, %0, c9, c0, 2\n"
630 val |= (1 << 9) | (1 << 5) | (2 << 6) | (2 << 0);
632 asm volatile("mcr p15, 1, %0, c9, c0, 2\n" : : "r"(val));
633 asm volatile("mrc p15, 0, %0, c1, c0, 0\n"
634 "orr %0, %0, #(1 << 2)\n" /* cache enable */
635 "mcr p15, 0, %0, c1, c0, 0\n"
640 early_initcall(exynos5_l2_cache_init);
642 static int __init exynos_init(void)
644 printk(KERN_INFO "EXYNOS: Initializing architecture\n");
646 if (soc_is_exynos5250())
647 return device_register(&exynos5_dev);
649 return device_register(&exynos4_dev);
652 /* uart registration process */
654 static void __init exynos_init_uarts(struct s3c2410_uartcfg *cfg, int no)
656 struct s3c2410_uartcfg *tcfg = cfg;
659 for (ucnt = 0; ucnt < no; ucnt++, tcfg++)
660 tcfg->has_fracval = 1;
662 if (soc_is_exynos5250())
663 s3c24xx_init_uartdevs("exynos4210-uart", exynos5_uart_resources, cfg, no);
665 s3c24xx_init_uartdevs("exynos4210-uart", exynos4_uart_resources, cfg, no);
668 static void __iomem *exynos_eint_base;
670 static DEFINE_SPINLOCK(eint_lock);
672 static unsigned int eint0_15_data[16];
674 static inline int exynos4_irq_to_gpio(unsigned int irq)
676 if (irq < IRQ_EINT(0))
681 return EXYNOS4_GPX0(irq);
685 return EXYNOS4_GPX1(irq);
689 return EXYNOS4_GPX2(irq);
693 return EXYNOS4_GPX3(irq);
698 static inline int exynos5_irq_to_gpio(unsigned int irq)
700 if (irq < IRQ_EINT(0))
705 return EXYNOS5_GPX0(irq);
709 return EXYNOS5_GPX1(irq);
713 return EXYNOS5_GPX2(irq);
717 return EXYNOS5_GPX3(irq);
722 static unsigned int exynos4_eint0_15_src_int[16] = {
741 static unsigned int exynos5_eint0_15_src_int[16] = {
759 static inline void exynos_irq_eint_mask(struct irq_data *data)
763 spin_lock(&eint_lock);
764 mask = __raw_readl(EINT_MASK(exynos_eint_base, data->irq));
765 mask |= EINT_OFFSET_BIT(data->irq);
766 __raw_writel(mask, EINT_MASK(exynos_eint_base, data->irq));
767 spin_unlock(&eint_lock);
770 static void exynos_irq_eint_unmask(struct irq_data *data)
774 spin_lock(&eint_lock);
775 mask = __raw_readl(EINT_MASK(exynos_eint_base, data->irq));
776 mask &= ~(EINT_OFFSET_BIT(data->irq));
777 __raw_writel(mask, EINT_MASK(exynos_eint_base, data->irq));
778 spin_unlock(&eint_lock);
781 static inline void exynos_irq_eint_ack(struct irq_data *data)
783 __raw_writel(EINT_OFFSET_BIT(data->irq),
784 EINT_PEND(exynos_eint_base, data->irq));
787 static void exynos_irq_eint_maskack(struct irq_data *data)
789 exynos_irq_eint_mask(data);
790 exynos_irq_eint_ack(data);
793 static int exynos_irq_eint_set_type(struct irq_data *data, unsigned int type)
795 int offs = EINT_OFFSET(data->irq);
801 case IRQ_TYPE_EDGE_RISING:
802 newvalue = S5P_IRQ_TYPE_EDGE_RISING;
805 case IRQ_TYPE_EDGE_FALLING:
806 newvalue = S5P_IRQ_TYPE_EDGE_FALLING;
809 case IRQ_TYPE_EDGE_BOTH:
810 newvalue = S5P_IRQ_TYPE_EDGE_BOTH;
813 case IRQ_TYPE_LEVEL_LOW:
814 newvalue = S5P_IRQ_TYPE_LEVEL_LOW;
817 case IRQ_TYPE_LEVEL_HIGH:
818 newvalue = S5P_IRQ_TYPE_LEVEL_HIGH;
822 printk(KERN_ERR "No such irq type %d", type);
826 shift = (offs & 0x7) * 4;
829 spin_lock(&eint_lock);
830 ctrl = __raw_readl(EINT_CON(exynos_eint_base, data->irq));
832 ctrl |= newvalue << shift;
833 __raw_writel(ctrl, EINT_CON(exynos_eint_base, data->irq));
834 spin_unlock(&eint_lock);
836 if (soc_is_exynos5250())
837 s3c_gpio_cfgpin(exynos5_irq_to_gpio(data->irq), S3C_GPIO_SFN(0xf));
839 s3c_gpio_cfgpin(exynos4_irq_to_gpio(data->irq), S3C_GPIO_SFN(0xf));
844 static struct irq_chip exynos_irq_eint = {
845 .name = "exynos-eint",
846 .irq_mask = exynos_irq_eint_mask,
847 .irq_unmask = exynos_irq_eint_unmask,
848 .irq_mask_ack = exynos_irq_eint_maskack,
849 .irq_ack = exynos_irq_eint_ack,
850 .irq_set_type = exynos_irq_eint_set_type,
852 .irq_set_wake = s3c_irqext_wake,
857 * exynos4_irq_demux_eint
859 * This function demuxes the IRQ from from EINTs 16 to 31.
860 * It is designed to be inlined into the specific handler
861 * s5p_irq_demux_eintX_Y.
863 * Each EINT pend/mask registers handle eight of them.
865 static inline void exynos_irq_demux_eint(unsigned int start)
869 u32 status = __raw_readl(EINT_PEND(exynos_eint_base, start));
870 u32 mask = __raw_readl(EINT_MASK(exynos_eint_base, start));
876 irq = fls(status) - 1;
877 generic_handle_irq(irq + start);
878 status &= ~(1 << irq);
882 static void exynos_irq_demux_eint16_31(unsigned int irq, struct irq_desc *desc)
884 struct irq_chip *chip = irq_get_chip(irq);
885 chained_irq_enter(chip, desc);
886 exynos_irq_demux_eint(IRQ_EINT(16));
887 exynos_irq_demux_eint(IRQ_EINT(24));
888 chained_irq_exit(chip, desc);
891 static void exynos_irq_eint0_15(unsigned int irq, struct irq_desc *desc)
893 u32 *irq_data = irq_get_handler_data(irq);
894 struct irq_chip *chip = irq_get_chip(irq);
896 chained_irq_enter(chip, desc);
897 chip->irq_mask(&desc->irq_data);
900 chip->irq_ack(&desc->irq_data);
902 generic_handle_irq(*irq_data);
904 chip->irq_unmask(&desc->irq_data);
905 chained_irq_exit(chip, desc);
908 static int __init exynos_init_irq_eint(void)
912 if (soc_is_exynos5250())
913 exynos_eint_base = ioremap(EXYNOS5_PA_GPIO1, SZ_4K);
915 exynos_eint_base = ioremap(EXYNOS4_PA_GPIO2, SZ_4K);
917 if (exynos_eint_base == NULL) {
918 pr_err("unable to ioremap for EINT base address\n");
922 for (irq = 0 ; irq <= 31 ; irq++) {
923 irq_set_chip_and_handler(IRQ_EINT(irq), &exynos_irq_eint,
925 set_irq_flags(IRQ_EINT(irq), IRQF_VALID);
928 irq_set_chained_handler(EXYNOS_IRQ_EINT16_31, exynos_irq_demux_eint16_31);
930 for (irq = 0 ; irq <= 15 ; irq++) {
931 eint0_15_data[irq] = IRQ_EINT(irq);
933 if (soc_is_exynos5250()) {
934 irq_set_handler_data(exynos5_eint0_15_src_int[irq],
935 &eint0_15_data[irq]);
936 irq_set_chained_handler(exynos5_eint0_15_src_int[irq],
937 exynos_irq_eint0_15);
939 irq_set_handler_data(exynos4_eint0_15_src_int[irq],
940 &eint0_15_data[irq]);
941 irq_set_chained_handler(exynos4_eint0_15_src_int[irq],
942 exynos_irq_eint0_15);
948 arch_initcall(exynos_init_irq_eint);