baboon.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Baboon Custom IC Management
  4. *
  5. * The Baboon custom IC controls the IDE, PCMCIA and media bay on the
  6. * PowerBook 190. It multiplexes multiple interrupt sources onto the
  7. * Nubus slot $C interrupt.
  8. */
  9. #include <linux/types.h>
  10. #include <linux/kernel.h>
  11. #include <linux/irq.h>
  12. #include <asm/macintosh.h>
  13. #include <asm/macints.h>
  14. #include <asm/mac_baboon.h>
  15. int baboon_present;
  16. static volatile struct baboon *baboon;
  17. /*
  18. * Baboon initialization.
  19. */
  20. void __init baboon_init(void)
  21. {
  22. if (macintosh_config->ident != MAC_MODEL_PB190) {
  23. baboon = NULL;
  24. baboon_present = 0;
  25. return;
  26. }
  27. baboon = (struct baboon *) BABOON_BASE;
  28. baboon_present = 1;
  29. pr_debug("Baboon detected at %p\n", baboon);
  30. }
  31. /*
  32. * Baboon interrupt handler.
  33. * XXX how do you clear a pending IRQ? is it even necessary?
  34. */
  35. static void baboon_irq(struct irq_desc *desc)
  36. {
  37. short events, irq_bit;
  38. int irq_num;
  39. events = baboon->mb_ifr & 0x07;
  40. irq_num = IRQ_BABOON_0;
  41. irq_bit = 1;
  42. do {
  43. if (events & irq_bit) {
  44. events &= ~irq_bit;
  45. generic_handle_irq(irq_num);
  46. }
  47. ++irq_num;
  48. irq_bit <<= 1;
  49. } while (events);
  50. }
  51. /*
  52. * Register the Baboon interrupt dispatcher on nubus slot $C.
  53. */
  54. void __init baboon_register_interrupts(void)
  55. {
  56. irq_set_chained_handler(IRQ_NUBUS_C, baboon_irq);
  57. }
  58. /*
  59. * The means for masking individual Baboon interrupts remains a mystery.
  60. * However, since we only use the IDE IRQ, we can just enable/disable all
  61. * Baboon interrupts. If/when we handle more than one Baboon IRQ, we must
  62. * either figure out how to mask them individually or else implement the
  63. * same workaround that's used for NuBus slots (see nubus_disabled and
  64. * via_nubus_irq_shutdown).
  65. */
  66. void baboon_irq_enable(int irq)
  67. {
  68. mac_irq_enable(irq_get_irq_data(IRQ_NUBUS_C));
  69. }
  70. void baboon_irq_disable(int irq)
  71. {
  72. mac_irq_disable(irq_get_irq_data(IRQ_NUBUS_C));
  73. }