sni_53c710.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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 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. return -ENOMEM;
  71. hostdata->dev = &dev->dev;
  72. dma_set_mask(&dev->dev, DMA_BIT_MASK(32));
  73. hostdata->base = ioremap_nocache(base, 0x100);
  74. hostdata->differential = 0;
  75. hostdata->clock = SNIRM710_CLOCK;
  76. hostdata->force_le_on_be = 1;
  77. hostdata->chip710 = 1;
  78. hostdata->burst_length = 4;
  79. host = NCR_700_detect(&snirm710_template, hostdata, &dev->dev);
  80. if (!host)
  81. goto out_kfree;
  82. host->this_id = 7;
  83. host->base = base;
  84. host->irq = platform_get_irq(dev, 0);
  85. if(request_irq(host->irq, NCR_700_intr, IRQF_SHARED, "snirm710", host)) {
  86. printk(KERN_ERR "snirm710: request_irq failed!\n");
  87. goto out_put_host;
  88. }
  89. dev_set_drvdata(&dev->dev, host);
  90. scsi_scan_host(host);
  91. return 0;
  92. out_put_host:
  93. scsi_host_put(host);
  94. out_kfree:
  95. iounmap(hostdata->base);
  96. kfree(hostdata);
  97. return -ENODEV;
  98. }
  99. static int snirm710_driver_remove(struct platform_device *dev)
  100. {
  101. struct Scsi_Host *host = dev_get_drvdata(&dev->dev);
  102. struct NCR_700_Host_Parameters *hostdata =
  103. (struct NCR_700_Host_Parameters *)host->hostdata[0];
  104. scsi_remove_host(host);
  105. NCR_700_release(host);
  106. free_irq(host->irq, host);
  107. iounmap(hostdata->base);
  108. kfree(hostdata);
  109. return 0;
  110. }
  111. static struct platform_driver snirm710_driver = {
  112. .probe = snirm710_probe,
  113. .remove = snirm710_driver_remove,
  114. .driver = {
  115. .name = "snirm_53c710",
  116. },
  117. };
  118. static int __init snirm710_init(void)
  119. {
  120. return platform_driver_register(&snirm710_driver);
  121. }
  122. static void __exit snirm710_exit(void)
  123. {
  124. platform_driver_unregister(&snirm710_driver);
  125. }
  126. module_init(snirm710_init);
  127. module_exit(snirm710_exit);