irq.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*
  2. * linux/arch/sh/boards/se/7722/irq.c
  3. *
  4. * Copyright (C) 2007 Nobuhiro Iwamatsu
  5. *
  6. * Hitachi UL SolutionEngine 7722 Support.
  7. *
  8. * This file is subject to the terms and conditions of the GNU General Public
  9. * License. See the file "COPYING" in the main directory of this archive
  10. * for more details.
  11. */
  12. #include <linux/init.h>
  13. #include <linux/irq.h>
  14. #include <linux/interrupt.h>
  15. #include <asm/irq.h>
  16. #include <asm/io.h>
  17. #include <asm/se7722.h>
  18. #define INTC_INTMSK0 0xFFD00044
  19. #define INTC_INTMSKCLR0 0xFFD00064
  20. static void disable_se7722_irq(unsigned int irq)
  21. {
  22. struct ipr_data *p = get_irq_chip_data(irq);
  23. ctrl_outw( ctrl_inw( p->addr ) | p->priority , p->addr );
  24. }
  25. static void enable_se7722_irq(unsigned int irq)
  26. {
  27. struct ipr_data *p = get_irq_chip_data(irq);
  28. ctrl_outw( ctrl_inw( p->addr ) & ~p->priority , p->addr );
  29. }
  30. static struct irq_chip se7722_irq_chip __read_mostly = {
  31. .name = "SE7722",
  32. .mask = disable_se7722_irq,
  33. .unmask = enable_se7722_irq,
  34. .mask_ack = disable_se7722_irq,
  35. };
  36. static struct ipr_data ipr_irq_table[] = {
  37. /* irq ,idx,sft, priority , addr */
  38. { MRSHPC_IRQ0 , 0 , 0 , MRSHPC_BIT0 , IRQ01_MASK } ,
  39. { MRSHPC_IRQ1 , 0 , 0 , MRSHPC_BIT1 , IRQ01_MASK } ,
  40. { MRSHPC_IRQ2 , 0 , 0 , MRSHPC_BIT2 , IRQ01_MASK } ,
  41. { MRSHPC_IRQ3 , 0 , 0 , MRSHPC_BIT3 , IRQ01_MASK } ,
  42. { SMC_IRQ , 0 , 0 , SMC_BIT , IRQ01_MASK } ,
  43. { EXT_IRQ , 0 , 0 , EXT_BIT , IRQ01_MASK } ,
  44. };
  45. int se7722_irq_demux(int irq)
  46. {
  47. if ((irq == IRQ0_IRQ)||(irq == IRQ1_IRQ)) {
  48. volatile unsigned short intv =
  49. *(volatile unsigned short *)IRQ01_STS;
  50. if (irq == IRQ0_IRQ){
  51. if(intv & SMC_BIT ) {
  52. return SMC_IRQ;
  53. } else if(intv & USB_BIT) {
  54. return USB_IRQ;
  55. } else {
  56. printk("intv =%04x\n", intv);
  57. return SMC_IRQ;
  58. }
  59. } else if(irq == IRQ1_IRQ){
  60. if(intv & MRSHPC_BIT0) {
  61. return MRSHPC_IRQ0;
  62. } else if(intv & MRSHPC_BIT1) {
  63. return MRSHPC_IRQ1;
  64. } else if(intv & MRSHPC_BIT2) {
  65. return MRSHPC_IRQ2;
  66. } else if(intv & MRSHPC_BIT3) {
  67. return MRSHPC_IRQ3;
  68. } else {
  69. printk("BIT_EXTENTION =%04x\n", intv);
  70. return EXT_IRQ;
  71. }
  72. }
  73. }
  74. return irq;
  75. }
  76. /*
  77. * Initialize IRQ setting
  78. */
  79. void __init init_se7722_IRQ(void)
  80. {
  81. int i = 0;
  82. ctrl_outw(0x2000, 0xb03fffec); /* mrshpc irq enable */
  83. ctrl_outl((3 << ((7 - 0) * 4))|(3 << ((7 - 1) * 4)), INTC_INTPRI0); /* irq0 pri=3,irq1,pri=3 */
  84. ctrl_outw((2 << ((7 - 0) * 2))|(2 << ((7 - 1) * 2)), INTC_ICR1); /* irq0,1 low-level irq */
  85. for (i = 0; i < ARRAY_SIZE(ipr_irq_table); i++) {
  86. disable_irq_nosync(ipr_irq_table[i].irq);
  87. set_irq_chip_and_handler_name( ipr_irq_table[i].irq, &se7722_irq_chip,
  88. handle_level_irq, "level");
  89. set_irq_chip_data( ipr_irq_table[i].irq, &ipr_irq_table[i] );
  90. disable_se7722_irq(ipr_irq_table[i].irq);
  91. }
  92. }