aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2012-11-12 11:19:29 -0500
committerArnd Bergmann <arnd@arndb.de>2012-11-12 11:19:29 -0500
commit69178dfeb13da9aa506f69db910ada86b228d0fd (patch)
treec5ff32f84bf49f012b46cc2607f2169fdc8bac41 /drivers
parent36e42a323cf0de26bd819448b024d3851fc0d865 (diff)
parent459bc971eba0fe84b3fe857cf0a71c5fd102f06b (diff)
Merge tag 'omap-for-v3.7-rc4/musb-regression-signed' of git://git.kernel.org/pub/scm/linux/kernel/git/tmlind/linux-omap into fixes
From Tony Lindgren <tony@atomide.com>: This series fixes an annoying regression to make MUSB working on omap4 again. Although it's getting rather late for these changes for the -rc cycle, it is important as many devices are using MUSB for charging and connectivity. With the USB PHY changes, MUSB started using the newly added drivers/usb/phy/omap-usb2.c driver introduced by commit 657b306a (usb: phy: add a new driver for omap usb2 phy) that is using the newly introduced drivers/bus/omap-ocp2scp.c introduced by commit 26a84b3e (drivers: bus: add a new driver for omap-ocp2scp). These changes allowed dropping a lot of PHY related code from arch/arm/mach-omap2/omap_phy_internal.c and have it live in the device driver like it should with commit c9e4412a (arm: omap: phy: remove unused functions from omap-phy-internal.c). However, MUSB on omap4 broke with these changes for legacy platform data boot, and now only works with device tree for omap4. Unfortunately we are still few critical bindings away from being able to make omap4 usbale with device tree. Fix the regression properly by adding platform data support to the ocp2scp driver so we can avoid adding back the driver code to arch/arm/mach-omap2. * tag 'omap-for-v3.7-rc4/musb-regression-signed' of git://git.kernel.org/pub/scm/linux/kernel/git/tmlind/linux-omap: ARM: OMAP: ocp2scp: create omap device for ocp2scp ARM: OMAP4: add _dev_attr_ to ocp2scp for representing usb_phy drivers: bus: ocp2scp: add pdata support Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/bus/omap-ocp2scp.c68
1 files changed, 65 insertions, 3 deletions
diff --git a/drivers/bus/omap-ocp2scp.c b/drivers/bus/omap-ocp2scp.c
index ff63560b8467..0c48b0e05ed6 100644
--- a/drivers/bus/omap-ocp2scp.c
+++ b/drivers/bus/omap-ocp2scp.c
@@ -22,6 +22,26 @@
22#include <linux/pm_runtime.h> 22#include <linux/pm_runtime.h>
23#include <linux/of.h> 23#include <linux/of.h>
24#include <linux/of_platform.h> 24#include <linux/of_platform.h>
25#include <linux/platform_data/omap_ocp2scp.h>
26
27/**
28 * _count_resources - count for the number of resources
29 * @res: struct resource *
30 *
31 * Count and return the number of resources populated for the device that is
32 * connected to ocp2scp.
33 */
34static unsigned _count_resources(struct resource *res)
35{
36 int cnt = 0;
37
38 while (res->start != res->end) {
39 cnt++;
40 res++;
41 }
42
43 return cnt;
44}
25 45
26static int ocp2scp_remove_devices(struct device *dev, void *c) 46static int ocp2scp_remove_devices(struct device *dev, void *c)
27{ 47{
@@ -34,20 +54,62 @@ static int ocp2scp_remove_devices(struct device *dev, void *c)
34 54
35static int __devinit omap_ocp2scp_probe(struct platform_device *pdev) 55static int __devinit omap_ocp2scp_probe(struct platform_device *pdev)
36{ 56{
37 int ret; 57 int ret;
38 struct device_node *np = pdev->dev.of_node; 58 unsigned res_cnt, i;
59 struct device_node *np = pdev->dev.of_node;
60 struct platform_device *pdev_child;
61 struct omap_ocp2scp_platform_data *pdata = pdev->dev.platform_data;
62 struct omap_ocp2scp_dev *dev;
39 63
40 if (np) { 64 if (np) {
41 ret = of_platform_populate(np, NULL, NULL, &pdev->dev); 65 ret = of_platform_populate(np, NULL, NULL, &pdev->dev);
42 if (ret) { 66 if (ret) {
43 dev_err(&pdev->dev, "failed to add resources for ocp2scp child\n"); 67 dev_err(&pdev->dev,
68 "failed to add resources for ocp2scp child\n");
44 goto err0; 69 goto err0;
45 } 70 }
71 } else if (pdata) {
72 for (i = 0, dev = *pdata->devices; i < pdata->dev_cnt; i++,
73 dev++) {
74 res_cnt = _count_resources(dev->res);
75
76 pdev_child = platform_device_alloc(dev->drv_name,
77 PLATFORM_DEVID_AUTO);
78 if (!pdev_child) {
79 dev_err(&pdev->dev,
80 "failed to allocate mem for ocp2scp child\n");
81 goto err0;
82 }
83
84 ret = platform_device_add_resources(pdev_child,
85 dev->res, res_cnt);
86 if (ret) {
87 dev_err(&pdev->dev,
88 "failed to add resources for ocp2scp child\n");
89 goto err1;
90 }
91
92 pdev_child->dev.parent = &pdev->dev;
93
94 ret = platform_device_add(pdev_child);
95 if (ret) {
96 dev_err(&pdev->dev,
97 "failed to register ocp2scp child device\n");
98 goto err1;
99 }
100 }
101 } else {
102 dev_err(&pdev->dev, "OCP2SCP initialized without plat data\n");
103 return -EINVAL;
46 } 104 }
105
47 pm_runtime_enable(&pdev->dev); 106 pm_runtime_enable(&pdev->dev);
48 107
49 return 0; 108 return 0;
50 109
110err1:
111 platform_device_put(pdev_child);
112
51err0: 113err0:
52 device_for_each_child(&pdev->dev, NULL, ocp2scp_remove_devices); 114 device_for_each_child(&pdev->dev, NULL, ocp2scp_remove_devices);
53 115