From patchwork Tue Oct 3 12:59:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Pietrasiewicz X-Patchwork-Id: 9982737 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 475A060375 for ; Tue, 3 Oct 2017 13:00:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3878428995 for ; Tue, 3 Oct 2017 13:00:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2CAC628999; Tue, 3 Oct 2017 13:00:06 +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 B92BD28995 for ; Tue, 3 Oct 2017 13:00:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753824AbdJCNAD (ORCPT ); Tue, 3 Oct 2017 09:00:03 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:47577 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753781AbdJCM7u (ORCPT ); Tue, 3 Oct 2017 08:59:50 -0400 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20171003125946euoutp01d0f6fe8df0b21e1a20f1454c127aedbb~qEOGy7Bcy1440214402euoutp01D; Tue, 3 Oct 2017 12:59:46 +0000 (GMT) Received: from eusmges2.samsung.com (unknown [203.254.199.241]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20171003125946eucas1p1f618ab230481947f049a9ef95994d5fc~qEOGIeb8Z2153121531eucas1p1Z; Tue, 3 Oct 2017 12:59:46 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2.samsung.com (EUCPMTA) with SMTP id F2.AD.12907.1C983D95; Tue, 3 Oct 2017 13:59:45 +0100 (BST) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20171003125945eucas1p24d49f5c51ea9acd59a76314158b69352~qEOFgEy1o1801418014eucas1p2M; Tue, 3 Oct 2017 12:59:45 +0000 (GMT) X-AuditID: cbfec7f1-f793a6d00000326b-14-59d389c1f386 Received: from eusync4.samsung.com ( [203.254.199.214]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id E4.EE.20118.1C983D95; Tue, 3 Oct 2017 13:59:45 +0100 (BST) Received: from AMDC831.digital.local ([106.116.147.122]) by eusync4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OX90037B03F4NC0@eusync4.samsung.com>; Tue, 03 Oct 2017 13:59:45 +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: [PATCHv2 1/2] drivers: phy: add calibrate method Date: Tue, 03 Oct 2017 14:59:37 +0200 Message-id: <1507035578-24945-2-git-send-email-andrzej.p@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1507035578-24945-1-git-send-email-andrzej.p@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrGIsWRmVeSWpSXmKPExsWy7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FoWSuzxaGpexkt 1h65y26x9PpFJovWvUfYHfg91sxbw+hx+dpFZo9NqzrZPPbPXcPusXlJvUffllWMHsdvbGfy +LxJLoAjissmJTUnsyy1SN8ugStjxo51TAXfBCoW/mplbWC8wdvFyMkhIWAicX77eyYIW0zi wr31bF2MXBxCAksYJfZunccM4TQxSay71s0CUsUmYCyx92AHI0hCRKCFUaLz4hYwh1ngPLNE y5cFjCBVwgKWEo3fr4F1sAioSpy4958dxOYVcJVY0zKfGWKfnMTJY5NZQWxOATeJZeu+gtUL CZRKzLy7lX0CI+8CRoZVjCKppcW56bnFRnrFibnFpXnpesn5uZsYgUG87djPLTsYu94FH2IU 4GBU4uHd4XEpUog1say4MvcQowQHs5IIL2/z5Ugh3pTEyqrUovz4otKc1OJDjNIcLErivL17 VkcKCaQnlqRmp6YWpBbBZJk4OKUaGGe0W7x/0LtSv0VeMGnz2Qln0w8cN+DSXb/62kZd2+7T tkaG+nqWup4vmHwdRWvKBcMXJ2g//JMVfuldszBDgb7rOgaVrH/Mp81ri6QTff/MWMn8alOt vatX/9RXU15Imqw1ahF5OiP3sSW/+s+1Fxg+smae0q7jPz5t1YXi476epg59C3leK7EUZyQa ajEXFScCANi4pqheAgAA X-CMS-MailID: 20171003125945eucas1p24d49f5c51ea9acd59a76314158b69352 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: 20171003125945eucas1p24d49f5c51ea9acd59a76314158b69352 X-RootMTR: 20171003125945eucas1p24d49f5c51ea9acd59a76314158b69352 References: <1507035578-24945-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 | 14 ++++++++++++++ include/linux/phy/phy.h | 10 ++++++++++ 2 files changed, 24 insertions(+) diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index a268f4d..fdf343a 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -372,6 +372,20 @@ 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; +} + /** * _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;