From patchwork Thu Oct 5 12:11:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Pietrasiewicz X-Patchwork-Id: 9987005 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7C020602B8 for ; Thu, 5 Oct 2017 12:15:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6793A28C5F for ; Thu, 5 Oct 2017 12:15:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5BE1428C65; Thu, 5 Oct 2017 12:15:49 +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=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E939F28C5F for ; Thu, 5 Oct 2017 12:15:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-reply-to:Message-id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=3PjZPFO21TzNVTo+LqZUpdbO5M7j5HzH6xAZcCrshNo=; b=Q2BA5OLV9LSNMuy/jtWhYoeX2R ppedqWDdKJ+l7StIrZtFQzuJ8k58cpv2AgX1dJBp5zyO9pXuZImhP77i7VERv4gW7lbBv4cBE7ULJ YRfA26T1+CEv8WNAln1GmJeOmt+zRbCrhPE8Qi33lGGcFR8Qvu5+G9ZMwbVk0VWcG1GVM3JerOes8 FNJkrU8IDS3NgzZHWiPPPa5mt7t69pvai7rxPGkEK/HjJBNadAPSCAap2I3cfXrWIroMC8jxxykc7 fsEaB9xGi5jElvvfqLsco829B8DqvMnyXshXo7zbsLh+23YNGobDbTMPjELRugcyATWe8NfHbSIqi UGdx1HXw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1e0548-0006rG-0Q; Thu, 05 Oct 2017 12:15:48 +0000 Received: from mailout2.w1.samsung.com ([210.118.77.12]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1e050y-0004a7-6e for linux-arm-kernel@lists.infradead.org; Thu, 05 Oct 2017 12:12:39 +0000 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20171005121203euoutp02d6b6d5a19f3e8b0bb4b88e4cdf1d6419~qq3Aiy7GA1249512495euoutp021; Thu, 5 Oct 2017 12:12:03 +0000 (GMT) Received: from eusmges2.samsung.com (unknown [203.254.199.241]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20171005121202eucas1p2c71fc3bb4019291c51b4176fc610179c~qq2-07vHi1097310973eucas1p2l; Thu, 5 Oct 2017 12:12:02 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2.samsung.com (EUCPMTA) with SMTP id A3.4F.12907.29126D95; Thu, 5 Oct 2017 13:12:02 +0100 (BST) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20171005121201eucas1p269da2155c4257777b0c3a5b210c651f8~qq2-GedMN0665006650eucas1p2J; Thu, 5 Oct 2017 12:12:01 +0000 (GMT) X-AuditID: cbfec7f1-f793a6d00000326b-17-59d621926eb5 Received: from eusync1.samsung.com ( [203.254.199.211]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id A3.4B.20118.19126D95; Thu, 5 Oct 2017 13:12:01 +0100 (BST) Received: from AMDC831.digital.local ([106.116.147.122]) by eusync1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OXC00HRTN7UQSB0@eusync1.samsung.com>; Thu, 05 Oct 2017 13:12:01 +0100 (BST) From: Andrzej Pietrasiewicz To: linux-samsung-soc@vger.kernel.org, linux-usb@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org Subject: [PATCHv3 1/2] drivers: phy: add calibrate method Date: Thu, 05 Oct 2017 14:11:50 +0200 Message-id: <1507205511-23048-2-git-send-email-andrzej.p@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1507205511-23048-1-git-send-email-andrzej.p@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrOIsWRmVeSWpSXmKPExsWy7djP87qTFK9FGqxaL24x62U7i8XGGetZ LY61PWG3mH/kHKtF8+L1bBb9j18zW1x42sNmcf78BnaLTY+vsVrMOL+PyWLRslZmi0NT9zJa rD1yl91i6fWLTBate4+wO/B7rJm3htHj8rWLzB6bVnWyeeyfu4bdY/OSeo++LasYPY7f2M7k 8XmTXABHFJdNSmpOZllqkb5dAlfGtRf7mQtmC1a0r8toYPzN28XIySEhYCLx6+ESRghbTOLC vfVsXYxcHEICSxkl7p+Yww7hfGaUuHzrECNMx/1921kgEsuAEucfQTkNTBLTHu5lAqliEzCW 2HuwgxEkISLQwijx/ko32CxmgbPMEg9fHGIGqRIWsJTYuukgO4jNIqAqselNFwuIzSvgKvFu /wl2iH1yEiePTWYFsTkF3CS2bbrACjJIQuA+m8SKBTdYIYpcJD43NrJB2MISr45vgWqWkbg8 uZsFom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2v3k7aIdNywcUqVFusRvmB30PvrqcTpjqjnz kzl7xL5oFzrJp+x+nrboCs++A1pt847vPmLdvPGl21r+nvIm5ivHd9z68/mLbSX/ioPZ5zu8 nzKr9muVze1X++hq5q+fX7Pv4EH2Dic7jq8ZHWKTnVU4408srF5xt6DieMBsZiWW4oxEQy3m ouJEAHdmQHFdAgAA X-CMS-MailID: 20171005121201eucas1p269da2155c4257777b0c3a5b210c651f8 X-Msg-Generator: CA X-Sender-IP: 182.198.249.180 X-Local-Sender: =?UTF-8?B?QW5kcnplaiBQaWV0cmFzaWV3aWN6G1NSUE9MLUtlcm5lbCAo?= =?UTF-8?B?VFApG+yCvOyEseyghOyekBtTZW5pb3IgU29mdHdhcmUgRW5naW5lZXI=?= X-Global-Sender: =?UTF-8?B?QW5kcnplaiBUb21hc3ogUGlldHJhc2lld2ljehtTUlBPTC1L?= =?UTF-8?B?ZXJuZWwgKFRQKRtTYW1zdW5nIEVsZWN0cm9uaWNzG1NlbmlvciBTb2Z0d2Fy?= =?UTF-8?B?ZSBFbmdpbmVlcg==?= X-Sender-Code: =?UTF-8?B?QzEwG0VIURtDMTBDRDAyQ0QwMjczOTI=?= CMS-TYPE: 201P X-CMS-RootMailID: 20171005121201eucas1p269da2155c4257777b0c3a5b210c651f8 X-RootMTR: 20171005121201eucas1p269da2155c4257777b0c3a5b210c651f8 References: <6935498c-9788-14e6-844f-f9e8288026dc@samsung.com> <1507205511-23048-1-git-send-email-andrzej.p@samsung.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171005_051232_472444_9478FDC5 X-CRM114-Status: GOOD ( 16.11 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Felipe Balbi , Bartlomiej Zolnierkiewicz , Greg Kroah-Hartman , Russell King , Krzysztof Kozlowski , Kishon Vijay Abraham I , Rob Herring , Kukjin Kim , Andrzej Pietrasiewicz , Marek Szyprowski MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Some quirky UDCs (like dwc3 on exynos) need to have heir phys calibrated e.g. for using super speed. Signed-off-by: Andrzej Pietrasiewicz --- drivers/phy/phy-core.c | 15 +++++++++++++++ include/linux/phy/phy.h | 10 ++++++++++ 2 files changed, 25 insertions(+) diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index a268f4d..b4964b0 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -372,6 +372,21 @@ int phy_reset(struct phy *phy) } EXPORT_SYMBOL_GPL(phy_reset); +int phy_calibrate(struct phy *phy) +{ + int ret; + + if (!phy || !phy->ops->calibrate) + return 0; + + mutex_lock(&phy->mutex); + ret = phy->ops->calibrate(phy); + mutex_unlock(&phy->mutex); + + return ret; +} +EXPORT_SYMBOL_GPL(phy_calibrate); + /** * _of_phy_get() - lookup and obtain a reference to a phy by phandle * @np: device_node for which to get the phy diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h index e694d40..87580c8 100644 --- a/include/linux/phy/phy.h +++ b/include/linux/phy/phy.h @@ -39,6 +39,7 @@ enum phy_mode { * @power_off: powering off the phy * @set_mode: set the mode of the phy * @reset: resetting the phy + * @calibrate: calibrate the phy * @owner: the module owner containing the ops */ struct phy_ops { @@ -48,6 +49,7 @@ struct phy_ops { int (*power_off)(struct phy *phy); int (*set_mode)(struct phy *phy, enum phy_mode mode); int (*reset)(struct phy *phy); + int (*calibrate)(struct phy *phy); struct module *owner; }; @@ -141,6 +143,7 @@ static inline void *phy_get_drvdata(struct phy *phy) int phy_power_off(struct phy *phy); int phy_set_mode(struct phy *phy, enum phy_mode mode); int phy_reset(struct phy *phy); +int phy_calibrate(struct phy *phy); static inline int phy_get_bus_width(struct phy *phy) { return phy->attrs.bus_width; @@ -262,6 +265,13 @@ static inline int phy_reset(struct phy *phy) return -ENOSYS; } +static inline int phy_calibrate(struct phy *phy) +{ + if (!phy) + return 0; + return -ENOSYS; +} + static inline int phy_get_bus_width(struct phy *phy) { return -ENOSYS;