ide-4drives.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. ide_hwif_t *hwif, *mate;
  24. unsigned long base = 0x1f0, ctl = 0x3f6;
  25. u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
  26. hw_regs_t 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. hw.chipset = ide_4drives;
  44. hwif = ide_find_port();
  45. if (hwif) {
  46. ide_init_port_hw(hwif, &hw);
  47. idx[0] = hwif->index;
  48. }
  49. mate = ide_find_port();
  50. if (mate) {
  51. ide_init_port_hw(mate, &hw);
  52. idx[1] = mate->index;
  53. }
  54. ide_device_add(idx, &ide_4drives_port_info);
  55. return 0;
  56. }
  57. module_init(ide_4drives_init);
  58. MODULE_AUTHOR("Bartlomiej Zolnierkiewicz");
  59. MODULE_DESCRIPTION("generic IDE chipset with 4 drives/port support");
  60. MODULE_LICENSE("GPL");