ide-4drives.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. 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. hwif->mmio = 1;
  36. idx[0] = hwif->index;
  37. }
  38. mate = ide_find_port();
  39. if (mate) {
  40. ide_init_port_hw(mate, &hw);
  41. mate->drives[0].select.all ^= 0x20;
  42. mate->drives[1].select.all ^= 0x20;
  43. mate->mmio = 1;
  44. idx[1] = mate->index;
  45. if (hwif) {
  46. hwif->mate = mate;
  47. mate->mate = hwif;
  48. hwif->serialized = mate->serialized = 1;
  49. }
  50. }
  51. ide_device_add(idx, NULL);
  52. return 0;
  53. }
  54. module_init(ide_4drives_init);
  55. MODULE_AUTHOR("Bartlomiej Zolnierkiewicz");
  56. MODULE_DESCRIPTION("generic IDE chipset with 4 drives/port support");
  57. MODULE_LICENSE("GPL");