ecoscsi.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. #define AUTOSENSE
  2. /* #define PSEUDO_DMA */
  3. /*
  4. * EcoSCSI Generic NCR5380 driver
  5. *
  6. * Copyright 1995, Russell King
  7. *
  8. * ALPHA RELEASE 1.
  9. *
  10. * For more information, please consult
  11. *
  12. * NCR 5380 Family
  13. * SCSI Protocol Controller
  14. * Databook
  15. *
  16. * NCR Microelectronics
  17. * 1635 Aeroplaza Drive
  18. * Colorado Springs, CO 80916
  19. * 1+ (719) 578-3400
  20. * 1+ (800) 334-5454
  21. */
  22. #include <linux/module.h>
  23. #include <linux/signal.h>
  24. #include <linux/ioport.h>
  25. #include <linux/delay.h>
  26. #include <linux/init.h>
  27. #include <linux/blkdev.h>
  28. #include <asm/io.h>
  29. #include <asm/system.h>
  30. #include "../scsi.h"
  31. #include <scsi/scsi_host.h>
  32. #define priv(host) ((struct NCR5380_hostdata *)(host)->hostdata)
  33. #define NCR5380_local_declare() void __iomem *_base
  34. #define NCR5380_setup(host) _base = priv(host)->base
  35. #define NCR5380_read(reg) ({ writeb(reg | 8, _base); readb(_base + 4); })
  36. #define NCR5380_write(reg, value) ({ writeb(reg | 8, _base); writeb(value, _base + 4); })
  37. #define NCR5380_intr ecoscsi_intr
  38. #define NCR5380_queue_command ecoscsi_queue_command
  39. #define NCR5380_proc_info ecoscsi_proc_info
  40. #define NCR5380_implementation_fields \
  41. void __iomem *base
  42. #include "../NCR5380.h"
  43. #define ECOSCSI_PUBLIC_RELEASE 1
  44. /*
  45. * Function : ecoscsi_setup(char *str, int *ints)
  46. *
  47. * Purpose : LILO command line initialization of the overrides array,
  48. *
  49. * Inputs : str - unused, ints - array of integer parameters with ints[0]
  50. * equal to the number of ints.
  51. *
  52. */
  53. void ecoscsi_setup(char *str, int *ints)
  54. {
  55. }
  56. const char * ecoscsi_info (struct Scsi_Host *spnt)
  57. {
  58. return "";
  59. }
  60. #define BOARD_NORMAL 0
  61. #define BOARD_NCR53C400 1
  62. #include "../NCR5380.c"
  63. static struct scsi_host_template ecoscsi_template = {
  64. .module = THIS_MODULE,
  65. .name = "Serial Port EcoSCSI NCR5380",
  66. .proc_name = "ecoscsi",
  67. .info = ecoscsi_info,
  68. .queuecommand = ecoscsi_queue_command,
  69. .eh_abort_handler = NCR5380_abort,
  70. .eh_bus_reset_handler = NCR5380_bus_reset,
  71. .can_queue = 16,
  72. .this_id = 7,
  73. .sg_tablesize = SG_ALL,
  74. .cmd_per_lun = 2,
  75. .use_clustering = DISABLE_CLUSTERING
  76. };
  77. static struct Scsi_Host *host;
  78. static int __init ecoscsi_init(void)
  79. {
  80. void __iomem *_base;
  81. int ret;
  82. if (!request_mem_region(0x33a0000, 4096, "ecoscsi")) {
  83. ret = -EBUSY;
  84. goto out;
  85. }
  86. _base = ioremap(0x33a0000, 4096);
  87. if (!_base) {
  88. ret = -ENOMEM;
  89. goto out_release;
  90. }
  91. NCR5380_write(MODE_REG, 0x20); /* Is it really SCSI? */
  92. if (NCR5380_read(MODE_REG) != 0x20) /* Write to a reg. */
  93. goto out_unmap;
  94. NCR5380_write(MODE_REG, 0x00); /* it back. */
  95. if (NCR5380_read(MODE_REG) != 0x00)
  96. goto out_unmap;
  97. host = scsi_host_alloc(tpnt, sizeof(struct NCR5380_hostdata));
  98. if (!host) {
  99. ret = -ENOMEM;
  100. goto out_unmap;
  101. }
  102. priv(host)->base = _base;
  103. host->irq = IRQ_NONE;
  104. NCR5380_init(host, 0);
  105. printk("scsi%d: at port 0x%08lx irqs disabled", host->host_no, host->io_port);
  106. printk(" options CAN_QUEUE=%d CMD_PER_LUN=%d release=%d",
  107. host->can_queue, host->cmd_per_lun, ECOSCSI_PUBLIC_RELEASE);
  108. printk("\nscsi%d:", host->host_no);
  109. NCR5380_print_options(host);
  110. printk("\n");
  111. scsi_add_host(host, NULL); /* XXX handle failure */
  112. scsi_scan_host(host);
  113. return 0;
  114. out_unmap:
  115. iounmap(_base);
  116. out_release:
  117. release_mem_region(0x33a0000, 4096);
  118. out:
  119. return ret;
  120. }
  121. static void __exit ecoscsi_exit(void)
  122. {
  123. scsi_remove_host(host);
  124. NCR5380_exit(host);
  125. scsi_host_put(host);
  126. release_mem_region(0x33a0000, 4096);
  127. return 0;
  128. }
  129. module_init(ecoscsi_init);
  130. module_exit(ecoscsi_exit);
  131. MODULE_AUTHOR("Russell King");
  132. MODULE_DESCRIPTION("Econet-SCSI driver for Acorn machines");
  133. MODULE_LICENSE("GPL");