Linux 3.8-rc7
[cris-mirror.git] / arch / m68k / amiga / platform.c
blob6083088c0cca8287f50888143fb18a95d71c0b5d
1 /*
2 * Copyright (C) 2007-2009 Geert Uytterhoeven
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 */
9 #include <linux/err.h>
10 #include <linux/init.h>
11 #include <linux/platform_device.h>
12 #include <linux/zorro.h>
14 #include <asm/amigahw.h>
15 #include <asm/amigayle.h>
18 #ifdef CONFIG_ZORRO
20 static const struct resource zorro_resources[] __initconst = {
21 /* Zorro II regions (on Zorro II/III) */
23 .name = "Zorro II exp",
24 .start = 0x00e80000,
25 .end = 0x00efffff,
26 .flags = IORESOURCE_MEM,
27 }, {
28 .name = "Zorro II mem",
29 .start = 0x00200000,
30 .end = 0x009fffff,
31 .flags = IORESOURCE_MEM,
33 /* Zorro III regions (on Zorro III only) */
35 .name = "Zorro III exp",
36 .start = 0xff000000,
37 .end = 0xffffffff,
38 .flags = IORESOURCE_MEM,
39 }, {
40 .name = "Zorro III cfg",
41 .start = 0x40000000,
42 .end = 0x7fffffff,
43 .flags = IORESOURCE_MEM,
48 static int __init amiga_init_bus(void)
50 struct platform_device *pdev;
51 unsigned int n;
53 if (!MACH_IS_AMIGA || !AMIGAHW_PRESENT(ZORRO))
54 return -ENODEV;
56 n = AMIGAHW_PRESENT(ZORRO3) ? 4 : 2;
57 pdev = platform_device_register_simple("amiga-zorro", -1,
58 zorro_resources, n);
59 return PTR_RET(pdev);
62 subsys_initcall(amiga_init_bus);
65 static int __init z_dev_present(zorro_id id)
67 unsigned int i;
69 for (i = 0; i < zorro_num_autocon; i++)
70 if (zorro_autocon[i].rom.er_Manufacturer == ZORRO_MANUF(id) &&
71 zorro_autocon[i].rom.er_Product == ZORRO_PROD(id))
72 return 1;
74 return 0;
77 #else /* !CONFIG_ZORRO */
79 static inline int z_dev_present(zorro_id id) { return 0; }
81 #endif /* !CONFIG_ZORRO */
84 static const struct resource a3000_scsi_resource __initconst = {
85 .start = 0xdd0000,
86 .end = 0xdd00ff,
87 .flags = IORESOURCE_MEM,
91 static const struct resource a4000t_scsi_resource __initconst = {
92 .start = 0xdd0000,
93 .end = 0xdd0fff,
94 .flags = IORESOURCE_MEM,
98 static const struct resource a1200_ide_resource __initconst = {
99 .start = 0xda0000,
100 .end = 0xda1fff,
101 .flags = IORESOURCE_MEM,
104 static const struct gayle_ide_platform_data a1200_ide_pdata __initconst = {
105 .base = 0xda0000,
106 .irqport = 0xda9000,
107 .explicit_ack = 1,
111 static const struct resource a4000_ide_resource __initconst = {
112 .start = 0xdd2000,
113 .end = 0xdd3fff,
114 .flags = IORESOURCE_MEM,
117 static const struct gayle_ide_platform_data a4000_ide_pdata __initconst = {
118 .base = 0xdd2020,
119 .irqport = 0xdd3020,
120 .explicit_ack = 0,
124 static const struct resource amiga_rtc_resource __initconst = {
125 .start = 0x00dc0000,
126 .end = 0x00dcffff,
127 .flags = IORESOURCE_MEM,
131 static int __init amiga_init_devices(void)
133 struct platform_device *pdev;
134 int error;
136 if (!MACH_IS_AMIGA)
137 return -ENODEV;
139 /* video hardware */
140 if (AMIGAHW_PRESENT(AMI_VIDEO)) {
141 pdev = platform_device_register_simple("amiga-video", -1, NULL,
143 if (IS_ERR(pdev))
144 return PTR_ERR(pdev);
148 /* sound hardware */
149 if (AMIGAHW_PRESENT(AMI_AUDIO)) {
150 pdev = platform_device_register_simple("amiga-audio", -1, NULL,
152 if (IS_ERR(pdev))
153 return PTR_ERR(pdev);
157 /* storage interfaces */
158 if (AMIGAHW_PRESENT(AMI_FLOPPY)) {
159 pdev = platform_device_register_simple("amiga-floppy", -1,
160 NULL, 0);
161 if (IS_ERR(pdev))
162 return PTR_ERR(pdev);
165 if (AMIGAHW_PRESENT(A3000_SCSI)) {
166 pdev = platform_device_register_simple("amiga-a3000-scsi", -1,
167 &a3000_scsi_resource, 1);
168 if (IS_ERR(pdev))
169 return PTR_ERR(pdev);
172 if (AMIGAHW_PRESENT(A4000_SCSI)) {
173 pdev = platform_device_register_simple("amiga-a4000t-scsi", -1,
174 &a4000t_scsi_resource,
176 if (IS_ERR(pdev))
177 return PTR_ERR(pdev);
180 if (AMIGAHW_PRESENT(A1200_IDE) ||
181 z_dev_present(ZORRO_PROD_MTEC_VIPER_MK_V_E_MATRIX_530_SCSI_IDE)) {
182 pdev = platform_device_register_simple("amiga-gayle-ide", -1,
183 &a1200_ide_resource, 1);
184 if (IS_ERR(pdev))
185 return PTR_ERR(pdev);
186 error = platform_device_add_data(pdev, &a1200_ide_pdata,
187 sizeof(a1200_ide_pdata));
188 if (error)
189 return error;
192 if (AMIGAHW_PRESENT(A4000_IDE)) {
193 pdev = platform_device_register_simple("amiga-gayle-ide", -1,
194 &a4000_ide_resource, 1);
195 if (IS_ERR(pdev))
196 return PTR_ERR(pdev);
197 error = platform_device_add_data(pdev, &a4000_ide_pdata,
198 sizeof(a4000_ide_pdata));
199 if (error)
200 return error;
204 /* other I/O hardware */
205 if (AMIGAHW_PRESENT(AMI_KEYBOARD)) {
206 pdev = platform_device_register_simple("amiga-keyboard", -1,
207 NULL, 0);
208 if (IS_ERR(pdev))
209 return PTR_ERR(pdev);
212 if (AMIGAHW_PRESENT(AMI_MOUSE)) {
213 pdev = platform_device_register_simple("amiga-mouse", -1, NULL,
215 if (IS_ERR(pdev))
216 return PTR_ERR(pdev);
219 if (AMIGAHW_PRESENT(AMI_SERIAL)) {
220 pdev = platform_device_register_simple("amiga-serial", -1,
221 NULL, 0);
222 if (IS_ERR(pdev))
223 return PTR_ERR(pdev);
226 if (AMIGAHW_PRESENT(AMI_PARALLEL)) {
227 pdev = platform_device_register_simple("amiga-parallel", -1,
228 NULL, 0);
229 if (IS_ERR(pdev))
230 return PTR_ERR(pdev);
234 /* real time clocks */
235 if (AMIGAHW_PRESENT(A2000_CLK)) {
236 pdev = platform_device_register_simple("rtc-msm6242", -1,
237 &amiga_rtc_resource, 1);
238 if (IS_ERR(pdev))
239 return PTR_ERR(pdev);
242 if (AMIGAHW_PRESENT(A3000_CLK)) {
243 pdev = platform_device_register_simple("rtc-rp5c01", -1,
244 &amiga_rtc_resource, 1);
245 if (IS_ERR(pdev))
246 return PTR_ERR(pdev);
249 return 0;
252 arch_initcall(amiga_init_devices);