delkin_cb.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /*
  2. * linux/drivers/ide/pci/delkin_cb.c
  3. *
  4. * Created 20 Oct 2004 by Mark Lord
  5. *
  6. * Basic support for Delkin/ASKA/Workbit Cardbus CompactFlash adapter
  7. *
  8. * Modeled after the 16-bit PCMCIA driver: ide-cs.c
  9. *
  10. * This is slightly peculiar, in that it is a PCI driver,
  11. * but is NOT an IDE PCI driver -- the IDE layer does not directly
  12. * support hot insertion/removal of PCI interfaces, so this driver
  13. * is unable to use the IDE PCI interfaces. Instead, it uses the
  14. * same interfaces as the ide-cs (PCMCIA) driver uses.
  15. * On the plus side, the driver is also smaller/simpler this way.
  16. *
  17. * This file is subject to the terms and conditions of the GNU General Public
  18. * License. See the file COPYING in the main directory of this archive for
  19. * more details.
  20. */
  21. #include <linux/autoconf.h>
  22. #include <linux/types.h>
  23. #include <linux/module.h>
  24. #include <linux/mm.h>
  25. #include <linux/blkdev.h>
  26. #include <linux/hdreg.h>
  27. #include <linux/ide.h>
  28. #include <linux/init.h>
  29. #include <linux/pci.h>
  30. #include <asm/io.h>
  31. /*
  32. * No chip documentation has yet been found,
  33. * so these configuration values were pulled from
  34. * a running Win98 system using "debug".
  35. * This gives around 3MByte/second read performance,
  36. * which is about 2/3 of what the chip is capable of.
  37. *
  38. * There is also a 4KByte mmio region on the card,
  39. * but its purpose has yet to be reverse-engineered.
  40. */
  41. static const u8 setup[] = {
  42. 0x00, 0x05, 0xbe, 0x01, 0x20, 0x8f, 0x00, 0x00,
  43. 0xa4, 0x1f, 0xb3, 0x1b, 0x00, 0x00, 0x00, 0x80,
  44. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  45. 0x00, 0x00, 0x00, 0x00, 0xa4, 0x83, 0x02, 0x13,
  46. };
  47. static int __devinit
  48. delkin_cb_probe (struct pci_dev *dev, const struct pci_device_id *id)
  49. {
  50. unsigned long base;
  51. hw_regs_t hw;
  52. ide_hwif_t *hwif = NULL;
  53. ide_drive_t *drive;
  54. int i, rc;
  55. rc = pci_enable_device(dev);
  56. if (rc) {
  57. printk(KERN_ERR "delkin_cb: pci_enable_device failed (%d)\n", rc);
  58. return rc;
  59. }
  60. rc = pci_request_regions(dev, "delkin_cb");
  61. if (rc) {
  62. printk(KERN_ERR "delkin_cb: pci_request_regions failed (%d)\n", rc);
  63. pci_disable_device(dev);
  64. return rc;
  65. }
  66. base = pci_resource_start(dev, 0);
  67. outb(0x02, base + 0x1e); /* set nIEN to block interrupts */
  68. inb(base + 0x17); /* read status to clear interrupts */
  69. for (i = 0; i < sizeof(setup); ++i) {
  70. if (setup[i])
  71. outb(setup[i], base + i);
  72. }
  73. pci_release_regions(dev); /* IDE layer handles regions itself */
  74. memset(&hw, 0, sizeof(hw));
  75. ide_std_init_ports(&hw, base + 0x10, base + 0x1e);
  76. hw.irq = dev->irq;
  77. hw.chipset = ide_pci; /* this enables IRQ sharing */
  78. rc = ide_register_hw_with_fixup(&hw, 0, &hwif, ide_undecoded_slave);
  79. if (rc < 0) {
  80. printk(KERN_ERR "delkin_cb: ide_register_hw failed (%d)\n", rc);
  81. pci_disable_device(dev);
  82. return -ENODEV;
  83. }
  84. pci_set_drvdata(dev, hwif);
  85. hwif->pci_dev = dev;
  86. drive = &hwif->drives[0];
  87. if (drive->present) {
  88. drive->io_32bit = 1;
  89. drive->unmask = 1;
  90. }
  91. return 0;
  92. }
  93. static void
  94. delkin_cb_remove (struct pci_dev *dev)
  95. {
  96. ide_hwif_t *hwif = pci_get_drvdata(dev);
  97. if (hwif)
  98. ide_unregister(hwif->index);
  99. pci_disable_device(dev);
  100. }
  101. static struct pci_device_id delkin_cb_pci_tbl[] __devinitdata = {
  102. { 0x1145, 0xf021, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
  103. { 0x1145, 0xf024, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
  104. { 0, },
  105. };
  106. MODULE_DEVICE_TABLE(pci, delkin_cb_pci_tbl);
  107. static struct pci_driver driver = {
  108. .name = "Delkin-ASKA-Workbit Cardbus IDE",
  109. .id_table = delkin_cb_pci_tbl,
  110. .probe = delkin_cb_probe,
  111. .remove = delkin_cb_remove,
  112. };
  113. static int
  114. delkin_cb_init (void)
  115. {
  116. return pci_register_driver(&driver);
  117. }
  118. static void
  119. delkin_cb_exit (void)
  120. {
  121. pci_unregister_driver(&driver);
  122. }
  123. module_init(delkin_cb_init);
  124. module_exit(delkin_cb_exit);
  125. MODULE_AUTHOR("Mark Lord");
  126. MODULE_DESCRIPTION("Basic support for Delkin/ASKA/Workbit Cardbus IDE");
  127. MODULE_LICENSE("GPL");