Commit | Line | Data |
---|---|---|
1dbae815 TL |
1 | /* |
2 | * linux/arch/arm/mach-omap2/devices.c | |
3 | * | |
4 | * OMAP2 platform device setup/initialization | |
5 | * | |
6 | * This program is free software; you can redistribute it and/or modify | |
7 | * it under the terms of the GNU General Public License as published by | |
8 | * the Free Software Foundation; either version 2 of the License, or | |
9 | * (at your option) any later version. | |
10 | */ | |
2f8163ba | 11 | #include <linux/gpio.h> |
1dbae815 TL |
12 | #include <linux/kernel.h> |
13 | #include <linux/init.h> | |
14 | #include <linux/platform_device.h> | |
fced80c7 | 15 | #include <linux/io.h> |
917fa280 | 16 | #include <linux/clk.h> |
f2ce6231 | 17 | #include <linux/err.h> |
1a5d8190 | 18 | #include <linux/slab.h> |
ad8dfac6 | 19 | #include <linux/of.h> |
484202f4 | 20 | #include <linux/pinctrl/machine.h> |
0f1142a5 | 21 | #include <linux/platform_data/omap4-keypad.h> |
459bc971 | 22 | #include <linux/platform_data/omap_ocp2scp.h> |
36273356 | 23 | #include <linux/usb/omap_control_usb.h> |
1dbae815 | 24 | |
1dbae815 TL |
25 | #include <asm/mach-types.h> |
26 | #include <asm/mach/map.h> | |
27 | ||
45c3eb7d | 28 | #include <linux/omap-dma.h> |
2a296c8f | 29 | |
ee0839c2 | 30 | #include "iomap.h" |
2a296c8f | 31 | #include "omap_hwmod.h" |
25c7d49e | 32 | #include "omap_device.h" |
0e70156d | 33 | #include "omap4-keypad.h" |
1dbae815 | 34 | |
7d7e1eba TL |
35 | #include "soc.h" |
36 | #include "common.h" | |
4896e394 | 37 | #include "mux.h" |
4814ced5 | 38 | #include "control.h" |
a11f6706 | 39 | #include "devices.h" |
d5e7c864 | 40 | #include "dma.h" |
4896e394 | 41 | |
0abcf618 | 42 | #define L3_MODULES_MAX_LEN 12 |
a4dc616a | 43 | #define L3_MODULES 3 |
0abcf618 | 44 | |
45 | static int __init omap3_l3_init(void) | |
46 | { | |
0abcf618 | 47 | struct omap_hwmod *oh; |
3528c58e | 48 | struct platform_device *pdev; |
0abcf618 | 49 | char oh_name[L3_MODULES_MAX_LEN]; |
50 | ||
51 | /* | |
52 | * To avoid code running on other OMAPs in | |
53 | * multi-omap builds | |
54 | */ | |
55 | if (!(cpu_is_omap34xx())) | |
56 | return -ENODEV; | |
57 | ||
eeb3711b | 58 | snprintf(oh_name, L3_MODULES_MAX_LEN, "l3_main"); |
0abcf618 | 59 | |
60 | oh = omap_hwmod_lookup(oh_name); | |
61 | ||
62 | if (!oh) | |
63 | pr_err("could not look up %s\n", oh_name); | |
64 | ||
c1d1cd59 | 65 | pdev = omap_device_build("omap_l3_smx", 0, oh, NULL, 0); |
0abcf618 | 66 | |
3528c58e | 67 | WARN(IS_ERR(pdev), "could not build omap_device for %s\n", oh_name); |
0abcf618 | 68 | |
3528c58e | 69 | return IS_ERR(pdev) ? PTR_ERR(pdev) : 0; |
0abcf618 | 70 | } |
b76c8b19 | 71 | omap_postcore_initcall(omap3_l3_init); |
0abcf618 | 72 | |
a4dc616a | 73 | static int __init omap4_l3_init(void) |
74 | { | |
eeb3711b | 75 | int i; |
a4dc616a | 76 | struct omap_hwmod *oh[3]; |
3528c58e | 77 | struct platform_device *pdev; |
a4dc616a | 78 | char oh_name[L3_MODULES_MAX_LEN]; |
79 | ||
ad8dfac6 BC |
80 | /* If dtb is there, the devices will be created dynamically */ |
81 | if (of_have_populated_dt()) | |
82 | return -ENODEV; | |
83 | ||
a4dc616a | 84 | /* |
85 | * To avoid code running on other OMAPs in | |
86 | * multi-omap builds | |
87 | */ | |
e17933c2 | 88 | if (!cpu_is_omap44xx() && !soc_is_omap54xx()) |
a4dc616a | 89 | return -ENODEV; |
90 | ||
91 | for (i = 0; i < L3_MODULES; i++) { | |
eeb3711b | 92 | snprintf(oh_name, L3_MODULES_MAX_LEN, "l3_main_%d", i+1); |
a4dc616a | 93 | |
94 | oh[i] = omap_hwmod_lookup(oh_name); | |
95 | if (!(oh[i])) | |
96 | pr_err("could not look up %s\n", oh_name); | |
97 | } | |
98 | ||
c1d1cd59 | 99 | pdev = omap_device_build_ss("omap_l3_noc", 0, oh, 3, NULL, 0); |
a4dc616a | 100 | |
3528c58e | 101 | WARN(IS_ERR(pdev), "could not build omap_device for %s\n", oh_name); |
a4dc616a | 102 | |
3528c58e | 103 | return IS_ERR(pdev) ? PTR_ERR(pdev) : 0; |
a4dc616a | 104 | } |
b76c8b19 | 105 | omap_postcore_initcall(omap4_l3_init); |
a4dc616a | 106 | |
828c707e | 107 | #if defined(CONFIG_VIDEO_OMAP2) || defined(CONFIG_VIDEO_OMAP2_MODULE) |
c40fae95 | 108 | |
cfe2cde6 | 109 | static struct resource omap2cam_resources[] = { |
c40fae95 | 110 | { |
828c707e TL |
111 | .start = OMAP24XX_CAMERA_BASE, |
112 | .end = OMAP24XX_CAMERA_BASE + 0xfff, | |
113 | .flags = IORESOURCE_MEM, | |
114 | }, | |
115 | { | |
7d7e1eba | 116 | .start = 24 + OMAP_INTC_START, |
828c707e TL |
117 | .flags = IORESOURCE_IRQ, |
118 | } | |
119 | }; | |
120 | ||
cfe2cde6 | 121 | static struct platform_device omap2cam_device = { |
828c707e TL |
122 | .name = "omap24xxcam", |
123 | .id = -1, | |
cfe2cde6 SA |
124 | .num_resources = ARRAY_SIZE(omap2cam_resources), |
125 | .resource = omap2cam_resources, | |
828c707e | 126 | }; |
a11f6706 | 127 | #endif |
828c707e | 128 | |
1a51a0ce OBC |
129 | #if defined(CONFIG_IOMMU_API) |
130 | ||
2ab7c848 | 131 | #include <linux/platform_data/iommu-omap.h> |
1a51a0ce | 132 | |
828c707e TL |
133 | static struct resource omap3isp_resources[] = { |
134 | { | |
135 | .start = OMAP3430_ISP_BASE, | |
136 | .end = OMAP3430_ISP_END, | |
137 | .flags = IORESOURCE_MEM, | |
138 | }, | |
828c707e TL |
139 | { |
140 | .start = OMAP3430_ISP_CCP2_BASE, | |
141 | .end = OMAP3430_ISP_CCP2_END, | |
142 | .flags = IORESOURCE_MEM, | |
143 | }, | |
144 | { | |
145 | .start = OMAP3430_ISP_CCDC_BASE, | |
146 | .end = OMAP3430_ISP_CCDC_END, | |
147 | .flags = IORESOURCE_MEM, | |
148 | }, | |
149 | { | |
150 | .start = OMAP3430_ISP_HIST_BASE, | |
151 | .end = OMAP3430_ISP_HIST_END, | |
152 | .flags = IORESOURCE_MEM, | |
153 | }, | |
154 | { | |
155 | .start = OMAP3430_ISP_H3A_BASE, | |
156 | .end = OMAP3430_ISP_H3A_END, | |
157 | .flags = IORESOURCE_MEM, | |
158 | }, | |
159 | { | |
160 | .start = OMAP3430_ISP_PREV_BASE, | |
161 | .end = OMAP3430_ISP_PREV_END, | |
162 | .flags = IORESOURCE_MEM, | |
163 | }, | |
164 | { | |
165 | .start = OMAP3430_ISP_RESZ_BASE, | |
166 | .end = OMAP3430_ISP_RESZ_END, | |
167 | .flags = IORESOURCE_MEM, | |
168 | }, | |
169 | { | |
170 | .start = OMAP3430_ISP_SBL_BASE, | |
171 | .end = OMAP3430_ISP_SBL_END, | |
172 | .flags = IORESOURCE_MEM, | |
173 | }, | |
174 | { | |
6817a69a TT |
175 | .start = OMAP3430_ISP_CSI2A_REGS1_BASE, |
176 | .end = OMAP3430_ISP_CSI2A_REGS1_END, | |
828c707e TL |
177 | .flags = IORESOURCE_MEM, |
178 | }, | |
179 | { | |
6817a69a TT |
180 | .start = OMAP3430_ISP_CSIPHY2_BASE, |
181 | .end = OMAP3430_ISP_CSIPHY2_END, | |
182 | .flags = IORESOURCE_MEM, | |
183 | }, | |
184 | { | |
185 | .start = OMAP3630_ISP_CSI2A_REGS2_BASE, | |
186 | .end = OMAP3630_ISP_CSI2A_REGS2_END, | |
828c707e TL |
187 | .flags = IORESOURCE_MEM, |
188 | }, | |
189 | { | |
6817a69a TT |
190 | .start = OMAP3630_ISP_CSI2C_REGS1_BASE, |
191 | .end = OMAP3630_ISP_CSI2C_REGS1_END, | |
192 | .flags = IORESOURCE_MEM, | |
193 | }, | |
194 | { | |
195 | .start = OMAP3630_ISP_CSIPHY1_BASE, | |
196 | .end = OMAP3630_ISP_CSIPHY1_END, | |
197 | .flags = IORESOURCE_MEM, | |
198 | }, | |
199 | { | |
200 | .start = OMAP3630_ISP_CSI2C_REGS2_BASE, | |
201 | .end = OMAP3630_ISP_CSI2C_REGS2_END, | |
828c707e TL |
202 | .flags = IORESOURCE_MEM, |
203 | }, | |
c19d19eb SA |
204 | { |
205 | .start = OMAP343X_CTRL_BASE + OMAP343X_CONTROL_CSIRXFE, | |
206 | .end = OMAP343X_CTRL_BASE + OMAP343X_CONTROL_CSIRXFE + 3, | |
207 | .flags = IORESOURCE_MEM, | |
208 | }, | |
209 | { | |
210 | .start = OMAP343X_CTRL_BASE + OMAP3630_CONTROL_CAMERA_PHY_CTRL, | |
211 | .end = OMAP343X_CTRL_BASE + OMAP3630_CONTROL_CAMERA_PHY_CTRL + 3, | |
212 | .flags = IORESOURCE_MEM, | |
213 | }, | |
828c707e | 214 | { |
7d7e1eba | 215 | .start = 24 + OMAP_INTC_START, |
828c707e TL |
216 | .flags = IORESOURCE_IRQ, |
217 | } | |
218 | }; | |
219 | ||
220 | static struct platform_device omap3isp_device = { | |
221 | .name = "omap3isp", | |
222 | .id = -1, | |
223 | .num_resources = ARRAY_SIZE(omap3isp_resources), | |
224 | .resource = omap3isp_resources, | |
225 | }; | |
226 | ||
c8eaab3b | 227 | static struct omap_iommu_arch_data omap3_isp_iommu = { |
72b15b6a | 228 | .name = "mmu_isp", |
c8eaab3b OBC |
229 | }; |
230 | ||
a11f6706 | 231 | int omap3_init_camera(struct isp_platform_data *pdata) |
828c707e | 232 | { |
a11f6706 | 233 | omap3isp_device.dev.platform_data = pdata; |
c8eaab3b OBC |
234 | omap3isp_device.dev.archdata.iommu = &omap3_isp_iommu; |
235 | ||
a11f6706 | 236 | return platform_device_register(&omap3isp_device); |
828c707e | 237 | } |
828c707e | 238 | |
1a51a0ce OBC |
239 | #else /* !CONFIG_IOMMU_API */ |
240 | ||
241 | int omap3_init_camera(struct isp_platform_data *pdata) | |
242 | { | |
243 | return 0; | |
244 | } | |
245 | ||
246 | #endif | |
247 | ||
828c707e TL |
248 | static inline void omap_init_camera(void) |
249 | { | |
cfe2cde6 SA |
250 | #if defined(CONFIG_VIDEO_OMAP2) || defined(CONFIG_VIDEO_OMAP2_MODULE) |
251 | if (cpu_is_omap24xx()) | |
252 | platform_device_register(&omap2cam_device); | |
828c707e | 253 | #endif |
cfe2cde6 | 254 | } |
828c707e | 255 | |
36273356 KVA |
256 | #if IS_ENABLED(CONFIG_OMAP_CONTROL_USB) |
257 | static struct omap_control_usb_platform_data omap4_control_usb_pdata = { | |
258 | .type = 1, | |
259 | }; | |
260 | ||
261 | struct resource omap4_control_usb_res[] = { | |
262 | { | |
263 | .name = "control_dev_conf", | |
264 | .start = 0x4a002300, | |
265 | .end = 0x4a002303, | |
266 | .flags = IORESOURCE_MEM, | |
267 | }, | |
268 | { | |
269 | .name = "otghs_control", | |
270 | .start = 0x4a00233c, | |
271 | .end = 0x4a00233f, | |
272 | .flags = IORESOURCE_MEM, | |
273 | }, | |
274 | }; | |
275 | ||
276 | static struct platform_device omap4_control_usb = { | |
277 | .name = "omap-control-usb", | |
278 | .id = -1, | |
279 | .dev = { | |
280 | .platform_data = &omap4_control_usb_pdata, | |
281 | }, | |
282 | .num_resources = 2, | |
283 | .resource = omap4_control_usb_res, | |
284 | }; | |
285 | ||
286 | static inline void __init omap_init_control_usb(void) | |
287 | { | |
288 | if (!cpu_is_omap44xx()) | |
289 | return; | |
290 | ||
291 | if (platform_device_register(&omap4_control_usb)) | |
292 | pr_err("Error registering omap_control_usb device\n"); | |
293 | } | |
294 | ||
295 | #else | |
296 | static inline void omap_init_control_usb(void) { } | |
297 | #endif /* CONFIG_OMAP_CONTROL_USB */ | |
298 | ||
59556765 | 299 | int __init omap4_keyboard_init(struct omap4_keypad_platform_data |
f67df6c6 | 300 | *sdp4430_keypad_data, struct omap_board_data *bdata) |
59556765 | 301 | { |
3528c58e | 302 | struct platform_device *pdev; |
59556765 SR |
303 | struct omap_hwmod *oh; |
304 | struct omap4_keypad_platform_data *keypad_data; | |
305 | unsigned int id = -1; | |
306 | char *oh_name = "kbd"; | |
307 | char *name = "omap4-keypad"; | |
308 | ||
309 | oh = omap_hwmod_lookup(oh_name); | |
310 | if (!oh) { | |
311 | pr_err("Could not look up %s\n", oh_name); | |
312 | return -ENODEV; | |
313 | } | |
314 | ||
315 | keypad_data = sdp4430_keypad_data; | |
316 | ||
3528c58e | 317 | pdev = omap_device_build(name, id, oh, keypad_data, |
c1d1cd59 | 318 | sizeof(struct omap4_keypad_platform_data)); |
59556765 | 319 | |
3528c58e | 320 | if (IS_ERR(pdev)) { |
25985edc | 321 | WARN(1, "Can't build omap_device for %s:%s.\n", |
59556765 | 322 | name, oh->name); |
3528c58e | 323 | return PTR_ERR(pdev); |
59556765 | 324 | } |
f67df6c6 | 325 | oh->mux = omap_hwmod_mux_init(bdata->pads, bdata->pads_cnt); |
59556765 SR |
326 | |
327 | return 0; | |
328 | } | |
329 | ||
6c20a683 | 330 | #if defined(CONFIG_OMAP_MBOX_FWK) || defined(CONFIG_OMAP_MBOX_FWK_MODULE) |
9cf793f9 | 331 | static inline void __init omap_init_mbox(void) |
c40fae95 | 332 | { |
69dbf857 | 333 | struct omap_hwmod *oh; |
3528c58e | 334 | struct platform_device *pdev; |
69dbf857 FC |
335 | |
336 | oh = omap_hwmod_lookup("mailbox"); | |
337 | if (!oh) { | |
338 | pr_err("%s: unable to find hwmod\n", __func__); | |
6c20a683 HD |
339 | return; |
340 | } | |
69dbf857 | 341 | |
c1d1cd59 | 342 | pdev = omap_device_build("omap-mailbox", -1, oh, NULL, 0); |
3528c58e KH |
343 | WARN(IS_ERR(pdev), "%s: could not build device, err %ld\n", |
344 | __func__, PTR_ERR(pdev)); | |
c40fae95 TL |
345 | } |
346 | #else | |
347 | static inline void omap_init_mbox(void) { } | |
6c20a683 | 348 | #endif /* CONFIG_OMAP_MBOX_FWK */ |
c40fae95 | 349 | |
9b6553cd | 350 | static inline void omap_init_sti(void) {} |
9b6553cd | 351 | |
f0fba2ad LG |
352 | #if defined(CONFIG_SND_SOC) || defined(CONFIG_SND_SOC_MODULE) |
353 | ||
354 | static struct platform_device omap_pcm = { | |
355 | .name = "omap-pcm-audio", | |
356 | .id = -1, | |
357 | }; | |
358 | ||
f0fba2ad LG |
359 | static void omap_init_audio(void) |
360 | { | |
f0fba2ad LG |
361 | platform_device_register(&omap_pcm); |
362 | } | |
363 | ||
364 | #else | |
365 | static inline void omap_init_audio(void) {} | |
366 | #endif | |
367 | ||
d231f5cb PU |
368 | #if defined(CONFIG_SND_OMAP_SOC_MCPDM) || \ |
369 | defined(CONFIG_SND_OMAP_SOC_MCPDM_MODULE) | |
370 | ||
9cf793f9 | 371 | static void __init omap_init_mcpdm(void) |
d231f5cb PU |
372 | { |
373 | struct omap_hwmod *oh; | |
927dbbb2 | 374 | struct platform_device *pdev; |
d231f5cb PU |
375 | |
376 | oh = omap_hwmod_lookup("mcpdm"); | |
5fe0a126 | 377 | if (!oh) |
d231f5cb | 378 | return; |
d231f5cb | 379 | |
c1d1cd59 | 380 | pdev = omap_device_build("omap-mcpdm", -1, oh, NULL, 0); |
927dbbb2 | 381 | WARN(IS_ERR(pdev), "Can't build omap_device for omap-mcpdm.\n"); |
d231f5cb PU |
382 | } |
383 | #else | |
384 | static inline void omap_init_mcpdm(void) {} | |
385 | #endif | |
386 | ||
de9eb097 PU |
387 | #if defined(CONFIG_SND_OMAP_SOC_DMIC) || \ |
388 | defined(CONFIG_SND_OMAP_SOC_DMIC_MODULE) | |
389 | ||
9cf793f9 | 390 | static void __init omap_init_dmic(void) |
de9eb097 PU |
391 | { |
392 | struct omap_hwmod *oh; | |
393 | struct platform_device *pdev; | |
394 | ||
395 | oh = omap_hwmod_lookup("dmic"); | |
6d931cf8 | 396 | if (!oh) |
de9eb097 | 397 | return; |
de9eb097 | 398 | |
c1d1cd59 | 399 | pdev = omap_device_build("omap-dmic", -1, oh, NULL, 0); |
de9eb097 PU |
400 | WARN(IS_ERR(pdev), "Can't build omap_device for omap-dmic.\n"); |
401 | } | |
402 | #else | |
403 | static inline void omap_init_dmic(void) {} | |
404 | #endif | |
405 | ||
5eeec215 RN |
406 | #if defined(CONFIG_SND_OMAP_SOC_OMAP_HDMI) || \ |
407 | defined(CONFIG_SND_OMAP_SOC_OMAP_HDMI_MODULE) | |
408 | ||
409 | static struct platform_device omap_hdmi_audio = { | |
410 | .name = "omap-hdmi-audio", | |
411 | .id = -1, | |
412 | }; | |
413 | ||
414 | static void __init omap_init_hdmi_audio(void) | |
415 | { | |
416 | struct omap_hwmod *oh; | |
417 | struct platform_device *pdev; | |
418 | ||
419 | oh = omap_hwmod_lookup("dss_hdmi"); | |
420 | if (!oh) { | |
421 | printk(KERN_ERR "Could not look up dss_hdmi hw_mod\n"); | |
422 | return; | |
423 | } | |
424 | ||
6efc3fe0 | 425 | pdev = omap_device_build("omap-hdmi-audio-dai", -1, oh, NULL, 0); |
5eeec215 RN |
426 | WARN(IS_ERR(pdev), |
427 | "Can't build omap_device for omap-hdmi-audio-dai.\n"); | |
428 | ||
429 | platform_device_register(&omap_hdmi_audio); | |
430 | } | |
431 | #else | |
432 | static inline void omap_init_hdmi_audio(void) {} | |
433 | #endif | |
434 | ||
646e3ed1 | 435 | #if defined(CONFIG_SPI_OMAP24XX) || defined(CONFIG_SPI_OMAP24XX_MODULE) |
ed7eb9d9 | 436 | |
2203747c | 437 | #include <linux/platform_data/spi-omap2-mcspi.h> |
ed7eb9d9 | 438 | |
9cf793f9 | 439 | static int __init omap_mcspi_init(struct omap_hwmod *oh, void *unused) |
af41a12f | 440 | { |
3528c58e | 441 | struct platform_device *pdev; |
1a5d8190 C |
442 | char *name = "omap2_mcspi"; |
443 | struct omap2_mcspi_platform_config *pdata; | |
444 | static int spi_num; | |
445 | struct omap2_mcspi_dev_attr *mcspi_attrib = oh->dev_attr; | |
446 | ||
447 | pdata = kzalloc(sizeof(*pdata), GFP_KERNEL); | |
448 | if (!pdata) { | |
449 | pr_err("Memory allocation for McSPI device failed\n"); | |
450 | return -ENOMEM; | |
451 | } | |
af41a12f | 452 | |
1a5d8190 C |
453 | pdata->num_cs = mcspi_attrib->num_chipselect; |
454 | switch (oh->class->rev) { | |
455 | case OMAP2_MCSPI_REV: | |
456 | case OMAP3_MCSPI_REV: | |
457 | pdata->regs_offset = 0; | |
458 | break; | |
459 | case OMAP4_MCSPI_REV: | |
460 | pdata->regs_offset = OMAP4_MCSPI_REG_OFFSET; | |
461 | break; | |
462 | default: | |
463 | pr_err("Invalid McSPI Revision value\n"); | |
e0feca89 | 464 | kfree(pdata); |
1a5d8190 C |
465 | return -EINVAL; |
466 | } | |
af41a12f | 467 | |
1a5d8190 | 468 | spi_num++; |
c1d1cd59 | 469 | pdev = omap_device_build(name, spi_num, oh, pdata, sizeof(*pdata)); |
3528c58e | 470 | WARN(IS_ERR(pdev), "Can't build omap_device for %s:%s\n", |
1a5d8190 C |
471 | name, oh->name); |
472 | kfree(pdata); | |
473 | return 0; | |
af41a12f | 474 | } |
af41a12f TL |
475 | |
476 | static void omap_init_mcspi(void) | |
477 | { | |
1a5d8190 | 478 | omap_hwmod_for_each_by_class("mcspi", omap_mcspi_init, NULL); |
ed7eb9d9 JY |
479 | } |
480 | ||
481 | #else | |
482 | static inline void omap_init_mcspi(void) {} | |
483 | #endif | |
484 | ||
4848d460 PW |
485 | /** |
486 | * omap_init_rng - bind the RNG hwmod to the RNG omap_device | |
487 | * | |
488 | * Bind the RNG hwmod to the RNG omap_device. No return value. | |
489 | */ | |
490 | static void omap_init_rng(void) | |
491 | { | |
492 | struct omap_hwmod *oh; | |
493 | struct platform_device *pdev; | |
494 | ||
495 | oh = omap_hwmod_lookup("rng"); | |
496 | if (!oh) | |
497 | return; | |
498 | ||
c1d1cd59 | 499 | pdev = omap_device_build("omap_rng", -1, oh, NULL, 0); |
4848d460 PW |
500 | WARN(IS_ERR(pdev), "Can't build omap_device for omap_rng\n"); |
501 | } | |
88341334 | 502 | |
26f88e6e | 503 | static void __init omap_init_sham(void) |
646e3ed1 | 504 | { |
8c7bb573 MG |
505 | struct omap_hwmod *oh; |
506 | struct platform_device *pdev; | |
507 | ||
508 | oh = omap_hwmod_lookup("sham"); | |
509 | if (!oh) | |
510 | return; | |
511 | ||
512 | pdev = omap_device_build("omap-sham", -1, oh, NULL, 0); | |
513 | WARN(IS_ERR(pdev), "Can't build omap_device for omap-sham\n"); | |
646e3ed1 | 514 | } |
646e3ed1 | 515 | |
14ae5564 | 516 | static void __init omap_init_aes(void) |
b744c679 | 517 | { |
77e2fd84 MG |
518 | struct omap_hwmod *oh; |
519 | struct platform_device *pdev; | |
520 | ||
521 | oh = omap_hwmod_lookup("aes"); | |
522 | if (!oh) | |
523 | return; | |
524 | ||
525 | pdev = omap_device_build("omap-aes", -1, oh, NULL, 0); | |
526 | WARN(IS_ERR(pdev), "Can't build omap_device for omap-aes\n"); | |
b744c679 DK |
527 | } |
528 | ||
d8874665 TL |
529 | /*-------------------------------------------------------------------------*/ |
530 | ||
b227358d VH |
531 | #if defined(CONFIG_VIDEO_OMAP2_VOUT) || \ |
532 | defined(CONFIG_VIDEO_OMAP2_VOUT_MODULE) | |
533 | #if defined(CONFIG_FB_OMAP2) || defined(CONFIG_FB_OMAP2_MODULE) | |
534 | static struct resource omap_vout_resource[3 - CONFIG_FB_OMAP2_NUM_FBS] = { | |
535 | }; | |
536 | #else | |
537 | static struct resource omap_vout_resource[2] = { | |
538 | }; | |
539 | #endif | |
540 | ||
541 | static struct platform_device omap_vout_device = { | |
542 | .name = "omap_vout", | |
543 | .num_resources = ARRAY_SIZE(omap_vout_resource), | |
544 | .resource = &omap_vout_resource[0], | |
545 | .id = -1, | |
546 | }; | |
547 | static void omap_init_vout(void) | |
548 | { | |
549 | if (platform_device_register(&omap_vout_device) < 0) | |
550 | printk(KERN_ERR "Unable to register OMAP-VOUT device\n"); | |
551 | } | |
552 | #else | |
553 | static inline void omap_init_vout(void) {} | |
554 | #endif | |
555 | ||
459bc971 KVA |
556 | #if defined(CONFIG_OMAP_OCP2SCP) || defined(CONFIG_OMAP_OCP2SCP_MODULE) |
557 | static int count_ocp2scp_devices(struct omap_ocp2scp_dev *ocp2scp_dev) | |
558 | { | |
559 | int cnt = 0; | |
560 | ||
561 | while (ocp2scp_dev->drv_name != NULL) { | |
562 | cnt++; | |
563 | ocp2scp_dev++; | |
564 | } | |
565 | ||
566 | return cnt; | |
567 | } | |
568 | ||
e407ee09 | 569 | static void __init omap_init_ocp2scp(void) |
459bc971 KVA |
570 | { |
571 | struct omap_hwmod *oh; | |
572 | struct platform_device *pdev; | |
573 | int bus_id = -1, dev_cnt = 0, i; | |
574 | struct omap_ocp2scp_dev *ocp2scp_dev; | |
575 | const char *oh_name, *name; | |
576 | struct omap_ocp2scp_platform_data *pdata; | |
577 | ||
578 | if (!cpu_is_omap44xx()) | |
579 | return; | |
580 | ||
581 | oh_name = "ocp2scp_usb_phy"; | |
582 | name = "omap-ocp2scp"; | |
583 | ||
584 | oh = omap_hwmod_lookup(oh_name); | |
585 | if (!oh) { | |
586 | pr_err("%s: could not find omap_hwmod for %s\n", __func__, | |
587 | oh_name); | |
588 | return; | |
589 | } | |
590 | ||
591 | pdata = kzalloc(sizeof(*pdata), GFP_KERNEL); | |
592 | if (!pdata) { | |
593 | pr_err("%s: No memory for ocp2scp pdata\n", __func__); | |
594 | return; | |
595 | } | |
596 | ||
597 | ocp2scp_dev = oh->dev_attr; | |
598 | dev_cnt = count_ocp2scp_devices(ocp2scp_dev); | |
599 | ||
600 | if (!dev_cnt) { | |
601 | pr_err("%s: No devices connected to ocp2scp\n", __func__); | |
602 | kfree(pdata); | |
603 | return; | |
604 | } | |
605 | ||
606 | pdata->devices = kzalloc(sizeof(struct omap_ocp2scp_dev *) | |
607 | * dev_cnt, GFP_KERNEL); | |
608 | if (!pdata->devices) { | |
609 | pr_err("%s: No memory for ocp2scp pdata devices\n", __func__); | |
610 | kfree(pdata); | |
611 | return; | |
612 | } | |
613 | ||
614 | for (i = 0; i < dev_cnt; i++, ocp2scp_dev++) | |
615 | pdata->devices[i] = ocp2scp_dev; | |
616 | ||
617 | pdata->dev_cnt = dev_cnt; | |
618 | ||
c1d1cd59 | 619 | pdev = omap_device_build(name, bus_id, oh, pdata, sizeof(*pdata)); |
459bc971 KVA |
620 | if (IS_ERR(pdev)) { |
621 | pr_err("Could not build omap_device for %s %s\n", | |
622 | name, oh_name); | |
623 | kfree(pdata->devices); | |
624 | kfree(pdata); | |
625 | return; | |
626 | } | |
627 | } | |
628 | #else | |
629 | static inline void omap_init_ocp2scp(void) { } | |
630 | #endif | |
631 | ||
1dbae815 TL |
632 | /*-------------------------------------------------------------------------*/ |
633 | ||
634 | static int __init omap2_init_devices(void) | |
635 | { | |
484202f4 MP |
636 | /* Enable dummy states for those platforms without pinctrl support */ |
637 | if (!of_have_populated_dt()) | |
638 | pinctrl_provide_dummies(); | |
639 | ||
81fbc5ef PW |
640 | /* |
641 | * please keep these calls, and their implementations above, | |
1dbae815 TL |
642 | * in alphabetical order so they're easier to sort through. |
643 | */ | |
f0fba2ad | 644 | omap_init_audio(); |
828c707e | 645 | omap_init_camera(); |
5eeec215 | 646 | omap_init_hdmi_audio(); |
c40fae95 | 647 | omap_init_mbox(); |
efcf1e50 | 648 | /* If dtb is there, the devices will be created dynamically */ |
259bd6ce | 649 | if (!of_have_populated_dt()) { |
36273356 | 650 | omap_init_control_usb(); |
259bd6ce | 651 | omap_init_dmic(); |
4b21ffcf | 652 | omap_init_mcpdm(); |
efcf1e50 | 653 | omap_init_mcspi(); |
114d7a8b | 654 | omap_init_sham(); |
53335acc | 655 | omap_init_aes(); |
259bd6ce | 656 | } |
9b6553cd | 657 | omap_init_sti(); |
4848d460 | 658 | omap_init_rng(); |
b227358d | 659 | omap_init_vout(); |
459bc971 | 660 | omap_init_ocp2scp(); |
1dbae815 TL |
661 | |
662 | return 0; | |
663 | } | |
b76c8b19 | 664 | omap_arch_initcall(omap2_init_devices); |