Received: by 10.223.164.202 with SMTP id h10csp4905755wrb; Tue, 21 Nov 2017 01:27:48 -0800 (PST) X-Google-Smtp-Source: AGs4zMYe9ZrnprrfHntq3qfqtu/nhYbnBBe0YywZ9OqIivkrBQ1c/ntplX+nXHbQs3wt0pprr9NE X-Received: by 10.84.215.207 with SMTP id g15mr16606566plj.369.1511256468436; Tue, 21 Nov 2017 01:27:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511256468; cv=none; d=google.com; s=arc-20160816; b=M64yp+yJEaGlGTjynif+UIVHaLFPTZSduK6emRz/IiIH/UXVyznKk8/SP3qCio6MSc 1pyzm8rEk2EMGufVIhxH8vlBo9BJ8tMAccK0jpzvCGVCFn7Ss9DUwEsANn0vqikezf9s Jr/5KVKbLdDWNJOd2laNgKxYWPuJdrZ2lmI5aImNWANH5DmrQ8LRtUpFkssOtSuK0v4o 3/n5dSeZsOCtMAnbKu3GP3gnDPzcWfUSnMLiRRc37G/XtKV5Hic6v+UtQD9lIvuzr1VS otQ27hihvQfA6GtP2nmu1h1dD0Pg39sW0Edkduxh3tO8lQdZCeKz/OVfGgvjD9fO0gOc 3Vnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dmarc-filter:dkim-signature:dkim-signature :arc-authentication-results; bh=ispbyVlG3OoJuSDNrlBMZUnAslRNTrjzauP3YmtqK5w=; b=aqTh0/Yz0AFtw8tpm/jfzXHa2mihZH60UM77kJIt9NpG1rccCNHetzKhI9THL6441y XscwU+rrQka7Ig+GnP1/YY87mby3txO59xogOr8rhDpiq9jM4rwgWC6hyr6+2qry1URE AAxfkI1i9y/lWfVCxYUsjtfhOndtO7HWeWgcVPC2qiKvHfvmG8nGtDziCVM/ktqKJ+Mk cwbrGc9IMST679yssKvX5mZ2LaaDXuUSsxmGBzB0R04l1xg6zLF5zKxfgBInH+6L7d4r qTfF1OoX7Rfgldeibc/eoTr8YQDKBa80LQGXnUpVoprGGlCmZxDiSHqj/1MxqOfdRTxx XTzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=mOuuDzQK; dkim=pass header.i=@codeaurora.org header.s=default header.b=WR2cwX7K; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n69si11482192pfk.214.2017.11.21.01.27.38; Tue, 21 Nov 2017 01:27:48 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=@codeaurora.org header.s=default header.b=mOuuDzQK; dkim=pass header.i=@codeaurora.org header.s=default header.b=WR2cwX7K; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751915AbdKUJZX (ORCPT + 72 others); 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= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project From 1586462975364717818@xxx Mon Dec 11 05:09:53 +0000 2017 X-GM-THRID: 1586462975364717818 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread