rapide.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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->chipset = ide_generic;
  50. hwif->hwif_data = base;
  51. hwif->gendev.parent = &ec->dev;
  52. hwif->noprobe = 0;
  53. idx[0] = hwif->index;
  54. ide_device_add(idx);
  55. ecard_set_drvdata(ec, hwif);
  56. goto out;
  57. }
  58. release:
  59. ecard_release_resources(ec);
  60. out:
  61. return ret;
  62. }
  63. static void __devexit rapide_remove(struct expansion_card *ec)
  64. {
  65. ide_hwif_t *hwif = ecard_get_drvdata(ec);
  66. ecard_set_drvdata(ec, NULL);
  67. /* there must be a better way */
  68. ide_unregister(hwif - ide_hwifs);
  69. ecard_release_resources(ec);
  70. }
  71. static struct ecard_id rapide_ids[] = {
  72. { MANU_YELLOWSTONE, PROD_YELLOWSTONE_RAPIDE32 },
  73. { 0xffff, 0xffff }
  74. };
  75. static struct ecard_driver rapide_driver = {
  76. .probe = rapide_probe,
  77. .remove = __devexit_p(rapide_remove),
  78. .id_table = rapide_ids,
  79. .drv = {
  80. .name = "rapide",
  81. },
  82. };
  83. static int __init rapide_init(void)
  84. {
  85. return ecard_register_driver(&rapide_driver);
  86. }
  87. MODULE_LICENSE("GPL");
  88. MODULE_DESCRIPTION("Yellowstone RAPIDE driver");
  89. module_init(rapide_init);