/drivers/scsi/lasi700.c

http://github.com/mirrors/linux · C · 175 lines · 129 code · 28 blank · 18 comment · 6 complexity · 58bd9c990aa3ae52f771b81e08b96639 MD5 · raw file

  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /* -*- mode: c; c-basic-offset: 8 -*- */
  3. /* PARISC LASI driver for the 53c700 chip
  4. *
  5. * Copyright (C) 2001 by James.Bottomley@HansenPartnership.com
  6. **-----------------------------------------------------------------------------
  7. **
  8. **
  9. **-----------------------------------------------------------------------------
  10. */
  11. /*
  12. * Many thanks to Richard Hirst <rhirst@linuxcare.com> for patiently
  13. * debugging this driver on the parisc architecture and suggesting
  14. * many improvements and bug fixes.
  15. *
  16. * Thanks also go to Linuxcare Inc. for providing several PARISC
  17. * machines for me to debug the driver on.
  18. */
  19. #include <linux/kernel.h>
  20. #include <linux/module.h>
  21. #include <linux/init.h>
  22. #include <linux/types.h>
  23. #include <linux/stat.h>
  24. #include <linux/mm.h>
  25. #include <linux/blkdev.h>
  26. #include <linux/ioport.h>
  27. #include <linux/dma-mapping.h>
  28. #include <linux/slab.h>
  29. #include <asm/page.h>
  30. #include <asm/pgtable.h>
  31. #include <asm/irq.h>
  32. #include <asm/hardware.h>
  33. #include <asm/parisc-device.h>
  34. #include <asm/delay.h>
  35. #include <scsi/scsi_host.h>
  36. #include <scsi/scsi_device.h>
  37. #include <scsi/scsi_transport.h>
  38. #include <scsi/scsi_transport_spi.h>
  39. #include "53c700.h"
  40. MODULE_AUTHOR("James Bottomley");
  41. MODULE_DESCRIPTION("lasi700 SCSI Driver");
  42. MODULE_LICENSE("GPL");
  43. #define LASI_700_SVERSION 0x00071
  44. #define LASI_710_SVERSION 0x00082
  45. #define LASI700_ID_TABLE { \
  46. .hw_type = HPHW_FIO, \
  47. .sversion = LASI_700_SVERSION, \
  48. .hversion = HVERSION_ANY_ID, \
  49. .hversion_rev = HVERSION_REV_ANY_ID, \
  50. }
  51. #define LASI710_ID_TABLE { \
  52. .hw_type = HPHW_FIO, \
  53. .sversion = LASI_710_SVERSION, \
  54. .hversion = HVERSION_ANY_ID, \
  55. .hversion_rev = HVERSION_REV_ANY_ID, \
  56. }
  57. #define LASI700_CLOCK 25
  58. #define LASI710_CLOCK 40
  59. #define LASI_SCSI_CORE_OFFSET 0x100
  60. static const struct parisc_device_id lasi700_ids[] __initconst = {
  61. LASI700_ID_TABLE,
  62. LASI710_ID_TABLE,
  63. { 0 }
  64. };
  65. static struct scsi_host_template lasi700_template = {
  66. .name = "LASI SCSI 53c700",
  67. .proc_name = "lasi700",
  68. .this_id = 7,
  69. .module = THIS_MODULE,
  70. };
  71. MODULE_DEVICE_TABLE(parisc, lasi700_ids);
  72. static int __init
  73. lasi700_probe(struct parisc_device *dev)
  74. {
  75. unsigned long base = dev->hpa.start + LASI_SCSI_CORE_OFFSET;
  76. struct NCR_700_Host_Parameters *hostdata;
  77. struct Scsi_Host *host;
  78. hostdata = kzalloc(sizeof(*hostdata), GFP_KERNEL);
  79. if (!hostdata) {
  80. dev_printk(KERN_ERR, &dev->dev, "Failed to allocate host data\n");
  81. return -ENOMEM;
  82. }
  83. hostdata->dev = &dev->dev;
  84. dma_set_mask(&dev->dev, DMA_BIT_MASK(32));
  85. hostdata->base = ioremap(base, 0x100);
  86. hostdata->differential = 0;
  87. if (dev->id.sversion == LASI_700_SVERSION) {
  88. hostdata->clock = LASI700_CLOCK;
  89. hostdata->force_le_on_be = 1;
  90. } else {
  91. hostdata->clock = LASI710_CLOCK;
  92. hostdata->force_le_on_be = 0;
  93. hostdata->chip710 = 1;
  94. hostdata->dmode_extra = DMODE_FC2;
  95. hostdata->burst_length = 8;
  96. }
  97. host = NCR_700_detect(&lasi700_template, hostdata, &dev->dev);
  98. if (!host)
  99. goto out_kfree;
  100. host->this_id = 7;
  101. host->base = base;
  102. host->irq = dev->irq;
  103. if(request_irq(dev->irq, NCR_700_intr, IRQF_SHARED, "lasi700", host)) {
  104. printk(KERN_ERR "lasi700: request_irq failed!\n");
  105. goto out_put_host;
  106. }
  107. dev_set_drvdata(&dev->dev, host);
  108. scsi_scan_host(host);
  109. return 0;
  110. out_put_host:
  111. scsi_host_put(host);
  112. out_kfree:
  113. iounmap(hostdata->base);
  114. kfree(hostdata);
  115. return -ENODEV;
  116. }
  117. static int __exit
  118. lasi700_driver_remove(struct parisc_device *dev)
  119. {
  120. struct Scsi_Host *host = dev_get_drvdata(&dev->dev);
  121. struct NCR_700_Host_Parameters *hostdata =
  122. (struct NCR_700_Host_Parameters *)host->hostdata[0];
  123. scsi_remove_host(host);
  124. NCR_700_release(host);
  125. free_irq(host->irq, host);
  126. iounmap(hostdata->base);
  127. kfree(hostdata);
  128. return 0;
  129. }
  130. static struct parisc_driver lasi700_driver __refdata = {
  131. .name = "lasi_scsi",
  132. .id_table = lasi700_ids,
  133. .probe = lasi700_probe,
  134. .remove = __exit_p(lasi700_driver_remove),
  135. };
  136. static int __init
  137. lasi700_init(void)
  138. {
  139. return register_parisc_driver(&lasi700_driver);
  140. }
  141. static void __exit
  142. lasi700_exit(void)
  143. {
  144. unregister_parisc_driver(&lasi700_driver);
  145. }
  146. module_init(lasi700_init);
  147. module_exit(lasi700_exit);