lasi700.c 4.0 KB

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