baboon.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /*
  2. * Baboon Custom IC Management
  3. *
  4. * The Baboon custom IC controls the IDE, PCMCIA and media bay on the
  5. * PowerBook 190. It multiplexes multiple interrupt sources onto the
  6. * Nubus slot $C interrupt.
  7. */
  8. #include <linux/types.h>
  9. #include <linux/kernel.h>
  10. #include <linux/irq.h>
  11. #include <asm/macintosh.h>
  12. #include <asm/macints.h>
  13. #include <asm/mac_baboon.h>
  14. /* #define DEBUG_IRQS */
  15. int baboon_present;
  16. static volatile struct baboon *baboon;
  17. #if 0
  18. extern int macide_ack_intr(struct ata_channel *);
  19. #endif
  20. /*
  21. * Baboon initialization.
  22. */
  23. void __init baboon_init(void)
  24. {
  25. if (macintosh_config->ident != MAC_MODEL_PB190) {
  26. baboon = NULL;
  27. baboon_present = 0;
  28. return;
  29. }
  30. baboon = (struct baboon *) BABOON_BASE;
  31. baboon_present = 1;
  32. printk("Baboon detected at %p\n", baboon);
  33. }
  34. /*
  35. * Baboon interrupt handler. This works a lot like a VIA.
  36. */
  37. static void baboon_irq(struct irq_desc *desc)
  38. {
  39. int irq_bit, irq_num;
  40. unsigned char events;
  41. #ifdef DEBUG_IRQS
  42. printk("baboon_irq: mb_control %02X mb_ifr %02X mb_status %02X\n",
  43. (uint) baboon->mb_control, (uint) baboon->mb_ifr,
  44. (uint) baboon->mb_status);
  45. #endif
  46. events = baboon->mb_ifr & 0x07;
  47. if (!events)
  48. return;
  49. irq_num = IRQ_BABOON_0;
  50. irq_bit = 1;
  51. do {
  52. if (events & irq_bit) {
  53. baboon->mb_ifr &= ~irq_bit;
  54. generic_handle_irq(irq_num);
  55. }
  56. irq_bit <<= 1;
  57. irq_num++;
  58. } while(events >= irq_bit);
  59. #if 0
  60. if (baboon->mb_ifr & 0x02) macide_ack_intr(NULL);
  61. /* for now we need to smash all interrupts */
  62. baboon->mb_ifr &= ~events;
  63. #endif
  64. }
  65. /*
  66. * Register the Baboon interrupt dispatcher on nubus slot $C.
  67. */
  68. void __init baboon_register_interrupts(void)
  69. {
  70. irq_set_chained_handler(IRQ_NUBUS_C, baboon_irq);
  71. }
  72. /*
  73. * The means for masking individual Baboon interrupts remains a mystery.
  74. * However, since we only use the IDE IRQ, we can just enable/disable all
  75. * Baboon interrupts. If/when we handle more than one Baboon IRQ, we must
  76. * either figure out how to mask them individually or else implement the
  77. * same workaround that's used for NuBus slots (see nubus_disabled and
  78. * via_nubus_irq_shutdown).
  79. */
  80. void baboon_irq_enable(int irq)
  81. {
  82. #ifdef DEBUG_IRQUSE
  83. printk("baboon_irq_enable(%d)\n", irq);
  84. #endif
  85. mac_irq_enable(irq_get_irq_data(IRQ_NUBUS_C));
  86. }
  87. void baboon_irq_disable(int irq)
  88. {
  89. #ifdef DEBUG_IRQUSE
  90. printk("baboon_irq_disable(%d)\n", irq);
  91. #endif
  92. mac_irq_disable(irq_get_irq_data(IRQ_NUBUS_C));
  93. }