Geert Uytterhoeven | 0d30546 | 2009-04-05 12:40:41 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2007-2009 Geert Uytterhoeven |
| 3 | * |
| 4 | * This file is subject to the terms and conditions of the GNU General Public |
| 5 | * License. See the file COPYING in the main directory of this archive |
| 6 | * for more details. |
| 7 | */ |
| 8 | |
Geert Uytterhoeven | eeed227 | 2012-01-22 12:44:25 +0100 | [diff] [blame] | 9 | #include <linux/err.h> |
Geert Uytterhoeven | 0d30546 | 2009-04-05 12:40:41 +0200 | [diff] [blame] | 10 | #include <linux/init.h> |
| 11 | #include <linux/platform_device.h> |
| 12 | #include <linux/zorro.h> |
| 13 | |
| 14 | #include <asm/amigahw.h> |
Geert Uytterhoeven | 9aed230 | 2009-12-08 20:12:20 +0100 | [diff] [blame] | 15 | #include <asm/amigayle.h> |
Geert Uytterhoeven | bd9ba8f | 2013-10-04 09:38:53 +0200 | [diff] [blame] | 16 | #include <asm/byteorder.h> |
Geert Uytterhoeven | 0d30546 | 2009-04-05 12:40:41 +0200 | [diff] [blame] | 17 | |
| 18 | |
| 19 | #ifdef CONFIG_ZORRO |
| 20 | |
| 21 | static const struct resource zorro_resources[] __initconst = { |
| 22 | /* Zorro II regions (on Zorro II/III) */ |
| 23 | { |
| 24 | .name = "Zorro II exp", |
| 25 | .start = 0x00e80000, |
| 26 | .end = 0x00efffff, |
| 27 | .flags = IORESOURCE_MEM, |
| 28 | }, { |
| 29 | .name = "Zorro II mem", |
| 30 | .start = 0x00200000, |
| 31 | .end = 0x009fffff, |
| 32 | .flags = IORESOURCE_MEM, |
| 33 | }, |
| 34 | /* Zorro III regions (on Zorro III only) */ |
| 35 | { |
| 36 | .name = "Zorro III exp", |
| 37 | .start = 0xff000000, |
| 38 | .end = 0xffffffff, |
| 39 | .flags = IORESOURCE_MEM, |
| 40 | }, { |
| 41 | .name = "Zorro III cfg", |
| 42 | .start = 0x40000000, |
| 43 | .end = 0x7fffffff, |
| 44 | .flags = IORESOURCE_MEM, |
| 45 | } |
| 46 | }; |
| 47 | |
| 48 | |
| 49 | static int __init amiga_init_bus(void) |
| 50 | { |
Geert Uytterhoeven | eeed227 | 2012-01-22 12:44:25 +0100 | [diff] [blame] | 51 | struct platform_device *pdev; |
| 52 | unsigned int n; |
| 53 | |
Geert Uytterhoeven | 0d30546 | 2009-04-05 12:40:41 +0200 | [diff] [blame] | 54 | if (!MACH_IS_AMIGA || !AMIGAHW_PRESENT(ZORRO)) |
| 55 | return -ENODEV; |
| 56 | |
Geert Uytterhoeven | eeed227 | 2012-01-22 12:44:25 +0100 | [diff] [blame] | 57 | n = AMIGAHW_PRESENT(ZORRO3) ? 4 : 2; |
| 58 | pdev = platform_device_register_simple("amiga-zorro", -1, |
| 59 | zorro_resources, n); |
Rusty Russell | 8c6ffba | 2013-07-15 11:20:32 +0930 | [diff] [blame] | 60 | return PTR_ERR_OR_ZERO(pdev); |
Geert Uytterhoeven | 0d30546 | 2009-04-05 12:40:41 +0200 | [diff] [blame] | 61 | } |
| 62 | |
| 63 | subsys_initcall(amiga_init_bus); |
| 64 | |
Geert Uytterhoeven | 9aed230 | 2009-12-08 20:12:20 +0100 | [diff] [blame] | 65 | |
Geert Uytterhoeven | 943ce30 | 2012-01-22 12:25:55 +0100 | [diff] [blame] | 66 | static int __init z_dev_present(zorro_id id) |
Geert Uytterhoeven | 9aed230 | 2009-12-08 20:12:20 +0100 | [diff] [blame] | 67 | { |
| 68 | unsigned int i; |
| 69 | |
Geert Uytterhoeven | bd9ba8f | 2013-10-04 09:38:53 +0200 | [diff] [blame] | 70 | for (i = 0; i < zorro_num_autocon; i++) { |
| 71 | const struct ExpansionRom *rom = &zorro_autocon_init[i].rom; |
| 72 | if (be16_to_cpu(rom->er_Manufacturer) == ZORRO_MANUF(id) && |
| 73 | rom->er_Product == ZORRO_PROD(id)) |
Geert Uytterhoeven | 9aed230 | 2009-12-08 20:12:20 +0100 | [diff] [blame] | 74 | return 1; |
Geert Uytterhoeven | bd9ba8f | 2013-10-04 09:38:53 +0200 | [diff] [blame] | 75 | } |
Geert Uytterhoeven | 9aed230 | 2009-12-08 20:12:20 +0100 | [diff] [blame] | 76 | |
| 77 | return 0; |
| 78 | } |
| 79 | |
| 80 | #else /* !CONFIG_ZORRO */ |
| 81 | |
| 82 | static inline int z_dev_present(zorro_id id) { return 0; } |
| 83 | |
| 84 | #endif /* !CONFIG_ZORRO */ |
Geert Uytterhoeven | fa6688e | 2009-04-05 12:45:56 +0200 | [diff] [blame] | 85 | |
| 86 | |
Geert Uytterhoeven | c2a24a4 | 2009-04-05 13:02:45 +0200 | [diff] [blame] | 87 | static const struct resource a3000_scsi_resource __initconst = { |
| 88 | .start = 0xdd0000, |
| 89 | .end = 0xdd00ff, |
| 90 | .flags = IORESOURCE_MEM, |
| 91 | }; |
| 92 | |
| 93 | |
Geert Uytterhoeven | a24a6b22 | 2009-04-05 13:05:50 +0200 | [diff] [blame] | 94 | static const struct resource a4000t_scsi_resource __initconst = { |
| 95 | .start = 0xdd0000, |
| 96 | .end = 0xdd0fff, |
| 97 | .flags = IORESOURCE_MEM, |
| 98 | }; |
| 99 | |
| 100 | |
Geert Uytterhoeven | 9aed230 | 2009-12-08 20:12:20 +0100 | [diff] [blame] | 101 | static const struct resource a1200_ide_resource __initconst = { |
| 102 | .start = 0xda0000, |
| 103 | .end = 0xda1fff, |
| 104 | .flags = IORESOURCE_MEM, |
| 105 | }; |
| 106 | |
| 107 | static const struct gayle_ide_platform_data a1200_ide_pdata __initconst = { |
| 108 | .base = 0xda0000, |
| 109 | .irqport = 0xda9000, |
| 110 | .explicit_ack = 1, |
| 111 | }; |
| 112 | |
| 113 | |
| 114 | static const struct resource a4000_ide_resource __initconst = { |
| 115 | .start = 0xdd2000, |
| 116 | .end = 0xdd3fff, |
| 117 | .flags = IORESOURCE_MEM, |
| 118 | }; |
| 119 | |
| 120 | static const struct gayle_ide_platform_data a4000_ide_pdata __initconst = { |
| 121 | .base = 0xdd2020, |
| 122 | .irqport = 0xdd3020, |
| 123 | .explicit_ack = 0, |
| 124 | }; |
| 125 | |
| 126 | |
Geert Uytterhoeven | 0779c86 | 2009-04-05 13:15:10 +0200 | [diff] [blame] | 127 | static const struct resource amiga_rtc_resource __initconst = { |
| 128 | .start = 0x00dc0000, |
| 129 | .end = 0x00dcffff, |
| 130 | .flags = IORESOURCE_MEM, |
| 131 | }; |
| 132 | |
| 133 | |
Geert Uytterhoeven | fa6688e | 2009-04-05 12:45:56 +0200 | [diff] [blame] | 134 | static int __init amiga_init_devices(void) |
| 135 | { |
Geert Uytterhoeven | 9aed230 | 2009-12-08 20:12:20 +0100 | [diff] [blame] | 136 | struct platform_device *pdev; |
Geert Uytterhoeven | eeed227 | 2012-01-22 12:44:25 +0100 | [diff] [blame] | 137 | int error; |
Geert Uytterhoeven | 9aed230 | 2009-12-08 20:12:20 +0100 | [diff] [blame] | 138 | |
Geert Uytterhoeven | fa6688e | 2009-04-05 12:45:56 +0200 | [diff] [blame] | 139 | if (!MACH_IS_AMIGA) |
| 140 | return -ENODEV; |
| 141 | |
| 142 | /* video hardware */ |
Geert Uytterhoeven | eeed227 | 2012-01-22 12:44:25 +0100 | [diff] [blame] | 143 | if (AMIGAHW_PRESENT(AMI_VIDEO)) { |
| 144 | pdev = platform_device_register_simple("amiga-video", -1, NULL, |
| 145 | 0); |
| 146 | if (IS_ERR(pdev)) |
| 147 | return PTR_ERR(pdev); |
| 148 | } |
Geert Uytterhoeven | fa6688e | 2009-04-05 12:45:56 +0200 | [diff] [blame] | 149 | |
Geert Uytterhoeven | ff2db7c | 2009-04-05 12:59:54 +0200 | [diff] [blame] | 150 | |
| 151 | /* sound hardware */ |
Geert Uytterhoeven | eeed227 | 2012-01-22 12:44:25 +0100 | [diff] [blame] | 152 | if (AMIGAHW_PRESENT(AMI_AUDIO)) { |
| 153 | pdev = platform_device_register_simple("amiga-audio", -1, NULL, |
| 154 | 0); |
| 155 | if (IS_ERR(pdev)) |
| 156 | return PTR_ERR(pdev); |
| 157 | } |
Geert Uytterhoeven | ff2db7c | 2009-04-05 12:59:54 +0200 | [diff] [blame] | 158 | |
Geert Uytterhoeven | 92183b3 | 2009-04-05 13:02:13 +0200 | [diff] [blame] | 159 | |
| 160 | /* storage interfaces */ |
Geert Uytterhoeven | eeed227 | 2012-01-22 12:44:25 +0100 | [diff] [blame] | 161 | if (AMIGAHW_PRESENT(AMI_FLOPPY)) { |
| 162 | pdev = platform_device_register_simple("amiga-floppy", -1, |
| 163 | NULL, 0); |
| 164 | if (IS_ERR(pdev)) |
| 165 | return PTR_ERR(pdev); |
| 166 | } |
Geert Uytterhoeven | 92183b3 | 2009-04-05 13:02:13 +0200 | [diff] [blame] | 167 | |
Geert Uytterhoeven | eeed227 | 2012-01-22 12:44:25 +0100 | [diff] [blame] | 168 | if (AMIGAHW_PRESENT(A3000_SCSI)) { |
| 169 | pdev = platform_device_register_simple("amiga-a3000-scsi", -1, |
| 170 | &a3000_scsi_resource, 1); |
| 171 | if (IS_ERR(pdev)) |
| 172 | return PTR_ERR(pdev); |
| 173 | } |
Geert Uytterhoeven | c2a24a4 | 2009-04-05 13:02:45 +0200 | [diff] [blame] | 174 | |
Geert Uytterhoeven | eeed227 | 2012-01-22 12:44:25 +0100 | [diff] [blame] | 175 | if (AMIGAHW_PRESENT(A4000_SCSI)) { |
| 176 | pdev = platform_device_register_simple("amiga-a4000t-scsi", -1, |
| 177 | &a4000t_scsi_resource, |
| 178 | 1); |
| 179 | if (IS_ERR(pdev)) |
| 180 | return PTR_ERR(pdev); |
| 181 | } |
Geert Uytterhoeven | a24a6b22 | 2009-04-05 13:05:50 +0200 | [diff] [blame] | 182 | |
Geert Uytterhoeven | 9aed230 | 2009-12-08 20:12:20 +0100 | [diff] [blame] | 183 | if (AMIGAHW_PRESENT(A1200_IDE) || |
| 184 | z_dev_present(ZORRO_PROD_MTEC_VIPER_MK_V_E_MATRIX_530_SCSI_IDE)) { |
| 185 | pdev = platform_device_register_simple("amiga-gayle-ide", -1, |
| 186 | &a1200_ide_resource, 1); |
Geert Uytterhoeven | eeed227 | 2012-01-22 12:44:25 +0100 | [diff] [blame] | 187 | if (IS_ERR(pdev)) |
| 188 | return PTR_ERR(pdev); |
| 189 | error = platform_device_add_data(pdev, &a1200_ide_pdata, |
| 190 | sizeof(a1200_ide_pdata)); |
| 191 | if (error) |
| 192 | return error; |
Geert Uytterhoeven | 9aed230 | 2009-12-08 20:12:20 +0100 | [diff] [blame] | 193 | } |
| 194 | |
| 195 | if (AMIGAHW_PRESENT(A4000_IDE)) { |
| 196 | pdev = platform_device_register_simple("amiga-gayle-ide", -1, |
| 197 | &a4000_ide_resource, 1); |
Geert Uytterhoeven | eeed227 | 2012-01-22 12:44:25 +0100 | [diff] [blame] | 198 | if (IS_ERR(pdev)) |
| 199 | return PTR_ERR(pdev); |
| 200 | error = platform_device_add_data(pdev, &a4000_ide_pdata, |
| 201 | sizeof(a4000_ide_pdata)); |
| 202 | if (error) |
| 203 | return error; |
Geert Uytterhoeven | 9aed230 | 2009-12-08 20:12:20 +0100 | [diff] [blame] | 204 | } |
| 205 | |
Geert Uytterhoeven | 5121c71 | 2009-04-05 13:10:56 +0200 | [diff] [blame] | 206 | |
| 207 | /* other I/O hardware */ |
Geert Uytterhoeven | eeed227 | 2012-01-22 12:44:25 +0100 | [diff] [blame] | 208 | if (AMIGAHW_PRESENT(AMI_KEYBOARD)) { |
| 209 | pdev = platform_device_register_simple("amiga-keyboard", -1, |
| 210 | NULL, 0); |
| 211 | if (IS_ERR(pdev)) |
| 212 | return PTR_ERR(pdev); |
| 213 | } |
Geert Uytterhoeven | 5121c71 | 2009-04-05 13:10:56 +0200 | [diff] [blame] | 214 | |
Geert Uytterhoeven | eeed227 | 2012-01-22 12:44:25 +0100 | [diff] [blame] | 215 | if (AMIGAHW_PRESENT(AMI_MOUSE)) { |
| 216 | pdev = platform_device_register_simple("amiga-mouse", -1, NULL, |
| 217 | 0); |
| 218 | if (IS_ERR(pdev)) |
| 219 | return PTR_ERR(pdev); |
| 220 | } |
Geert Uytterhoeven | 314c926 | 2009-04-05 13:11:28 +0200 | [diff] [blame] | 221 | |
Geert Uytterhoeven | eeed227 | 2012-01-22 12:44:25 +0100 | [diff] [blame] | 222 | if (AMIGAHW_PRESENT(AMI_SERIAL)) { |
| 223 | pdev = platform_device_register_simple("amiga-serial", -1, |
| 224 | NULL, 0); |
| 225 | if (IS_ERR(pdev)) |
| 226 | return PTR_ERR(pdev); |
| 227 | } |
Geert Uytterhoeven | 826e8c8 | 2009-04-05 13:12:30 +0200 | [diff] [blame] | 228 | |
Geert Uytterhoeven | eeed227 | 2012-01-22 12:44:25 +0100 | [diff] [blame] | 229 | if (AMIGAHW_PRESENT(AMI_PARALLEL)) { |
| 230 | pdev = platform_device_register_simple("amiga-parallel", -1, |
| 231 | NULL, 0); |
| 232 | if (IS_ERR(pdev)) |
| 233 | return PTR_ERR(pdev); |
| 234 | } |
Geert Uytterhoeven | 6f8221c | 2009-04-05 13:13:20 +0200 | [diff] [blame] | 235 | |
Geert Uytterhoeven | 0779c86 | 2009-04-05 13:15:10 +0200 | [diff] [blame] | 236 | |
| 237 | /* real time clocks */ |
Geert Uytterhoeven | eeed227 | 2012-01-22 12:44:25 +0100 | [diff] [blame] | 238 | if (AMIGAHW_PRESENT(A2000_CLK)) { |
| 239 | pdev = platform_device_register_simple("rtc-msm6242", -1, |
| 240 | &amiga_rtc_resource, 1); |
| 241 | if (IS_ERR(pdev)) |
| 242 | return PTR_ERR(pdev); |
| 243 | } |
Geert Uytterhoeven | 0779c86 | 2009-04-05 13:15:10 +0200 | [diff] [blame] | 244 | |
Geert Uytterhoeven | eeed227 | 2012-01-22 12:44:25 +0100 | [diff] [blame] | 245 | if (AMIGAHW_PRESENT(A3000_CLK)) { |
| 246 | pdev = platform_device_register_simple("rtc-rp5c01", -1, |
| 247 | &amiga_rtc_resource, 1); |
| 248 | if (IS_ERR(pdev)) |
| 249 | return PTR_ERR(pdev); |
| 250 | } |
Geert Uytterhoeven | 0779c86 | 2009-04-05 13:15:10 +0200 | [diff] [blame] | 251 | |
Geert Uytterhoeven | fa6688e | 2009-04-05 12:45:56 +0200 | [diff] [blame] | 252 | return 0; |
| 253 | } |
| 254 | |
Geert Uytterhoeven | e2b5628 | 2012-01-22 12:45:45 +0100 | [diff] [blame] | 255 | arch_initcall(amiga_init_devices); |