Skip to content

Commit 50c5fee

Browse files
Finn Thaingeertu
authored andcommitted
ide/macide: Convert Mac IDE driver to platform driver
Add platform devices for the Mac IDE controller variants. Convert the macide module into a platform driver to support two of those variants. For the third, use a generic "pata_platform" driver instead. This enables automatic loading of the appropriate module and begins the process of replacing the driver with libata alternatives. Signed-off-by: Finn Thain <fthain@telegraphics.com.au> Tested-by: Stan Johnson <userm57@yahoo.com> Cc: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> Cc: Joshua Thompson <funaho@jurai.org> References: commit 5ed0794 ("m68k/atari: Convert Falcon IDE drivers to platform drivers") References: commit 7ad19a9 ("ide: officially deprecated the legacy IDE driver") Link: https://lore.kernel.org/r/edd106dad1bbea32500601c6071f37a9f02a8004.1600901284.git.fthain@telegraphics.com.au Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
1 parent 352e042 commit 50c5fee

5 files changed

Lines changed: 90 additions & 26 deletions

File tree

arch/m68k/configs/mac_defconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,7 @@ CONFIG_DUMMY_IRQ=m
317317
CONFIG_IDE=y
318318
CONFIG_IDE_GD_ATAPI=y
319319
CONFIG_BLK_DEV_IDECD=y
320+
CONFIG_BLK_DEV_PLATFORM=y
320321
CONFIG_BLK_DEV_MAC_IDE=y
321322
CONFIG_RAID_ATTRS=m
322323
CONFIG_SCSI=y

arch/m68k/configs/multi_defconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,7 @@ CONFIG_DUMMY_IRQ=m
346346
CONFIG_IDE=y
347347
CONFIG_IDE_GD_ATAPI=y
348348
CONFIG_BLK_DEV_IDECD=y
349+
CONFIG_BLK_DEV_PLATFORM=y
349350
CONFIG_BLK_DEV_GAYLE=y
350351
CONFIG_BLK_DEV_BUDDHA=y
351352
CONFIG_BLK_DEV_FALCON_IDE=y

arch/m68k/mac/config.c

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <linux/init.h>
2525
#include <linux/vt_kern.h>
2626
#include <linux/platform_device.h>
27+
#include <linux/ata_platform.h>
2728
#include <linux/adb.h>
2829
#include <linux/cuda.h>
2930
#include <linux/pmu.h>
@@ -940,6 +941,26 @@ static const struct resource mac_scsi_ccl_rsrc[] __initconst = {
940941
},
941942
};
942943

944+
static const struct resource mac_ide_quadra_rsrc[] __initconst = {
945+
DEFINE_RES_MEM(0x50F1A000, 0x104),
946+
DEFINE_RES_IRQ(IRQ_NUBUS_F),
947+
};
948+
949+
static const struct resource mac_ide_pb_rsrc[] __initconst = {
950+
DEFINE_RES_MEM(0x50F1A000, 0x104),
951+
DEFINE_RES_IRQ(IRQ_NUBUS_C),
952+
};
953+
954+
static const struct resource mac_pata_baboon_rsrc[] __initconst = {
955+
DEFINE_RES_MEM(0x50F1A000, 0x38),
956+
DEFINE_RES_MEM(0x50F1A038, 0x04),
957+
DEFINE_RES_IRQ(IRQ_BABOON_1),
958+
};
959+
960+
static const struct pata_platform_info mac_pata_baboon_data __initconst = {
961+
.ioport_shift = 2,
962+
};
963+
943964
int __init mac_platform_init(void)
944965
{
945966
phys_addr_t swim_base = 0;
@@ -1048,6 +1069,26 @@ int __init mac_platform_init(void)
10481069
break;
10491070
}
10501071

1072+
/*
1073+
* IDE device
1074+
*/
1075+
1076+
switch (macintosh_config->ide_type) {
1077+
case MAC_IDE_QUADRA:
1078+
platform_device_register_simple("mac_ide", -1,
1079+
mac_ide_quadra_rsrc, ARRAY_SIZE(mac_ide_quadra_rsrc));
1080+
break;
1081+
case MAC_IDE_PB:
1082+
platform_device_register_simple("mac_ide", -1,
1083+
mac_ide_pb_rsrc, ARRAY_SIZE(mac_ide_pb_rsrc));
1084+
break;
1085+
case MAC_IDE_BABOON:
1086+
platform_device_register_resndata(NULL, "pata_platform", -1,
1087+
mac_pata_baboon_rsrc, ARRAY_SIZE(mac_pata_baboon_rsrc),
1088+
&mac_pata_baboon_data, sizeof(mac_pata_baboon_data));
1089+
break;
1090+
}
1091+
10511092
/*
10521093
* Ethernet device
10531094
*/

