ide-4drives.c 1.5 KB

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