| .. | .. |
|---|
| 15 | 15 | #include <linux/blkdev.h> |
|---|
| 16 | 16 | #include <linux/ide.h> |
|---|
| 17 | 17 | #include <linux/init.h> |
|---|
| 18 | +#include <linux/platform_device.h> |
|---|
| 18 | 19 | |
|---|
| 19 | 20 | #include <asm/setup.h> |
|---|
| 20 | 21 | #include <asm/atarihw.h> |
|---|
| .. | .. |
|---|
| 25 | 26 | #define DRV_NAME "falconide" |
|---|
| 26 | 27 | |
|---|
| 27 | 28 | /* |
|---|
| 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 |
|---|
| 35 | 30 | */ |
|---|
| 36 | 31 | |
|---|
| 37 | 32 | #define ATA_HD_CONTROL 0x39 |
|---|
| .. | .. |
|---|
| 114 | 109 | .chipset = ide_generic, |
|---|
| 115 | 110 | }; |
|---|
| 116 | 111 | |
|---|
| 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) |
|---|
| 118 | 113 | { |
|---|
| 119 | 114 | int i; |
|---|
| 120 | 115 | |
|---|
| 121 | 116 | memset(hw, 0, sizeof(*hw)); |
|---|
| 122 | 117 | |
|---|
| 123 | | - hw->io_ports.data_addr = ATA_HD_BASE; |
|---|
| 118 | + hw->io_ports.data_addr = base; |
|---|
| 124 | 119 | |
|---|
| 125 | 120 | 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; |
|---|
| 127 | 122 | |
|---|
| 128 | | - hw->io_ports.ctl_addr = ATA_HD_BASE + ATA_HD_CONTROL; |
|---|
| 123 | + hw->io_ports.ctl_addr = base + ATA_HD_CONTROL; |
|---|
| 129 | 124 | |
|---|
| 130 | 125 | hw->irq = IRQ_MFP_IDE; |
|---|
| 131 | 126 | } |
|---|
| .. | .. |
|---|
| 134 | 129 | * Probe for a Falcon IDE interface |
|---|
| 135 | 130 | */ |
|---|
| 136 | 131 | |
|---|
| 137 | | -static int __init falconide_init(void) |
|---|
| 132 | +static int __init falconide_init(struct platform_device *pdev) |
|---|
| 138 | 133 | { |
|---|
| 134 | + struct resource *res; |
|---|
| 139 | 135 | struct ide_host *host; |
|---|
| 140 | 136 | struct ide_hw hw, *hws[] = { &hw }; |
|---|
| 137 | + unsigned long base; |
|---|
| 141 | 138 | int rc; |
|---|
| 142 | 139 | |
|---|
| 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) |
|---|
| 144 | 144 | return -ENODEV; |
|---|
| 145 | 145 | |
|---|
| 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"); |
|---|
| 150 | 149 | return -EBUSY; |
|---|
| 151 | 150 | } |
|---|
| 152 | 151 | |
|---|
| 153 | | - falconide_setup_ports(&hw); |
|---|
| 152 | + base = (unsigned long)res->start; |
|---|
| 153 | + |
|---|
| 154 | + falconide_setup_ports(&hw, base); |
|---|
| 154 | 155 | |
|---|
| 155 | 156 | host = ide_host_alloc(&falconide_port_info, hws, 1); |
|---|
| 156 | 157 | if (host == NULL) { |
|---|
| .. | .. |
|---|
| 165 | 166 | if (rc) |
|---|
| 166 | 167 | goto err_free; |
|---|
| 167 | 168 | |
|---|
| 169 | + platform_set_drvdata(pdev, host); |
|---|
| 168 | 170 | return 0; |
|---|
| 169 | 171 | err_free: |
|---|
| 170 | 172 | ide_host_free(host); |
|---|
| 171 | 173 | err: |
|---|
| 172 | | - release_mem_region(ATA_HD_BASE, 0x40); |
|---|
| 174 | + release_mem_region(res->start, resource_size(res)); |
|---|
| 173 | 175 | return rc; |
|---|
| 174 | 176 | } |
|---|
| 175 | 177 | |
|---|
| 176 | | -module_init(falconide_init); |
|---|
| 178 | +static int falconide_remove(struct platform_device *pdev) |
|---|
| 179 | +{ |
|---|
| 180 | + struct ide_host *host = platform_get_drvdata(pdev); |
|---|
| 177 | 181 | |
|---|
| 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"); |
|---|
| 178 | 198 | MODULE_LICENSE("GPL"); |
|---|
| 199 | +MODULE_ALIAS("platform:atari-falcon-ide"); |
|---|