diff options
| author | Geert Uytterhoeven <geert@linux-m68k.org> | 2009-04-05 07:05:50 -0400 |
|---|---|---|
| committer | Geert Uytterhoeven <geert@linux-m68k.org> | 2010-05-26 13:51:09 -0400 |
| commit | a24a6b22254bca8d54be6c8b7d8730d09f1058cc (patch) | |
| tree | 4c7c71125efbc22f2f6302fc96538ce1d2b9f55a | |
| parent | 2b21d5e47bb9b07f90cf213c885867cf11f99976 (diff) | |
m68k: amiga - A4000T SCSI platform device conversion
Acked-by: James Bottomley <James.Bottomley@suse.de>
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
| -rw-r--r-- | arch/m68k/amiga/platform.c | 11 | ||||
| -rw-r--r-- | drivers/scsi/a4000t.c | 101 |
2 files changed, 57 insertions, 55 deletions
diff --git a/arch/m68k/amiga/platform.c b/arch/m68k/amiga/platform.c index df1fae3c3729..027e4cae88ff 100644 --- a/arch/m68k/amiga/platform.c +++ b/arch/m68k/amiga/platform.c | |||
| @@ -65,6 +65,13 @@ static const struct resource a3000_scsi_resource __initconst = { | |||
| 65 | }; | 65 | }; |
| 66 | 66 | ||
| 67 | 67 | ||
| 68 | static const struct resource a4000t_scsi_resource __initconst = { | ||
| 69 | .start = 0xdd0000, | ||
| 70 | .end = 0xdd0fff, | ||
| 71 | .flags = IORESOURCE_MEM, | ||
| 72 | }; | ||
| 73 | |||
| 74 | |||
| 68 | static int __init amiga_init_devices(void) | 75 | static int __init amiga_init_devices(void) |
| 69 | { | 76 | { |
| 70 | if (!MACH_IS_AMIGA) | 77 | if (!MACH_IS_AMIGA) |
| @@ -88,6 +95,10 @@ static int __init amiga_init_devices(void) | |||
| 88 | platform_device_register_simple("amiga-a3000-scsi", -1, | 95 | platform_device_register_simple("amiga-a3000-scsi", -1, |
| 89 | &a3000_scsi_resource, 1); | 96 | &a3000_scsi_resource, 1); |
| 90 | 97 | ||
| 98 | if (AMIGAHW_PRESENT(A4000_SCSI)) | ||
| 99 | platform_device_register_simple("amiga-a4000t-scsi", -1, | ||
| 100 | &a4000t_scsi_resource, 1); | ||
| 101 | |||
| 91 | return 0; | 102 | return 0; |
| 92 | } | 103 | } |
| 93 | 104 | ||
diff --git a/drivers/scsi/a4000t.c b/drivers/scsi/a4000t.c index 11ae6be8aeaf..23c76f41883c 100644 --- a/drivers/scsi/a4000t.c +++ b/drivers/scsi/a4000t.c | |||
| @@ -20,10 +20,6 @@ | |||
| 20 | 20 | ||
| 21 | #include "53c700.h" | 21 | #include "53c700.h" |
| 22 | 22 | ||
| 23 | MODULE_AUTHOR("Alan Hourihane <alanh@fairlite.demon.co.uk> / Kars de Jong <jongk@linux-m68k.org>"); | ||
| 24 | MODULE_DESCRIPTION("Amiga A4000T NCR53C710 driver"); | ||
| 25 | MODULE_LICENSE("GPL"); | ||
| 26 | |||
| 27 | 23 | ||
| 28 | static struct scsi_host_template a4000t_scsi_driver_template = { | 24 | static struct scsi_host_template a4000t_scsi_driver_template = { |
| 29 | .name = "A4000T builtin SCSI", | 25 | .name = "A4000T builtin SCSI", |
| @@ -32,30 +28,35 @@ static struct scsi_host_template a4000t_scsi_driver_template = { | |||
| 32 | .module = THIS_MODULE, | 28 | .module = THIS_MODULE, |
| 33 | }; | 29 | }; |
| 34 | 30 | ||
| 35 | static struct platform_device *a4000t_scsi_device; | ||
| 36 | 31 | ||
| 37 | #define A4000T_SCSI_ADDR 0xdd0040 | 32 | #define A4000T_SCSI_OFFSET 0x40 |
| 38 | 33 | ||
| 39 | static int __devinit a4000t_probe(struct platform_device *dev) | 34 | static int __init amiga_a4000t_scsi_probe(struct platform_device *pdev) |
| 40 | { | 35 | { |
| 41 | struct Scsi_Host *host; | 36 | struct resource *res; |
| 37 | phys_addr_t scsi_addr; | ||
| 42 | struct NCR_700_Host_Parameters *hostdata; | 38 | struct NCR_700_Host_Parameters *hostdata; |
| 39 | struct Scsi_Host *host; | ||
| 43 | 40 | ||
| 44 | if (!(MACH_IS_AMIGA && AMIGAHW_PRESENT(A4000_SCSI))) | 41 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
| 45 | goto out; | 42 | if (!res) |
| 43 | return -ENODEV; | ||
| 46 | 44 | ||
| 47 | if (!request_mem_region(A4000T_SCSI_ADDR, 0x1000, | 45 | if (!request_mem_region(res->start, resource_size(res), |
| 48 | "A4000T builtin SCSI")) | 46 | "A4000T builtin SCSI")) |
| 49 | goto out; | 47 | return -EBUSY; |
| 50 | 48 | ||
| 51 | hostdata = kzalloc(sizeof(struct NCR_700_Host_Parameters), GFP_KERNEL); | 49 | hostdata = kzalloc(sizeof(struct NCR_700_Host_Parameters), |
| 50 | GFP_KERNEL); | ||
| 52 | if (!hostdata) { | 51 | if (!hostdata) { |
| 53 | printk(KERN_ERR "a4000t-scsi: Failed to allocate host data\n"); | 52 | dev_err(&pdev->dev, "Failed to allocate host data\n"); |
| 54 | goto out_release; | 53 | goto out_release; |
| 55 | } | 54 | } |
| 56 | 55 | ||
| 56 | scsi_addr = res->start + A4000T_SCSI_OFFSET; | ||
| 57 | |||
| 57 | /* Fill in the required pieces of hostdata */ | 58 | /* Fill in the required pieces of hostdata */ |
| 58 | hostdata->base = (void __iomem *)ZTWO_VADDR(A4000T_SCSI_ADDR); | 59 | hostdata->base = (void __iomem *)ZTWO_VADDR(scsi_addr); |
| 59 | hostdata->clock = 50; | 60 | hostdata->clock = 50; |
| 60 | hostdata->chip710 = 1; | 61 | hostdata->chip710 = 1; |
| 61 | hostdata->dmode_extra = DMODE_FC2; | 62 | hostdata->dmode_extra = DMODE_FC2; |
| @@ -63,26 +64,25 @@ static int __devinit a4000t_probe(struct platform_device *dev) | |||
| 63 | 64 | ||
| 64 | /* and register the chip */ | 65 | /* and register the chip */ |
| 65 | host = NCR_700_detect(&a4000t_scsi_driver_template, hostdata, | 66 | host = NCR_700_detect(&a4000t_scsi_driver_template, hostdata, |
| 66 | &dev->dev); | 67 | &pdev->dev); |
| 67 | if (!host) { | 68 | if (!host) { |
| 68 | printk(KERN_ERR "a4000t-scsi: No host detected; " | 69 | dev_err(&pdev->dev, |
| 69 | "board configuration problem?\n"); | 70 | "No host detected; board configuration problem?\n"); |
| 70 | goto out_free; | 71 | goto out_free; |
| 71 | } | 72 | } |
| 72 | 73 | ||
| 73 | host->this_id = 7; | 74 | host->this_id = 7; |
| 74 | host->base = A4000T_SCSI_ADDR; | 75 | host->base = scsi_addr; |
| 75 | host->irq = IRQ_AMIGA_PORTS; | 76 | host->irq = IRQ_AMIGA_PORTS; |
| 76 | 77 | ||
| 77 | if (request_irq(host->irq, NCR_700_intr, IRQF_SHARED, "a4000t-scsi", | 78 | if (request_irq(host->irq, NCR_700_intr, IRQF_SHARED, "a4000t-scsi", |
| 78 | host)) { | 79 | host)) { |
| 79 | printk(KERN_ERR "a4000t-scsi: request_irq failed\n"); | 80 | dev_err(&pdev->dev, "request_irq failed\n"); |
| 80 | goto out_put_host; | 81 | goto out_put_host; |
| 81 | } | 82 | } |
| 82 | 83 | ||
| 83 | platform_set_drvdata(dev, host); | 84 | platform_set_drvdata(pdev, host); |
| 84 | scsi_scan_host(host); | 85 | scsi_scan_host(host); |
| 85 | |||
| 86 | return 0; | 86 | return 0; |
| 87 | 87 | ||
| 88 | out_put_host: | 88 | out_put_host: |
| @@ -90,58 +90,49 @@ static int __devinit a4000t_probe(struct platform_device *dev) | |||
| 90 | out_free: | 90 | out_free: |
| 91 | kfree(hostdata); | 91 | kfree(hostdata); |
| 92 | out_release: | 92 | out_release: |
| 93 | release_mem_region(A4000T_SCSI_ADDR, 0x1000); | 93 | release_mem_region(res->start, resource_size(res)); |
| 94 | out: | ||
| 95 | return -ENODEV; | 94 | return -ENODEV; |
| 96 | } | 95 | } |
| 97 | 96 | ||
| 98 | static __devexit int a4000t_device_remove(struct platform_device *dev) | 97 | static int __exit amiga_a4000t_scsi_remove(struct platform_device *pdev) |
| 99 | { | 98 | { |
| 100 | struct Scsi_Host *host = platform_get_drvdata(dev); | 99 | struct Scsi_Host *host = platform_get_drvdata(pdev); |
| 101 | struct NCR_700_Host_Parameters *hostdata = shost_priv(host); | 100 | struct NCR_700_Host_Parameters *hostdata = shost_priv(host); |
| 101 | struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
| 102 | 102 | ||
| 103 | scsi_remove_host(host); | 103 | scsi_remove_host(host); |
| 104 | |||
| 105 | NCR_700_release(host); | 104 | NCR_700_release(host); |
| 106 | kfree(hostdata); | 105 | kfree(hostdata); |
| 107 | free_irq(host->irq, host); | 106 | free_irq(host->irq, host); |
| 108 | release_mem_region(A4000T_SCSI_ADDR, 0x1000); | 107 | release_mem_region(res->start, resource_size(res)); |
| 109 | |||
| 110 | return 0; | 108 | return 0; |
| 111 | } | 109 | } |
| 112 | 110 | ||
| 113 | static struct platform_driver a4000t_scsi_driver = { | 111 | static struct platform_driver amiga_a4000t_scsi_driver = { |
| 114 | .driver = { | 112 | .remove = __exit_p(amiga_a4000t_scsi_remove), |
| 115 | .name = "a4000t-scsi", | 113 | .driver = { |
| 116 | .owner = THIS_MODULE, | 114 | .name = "amiga-a4000t-scsi", |
| 115 | .owner = THIS_MODULE, | ||
| 117 | }, | 116 | }, |
| 118 | .probe = a4000t_probe, | ||
| 119 | .remove = __devexit_p(a4000t_device_remove), | ||
| 120 | }; | 117 | }; |
| 121 | 118 | ||
| 122 | static int __init a4000t_scsi_init(void) | 119 | static int __init amiga_a4000t_scsi_init(void) |
| 123 | { | 120 | { |
| 124 | int err; | 121 | return platform_driver_probe(&amiga_a4000t_scsi_driver, |
| 125 | 122 | amiga_a4000t_scsi_probe); | |
| 126 | err = platform_driver_register(&a4000t_scsi_driver); | ||
| 127 | if (err) | ||
| 128 | return err; | ||
| 129 | |||
| 130 | a4000t_scsi_device = platform_device_register_simple("a4000t-scsi", | ||
| 131 | -1, NULL, 0); | ||
| 132 | if (IS_ERR(a4000t_scsi_device)) { | ||
| 133 | platform_driver_unregister(&a4000t_scsi_driver); | ||
| 134 | return PTR_ERR(a4000t_scsi_device); | ||
| 135 | } | ||
| 136 | |||
| 137 | return err; | ||
| 138 | } | 123 | } |
| 139 | 124 | ||
| 140 | static void __exit a4000t_scsi_exit(void) | 125 | module_init(amiga_a4000t_scsi_init); |
| 126 | |||
| 127 | static void __exit amiga_a4000t_scsi_exit(void) | ||
| 141 | { | 128 | { |
| 142 | platform_device_unregister(a4000t_scsi_device); | 129 | platform_driver_unregister(&amiga_a4000t_scsi_driver); |
| 143 | platform_driver_unregister(&a4000t_scsi_driver); | ||
| 144 | } | 130 | } |
| 145 | 131 | ||
| 146 | module_init(a4000t_scsi_init); | 132 | module_exit(amiga_a4000t_scsi_exit); |
| 147 | module_exit(a4000t_scsi_exit); | 133 | |
| 134 | MODULE_AUTHOR("Alan Hourihane <alanh@fairlite.demon.co.uk> / " | ||
| 135 | "Kars de Jong <jongk@linux-m68k.org>"); | ||
| 136 | MODULE_DESCRIPTION("Amiga A4000T NCR53C710 driver"); | ||
| 137 | MODULE_LICENSE("GPL"); | ||
| 138 | MODULE_ALIAS("platform:amiga-a4000t-scsi"); | ||
