diff mbox

[v2,3/3] ARM: OMAP: ocp2scp: create omap device for ocp2scp

Message ID 1349675983-23803-4-git-send-email-kishon@ti.com (mailing list archive)
State New, archived
Headers show

Commit Message

Kishon Vijay Abraham I Oct. 8, 2012, 5:59 a.m. UTC
Platfrom device for ocp2scp is created using omap_device_build in
devices file. This is used for both omap4(musb) and omap5(dwc3).

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
---
 arch/arm/mach-omap2/devices.c |   76 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 76 insertions(+)

Comments

Felipe Balbi Oct. 26, 2012, 6:50 a.m. UTC | #1
Hi,

On Mon, Oct 08, 2012 at 11:29:43AM +0530, Kishon Vijay Abraham I wrote:
> Platfrom device for ocp2scp is created using omap_device_build in
> devices file. This is used for both omap4(musb) and omap5(dwc3).
> 
> Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
> ---
>  arch/arm/mach-omap2/devices.c |   76 +++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 76 insertions(+)
> 
> diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c
> index c8c2117..ac2bfce 100644
> --- a/arch/arm/mach-omap2/devices.c
> +++ b/arch/arm/mach-omap2/devices.c
> @@ -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,80 @@ 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";

how about adding checks here to return early case we're not running on
OMAP4 or OMAP5 ??
Arnd Bergmann Oct. 26, 2012, 7:47 a.m. UTC | #2
On Friday 26 October 2012, Felipe Balbi wrote:
> > +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";
> 
> how about adding checks here to return early case we're not running on
> OMAP4 or OMAP5 ??
> 

I suppose even OMAP4-only, since OMAP5 always has DT enabled.

	Arnd
Tony Lindgren Oct. 26, 2012, 5:21 p.m. UTC | #3
* Arnd Bergmann <arnd@arndb.de> [121026 00:48]:
> On Friday 26 October 2012, Felipe Balbi wrote:
> > > +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";
> > 
> > how about adding checks here to return early case we're not running on
> > OMAP4 or OMAP5 ??
> > 
> 
> I suppose even OMAP4-only, since OMAP5 always has DT enabled.

Hmm yes, currently omap_hwmod_lookup(oh_name) produces
bogus errors for other omaps as the hwmod data is only
there for omap4.

Regards,

Tony
Felipe Balbi Oct. 26, 2012, 7:59 p.m. UTC | #4
On Fri, Oct 26, 2012 at 10:21:41AM -0700, Tony Lindgren wrote:
> * Arnd Bergmann <arnd@arndb.de> [121026 00:48]:
> > On Friday 26 October 2012, Felipe Balbi wrote:
> > > > +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";
> > > 
> > > how about adding checks here to return early case we're not running on
> > > OMAP4 or OMAP5 ??
> > > 
> > 
> > I suppose even OMAP4-only, since OMAP5 always has DT enabled.
> 
> Hmm yes, currently omap_hwmod_lookup(oh_name) produces
> bogus errors for other omaps as the hwmod data is only
> there for omap4.

shouldn't that be fixed too ? I mean, if data isn't just return -ENODEV
or something similar.
Tony Lindgren Oct. 26, 2012, 8:16 p.m. UTC | #5
* Felipe Balbi <balbi@ti.com> [121026 13:07]:
> On Fri, Oct 26, 2012 at 10:21:41AM -0700, Tony Lindgren wrote:
> > * Arnd Bergmann <arnd@arndb.de> [121026 00:48]:
> > > On Friday 26 October 2012, Felipe Balbi wrote:
> > > > > +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";
> > > > 
> > > > how about adding checks here to return early case we're not running on
> > > > OMAP4 or OMAP5 ??
> > > > 
> > > 
> > > I suppose even OMAP4-only, since OMAP5 always has DT enabled.
> > 
> > Hmm yes, currently omap_hwmod_lookup(oh_name) produces
> > bogus errors for other omaps as the hwmod data is only
> > there for omap4.
> 
> shouldn't that be fixed too ? I mean, if data isn't just return -ENODEV
> or something similar.

Yes some kind of checking is needed here.

Regards,

Tony
Kishon Vijay Abraham I Oct. 27, 2012, 12:29 p.m. UTC | #6
On Saturday 27 October 2012 01:46 AM, Tony Lindgren wrote:
> * Felipe Balbi <balbi@ti.com> [121026 13:07]:
>> On Fri, Oct 26, 2012 at 10:21:41AM -0700, Tony Lindgren wrote:
>>> * Arnd Bergmann <arnd@arndb.de> [121026 00:48]:
>>>> On Friday 26 October 2012, Felipe Balbi wrote:
>>>>>> +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";
>>>>>
>>>>> how about adding checks here to return early case we're not running on
>>>>> OMAP4 or OMAP5 ??
>>>>>
>>>>
>>>> I suppose even OMAP4-only, since OMAP5 always has DT enabled.
>>>
>>> Hmm yes, currently omap_hwmod_lookup(oh_name) produces
>>> bogus errors for other omaps as the hwmod data is only
>>> there for omap4.
>>
>> shouldn't that be fixed too ? I mean, if data isn't just return -ENODEV
>> or something similar.
>
> Yes some kind of checking is needed here.

Ok. I'll fix and send.

Thanks
Kishon
diff mbox

Patch

diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c
index c8c2117..ac2bfce 100644
--- a/arch/arm/mach-omap2/devices.c
+++ b/arch/arm/mach-omap2/devices.c
@@ -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,80 @@  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__);
+		kfree(pdata);
+		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__);
+		kfree(pdata);
+		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);
+		kfree(pdata->devices);
+		kfree(pdata);
+		return;
+	}
+}
+#else
+static inline void omap_init_ocp2scp(void) { }
+#endif
+
 /*-------------------------------------------------------------------------*/
 
 static int __init omap2_init_devices(void)
@@ -640,6 +715,7 @@  static int __init omap2_init_devices(void)
 	omap_init_sham();
 	omap_init_aes();
 	omap_init_vout();
+	omap_init_ocp2scp();
 
 	return 0;
 }