ide-4drives.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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 int 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.all ^= 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. };
  21. static int __init ide_4drives_init(void)
  22. {
  23. unsigned long base = 0x1f0, ctl = 0x3f6;
  24. hw_regs_t hw, *hws[] = { &hw, &hw, NULL, NULL };
  25. if (probe_4drives == 0)
  26. return -ENODEV;
  27. if (!request_region(base, 8, DRV_NAME)) {
  28. printk(KERN_ERR "%s: I/O resource 0x%lX-0x%lX not free.\n",
  29. DRV_NAME, base, base + 7);
  30. return -EBUSY;
  31. }
  32. if (!request_region(ctl, 1, DRV_NAME)) {
  33. printk(KERN_ERR "%s: I/O resource 0x%lX not free.\n",
  34. DRV_NAME, ctl);
  35. release_region(base, 8);
  36. return -EBUSY;
  37. }
  38. memset(&hw, 0, sizeof(hw));
  39. ide_std_init_ports(&hw, base, ctl);
  40. hw.irq = 14;
  41. hw.chipset = ide_4drives;
  42. return ide_host_add(&ide_4drives_port_info, hws, NULL);
  43. }
  44. module_init(ide_4drives_init);
  45. MODULE_AUTHOR("Bartlomiej Zolnierkiewicz");
  46. MODULE_DESCRIPTION("generic IDE chipset with 4 drives/port support");
  47. MODULE_LICENSE("GPL");