From patchwork Tue Nov 21 09:23:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manu Gautam X-Patchwork-Id: 10067821 X-Patchwork-Delegate: agross@codeaurora.org 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 45B566022E for ; Tue, 21 Nov 2017 09:26:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 377F52022C for ; Tue, 21 Nov 2017 09:26:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2C76628AC4; Tue, 21 Nov 2017 09:26:50 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 C79E52022C for ; Tue, 21 Nov 2017 09:26:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751918AbdKUJZX (ORCPT ); Tue, 21 Nov 2017 04:25:23 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:41962 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751338AbdKUJZT (ORCPT ); Tue, 21 Nov 2017 04:25:19 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 07C986081B; Tue, 21 Nov 2017 09:25:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1511256319; bh=KQRir9KcoKsDhSbtoXcl0k0rCzH8JjQYH7sSkm/BqKw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mOuuDzQKYulaxXr51Jzd5eVpevGLgYdauNMSSSMn7HhFa/cFH7N9K9+xOEp+GDSHm dymut+b/mnbTvr/3wiHNGoZ48pl/HAflevK+Z0UAtH37W//r/kK3sM0XlXq4y+tbPW xbumj54v2cVrtiFkjL2n4om+9wAJMHtWL4TblTis= Received: from mgautam-linux.qualcomm.com (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: mgautam@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 7C53D6080B; Tue, 21 Nov 2017 09:25:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1511256318; bh=KQRir9KcoKsDhSbtoXcl0k0rCzH8JjQYH7sSkm/BqKw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WR2cwX7KeK25ycdDtKeVTF7h4nXdintDuspj5srrvZobVUmhIgdquMP6hpeQ4AkDV nE+TqkI2QHZnz8hwVExjWrFp2cOCPz9h/mkmV9puMeJzY60Bun9zbjmTdMHEM8Tjkh ffbURycC+LGiMUDksaQQYDELydv4z0TTF98x2QUg= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 7C53D6080B Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=mgautam@codeaurora.org From: Manu Gautam To: Kishon Vijay Abraham I Cc: linux-arm-msm@vger.kernel.org, linux-usb@vger.kernel.org, Manu Gautam , linux-kernel@vger.kernel.org (open list:GENERIC PHY FRAMEWORK) Subject: [PATCH v3 14/16] phy: Add notify_speed callback Date: Tue, 21 Nov 2017 14:53:24 +0530 Message-Id: <1511256206-1587-15-git-send-email-mgautam@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1511256206-1587-1-git-send-email-mgautam@codeaurora.org> References: <1511256206-1587-1-git-send-email-mgautam@codeaurora.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP QCOM USB PHYs can monitor resume/remote-wakeup event in suspended state. However PHY driver must know current operational speed of PHY in order to set correct polarity of wakeup events for detection. E.g. QUSB2 PHY monitors DP/DM signals depending on speed is LS or FS/HS to detect resume. Similarly QMP USB3 PHY in SS mode should monitor RX terminations attach/detach and LFPS events depending on SSPHY is active or not. Signed-off-by: Manu Gautam --- drivers/phy/phy-core.c | 30 ++++++++++++++++++++++++++++++ include/linux/phy/phy.h | 26 ++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index b4964b0..03df2be 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -387,6 +387,36 @@ int phy_calibrate(struct phy *phy) } EXPORT_SYMBOL_GPL(phy_calibrate); +int phy_notify_speed(struct phy *phy, enum phy_speed speed) +{ + int ret; + + if (!phy || !phy->ops->notify_speed) + return 0; + + mutex_lock(&phy->mutex); + ret = phy->ops->notify_speed(phy, speed); + mutex_unlock(&phy->mutex); + + return ret; +} +EXPORT_SYMBOL_GPL(phy_notify_speed); + +enum phy_speed phy_get_speed(struct phy *phy) +{ + enum phy_speed ret; + + if (!phy || !phy->ops->get_speed) + return PHY_SPEED_UNKNOWN; + + mutex_lock(&phy->mutex); + ret = phy->ops->get_speed(phy); + mutex_unlock(&phy->mutex); + + return ret; +} +EXPORT_SYMBOL_GPL(phy_get_speed); + /** * _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 4f8423a..9efd3cd 100644 --- a/include/linux/phy/phy.h +++ b/include/linux/phy/phy.h @@ -33,6 +33,14 @@ enum phy_mode { PHY_MODE_UFS_HS_B, }; +enum phy_speed { + PHY_SPEED_UNKNOWN, + PHY_SPEED_USB_LS, + PHY_SPEED_USB_FS, + PHY_SPEED_USB_HS, + PHY_SPEED_USB_SS, +}; + /** * struct phy_ops - set of function pointers for performing phy operations * @init: operation to be performed for initializing phy @@ -42,6 +50,8 @@ enum phy_mode { * @set_mode: set the mode of the phy * @reset: resetting the phy * @calibrate: calibrate the phy + * @notify_speed: notify phy driver of current speed of PHY + * @get_speed: get current operational speed of PHY * @owner: the module owner containing the ops */ struct phy_ops { @@ -52,6 +62,8 @@ struct phy_ops { int (*set_mode)(struct phy *phy, enum phy_mode mode); int (*reset)(struct phy *phy); int (*calibrate)(struct phy *phy); + int (*notify_speed)(struct phy *phy, enum phy_speed speed); + enum phy_speed (*get_speed)(struct phy *phy); struct module *owner; }; @@ -146,6 +158,8 @@ static inline void *phy_get_drvdata(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); +int phy_notify_speed(struct phy *phy, enum phy_speed speed); +enum phy_speed phy_get_speed(struct phy *phy); static inline int phy_get_bus_width(struct phy *phy) { return phy->attrs.bus_width; @@ -274,6 +288,18 @@ static inline int phy_calibrate(struct phy *phy) return -ENOSYS; } +static inline int phy_notify_speed(struct phy *phy, enum phy_speed speed) +{ + if (!phy) + return 0; + return -EINVAL; +} + +static inline enum phy_speed phy_get_speed(struct phy *phy) +{ + return PHY_SPEED_UNKNOWN; +} + static inline int phy_get_bus_width(struct phy *phy) { return -ENOSYS;