From patchwork Tue Dec 17 19:42:32 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Porter X-Patchwork-Id: 22615 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f70.google.com (mail-oa0-f70.google.com [209.85.219.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id CEE8C23FBC for ; Tue, 17 Dec 2013 19:42:59 +0000 (UTC) Received: by mail-oa0-f70.google.com with SMTP id m1sf24512582oag.5 for ; Tue, 17 Dec 2013 11:42:59 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=X1gsPi5gLGjH3GjCMGeO3W/uQpztEQtDk7WTGvT3Dks=; b=AT0HECdvRiNjhPtxlS1f8AOs6VElspfez29/XhUV0NcPhhW0kaXGyl5cYzMZHGK0Ju OCUU+nLCc7rZz0VZGD8/z6Om2SDQ/+flKXcg95+DgQdRqqDyfSeVnvyWLkWs5tstMcqh x5l3gi4jh8qfTMcWH2WkB+gvEF+eyDyRyIsBsX5aKPRsxFXPsusWo17luyT4dPHrdm4r ih4mSYQPkqwWivUy6sd4y3dvWL7JeCHwdINl4D8LEySrF8AC6pdWP4CaNH2OIXa8ZPV5 vtSSURp87SWWitpPDigghzsAOl8RZCC4SYMOSuC07R1McJTYFBTp+qTho9RxjoMHW4Rj jzYQ== X-Gm-Message-State: ALoCoQkGI8a/8Du0Wku3G4AnL8Sen06p5YIVNTOvmr7GSppKlwD/ZrY2VzIuHO7CmG5hoY+ciOGW X-Received: by 10.182.218.12 with SMTP id pc12mr8420662obc.35.1387309378889; Tue, 17 Dec 2013 11:42:58 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.101.39 with SMTP id fd7ls2621213qeb.16.gmail; Tue, 17 Dec 2013 11:42:58 -0800 (PST) X-Received: by 10.221.39.137 with SMTP id tm9mr157822vcb.63.1387309378761; Tue, 17 Dec 2013 11:42:58 -0800 (PST) Received: from mail-ve0-f175.google.com (mail-ve0-f175.google.com [209.85.128.175]) by mx.google.com with ESMTPS id dq5si5140333vcb.99.2013.12.17.11.42.58 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 17 Dec 2013 11:42:58 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.175 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.175; Received: by mail-ve0-f175.google.com with SMTP id jx11so4581998veb.6 for ; Tue, 17 Dec 2013 11:42:58 -0800 (PST) X-Received: by 10.58.95.97 with SMTP id dj1mr11384152veb.21.1387309378683; Tue, 17 Dec 2013 11:42:58 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.59.13.131 with SMTP id ey3csp191028ved; Tue, 17 Dec 2013 11:42:58 -0800 (PST) X-Received: by 10.50.143.10 with SMTP id sa10mr4803636igb.8.1387309377798; Tue, 17 Dec 2013 11:42:57 -0800 (PST) Received: from mail-ig0-f179.google.com (mail-ig0-f179.google.com [209.85.213.179]) by mx.google.com with ESMTPS id lo5si18407549icc.97.2013.12.17.11.42.57 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 17 Dec 2013 11:42:57 -0800 (PST) Received-SPF: neutral (google.com: 209.85.213.179 is neither permitted nor denied by best guess record for domain of mporter@linaro.org) client-ip=209.85.213.179; Received: by mail-ig0-f179.google.com with SMTP id hk11so7167391igb.0 for ; Tue, 17 Dec 2013 11:42:57 -0800 (PST) X-Received: by 10.50.40.102 with SMTP id w6mr4900121igk.20.1387309377431; Tue, 17 Dec 2013 11:42:57 -0800 (PST) Received: from beef.ohporter.com (cpe-98-27-254-98.neo.res.rr.com. [98.27.254.98]) by mx.google.com with ESMTPSA id v2sm23254399igz.3.2013.12.17.11.42.54 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 17 Dec 2013 11:42:56 -0800 (PST) From: Matt Porter To: Felipe Balbi , Greg Kroah-Hartman , Kishon Vijay Abraham I , Rob Herring , Pawel Moll , Mark Rutland , Kumar Gala , Ian Campbell , Christian Daudt , Paul Zimmerman Cc: Tomasz Figa , Kamil Debski , Kyungmin Park , Dinh Nguyen , Russell King , Linux USB List , Linux ARM Kernel List , Linux Kernel Mailing List , Devicetree List , Linaro Patches Subject: [PATCH v7 5/9] usb: gadget: s3c-hsotg: enable generic phy support Date: Tue, 17 Dec 2013 14:42:32 -0500 Message-Id: <1387309356-17195-6-git-send-email-mporter@linaro.org> X-Mailer: git-send-email 1.8.4 In-Reply-To: <1387309356-17195-1-git-send-email-mporter@linaro.org> References: <1387309356-17195-1-git-send-email-mporter@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: mporter@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.175 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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 --- drivers/usb/gadget/s3c-hsotg.c | 55 ++++++++++++++++++++++++++++++------------ 1 file changed, 39 insertions(+), 16 deletions(-) diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c index cbfbf41..8f9bcdb 100644 --- a/drivers/usb/gadget/s3c-hsotg.c +++ b/drivers/usb/gadget/s3c-hsotg.c @@ -30,6 +30,8 @@ #include #include #include +#include +#include #include #include @@ -138,6 +140,7 @@ struct s3c_hsotg_ep { * @dev: The parent device supplied to the probe function * @driver: USB gadget driver * @phy: The otg phy transceiver structure for phy control. + * @uphy: The otg phy transceiver structure for old USB 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. @@ -159,7 +162,8 @@ struct s3c_hsotg_ep { struct s3c_hsotg { struct device *dev; struct usb_gadget_driver *driver; - struct usb_phy *phy; + struct phy *phy; + struct usb_phy *uphy; struct s3c_hsotg_plat *plat; spinlock_t lock; @@ -2901,8 +2905,11 @@ static void s3c_hsotg_phy_enable(struct s3c_hsotg *hsotg) dev_dbg(hsotg->dev, "pdev 0x%p\n", pdev); - if (hsotg->phy) - usb_phy_init(hsotg->phy); + if (hsotg->phy) { + phy_init(hsotg->phy); + phy_power_on(hsotg->phy); + } else if (hsotg->uphy) + usb_phy_init(hsotg->uphy); else if (hsotg->plat->phy_init) hsotg->plat->phy_init(pdev, hsotg->plat->phy_type); } @@ -2918,8 +2925,11 @@ static void s3c_hsotg_phy_disable(struct s3c_hsotg *hsotg) { struct platform_device *pdev = to_platform_device(hsotg->dev); - if (hsotg->phy) - usb_phy_shutdown(hsotg->phy); + if (hsotg->phy) { + phy_power_off(hsotg->phy); + phy_exit(hsotg->phy); + } else if (hsotg->uphy) + usb_phy_shutdown(hsotg->uphy); else if (hsotg->plat->phy_exit) hsotg->plat->phy_exit(pdev, hsotg->plat->phy_type); } @@ -3526,7 +3536,8 @@ static void s3c_hsotg_delete_debug(struct s3c_hsotg *hsotg) 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 *phy; + struct usb_phy *uphy; struct device *dev = &pdev->dev; struct s3c_hsotg_ep *eps; struct s3c_hsotg *hsotg; @@ -3541,19 +3552,26 @@ static int s3c_hsotg_probe(struct platform_device *pdev) return -ENOMEM; } - phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2); + /* + * Attempt to find a generic PHY, then look for an old style + * USB PHY, finally fall back to pdata + */ + phy = devm_phy_get(&pdev->dev, "usb2-phy"); 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 { + uphy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2); + if (IS_ERR(uphy)) { + /* 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; + } hsotg->plat = plat; - } - } else { + } else + hsotg->uphy = uphy; + } else hsotg->phy = phy; - } hsotg->dev = dev; @@ -3620,6 +3638,9 @@ static int s3c_hsotg_probe(struct platform_device *pdev) goto err_supplies; } + if (hsotg->phy) + phy_init(hsotg->phy); + /* usb phy enable */ s3c_hsotg_phy_enable(hsotg); @@ -3713,6 +3734,8 @@ static int s3c_hsotg_remove(struct platform_device *pdev) } s3c_hsotg_phy_disable(hsotg); + if (hsotg->phy) + phy_exit(hsotg->phy); clk_disable_unprepare(hsotg->clk); return 0;