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 | |
| 9 | #include <linux/init.h> |
| 10 | #include <linux/platform_device.h> |
| 11 | #include <linux/zorro.h> |
| 12 | |
| 13 | #include <asm/amigahw.h> |
Geert Uytterhoeven | 9aed230 | 2009-12-08 20:12:20 +0100 | [diff] [blame] | 14 | #include <asm/amigayle.h> |
Geert Uytterhoeven | 0d30546 | 2009-04-05 12:40:41 +0200 | [diff] [blame] | 15 | |
| 16 | |
| 17 | #ifdef CONFIG_ZORRO |
| 18 | |
| 19 | static const struct resource zorro_resources[] __initconst = { |
| 20 | /* Zorro II regions (on Zorro II/III) */ |
| 21 | { |
| 22 | .name = "Zorro II exp", |
| 23 | .start = 0x00e80000, |
| 24 | .end = 0x00efffff, |
| 25 | .flags = IORESOURCE_MEM, |
| 26 | }, { |
| 27 | .name = "Zorro II mem", |
| 28 | .start = 0x00200000, |
| 29 | .end = 0x009fffff, |
| 30 | .flags = IORESOURCE_MEM, |
| 31 | }, |
| 32 | /* Zorro III regions (on Zorro III only) */ |
| 33 | { |
| 34 | .name = "Zorro III exp", |
| 35 | .start = 0xff000000, |
| 36 | .end = 0xffffffff, |
| 37 | .flags = IORESOURCE_MEM, |
| 38 | }, { |
| 39 | .name = "Zorro III cfg", |
| 40 | .start = 0x40000000, |
| 41 | .end = 0x7fffffff, |
| 42 | .flags = IORESOURCE_MEM, |
| 43 | } |
| 44 | }; |
| 45 | |
| 46 | |
| 47 | static int __init amiga_init_bus(void) |
| 48 | { |
| 49 | if (!MACH_IS_AMIGA || !AMIGAHW_PRESENT(ZORRO)) |
| 50 | return -ENODEV; |
| 51 | |
| 52 | platform_device_register_simple("amiga-zorro", -1, zorro_resources, |
| 53 | AMIGAHW_PRESENT(ZORRO3) ? 4 : 2); |
| 54 | return 0; |
| 55 | } |
| 56 | |
| 57 | subsys_initcall(amiga_init_bus); |
| 58 | |
Geert Uytterhoeven | 9aed230 | 2009-12-08 20:12:20 +0100 | [diff] [blame] | 59 | |
| 60 | static int z_dev_present(zorro_id id) |
| 61 | { |
| 62 | unsigned int i; |
| 63 | |
| 64 | for (i = 0; i < zorro_num_autocon; i++) |
| 65 | if (zorro_autocon[i].rom.er_Manufacturer == ZORRO_MANUF(id) && |
| 66 | zorro_autocon[i].rom.er_Product == ZORRO_PROD(id)) |
| 67 | return 1; |
| 68 | |
| 69 | return 0; |
| 70 | } |
| 71 | |
| 72 | #else /* !CONFIG_ZORRO */ |
| 73 | |
| 74 | static inline int z_dev_present(zorro_id id) { return 0; } |
| 75 | |
| 76 | #endif /* !CONFIG_ZORRO */ |
Geert Uytterhoeven | fa6688e | 2009-04-05 12:45:56 +0200 | [diff] [blame] | 77 | |
| 78 | |
Geert Uytterhoeven | c2a24a4 | 2009-04-05 13:02:45 +0200 | [diff] [blame] | 79 | static const struct resource a3000_scsi_resource __initconst = { |
| 80 | .start = 0xdd0000, |
| 81 | .end = 0xdd00ff, |
| 82 | .flags = IORESOURCE_MEM, |
| 83 | }; |
| 84 | |
| 85 | |
Geert Uytterhoeven | a24a6b22 | 2009-04-05 13:05:50 +0200 | [diff] [blame] | 86 | static const struct resource a4000t_scsi_resource __initconst = { |
| 87 | .start = 0xdd0000, |
| 88 | .end = 0xdd0fff, |
| 89 | .flags = IORESOURCE_MEM, |
| 90 | }; |
| 91 | |
| 92 | |
Geert Uytterhoeven | 9aed230 | 2009-12-08 20:12:20 +0100 | [diff] [blame] | 93 | static const struct resource a1200_ide_resource __initconst = { |
| 94 | .start = 0xda0000, |
| 95 | .end = 0xda1fff, |
| 96 | .flags = IORESOURCE_MEM, |
| 97 | }; |
| 98 | |
| 99 | static const struct gayle_ide_platform_data a1200_ide_pdata __initconst = { |
| 100 | .base = 0xda0000, |
| 101 | .irqport = 0xda9000, |
| 102 | .explicit_ack = 1, |
| 103 | }; |
| 104 | |
| 105 | |
| 106 | static const struct resource a4000_ide_resource __initconst = { |
| 107 | .start = 0xdd2000, |
| 108 | .end = 0xdd3fff, |
| 109 | .flags = IORESOURCE_MEM, |
| 110 | }; |
| 111 | |
| 112 | static const struct gayle_ide_platform_data a4000_ide_pdata __initconst = { |
| 113 | .base = 0xdd2020, |
| 114 | .irqport = 0xdd3020, |
| 115 | .explicit_ack = 0, |
| 116 | }; |
| 117 | |
| 118 | |
Geert Uytterhoeven | fa6688e | 2009-04-05 12:45:56 +0200 | [diff] [blame] | 119 | static int __init amiga_init_devices(void) |
| 120 | { |
Geert Uytterhoeven | 9aed230 | 2009-12-08 20:12:20 +0100 | [diff] [blame] | 121 | struct platform_device *pdev; |
| 122 | |
Geert Uytterhoeven | fa6688e | 2009-04-05 12:45:56 +0200 | [diff] [blame] | 123 | if (!MACH_IS_AMIGA) |
| 124 | return -ENODEV; |
| 125 | |
| 126 | /* video hardware */ |
| 127 | if (AMIGAHW_PRESENT(AMI_VIDEO)) |
| 128 | platform_device_register_simple("amiga-video", -1, NULL, 0); |
| 129 | |
Geert Uytterhoeven | ff2db7c | 2009-04-05 12:59:54 +0200 | [diff] [blame] | 130 | |
| 131 | /* sound hardware */ |
| 132 | if (AMIGAHW_PRESENT(AMI_AUDIO)) |
| 133 | platform_device_register_simple("amiga-audio", -1, NULL, 0); |
| 134 | |
Geert Uytterhoeven | 92183b3 | 2009-04-05 13:02:13 +0200 | [diff] [blame] | 135 | |
| 136 | /* storage interfaces */ |
| 137 | if (AMIGAHW_PRESENT(AMI_FLOPPY)) |
| 138 | platform_device_register_simple("amiga-floppy", -1, NULL, 0); |
| 139 | |
Geert Uytterhoeven | c2a24a4 | 2009-04-05 13:02:45 +0200 | [diff] [blame] | 140 | if (AMIGAHW_PRESENT(A3000_SCSI)) |
| 141 | platform_device_register_simple("amiga-a3000-scsi", -1, |
| 142 | &a3000_scsi_resource, 1); |
| 143 | |
Geert Uytterhoeven | a24a6b22 | 2009-04-05 13:05:50 +0200 | [diff] [blame] | 144 | if (AMIGAHW_PRESENT(A4000_SCSI)) |
| 145 | platform_device_register_simple("amiga-a4000t-scsi", -1, |
| 146 | &a4000t_scsi_resource, 1); |
| 147 | |
Geert Uytterhoeven | 9aed230 | 2009-12-08 20:12:20 +0100 | [diff] [blame] | 148 | if (AMIGAHW_PRESENT(A1200_IDE) || |
| 149 | z_dev_present(ZORRO_PROD_MTEC_VIPER_MK_V_E_MATRIX_530_SCSI_IDE)) { |
| 150 | pdev = platform_device_register_simple("amiga-gayle-ide", -1, |
| 151 | &a1200_ide_resource, 1); |
| 152 | platform_device_add_data(pdev, &a1200_ide_pdata, |
| 153 | sizeof(a1200_ide_pdata)); |
| 154 | } |
| 155 | |
| 156 | if (AMIGAHW_PRESENT(A4000_IDE)) { |
| 157 | pdev = platform_device_register_simple("amiga-gayle-ide", -1, |
| 158 | &a4000_ide_resource, 1); |
| 159 | platform_device_add_data(pdev, &a4000_ide_pdata, |
| 160 | sizeof(a4000_ide_pdata)); |
| 161 | } |
| 162 | |
Geert Uytterhoeven | 5121c71 | 2009-04-05 13:10:56 +0200 | [diff] [blame] | 163 | |
| 164 | /* other I/O hardware */ |
| 165 | if (AMIGAHW_PRESENT(AMI_KEYBOARD)) |
| 166 | platform_device_register_simple("amiga-keyboard", -1, NULL, 0); |
| 167 | |
Geert Uytterhoeven | 314c926 | 2009-04-05 13:11:28 +0200 | [diff] [blame] | 168 | if (AMIGAHW_PRESENT(AMI_MOUSE)) |
| 169 | platform_device_register_simple("amiga-mouse", -1, NULL, 0); |
| 170 | |
Geert Uytterhoeven | 826e8c8 | 2009-04-05 13:12:30 +0200 | [diff] [blame^] | 171 | if (AMIGAHW_PRESENT(AMI_SERIAL)) |
| 172 | platform_device_register_simple("amiga-serial", -1, NULL, 0); |
| 173 | |
Geert Uytterhoeven | fa6688e | 2009-04-05 12:45:56 +0200 | [diff] [blame] | 174 | return 0; |
| 175 | } |
| 176 | |
| 177 | device_initcall(amiga_init_devices); |