aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-omap2/devices.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-omap2/devices.c')
-rw-r--r--arch/arm/mach-omap2/devices.c158
1 files changed, 37 insertions, 121 deletions
diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c
index 4269fc145698..aef96e45cb20 100644
--- a/arch/arm/mach-omap2/devices.c
+++ b/arch/arm/mach-omap2/devices.c
@@ -15,12 +15,13 @@
15#include <linux/io.h> 15#include <linux/io.h>
16#include <linux/clk.h> 16#include <linux/clk.h>
17#include <linux/err.h> 17#include <linux/err.h>
18#include <linux/gpio.h>
18#include <linux/slab.h> 19#include <linux/slab.h>
19#include <linux/of.h> 20#include <linux/of.h>
20#include <linux/pinctrl/machine.h> 21#include <linux/pinctrl/machine.h>
21#include <linux/platform_data/omap4-keypad.h> 22#include <linux/platform_data/omap4-keypad.h>
22#include <linux/platform_data/omap_ocp2scp.h> 23#include <linux/wl12xx.h>
23#include <linux/usb/omap_control_usb.h> 24#include <linux/platform_data/mailbox-omap.h>
24 25
25#include <asm/mach-types.h> 26#include <asm/mach-types.h>
26#include <asm/mach/map.h> 27#include <asm/mach/map.h>
@@ -37,7 +38,6 @@
37#include "mux.h" 38#include "mux.h"
38#include "control.h" 39#include "control.h"
39#include "devices.h" 40#include "devices.h"
40#include "dma.h"
41 41
42#define L3_MODULES_MAX_LEN 12 42#define L3_MODULES_MAX_LEN 12
43#define L3_MODULES 3 43#define L3_MODULES 3
@@ -253,49 +253,6 @@ static inline void omap_init_camera(void)
253#endif 253#endif
254} 254}
255 255
256#if IS_ENABLED(CONFIG_OMAP_CONTROL_USB)
257static struct omap_control_usb_platform_data omap4_control_usb_pdata = {
258 .type = 1,
259};
260
261struct 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
276static 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
286static 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
296static inline void omap_init_control_usb(void) { }
297#endif /* CONFIG_OMAP_CONTROL_USB */
298
299int __init omap4_keyboard_init(struct omap4_keypad_platform_data 256int __init omap4_keyboard_init(struct omap4_keypad_platform_data
300 *sdp4430_keypad_data, struct omap_board_data *bdata) 257 *sdp4430_keypad_data, struct omap_board_data *bdata)
301{ 258{
@@ -327,25 +284,31 @@ int __init omap4_keyboard_init(struct omap4_keypad_platform_data
327 return 0; 284 return 0;
328} 285}
329 286
330#if defined(CONFIG_OMAP_MBOX_FWK) || defined(CONFIG_OMAP_MBOX_FWK_MODULE) 287#if defined(CONFIG_OMAP2PLUS_MBOX) || defined(CONFIG_OMAP2PLUS_MBOX_MODULE)
331static inline void __init omap_init_mbox(void) 288static inline void __init omap_init_mbox(void)
332{ 289{
333 struct omap_hwmod *oh; 290 struct omap_hwmod *oh;
334 struct platform_device *pdev; 291 struct platform_device *pdev;
292 struct omap_mbox_pdata *pdata;
335 293
336 oh = omap_hwmod_lookup("mailbox"); 294 oh = omap_hwmod_lookup("mailbox");
337 if (!oh) { 295 if (!oh) {
338 pr_err("%s: unable to find hwmod\n", __func__); 296 pr_err("%s: unable to find hwmod\n", __func__);
339 return; 297 return;
340 } 298 }
299 if (!oh->dev_attr) {
300 pr_err("%s: hwmod doesn't have valid attrs\n", __func__);
301 return;
302 }
341 303
342 pdev = omap_device_build("omap-mailbox", -1, oh, NULL, 0); 304 pdata = (struct omap_mbox_pdata *)oh->dev_attr;
305 pdev = omap_device_build("omap-mailbox", -1, oh, pdata, sizeof(*pdata));
343 WARN(IS_ERR(pdev), "%s: could not build device, err %ld\n", 306 WARN(IS_ERR(pdev), "%s: could not build device, err %ld\n",
344 __func__, PTR_ERR(pdev)); 307 __func__, PTR_ERR(pdev));
345} 308}
346#else 309#else
347static inline void omap_init_mbox(void) { } 310static inline void omap_init_mbox(void) { }
348#endif /* CONFIG_OMAP_MBOX_FWK */ 311#endif /* CONFIG_OMAP2PLUS_MBOX */
349 312
350static inline void omap_init_sti(void) {} 313static inline void omap_init_sti(void) {}
351 314
@@ -374,10 +337,8 @@ static void __init omap_init_mcpdm(void)
374 struct platform_device *pdev; 337 struct platform_device *pdev;
375 338
376 oh = omap_hwmod_lookup("mcpdm"); 339 oh = omap_hwmod_lookup("mcpdm");
377 if (!oh) { 340 if (!oh)
378 printk(KERN_ERR "Could not look up mcpdm hw_mod\n");
379 return; 341 return;
380 }
381 342
382 pdev = omap_device_build("omap-mcpdm", -1, oh, NULL, 0); 343 pdev = omap_device_build("omap-mcpdm", -1, oh, NULL, 0);
383 WARN(IS_ERR(pdev), "Can't build omap_device for omap-mcpdm.\n"); 344 WARN(IS_ERR(pdev), "Can't build omap_device for omap-mcpdm.\n");
@@ -395,10 +356,8 @@ static void __init omap_init_dmic(void)
395 struct platform_device *pdev; 356 struct platform_device *pdev;
396 357
397 oh = omap_hwmod_lookup("dmic"); 358 oh = omap_hwmod_lookup("dmic");
398 if (!oh) { 359 if (!oh)
399 pr_err("Could not look up dmic hw_mod\n");
400 return; 360 return;
401 }
402 361
403 pdev = omap_device_build("omap-dmic", -1, oh, NULL, 0); 362 pdev = omap_device_build("omap-dmic", -1, oh, NULL, 0);
404 WARN(IS_ERR(pdev), "Can't build omap_device for omap-dmic.\n"); 363 WARN(IS_ERR(pdev), "Can't build omap_device for omap-dmic.\n");
@@ -421,10 +380,8 @@ static void __init omap_init_hdmi_audio(void)
421 struct platform_device *pdev; 380 struct platform_device *pdev;
422 381
423 oh = omap_hwmod_lookup("dss_hdmi"); 382 oh = omap_hwmod_lookup("dss_hdmi");
424 if (!oh) { 383 if (!oh)
425 printk(KERN_ERR "Could not look up dss_hdmi hw_mod\n");
426 return; 384 return;
427 }
428 385
429 pdev = omap_device_build("omap-hdmi-audio-dai", -1, oh, NULL, 0); 386 pdev = omap_device_build("omap-hdmi-audio-dai", -1, oh, NULL, 0);
430 WARN(IS_ERR(pdev), 387 WARN(IS_ERR(pdev),
@@ -557,80 +514,38 @@ static void omap_init_vout(void)
557static inline void omap_init_vout(void) {} 514static inline void omap_init_vout(void) {}
558#endif 515#endif
559 516
560#if defined(CONFIG_OMAP_OCP2SCP) || defined(CONFIG_OMAP_OCP2SCP_MODULE) 517#if IS_ENABLED(CONFIG_WL12XX)
561static int count_ocp2scp_devices(struct omap_ocp2scp_dev *ocp2scp_dev)
562{
563 int cnt = 0;
564 518
565 while (ocp2scp_dev->drv_name != NULL) { 519static struct wl12xx_platform_data wl12xx __initdata;
566 cnt++;
567 ocp2scp_dev++;
568 }
569
570 return cnt;
571}
572 520
573static void __init omap_init_ocp2scp(void) 521void __init omap_init_wl12xx_of(void)
574{ 522{
575 struct omap_hwmod *oh; 523 int ret;
576 struct platform_device *pdev;
577 int bus_id = -1, dev_cnt = 0, i;
578 struct omap_ocp2scp_dev *ocp2scp_dev;
579 const char *oh_name, *name;
580 struct omap_ocp2scp_platform_data *pdata;
581
582 if (!cpu_is_omap44xx())
583 return;
584
585 oh_name = "ocp2scp_usb_phy";
586 name = "omap-ocp2scp";
587
588 oh = omap_hwmod_lookup(oh_name);
589 if (!oh) {
590 pr_err("%s: could not find omap_hwmod for %s\n", __func__,
591 oh_name);
592 return;
593 }
594 524
595 pdata = kzalloc(sizeof(*pdata), GFP_KERNEL); 525 if (!of_have_populated_dt())
596 if (!pdata) {
597 pr_err("%s: No memory for ocp2scp pdata\n", __func__);
598 return; 526 return;
599 }
600 527
601 ocp2scp_dev = oh->dev_attr; 528 if (of_machine_is_compatible("ti,omap4-sdp")) {
602 dev_cnt = count_ocp2scp_devices(ocp2scp_dev); 529 wl12xx.board_ref_clock = WL12XX_REFCLOCK_26;
603 530 wl12xx.board_tcxo_clock = WL12XX_TCXOCLOCK_26;
604 if (!dev_cnt) { 531 wl12xx.irq = gpio_to_irq(53);
605 pr_err("%s: No devices connected to ocp2scp\n", __func__); 532 } else if (of_machine_is_compatible("ti,omap4-panda")) {
606 kfree(pdata); 533 wl12xx.board_ref_clock = WL12XX_REFCLOCK_38;
534 wl12xx.irq = gpio_to_irq(53);
535 } else {
607 return; 536 return;
608 } 537 }
609 538
610 pdata->devices = kzalloc(sizeof(struct omap_ocp2scp_dev *) 539 ret = wl12xx_set_platform_data(&wl12xx);
611 * dev_cnt, GFP_KERNEL); 540 if (ret) {
612 if (!pdata->devices) { 541 pr_err("error setting wl12xx data: %d\n", ret);
613 pr_err("%s: No memory for ocp2scp pdata devices\n", __func__);
614 kfree(pdata);
615 return;
616 }
617
618 for (i = 0; i < dev_cnt; i++, ocp2scp_dev++)
619 pdata->devices[i] = ocp2scp_dev;
620
621 pdata->dev_cnt = dev_cnt;
622
623 pdev = omap_device_build(name, bus_id, oh, pdata, sizeof(*pdata));
624 if (IS_ERR(pdev)) {
625 pr_err("Could not build omap_device for %s %s\n",
626 name, oh_name);
627 kfree(pdata->devices);
628 kfree(pdata);
629 return; 542 return;
630 } 543 }
631} 544}
632#else 545#else
633static inline void omap_init_ocp2scp(void) { } 546static inline void omap_init_wl12xx_of(void)
547{
548}
634#endif 549#endif
635 550
636/*-------------------------------------------------------------------------*/ 551/*-------------------------------------------------------------------------*/
@@ -651,17 +566,18 @@ static int __init omap2_init_devices(void)
651 omap_init_mbox(); 566 omap_init_mbox();
652 /* If dtb is there, the devices will be created dynamically */ 567 /* If dtb is there, the devices will be created dynamically */
653 if (!of_have_populated_dt()) { 568 if (!of_have_populated_dt()) {
654 omap_init_control_usb();
655 omap_init_dmic(); 569 omap_init_dmic();
656 omap_init_mcpdm(); 570 omap_init_mcpdm();
657 omap_init_mcspi(); 571 omap_init_mcspi();
658 omap_init_sham(); 572 omap_init_sham();
659 omap_init_aes(); 573 omap_init_aes();
574 } else {
575 /* These can be removed when bindings are done */
576 omap_init_wl12xx_of();
660 } 577 }
661 omap_init_sti(); 578 omap_init_sti();
662 omap_init_rng(); 579 omap_init_rng();
663 omap_init_vout(); 580 omap_init_vout();
664 omap_init_ocp2scp();
665 581
666 return 0; 582 return 0;
667} 583}