macide.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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_DATA 0x00
  30. #define IDE_ERROR 0x04 /* see err-bits */
  31. #define IDE_NSECTOR 0x08 /* nr of sectors to read/write */
  32. #define IDE_SECTOR 0x0c /* starting sector */
  33. #define IDE_LCYL 0x10 /* starting cylinder */
  34. #define IDE_HCYL 0x14 /* high byte of starting cyl */
  35. #define IDE_SELECT 0x18 /* 101dhhhh , d=drive, hhhh=head */
  36. #define IDE_STATUS 0x1c /* see status-bits */
  37. #define IDE_CONTROL 0x38 /* control/altstatus */
  38. /*
  39. * Mac-specific registers
  40. */
  41. /*
  42. * this register is odd; it doesn't seem to do much and it's
  43. * not word-aligned like virtually every other hardware register
  44. * on the Mac...
  45. */
  46. #define IDE_IFR 0x101 /* (0x101) IDE interrupt flags on Quadra:
  47. *
  48. * Bit 0+1: some interrupt flags
  49. * Bit 2+3: some interrupt enable
  50. * Bit 4: ??
  51. * Bit 5: IDE interrupt flag (any hwif)
  52. * Bit 6: maybe IDE interrupt enable (any hwif) ??
  53. * Bit 7: Any interrupt condition
  54. */
  55. volatile unsigned char *ide_ifr = (unsigned char *) (IDE_BASE + IDE_IFR);
  56. static int macide_offsets[IDE_NR_PORTS] = {
  57. IDE_DATA, IDE_ERROR, IDE_NSECTOR, IDE_SECTOR, IDE_LCYL,
  58. IDE_HCYL, IDE_SELECT, IDE_STATUS, IDE_CONTROL
  59. };
  60. int macide_ack_intr(ide_hwif_t* hwif)
  61. {
  62. if (*ide_ifr & 0x20) {
  63. *ide_ifr &= ~0x20;
  64. return 1;
  65. }
  66. return 0;
  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. hw_regs_t hw;
  76. ide_hwif_t *hwif;
  77. switch (macintosh_config->ide_type) {
  78. case MAC_IDE_QUADRA:
  79. ide_setup_ports(&hw, IDE_BASE, macide_offsets,
  80. 0, 0, macide_ack_intr,
  81. // quadra_ide_iops,
  82. IRQ_NUBUS_F);
  83. break;
  84. case MAC_IDE_PB:
  85. ide_setup_ports(&hw, IDE_BASE, macide_offsets,
  86. 0, 0, macide_ack_intr,
  87. // macide_pb_iops,
  88. IRQ_NUBUS_C);
  89. break;
  90. case MAC_IDE_BABOON:
  91. ide_setup_ports(&hw, BABOON_BASE, macide_offsets,
  92. 0, 0, NULL,
  93. // macide_baboon_iops,
  94. IRQ_BABOON_1);
  95. break;
  96. default:
  97. return -ENODEV;
  98. }
  99. printk(KERN_INFO "ide: Macintosh %s IDE controller\n",
  100. mac_ide_name[macintosh_config->ide_type - 1]);
  101. hwif = ide_find_port(hw.io_ports[IDE_DATA_OFFSET]);
  102. if (hwif) {
  103. u8 index = hwif->index;
  104. u8 idx[4] = { index, 0xff, 0xff, 0xff };
  105. ide_init_port_data(hwif, index);
  106. ide_init_port_hw(hwif, &hw);
  107. hwif->mmio = 1;
  108. ide_device_add(idx, NULL);
  109. }
  110. return 0;
  111. }
  112. module_init(macide_init);