irq-uart.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /* arch/arm/plat-samsung/irq-uart.c
  2. * originally part of arch/arm/plat-s3c64xx/irq.c
  3. *
  4. * Copyright 2008 Openmoko, Inc.
  5. * Copyright 2008 Simtec Electronics
  6. * Ben Dooks <ben@simtec.co.uk>
  7. * http://armlinux.simtec.co.uk/
  8. *
  9. * Samsung- UART Interrupt handling
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License version 2 as
  13. * published by the Free Software Foundation.
  14. */
  15. #include <linux/kernel.h>
  16. #include <linux/interrupt.h>
  17. #include <linux/serial_core.h>
  18. #include <linux/irq.h>
  19. #include <linux/io.h>
  20. #include <mach/map.h>
  21. #include <plat/irq-uart.h>
  22. #include <plat/regs-serial.h>
  23. #include <plat/cpu.h>
  24. /* Note, we make use of the fact that the parent IRQs, IRQ_UART[0..3]
  25. * are consecutive when looking up the interrupt in the demux routines.
  26. */
  27. static void s3c_irq_demux_uart(unsigned int irq, struct irq_desc *desc)
  28. {
  29. struct s3c_uart_irq *uirq = desc->irq_data.handler_data;
  30. u32 pend = __raw_readl(uirq->regs + S3C64XX_UINTP);
  31. int base = uirq->base_irq;
  32. if (pend & (1 << 0))
  33. generic_handle_irq(base);
  34. if (pend & (1 << 1))
  35. generic_handle_irq(base + 1);
  36. if (pend & (1 << 2))
  37. generic_handle_irq(base + 2);
  38. if (pend & (1 << 3))
  39. generic_handle_irq(base + 3);
  40. }
  41. static void __init s3c_init_uart_irq(struct s3c_uart_irq *uirq)
  42. {
  43. void __iomem *reg_base = uirq->regs;
  44. struct irq_chip_generic *gc;
  45. struct irq_chip_type *ct;
  46. /* mask all interrupts at the start. */
  47. __raw_writel(0xf, reg_base + S3C64XX_UINTM);
  48. gc = irq_alloc_generic_chip("s3c-uart", 1, uirq->base_irq, reg_base,
  49. handle_level_irq);
  50. if (!gc) {
  51. pr_err("%s: irq_alloc_generic_chip for IRQ %u failed\n",
  52. __func__, uirq->base_irq);
  53. return;
  54. }
  55. ct = gc->chip_types;
  56. ct->chip.irq_ack = irq_gc_ack_set_bit;
  57. ct->chip.irq_mask = irq_gc_mask_set_bit;
  58. ct->chip.irq_unmask = irq_gc_mask_clr_bit;
  59. ct->regs.ack = S3C64XX_UINTP;
  60. ct->regs.mask = S3C64XX_UINTM;
  61. irq_setup_generic_chip(gc, IRQ_MSK(4), IRQ_GC_INIT_MASK_CACHE,
  62. IRQ_NOREQUEST | IRQ_NOPROBE, 0);
  63. irq_set_handler_data(uirq->parent_irq, uirq);
  64. irq_set_chained_handler(uirq->parent_irq, s3c_irq_demux_uart);
  65. }
  66. /**
  67. * s3c_init_uart_irqs() - initialise UART IRQs and the necessary demuxing
  68. * @irq: The interrupt data for registering
  69. * @nr_irqs: The number of interrupt descriptions in @irq.
  70. *
  71. * Register the UART interrupts specified by @irq including the demuxing
  72. * routines. This supports the S3C6400 and newer style of devices.
  73. */
  74. void __init s3c_init_uart_irqs(struct s3c_uart_irq *irq, unsigned int nr_irqs)
  75. {
  76. for (; nr_irqs > 0; nr_irqs--, irq++)
  77. s3c_init_uart_irq(irq);
  78. }