rapide.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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->io_ports[i] = port;
  23. port += sz;
  24. }
  25. hwif->io_ports[IDE_CONTROL_OFFSET] = (unsigned long)ctrl;
  26. hwif->irq = irq;
  27. hwif->mmio = 1;
  28. default_hwif_mmiops(hwif);
  29. out:
  30. return hwif;
  31. }
  32. static int __devinit
  33. rapide_probe(struct expansion_card *ec, const struct ecard_id *id)
  34. {
  35. ide_hwif_t *hwif;
  36. void __iomem *base;
  37. int ret;
  38. u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
  39. ret = ecard_request_resources(ec);
  40. if (ret)
  41. goto out;
  42. base = ecardm_iomap(ec, ECARD_RES_MEMC, 0, 0);
  43. if (!base) {
  44. ret = -ENOMEM;
  45. goto release;
  46. }
  47. hwif = rapide_locate_hwif(base, base + 0x818, 1 << 6, ec->irq);
  48. if (hwif) {
  49. hwif->hwif_data = base;
  50. hwif->gendev.parent = &ec->dev;
  51. hwif->noprobe = 0;
  52. idx[0] = hwif->index;
  53. ide_device_add(idx);
  54. ecard_set_drvdata(ec, hwif);
  55. goto out;
  56. }
  57. release:
  58. ecard_release_resources(ec);
  59. out:
  60. return ret;
  61. }
  62. static void __devexit rapide_remove(struct expansion_card *ec)
  63. {
  64. ide_hwif_t *hwif = ecard_get_drvdata(ec);
  65. ecard_set_drvdata(ec, NULL);
  66. /* there must be a better way */
  67. ide_unregister(hwif - ide_hwifs);
  68. ecard_release_resources(ec);
  69. }
  70. static struct ecard_id rapide_ids[] = {
  71. { MANU_YELLOWSTONE, PROD_YELLOWSTONE_RAPIDE32 },
  72. { 0xffff, 0xffff }
  73. };
  74. static struct ecard_driver rapide_driver = {
  75. .probe = rapide_probe,
  76. .remove = __devexit_p(rapide_remove),
  77. .id_table = rapide_ids,
  78. .drv = {
  79. .name = "rapide",
  80. },
  81. };
  82. static int __init rapide_init(void)
  83. {
  84. return ecard_register_driver(&rapide_driver);
  85. }
  86. MODULE_LICENSE("GPL");
  87. MODULE_DESCRIPTION("Yellowstone RAPIDE driver");
  88. module_init(rapide_init);