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

m68k: amiga - Amiga Gayle IDE platform device conversion

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>

+150 -66
+62 -1
arch/m68k/amiga/platform.c
··· 11 11 #include <linux/zorro.h> 12 12 13 13 #include <asm/amigahw.h> 14 + #include <asm/amigayle.h> 14 15 15 16 16 17 #ifdef CONFIG_ZORRO ··· 56 55 57 56 subsys_initcall(amiga_init_bus); 58 57 59 - #endif /* CONFIG_ZORRO */ 58 + 59 + static int z_dev_present(zorro_id id) 60 + { 61 + unsigned int i; 62 + 63 + for (i = 0; i < zorro_num_autocon; i++) 64 + if (zorro_autocon[i].rom.er_Manufacturer == ZORRO_MANUF(id) && 65 + zorro_autocon[i].rom.er_Product == ZORRO_PROD(id)) 66 + return 1; 67 + 68 + return 0; 69 + } 70 + 71 + #else /* !CONFIG_ZORRO */ 72 + 73 + static inline int z_dev_present(zorro_id id) { return 0; } 74 + 75 + #endif /* !CONFIG_ZORRO */ 60 76 61 77 62 78 static const struct resource a3000_scsi_resource __initconst = { ··· 90 72 }; 91 73 92 74 75 + static const struct resource a1200_ide_resource __initconst = { 76 + .start = 0xda0000, 77 + .end = 0xda1fff, 78 + .flags = IORESOURCE_MEM, 79 + }; 80 + 81 + static const struct gayle_ide_platform_data a1200_ide_pdata __initconst = { 82 + .base = 0xda0000, 83 + .irqport = 0xda9000, 84 + .explicit_ack = 1, 85 + }; 86 + 87 + 88 + static const struct resource a4000_ide_resource __initconst = { 89 + .start = 0xdd2000, 90 + .end = 0xdd3fff, 91 + .flags = IORESOURCE_MEM, 92 + }; 93 + 94 + static const struct gayle_ide_platform_data a4000_ide_pdata __initconst = { 95 + .base = 0xdd2020, 96 + .irqport = 0xdd3020, 97 + .explicit_ack = 0, 98 + }; 99 + 100 + 93 101 static int __init amiga_init_devices(void) 94 102 { 103 + struct platform_device *pdev; 104 + 95 105 if (!MACH_IS_AMIGA) 96 106 return -ENODEV; 97 107 ··· 144 98 if (AMIGAHW_PRESENT(A4000_SCSI)) 145 99 platform_device_register_simple("amiga-a4000t-scsi", -1, 146 100 &a4000t_scsi_resource, 1); 101 + 102 + if (AMIGAHW_PRESENT(A1200_IDE) || 103 + z_dev_present(ZORRO_PROD_MTEC_VIPER_MK_V_E_MATRIX_530_SCSI_IDE)) { 104 + pdev = platform_device_register_simple("amiga-gayle-ide", -1, 105 + &a1200_ide_resource, 1); 106 + platform_device_add_data(pdev, &a1200_ide_pdata, 107 + sizeof(a1200_ide_pdata)); 108 + } 109 + 110 + if (AMIGAHW_PRESENT(A4000_IDE)) { 111 + pdev = platform_device_register_simple("amiga-gayle-ide", -1, 112 + &a4000_ide_resource, 1); 113 + platform_device_add_data(pdev, &a4000_ide_pdata, 114 + sizeof(a4000_ide_pdata)); 115 + } 147 116 148 117 return 0; 149 118 }
+6
arch/m68k/include/asm/amigayle.h
··· 104 104 #define GAYLE_CFG_250NS 0x00 105 105 #define GAYLE_CFG_720NS 0x0c 106 106 107 + struct gayle_ide_platform_data { 108 + unsigned long base; 109 + unsigned long irqport; 110 + int explicit_ack; /* A1200 IDE needs explicit ack */ 111 + }; 112 + 107 113 #endif /* asm-m68k/amigayle.h */
+82 -65
drivers/ide/gayle.c
··· 16 16 #include <linux/init.h> 17 17 #include <linux/zorro.h> 18 18 #include <linux/module.h> 19 + #include <linux/platform_device.h> 19 20 20 21 #include <asm/setup.h> 21 22 #include <asm/amigahw.h> 22 23 #include <asm/amigaints.h> 23 24 #include <asm/amigayle.h> 24 25 25 - 26 - /* 27 - * Bases of the IDE interfaces 28 - */ 29 - 30 - #define GAYLE_BASE_4000 0xdd2020 /* A4000/A4000T */ 31 - #define GAYLE_BASE_1200 0xda0000 /* A1200/A600 and E-Matrix 530 */ 32 - 33 - #define GAYLE_IDEREG_SIZE 0x2000 34 26 35 27 /* 36 28 * Offsets from one of the above bases ··· 60 68 61 69 static int gayle_test_irq(ide_hwif_t *hwif) 62 70 { 63 - unsigned char ch; 71 + unsigned char ch; 64 72 65 - ch = z_readb(hwif->io_ports.irq_addr); 66 - if (!(ch & GAYLE_IRQ_IDE)) 67 - return 0; 68 - return 1; 73 + ch = z_readb(hwif->io_ports.irq_addr); 74 + if (!(ch & GAYLE_IRQ_IDE)) 75 + return 0; 76 + return 1; 69 77 } 70 78 71 79 static void gayle_a1200_clear_irq(ide_drive_t *drive) 72 80 { 73 - ide_hwif_t *hwif = drive->hwif; 81 + ide_hwif_t *hwif = drive->hwif; 74 82 75 - (void)z_readb(hwif->io_ports.status_addr); 76 - z_writeb(0x7c, hwif->io_ports.irq_addr); 83 + (void)z_readb(hwif->io_ports.status_addr); 84 + z_writeb(0x7c, hwif->io_ports.irq_addr); 77 85 } 78 86 79 87 static void __init gayle_setup_ports(struct ide_hw *hw, unsigned long base, ··· 114 122 * Probe for a Gayle IDE interface (and optionally for an IDE doubler) 115 123 */ 116 124 117 - static int __init gayle_init(void) 125 + static int __init amiga_gayle_ide_probe(struct platform_device *pdev) 118 126 { 119 - unsigned long phys_base, res_start, res_n; 120 - unsigned long base, ctrlport, irqport; 121 - int a4000, i, rc; 122 - struct ide_hw hw[GAYLE_NUM_HWIFS], *hws[GAYLE_NUM_HWIFS]; 123 - struct ide_port_info d = gayle_port_info; 127 + struct resource *res; 128 + struct gayle_ide_platform_data *pdata; 129 + unsigned long base, ctrlport, irqport; 130 + unsigned int i; 131 + int error; 132 + struct ide_hw hw[GAYLE_NUM_HWIFS], *hws[GAYLE_NUM_HWIFS]; 133 + struct ide_port_info d = gayle_port_info; 134 + struct ide_host *host; 124 135 125 - if (!MACH_IS_AMIGA) 126 - return -ENODEV; 136 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 137 + if (!res) 138 + return -ENODEV; 127 139 128 - if ((a4000 = AMIGAHW_PRESENT(A4000_IDE)) || AMIGAHW_PRESENT(A1200_IDE)) 129 - goto found; 130 - 131 - #ifdef CONFIG_ZORRO 132 - if (zorro_find_device(ZORRO_PROD_MTEC_VIPER_MK_V_E_MATRIX_530_SCSI_IDE, 133 - NULL)) 134 - goto found; 135 - #endif 136 - return -ENODEV; 137 - 138 - found: 139 - printk(KERN_INFO "ide: Gayle IDE controller (A%d style%s)\n", 140 - a4000 ? 4000 : 1200, 141 - ide_doubler ? ", IDE doubler" : ""); 142 - 143 - if (a4000) { 144 - phys_base = GAYLE_BASE_4000; 145 - irqport = (unsigned long)ZTWO_VADDR(GAYLE_IRQ_4000); 146 - d.port_ops = &gayle_a4000_port_ops; 147 - } else { 148 - phys_base = GAYLE_BASE_1200; 149 - irqport = (unsigned long)ZTWO_VADDR(GAYLE_IRQ_1200); 150 - d.port_ops = &gayle_a1200_port_ops; 151 - } 152 - 153 - res_start = ((unsigned long)phys_base) & ~(GAYLE_NEXT_PORT-1); 154 - res_n = GAYLE_IDEREG_SIZE; 155 - 156 - if (!request_mem_region(res_start, res_n, "IDE")) 140 + if (!request_mem_region(res->start, resource_size(res), "IDE")) 157 141 return -EBUSY; 158 142 159 - for (i = 0; i < GAYLE_NUM_PROBE_HWIFS; i++) { 160 - base = (unsigned long)ZTWO_VADDR(phys_base + i * GAYLE_NEXT_PORT); 161 - ctrlport = GAYLE_HAS_CONTROL_REG ? (base + GAYLE_CONTROL) : 0; 143 + pdata = pdev->dev.platform_data; 144 + pr_info("ide: Gayle IDE controller (A%u style%s)\n", 145 + pdata->explicit_ack ? 1200 : 4000, 146 + ide_doubler ? ", IDE doubler" : ""); 162 147 163 - gayle_setup_ports(&hw[i], base, ctrlport, irqport); 148 + base = (unsigned long)ZTWO_VADDR(pdata->base); 149 + ctrlport = 0; 150 + irqport = (unsigned long)ZTWO_VADDR(pdata->irqport); 151 + if (pdata->explicit_ack) 152 + d.port_ops = &gayle_a1200_port_ops; 153 + else 154 + d.port_ops = &gayle_a4000_port_ops; 164 155 165 - hws[i] = &hw[i]; 166 - } 156 + for (i = 0; i < GAYLE_NUM_PROBE_HWIFS; i++, base += GAYLE_NEXT_PORT) { 157 + if (GAYLE_HAS_CONTROL_REG) 158 + ctrlport = base + GAYLE_CONTROL; 167 159 168 - rc = ide_host_add(&d, hws, i, NULL); 169 - if (rc) 170 - release_mem_region(res_start, res_n); 160 + gayle_setup_ports(&hw[i], base, ctrlport, irqport); 161 + hws[i] = &hw[i]; 162 + } 171 163 172 - return rc; 164 + error = ide_host_add(&d, hws, i, &host); 165 + if (error) 166 + goto out; 167 + 168 + platform_set_drvdata(pdev, host); 169 + return 0; 170 + 171 + out: 172 + release_mem_region(res->start, resource_size(res)); 173 + return error; 173 174 } 174 175 175 - module_init(gayle_init); 176 + static int __exit amiga_gayle_ide_remove(struct platform_device *pdev) 177 + { 178 + struct ide_host *host = platform_get_drvdata(pdev); 179 + struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 180 + 181 + ide_host_remove(host); 182 + release_mem_region(res->start, resource_size(res)); 183 + return 0; 184 + } 185 + 186 + static struct platform_driver amiga_gayle_ide_driver = { 187 + .remove = __exit_p(amiga_gayle_ide_remove), 188 + .driver = { 189 + .name = "amiga-gayle-ide", 190 + .owner = THIS_MODULE, 191 + }, 192 + }; 193 + 194 + static int __init amiga_gayle_ide_init(void) 195 + { 196 + return platform_driver_probe(&amiga_gayle_ide_driver, 197 + amiga_gayle_ide_probe); 198 + } 199 + 200 + module_init(amiga_gayle_ide_init); 201 + 202 + static void __exit amiga_gayle_ide_exit(void) 203 + { 204 + platform_driver_unregister(&amiga_gayle_ide_driver); 205 + } 206 + 207 + module_exit(amiga_gayle_ide_exit); 176 208 177 209 MODULE_LICENSE("GPL"); 210 + MODULE_ALIAS("platform:amiga-gayle-ide");