]>
Commit | Line | Data |
---|---|---|
a16efc1c KJ |
1 | /* |
2 | * Detection routine for the NCR53c710 based Amiga SCSI Controllers for Linux. | |
3 | * Amiga Technologies A4000T SCSI controller. | |
4 | * | |
5 | * Written 1997 by Alan Hourihane <[email protected]> | |
6 | * plus modifications of the 53c7xx.c driver to support the Amiga. | |
7 | * | |
8 | * Rewritten to use 53c700.c by Kars de Jong <[email protected]> | |
9 | */ | |
10 | ||
11 | #include <linux/module.h> | |
12 | #include <linux/platform_device.h> | |
13 | #include <linux/init.h> | |
14 | #include <linux/interrupt.h> | |
5a0e3ad6 | 15 | #include <linux/slab.h> |
96249cf9 | 16 | #include <asm/amigahw.h> |
a16efc1c KJ |
17 | #include <asm/amigaints.h> |
18 | #include <scsi/scsi_host.h> | |
19 | #include <scsi/scsi_transport_spi.h> | |
20 | ||
21 | #include "53c700.h" | |
22 | ||
a16efc1c KJ |
23 | |
24 | static struct scsi_host_template a4000t_scsi_driver_template = { | |
25 | .name = "A4000T builtin SCSI", | |
26 | .proc_name = "A4000t", | |
27 | .this_id = 7, | |
28 | .module = THIS_MODULE, | |
29 | }; | |
30 | ||
a16efc1c | 31 | |
a24a6b22 | 32 | #define A4000T_SCSI_OFFSET 0x40 |
a16efc1c | 33 | |
a24a6b22 | 34 | static int __init amiga_a4000t_scsi_probe(struct platform_device *pdev) |
a16efc1c | 35 | { |
a24a6b22 GU |
36 | struct resource *res; |
37 | phys_addr_t scsi_addr; | |
a16efc1c | 38 | struct NCR_700_Host_Parameters *hostdata; |
a24a6b22 | 39 | struct Scsi_Host *host; |
a16efc1c | 40 | |
a24a6b22 GU |
41 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
42 | if (!res) | |
43 | return -ENODEV; | |
a16efc1c | 44 | |
a24a6b22 | 45 | if (!request_mem_region(res->start, resource_size(res), |
a16efc1c | 46 | "A4000T builtin SCSI")) |
a24a6b22 | 47 | return -EBUSY; |
a16efc1c | 48 | |
a24a6b22 GU |
49 | hostdata = kzalloc(sizeof(struct NCR_700_Host_Parameters), |
50 | GFP_KERNEL); | |
bbfbbbc1 | 51 | if (!hostdata) { |
a24a6b22 | 52 | dev_err(&pdev->dev, "Failed to allocate host data\n"); |
a16efc1c KJ |
53 | goto out_release; |
54 | } | |
a16efc1c | 55 | |
a24a6b22 GU |
56 | scsi_addr = res->start + A4000T_SCSI_OFFSET; |
57 | ||
a16efc1c | 58 | /* Fill in the required pieces of hostdata */ |
6112ea08 | 59 | hostdata->base = ZTWO_VADDR(scsi_addr); |
a16efc1c KJ |
60 | hostdata->clock = 50; |
61 | hostdata->chip710 = 1; | |
62 | hostdata->dmode_extra = DMODE_FC2; | |
63 | hostdata->dcntl_extra = EA_710; | |
64 | ||
65 | /* and register the chip */ | |
e5779a58 | 66 | host = NCR_700_detect(&a4000t_scsi_driver_template, hostdata, |
a24a6b22 | 67 | &pdev->dev); |
a16efc1c | 68 | if (!host) { |
a24a6b22 GU |
69 | dev_err(&pdev->dev, |
70 | "No host detected; board configuration problem?\n"); | |
a16efc1c KJ |
71 | goto out_free; |
72 | } | |
73 | ||
74 | host->this_id = 7; | |
a24a6b22 | 75 | host->base = scsi_addr; |
a16efc1c KJ |
76 | host->irq = IRQ_AMIGA_PORTS; |
77 | ||
78 | if (request_irq(host->irq, NCR_700_intr, IRQF_SHARED, "a4000t-scsi", | |
79 | host)) { | |
a24a6b22 | 80 | dev_err(&pdev->dev, "request_irq failed\n"); |
a16efc1c KJ |
81 | goto out_put_host; |
82 | } | |
83 | ||
a24a6b22 | 84 | platform_set_drvdata(pdev, host); |
a16efc1c | 85 | scsi_scan_host(host); |
a16efc1c KJ |
86 | return 0; |
87 | ||
88 | out_put_host: | |
89 | scsi_host_put(host); | |
90 | out_free: | |
91 | kfree(hostdata); | |
92 | out_release: | |
a24a6b22 | 93 | release_mem_region(res->start, resource_size(res)); |
a16efc1c KJ |
94 | return -ENODEV; |
95 | } | |
96 | ||
a24a6b22 | 97 | static int __exit amiga_a4000t_scsi_remove(struct platform_device *pdev) |
a16efc1c | 98 | { |
a24a6b22 | 99 | struct Scsi_Host *host = platform_get_drvdata(pdev); |
a16efc1c | 100 | struct NCR_700_Host_Parameters *hostdata = shost_priv(host); |
a24a6b22 | 101 | struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
a16efc1c KJ |
102 | |
103 | scsi_remove_host(host); | |
a16efc1c KJ |
104 | NCR_700_release(host); |
105 | kfree(hostdata); | |
106 | free_irq(host->irq, host); | |
a24a6b22 | 107 | release_mem_region(res->start, resource_size(res)); |
a16efc1c KJ |
108 | return 0; |
109 | } | |
110 | ||
a24a6b22 GU |
111 | static struct platform_driver amiga_a4000t_scsi_driver = { |
112 | .remove = __exit_p(amiga_a4000t_scsi_remove), | |
113 | .driver = { | |
114 | .name = "amiga-a4000t-scsi", | |
115 | .owner = THIS_MODULE, | |
7a192ec3 | 116 | }, |
a16efc1c KJ |
117 | }; |
118 | ||
70695baa | 119 | module_platform_driver_probe(amiga_a4000t_scsi_driver, amiga_a4000t_scsi_probe); |
a24a6b22 GU |
120 | |
121 | MODULE_AUTHOR("Alan Hourihane <[email protected]> / " | |
122 | "Kars de Jong <[email protected]>"); | |
123 | MODULE_DESCRIPTION("Amiga A4000T NCR53C710 driver"); | |
124 | MODULE_LICENSE("GPL"); | |
125 | MODULE_ALIAS("platform:amiga-a4000t-scsi"); |