Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp1742585pxb; Sat, 14 Nov 2020 00:17:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJw7SWwclv+UAg5r8+E+s5TCvLbSMW0t4FWjxhoaZjBjHO4eY1A5hBx4IgXeXJ0RjCpc1Njx X-Received: by 2002:a17:906:4748:: with SMTP id j8mr5558647ejs.22.1605341851456; Sat, 14 Nov 2020 00:17:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605341851; cv=none; d=google.com; s=arc-20160816; b=0G5WQZL6q5rWRDrDnOSVjQ0n61Y+JVXta/4mq16d8zt3kxr370PDLN6aYLw1Jazyap Xn9KX5AzgIRGsYNr0BjR0SJEjqaJ7A0ZpQN8Syw6sGoBgIlhEAaqLlPrG7khihhTkL8p 4HDWCC+aW7axlBO/nUhX/tzKdTlKVlhhcS8I+j7U/2P6gUNwGHKCa8aBaGNDbzIhXXaQ xj7fPMAC26COVmKN8phNNDv/JECn5c79GaxxqfCIBFe5f4p/7a3/+KpOD24qknXzvvyL 0DGILRODyCHd5ziTpbeCGU5PsKRW1XxUz4aBxisxX6foO6/5KY83QpzfNAGACgiZKSIm tRHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dmarc-filter:sender:dkim-signature; bh=gM6smahYGSlYh/yqa/mC96B6/Ar1CKsusJG/IRBqBuI=; b=RFiGp3iWJPhSMoLz2iNtNt0S5cDeQx5My7Lp79DZUjT+27Qg6Y3sARHRLAr1qNTaKZ TfyGZoe3GvoVVtSyDkqWVNX08REOZRkLUgXZRHK6ui6xxL1krbh4WqhGldF67x73tMQj gab1l1o5iowgV44qqvIiSFeOeVQ/wYSk8miHLSPaCI30K1sikLNo4ilSkYX2zfjQp/bW rDBqN6E9jG6f+PAIO3MiXS6VKaGsixt9mAT6q3WtmTBlaackm1gP1a3LNgqxOgRLGq83 fNucd/mW63Q/hTjxaz55JyEL/aGu0hWjBnInfzKYfCE/U5j/JdVOONlq20EwM5+54Z4a +Stg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=XI1YpGcn; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u23si7957480ejj.163.2020.11.14.00.17.09; Sat, 14 Nov 2020 00:17:31 -0800 (PST) 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=@mg.codeaurora.org header.s=smtp header.b=XI1YpGcn; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726621AbgKNINB (ORCPT + 99 others); Sat, 14 Nov 2020 03:13:01 -0500 Received: from m42-4.mailgun.net ([69.72.42.4]:52693 "EHLO m42-4.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726610AbgKNINB (ORCPT ); Sat, 14 Nov 2020 03:13:01 -0500 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1605341580; h=Content-Transfer-Encoding: MIME-Version: References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=gM6smahYGSlYh/yqa/mC96B6/Ar1CKsusJG/IRBqBuI=; b=XI1YpGcnbOTCPm1d4o3o2zjAhJAFKwPWehuGDa7rhaaYAhtZsczfNUKT87LbHEuQQr2tHF9L rGlF92Gg9Bv6cgimh1o4toYLGarElDmLKEEqrNnKkI+51kEOeWZN0JJawd+9nWCddDm5zn6Z ITelEoYLcuWS8OSS2ut4F/t/V3A= X-Mailgun-Sending-Ip: 69.72.42.4 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n04.prod.us-east-1.postgun.com with SMTP id 5faf9185c3c3b090043a987b (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Sat, 14 Nov 2020 08:12:53 GMT Sender: wcheng=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 84461C433CB; Sat, 14 Nov 2020 08:12:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=ALL_TRUSTED,BAYES_00,SPF_FAIL, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from wcheng-linux.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: wcheng) by smtp.codeaurora.org (Postfix) with ESMTPSA id 7BC87C433C8; Sat, 14 Nov 2020 08:12:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 7BC87C433C8 Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=fail smtp.mailfrom=wcheng@codeaurora.org From: Wesley Cheng To: balbi@kernel.org, gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, jackp@codeaurora.org, Wesley Cheng Subject: [PATCH 1/3] usb: dwc3: gadget: Introduce a DWC3 VBUS draw callback Date: Sat, 14 Nov 2020 00:12:45 -0800 Message-Id: <20201114081247.25063-2-wcheng@codeaurora.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20201114081247.25063-1-wcheng@codeaurora.org> References: <20201114081247.25063-1-wcheng@codeaurora.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Some devices support charging while in device mode. In these situations, the USB gadget will notify the DWC3 gadget driver to modify the current based on the enumeration and device state. The usb_phy_set_power() API will allow external charger entities to adjust the charge current through the notifier block. Signed-off-by: Wesley Cheng --- drivers/usb/dwc3/gadget.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index c145da1d8ba5..69122f66978e 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -2387,6 +2387,16 @@ static void dwc3_gadget_set_speed(struct usb_gadget *g, spin_unlock_irqrestore(&dwc->lock, flags); } +static int dwc3_gadget_vbus_draw(struct usb_gadget *g, unsigned int mA) +{ + struct dwc3 *dwc = gadget_to_dwc(g); + + if (dwc->usb2_phy) + return usb_phy_set_power(dwc->usb2_phy, mA); + + return 0; +} + static const struct usb_gadget_ops dwc3_gadget_ops = { .get_frame = dwc3_gadget_get_frame, .wakeup = dwc3_gadget_wakeup, @@ -2396,6 +2406,7 @@ static const struct usb_gadget_ops dwc3_gadget_ops = { .udc_stop = dwc3_gadget_stop, .udc_set_speed = dwc3_gadget_set_speed, .get_config_params = dwc3_gadget_config_params, + .vbus_draw = dwc3_gadget_vbus_draw, }; /* -------------------------------------------------------------------------- */ -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project