Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 5ed0794cde593 ("m68k/atari: Convert Falcon IDE drivers to platform drivers")
References: commit 7ad19a99ad431 ("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>

authored by

Finn Thain and committed by
Geert Uytterhoeven
50c5feee 352e0429

+90 -26
+1
arch/m68k/configs/mac_defconfig
··· 317 317 CONFIG_IDE=y 318 318 CONFIG_IDE_GD_ATAPI=y 319 319 CONFIG_BLK_DEV_IDECD=y 320 + CONFIG_BLK_DEV_PLATFORM=y 320 321 CONFIG_BLK_DEV_MAC_IDE=y 321 322 CONFIG_RAID_ATTRS=m 322 323 CONFIG_SCSI=y
+1
arch/m68k/configs/multi_defconfig
··· 346 346 CONFIG_IDE=y 347 347 CONFIG_IDE_GD_ATAPI=y 348 348 CONFIG_BLK_DEV_IDECD=y 349 + CONFIG_BLK_DEV_PLATFORM=y 349 350 CONFIG_BLK_DEV_GAYLE=y 350 351 CONFIG_BLK_DEV_BUDDHA=y 351 352 CONFIG_BLK_DEV_FALCON_IDE=y
+41
arch/m68k/mac/config.c
··· 24 24 #include <linux/init.h> 25 25 #include <linux/vt_kern.h> 26 26 #include <linux/platform_device.h> 27 + #include <linux/ata_platform.h> 27 28 #include <linux/adb.h> 28 29 #include <linux/cuda.h> 29 30 #include <linux/pmu.h> ··· 941 940 }, 942 941 }; 943 942 943 + static const struct resource mac_ide_quadra_rsrc[] __initconst = { 944 + DEFINE_RES_MEM(0x50F1A000, 0x104), 945 + DEFINE_RES_IRQ(IRQ_NUBUS_F), 946 + }; 947 + 948 + static const struct resource mac_ide_pb_rsrc[] __initconst = { 949 + DEFINE_RES_MEM(0x50F1A000, 0x104), 950 + DEFINE_RES_IRQ(IRQ_NUBUS_C), 951 + }; 952 + 953 + static const struct resource mac_pata_baboon_rsrc[] __initconst = { 954 + DEFINE_RES_MEM(0x50F1A000, 0x38), 955 + DEFINE_RES_MEM(0x50F1A038, 0x04), 956 + DEFINE_RES_IRQ(IRQ_BABOON_1), 957 + }; 958 + 959 + static const struct pata_platform_info mac_pata_baboon_data __initconst = { 960 + .ioport_shift = 2, 961 + }; 962 + 944 963 int __init mac_platform_init(void) 945 964 { 946 965 phys_addr_t swim_base = 0; ··· 1066 1045 */ 1067 1046 platform_device_register_simple("mac_scsi", 0, 1068 1047 mac_scsi_ccl_rsrc, ARRAY_SIZE(mac_scsi_ccl_rsrc)); 1048 + break; 1049 + } 1050 + 1051 + /* 1052 + * IDE device 1053 + */ 1054 + 1055 + switch (macintosh_config->ide_type) { 1056 + case MAC_IDE_QUADRA: 1057 + platform_device_register_simple("mac_ide", -1, 1058 + mac_ide_quadra_rsrc, ARRAY_SIZE(mac_ide_quadra_rsrc)); 1059 + break; 1060 + case MAC_IDE_PB: 1061 + platform_device_register_simple("mac_ide", -1, 1062 + mac_ide_pb_rsrc, ARRAY_SIZE(mac_ide_pb_rsrc)); 1063 + break; 1064 + case MAC_IDE_BABOON: 1065 + platform_device_register_resndata(NULL, "pata_platform", -1, 1066 + mac_pata_baboon_rsrc, ARRAY_SIZE(mac_pata_baboon_rsrc), 1067 + &mac_pata_baboon_data, sizeof(mac_pata_baboon_data)); 1069 1068 break; 1070 1069 } 1071 1070
+4 -3
drivers/ide/Kconfig
··· 744 744 depends on MAC 745 745 help 746 746 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. 750 751 751 752 Say Y if you have such an Macintosh model and want to use IDE 752 753 devices (hard disks, CD-ROM drives, etc.) that are connected to the
+43 -23
drivers/ide/macide.c
··· 18 18 #include <linux/delay.h> 19 19 #include <linux/ide.h> 20 20 #include <linux/module.h> 21 + #include <linux/platform_device.h> 21 22 22 23 #include <asm/macintosh.h> 23 - #include <asm/macints.h> 24 - #include <asm/mac_baboon.h> 24 + 25 + #define DRV_NAME "mac_ide" 25 26 26 27 #define IDE_BASE 0x50F1A000 /* Base address of IDE controller */ 27 28 ··· 101 100 * Probe for a Macintosh IDE interface 102 101 */ 103 102 104 - static int __init macide_init(void) 103 + static int mac_ide_probe(struct platform_device *pdev) 105 104 { 106 - unsigned long base; 107 - int irq; 105 + struct resource *mem, *irq; 108 106 struct ide_hw hw, *hws[] = { &hw }; 109 107 struct ide_port_info d = macide_port_info; 108 + struct ide_host *host; 109 + int rc; 110 110 111 111 if (!MACH_IS_MAC) 112 112 return -ENODEV; 113 113 114 - switch (macintosh_config->ide_type) { 115 - case MAC_IDE_QUADRA: 116 - base = IDE_BASE; 117 - irq = IRQ_NUBUS_F; 118 - break; 119 - case MAC_IDE_PB: 120 - base = IDE_BASE; 121 - irq = IRQ_NUBUS_C; 122 - break; 123 - case MAC_IDE_BABOON: 124 - base = BABOON_BASE; 125 - d.port_ops = NULL; 126 - irq = IRQ_BABOON_1; 127 - break; 128 - default: 114 + mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 115 + if (!mem) 129 116 return -ENODEV; 117 + 118 + irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0); 119 + if (!irq) 120 + return -ENODEV; 121 + 122 + if (!devm_request_mem_region(&pdev->dev, mem->start, 123 + resource_size(mem), DRV_NAME)) { 124 + dev_err(&pdev->dev, "resources busy\n"); 125 + return -EBUSY; 130 126 } 131 127 132 128 printk(KERN_INFO "ide: Macintosh %s IDE controller\n", 133 129 mac_ide_name[macintosh_config->ide_type - 1]); 134 130 135 - macide_setup_ports(&hw, base, irq); 131 + macide_setup_ports(&hw, mem->start, irq->start); 136 132 137 - return ide_host_add(&d, hws, 1, NULL); 133 + rc = ide_host_add(&d, hws, 1, &host); 134 + if (rc) 135 + return rc; 136 + 137 + platform_set_drvdata(pdev, host); 138 + return 0; 138 139 } 139 140 140 - module_init(macide_init); 141 + static int mac_ide_remove(struct platform_device *pdev) 142 + { 143 + struct ide_host *host = platform_get_drvdata(pdev); 141 144 145 + ide_host_remove(host); 146 + return 0; 147 + } 148 + 149 + static struct platform_driver mac_ide_driver = { 150 + .driver = { 151 + .name = DRV_NAME, 152 + }, 153 + .probe = mac_ide_probe, 154 + .remove = mac_ide_remove, 155 + }; 156 + 157 + module_platform_driver(mac_ide_driver); 158 + 159 + MODULE_ALIAS("platform:" DRV_NAME); 142 160 MODULE_LICENSE("GPL");