falconide.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /*
  2. * Atari Falcon IDE Driver
  3. *
  4. * Created 12 Jul 1997 by Geert Uytterhoeven
  5. *
  6. * This file is subject to the terms and conditions of the GNU General Public
  7. * License. See the file COPYING in the main directory of this archive for
  8. * more details.
  9. */
  10. #include <linux/module.h>
  11. #include <linux/types.h>
  12. #include <linux/mm.h>
  13. #include <linux/interrupt.h>
  14. #include <linux/blkdev.h>
  15. #include <linux/hdreg.h>
  16. #include <linux/ide.h>
  17. #include <linux/init.h>
  18. #include <asm/setup.h>
  19. #include <asm/atarihw.h>
  20. #include <asm/atariints.h>
  21. #include <asm/atari_stdma.h>
  22. #define DRV_NAME "falconide"
  23. /*
  24. * Base of the IDE interface
  25. */
  26. #define ATA_HD_BASE 0xfff00000
  27. /*
  28. * Offsets from the above base
  29. */
  30. #define ATA_HD_CONTROL 0x39
  31. /*
  32. * falconide_intr_lock is used to obtain access to the IDE interrupt,
  33. * which is shared between several drivers.
  34. */
  35. int falconide_intr_lock;
  36. EXPORT_SYMBOL(falconide_intr_lock);
  37. static void falconide_input_data(ide_drive_t *drive, struct request *rq,
  38. void *buf, unsigned int len)
  39. {
  40. unsigned long data_addr = drive->hwif->io_ports.data_addr;
  41. if (drive->media == ide_disk && rq && rq->cmd_type == REQ_TYPE_FS)
  42. return insw(data_addr, buf, (len + 1) / 2);
  43. insw_swapw(data_addr, buf, (len + 1) / 2);
  44. }
  45. static void falconide_output_data(ide_drive_t *drive, struct request *rq,
  46. void *buf, unsigned int len)
  47. {
  48. unsigned long data_addr = drive->hwif->io_ports.data_addr;
  49. if (drive->media == ide_disk && rq && rq->cmd_type == REQ_TYPE_FS)
  50. return outsw(data_addr, buf, (len + 1) / 2);
  51. outsw_swapw(data_addr, buf, (len + 1) / 2);
  52. }
  53. static void __init falconide_setup_ports(hw_regs_t *hw)
  54. {
  55. int i;
  56. memset(hw, 0, sizeof(*hw));
  57. hw->io_ports.data_addr = ATA_HD_BASE;
  58. for (i = 1; i < 8; i++)
  59. hw->io_ports_array[i] = ATA_HD_BASE + 1 + i * 4;
  60. hw->io_ports.ctl_addr = ATA_HD_BASE + ATA_HD_CONTROL;
  61. hw->irq = IRQ_MFP_IDE;
  62. hw->ack_intr = NULL;
  63. hw->chipset = ide_generic;
  64. }
  65. /*
  66. * Probe for a Falcon IDE interface
  67. */
  68. static int __init falconide_init(void)
  69. {
  70. hw_regs_t hw;
  71. ide_hwif_t *hwif;
  72. if (!MACH_IS_ATARI || !ATARIHW_PRESENT(IDE))
  73. return 0;
  74. printk(KERN_INFO "ide: Falcon IDE controller\n");
  75. if (!request_mem_region(ATA_HD_BASE, 0x40, DRV_NAME)) {
  76. printk(KERN_ERR "%s: resources busy\n", DRV_NAME);
  77. return -EBUSY;
  78. }
  79. falconide_setup_ports(&hw);
  80. hwif = ide_find_port();
  81. if (hwif) {
  82. u8 index = hwif->index;
  83. u8 idx[4] = { index, 0xff, 0xff, 0xff };
  84. ide_init_port_hw(hwif, &hw);
  85. /* Atari has a byte-swapped IDE interface */
  86. hwif->input_data = falconide_input_data;
  87. hwif->output_data = falconide_output_data;
  88. ide_get_lock(NULL, NULL);
  89. ide_device_add(idx, NULL);
  90. ide_release_lock();
  91. }
  92. return 0;
  93. }
  94. module_init(falconide_init);
  95. MODULE_LICENSE("GPL");