All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/2] usb: renesas_usbhs: Add device tree support for R-Car H2 and M2
@ 2014-08-01 11:49 ` Yoshihiro Shimoda
  0 siblings, 0 replies; 6+ messages in thread
From: Yoshihiro Shimoda @ 2014-08-01 11:49 UTC (permalink / raw)
  To: SH-Linux, linux-usb; +Cc: devicetree, Grant Likely, Rob Herring

This driver supports other SoCs, but they need boards/Soc depend code.
So, this patch adds device tree support for R-Car H2 and M2 initially.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
---
 drivers/usb/renesas_usbhs/common.c |   43 ++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)

diff --git a/drivers/usb/renesas_usbhs/common.c b/drivers/usb/renesas_usbhs/common.c
index 1b9bf8d..845a889 100644
--- a/drivers/usb/renesas_usbhs/common.c
+++ b/drivers/usb/renesas_usbhs/common.c
@@ -18,6 +18,7 @@
 #include <linux/gpio.h>
 #include <linux/io.h>
 #include <linux/module.h>
+#include <linux/of_gpio.h>
 #include <linux/pm_runtime.h>
 #include <linux/slab.h>
 #include <linux/sysfs.h>
@@ -438,6 +439,34 @@ static int usbhsc_drvcllbck_notify_hotplug(struct platform_device *pdev)
 /*
  *		platform functions
  */
+static struct renesas_usbhs_platform_info *usbhs_parse_dt(struct device *dev)
+{
+	struct renesas_usbhs_platform_info *info;
+	struct renesas_usbhs_driver_param *dparam;
+	u32 tmp;
+	int gpio;
+
+	info = devm_kzalloc(dev, sizeof(*info), GFP_KERNEL);
+	if (!info)
+		return NULL;
+
+	dparam = &info->driver_param;
+
+	if (of_device_is_compatible(dev->of_node, "renesas,usbhs-r8a7790"))
+		dparam->type = USBHS_TYPE_R8A7790;
+
+	if (of_device_is_compatible(dev->of_node, "renesas,usbhs-r8a7791"))
+		dparam->type = USBHS_TYPE_R8A7791;
+
+	if (!of_property_read_u32(dev->of_node, "buswait_bwait", &tmp))
+		dparam->buswait_bwait = tmp;
+	gpio = of_get_named_gpio_flags(dev->of_node, "enable-gpio", 0, NULL);
+	if (gpio > 0)
+		dparam->enable_gpio = gpio;
+
+	return info;
+}
+
 static int usbhs_probe(struct platform_device *pdev)
 {
 	struct renesas_usbhs_platform_info *info = dev_get_platdata(&pdev->dev);
@@ -446,6 +475,10 @@ static int usbhs_probe(struct platform_device *pdev)
 	struct resource *res, *irq_res;
 	int ret;

+	/* check device node */
+	if (pdev->dev.of_node)
+		info = pdev->dev.platform_data = usbhs_parse_dt(&pdev->dev);
+
 	/* check platform information */
 	if (!info) {
 		dev_err(&pdev->dev, "no platform information\n");
@@ -685,10 +718,20 @@ static const struct dev_pm_ops usbhsc_pm_ops = {
 	.runtime_resume		= usbhsc_runtime_nop,
 };

+#ifdef CONFIG_OF
+static const struct of_device_id usbhs_of_match[] = {
+	{ .compatible = "renesas,usbhs-r8a7790"},
+	{ .compatible = "renesas,usbhs-r8a7791"},
+	{ },
+};
+MODULE_DEVICE_TABLE(of, usbhs_of_match);
+#endif
+
 static struct platform_driver renesas_usbhs_driver = {
 	.driver		= {
 		.name	= "renesas_usbhs",
 		.pm	= &usbhsc_pm_ops,
+		.of_match_table = of_match_ptr(usbhs_of_match),
 	},
 	.probe		= usbhs_probe,
 	.remove		= usbhs_remove,
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] usb: renesas_usbhs: Add device tree support for R-Car H2 and M2
@ 2014-08-01 11:49 ` Yoshihiro Shimoda
  0 siblings, 0 replies; 6+ messages in thread
From: Yoshihiro Shimoda @ 2014-08-01 11:49 UTC (permalink / raw)
  To: SH-Linux, linux-usb; +Cc: devicetree, Grant Likely, Rob Herring

This driver supports other SoCs, but they need boards/Soc depend code.
So, this patch adds device tree support for R-Car H2 and M2 initially.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
---
 drivers/usb/renesas_usbhs/common.c |   43 ++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)

