rapide.c 2.2 KB

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