macide.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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/delay.h>
  18. #include <linux/ide.h>
  19. #include <asm/macintosh.h>
  20. #include <asm/macints.h>
  21. #include <asm/mac_baboon.h>
  22. #define IDE_BASE 0x50F1A000 /* Base address of IDE controller */
  23. /*
  24. * Generic IDE registers as offsets from the base
  25. * These match MkLinux so they should be correct.
  26. */
  27. #define IDE_CONTROL 0x38 /* control/altstatus */
  28. /*
  29. * Mac-specific registers
  30. */
  31. /*
  32. * this register is odd; it doesn't seem to do much and it's
  33. * not word-aligned like virtually every other hardware register
  34. * on the Mac...
  35. */
  36. #define IDE_IFR 0x101 /* (0x101) IDE interrupt flags on Quadra:
  37. *
  38. * Bit 0+1: some interrupt flags
  39. * Bit 2+3: some interrupt enable
  40. * Bit 4: ??
  41. * Bit 5: IDE interrupt flag (any hwif)
  42. * Bit 6: maybe IDE interrupt enable (any hwif) ??
  43. * Bit 7: Any interrupt condition
  44. */
  45. volatile unsigned char *ide_ifr = (unsigned char *) (IDE_BASE + IDE_IFR);
  46. int macide_test_irq(ide_hwif_t *hwif)
  47. {
  48. if (*ide_ifr & 0x20)
  49. return 1;
  50. return 0;
  51. }
  52. static void macide_clear_irq(ide_drive_t *drive)
  53. {
  54. *ide_ifr &= ~0x20;
  55. }
  56. static void __init macide_setup_ports(struct ide_hw *hw, unsigned long base,
  57. int irq)
  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. }
  66. static const struct ide_port_ops macide_port_ops = {
  67. .clear_irq = macide_clear_irq,
  68. .test_irq = macide_test_irq,
  69. };
  70. static const struct ide_port_info macide_port_info = {
  71. .port_ops = &macide_port_ops,
  72. .host_flags = IDE_HFLAG_MMIO | IDE_HFLAG_NO_DMA,
  73. .irq_flags = IRQF_SHARED,
  74. .chipset = ide_generic,
  75. };
  76. static const char *mac_ide_name[] =
  77. { "Quadra", "Powerbook", "Powerbook Baboon" };
  78. /*
  79. * Probe for a Macintosh IDE interface
  80. */
  81. static int __init macide_init(void)
  82. {
  83. unsigned long base;
  84. int irq;
  85. struct ide_hw hw, *hws[] = { &hw };
  86. struct ide_port_info d = macide_port_info;
  87. if (!MACH_IS_MAC)
  88. return -ENODEV;
  89. switch (macintosh_config->ide_type) {
  90. case MAC_IDE_QUADRA:
  91. base = IDE_BASE;
  92. irq = IRQ_NUBUS_F;
  93. break;
  94. case MAC_IDE_PB:
  95. base = IDE_BASE;
  96. irq = IRQ_NUBUS_C;
  97. break;
  98. case MAC_IDE_BABOON:
  99. base = BABOON_BASE;
  100. d.port_ops = NULL;
  101. irq = IRQ_BABOON_1;
  102. break;
  103. default:
  104. return -ENODEV;
  105. }
  106. printk(KERN_INFO "ide: Macintosh %s IDE controller\n",
  107. mac_ide_name[macintosh_config->ide_type - 1]);
  108. macide_setup_ports(&hw, base, irq);
  109. return ide_host_add(&d, hws, 1, NULL);
  110. }
  111. module_init(macide_init);
  112. MODULE_LICENSE("GPL");