ocp2scp: add non-dt support
Subsystems (4)
cover ocp2scp: add non-dt support
This patch series allows ocp2scp driver to create its child devices from the platform data.
In omap platforms, usb phy is connected to ocp2scp and usb phy is needed for MUSB to be functional. When ocp2scp driver was added, it had only dt support which means it wont create usb phy devices for non-dt boot.
This patch series adds non-dt support to ocp2scp and this series is needed for getting MUSB functioanl in non-dt boot.
This patch series is rebased on linux-next. Let me know if it had to be based on some other tree.
Did a quick testing for g_zero enumeration in panda board.
Kishon Vijay Abraham I (3):
drivers: bus: ocp2scp: add pdata support
ARM: OMAP4: add _dev_attr_ to ocp2scp for representing usb_phy
ARM: OMAP: ocp2scp: create omap device for ocp2scp
arch/arm/mach-omap2/devices.c | 72 ++++++++++++++++++++++++++++ arch/arm/mach-omap2/omap_hwmod_44xx_data.c | 28 +++++++++++ drivers/bus/omap-ocp2scp.c | 67 ++++++++++++++++++++++++-- include/linux/platform_data/omap_ocp2scp.h | 31 ++++++++++++ 4 files changed, 195 insertions(+), 3 deletions(-) create mode 100644 include/linux/platform_data/omap_ocp2scp.h
Signature · 1 line
1.7.9.5
PATCH 1/3 drivers: bus: ocp2scp: add pdata support
ocp2scp was not having pdata support which makes *musb* fail for non-dt boot in OMAP platform. The pdata will have information about the devices that is connected to ocp2scp. ocp2scp driver will now make use of this information to create the devices that is attached to ocp2scp.
--- drivers/bus/omap-ocp2scp.c | 67 ++++++++++++++++++++++++++-- include/linux/platform_data/omap_ocp2scp.h | 31 +++++++++++++ 2 files changed, 95 insertions(+), 3 deletions(-) create mode 100644 include/linux/platform_data/omap_ocp2scp.h
drivers/bus/omap-ocp2scp.c +64 -3
@@ -22,6 +22,26 @@#include <linux/pm_runtime.h> #include <linux/of.h> #include <linux/of_platform.h> +#include <linux/platform_data/omap_ocp2scp.h> + +/** +* _count_resources - count for the number of resources +* @res: struct resource * +* +* Count and return the number of resources populated for the device that is +* connected to ocp2scp. +*/ +static unsigned _count_resources (struct resource *res) +{ +int cnt =0 ; + +while (res->start != res->end) { + cnt++; + res++; + } + +return cnt; +}static int ocp2scp_remove_devices (struct device *dev,void *c) {
@@ -34,20 +54,61 @@ static int ocp2scp_remove_devices(struct device *dev, void *c)static int __devinit omap_ocp2scp_probe (struct platform_device *pdev) { -int ret; -struct device_node *np = pdev->dev.of_node; +int ret; +unsigned res_cnt, i; +struct device_node *np = pdev->dev.of_node; +struct platform_device *pdev_child; +struct omap_ocp2scp_platform_data *pdata = pdev->dev.platform_data; +struct omap_ocp2scp_dev *dev;if (np) { ret =of_platform_populate (np,NULL ,NULL , &pdev->dev);if (ret) { -dev_err (&pdev->dev,"failed to add resources for ocp2scp child\n" ); +dev_err (&pdev->dev, +"failed to add resources for ocp2scp child\n" ); goto err0; } + }else if (pdata) { +for (i =0 , dev = *pdata->devices; i < pdata->dev_cnt; i++, + dev++) { + res_cnt =_count_resources (dev->res); + + pdev_child =platform_device_alloc (dev->drv_name,-1 ); +if (!pdev_child) { +dev_err (&pdev->dev, +"failed to allocate mem for ocp2scp child\n" ); + goto err0; + } + + ret =platform_device_add_resources (pdev_child, + dev->res, res_cnt); +if (ret) { +dev_err (&pdev->dev, +"failed to add resources for ocp2scp child\n" ); + goto err1; + } + + pdev_child->dev.parent = &pdev->dev; + + ret =platform_device_add (pdev_child); +if (ret) { +dev_err (&pdev->dev, +"failed to register ocp2scp child device\n" ); + goto err1; + } + } + }else { +dev_err (&pdev->dev,"OCP2SCP initialized without plat data\n" ); +return -EINVAL ; } +pm_runtime_enable (&pdev->dev);return 0 ; +err1: +platform_device_put (pdev_child); + err0:device_for_each_child (&pdev->dev,NULL , ocp2scp_remove_devices);
include/linux/platform_data/omap_ocp2scp.h new file +31 -0
@@ -0,0 +1,31 @@ +/* +* omap_ocp2scp.h -- ocp2scp header file +* +* Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* Author: Kishon Vijay Abraham I <[email protected]> +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +*/ + +#ifndef __DRIVERS_OMAP_OCP2SCP_H +#define __DRIVERS_OMAP_OCP2SCP_H + +struct omap_ocp2scp_dev { +const char *drv_name; +struct resource *res; +}; + +struct omap_ocp2scp_platform_data { +int dev_cnt; +struct omap_ocp2scp_dev **devices; +}; +#endif /* __DRIVERS_OMAP_OCP2SCP_H */
Signature · 1 line
1.7.9.5
PATCH 2/3 ARM: OMAP4: add _dev_attr_ to ocp2scp for representing usb_phy
In reply to Kishon Vijay Abraham IIn order to reflect devices(usb_phy) attached to ocp2scp bus, ocp2scp is assigned a device attribute to represent the attached devices.
--- arch/arm/mach-omap2/omap_hwmod_44xx_data.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
arch/arm/mach-omap2/omap_hwmod_44xx_data.c +28 -0
@@ -21,6 +21,7 @@#include <linux/io.h> #include <linux/platform_data/gpio-omap.h> #include <linux/power/smartreflex.h> +#include <linux/platform_data/omap_ocp2scp.h> #include <plat/omap_hwmod.h> #include <plat/i2c.h>
@@ -2681,6 +2682,32 @@ static struct omap_hwmod_class omap44xx_ocp2scp_hwmod_class = { .sysc = &omap44xx_ocp2scp_sysc, }; +/* ocp2scp dev_attr */ +static struct resource omap44xx_usb_phy_and_pll_addrs[] = { + { + .name ="usb_phy" , + .start =0x4a0ad080 , + .end =0x4a0ae000 , + .flags =IORESOURCE_MEM , + }, + { +/* XXX: Remove this once control module driver is in place */ + .name ="ctrl_dev" , + .start =0x4a002300 , + .end =0x4a002303 , + .flags =IORESOURCE_MEM , + }, + { } +}; + +static struct omap_ocp2scp_dev ocp2scp_dev_attr[] = { + { + .drv_name ="omap-usb2" , + .res = omap44xx_usb_phy_and_pll_addrs, + }, + { } +}; +/* ocp2scp_usb_phy */ static struct omap_hwmod omap44xx_ocp2scp_usb_phy_hwmod = { .name ="ocp2scp_usb_phy" ,
@@ -2694,6 +2721,7 @@ static struct omap_hwmod omap44xx_ocp2scp_usb_phy_hwmod = { .modulemode = MODULEMODE_HWCTRL, }, }, + .dev_attr = ocp2scp_dev_attr, };/*
Signature · 1 line
1.7.9.5
PATCH 3/3 ARM: OMAP: ocp2scp: create omap device for ocp2scp
In reply to Kishon Vijay Abraham IPlatfrom device for ocp2scp is created using omap_device_build in devices file. This is used for both omap4(musb) and omap5(dwc3).
--- arch/arm/mach-omap2/devices.c | 72 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+)
arch/arm/mach-omap2/devices.c +72 -0
@@ -19,6 +19,7 @@#include <linux/of.h> #include <linux/pinctrl/machine.h> #include <linux/platform_data/omap4-keypad.h> +#include <linux/platform_data/omap_ocp2scp.h> #include <asm/mach-types.h> #include <asm/mach/map.h>
@@ -613,6 +614,76 @@ static void omap_init_vout(void)static inline void omap_init_vout (void ) {}#endif +#if defined(CONFIG_OMAP_OCP2SCP ) || defined(CONFIG_OMAP_OCP2SCP_MODULE ) +static int count_ocp2scp_devices (struct omap_ocp2scp_dev *ocp2scp_dev) +{ +int cnt =0 ; + +while (ocp2scp_dev->drv_name !=NULL ) { + cnt++; + ocp2scp_dev++; + } + +return cnt; +} + +static void omap_init_ocp2scp (void ) +{ +struct omap_hwmod *oh; +struct platform_device *pdev; +int bus_id =-1 , dev_cnt =0 , i; +struct omap_ocp2scp_dev *ocp2scp_dev; +const char *oh_name, *name; +struct omap_ocp2scp_platform_data *pdata; + + oh_name ="ocp2scp_usb_phy" ; + name ="omap-ocp2scp" ; + + oh =omap_hwmod_lookup (oh_name); +if (!oh) { +pr_err ("%s: could not find omap_hwmod for %s\n" , __func__, + oh_name); +return ; + } + + pdata =kzalloc (sizeof (*pdata),GFP_KERNEL ); +if (!pdata) { +pr_err ("%s: No memory for ocp2scp pdata\n" , __func__); +return ; + } + + ocp2scp_dev = oh->dev_attr; + dev_cnt =count_ocp2scp_devices (ocp2scp_dev); + +if (!dev_cnt) { +pr_err ("%s: No devices connected to ocp2scp\n" , __func__); +return ; + } + + pdata->devices =kzalloc (sizeof (struct omap_ocp2scp_dev *) + * dev_cnt,GFP_KERNEL ); +if (!pdata->devices) { +pr_err ("%s: No memory for ocp2scp pdata devices\n" , __func__); +return ; + } + +for (i =0 ; i < dev_cnt; i++, ocp2scp_dev++) + pdata->devices[i] = ocp2scp_dev; + + pdata->dev_cnt = dev_cnt; + + pdev =omap_device_build (name, bus_id, oh, pdata,sizeof (*pdata),NULL , +0 , false); +if (IS_ERR (pdev)) { +pr_err ("Could not build omap_device for %s %s\n" , + name, oh_name); +return ; + } +} +#else +static inline void omap_init_ocp2scp (void ) { } +#endif +/*-------------------------------------------------------------------------*/ static int __init omap2_init_devices (void )
@@ -640,6 +711,7 @@ static int __init omap2_init_devices(void)omap_init_sham ();omap_init_aes ();omap_init_vout (); +omap_init_ocp2scp ();return 0 ; }
Signature · 1 line
1.7.9.5
Re: [PATCH 3/3] ARM: OMAP: ocp2scp: create omap device for ocp2scp
Hello.
Quoted 12 lines · Kishon Vijay Abraham I
Platfrom device for ocp2scp is created using
omap_device_buildin devices file. This is used for both omap4(musb) and omap5(dwc3).Signed-off-by Kishon Vijay Abraham I<[email protected]>--- arch/arm/mach-omap2/devices.c | 72 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+)arch/arm/mach-omap2/devices.c +0
-0
[...]
Quoted 1 line
arch/arm/mach-omap2/devices.c +0
-0@@ -613,6 +614,76 @@ static void omap_init_vout(void)
[...]
Quoted 21 lines
arch/arm/mach-omap2/devices.c +21
-0+static void omap_init_ocp2scp (void ) +{ +struct omap_hwmod *oh; +struct platform_device *pdev; +int bus_id =-1 , dev_cnt =0 , i; +struct omap_ocp2scp_dev *ocp2scp_dev; +const char *oh_name, *name; +struct omap_ocp2scp_platform_data *pdata; + + oh_name ="ocp2scp_usb_phy" ; + name ="omap-ocp2scp" ; + + oh =omap_hwmod_lookup (oh_name); +if (!oh) { +pr_err ("%s: could not find omap_hwmod for %s\n" , __func__, + oh_name); +return ; + } + + pdata =kzalloc (sizeof (*pdata),GFP_KERNEL ); +if (!pdata) {
arch/arm/mach-omap2/devices.c static void omap_init_vout(void) · line 660
Quoted 10 lines
arch/arm/mach-omap2/devices.c +10
-0+pr_err ("%s: No memory for ocp2scp pdata\n" , __func__); +return ; + } + + ocp2scp_dev = oh->dev_attr; + dev_cnt =count_ocp2scp_devices (ocp2scp_dev); + +if (!dev_cnt) { +pr_err ("%s: No devices connected to ocp2scp\n" , __func__); +return ;
Don't you leak 'pdata' here?
Quoted 10 lines
arch/arm/mach-omap2/devices.c +10
-0+ } + + pdata->devices =kzalloc (sizeof (struct omap_ocp2scp_dev *) + * dev_cnt,GFP_KERNEL ); +if (!pdata->devices) { +pr_err ("%s: No memory for ocp2scp pdata devices\n" , __func__); +return ; + } + +for (i =0 ; i< dev_cnt; i++, ocp2scp_dev++)
arch/arm/mach-omap2/devices.c static void omap_init_vout(void) · line 680
Quoted 10 lines
arch/arm/mach-omap2/devices.c +10
-0+ pdata->devices[i] = ocp2scp_dev; + + pdata->dev_cnt = dev_cnt; + + pdev =omap_device_build (name, bus_id, oh, pdata,sizeof (*pdata),NULL , +0 , false); +if (IS_ERR (pdev)) { +pr_err ("Could not build omap_device for %s %s\n" , + name, oh_name); +return ;
Don't you leak 'pdata' and 'pdata->devices' here?
arch/arm/mach-omap2/devices.c
Quoted 3 lines
arch/arm/mach-omap2/devices.c +2
-0+ } +}
WBR, Sergei
Re: [PATCH 3/3] ARM: OMAP: ocp2scp: create omap device for ocp2scp
Hi,
Quoted 71 lines · Sergei Shtylyov
Hello.
Quoted 14 lines · Kishon Vijay Abraham I
Platfrom device for ocp2scp is created using
omap_device_buildin devices file. This is used for both omap4(musb) and omap5(dwc3).Signed-off-by Kishon Vijay Abraham I<[email protected]>--- arch/arm/mach-omap2/devices.c | 72 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+)arch/arm/mach-omap2/devices.c +0
-0[...]
Quoted 1 line
arch/arm/mach-omap2/devices.c +0
-0@@ -613,6 +614,76 @@ static void omap_init_vout(void)[...]
Quoted 21 lines
arch/arm/mach-omap2/devices.c +21
-0+static void omap_init_ocp2scp (void ) +{ +struct omap_hwmod *oh; +struct platform_device *pdev; +int bus_id =-1 , dev_cnt =0 , i; +struct omap_ocp2scp_dev *ocp2scp_dev; +const char *oh_name, *name; +struct omap_ocp2scp_platform_data *pdata; + + oh_name ="ocp2scp_usb_phy" ; + name ="omap-ocp2scp" ; + + oh =omap_hwmod_lookup (oh_name); +if (!oh) { +pr_err ("%s: could not find omap_hwmod for %s\n" , __func__, + oh_name); +return ; + } + + pdata =kzalloc (sizeof (*pdata),GFP_KERNEL ); +if (!pdata) {arch/arm/mach-omap2/devices.c static void omap_init_vout(void) · line 660
Quoted 10 lines
arch/arm/mach-omap2/devices.c +10
-0+pr_err ("%s: No memory for ocp2scp pdata\n" , __func__); +return ; + } + + ocp2scp_dev = oh->dev_attr; + dev_cnt =count_ocp2scp_devices (ocp2scp_dev); + +if (!dev_cnt) { +pr_err ("%s: No devices connected to ocp2scp\n" , __func__); +return ;Don't you leak 'pdata' here?
Quoted 15 lines
arch/arm/mach-omap2/devices.c +15
-0+ } + + pdata->devices =kzalloc (sizeof (struct omap_ocp2scp_dev *) + * dev_cnt,GFP_KERNEL ); +if (!pdata->devices) { +pr_err ("%s: No memory for ocp2scp pdata devices\n" , __func__); +return ; + } + +for (i =0 ; i< dev_cnt; i++, ocp2scp_dev++) + pdata->devices[i] = ocp2scp_dev; + + pdata->dev_cnt = dev_cnt; + + pdev = omap_device_build(name, bus_id, oh, pdata, sizeof(*pdata),
Quoted 8 lines
arch/arm/mach-omap2/devices.c static void omap_init_vout(void) · line 680
Quoted 6 lines
NULL,
arch/arm/mach-omap2/devices.c +5
-0+ 0, false); +if (IS_ERR (pdev)) { +pr_err ("Could not build omap_device for %s %s\n" , + name, oh_name); +return ;Don't you leak 'pdata' and 'pdata->devices' here?
Will re-post the patch fixing it.
Thanks
Kishon