lasi700.c 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. /* -*- mode: c; c-basic-offset: 8 -*- */
  2. /* PARISC LASI driver for the 53c700 chip
  3. *
  4. * Copyright (C) 2001 by James.Bottomley@HansenPartnership.com
  5. **-----------------------------------------------------------------------------
  6. **
  7. ** This program is free software; you can redistribute it and/or modify
  8. ** it under the terms of the GNU General Public License as published by
  9. ** the Free Software Foundation; either version 2 of the License, or
  10. ** (at your option) any later version.
  11. **
  12. ** This program is distributed in the hope that it will be useful,
  13. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. ** GNU General Public License for more details.
  16. **
  17. ** You should have received a copy of the GNU General Public License
  18. ** along with this program; if not, write to the Free Software
  19. ** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20. **
  21. **-----------------------------------------------------------------------------
  22. */
  23. /*
  24. * Many thanks to Richard Hirst <rhirst@linuxcare.com> for patiently
  25. * debugging this driver on the parisc architecture and suggesting
  26. * many improvements and bug fixes.
  27. *
  28. * Thanks also go to Linuxcare Inc. for providing several PARISC
  29. * machines for me to debug the driver on.
  30. */
  31. #include <linux/kernel.h>
  32. #include <linux/module.h>
  33. #include <linux/init.h>
  34. #include <linux/types.h>
  35. #include <linux/stat.h>
  36. #include <linux/mm.h>
  37. #include <linux/blkdev.h>
  38. #include <linux/ioport.h>
  39. #include <linux/dma-mapping.h>
  40. #include <asm/page.h>
  41. #include <asm/pgtable.h>
  42. #include <asm/irq.h>
  43. #include <asm/hardware.h>
  44. #include <asm/parisc-device.h>
  45. #include <asm/delay.h>
  46. #include <scsi/scsi_host.h>
  47. #include <scsi/scsi_device.h>
  48. #include <scsi/scsi_transport.h>
  49. #include <scsi/scsi_transport_spi.h>
  50. #include "53c700.h"
  51. MODULE_AUTHOR("James Bottomley");
  52. MODULE_DESCRIPTION("lasi700 SCSI Driver");
  53. MODULE_LICENSE("GPL");
  54. #define LASI_700_SVERSION 0x00071
  55. #define LASI_710_SVERSION 0x00082
  56. #define LASI700_ID_TABLE { \
  57. .hw_type = HPHW_FIO, \
  58. .sversion = LASI_700_SVERSION, \
  59. .hversion = HVERSION_ANY_ID, \
  60. .hversion_rev = HVERSION_REV_ANY_ID, \
  61. }
  62. #define LASI710_ID_TABLE { \
  63. .hw_type = HPHW_FIO, \
  64. .sversion = LASI_710_SVERSION, \
  65. .hversion = HVERSION_ANY_ID, \
  66. .hversion_rev = HVERSION_REV_ANY_ID, \
  67. }
  68. #define LASI700_CLOCK 25
  69. #define LASI710_CLOCK 40
  70. #define LASI_SCSI_CORE_OFFSET 0x100
  71. static struct parisc_device_id lasi700_ids[] = {
  72. LASI700_ID_TABLE,
  73. LASI710_ID_TABLE,
  74. { 0 }
  75. };
  76. static struct scsi_host_template lasi700_template = {
  77. .name = "LASI SCSI 53c700",
  78. .proc_name = "lasi700",
  79. .this_id = 7,
  80. .module = THIS_MODULE,
  81. };
  82. MODULE_DEVICE_TABLE(parisc, lasi700_ids);
  83. static int __init
  84. lasi700_probe(struct parisc_device *dev)
  85. {
  86. unsigned long base = dev->hpa.start + LASI_SCSI_CORE_OFFSET;
  87. struct NCR_700_Host_Parameters *hostdata;
  88. struct Scsi_Host *host;
  89. hostdata = kmalloc(sizeof(*hostdata), GFP_KERNEL);
  90. if (!hostdata) {
  91. printk(KERN_ERR "%s: Failed to allocate host data\n",
  92. dev->dev.bus_id);
  93. return -ENOMEM;
  94. }
  95. memset(hostdata, 0, sizeof(struct NCR_700_Host_Parameters));
  96. hostdata->dev = &dev->dev;
  97. dma_set_mask(&dev->dev, DMA_32BIT_MASK);
  98. hostdata->base = ioremap_nocache(base, 0x100);
  99. hostdata->differential = 0;
  100. if (dev->id.sversion == LASI_700_SVERSION) {
  101. hostdata->clock = LASI700_CLOCK;
  102. hostdata->force_le_on_be = 1;
  103. } else {
  104. hostdata->clock = LASI710_CLOCK;
  105. hostdata->force_le_on_be = 0;
  106. hostdata->chip710 = 1;
  107. hostdata->dmode_extra = DMODE_FC2;
  108. hostdata->burst_length = 8;
  109. }
  110. host = NCR_700_detect(&lasi700_template, hostdata, &dev->dev);
  111. if (!host)
  112. goto out_kfree;
  113. host->this_id = 7;
  114. host->base = base;
  115. host->irq = dev->irq;
  116. if(request_irq(dev->irq, NCR_700_intr, IRQF_SHARED, "lasi700", host)) {
  117. printk(KERN_ERR "lasi700: request_irq failed!\n");
  118. goto out_put_host;
  119. }
  120. dev_set_drvdata(&dev->dev, host);
  121. scsi_scan_host(host);
  122. return 0;
  123. out_put_host:
  124. scsi_host_put(host);
  125. out_kfree:
  126. iounmap(hostdata->base);
  127. kfree(hostdata);
  128. return -ENODEV;
  129. }
  130. static int __exit
  131. lasi700_driver_remove(struct parisc_device *dev)
  132. {
  133. struct Scsi_Host *host = dev_get_drvdata(&dev->dev);
  134. struct NCR_700_Host_Parameters *hostdata =
  135. (struct NCR_700_Host_Parameters *)host->hostdata[0];
  136. scsi_remove_host(host);
  137. NCR_700_release(host);
  138. free_irq(host->irq, host);
  139. iounmap(hostdata->base);
  140. kfree(hostdata);
  141. return 0;
  142. }
  143. static struct parisc_driver lasi700_driver = {
  144. .name = "lasi_scsi",
  145. .id_table = lasi700_ids,
  146. .probe = lasi700_probe,
  147. .remove = __devexit_p(lasi700_driver_remove),
  148. };
  149. static int __init
  150. lasi700_init(void)
  151. {
  152. return register_parisc_driver(&lasi700_driver);
  153. }
  154. static void __exit
  155. lasi700_exit(void)
  156. {
  157. unregister_parisc_driver(&lasi700_driver);
  158. }
  159. module_init(lasi700_init);
  160. module_exit(lasi700_exit);