Skip to content

Commit 5ed0794

Browse files
Michael Schmitzgeertu
authored andcommitted
m68k/atari: Convert Falcon IDE drivers to platform drivers
Autoloading of Falcon IDE driver modules requires converting these drivers to platform drivers. Add platform device for Falcon IDE interface in Atari platform setup code. Use this in the pata_falcon driver in place of the simple platform device set up on the fly. Convert falconide driver to use the same platform device that is used by pata_falcon also. (With the introduction of a platform device for the Atari Falcon IDE interface, the old Falcon IDE driver no longer loads (resource already claimed by the platform device)). Tested (as built-in driver) on my Atari Falcon. Signed-off-by: Michael Schmitz <schmitzmic@gmail.com> Acked-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> Link: https://lore.kernel.org/r/1573008449-8226-1-git-send-email-schmitzmic@gmail.com Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
1 parent 032f128 commit 5ed0794

3 files changed

Lines changed: 95 additions & 34 deletions

File tree

‎arch/m68k/atari/config.c‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -869,8 +869,28 @@ static const struct resource atari_scsi_tt_rsrc[] __initconst = {
869869
};
870870
#endif
871871

872+
/*
873+
* Falcon IDE interface
874+
*/
875+
876+
#define FALCON_IDE_BASE 0xfff00000
877+
878+
static const struct resource atari_falconide_rsrc[] __initconst = {
879+
{
880+
.flags = IORESOURCE_MEM,
881+
.start = FALCON_IDE_BASE,
882+
.end = FALCON_IDE_BASE + 0x39,
883+
},
884+
{
885+
.flags = IORESOURCE_IRQ,
886+
.start = IRQ_MFP_FSCSI,
887+
.end = IRQ_MFP_FSCSI,
888+
},
889+
};
890+
872891
int __init atari_platform_init(void)
873892
{
893+
struct platform_device *pdev;
874894
int rv = 0;
875895

876896
if (!MACH_IS_ATARI)
@@ -912,6 +932,13 @@ int __init atari_platform_init(void)
912932
atari_scsi_tt_rsrc, ARRAY_SIZE(atari_scsi_tt_rsrc));
913933
#endif
914934

935+
if (ATARIHW_PRESENT(IDE)) {
936+
pdev = platform_device_register_simple("atari-falcon-ide", -1,
937+
atari_falconide_rsrc, ARRAY_SIZE(atari_falconide_rsrc));
938+
if (IS_ERR(pdev))
939+
rv = PTR_ERR(pdev);
940+
}
941+
915942
return rv;
916943
}
917944

‎drivers/ata/pata_falcon.c‎

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
#define DRV_NAME "pata_falcon"
3434
#define DRV_VERSION "0.1.0"
3535

36-
#define ATA_HD_BASE 0xfff00000
3736
#define ATA_HD_CONTROL 0x39
3837

