ide-pnp.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. * This file provides autodetection for ISA PnP IDE interfaces.
  3. * It was tested with "ESS ES1868 Plug and Play AudioDrive" IDE interface.
  4. *
  5. * Copyright (C) 2000 Andrey Panin <pazke@donpac.ru>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2, or (at your option)
  10. * any later version.
  11. *
  12. * You should have received a copy of the GNU General Public License
  13. * (for example /usr/src/linux/COPYING); if not, write to the Free
  14. * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. */
  16. #include <linux/init.h>
  17. #include <linux/pnp.h>
  18. #include <linux/ide.h>
  19. /* Add your devices here :)) */
  20. static struct pnp_device_id idepnp_devices[] = {
  21. /* Generic ESDI/IDE/ATA compatible hard disk controller */
  22. {.id = "PNP0600", .driver_data = 0},
  23. {.id = ""}
  24. };
  25. static int idepnp_probe(struct pnp_dev *dev, const struct pnp_device_id *dev_id)
  26. {
  27. hw_regs_t hw;
  28. ide_hwif_t *hwif;
  29. if (!(pnp_port_valid(dev, 0) && pnp_port_valid(dev, 1) && pnp_irq_valid(dev, 0)))
  30. return -1;
  31. memset(&hw, 0, sizeof(hw));
  32. ide_std_init_ports(&hw, pnp_port_start(dev, 0),
  33. pnp_port_start(dev, 1));
  34. hw.irq = pnp_irq(dev, 0);
  35. hwif = ide_find_port();
  36. if (hwif) {
  37. u8 index = hwif->index;
  38. u8 idx[4] = { index, 0xff, 0xff, 0xff };
  39. ide_init_port_data(hwif, index);
  40. ide_init_port_hw(hwif, &hw);
  41. printk(KERN_INFO "ide%d: generic PnP IDE interface\n", index);
  42. pnp_set_drvdata(dev, hwif);
  43. ide_device_add(idx, NULL);
  44. return 0;
  45. }
  46. return -1;
  47. }
  48. static void idepnp_remove(struct pnp_dev *dev)
  49. {
  50. ide_hwif_t *hwif = pnp_get_drvdata(dev);
  51. if (hwif)
  52. ide_unregister(hwif->index);
  53. else
  54. printk(KERN_ERR "idepnp: Unable to remove device, please report.\n");
  55. }
  56. static struct pnp_driver idepnp_driver = {
  57. .name = "ide",
  58. .id_table = idepnp_devices,
  59. .probe = idepnp_probe,
  60. .remove = idepnp_remove,
  61. };
  62. static int __init pnpide_init(void)
  63. {
  64. return pnp_register_driver(&idepnp_driver);
  65. }
  66. static void __exit pnpide_exit(void)
  67. {
  68. pnp_unregister_driver(&idepnp_driver);
  69. }
  70. module_init(pnpide_init);
  71. module_exit(pnpide_exit);
  72. MODULE_LICENSE("GPL");