| From 7fc5a807ad121c4c9eb52c022037f1df5ad8a442 Mon Sep 17 00:00:00 2001 |
| From: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> |
| Date: Fri, 29 Sep 2017 20:45:01 +0900 |
| Subject: [PATCH 0231/1795] usb: gadget: udc: renesas_usb3: add support for |
| generic phy |
| |
| This patch adds support for generic phy as an optional. If you want |
| to use a generic phy (e.g. phy-rcar-gen3-usb3 driver) on this driver, |
| you have to do "insmod phy-rcar-gen3-usb3.ko" first for now. |
| |
| Acked-by: Rob Herring <robh@kernel.org> |
| Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> |
| Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com> |
| (cherry picked from commit 279d4bc6406022461713cd6a3e5411336d2ff26b) |
| Signed-off-by: Simon Horman <horms+renesas@verge.net.au> |
| Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> |
| |
| Conflicts: |
| drivers/usb/gadget/udc/renesas_usb3.c |
| --- |
| .../devicetree/bindings/usb/renesas_usb3.txt | 4 +++ |
| drivers/usb/gadget/udc/renesas_usb3.c | 26 +++++++++++++++++-- |
| 2 files changed, 28 insertions(+), 2 deletions(-) |
| |
| diff --git a/Documentation/devicetree/bindings/usb/renesas_usb3.txt b/Documentation/devicetree/bindings/usb/renesas_usb3.txt |
| index e28025883b79..87a45e2f9b7f 100644 |
| --- a/Documentation/devicetree/bindings/usb/renesas_usb3.txt |
| +++ b/Documentation/devicetree/bindings/usb/renesas_usb3.txt |
| @@ -15,6 +15,10 @@ Required properties: |
| - interrupts: Interrupt specifier for the USB3.0 Peripheral |
| - clocks: clock phandle and specifier pair |
| |
| +Optional properties: |
| + - phys: phandle + phy specifier pair |
| + - phy-names: must be "usb" |
| + |
| Example of R-Car H3 ES1.x: |
| usb3_peri0: usb@ee020000 { |
| compatible = "renesas,r8a7795-usb3-peri", |
| diff --git a/drivers/usb/gadget/udc/renesas_usb3.c b/drivers/usb/gadget/udc/renesas_usb3.c |
| index 3368cb1ac51c..ef833f5c2523 100644 |
| --- a/drivers/usb/gadget/udc/renesas_usb3.c |
| +++ b/drivers/usb/gadget/udc/renesas_usb3.c |
| @@ -1,7 +1,7 @@ |
| /* |
| * Renesas USB3.0 Peripheral driver (USB gadget) |
| * |
| - * Copyright (C) 2015 Renesas Electronics Corporation |
| + * Copyright (C) 2015-2017 Renesas Electronics Corporation |
| * |
| * 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 |
| @@ -17,6 +17,7 @@ |
| #include <linux/io.h> |
| #include <linux/module.h> |
| #include <linux/of_device.h> |
| +#include <linux/phy/phy.h> |
| #include <linux/platform_device.h> |
| #include <linux/pm_runtime.h> |
| #include <linux/sizes.h> |
| @@ -334,6 +335,7 @@ struct renesas_usb3 { |
| struct usb_gadget_driver *driver; |
| struct extcon_dev *extcon; |
| struct work_struct extcon_work; |
| + struct phy *phy; |
| struct dentry *dentry; |
| |
| struct renesas_usb3_ep *usb3_ep; |
| @@ -2247,6 +2249,9 @@ static int renesas_usb3_start(struct usb_gadget *gadget, |
| /* hook up the driver */ |
| usb3->driver = driver; |
| |
| + if (usb3->phy) |
| + phy_init(usb3->phy); |
| + |
| pm_runtime_get_sync(usb3_to_dev(usb3)); |
| |
| renesas_usb3_init_controller(usb3); |
| @@ -2263,6 +2268,9 @@ static int renesas_usb3_stop(struct usb_gadget *gadget) |
| usb3->driver = NULL; |
| renesas_usb3_stop_controller(usb3); |
| |
| + if (usb3->phy) |
| + phy_exit(usb3->phy); |
| + |
| pm_runtime_put(usb3_to_dev(usb3)); |
| |
| return 0; |
| @@ -2416,6 +2424,8 @@ static int renesas_usb3_remove(struct platform_device *pdev) |
| renesas_usb3_dma_free_prd(usb3, &pdev->dev); |
| |
| __renesas_usb3_ep_free_request(usb3->ep0_req); |
| + if (usb3->phy) |
| + phy_put(usb3->phy); |
| pm_runtime_disable(usb3_to_dev(usb3)); |
| |
| return 0; |
| @@ -2647,11 +2657,19 @@ static int renesas_usb3_probe(struct platform_device *pdev) |
| if (ret < 0) |
| goto err_dev_create; |
| |
| + /* |
| + * This is an optional. So, if this driver cannot get a phy, |
| + * this driver will not handle a phy anymore. |
| + */ |
| + usb3->phy = devm_phy_get(&pdev->dev, "usb"); |
| + if (IS_ERR(usb3->phy)) |
| + usb3->phy = NULL; |
| + |
| usb3->workaround_for_vbus = priv->workaround_for_vbus; |
| |
| renesas_usb3_debugfs_init(usb3, &pdev->dev); |
| |
| - dev_info(&pdev->dev, "probed\n"); |
| + dev_info(&pdev->dev, "probed%s\n", usb3->phy ? " with phy" : ""); |
| pm_runtime_enable(usb3_to_dev(usb3)); |
| |
| return 0; |
| @@ -2678,6 +2696,8 @@ static int renesas_usb3_suspend(struct device *dev) |
| return 0; |
| |
| renesas_usb3_stop_controller(usb3); |
| + if (usb3->phy) |
| + phy_exit(usb3->phy); |
| pm_runtime_put(dev); |
| |
| return 0; |
| @@ -2691,6 +2711,8 @@ static int renesas_usb3_resume(struct device *dev) |
| if (!usb3->driver) |
| return 0; |
| |
| + if (usb3->phy) |
| + phy_init(usb3->phy); |
| pm_runtime_get_sync(dev); |
| renesas_usb3_init_controller(usb3); |
| |
| -- |
| 2.19.0 |
| |