ide-4drives.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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 int __init ide_4drives_init(void)
  10. {
  11. ide_hwif_t *hwif, *mate;
  12. unsigned long base = 0x1f0, ctl = 0x3f6;
  13. u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
  14. hw_regs_t hw;
  15. if (probe_4drives == 0)
  16. return -ENODEV;
  17. if (!request_region(base, 8, DRV_NAME)) {
  18. printk(KERN_ERR "%s: I/O resource 0x%lX-0x%lX not free.\n",
  19. DRV_NAME, base, base + 7);
  20. return -EBUSY;
  21. }
  22. if (!request_region(ctl, 1, DRV_NAME)) {
  23. printk(KERN_ERR "%s: I/O resource 0x%lX not free.\n",
  24. DRV_NAME, ctl);
  25. release_region(base, 8);
  26. return -EBUSY;
  27. }
  28. memset(&hw, 0, sizeof(hw));
  29. ide_std_init_ports(&hw, base, ctl);
  30. hw.irq = 14;
  31. hw.chipset = ide_4drives;
  32. hwif = ide_find_port();
  33. if (hwif) {
  34. ide_init_port_hw(hwif, &hw);
  35. idx[0] = hwif->index;
  36. }
  37. mate = ide_find_port();
  38. if (mate) {
  39. ide_init_port_hw(mate, &hw);
  40. mate->drives[0].select.all ^= 0x20;
  41. mate->drives[1].select.all ^= 0x20;
  42. idx[1] = mate->index;
  43. if (hwif) {
  44. hwif->mate = mate;
  45. mate->mate = hwif;
  46. hwif->serialized = mate->serialized = 1;
  47. }
  48. }
  49. ide_device_add(idx, NULL);
  50. return 0;
  51. }
  52. module_init(ide_4drives_init);
  53. MODULE_AUTHOR("Bartlomiej Zolnierkiewicz");
  54. MODULE_DESCRIPTION("generic IDE chipset with 4 drives/port support");
  55. MODULE_LICENSE("GPL");