macide.c 3.0 KB

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