linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: matt.porter@linaro.org (Matt Porter)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 5/9] usb: gadget: s3c-hsotg: enable generic phy support
Date: Fri,  1 Nov 2013 15:45:54 -0400	[thread overview]
Message-ID: <1383335158-19730-6-git-send-email-matt.porter@linaro.org> (raw)
In-Reply-To: <1383335158-19730-1-git-send-email-matt.porter@linaro.org>

Adds support for the generic PHY subsystem. Generic PHY
support is probed and then the driver falls back to checking
for an old style USB PHY and pdata if not found.

Signed-off-by: Matt Porter <matt.porter@linaro.org>
---
 drivers/usb/gadget/s3c-hsotg.c | 54 ++++++++++++++++++++++++++++--------------
 1 file changed, 36 insertions(+), 18 deletions(-)

diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c
index 3e0c124..f97978b 100644
--- a/drivers/usb/gadget/s3c-hsotg.c
+++ b/drivers/usb/gadget/s3c-hsotg.c
@@ -34,6 +34,7 @@
 #include <linux/usb/ch9.h>
 #include <linux/usb/gadget.h>
 #include <linux/usb/phy.h>
+#include <linux/phy/phy.h>
 #include <linux/platform_data/s3c-hsotg.h>
 
 #include "s3c-hsotg.h"
@@ -131,7 +132,8 @@ struct s3c_hsotg_ep {
  * struct s3c_hsotg - driver state.
  * @dev: The parent device supplied to the probe function
  * @driver: USB gadget driver
- * @phy: The otg phy transceiver structure for phy control.
+ * @phy: The otg phy transceiver structure for old USB phy control.
+ * @gphy: The otg phy transceiver structure for generic phy control.
  * @plat: The platform specific configuration data. This can be removed once
  * all SoCs support usb transceiver.
  * @regs: The memory area mapped for accessing registers.
@@ -154,6 +156,7 @@ struct s3c_hsotg {
 	struct device		 *dev;
 	struct usb_gadget_driver *driver;
 	struct usb_phy		*phy;
+	struct phy		*gphy;
 	struct s3c_hsotg_plat	 *plat;
 
 	spinlock_t              lock;
@@ -2820,9 +2823,12 @@ static void s3c_hsotg_phy_enable(struct s3c_hsotg *hsotg)
 
 	dev_dbg(hsotg->dev, "pdev 0x%p\n", pdev);
 
-	if (hsotg->phy)
+	if (hsotg->gphy) {
+		phy_init(hsotg->gphy);
+		phy_power_on(hsotg->gphy);
+	} else if (hsotg->phy) {
 		usb_phy_init(hsotg->phy);
-	else if (hsotg->plat->phy_init)
+	} else if (hsotg->plat->phy_init)
 		hsotg->plat->phy_init(pdev, hsotg->plat->phy_type);
 }
 
@@ -2837,9 +2843,12 @@ static void s3c_hsotg_phy_disable(struct s3c_hsotg *hsotg)
 {
 	struct platform_device *pdev = to_platform_device(hsotg->dev);
 
-	if (hsotg->phy)
+	if (hsotg->gphy) {
+		phy_power_off(hsotg->gphy);
+		phy_exit(hsotg->gphy);
+	} else if (hsotg->phy) {
 		usb_phy_shutdown(hsotg->phy);
-	else if (hsotg->plat->phy_exit)
+	} else if (hsotg->plat->phy_exit)
 		hsotg->plat->phy_exit(pdev, hsotg->plat->phy_type);
 }
 
@@ -3446,6 +3455,7 @@ static int s3c_hsotg_probe(struct platform_device *pdev)
 {
 	struct s3c_hsotg_plat *plat = dev_get_platdata(&pdev->dev);
 	struct usb_phy *phy;
+	struct phy *gphy;
 	struct device *dev = &pdev->dev;
 	struct s3c_hsotg_ep *eps;
 	struct s3c_hsotg *hsotg;
@@ -3460,19 +3470,27 @@ static int s3c_hsotg_probe(struct platform_device *pdev)
 		return -ENOMEM;
 	}
 
-	phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
-	if (IS_ERR(phy)) {
-		/* Fallback for pdata */
-		plat = dev_get_platdata(&pdev->dev);
-		if (!plat) {
-			dev_err(&pdev->dev, "no platform data or transceiver defined\n");
-			return -EPROBE_DEFER;
-		} else {
-			hsotg->plat = plat;
-		}
-	} else {
-		hsotg->phy = phy;
-	}
+	/*
+	 * Attempt to find a generic PHY, then look for an old style
+	 *  USB PHY, finally fall back to pdata
+	 */
+	gphy = devm_phy_get(dev, "usb2-phy");
+	if (IS_ERR(gphy)) {
+		phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
+		if (IS_ERR(phy)) {
+			/* Fallback for pdata */
+			plat = dev_get_platdata(&pdev->dev);
+			if (!plat) {
+				dev_err(&pdev->dev,
+					"no platform data or transceiver defined\n");
+				return -EPROBE_DEFER;
+			} else {
+				hsotg->plat = plat;
+			}
+		} else
+			hsotg->phy = phy;
+	} else
+		hsotg->gphy = gphy;
 
 	hsotg->dev = dev;
 
-- 
1.8.4

  parent reply	other threads:[~2013-11-01 19:45 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-01 19:45 [PATCH v2 0/9] USB Device Controller support for BCM281xx Matt Porter
2013-11-01 19:45 ` [PATCH v2 1/9] phy: add phy_get_bus_width()/phy_set_bus_width() calls Matt Porter
2013-11-02 13:14   ` Tomasz Figa
2013-11-02 17:16     ` Kishon Vijay Abraham I
2013-11-02 17:47       ` Matt Porter
2013-11-02 17:58         ` Tomasz Figa
2013-11-04  6:04           ` Kishon Vijay Abraham I
2013-11-01 19:45 ` [PATCH v2 2/9] staging: dwc2: update DT binding to add generic clock/phy properties Matt Porter
2013-11-01 19:45 ` [PATCH v2 3/9] usb: gadget: s3c-hsotg: enable build for other platforms Matt Porter
2013-11-01 19:45 ` [PATCH v2 4/9] usb: gadget: s3c-hsotg: add snps, dwc2 compatible string Matt Porter
2013-11-01 19:45 ` Matt Porter [this message]
2013-11-02 13:09   ` [PATCH v2 5/9] usb: gadget: s3c-hsotg: enable generic phy support Tomasz Figa
2013-11-02 17:52     ` Matt Porter
2013-11-01 19:45 ` [PATCH v2 6/9] usb: gadget: s3c-hsotg: get phy bus width from phy subsystem Matt Porter
2013-11-01 19:45 ` [PATCH v2 7/9] phy: add Broadcom Kona USB2 PHY DT binding Matt Porter
2013-11-01 20:54   ` Arend van Spriel
2013-11-01 22:56     ` Matt Porter
2013-11-01 19:45 ` [PATCH v2 8/9] phy: add Broadcom Kona USB2 PHY driver Matt Porter
2013-11-04  6:27   ` Kishon Vijay Abraham I
2013-11-25 14:16     ` Matt Porter
2013-11-01 19:45 ` [PATCH v2 9/9] ARM: dts: add usb udc support to bcm281xx Matt Porter
2013-11-01 20:56   ` Sergei Shtylyov
2013-11-01 22:52     ` Matt Porter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1383335158-19730-6-git-send-email-matt.porter@linaro.org \
    --to=matt.porter@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).