Skip to contentSkip to conversation

usb: renesas_usbhs: Add device tree support for R-Car H2 and M2

PATCH In review Yoshihiro Shimoda 2 participants 6 messages Sep 3, 2014 – Oct 2, 2014 3 messages not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v3 2/2 usb: renesas_usbhs: Add device tree support for R-Car H2 and M2

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.

---
 drivers/usb/renesas_usbhs/common.c |   44 ++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)
drivers/usb/renesas_usbhs/common.c +44 -0
index 1b9bf8d..b3b6813 100644
@@ -18,6 +18,8 @@
 #include <linux/gpio.h>
 #include <linux/io.h>
 #include <linux/module.h>
+#include <linux/of_device.h>
+#include <linux/of_gpio.h>
 #include <linux/pm_runtime.h>
 #include <linux/slab.h>
 #include <linux/sysfs.h>
@@ -438,6 +440,43 @@ static int usbhsc_drvcllbck_notify_hotplug(struct platform_device *pdev)
 /*
  *		platform functions
  */
+static const struct of_device_id usbhs_of_match[] = {
+	{
+		.compatible = "renesas,usbhs-r8a7790",
+		.data = (void *)USBHS_TYPE_R8A7790,
+	},
+	{
+		.compatible = "renesas,usbhs-r8a7791",
+		.data = (void *)USBHS_TYPE_R8A7791,
+	},
+	{ },
+};
+MODULE_DEVICE_TABLE(of, usbhs_of_match);
+
+static struct renesas_usbhs_platform_info *usbhs_parse_dt(struct device *dev)
+{
+	struct renesas_usbhs_platform_info *info;
+	struct renesas_usbhs_driver_param *dparam;
+	const struct of_device_id *of_id = of_match_device(usbhs_of_match, dev);
+	u32 tmp;
+	int gpio;
+
+	info = devm_kzalloc(dev, sizeof(*info), GFP_KERNEL);
+	if (!info)
+		return NULL;
+
+	dparam = &info->driver_param;
+	dparam->type = of_id ? (u32)of_id->data : 0;
+	if (!of_property_read_u32(dev->of_node, "renesas,buswait", &tmp))
+		dparam->buswait_bwait = tmp;
+	gpio = of_get_named_gpio_flags(dev->of_node, "renesas,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 +485,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");
@@ -689,6 +732,7 @@ 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,
Signature · 1 line
1.7.9.5

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw

Hello.

Quoted 23 lines · Yoshihiro Shimoda

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.

---
  drivers/usb/renesas_usbhs/common.c |   44 ++++++++++++++++++++++++++++++++++++
  1 file changed, 44 insertions(+)
drivers/usb/renesas_usbhs/common.c +2 -0
index 1b9bf8d..b3b6813 100644
@@ -18,6 +18,8 @@
  #include <linux/gpio.h>
  #include <linux/io.h>
  #include <linux/module.h>
+#include <linux/of_device.h>
+#include <linux/of_gpio.h>
  #include <linux/pm_runtime.h>
  #include <linux/slab.h>
  #include <linux/sysfs.h>
@@ -438,6 +440,43 @@ static int usbhsc_drvcllbck_notify_hotplug(struct platform_device *pdev)

[...]

Quoted 12 lines
drivers/usb/renesas_usbhs/common.c +12 -0
+static struct renesas_usbhs_platform_info *usbhs_parse_dt(struct device *dev)
+{
+	struct renesas_usbhs_platform_info *info;
+	struct renesas_usbhs_driver_param *dparam;
+	const struct of_device_id *of_id = of_match_device(usbhs_of_match, dev);
+	u32 tmp;
+	int gpio;
+
+	info = devm_kzalloc(dev, sizeof(*info), GFP_KERNEL);
+	if (!info)
+		return NULL;
+

drivers/usb/renesas_usbhs/common.c static int usbhsc_drvcllbck_notify_hotplug(struct platform_device *pdev) · line 477

Quoted 10 lines
drivers/usb/renesas_usbhs/common.c +10 -0
+	dparam = &info->driver_param;
+	dparam->type = of_id ? (u32)of_id->data : 0;
+	if (!of_property_read_u32(dev->of_node, "renesas,buswait", &tmp))
+		dparam->buswait_bwait = tmp;
+	gpio = of_get_named_gpio_flags(dev->of_node, "renesas,enable-gpio", 0,
+				       NULL);
+	if (gpio > 0)
+		dparam->enable_gpio = gpio;
+
+	return info;

I don't see where you parse the optional "phy" property. It should exist
for the Lager and Koelsch boards you target.

WBR, Sergei

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw

Hello.

Quoted 45 lines · Sergei Shtylyov

Hello.

Quoted 23 lines · Yoshihiro Shimoda

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.

---
  drivers/usb/renesas_usbhs/common.c |   44 ++++++++++++++++++++++++++++++++++++
  1 file changed, 44 insertions(+)
drivers/usb/renesas_usbhs/common.c +2 -0
index 1b9bf8d..b3b6813 100644
@@ -18,6 +18,8 @@
  #include <linux/gpio.h>
  #include <linux/io.h>
  #include <linux/module.h>
+#include <linux/of_device.h>
+#include <linux/of_gpio.h>
  #include <linux/pm_runtime.h>
  #include <linux/slab.h>
  #include <linux/sysfs.h>
@@ -438,6 +440,43 @@ static int usbhsc_drvcllbck_notify_hotplug(struct platform_device *pdev)

[...]

Quoted 17 lines
drivers/usb/renesas_usbhs/common.c +17 -0
+static struct renesas_usbhs_platform_info *usbhs_parse_dt(struct device *dev)
+{
+	struct renesas_usbhs_platform_info *info;
+	struct renesas_usbhs_driver_param *dparam;
+	const struct of_device_id *of_id = of_match_device(usbhs_of_match, dev);
+	u32 tmp;
+	int gpio;
+
+	info = devm_kzalloc(dev, sizeof(*info), GFP_KERNEL);
+	if (!info)
+		return NULL;
+
+	dparam = &info->driver_param;
+	dparam->type = of_id ? (u32)of_id->data : 0;
+	if (!of_property_read_u32(dev->of_node, "renesas,buswait", &tmp))
+		dparam->buswait_bwait = tmp;
+	gpio = of_get_named_gpio_flags(dev->of_node, "renesas,enable-gpio", 0,
Quoted 8 lines

drivers/usb/renesas_usbhs/common.c static int usbhsc_drvcllbck_notify_hotplug(struct platform_device *pdev) · line 477

Quoted 5 lines
drivers/usb/renesas_usbhs/common.c +5 -0
+				       NULL);
+	if (gpio > 0)
+		dparam->enable_gpio = gpio;
+
+	return info;

I don't see where you parse the optional "phy" property. It should exist
for the Lager and Koelsch boards you target.

Since I wrote 'phy-names: must be "usb"' in the document, I intend to use a fixed property for "phy" driver like the following:

	phy = phy_get(&pdev->dev, "usb");

Is this a bad code?

About using the phy driver in renesas_usbhs driver, I intend to modify the drivers/usb/renesas_usbhs/rcar.c.

Best regards,
Yoshihiro Shimoda

Quoted 2 lines

WBR, Sergei

A message that is not in the archive (sent off-list or not yet received): [email protected]

#5 lore raw

Hello.

Quoted 13 lines · Yoshihiro Shimoda
Quoted 13 lines
Quoted 13 lines

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.

---
   drivers/usb/renesas_usbhs/common.c |   44 ++++++++++++++++++++++++++++++++++++
   1 file changed, 44 insertions(+)
drivers/usb/renesas_usbhs/common.c +0 -0
index 1b9bf8d..b3b6813 100644

[...]

Quoted 28 lines
Quoted 19 lines
Quoted 1 line
drivers/usb/renesas_usbhs/common.c +0 -0
@@ -438,6 +440,43 @@ static int usbhsc_drvcllbck_notify_hotplug(struct platform_device *pdev)

[...]

Quoted 17 lines
drivers/usb/renesas_usbhs/common.c +17 -0
+static struct renesas_usbhs_platform_info *usbhs_parse_dt(struct device *dev)
+{
+	struct renesas_usbhs_platform_info *info;
+	struct renesas_usbhs_driver_param *dparam;
+	const struct of_device_id *of_id = of_match_device(usbhs_of_match, dev);
+	u32 tmp;
+	int gpio;
+
+	info = devm_kzalloc(dev, sizeof(*info), GFP_KERNEL);
+	if (!info)
+		return NULL;
+
+	dparam = &info->driver_param;
+	dparam->type = of_id ? (u32)of_id->data : 0;
+	if (!of_property_read_u32(dev->of_node, "renesas,buswait", &tmp))
+		dparam->buswait_bwait = tmp;
+	gpio = of_get_named_gpio_flags(dev->of_node, "renesas,enable-gpio", 0,
Quoted 8 lines

drivers/usb/renesas_usbhs/common.c static int usbhsc_drvcllbck_notify_hotplug(struct platform_device *pdev) · line 477

Quoted 5 lines
drivers/usb/renesas_usbhs/common.c +5 -0
+				       NULL);
+	if (gpio > 0)
+		dparam->enable_gpio = gpio;
+
+	return info;

I don't see where you parse the optional "phy" property. It should exist
for the Lager and Koelsch boards you target.

Quoted 6 lines

Since I wrote 'phy-names: must be "usb"' in the document, I intend to use a fixed property for "phy" driver like the following:

	phy = phy_get(&pdev->dev, "usb");

Is this a bad code?

Seems OK.

Quoted 2 lines

About using the phy driver in renesas_usbhs driver, I intend to modify the drivers/usb/renesas_usbhs/rcar.c.

Hm, it slready supports 'struct usb_phy'. Also PHYs are not limited to
R-Car Gen2 SoCs...

Quoted 2 lines

Best regards,
Yoshihiro Shimoda

WBR, Sergei

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 542B21DE.4010903-M4DtvfQ/[email protected]

#7 lore raw
Quoted 45 lines · Sergei Shtylyov
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines

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.

---
   drivers/usb/renesas_usbhs/common.c |   44
++++++++++++++++++++++++++++++++++++
   1 file changed, 44 insertions(+)
drivers/usb/renesas_usbhs/common.c +0 -0
index 1b9bf8d..b3b6813 100644

[...]

Quoted 29 lines
Quoted 29 lines
Quoted 2 lines
drivers/usb/renesas_usbhs/common.c +0 -0
@@ -438,6 +440,43 @@ static int usbhsc_drvcllbck_notify_hotplug(struct
 platform_device *pdev)

[...]

Quoted 13 lines

+static struct renesas_usbhs_platform_info *usbhs_parse_dt(struct device *dev)

drivers/usb/renesas_usbhs/common.c +11 -0
+{
+    struct renesas_usbhs_platform_info *info;
+    struct renesas_usbhs_driver_param *dparam;
+    const struct of_device_id *of_id = of_match_device(usbhs_of_match, dev);
+    u32 tmp;
+    int gpio;
+
+    info = devm_kzalloc(dev, sizeof(*info), GFP_KERNEL);
+    if (!info)
+        return NULL;
+

drivers/usb/renesas_usbhs/common.c

Quoted 10 lines
drivers/usb/renesas_usbhs/common.c +10 -0
+    dparam = &info->driver_param;
+    dparam->type = of_id ? (u32)of_id->data : 0;
+    if (!of_property_read_u32(dev->of_node, "renesas,buswait", &tmp))
+        dparam->buswait_bwait = tmp;
+    gpio = of_get_named_gpio_flags(dev->of_node, "renesas,enable-gpio", 0,
+                       NULL);
+    if (gpio > 0)
+        dparam->enable_gpio = gpio;
+
+    return info;

I don't see where you parse the optional "phy" property. It should exist
for the Lager and Koelsch boards you target.

[...]

Quoted 5 lines
Quoted 2 lines

About using the phy driver in renesas_usbhs driver, I intend to modify the drivers/usb/renesas_usbhs/rcar.c.

Hm, it slready supports 'struct usb_phy'. Also PHYs are not limited to
R-Car Gen2 SoCs...

OK, let's do this locally to rcar2.c for now. But since you still haven't
provided the patches and I'm tasked with the USBHS support, I have to take the further development in my hands.

Quoted 2 lines
Quoted 2 lines

Best regards,
Yoshihiro Shimoda

WBR, Sergei

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#8 lore raw

Hello.

Quoted 53 lines · Sergei Shtylyov
Quoted 45 lines · Sergei Shtylyov
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines

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.

---
   drivers/usb/renesas_usbhs/common.c |   44
++++++++++++++++++++++++++++++++++++
   1 file changed, 44 insertions(+)
drivers/usb/renesas_usbhs/common.c +0 -0
index 1b9bf8d..b3b6813 100644

[...]

Quoted 29 lines
Quoted 29 lines
Quoted 2 lines
drivers/usb/renesas_usbhs/common.c +0 -0
@@ -438,6 +440,43 @@ static int usbhsc_drvcllbck_notify_hotplug(struct
 platform_device *pdev)

[...]

Quoted 13 lines

+static struct renesas_usbhs_platform_info *usbhs_parse_dt(struct device *dev)

drivers/usb/renesas_usbhs/common.c +11 -0
+{
+    struct renesas_usbhs_platform_info *info;
+    struct renesas_usbhs_driver_param *dparam;
+    const struct of_device_id *of_id = of_match_device(usbhs_of_match, dev);
+    u32 tmp;
+    int gpio;
+
+    info = devm_kzalloc(dev, sizeof(*info), GFP_KERNEL);
+    if (!info)
+        return NULL;
+

drivers/usb/renesas_usbhs/common.c

Quoted 10 lines
drivers/usb/renesas_usbhs/common.c +10 -0
+    dparam = &info->driver_param;
+    dparam->type = of_id ? (u32)of_id->data : 0;
+    if (!of_property_read_u32(dev->of_node, "renesas,buswait", &tmp))
+        dparam->buswait_bwait = tmp;
+    gpio = of_get_named_gpio_flags(dev->of_node, "renesas,enable-gpio", 0,
+                       NULL);
+    if (gpio > 0)
+        dparam->enable_gpio = gpio;
+
+    return info;

I don't see where you parse the optional "phy" property. It should exist
for the Lager and Koelsch boards you target.

[...]

Quoted 2 lines
Quoted 2 lines

About using the phy driver in renesas_usbhs driver, I intend to modify the drivers/usb/renesas_usbhs/rcar.c.

Quoted 6 lines
Quoted 2 lines

Hm, it slready supports 'struct usb_phy'. Also PHYs are not limited to
R-Car Gen2 SoCs...

OK, let's do this locally to rcar2.c for now. But since you still haven't
provided the patches and I'm tasked with the USBHS support, I have to take the further development in my hands.

Thank you for the reply. And, I'm sorry for the deleyed response. I will submit the patches (add support generic phy in rcar.c and device node for some SoCs) today.

Best regards,
Yoshihiro Shimoda

Quoted 5 lines
Quoted 2 lines
Quoted 2 lines

Best regards,
Yoshihiro Shimoda

WBR, Sergei