rapide.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. void __iomem *base;
  30. struct ide_host *host;
  31. int ret;
  32. hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
  33. ret = ecard_request_resources(ec);
  34. if (ret)
  35. goto out;
  36. base = ecardm_iomap(ec, ECARD_RES_MEMC, 0, 0);
  37. if (!base) {
  38. ret = -ENOMEM;
  39. goto release;
  40. }
  41. memset(&hw, 0, sizeof(hw));
  42. rapide_setup_ports(&hw, base, base + 0x818, 1 << 6, ec->irq);
  43. hw.chipset = ide_generic;
  44. hw.dev = &ec->dev;
  45. host = ide_host_alloc(&rapide_port_info, hws);
  46. if (host == NULL) {
  47. ret = -ENOENT;
  48. goto release;
  49. }
  50. ide_host_register(host, &rapide_port_info, hws);
  51. ecard_set_drvdata(ec, host);
  52. goto out;
  53. release:
  54. ecard_release_resources(ec);
  55. out:
  56. return ret;
  57. }
  58. static void __devexit rapide_remove(struct expansion_card *ec)
  59. {
  60. struct ide_host *host = ecard_get_drvdata(ec);
  61. ecard_set_drvdata(ec, NULL);
  62. ide_host_remove(host);
  63. ecard_release_resources(ec);
  64. }
  65. static struct ecard_id rapide_ids[] = {
  66. { MANU_YELLOWSTONE, PROD_YELLOWSTONE_RAPIDE32 },
  67. { 0xffff, 0xffff }
  68. };
  69. static struct ecard_driver rapide_driver = {
  70. .probe = rapide_probe,
  71. .remove = __devexit_p(rapide_remove),
  72. .id_table = rapide_ids,
  73. .drv = {
  74. .name = "rapide",
  75. },
  76. };
  77. static int __init rapide_init(void)
  78. {
  79. return ecard_register_driver(&rapide_driver);
  80. }
  81. MODULE_LICENSE("GPL");
  82. MODULE_DESCRIPTION("Yellowstone RAPIDE driver");
  83. module_init(rapide_init);