diff --git a/drivers/usb/renesas_usbhs/common.c b/drivers/usb/renesas_usbhs/common.c
index 1b9bf8d..845a889 100644
--- a/drivers/usb/renesas_usbhs/common.c
+++ b/drivers/usb/renesas_usbhs/common.c
@@ -18,6 +18,7 @@
 #include <linux/gpio.h>
 #include <linux/io.h>
 #include <linux/module.h>
+#include <linux/of_gpio.h>
 #include <linux/pm_runtime.h>
 #include <linux/slab.h>
 #include <linux/sysfs.h>
@@ -438,6 +439,34 @@ static int usbhsc_drvcllbck_notify_hotplug(struct platform_device *pdev)
 /*
  *		platform functions
  */
+static struct renesas_usbhs_platform_info *usbhs_parse_dt(struct device *dev)
+{
+	struct renesas_usbhs_platform_info *info;
+	struct renesas_usbhs_driver_param *dparam;
+	u32 tmp;
+	int gpio;
+
+	info = devm_kzalloc(dev, sizeof(*info), GFP_KERNEL);
+	if (!info)
+		return NULL;
+
+	dparam = &info->driver_param;
+
+	if (of_device_is_compatible(dev->of_node, "renesas,usbhs-r8a7790"))
+		dparam->type = USBHS_TYPE_R8A7790;
+
+	if (of_device_is_compatible(dev->of_node, "renesas,usbhs-r8a7791"))
+		dparam->type = USBHS_TYPE_R8A7791;
+
+	if (!of_property_read_u32(dev->of_node, "buswait_bwait", &tmp))
+		dparam->buswait_bwait = tmp;
+	gpio = of_get_named_gpio_flags(dev->of_node, "enable-gpio", 0, NULL);
+	if (gpio > 0)
+		dparam->enable_gpio = gpio;
+
+	return info;
+}
+
 static int usbhs_probe(struct platform_device *pdev)
 {
 	struct renesas_usbhs_platform_info *info = dev_get_platdata(&pdev->dev);
@@ -446,6 +475,10 @@ static int usbhs_probe(struct platform_device *pdev)
 	struct resource *res, *irq_res;
 	int ret;

+	/* check device node */
+	if (pdev->dev.of_node)
+		info = pdev->dev.platform_data = usbhs_parse_dt(&pdev->dev);
+
 	/* check platform information */
 	if (!info) {
 		dev_err(&pdev->dev, "no platform information\n");
@@ -685,10 +718,20 @@ static const struct dev_pm_ops usbhsc_pm_ops = {
 	.runtime_resume		= usbhsc_runtime_nop,
 };

+#ifdef CONFIG_OF
+static const struct of_device_id usbhs_of_match[] = {
+	{ .compatible = "renesas,usbhs-r8a7790"},
+	{ .compatible = "renesas,usbhs-r8a7791"},
+	{ },
+};
+MODULE_DEVICE_TABLE(of, usbhs_of_match);
+#endif
+
 static struct platform_driver renesas_usbhs_driver = {
 	.driver		= {
 		.name	= "renesas_usbhs",
 		.pm	= &usbhsc_pm_ops,
+		.of_match_table = of_match_ptr(usbhs_of_match),
 	},
 	.probe		= usbhs_probe,
 	.remove		= usbhs_remove,
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] usb: renesas_usbhs: Add device tree support for R-Car H2 and M2
  2014-08-01 11:49 ` Yoshihiro Shimoda
@ 2014-08-04  0:05   ` Kuninori Morimoto
  -1 siblings, 0 replies; 6+ messages in thread
From: Kuninori Morimoto @ 2014-08-04  0:05 UTC (permalink / raw)
  To: Yoshihiro Shimoda
  Cc: SH-Linux, linux-usb, devicetree, Grant Likely, Rob Herring


Hi Shimoda-san

> This driver supports other SoCs, but they need boards/Soc depend code.
> So, this patch adds device tree support for R-Car H2 and M2 initially.
> 
> Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> ---
(snip)
> +static struct renesas_usbhs_platform_info *usbhs_parse_dt(struct device *dev)
> +{
> +	struct renesas_usbhs_platform_info *info;
> +	struct renesas_usbhs_driver_param *dparam;
> +	u32 tmp;
> +	int gpio;
> +
> +	info = devm_kzalloc(dev, sizeof(*info), GFP_KERNEL);
> +	if (!info)
> +		return NULL;
> +
> +	dparam = &info->driver_param;
> +
> +	if (of_device_is_compatible(dev->of_node, "renesas,usbhs-r8a7790"))
> +		dparam->type = USBHS_TYPE_R8A7790;
> +
> +	if (of_device_is_compatible(dev->of_node, "renesas,usbhs-r8a7791"))
> +		dparam->type = USBHS_TYPE_R8A7791;
> +
> +	if (!of_property_read_u32(dev->of_node, "buswait_bwait", &tmp))
> +		dparam->buswait_bwait = tmp;
> +	gpio = of_get_named_gpio_flags(dev->of_node, "enable-gpio", 0, NULL);
> +	if (gpio > 0)
> +		dparam->enable_gpio = gpio;
(snip)
> +static const struct of_device_id usbhs_of_match[] = {
> +	{ .compatible = "renesas,usbhs-r8a7790"},
> +	{ .compatible = "renesas,usbhs-r8a7791"},
> +	{ },

How about to use "of_device_id :: data" for USBHS_TYPE_xxx ?

Best regards
---
Kuninori Morimoto

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] usb: renesas_usbhs: Add device tree support for R-Car H2 and M2
@ 2014-08-04  0:05   ` Kuninori Morimoto
  0 siblings, 0 replies; 6+ messages in thread
From: Kuninori Morimoto @ 2014-08-04  0:05 UTC (permalink / raw)
  To: Yoshihiro Shimoda
  Cc: SH-Linux, linux-usb, devicetree, Grant Likely, Rob Herring


Hi Shimoda-san

> This driver supports other SoCs, but they need boards/Soc depend code.
> So, this patch adds device tree support for R-Car H2 and M2 initially.
> 
> Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> ---
(snip)
> +static struct renesas_usbhs_platform_info *usbhs_parse_dt(struct device *dev)
> +{
> +	struct renesas_usbhs_platform_info *info;
> +	struct renesas_usbhs_driver_param *dparam;
> +	u32 tmp;
> +	int gpio;
> +
> +	info = devm_kzalloc(dev, sizeof(*info), GFP_KERNEL);
> +	if (!info)
> +		return NULL;
> +
> +	dparam = &info->driver_param;
> +
> +	if (of_device_is_compatible(dev->of_node, "renesas,usbhs-r8a7790"))
> +		dparam->type = USBHS_TYPE_R8A7790;
> +
> +	if (of_device_is_compatible(dev->of_node, "renesas,usbhs-r8a7791"))
> +		dparam->type = USBHS_TYPE_R8A7791;
> +
> +	if (!of_property_read_u32(dev->of_node, "buswait_bwait", &tmp))
> +		dparam->buswait_bwait = tmp;
> +	gpio = of_get_named_gpio_flags(dev->of_node, "enable-gpio", 0, NULL);
> +	if (gpio > 0)
> +		dparam->enable_gpio = gpio;
(snip)
> +static const struct of_device_id usbhs_of_match[] = {
> +	{ .compatible = "renesas,usbhs-r8a7790"},
> +	{ .compatible = "renesas,usbhs-r8a7791"},
> +	{ },

How about to use "of_device_id :: data" for USBHS_TYPE_xxx ?

Best regards
---
Kuninori Morimoto

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] usb: renesas_usbhs: Add device tree support for R-Car H2 and M2
  2014-08-04  0:05   ` Kuninori Morimoto
@ 2014-08-04  4:27     ` Yoshihiro Shimoda
  -1 siblings, 0 replies; 6+ messages in thread
From: Yoshihiro Shimoda @ 2014-08-04  4:27 UTC (permalink / raw)
  To: Kuninori Morimoto
  Cc: SH-Linux, linux-usb, devicetree, Grant Likely, Rob Herring

Hi Morimoto-san,

(2014/08/04 9:05), Kuninori Morimoto wrote:
> 
> Hi Shimoda-san
> 
>> This driver supports other SoCs, but they need boards/Soc depend code.
>> So, this patch adds device tree support for R-Car H2 and M2 initially.
>>
>> Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
>> ---
> (snip)
>> +static struct renesas_usbhs_platform_info *usbhs_parse_dt(struct device *dev)
>> +{
>> +	struct renesas_usbhs_platform_info *info;
>> +	struct renesas_usbhs_driver_param *dparam;
>> +	u32 tmp;
>> +	int gpio;
>> +
>> +	info = devm_kzalloc(dev, sizeof(*info), GFP_KERNEL);
>> +	if (!info)
>> +		return NULL;
>> +
>> +	dparam = &info->driver_param;
>> +
>> +	if (of_device_is_compatible(dev->of_node, "renesas,usbhs-r8a7790"))
>> +		dparam->type = USBHS_TYPE_R8A7790;
>> +
>> +	if (of_device_is_compatible(dev->of_node, "renesas,usbhs-r8a7791"))
>> +		dparam->type = USBHS_TYPE_R8A7791;
>> +
>> +	if (!of_property_read_u32(dev->of_node, "buswait_bwait", &tmp))
>> +		dparam->buswait_bwait = tmp;
>> +	gpio = of_get_named_gpio_flags(dev->of_node, "enable-gpio", 0, NULL);
>> +	if (gpio > 0)
>> +		dparam->enable_gpio = gpio;
> (snip)
>> +static const struct of_device_id usbhs_of_match[] = {
>> +	{ .compatible = "renesas,usbhs-r8a7790"},
>> +	{ .compatible = "renesas,usbhs-r8a7791"},
>> +	{ },
> 
> How about to use "of_device_id :: data" for USBHS_TYPE_xxx ?

Thank you for the suggestion.
To remove the "if (of_device_is_compatible(...))", I will use the
"of_device_id :: data" lile a ".data = (void *)USBHS_TYPE_R8A7790".

Best regards,
Yoshihiro Shimoda

> Best regards
> ---
> Kuninori Morimoto
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] usb: renesas_usbhs: Add device tree support for R-Car H2 and M2
@ 2014-08-04  4:27     ` Yoshihiro Shimoda
  0 siblings, 0 replies; 6+ messages in thread
From: Yoshihiro Shimoda @ 2014-08-04  4:27 UTC (permalink / raw)
  To: Kuninori Morimoto
  Cc: SH-Linux, linux-usb, devicetree, Grant Likely, Rob Herring

Hi Morimoto-san,

(2014/08/04 9:05), Kuninori Morimoto wrote:
> 
> Hi Shimoda-san
> 
>> This driver supports other SoCs, but they need boards/Soc depend code.
>> So, this patch adds device tree support for R-Car H2 and M2 initially.
>>
>> Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
>> ---
> (snip)
>> +static struct renesas_usbhs_platform_info *usbhs_parse_dt(struct device *dev)
>> +{
>> +	struct renesas_usbhs_platform_info *info;
>> +	struct renesas_usbhs_driver_param *dparam;
>> +	u32 tmp;
>> +	int gpio;
>> +
>> +	info = devm_kzalloc(dev, sizeof(*info), GFP_KERNEL);
>> +	if (!info)
>> +		return NULL;
>> +
>> +	dparam = &info->driver_param;
>> +
>> +	if (of_device_is_compatible(dev->of_node, "renesas,usbhs-r8a7790"))
>> +		dparam->type = USBHS_TYPE_R8A7790;
>> +
>> +	if (of_device_is_compatible(dev->of_node, "renesas,usbhs-r8a7791"))
>> +		dparam->type = USBHS_TYPE_R8A7791;
>> +
>> +	if (!of_property_read_u32(dev->of_node, "buswait_bwait", &tmp))
>> +		dparam->buswait_bwait = tmp;
>> +	gpio = of_get_named_gpio_flags(dev->of_node, "enable-gpio", 0, NULL);
>> +	if (gpio > 0)
>> +		dparam->enable_gpio = gpio;
> (snip)
>> +static const struct of_device_id usbhs_of_match[] = {
>> +	{ .compatible = "renesas,usbhs-r8a7790"},
>> +	{ .compatible = "renesas,usbhs-r8a7791"},
>> +	{ },
> 
> How about to use "of_device_id :: data" for USBHS_TYPE_xxx ?

Thank you for the suggestion.
To remove the "if (of_device_is_compatible(...))", I will use the
"of_device_id :: data" lile a ".data = (void *)USBHS_TYPE_R8A7790".

Best regards,
Yoshihiro Shimoda

> Best regards
> ---
> Kuninori Morimoto
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-08-04  4:27 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-01 11:49 [PATCH 2/2] usb: renesas_usbhs: Add device tree support for R-Car H2 and M2 Yoshihiro Shimoda
2014-08-01 11:49 ` Yoshihiro Shimoda
2014-08-04  0:05 ` Kuninori Morimoto
2014-08-04  0:05   ` Kuninori Morimoto
2014-08-04  4:27   ` Yoshihiro Shimoda
2014-08-04  4:27     ` Yoshihiro Shimoda

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.