From patchwork Thu Dec 19 14:23:06 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Porter X-Patchwork-Id: 22634 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vb0-f70.google.com (mail-vb0-f70.google.com [209.85.212.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 056E523FCA for ; Thu, 19 Dec 2013 14:23:33 +0000 (UTC) Received: by mail-vb0-f70.google.com with SMTP id w5sf1270910vbf.1 for ; Thu, 19 Dec 2013 06:23:33 -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=DwIe993vfeHc+GYdsaiTdLDlnmrZkwP4W2aUTQRJ4Bjr+HWMt0WB8OhuUMWkwLoG+S 3wZVy8PnHCIRECo5vpjKPt+OWccMluEfQelYqySWUiYv2l6dRY6fXg7ZhGz4qHrtOzHW Qj/WfwLd2tfTA28zFk+mcZK9o9dbWTRCJ0DqRzKDhT8LmKLWRHK9ndT/v/3rR/QnmGW7 /0ZBtGdq31umugIoRebAJemL2KXfTuj2u2EYxygAAB6hmrWuiarsIfUtDQxkkHvv/VLV 0FaQ3WWv8WTjdZtilFOySDhLTW2gXmiZ9EpvTYBr3YOHtwafCV8ZYUpiuypMzXWblpom Uctw== X-Gm-Message-State: ALoCoQkQY/7otuKmd8CbiDOWFUOcAxCd8GTPQqPaBZx2XCRCqIc3PNumncDASDGEYDMAWYTgATFh X-Received: by 10.224.38.206 with SMTP id c14mr829701qae.4.1387463013180; Thu, 19 Dec 2013 06:23:33 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.36.2 with SMTP id m2ls365781qej.40.gmail; Thu, 19 Dec 2013 06:23:33 -0800 (PST) X-Received: by 10.52.98.194 with SMTP id ek2mr949871vdb.11.1387463012920; Thu, 19 Dec 2013 06:23:32 -0800 (PST) Received: from mail-vb0-f46.google.com (mail-vb0-f46.google.com [209.85.212.46]) by mx.google.com with ESMTPS id tl2si730943vdc.25.2013.12.19.06.23.32 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 19 Dec 2013 06:23:32 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.46 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.46; Received: by mail-vb0-f46.google.com with SMTP id w20so663732vbb.19 for ; Thu, 19 Dec 2013 06:23:32 -0800 (PST) X-Received: by 10.220.98.201 with SMTP id r9mr8969vcn.34.1387463012826; Thu, 19 Dec 2013 06:23:32 -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 ey3csp323641ved; Thu, 19 Dec 2013 06:23:32 -0800 (PST) X-Received: by 10.50.78.229 with SMTP id e5mr2302340igx.49.1387463011923; Thu, 19 Dec 2013 06:23:31 -0800 (PST) Received: from mail-ie0-f177.google.com (mail-ie0-f177.google.com [209.85.223.177]) by mx.google.com with ESMTPS id mg9si4075314icc.24.2013.12.19.06.23.31 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 19 Dec 2013 06:23:31 -0800 (PST) Received-SPF: neutral (google.com: 209.85.223.177 is neither permitted nor denied by best guess record for domain of mporter@linaro.org) client-ip=209.85.223.177; Received: by mail-ie0-f177.google.com with SMTP id tp5so1309177ieb.8 for ; Thu, 19 Dec 2013 06:23:31 -0800 (PST) X-Received: by 10.42.24.138 with SMTP id w10mr1250491icb.22.1387463011632; Thu, 19 Dec 2013 06:23:31 -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 l7sm5656642igx.2.2013.12.19.06.23.29 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 19 Dec 2013 06:23:30 -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 v8 5/9] usb: gadget: s3c-hsotg: enable generic phy support Date: Thu, 19 Dec 2013 09:23:06 -0500 Message-Id: <1387462990-12039-6-git-send-email-mporter@linaro.org> X-Mailer: git-send-email 1.8.4 In-Reply-To: <1387462990-12039-1-git-send-email-mporter@linaro.org> References: <1387462990-12039-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.212.46 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;