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
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>
16 #include <asm/byteorder.h>
21 static const struct resource zorro_resources
[] __initconst
= {
22 /* Zorro II regions (on Zorro II/III) */
24 .name
= "Zorro II exp",
27 .flags
= IORESOURCE_MEM
,
29 .name
= "Zorro II mem",
32 .flags
= IORESOURCE_MEM
,
34 /* Zorro III regions (on Zorro III only) */
36 .name
= "Zorro III exp",
39 .flags
= IORESOURCE_MEM
,
41 .name
= "Zorro III cfg",
44 .flags
= IORESOURCE_MEM
,
49 static int __init
amiga_init_bus(void)
51 struct platform_device
*pdev
;
54 if (!MACH_IS_AMIGA
|| !AMIGAHW_PRESENT(ZORRO
))
57 n
= AMIGAHW_PRESENT(ZORRO3
) ? 4 : 2;
58 pdev
= platform_device_register_simple("amiga-zorro", -1,
60 return PTR_ERR_OR_ZERO(pdev
);
63 subsys_initcall(amiga_init_bus
);
66 static int __init
z_dev_present(zorro_id id
)
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
))
80 #else /* !CONFIG_ZORRO */
82 static inline int z_dev_present(zorro_id id
) { return 0; }
84 #endif /* !CONFIG_ZORRO */
87 static const struct resource a3000_scsi_resource __initconst
= {
90 .flags
= IORESOURCE_MEM
,
94 static const struct resource a4000t_scsi_resource __initconst
= {
97 .flags
= IORESOURCE_MEM
,
101 static const struct resource a1200_ide_resource __initconst
= {
104 .flags
= IORESOURCE_MEM
,
107 static const struct gayle_ide_platform_data a1200_ide_pdata __initconst
= {
114 static const struct resource a4000_ide_resource __initconst
= {
117 .flags
= IORESOURCE_MEM
,
120 static const struct gayle_ide_platform_data a4000_ide_pdata __initconst
= {
127 static const struct resource amiga_rtc_resource __initconst
= {
130 .flags
= IORESOURCE_MEM
,
134 static int __init
amiga_init_devices(void)
136 struct platform_device
*pdev
;
143 if (AMIGAHW_PRESENT(AMI_VIDEO
)) {
144 pdev
= platform_device_register_simple("amiga-video", -1, NULL
,
147 return PTR_ERR(pdev
);
152 if (AMIGAHW_PRESENT(AMI_AUDIO
)) {
153 pdev
= platform_device_register_simple("amiga-audio", -1, NULL
,
156 return PTR_ERR(pdev
);
160 /* storage interfaces */
161 if (AMIGAHW_PRESENT(AMI_FLOPPY
)) {
162 pdev
= platform_device_register_simple("amiga-floppy", -1,
165 return PTR_ERR(pdev
);
168 if (AMIGAHW_PRESENT(A3000_SCSI
)) {
169 pdev
= platform_device_register_simple("amiga-a3000-scsi", -1,
170 &a3000_scsi_resource
, 1);
172 return PTR_ERR(pdev
);
175 if (AMIGAHW_PRESENT(A4000_SCSI
)) {
176 pdev
= platform_device_register_simple("amiga-a4000t-scsi", -1,
177 &a4000t_scsi_resource
,
180 return PTR_ERR(pdev
);
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);
188 return PTR_ERR(pdev
);
189 error
= platform_device_add_data(pdev
, &a1200_ide_pdata
,
190 sizeof(a1200_ide_pdata
));
195 if (AMIGAHW_PRESENT(A4000_IDE
)) {
196 pdev
= platform_device_register_simple("amiga-gayle-ide", -1,
197 &a4000_ide_resource
, 1);
199 return PTR_ERR(pdev
);
200 error
= platform_device_add_data(pdev
, &a4000_ide_pdata
,
201 sizeof(a4000_ide_pdata
));
207 /* other I/O hardware */
208 if (AMIGAHW_PRESENT(AMI_KEYBOARD
)) {
209 pdev
= platform_device_register_simple("amiga-keyboard", -1,
212 return PTR_ERR(pdev
);
215 if (AMIGAHW_PRESENT(AMI_MOUSE
)) {
216 pdev
= platform_device_register_simple("amiga-mouse", -1, NULL
,
219 return PTR_ERR(pdev
);
222 if (AMIGAHW_PRESENT(AMI_SERIAL
)) {
223 pdev
= platform_device_register_simple("amiga-serial", -1,
226 return PTR_ERR(pdev
);
229 if (AMIGAHW_PRESENT(AMI_PARALLEL
)) {
230 pdev
= platform_device_register_simple("amiga-parallel", -1,
233 return PTR_ERR(pdev
);
237 /* real time clocks */
238 if (AMIGAHW_PRESENT(A2000_CLK
)) {
239 pdev
= platform_device_register_simple("rtc-msm6242", -1,
240 &amiga_rtc_resource
, 1);
242 return PTR_ERR(pdev
);
245 if (AMIGAHW_PRESENT(A3000_CLK
)) {
246 pdev
= platform_device_register_simple("rtc-rp5c01", -1,
247 &amiga_rtc_resource
, 1);
249 return PTR_ERR(pdev
);
255 arch_initcall(amiga_init_devices
);