]>
Commit | Line | Data |
---|---|---|
74ba9207 | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
c27d85f3 TB |
2 | /* -*- mode: c; c-basic-offset: 8 -*- */ |
3 | ||
4 | /* SNI RM driver | |
5 | * | |
6 | * Copyright (C) 2001 by James.Bottomley@HansenPartnership.com | |
7 | **----------------------------------------------------------------------------- | |
8 | ** | |
c27d85f3 TB |
9 | ** |
10 | **----------------------------------------------------------------------------- | |
11 | */ | |
12 | ||
13 | /* | |
14 | * Based on lasi700.c | |
15 | */ | |
16 | ||
17 | #include <linux/kernel.h> | |
18 | #include <linux/module.h> | |
19 | #include <linux/init.h> | |
20 | #include <linux/types.h> | |
5a0e3ad6 | 21 | #include <linux/slab.h> |
c27d85f3 TB |
22 | #include <linux/stat.h> |
23 | #include <linux/mm.h> | |
24 | #include <linux/blkdev.h> | |
25 | #include <linux/sched.h> | |
26 | #include <linux/ioport.h> | |
27 | #include <linux/dma-mapping.h> | |
28 | #include <linux/platform_device.h> | |
29 | ||
30 | #include <asm/page.h> | |
31 | #include <asm/pgtable.h> | |
32 | #include <asm/irq.h> | |
33 | #include <asm/delay.h> | |
34 | ||
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 | ||
40 | #include "53c700.h" | |
41 | ||
d36b6910 | 42 | MODULE_AUTHOR("Thomas Bogendörfer"); |
c27d85f3 TB |
43 | MODULE_DESCRIPTION("SNI RM 53c710 SCSI Driver"); |
44 | MODULE_LICENSE("GPL"); | |
ecc1241e | 45 | MODULE_ALIAS("platform:snirm_53c710"); |
c27d85f3 TB |
46 | |
47 | #define SNIRM710_CLOCK 32 | |
48 | ||
49 | static struct scsi_host_template snirm710_template = { | |
50 | .name = "SNI RM SCSI 53c710", | |
51 | .proc_name = "snirm_53c710", | |
52 | .this_id = 7, | |
53 | .module = THIS_MODULE, | |
54 | }; | |
55 | ||
6f039790 | 56 | static int snirm710_probe(struct platform_device *dev) |
c27d85f3 TB |
57 | { |
58 | unsigned long base; | |
59 | struct NCR_700_Host_Parameters *hostdata; | |
60 | struct Scsi_Host *host; | |
61 | struct resource *res; | |
62 | ||
63 | res = platform_get_resource(dev, IORESOURCE_MEM, 0); | |
64 | if (!res) | |
65 | return -ENODEV; | |
66 | ||
67 | base = res->start; | |
68 | hostdata = kzalloc(sizeof(*hostdata), GFP_KERNEL); | |
69 | if (!hostdata) { | |
71610f55 | 70 | dev_printk(KERN_ERR, dev, "Failed to allocate host data\n"); |
c27d85f3 TB |
71 | return -ENOMEM; |
72 | } | |
73 | ||
74 | hostdata->dev = &dev->dev; | |
284901a9 | 75 | dma_set_mask(&dev->dev, DMA_BIT_MASK(32)); |
2da86589 | 76 | hostdata->base = ioremap_nocache(base, 0x100); |
c27d85f3 TB |
77 | hostdata->differential = 0; |
78 | ||
79 | hostdata->clock = SNIRM710_CLOCK; | |
80 | hostdata->force_le_on_be = 1; | |
81 | hostdata->chip710 = 1; | |
82 | hostdata->burst_length = 4; | |
83 | ||
84 | host = NCR_700_detect(&snirm710_template, hostdata, &dev->dev); | |
85 | if (!host) | |
86 | goto out_kfree; | |
87 | host->this_id = 7; | |
88 | host->base = base; | |
89 | host->irq = platform_get_irq(dev, 0); | |
2833bf68 | 90 | if(request_irq(host->irq, NCR_700_intr, IRQF_SHARED, "snirm710", host)) { |
c27d85f3 TB |
91 | printk(KERN_ERR "snirm710: request_irq failed!\n"); |
92 | goto out_put_host; | |
93 | } | |
94 | ||
95 | dev_set_drvdata(&dev->dev, host); | |
96 | scsi_scan_host(host); | |
97 | ||
98 | return 0; | |
99 | ||
100 | out_put_host: | |
101 | scsi_host_put(host); | |
102 | out_kfree: | |
103 | iounmap(hostdata->base); | |
104 | kfree(hostdata); | |
105 | return -ENODEV; | |
106 | } | |
107 | ||
ba21222d | 108 | static int snirm710_driver_remove(struct platform_device *dev) |
c27d85f3 TB |
109 | { |
110 | struct Scsi_Host *host = dev_get_drvdata(&dev->dev); | |
111 | struct NCR_700_Host_Parameters *hostdata = | |
112 | (struct NCR_700_Host_Parameters *)host->hostdata[0]; | |
113 | ||
114 | scsi_remove_host(host); | |
115 | NCR_700_release(host); | |
116 | free_irq(host->irq, host); | |
117 | iounmap(hostdata->base); | |
118 | kfree(hostdata); | |
119 | ||
120 | return 0; | |
121 | } | |
122 | ||
123 | static struct platform_driver snirm710_driver = { | |
124 | .probe = snirm710_probe, | |
6f039790 | 125 | .remove = snirm710_driver_remove, |
c27d85f3 TB |
126 | .driver = { |
127 | .name = "snirm_53c710", | |
128 | }, | |
129 | }; | |
130 | ||
131 | static int __init snirm710_init(void) | |
132 | { | |
2da86589 | 133 | return platform_driver_register(&snirm710_driver); |
c27d85f3 TB |
134 | } |
135 | ||
136 | static void __exit snirm710_exit(void) | |
137 | { | |
138 | platform_driver_unregister(&snirm710_driver); | |
139 | } | |
140 | ||
141 | module_init(snirm710_init); | |
142 | module_exit(snirm710_exit); |