sni_53c710.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. /* -*- mode: c; c-basic-offset: 8 -*- */
  2. /* SNI RM driver
  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. * Based on lasi700.c
  25. */
  26. #include <linux/kernel.h>
  27. #include <linux/module.h>
  28. #include <linux/init.h>
  29. #include <linux/types.h>
  30. #include <linux/slab.h>
  31. #include <linux/stat.h>
  32. #include <linux/mm.h>
  33. #include <linux/blkdev.h>
  34. #include <linux/sched.h>
  35. #include <linux/ioport.h>
  36. #include <linux/dma-mapping.h>
  37. #include <linux/platform_device.h>
  38. #include <asm/page.h>
  39. #include <asm/pgtable.h>
  40. #include <asm/irq.h>
  41. #include <asm/delay.h>
  42. #include <scsi/scsi_host.h>
  43. #include <scsi/scsi_device.h>
  44. #include <scsi/scsi_transport.h>
  45. #include <scsi/scsi_transport_spi.h>
  46. #include "53c700.h"
  47. MODULE_AUTHOR("Thomas Bogendörfer");
  48. MODULE_DESCRIPTION("SNI RM 53c710 SCSI Driver");
  49. MODULE_LICENSE("GPL");
  50. MODULE_ALIAS("platform:snirm_53c710");
  51. #define SNIRM710_CLOCK 32
  52. static struct scsi_host_template snirm710_template = {
  53. .name = "SNI RM SCSI 53c710",
  54. .proc_name = "snirm_53c710",
  55. .this_id = 7,
  56. .module = THIS_MODULE,
  57. };
  58. static int __devinit snirm710_probe(struct platform_device *dev)
  59. {
  60. unsigned long base;
  61. struct NCR_700_Host_Parameters *hostdata;
  62. struct Scsi_Host *host;
  63. struct resource *res;
  64. res = platform_get_resource(dev, IORESOURCE_MEM, 0);
  65. if (!res)
  66. return -ENODEV;
  67. base = res->start;
  68. hostdata = kzalloc(sizeof(*hostdata), GFP_KERNEL);
  69. if (!hostdata) {
  70. dev_printk(KERN_ERR, dev, "Failed to allocate host data\n");
  71. return -ENOMEM;
  72. }
  73. hostdata->dev = &dev->dev;
  74. dma_set_mask(&dev->dev, DMA_BIT_MASK(32));
  75. hostdata->base = ioremap_nocache(base, 0x100);
  76. hostdata->differential = 0;
  77. hostdata->clock = SNIRM710_CLOCK;
  78. hostdata->force_le_on_be = 1;
  79. hostdata->chip710 = 1;
  80. hostdata->burst_length = 4;
  81. host = NCR_700_detect(&snirm710_template, hostdata, &dev->dev);
  82. if (!host)
  83. goto out_kfree;
  84. host->this_id = 7;
  85. host->base = base;
  86. host->irq = platform_get_irq(dev, 0);
  87. if(request_irq(host->irq, NCR_700_intr, IRQF_SHARED, "snirm710", host)) {
  88. printk(KERN_ERR "snirm710: request_irq failed!\n");
  89. goto out_put_host;
  90. }
  91. dev_set_drvdata(&dev->dev, host);
  92. scsi_scan_host(host);
  93. return 0;
  94. out_put_host:
  95. scsi_host_put(host);
  96. out_kfree:
  97. iounmap(hostdata->base);
  98. kfree(hostdata);
  99. return -ENODEV;
  100. }
  101. static int __exit snirm710_driver_remove(struct platform_device *dev)
  102. {
  103. struct Scsi_Host *host = dev_get_drvdata(&dev->dev);
  104. struct NCR_700_Host_Parameters *hostdata =
  105. (struct NCR_700_Host_Parameters *)host->hostdata[0];
  106. scsi_remove_host(host);
  107. NCR_700_release(host);
  108. free_irq(host->irq, host);
  109. iounmap(hostdata->base);
  110. kfree(hostdata);
  111. return 0;
  112. }
  113. static struct platform_driver snirm710_driver = {
  114. .probe = snirm710_probe,
  115. .remove = __devexit_p(snirm710_driver_remove),
  116. .driver = {
  117. .name = "snirm_53c710",
  118. .owner = THIS_MODULE,
  119. },
  120. };
  121. static int __init snirm710_init(void)
  122. {
  123. return platform_driver_register(&snirm710_driver);
  124. }
  125. static void __exit snirm710_exit(void)
  126. {
  127. platform_driver_unregister(&snirm710_driver);
  128. }
  129. module_init(snirm710_init);
  130. module_exit(snirm710_exit);