Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp633762ybz; Wed, 15 Apr 2020 15:35:04 -0700 (PDT) X-Google-Smtp-Source: APiQypJwdgWNj0rAKCEprSOlm6lVzyauIoEqsB/XHC6DR/1vP7lRPcHmHyLPQOPmFZZmWyQSy7H2 X-Received: by 2002:a05:6402:94d:: with SMTP id h13mr24074651edz.192.1586990103842; Wed, 15 Apr 2020 15:35:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586990103; cv=none; d=google.com; s=arc-20160816; b=Chlq1vmAy9bCq7k5ZpVgWSkldoZ04XR7PAWag6yV1vonuxDoMZj3Pnf6GcE/vbcdVX H7MXIj0aCGVIJTym8riAwLgB3umdnqqQ1Vvo99tseASP6I5VSBW8KDP6KGnIPC5HPVn/ uXY/A8c2FBpFBzmNfbZNXI5V5WHcshSRklVdSM68NUJ0WZ/4VvnwoNX/Yfpli4HN6Uxv +jNkk7B946eF1XRfxqap/F6IYQpF+g8D+Lwikg3zJdu9ZSFf6j8GRvL29sZTPTKP0W6e xoSQ3QQXeXq3oZWt3bx7ixk0DEuAfeDcSREzkMShJui+mk69MRpIuDgdP06pxvyQYi0R IhIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:dkim-signature:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from; bh=dGYpAOijxW3GRCvoqmiBOVWTNifRfJYwZqamEi3UNkM=; b=QPRkABuIuk5OZchqrM5gRmxq8EFmxeA27vh3kA8i5NfCZA8Mn8Y8mIWXUUA7SVr6l2 hH0U+Q1Jx9TPsdhJN+m/4E4njTLcB78qz2xlat2RCOQ+AXWvz2zPQqxYkn2sqeQUQ2F/ JDmM+OomdfY8+vh2BvVzAj1x3AdJ91tNwqqiGKmLnpbzPAeTTrHpYS1nm8tr6uUUmsVe UaxK/euB2LoKIor4zBeX02pNEDHU9b+duR+O/uTotz2P6Qkyb6mRDpVFN7AJZIIBNqIz owILgHquG7YlinfvJxZktGvcluOa0DOcbd+jLv58rdVu83T/8a2xrHPgQ06BztgsCkV0 8q4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=c6nU3yHL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ch28si369659edb.247.2020.04.15.15.34.40; Wed, 15 Apr 2020 15:35:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=c6nU3yHL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2894516AbgDOI1i (ORCPT + 99 others); Wed, 15 Apr 2020 04:27:38 -0400 Received: from hqnvemgate25.nvidia.com ([216.228.121.64]:16788 "EHLO hqnvemgate25.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2894471AbgDOI1K (ORCPT ); Wed, 15 Apr 2020 04:27:10 -0400 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate25.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Wed, 15 Apr 2020 01:24:28 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Wed, 15 Apr 2020 01:25:27 -0700 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Wed, 15 Apr 2020 01:25:27 -0700 Received: from HQMAIL109.nvidia.com (172.20.187.15) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Wed, 15 Apr 2020 08:25:26 +0000 Received: from rnnvemgw01.nvidia.com (10.128.109.123) by HQMAIL109.nvidia.com (172.20.187.15) with Microsoft SMTP Server (TLS) id 15.0.1473.3 via Frontend Transport; Wed, 15 Apr 2020 08:25:26 +0000 Received: from nkristam-ubuntu.nvidia.com (Not Verified[10.19.67.128]) by rnnvemgw01.nvidia.com with Trustwave SEG (v7,5,8,10121) id ; Wed, 15 Apr 2020 01:25:25 -0700 From: Nagarjuna Kristam To: , , , , , , CC: , , , , Nagarjuna Kristam Subject: [PATCH V2 2/8] usb: gadget: tegra-xudc: Add vbus_draw support Date: Wed, 15 Apr 2020 13:55:02 +0530 Message-ID: <1586939108-10075-3-git-send-email-nkristam@nvidia.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1586939108-10075-1-git-send-email-nkristam@nvidia.com> References: <1586939108-10075-1-git-send-email-nkristam@nvidia.com> X-NVConfidentiality: public MIME-Version: 1.0 Content-Type: text/plain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1586939068; bh=dGYpAOijxW3GRCvoqmiBOVWTNifRfJYwZqamEi3UNkM=; h=X-PGP-Universal:From:To:CC:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:X-NVConfidentiality:MIME-Version: Content-Type; b=c6nU3yHL1CVuyXkrkf++DlgV8JwwzyamZnXysUsHa8WP67YMG6dd+3I8wabebFwbm bGoiqgTcmddjuD9gxGWm1bYxxejUe5l5aw6oxBqluSmCdib/uABPlvj4xiU7g2aivb Fi4v4iArRi48CWskEC1G2EkCr5zVnZchjDVZLzxZB6Sb0+sPF96dqa1Kb7xZzljrTy iNSn24KFqkXeR5IwyQZAXGMb0lfvldv4PMNmtNYx5OUFGcfzLiWNPkwiFE982XtUDW gyr9YA9U1eteSIqwh0k1b/IhapBxIr9fRo0xwILKx2vA9gmrgoQ5u83I8ygSLW44qh FkxdypfGpqdpQ== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Register vbus_draw to gadget ops and update corresponding vbus draw current to usb_phy. Signed-off-by: Nagarjuna Kristam --- V2: - Patch re-based. --- drivers/usb/gadget/udc/tegra-xudc.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/usb/gadget/udc/tegra-xudc.c b/drivers/usb/gadget/udc/tegra-xudc.c index 52a6add..9d3c109 100644 --- a/drivers/usb/gadget/udc/tegra-xudc.c +++ b/drivers/usb/gadget/udc/tegra-xudc.c @@ -492,6 +492,7 @@ struct tegra_xudc { bool powergated; struct usb_phy **usbphy; + struct usb_phy *curr_usbphy; struct notifier_block vbus_nb; struct completion disconnect_complete; @@ -719,6 +720,7 @@ static int tegra_xudc_vbus_notify(struct notifier_block *nb, if (!xudc->suspended && phy_index != -1) { xudc->curr_utmi_phy = xudc->utmi_phy[phy_index]; xudc->curr_usb3_phy = xudc->usb3_phy[phy_index]; + xudc->curr_usbphy = usbphy; schedule_work(&xudc->usb_role_sw_work); } @@ -2042,6 +2044,19 @@ static int tegra_xudc_gadget_stop(struct usb_gadget *gadget) return 0; } +static int tegra_xudc_gadget_vbus_draw(struct usb_gadget *gadget, + unsigned int m_a) +{ + struct tegra_xudc *xudc = to_xudc(gadget); + + dev_dbg(xudc->dev, "%s: %u mA\n", __func__, m_a); + + if (xudc->curr_usbphy->chg_type == SDP_TYPE) + usb_phy_set_power(xudc->curr_usbphy, m_a); + + return 0; +} + static int tegra_xudc_set_selfpowered(struct usb_gadget *gadget, int is_on) { struct tegra_xudc *xudc = to_xudc(gadget); @@ -2058,6 +2073,7 @@ static struct usb_gadget_ops tegra_xudc_gadget_ops = { .pullup = tegra_xudc_gadget_pullup, .udc_start = tegra_xudc_gadget_start, .udc_stop = tegra_xudc_gadget_stop, + .vbus_draw = tegra_xudc_gadget_vbus_draw, .set_selfpowered = tegra_xudc_set_selfpowered, }; -- 2.7.4