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 cf365c387c06..d2215e9873a5 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> |
@@ -615,6 +616,83 @@ static void omap_init_vout(void) | |||
615 | static inline void omap_init_vout(void) {} | 616 | static inline void omap_init_vout(void) {} |
616 | #endif | 617 | #endif |
617 | 618 | ||
619 | #if defined(CONFIG_OMAP_OCP2SCP) || defined(CONFIG_OMAP_OCP2SCP_MODULE) | ||
620 | static int count_ocp2scp_devices(struct omap_ocp2scp_dev *ocp2scp_dev) | ||
621 | { | ||
622 | int cnt = 0; | ||
623 | |||
624 | while (ocp2scp_dev->drv_name != NULL) { | ||
625 | cnt++; | ||
626 | ocp2scp_dev++; | ||
627 | } | ||
628 | |||
629 | return cnt; | ||
630 | } | ||
631 | |||
632 | static void omap_init_ocp2scp(void) | ||
633 | { | ||
634 | struct omap_hwmod *oh; | ||
635 | struct platform_device *pdev; | ||
636 | int bus_id = -1, dev_cnt = 0, i; | ||
637 | struct omap_ocp2scp_dev *ocp2scp_dev; | ||
638 | const char *oh_name, *name; | ||
639 | struct omap_ocp2scp_platform_data *pdata; | ||
640 | |||
641 | if (!cpu_is_omap44xx()) | ||
642 | return; | ||
643 | |||
644 | oh_name = "ocp2scp_usb_phy"; | ||
645 | name = "omap-ocp2scp"; | ||
646 | |||
647 | oh = omap_hwmod_lookup(oh_name); | ||
648 | if (!oh) { | ||
649 | pr_err("%s: could not find omap_hwmod for %s\n", __func__, | ||
650 | oh_name); | ||
651 | return; | ||
652 | } | ||
653 | |||
654 | pdata = kzalloc(sizeof(*pdata), GFP_KERNEL); | ||
655 | if (!pdata) { | ||
656 | pr_err("%s: No memory for ocp2scp pdata\n", __func__); | ||
657 | return; | ||
658 | } | ||
659 | |||
660 | ocp2scp_dev = oh->dev_attr; | ||
661 | dev_cnt = count_ocp2scp_devices(ocp2scp_dev); | ||
662 | |||
663 | if (!dev_cnt) { | ||
664 | pr_err("%s: No devices connected to ocp2scp\n", __func__); | ||
665 | kfree(pdata); | ||
666 | return; | ||
667 | } | ||
668 | |||
669 | pdata->devices = kzalloc(sizeof(struct omap_ocp2scp_dev *) | ||
670 | * dev_cnt, GFP_KERNEL); | ||
671 | if (!pdata->devices) { | ||
672 | pr_err("%s: No memory for ocp2scp pdata devices\n", __func__); | ||
673 | kfree(pdata); | ||
674 | return; | ||
675 | } | ||
676 | |||
677 | for (i = 0; i < dev_cnt; i++, ocp2scp_dev++) | ||
678 | pdata->devices[i] = ocp2scp_dev; | ||
679 | |||
680 | pdata->dev_cnt = dev_cnt; | ||
681 | |||
682 | pdev = omap_device_build(name, bus_id, oh, pdata, sizeof(*pdata), NULL, | ||
683 | 0, false); | ||
684 | if (IS_ERR(pdev)) { | ||
685 | pr_err("Could not build omap_device for %s %s\n", | ||
686 | name, oh_name); | ||
687 | kfree(pdata->devices); | ||
688 | kfree(pdata); | ||
689 | return; | ||
690 | } | ||
691 | } | ||
692 | #else | ||
693 | static inline void omap_init_ocp2scp(void) { } | ||
694 | #endif | ||
695 | |||
618 | /*-------------------------------------------------------------------------*/ | 696 | /*-------------------------------------------------------------------------*/ |
619 | 697 | ||
620 | static int __init omap2_init_devices(void) | 698 | static int __init omap2_init_devices(void) |
@@ -642,6 +720,7 @@ static int __init omap2_init_devices(void) | |||
642 | omap_init_sham(); | 720 | omap_init_sham(); |
643 | omap_init_aes(); | 721 | omap_init_aes(); |
644 | omap_init_vout(); | 722 | omap_init_vout(); |
723 | omap_init_ocp2scp(); | ||
645 | 724 | ||
646 | return 0; | 725 | return 0; |
647 | } | 726 | } |