drivers/ide/Kconfig

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -744,9 +744,10 @@ config BLK_DEV_MAC_IDE
744744
depends on MAC
745745
help
746746
This is the IDE driver for the on-board IDE interface on some m68k
747-
Macintosh models. It supports both the `Quadra style' (used in
748-
Quadra/ Centris 630 and Performa 588 models) and `Powerbook style'
749-
(used in the Powerbook 150 and 190 models) IDE interface.
747+
Macintosh models, namely Quadra/Centris 630, Performa 588 and
748+
Powerbook 150. The IDE interface on the Powerbook 190 is not
749+
supported by this driver and requires BLK_DEV_PLATFORM or
750+
PATA_PLATFORM.
750751

751752
Say Y if you have such an Macintosh model and want to use IDE
752753
devices (hard disks, CD-ROM drives, etc.) that are connected to the

drivers/ide/macide.c

Lines changed: 43 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,11 @@
1818
#include <linux/delay.h>
1919
#include <linux/ide.h>
2020
#include <linux/module.h>
21+
#include <linux/platform_device.h>
2122

2223
#include <asm/macintosh.h>
23-
#include <asm/macints.h>
24-
#include <asm/mac_baboon.h>
24+
25+
#define DRV_NAME "mac_ide"
2526

2627
#define IDE_BASE 0x50F1A000 /* Base address of IDE controller */
2728

@@ -100,42 +101,61 @@ static const char *mac_ide_name[] =
100101
* Probe for a Macintosh IDE interface
101102
*/
102103

103-
static int __init macide_init(void)
104+
static int mac_ide_probe(struct platform_device *pdev)
104105
{
105-
unsigned long base;
106-
int irq;
106+
struct resource *mem, *irq;
107107
struct ide_hw hw, *hws[] = { &hw };
108108
struct ide_port_info d = macide_port_info;
109+
struct ide_host *host;
110+
int rc;
109111

110112
if (!MACH_IS_MAC)
111113
return -ENODEV;
112114

113-
switch (macintosh_config->ide_type) {
114-
case MAC_IDE_QUADRA:
115-
base = IDE_BASE;
116-
irq = IRQ_NUBUS_F;
117-
break;
118-
case MAC_IDE_PB:
119-
base = IDE_BASE;
120-
irq = IRQ_NUBUS_C;
121-
break;
122-
case MAC_IDE_BABOON:
123-
base = BABOON_BASE;
124-
d.port_ops = NULL;
125-
irq = IRQ_BABOON_1;
126-
break;
127-
default:
115+
mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
116+
if (!mem)
117+
return -ENODEV;
118+
119+
irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
120+
if (!irq)
128121
return -ENODEV;
122+
123+
if (!devm_request_mem_region(&pdev->dev, mem->start,
124+
resource_size(mem), DRV_NAME)) {
125+
dev_err(&pdev->dev, "resources busy\n");
126+
return -EBUSY;
129127
}
130128

131129
printk(KERN_INFO "ide: Macintosh %s IDE controller\n",
132130
mac_ide_name[macintosh_config->ide_type - 1]);
133131

134-
macide_setup_ports(&hw, base, irq);
132+
macide_setup_ports(&hw, mem->start, irq->start);
135133

136-
return ide_host_add(&d, hws, 1, NULL);
134+
rc = ide_host_add(&d, hws, 1, &host);
135+
if (rc)
136+
return rc;
137+
138+
platform_set_drvdata(pdev, host);
139+
return 0;
137140
}
138141

139-
module_init(macide_init);
142+
static int mac_ide_remove(struct platform_device *pdev)
143+
{
144+
struct ide_host *host = platform_get_drvdata(pdev);
145+
146+
ide_host_remove(host);
147+
return 0;
148+
}
149+
150+
static struct platform_driver mac_ide_driver = {
151+
.driver = {
152+
.name = DRV_NAME,
153+
},
154+
.probe = mac_ide_probe,
155+
.remove = mac_ide_remove,
156+
};
157+
158+
module_platform_driver(mac_ide_driver);
140159

160+
MODULE_ALIAS("platform:" DRV_NAME);
141161
MODULE_LICENSE("GPL");

0 commit comments

Comments
 (0)