xref: /openbmc/linux/arch/m68k/amiga/platform.c (revision e23feb16)
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/err.h>
10 #include <linux/init.h>
11 #include <linux/platform_device.h>
12 #include <linux/zorro.h>
13 
14 #include <asm/amigahw.h>
15 #include <asm/amigayle.h>
16 
17 
18 #ifdef CONFIG_ZORRO
19 
20 static const struct resource zorro_resources[] __initconst = {
21 	/* Zorro II regions (on Zorro II/III) */
22 	{
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,
32 	},
33 	/* Zorro III regions (on Zorro III only) */
34 	{
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,
44 	}
45 };
46 
47 
48 static int __init amiga_init_bus(void)
49 {
50 	struct platform_device *pdev;
51 	unsigned int n;
52 
53 	if (!MACH_IS_AMIGA || !AMIGAHW_PRESENT(ZORRO))
54 		return -ENODEV;
55 
56 	n = AMIGAHW_PRESENT(ZORRO3) ? 4 : 2;
57 	pdev = platform_device_register_simple("amiga-zorro", -1,
58 					       zorro_resources, n);
59 	return PTR_ERR_OR_ZERO(pdev);
60 }
61 
62 subsys_initcall(amiga_init_bus);
63 
64 
65 static int __init z_dev_present(zorro_id id)
66 {
67 	unsigned int i;
68 
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;
73 
74 	return 0;
75 }
76 
77 #else /* !CONFIG_ZORRO */
78 
79 static inline int z_dev_present(zorro_id id) { return 0; }
80 
81 #endif /* !CONFIG_ZORRO */
82 
83 
84 static const struct resource a3000_scsi_resource __initconst = {
85 	.start	= 0xdd0000,
86 	.end	= 0xdd00ff,
87 	.flags	= IORESOURCE_MEM,
88 };
89 
90 
91 static const struct resource a4000t_scsi_resource __initconst = {
92 	.start	= 0xdd0000,
93 	.end	= 0xdd0fff,
94 	.flags	= IORESOURCE_MEM,
95 };
96 
97 
98 static const struct resource a1200_ide_resource __initconst = {
99 	.start	= 0xda0000,
100 	.end	= 0xda1fff,
101 	.flags	= IORESOURCE_MEM,
102 };
103 
104 static const struct gayle_ide_platform_data a1200_ide_pdata __initconst = {
105 	.base		= 0xda0000,
106 	.irqport	= 0xda9000,
107 	.explicit_ack	= 1,
108 };
109 
110 
111 static const struct resource a4000_ide_resource __initconst = {
112 	.start	= 0xdd2000,
113 	.end	= 0xdd3fff,
114 	.flags	= IORESOURCE_MEM,
115 };
116 
117 static const struct gayle_ide_platform_data a4000_ide_pdata __initconst = {
118 	.base		= 0xdd2020,
119 	.irqport	= 0xdd3020,
120 	.explicit_ack	= 0,
121 };
122 
123 
124 static const struct resource amiga_rtc_resource __initconst = {
125 	.start	= 0x00dc0000,
126 	.end	= 0x00dcffff,
127 	.flags	= IORESOURCE_MEM,
128 };
129 
130 
131 static int __init amiga_init_devices(void)
132 {
133 	struct platform_device *pdev;
134 	int error;
135 
136 	if (!MACH_IS_AMIGA)
137 		return -ENODEV;
138 
139 	/* video hardware */
140 	if (AMIGAHW_PRESENT(AMI_VIDEO)) {
141 		pdev = platform_device_register_simple("amiga-video", -1, NULL,
142 						       0);
143 		if (IS_ERR(pdev))
144 			return PTR_ERR(pdev);
145 	}
146 
147 
148 	/* sound hardware */
149 	if (AMIGAHW_PRESENT(AMI_AUDIO)) {
150 		pdev = platform_device_register_simple("amiga-audio", -1, NULL,
151 						       0);
152 		if (IS_ERR(pdev))
153 			return PTR_ERR(pdev);
154 	}
155 
156 
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);
163 	}
164 
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);
170 	}
171 
172 	if (AMIGAHW_PRESENT(A4000_SCSI)) {
173 		pdev = platform_device_register_simple("amiga-a4000t-scsi", -1,
174 						       &a4000t_scsi_resource,
175 						       1);
176 		if (IS_ERR(pdev))
177 			return PTR_ERR(pdev);
178 	}
179 
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;
190 	}
191 
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;
201 	}
202 
203 
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);
210 	}
211 
212 	if (AMIGAHW_PRESENT(AMI_MOUSE)) {
213 		pdev = platform_device_register_simple("amiga-mouse", -1, NULL,
214 						       0);
215 		if (IS_ERR(pdev))
216 			return PTR_ERR(pdev);
217 	}
218 
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);
224 	}
225 
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);
231 	}
232 
233 
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);
240 	}
241 
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);
247 	}
248 
249 	return 0;
250 }
251 
252 arch_initcall(amiga_init_devices);
253