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: 169233 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp3525580ilk; Fri, 19 Jul 2019 01:13:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqz3D5nOxYvrRP5sfnjtimhyBhMbCuJr3Ze5+E9oQ5S0Z311pC+qSb10hFJ5DaSL5ZnMSrvz X-Received: by 2002:a63:460c:: with SMTP id t12mr52415901pga.69.1563524006322; Fri, 19 Jul 2019 01:13:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563524006; cv=none; d=google.com; s=arc-20160816; b=LcFntgwymZcyf/bW3JgrifBizp83GNF9jGQ4TTmpsH+dWFwY+K8w/worn4MYEn+H6M HFm4tYNzrga8yNcz7yPJhKY179m93EyhGw4SNHCiTW96XrniHy8NyPKmA+ItphJbGwSc saXiyMejfduI3uwdpNVfghgkK///NpsQiY4FFYiAUHvrwl2pmuoGrBtqsq5x6+h/m8cz N5sot8okI/cTP6wroBh++O1oWDz4STuHXZMqPsftqX8FCM1Or4R6AZAlFMdb9+myjGNE /jkQm4Ekiw2HEfvKx4e/vQ53HNwvCmCaY0Q6Vwo7atUzKm6ob2t5FomSsRUuzMYXiLk7 tX5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:cms-type:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature:dkim-filter; bh=X+0sRSBwj49+/ldRgneHCL3di9djaWyRquWJEnNhSZw=; b=AfQLcYtBJHpedaJSgadA03W7U4qOHZzEt3Nn7ICjcOxg4nxesTTkviM+xPAhKrVUQo Ivi5pp/d8G96ashFWLNoHzAYPPXabMlkdSlH5GknchAkiqFWhWmUqeiZaXVcbEbCOij5 PGSpXQz0SFqngJJc+A975zBYwTrarigIMRW5haA5Ayw5OuiTEikzROzvEsgLX6eFLf/H xgWgk/jMnPwfBA7Ed9Hj9kLnMzgXA4lMQ/nzb+pbn9kGDh7HXondZTnpMc+VNiRwpNfa D4zTAn2vFqZVc8uZ8BLgdybIyWzrCbgkwyYPFDXijtw1zBRLWNqc7jqUJs55gSeNBK5S Jcxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=o4h5eIMs; spf=pass (google.com: best guess record for domain of linux-samsung-soc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-samsung-soc-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q15si1951470pgt.150.2019.07.19.01.13.26; Fri, 19 Jul 2019 01:13:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-samsung-soc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=o4h5eIMs; spf=pass (google.com: best guess record for domain of linux-samsung-soc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-samsung-soc-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726320AbfGSINZ (ORCPT + 3 others); Fri, 19 Jul 2019 04:13:25 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:52110 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726239AbfGSINZ (ORCPT ); Fri, 19 Jul 2019 04:13:25 -0400 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20190719081324euoutp0271f689ef4e74ec67904e415e05f9e09b~ywMxJUXYD2057320573euoutp02V for ; Fri, 19 Jul 2019 08:13:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20190719081324euoutp0271f689ef4e74ec67904e415e05f9e09b~ywMxJUXYD2057320573euoutp02V 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+BepUGYnTk3tYIBqaGSUenlsL1d3DKHG5aQbUCmuJw8cvgl3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4g1NDc0tLA3Njc2NzSyUxHk7BA7GCAmkJ5akZqemFqQWwfQx 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-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org 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 --- drivers/usb/core/hcd.c | 7 +++++++ drivers/usb/core/phy.c | 21 +++++++++++++++++++++ drivers/usb/core/phy.h | 1 + 3 files changed, 29 insertions(+) -- 2.17.1 Tested-by: Anand Moon Tested-by: Jochen Sprickerhof 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);