diff options
Diffstat (limited to 'arch/arm/mach-omap2/devices.c')
-rw-r--r-- | arch/arm/mach-omap2/devices.c | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c index cba60e05e32e..c72b5a727720 100644 --- a/arch/arm/mach-omap2/devices.c +++ b/arch/arm/mach-omap2/devices.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <linux/of.h> | 19 | #include <linux/of.h> |
20 | #include <linux/pinctrl/machine.h> | 20 | #include <linux/pinctrl/machine.h> |
21 | #include <linux/platform_data/omap4-keypad.h> | 21 | #include <linux/platform_data/omap4-keypad.h> |
22 | #include <linux/platform_data/omap_ocp2scp.h> | ||
22 | 23 | ||
23 | #include <asm/mach-types.h> | 24 | #include <asm/mach-types.h> |
24 | #include <asm/mach/map.h> | 25 | #include <asm/mach/map.h> |
@@ -613,6 +614,83 @@ static void omap_init_vout(void) | |||
613 | static inline void omap_init_vout(void) {} | 614 | static inline void omap_init_vout(void) {} |
614 | #endif | 615 | #endif |
615 | 616 | ||
617 | #if defined(CONFIG_OMAP_OCP2SCP) || defined(CONFIG_OMAP_OCP2SCP_MODULE) | ||
618 | static int count_ocp2scp_devices(struct omap_ocp2scp_dev *ocp2scp_dev) | ||
619 | { | ||
620 | int cnt = 0; | ||
621 | |||
622 | while (ocp2scp_dev->drv_name != NULL) { | ||
623 | cnt++; | ||
624 | ocp2scp_dev++; | ||
625 | } | ||
626 | |||
627 | return cnt; | ||
628 | } | ||
629 | |||
630 | static void omap_init_ocp2scp(void) | ||
631 | { | ||
632 | struct omap_hwmod *oh; | ||
633 | struct platform_device *pdev; | ||
634 | int bus_id = -1, dev_cnt = 0, i; | ||
635 | struct omap_ocp2scp_dev *ocp2scp_dev; | ||
636 | const char *oh_name, *name; | ||
637 | struct omap_ocp2scp_platform_data *pdata; | ||
638 | |||
639 | if (!cpu_is_omap44xx()) | ||
640 | return; | ||
641 | |||
642 | oh_name = "ocp2scp_usb_phy"; | ||
643 | name = "omap-ocp2scp"; | ||
644 | |||
645 | oh = omap_hwmod_lookup(oh_name); | ||
646 | if (!oh) { | ||
647 | pr_err("%s: could not find omap_hwmod for %s\n", __func__, | ||
648 | oh_name); | ||
649 | return; | ||
650 | } | ||
651 | |||
652 | pdata = kzalloc(sizeof(*pdata), GFP_KERNEL); | ||
653 | if (!pdata) { | ||
654 | pr_err("%s: No memory for ocp2scp pdata\n", __func__); | ||
655 | return; | ||
656 | } | ||
657 | |||
658 | ocp2scp_dev = oh->dev_attr; | ||
659 | dev_cnt = count_ocp2scp_devices(ocp2scp_dev); | ||
660 | |||
661 | if (!dev_cnt) { | ||
662 | pr_err("%s: No devices connected to ocp2scp\n", __func__); | ||
663 | kfree(pdata); | ||
664 | return; | ||
665 | } | ||
666 | |||
667 | pdata->devices = kzalloc(sizeof(struct omap_ocp2scp_dev *) | ||
668 | * dev_cnt, GFP_KERNEL); | ||
669 | if (!pdata->devices) { | ||
670 | pr_err("%s: No memory for ocp2scp pdata devices\n", __func__); | ||
671 | kfree(pdata); | ||
672 | return; | ||
673 | } | ||
674 | |||
675 | for (i = 0; i < dev_cnt; i++, ocp2scp_dev++) | ||
676 | pdata->devices[i] = ocp2scp_dev; | ||
677 | |||
678 | pdata->dev_cnt = dev_cnt; | ||
679 | |||
680 | pdev = omap_device_build(name, bus_id, oh, pdata, sizeof(*pdata), NULL, | ||
681 | 0, false); | ||
682 | if (IS_ERR(pdev)) { | ||
683 | pr_err("Could not build omap_device for %s %s\n", | ||
684 | name, oh_name); | ||
685 | kfree(pdata->devices); | ||
686 | kfree(pdata); | ||
687 | return; | ||
688 | } | ||
689 | } | ||
690 | #else | ||
691 | static inline void omap_init_ocp2scp(void) { } | ||
692 | #endif | ||
693 | |||
616 | /*-------------------------------------------------------------------------*/ | 694 | /*-------------------------------------------------------------------------*/ |
617 | 695 | ||
618 | static int __init omap2_init_devices(void) | 696 | static int __init omap2_init_devices(void) |
@@ -640,6 +718,7 @@ static int __init omap2_init_devices(void) | |||
640 | omap_init_sham(); | 718 | omap_init_sham(); |
641 | omap_init_aes(); | 719 | omap_init_aes(); |
642 | omap_init_vout(); | 720 | omap_init_vout(); |
721 | omap_init_ocp2scp(); | ||
643 | 722 | ||
644 | return 0; | 723 | return 0; |
645 | } | 724 | } |