ide-4drives.c 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #include <linux/kernel.h>
  2. #include <linux/init.h>
  3. #include <linux/module.h>
  4. #include <linux/ide.h>
  5. #define DRV_NAME "ide-4drives"
  6. static bool probe_4drives;
  7. module_param_named(probe, probe_4drives, bool, 0);
  8. MODULE_PARM_DESC(probe, "probe for generic IDE chipset with 4 drives/port");
  9. static void ide_4drives_init_dev(ide_drive_t *drive)
  10. {
  11. if (drive->hwif->channel)
  12. drive->select ^= 0x20;
  13. }
  14. static const struct ide_port_ops ide_4drives_port_ops = {
  15. .init_dev = ide_4drives_init_dev,
  16. };
  17. static const struct ide_port_info ide_4drives_port_info = {
  18. .port_ops = &ide_4drives_port_ops,
  19. .host_flags = IDE_HFLAG_SERIALIZE | IDE_HFLAG_NO_DMA |
  20. IDE_HFLAG_4DRIVES,
  21. .chipset = ide_4drives,
  22. };
  23. static int __init ide_4drives_init(void)
  24. {
  25. unsigned long base = 0x1f0, ctl = 0x3f6;
  26. struct ide_hw hw, *hws[] = { &hw, &hw };
  27. if (probe_4drives == 0)
  28. return -ENODEV;
  29. if (!request_region(base, 8, DRV_NAME)) {
  30. printk(KERN_ERR "%s: I/O resource 0x%lX-0x%lX not free.\n",
  31. DRV_NAME, base, base + 7);
  32. return -EBUSY;
  33. }
  34. if (!request_region(ctl, 1, DRV_NAME)) {
  35. printk(KERN_ERR "%s: I/O resource 0x%lX not free.\n",
  36. DRV_NAME, ctl);
  37. release_region(base, 8);
  38. return -EBUSY;
  39. }
  40. memset(&hw, 0, sizeof(hw));
  41. ide_std_init_ports(&hw, base, ctl);
  42. hw.irq = 14;
  43. return ide_host_add(&ide_4drives_port_info, hws, 2, NULL);
  44. }
  45. module_init(ide_4drives_init);
  46. MODULE_AUTHOR("Bartlomiej Zolnierkiewicz");
  47. MODULE_DESCRIPTION("generic IDE chipset with 4 drives/port support");
  48. MODULE_LICENSE("GPL");