rapide.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /*
  2. * Copyright (c) 1996-2002 Russell King.
  3. */
  4. #include <linux/module.h>
  5. #include <linux/slab.h>
  6. #include <linux/blkdev.h>
  7. #include <linux/errno.h>
  8. #include <linux/ide.h>
  9. #include <linux/init.h>
  10. #include <asm/ecard.h>
  11. static struct const ide_port_info rapide_port_info = {
  12. .host_flags = IDE_HFLAG_MMIO | IDE_HFLAG_NO_DMA,
  13. };
  14. static void rapide_setup_ports(hw_regs_t *hw, void __iomem *base,
  15. void __iomem *ctrl, unsigned int sz, int irq)
  16. {
  17. unsigned long port = (unsigned long)base;
  18. int i;
  19. for (i = 0; i <= 7; i++) {
  20. hw->io_ports_array[i] = port;
  21. port += sz;
  22. }
  23. hw->io_ports.ctl_addr = (unsigned long)ctrl;
  24. hw->irq = irq;
  25. }
  26. static int __devinit
  27. rapide_probe(struct expansion_card *ec, const struct ecard_id *id)
  28. {
  29. ide_hwif_t *hwif;
  30. void __iomem *base;
  31. int ret;
  32. hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
  33. u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
  34. ret = ecard_request_resources(ec);
  35. if (ret)
  36. goto out;
  37. base = ecardm_iomap(ec, ECARD_RES_MEMC, 0, 0);
  38. if (!base) {
  39. ret = -ENOMEM;
  40. goto release;
  41. }
  42. memset(&hw, 0, sizeof(hw));
  43. rapide_setup_ports(&hw, base, base + 0x818, 1 << 6, ec->irq);
  44. hw.chipset = ide_generic;
  45. hw.dev = &ec->dev;
  46. hwif = ide_find_port();
  47. if (hwif == NULL) {
  48. ret = -ENOENT;
  49. goto release;
  50. }
  51. idx[0] = hwif->index;
  52. ide_device_add(idx, &rapide_port_info, hws);
  53. ecard_set_drvdata(ec, hwif);
  54. goto out;
  55. release:
  56. ecard_release_resources(ec);
  57. out:
  58. return ret;
  59. }
  60. static void __devexit rapide_remove(struct expansion_card *ec)
  61. {
  62. ide_hwif_t *hwif = ecard_get_drvdata(ec);
  63. ecard_set_drvdata(ec, NULL);
  64. ide_unregister(hwif);
  65. ecard_release_resources(ec);
  66. }
  67. static struct ecard_id rapide_ids[] = {
  68. { MANU_YELLOWSTONE, PROD_YELLOWSTONE_RAPIDE32 },
  69. { 0xffff, 0xffff }
  70. };
  71. static struct ecard_driver rapide_driver = {
  72. .probe = rapide_probe,
  73. .remove = __devexit_p(rapide_remove),
  74. .id_table = rapide_ids,
  75. .drv = {
  76. .name = "rapide",
  77. },
  78. };
  79. static int __init rapide_init(void)
  80. {
  81. return ecard_register_driver(&rapide_driver);
  82. }
  83. MODULE_LICENSE("GPL");
  84. MODULE_DESCRIPTION("Yellowstone RAPIDE driver");
  85. module_init(rapide_init);