macide.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /*
  2. * Macintosh IDE Driver
  3. *
  4. * Copyright (C) 1998 by Michael Schmitz
  5. *
  6. * This driver was written based on information obtained from the MacOS IDE
  7. * driver binary by Mikael Forselius
  8. *
  9. * This file is subject to the terms and conditions of the GNU General Public
  10. * License. See the file COPYING in the main directory of this archive for
  11. * more details.
  12. */
  13. #include <linux/types.h>
  14. #include <linux/mm.h>
  15. #include <linux/interrupt.h>
  16. #include <linux/blkdev.h>
  17. #include <linux/hdreg.h>
  18. #include <linux/delay.h>
  19. #include <linux/ide.h>
  20. #include <asm/machw.h>
  21. #include <asm/macintosh.h>
  22. #include <asm/macints.h>
  23. #include <asm/mac_baboon.h>
  24. #define IDE_BASE 0x50F1A000 /* Base address of IDE controller */
  25. /*
  26. * Generic IDE registers as offsets from the base
  27. * These match MkLinux so they should be correct.
  28. */
  29. #define IDE_CONTROL 0x38 /* control/altstatus */
  30. /*
  31. * Mac-specific registers
  32. */
  33. /*
  34. * this register is odd; it doesn't seem to do much and it's
  35. * not word-aligned like virtually every other hardware register
  36. * on the Mac...
  37. */
  38. #define IDE_IFR 0x101 /* (0x101) IDE interrupt flags on Quadra:
  39. *
  40. * Bit 0+1: some interrupt flags
  41. * Bit 2+3: some interrupt enable
  42. * Bit 4: ??
  43. * Bit 5: IDE interrupt flag (any hwif)
  44. * Bit 6: maybe IDE interrupt enable (any hwif) ??
  45. * Bit 7: Any interrupt condition
  46. */
  47. volatile unsigned char *ide_ifr = (unsigned char *) (IDE_BASE + IDE_IFR);
  48. int macide_ack_intr(ide_hwif_t* hwif)
  49. {
  50. if (*ide_ifr & 0x20) {
  51. *ide_ifr &= ~0x20;
  52. return 1;
  53. }
  54. return 0;
  55. }
  56. static void __init macide_setup_ports(hw_regs_t *hw, unsigned long base,
  57. int irq, ide_ack_intr_t *ack_intr)
  58. {
  59. int i;
  60. memset(hw, 0, sizeof(*hw));
  61. for (i = 0; i < 8; i++)
  62. hw->io_ports_array[i] = base + i * 4;
  63. hw->io_ports.ctl_addr = base + IDE_CONTROL;
  64. hw->irq = irq;
  65. hw->ack_intr = ack_intr;
  66. hw->chipset = ide_generic;
  67. }
  68. static const char *mac_ide_name[] =
  69. { "Quadra", "Powerbook", "Powerbook Baboon" };
  70. /*
  71. * Probe for a Macintosh IDE interface
  72. */
  73. static int __init macide_init(void)
  74. {
  75. ide_ack_intr_t *ack_intr;
  76. unsigned long base;
  77. int irq;
  78. hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
  79. if (!MACH_IS_MAC)
  80. return -ENODEV;
  81. switch (macintosh_config->ide_type) {
  82. case MAC_IDE_QUADRA:
  83. base = IDE_BASE;
  84. ack_intr = macide_ack_intr;
  85. irq = IRQ_NUBUS_F;
  86. break;
  87. case MAC_IDE_PB:
  88. base = IDE_BASE;
  89. ack_intr = macide_ack_intr;
  90. irq = IRQ_NUBUS_C;
  91. break;
  92. case MAC_IDE_BABOON:
  93. base = BABOON_BASE;
  94. ack_intr = NULL;
  95. irq = IRQ_BABOON_1;
  96. break;
  97. default:
  98. return -ENODEV;
  99. }
  100. printk(KERN_INFO "ide: Macintosh %s IDE controller\n",
  101. mac_ide_name[macintosh_config->ide_type - 1]);
  102. macide_setup_ports(&hw, base, irq, ack_intr);
  103. return ide_host_add(NULL, hws, NULL);
  104. }
  105. module_init(macide_init);
  106. MODULE_LICENSE("GPL");