rapide.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. * Copyright (c) 1996-2002 Russell King.
  3. */
  4. #include <linux/module.h>
  5. #include <linux/blkdev.h>
  6. #include <linux/errno.h>
  7. #include <linux/ide.h>
  8. #include <linux/init.h>
  9. #include <asm/ecard.h>
  10. static const struct ide_port_info rapide_port_info = {
  11. .host_flags = IDE_HFLAG_MMIO | IDE_HFLAG_NO_DMA,
  12. .chipset = ide_generic,
  13. };
  14. static void rapide_setup_ports(struct ide_hw *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 rapide_probe(struct expansion_card *ec, const struct ecard_id *id)
  27. {
  28. void __iomem *base;
  29. struct ide_host *host;
  30. int ret;
  31. struct ide_hw hw, *hws[] = { &hw };
  32. ret = ecard_request_resources(ec);
  33. if (ret)
  34. goto out;
  35. base = ecardm_iomap(ec, ECARD_RES_MEMC, 0, 0);
  36. if (!base) {
  37. ret = -ENOMEM;
  38. goto release;
  39. }
  40. memset(&hw, 0, sizeof(hw));
  41. rapide_setup_ports(&hw, base, base + 0x818, 1 << 6, ec->irq);
  42. hw.dev = &ec->dev;
  43. ret = ide_host_add(&rapide_port_info, hws, 1, &host);
  44. if (ret)
  45. goto release;
  46. ecard_set_drvdata(ec, host);
  47. goto out;
  48. release:
  49. ecard_release_resources(ec);
  50. out:
  51. return ret;
  52. }
  53. static void rapide_remove(struct expansion_card *ec)
  54. {
  55. struct ide_host *host = ecard_get_drvdata(ec);
  56. ecard_set_drvdata(ec, NULL);
  57. ide_host_remove(host);
  58. ecard_release_resources(ec);
  59. }
  60. static struct ecard_id rapide_ids[] = {
  61. { MANU_YELLOWSTONE, PROD_YELLOWSTONE_RAPIDE32 },
  62. { 0xffff, 0xffff }
  63. };
  64. static struct ecard_driver rapide_driver = {
  65. .probe = rapide_probe,
  66. .remove = rapide_remove,
  67. .id_table = rapide_ids,
  68. .drv = {
  69. .name = "rapide",
  70. },
  71. };
  72. static int __init rapide_init(void)
  73. {
  74. return ecard_register_driver(&rapide_driver);
  75. }
  76. static void __exit rapide_exit(void)
  77. {
  78. ecard_remove_driver(&rapide_driver);
  79. }
  80. MODULE_LICENSE("GPL");
  81. MODULE_DESCRIPTION("Yellowstone RAPIDE driver");
  82. module_init(rapide_init);
  83. module_exit(rapide_exit);