hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/ide/falconide.c
....@@ -15,6 +15,7 @@
1515 #include <linux/blkdev.h>
1616 #include <linux/ide.h>
1717 #include <linux/init.h>
18
+#include <linux/platform_device.h>
1819
1920 #include <asm/setup.h>
2021 #include <asm/atarihw.h>
....@@ -25,13 +26,7 @@
2526 #define DRV_NAME "falconide"
2627
2728 /*
28
- * Base of the IDE interface
29
- */
30
-
31
-#define ATA_HD_BASE 0xfff00000
32
-
33
- /*
34
- * Offsets from the above base
29
+ * Offsets from base address
3530 */
3631
3732 #define ATA_HD_CONTROL 0x39
....@@ -114,18 +109,18 @@
114109 .chipset = ide_generic,
115110 };
116111
117
-static void __init falconide_setup_ports(struct ide_hw *hw)
112
+static void __init falconide_setup_ports(struct ide_hw *hw, unsigned long base)
118113 {
119114 int i;
120115
121116 memset(hw, 0, sizeof(*hw));
122117
123
- hw->io_ports.data_addr = ATA_HD_BASE;
118
+ hw->io_ports.data_addr = base;
124119
125120 for (i = 1; i < 8; i++)
126
- hw->io_ports_array[i] = ATA_HD_BASE + 1 + i * 4;
121
+ hw->io_ports_array[i] = base + 1 + i * 4;
127122
128
- hw->io_ports.ctl_addr = ATA_HD_BASE + ATA_HD_CONTROL;
123
+ hw->io_ports.ctl_addr = base + ATA_HD_CONTROL;
129124
130125 hw->irq = IRQ_MFP_IDE;
131126 }
....@@ -134,23 +129,29 @@
134129 * Probe for a Falcon IDE interface
135130 */
136131
137
-static int __init falconide_init(void)
132
+static int __init falconide_init(struct platform_device *pdev)
138133 {
134
+ struct resource *res;
139135 struct ide_host *host;
140136 struct ide_hw hw, *hws[] = { &hw };
137
+ unsigned long base;
141138 int rc;
142139
143
- if (!MACH_IS_ATARI || !ATARIHW_PRESENT(IDE))
140
+ dev_info(&pdev->dev, "Atari Falcon IDE controller\n");
141
+
142
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
143
+ if (!res)
144144 return -ENODEV;
145145
146
- printk(KERN_INFO "ide: Falcon IDE controller\n");
147
-
148
- if (!request_mem_region(ATA_HD_BASE, 0x40, DRV_NAME)) {
149
- printk(KERN_ERR "%s: resources busy\n", DRV_NAME);
146
+ if (!devm_request_mem_region(&pdev->dev, res->start,
147
+ resource_size(res), DRV_NAME)) {
148
+ dev_err(&pdev->dev, "resources busy\n");
150149 return -EBUSY;
151150 }
152151
153
- falconide_setup_ports(&hw);
152
+ base = (unsigned long)res->start;
153
+
154
+ falconide_setup_ports(&hw, base);
154155
155156 host = ide_host_alloc(&falconide_port_info, hws, 1);
156157 if (host == NULL) {
....@@ -165,14 +166,34 @@
165166 if (rc)
166167 goto err_free;
167168
169
+ platform_set_drvdata(pdev, host);
168170 return 0;
169171 err_free:
170172 ide_host_free(host);
171173 err:
172
- release_mem_region(ATA_HD_BASE, 0x40);
174
+ release_mem_region(res->start, resource_size(res));
173175 return rc;
174176 }
175177
176
-module_init(falconide_init);
178
+static int falconide_remove(struct platform_device *pdev)
179
+{
180
+ struct ide_host *host = platform_get_drvdata(pdev);
177181
182
+ ide_host_remove(host);
183
+
184
+ return 0;
185
+}
186
+
187
+static struct platform_driver ide_falcon_driver = {
188
+ .remove = falconide_remove,
189
+ .driver = {
190
+ .name = "atari-falcon-ide",
191
+ },
192
+};
193
+
194
+module_platform_driver_probe(ide_falcon_driver, falconide_init);
195
+
196
+MODULE_AUTHOR("Geert Uytterhoeven");
197
+MODULE_DESCRIPTION("low-level driver for Atari Falcon IDE");
178198 MODULE_LICENSE("GPL");
199
+MODULE_ALIAS("platform:atari-falcon-ide");