3938
static struct scsi_host_template pata_falcon_sht = {
@@ -120,24 +119,22 @@ static struct ata_port_operations pata_falcon_ops = {
120119
.set_mode = pata_falcon_set_mode,
121120
};
122121

123-
static int pata_falcon_init_one(void)
122+
static int __init pata_falcon_init_one(struct platform_device *pdev)
124123
{
124+
struct resource *res;
125125
struct ata_host *host;
126126
struct ata_port *ap;
127-
struct platform_device *pdev;
128127
void __iomem *base;
129128

130-
if (!MACH_IS_ATARI || !ATARIHW_PRESENT(IDE))
131-
return -ENODEV;
132-
133-
pr_info(DRV_NAME ": Atari Falcon PATA controller\n");
129+
dev_info(&pdev->dev, "Atari Falcon PATA controller\n");
134130

135-
pdev = platform_device_register_simple(DRV_NAME, 0, NULL, 0);
136-
if (IS_ERR(pdev))
137-
return PTR_ERR(pdev);
131+
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
132+
if (!res)
133+
return -ENODEV;
138134

139-
if (!devm_request_mem_region(&pdev->dev, ATA_HD_BASE, 0x40, DRV_NAME)) {
140-
pr_err(DRV_NAME ": resources busy\n");
135+
if (!devm_request_mem_region(&pdev->dev, res->start,
136+
resource_size(res), DRV_NAME)) {
137+
dev_err(&pdev->dev, "resources busy\n");
141138
return -EBUSY;
142139
}
143140

@@ -152,7 +149,7 @@ static int pata_falcon_init_one(void)
152149
ap->flags |= ATA_FLAG_SLAVE_POSS | ATA_FLAG_NO_IORDY;
153150
ap->flags |= ATA_FLAG_PIO_POLLING;
154151

155-
base = (void __iomem *)ATA_HD_BASE;
152+
base = (void __iomem *)res->start;
156153
ap->ioaddr.data_addr = base;
157154
ap->ioaddr.error_addr = base + 1 + 1 * 4;
158155
ap->ioaddr.feature_addr = base + 1 + 1 * 4;
@@ -174,9 +171,26 @@ static int pata_falcon_init_one(void)
174171
return ata_host_activate(host, 0, NULL, 0, &pata_falcon_sht);
175172
}
176173

177-
module_init(pata_falcon_init_one);
174+
static int __exit pata_falcon_remove_one(struct platform_device *pdev)
175+
{
176+
struct ata_host *host = platform_get_drvdata(pdev);
177+
178+
ata_host_detach(host);
179+
180+
return 0;
181+
}
182+
183+
static struct platform_driver pata_falcon_driver = {
184+
.remove = __exit_p(pata_falcon_remove_one),
185+
.driver = {
186+
.name = "atari-falcon-ide",
187+
},
188+
};
189+
190+
module_platform_driver_probe(pata_falcon_driver, pata_falcon_init_one);
178191

179192
MODULE_AUTHOR("Bartlomiej Zolnierkiewicz");
180193
MODULE_DESCRIPTION("low-level driver for Atari Falcon PATA");
181194
MODULE_LICENSE("GPL v2");
195+
MODULE_ALIAS("platform:atari-falcon-ide");
182196
MODULE_VERSION(DRV_VERSION);

‎drivers/ide/falconide.c‎

Lines changed: 40 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -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 @@ static const struct ide_port_info falconide_port_info = {
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 @@ static void __init falconide_setup_ports(struct ide_hw *hw)
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))
144-
return -ENODEV;
140+
dev_info(&pdev->dev, "Atari Falcon IDE controller\n");
145141

146-
printk(KERN_INFO "ide: Falcon IDE controller\n");
142+
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
143+
if (!res)
144+
return -ENODEV;
147145

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) {
@@ -169,10 +170,29 @@ static int __init falconide_init(void)
169170
err_free:
170171
ide_host_free(host);
171172
err:
172-
release_mem_region(ATA_HD_BASE, 0x40);
173+
release_mem_region(res->start, resource_size(res));
173174
return rc;
174175
}
175176

176-
module_init(falconide_init);
177+
static int falconide_remove(struct platform_device *pdev)
178+
{
179+
struct ide_host *host = dev_get_drvdata(&pdev->dev);
180+
181+
ide_host_remove(host);
182+
183+
return 0;
184+
}
185+
186+
static struct platform_driver ide_falcon_driver = {
187+
.remove = falconide_remove,
188+
.driver = {
189+
.name = "atari-falcon-ide",
190+
},
191+
};
192+
193+
module_platform_driver_probe(ide_falcon_driver, falconide_init);
177194

195+
MODULE_AUTHOR("Geert Uytterhoeven");
196+
MODULE_DESCRIPTION("low-level driver for Atari Falcon IDE");
178197
MODULE_LICENSE("GPL");
198+
MODULE_ALIAS("platform:atari-falcon-ide");

0 commit comments

Comments
 (0)