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: 9986995 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 2D594602B8 for ; Thu, 5 Oct 2017 12:12:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 19A3628C2A for ; Thu, 5 Oct 2017 12:12:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0E54D28C70; Thu, 5 Oct 2017 12:12:23 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham 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 A1F1828C2A for ; Thu, 5 Oct 2017 12:12:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751424AbdJEMMT (ORCPT ); Thu, 5 Oct 2017 08:12:19 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:48493 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751380AbdJEMMF (ORCPT ); Thu, 5 Oct 2017 08:12:05 -0400 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 Cc: Andrzej Pietrasiewicz , Marek Szyprowski , Bartlomiej Zolnierkiewicz , Krzysztof Kozlowski , Kukjin Kim , Russell King , Mark Rutland , Rob Herring , Kishon Vijay Abraham I , Felipe Balbi , Greg Kroah-Hartman 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+NgFvrOIsWRmVeSWpSXm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xaGpexkt 1h65y26x9PpFJovWvUfYHfg91sxbw+hx+dpFZo9NqzrZPPbPXcPusXlJvUffllWMHsdvbGfy +LxJLoAjissmJTUnsyy1SN8ugSvj2ov9zAWzBSva12U0MP7m7WLk5JAQMJG4v287C4QtJnHh 3nq2LkYuDiGBJYwS64/eg3KamCSaF9xlBKliEzCW2HuwgxEkISLQwijReXELmMMscJ5ZouXL ArAqYQFLia2bDrKD2CwCqhKb3nSB7eAVcJV4t/8EO8Q+OYmTxyazgticAm4S2zZdALOFBKok zj6dxDSBkXcBI8MqRpHU0uLc9NxiI73ixNzi0rx0veT83E2MwBDeduznlh2MXe+CDzEKcDAq 8fAyPLgSKcSaWFZcmXuIUYKDWUmE95LotUgh3pTEyqrUovz4otKc1OJDjNIcLErivL17VkcK CaQnlqRmp6YWpBbBZJk4OKUaGNv83ba1/WYJ2v3k7aIdNywcUqVFusRvmB30PvrqcTpjqjnz 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> Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.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;