From patchwork Fri Jul 19 08:13:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 11049829 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AF2BB746 for ; Fri, 19 Jul 2019 08:13:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A2BC5288BB for ; Fri, 19 Jul 2019 08:13:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 96647288CA; Fri, 19 Jul 2019 08:13:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3196B288BB for ; Fri, 19 Jul 2019 08:13:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727159AbfGSINZ (ORCPT ); Fri, 19 Jul 2019 04:13:25 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:34662 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726271AbfGSINZ (ORCPT ); Fri, 19 Jul 2019 04:13:25 -0400 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20190719081324euoutp01dd671372dff7ca42f4f55eff42e01982~ywMxTpMaZ0994709947euoutp015 for ; Fri, 19 Jul 2019 08:13:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20190719081324euoutp01dd671372dff7ca42f4f55eff42e01982~ywMxTpMaZ0994709947euoutp015 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1563524004; bh=X+0sRSBwj49+/ldRgneHCL3di9djaWyRquWJEnNhSZw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=o4h5eIMs/RDjPAI4xXM1uaYMkHxDHsaDFHOa7AYSHq8Z09wF32DqxO+FGDrjiBVJx IQFD+oE75zyYsG/uVLv5oV4Awt57KzWr3QV+U5sRsRIqwRYIKdttizCDJ/3w+7JYpl mBhYygvffpuBoFfIcF54ftDJCkzPdY2Ws4wPdHL4= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20190719081323eucas1p1b1a4d7092531d08be1dc47ddfc96ac15~ywMwbRYNz0104801048eucas1p1q; Fri, 19 Jul 2019 08:13:23 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 26.53.04325.3AB713D5; Fri, 19 Jul 2019 09:13:23 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20190719081322eucas1p1f3114c43ca3c53b60766edf1846347cc~ywMvd-epk2477124771eucas1p1M; Fri, 19 Jul 2019 08:13:22 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20190719081322eusmtrp1ae3099dc895de74ea0360e8553bd63f5~ywMvUA0oY0401704017eusmtrp1E; Fri, 19 Jul 2019 08:13:22 +0000 (GMT) X-AuditID: cbfec7f5-b75ff700000010e5-6e-5d317ba3a4a5 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 1E.17.04140.2AB713D5; Fri, 19 Jul 2019 09:13:22 +0100 (BST) Received: from AMDC2765.DIGITAL.local (unknown [106.120.51.73]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20190719081321eusmtip2047069aab218be661f3ac23c15eccea4~ywMutCK2M3248932489eusmtip2l; Fri, 19 Jul 2019 08:13:21 +0000 (GMT) From: Marek Szyprowski To: linux-usb@vger.kernel.org, linux-samsung-soc@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Marek Szyprowski , Mathias Nyman , Felipe Balbi , Bartlomiej Zolnierkiewicz , Krzysztof Kozlowski , Jochen Sprickerhof , Anand Moon Subject: [PATCH v2 1/2] usb: core: phy: add support for PHY calibration Date: Fri, 19 Jul 2019 10:13:16 +0200 Message-Id: <20190719081316.9298-1-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190719081212.9249-1-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprFKsWRmVeSWpSXmKPExsWy7djP87qLqw1jDV4tEbbYOGM9q8Wxtifs Fs2L17NZLP17j9Hi/PkN7BaXd81hs5hxfh+TxaJlrcwW6zbeYrdYe+QuUN2mKawO3B47Z91l 91i85yWTx6ZVnWwe++euYffo27KK0WPDln8sHp83yQWwR3HZpKTmZJalFunbJXBl9K2OLtgr VnH0QStrA2O7cBcjJ4eEgInEjQk/2boYuTiEBFYwSix89RfK+cIo8fpAFxOE85lR4t+Eneww LY83HWKHSCxnlFi6+ykzXEvn79dMIFVsAoYSXW+72EBsEQEHiSVL74DNZRb4zyQx/cYJVpCE sIC7ROfTB0A2BweLgKpEwxNBkDCvgI3Ess6jjBDb5CVWbzjADGJzCthKTGi4BbZZQmA6u8Tf P2+ZIYpcJJ5c/sUEYQtLvDq+BepUGYnTk3tYIBqaGSUenlsL1d3DKHG5aQbUCmuJw8cvgl3B LKApsX6XPkTYUeL45AcsIGEJAT6JG2/BjmMGMidtm84ME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WwfQx cXBKNTBu2n1d5fHfFbceNEwvvvfvdO/mXdxTU+5/cZwfe/JrfUP1dDclrlwuP5+ZjyWaDL8a Tc9ynt4Q0dc17YqbDPdJ7bLMvA+frr+okCz7zLJsrlNIRKHvKlXribpibzTD/Er+X21eJm0k srcmd84d6aMxj5s3Z/Pktdo/nXl04XnV32+eh1Y1v5irxFKckWioxVxUnAgAoSil1I0CAAA= X-CMS-MailID: 20190719081322eucas1p1f3114c43ca3c53b60766edf1846347cc X-Msg-Generator: CA X-RootMTR: 20190719081322eucas1p1f3114c43ca3c53b60766edf1846347cc X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20190719081322eucas1p1f3114c43ca3c53b60766edf1846347cc References: <20190719081212.9249-1-m.szyprowski@samsung.com> Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Some PHYs (for example Exynos5 USB3.0 DRD PHY) require calibration to be done after every USB HCD reset. Generic PHY framework has been already extended with phy_calibrate() function in commit 36914111e682 ("drivers: phy: add calibrate method"). This patch adds support for it to generic PHY handling code in USB HCD core. Signed-off-by: Marek Szyprowski Tested-by: Anand Moon Tested-by: Jochen Sprickerhof --- drivers/usb/core/hcd.c | 7 +++++++ drivers/usb/core/phy.c | 21 +++++++++++++++++++++ drivers/usb/core/phy.h | 1 + 3 files changed, 29 insertions(+) diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index 88533938ce19..b89936c1df23 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c @@ -2291,6 +2291,9 @@ int hcd_bus_resume(struct usb_device *rhdev, pm_message_t msg) hcd->state = HC_STATE_RESUMING; status = hcd->driver->bus_resume(hcd); clear_bit(HCD_FLAG_WAKEUP_PENDING, &hcd->flags); + if (status == 0) + status = usb_phy_roothub_calibrate(hcd->phy_roothub); + if (status == 0) { struct usb_device *udev; int port1; @@ -2864,6 +2867,10 @@ int usb_add_hcd(struct usb_hcd *hcd, } hcd->rh_pollable = 1; + retval = usb_phy_roothub_calibrate(hcd->phy_roothub); + if (retval) + goto err_hcd_driver_setup; + /* NOTE: root hub and controller capabilities may not be the same */ if (device_can_wakeup(hcd->self.controller) && device_can_wakeup(&hcd->self.root_hub->dev)) diff --git a/drivers/usb/core/phy.c b/drivers/usb/core/phy.c index 7580493b867a..fb1588e7c282 100644 --- a/drivers/usb/core/phy.c +++ b/drivers/usb/core/phy.c @@ -151,6 +151,27 @@ int usb_phy_roothub_set_mode(struct usb_phy_roothub *phy_roothub, } EXPORT_SYMBOL_GPL(usb_phy_roothub_set_mode); +int usb_phy_roothub_calibrate(struct usb_phy_roothub *phy_roothub) +{ + struct usb_phy_roothub *roothub_entry; + struct list_head *head; + int err; + + if (!phy_roothub) + return 0; + + head = &phy_roothub->list; + + list_for_each_entry(roothub_entry, head, list) { + err = phy_calibrate(roothub_entry->phy); + if (err) + return err; + } + + return 0; +} +EXPORT_SYMBOL_GPL(usb_phy_roothub_calibrate); + int usb_phy_roothub_power_on(struct usb_phy_roothub *phy_roothub) { struct usb_phy_roothub *roothub_entry; diff --git a/drivers/usb/core/phy.h b/drivers/usb/core/phy.h index dad564e2d2d4..20a267cd986b 100644 --- a/drivers/usb/core/phy.h +++ b/drivers/usb/core/phy.h @@ -18,6 +18,7 @@ int usb_phy_roothub_exit(struct usb_phy_roothub *phy_roothub); int usb_phy_roothub_set_mode(struct usb_phy_roothub *phy_roothub, enum phy_mode mode); +int usb_phy_roothub_calibrate(struct usb_phy_roothub *phy_roothub); int usb_phy_roothub_power_on(struct usb_phy_roothub *phy_roothub); void usb_phy_roothub_power_off(struct usb_phy_roothub *phy_roothub);