delkin_cb.c 3.7 KB

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