From patchwork Fri Jan 20 18:50:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 9529271 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 BA79F60434 for ; Fri, 20 Jan 2017 18:53:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AFAF92040D for ; Fri, 20 Jan 2017 18:53:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A48B9286A2; Fri, 20 Jan 2017 18:53:52 +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=-1.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_SORBS_SPAM,T_DKIM_INVALID autolearn=no 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 4F0072040D for ; Fri, 20 Jan 2017 18:53:52 +0000 (UTC) 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 1cUeJq-0003yJ-Ug; Fri, 20 Jan 2017 18:53:50 +0000 Received: from mail-pg0-f47.google.com ([74.125.83.47]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cUeIR-000202-Hl for linux-arm-kernel@lists.infradead.org; Fri, 20 Jan 2017 18:52:26 +0000 Received: by mail-pg0-f47.google.com with SMTP id 194so25576699pgd.2 for ; Fri, 20 Jan 2017 10:52:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=1IpWcgUTmLVlQ2BjgLx73U6iz+Or+DLLkJ487QgzWOc=; b=GNlpKimaZkP6P1VxUruCFQ0GnhDSVPxmtCCiJQMNTf34+onpuO1r+SEDlUZl6WwmCP OLyE2qnq4e/n4gs/UewGHJ4BDxydu3/goemDa+X3Xi0FAQYNJWYiRkJ6/dRgL/I0jtv+ A+FNFumJowdAu8vcr3A+nRRkDcpNWQgywn/P4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=1IpWcgUTmLVlQ2BjgLx73U6iz+Or+DLLkJ487QgzWOc=; b=emVBqaQbM+uPQEg7G6HeFGfKLbFl9SaJAbVHs6kCPzxQlyoH5Ak9v92vDXXx40hSDd eDU6O7mqEj1LwnKjdDI7yQyIxIFgqk5gROjRtbJPEcvImifj85TxndsdtXP82HzAxLEy dMV+k84DYID+TygY9CtXqp6003OGs6sTCAXMjlqDZCJ1ze8JAKkzGiFlkZFYJ55FPQk/ njB9/8kFdUxiLBTNFJqroj5i6DZgWDp9EVM38CfgGVGG8ebXwLbkhP1Litwoq50AZ3kX gF15oIGHdB4lO6sv4mnaKWWQqiQdnDiycH6T8B2eP2jSSZdUvD54Gd9bVEP2V23CUz+q mi/A== X-Gm-Message-State: AIkVDXKFt6D44D2CZzfAgm7ckkkXb9z6dQo8G7Z4d6NGDFBQt9TmNG+nEHeqGVLzYGxnAZs6 X-Received: by 10.84.254.74 with SMTP id a10mr23482645pln.57.1484938262858; Fri, 20 Jan 2017 10:51:02 -0800 (PST) Received: from localhost.localdomain (i-global254.qualcomm.com. [199.106.103.254]) by smtp.gmail.com with ESMTPSA id j78sm18574274pfk.39.2017.01.20.10.51.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 20 Jan 2017 10:51:02 -0800 (PST) From: Stephen Boyd To: Peter Chen , Kishon Vijay Abraham I Subject: [PATCH v7 3/5] phy: Add set_vbus callback Date: Fri, 20 Jan 2017 10:50:55 -0800 Message-Id: <20170120185057.16206-4-stephen.boyd@linaro.org> X-Mailer: git-send-email 2.10.0.297.gf6727b0 In-Reply-To: <20170120185057.16206-1-stephen.boyd@linaro.org> References: <20170120185057.16206-1-stephen.boyd@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170120_105223_686008_62D7956E X-CRM114-Status: GOOD ( 12.61 ) 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: Felipe Balbi , Arnd Bergmann , Neil Armstrong , linux-arm-msm@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Bjorn Andersson , Andy Gross , linux-arm-kernel@lists.infradead.org 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 USB PHYs need to be told about vbus changing state explicitly. For example the qcom USB HS PHY needs to toggle a bit when vbus goes from low to high (VBUSVLDEXT) to cause the "session valid" signal to toggle. This signal will pull up D+ when the phy starts running. If the vbus signal isn't routed to the PHY this "session valid" signal won't ever toggle, so we have to toggle it explicitly. This callback is used to do that. Cc: Peter Chen Signed-off-by: Stephen Boyd --- New patch 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 a268f4d6f3e9..8b1a6bfa5133 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -357,6 +357,21 @@ int phy_set_mode(struct phy *phy, enum phy_mode mode) } EXPORT_SYMBOL_GPL(phy_set_mode); +int phy_set_vbus(struct phy *phy, int on) +{ + int ret; + + if (!phy || !phy->ops->set_vbus) + return 0; + + mutex_lock(&phy->mutex); + ret = phy->ops->set_vbus(phy, on); + mutex_unlock(&phy->mutex); + + return ret; +} +EXPORT_SYMBOL_GPL(phy_set_vbus); + int phy_reset(struct phy *phy) { int ret; diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h index 78bb0d7f6b11..4d1ebde7fb14 100644 --- a/include/linux/phy/phy.h +++ b/include/linux/phy/phy.h @@ -36,6 +36,7 @@ enum phy_mode { * @power_on: powering on the phy * @power_off: powering off the phy * @set_mode: set the mode of the phy + * @set_vbus: enable/disable vbus in the phy (USB) * @reset: resetting the phy * @owner: the module owner containing the ops */ @@ -45,6 +46,7 @@ struct phy_ops { int (*power_on)(struct phy *phy); int (*power_off)(struct phy *phy); int (*set_mode)(struct phy *phy, enum phy_mode mode); + int (*set_vbus)(struct phy *phy, int on); int (*reset)(struct phy *phy); struct module *owner; }; @@ -138,6 +140,7 @@ int phy_exit(struct phy *phy); int phy_power_on(struct phy *phy); int phy_power_off(struct phy *phy); int phy_set_mode(struct phy *phy, enum phy_mode mode); +int phy_set_vbus(struct phy *phy, int on); int phy_reset(struct phy *phy); static inline int phy_get_bus_width(struct phy *phy) { @@ -253,6 +256,13 @@ static inline int phy_set_mode(struct phy *phy, enum phy_mode mode) return -ENOSYS; } +static inline int phy_set_vbus(struct phy *phy, int on) +{ + if (!phy) + return 0; + return -ENOSYS; +} + static inline int phy_reset(struct phy *phy) { if (!phy)