From patchwork Mon Feb 26 17:26:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 775907 Delivered-To: patch@linaro.org Received: by 2002:ab3:621a:0:b0:258:3251:9e33 with SMTP id w26csp1492337lte; Mon, 26 Feb 2024 09:26:42 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXV7ijpjtPXCpHj2MzlCRrYYXxhyr4qP6KSflkzhYRU+EcA5RAfdHqcER74WvW2UFpOHLtrNX12UV/fVOjnQOJR X-Google-Smtp-Source: AGHT+IEQlT0YcZvE2Rc1kGpfRg/zlmkyhP47uGFA8k7qFR+BhKnCR+j9+9j0CA5WtvlDNNshXS1c X-Received: by 2002:a2e:8ec5:0:b0:2d2:3820:fb4f with SMTP id e5-20020a2e8ec5000000b002d23820fb4fmr4219287ljl.12.1708968402535; Mon, 26 Feb 2024 09:26:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1708968402; cv=none; d=google.com; s=arc-20160816; b=hDP7Lm9zRUugIe1pKEjkDvnetVsOcBub9fF0Cu6G5Y8APRtrGf3SAQraUJdZqYucOF PnRvx+DcDcNVqo7ivVudgGRC9cK3++rTbOcQB4S6T/qzHNLNs+SjQ7IqDBD4nxz5DrUE FpL9QJnjJaLUq7jfZeelJQ6hnZ5UfZmEOb7msKfIJhVRfE9Iok4KD4gk78Xxzdk+kZyE kycV21U254Z24G14OtVlhJsxXesmbi70CBsU21GilIQhK1b3Sog3cXxPOqmk5Dr66Gnm Qhd+HHq5drb43mGayGFkhy81Kq1GUz80cXnnFSV2Ve0yQ5aqsKTcJxDjXG0h9IohY5yN /oTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:cc:to:in-reply-to:references :message-id:content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=gT115ImxSsstmDbYl/cOUJ4kQloLdD5lNxvH9PvgL1w=; fh=eMIFqMtX6ot1B8Fc5PRDTZri8eLPhLzTmwordugWz+g=; b=jlFGPM7P2KtNoKRkMbm1JIZGaH9nr0A37G9i8eRxfutosNExG/Rgewkse5g6krptVt fZtTfEA5nDV7+FznrsQx3kWnElpzWyLbALmNvk3b/fiMxRjQorLSp4QYRTuKBKYy0ziy /MV2yFZivPIOxLgK4U4O7fxu4IPdgRaKGJZGXWYQYSlUzh6cuYyiLqpsqf6DNyM82nvN Q3TcuJ20n4mYpCNEn8JCDGxBjvB7j18auLAQ/Bfrx8ec4OQ3JIkYikbbllwA2/e14Ipp AYIHEX3kR9radTtM86U7Bn1hamVRGvV/iSTXpcrZJ0kWtYHTEvDDbh26EzUInqCJJcoE iQvw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UnUX+q1y; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id m19-20020a05600c4f5300b004129d0414c7si2837227wmq.228.2024.02.26.09.26.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 09:26:42 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UnUX+q1y; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6B59387F56; Mon, 26 Feb 2024 18:26:30 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="UnUX+q1y"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B254D87F25; Mon, 26 Feb 2024 18:26:28 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-lj1-x235.google.com (mail-lj1-x235.google.com [IPv6:2a00:1450:4864:20::235]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id F1CC387F2C for ; Mon, 26 Feb 2024 18:26:24 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=caleb.connolly@linaro.org Received: by mail-lj1-x235.google.com with SMTP id 38308e7fff4ca-2d2533089f6so40078711fa.1 for ; Mon, 26 Feb 2024 09:26:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708968384; x=1709573184; darn=lists.denx.de; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=gT115ImxSsstmDbYl/cOUJ4kQloLdD5lNxvH9PvgL1w=; b=UnUX+q1yM6C5PpotU1U690HCDkRid9RWQf85POdLlFI8MmfYILtr4GqtlCiOXMjTn+ P5oCzb/fSh9zM6cA5+1XmS6T+JoXZzbOJLYX2nu/uj1PcuAM1DJYik58yzz0SprrhSuf IWAeV9sHUelk4A9TsIvWECB3dLaE7B20OLOeBJ03FrJvH6Uzln7sB9/vX9vizS2TRllQ 17oA5jIvQseqRSbQAjoWfhlH+d9NCh1mfHjSR7HPUGUj38ecvCTWxORG9SmLNQ+sbfmV zHmcXgtAn3D5+THzBNf+ZlzTWlyXO/n3LVjIZ7TxHFzU936bAO4ja/NuQzMqoQuVUNs/ GjOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708968384; x=1709573184; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gT115ImxSsstmDbYl/cOUJ4kQloLdD5lNxvH9PvgL1w=; b=suVoe4X6qJrR0PUYlM14QLugBtcG3oYv3zQ9rAqo0daDi3Wzo3P1J90W0q3sOSHBZ/ +3mDo2kVIBxfqBomOudkiYrtihPGYgS9Y38F+cn8FWC6/dtqQ0CxWgwCdDJPwUjP8VYh zbcOTusLs/V2mSn3YJ5VWSK7KreDnQCtNqr41mHaJg2UWTXhJSwbvUjUOtnYgd7ha7GV UrL22J8ItG6Q8/FQ9hVDF6Mit7eyQCU9+3B8jrIvMaTIWM+irhGH4EXkMUfv0EhDNomh EqNhnFdWdWPVBCRZPvvAHJsH5iHRAHKNcsRCT04HF9MaQgDieqe62My1VMWTbfcOj1A/ Z+2Q== X-Forwarded-Encrypted: i=1; AJvYcCVimJwevkWbdcPZGkgVQaKenn6Vac3EjwTKgRTWaTLn1dVz84K1U/a96iiAB6x1bG0f2/aWJGRymqyoDGijCHpZidlP6g== X-Gm-Message-State: AOJu0YxF+D6yKeirYt3j6CMs/C6QN4uaZaEV7WDoa9ygLTiIGQZxgQe9 gUH+2B5jVB6a0BJzcyz1j3CkJNkoVmJF1V+v7oiVlB4EDyLiNyD/8nkbM28qhq0= X-Received: by 2002:a2e:3a0f:0:b0:2d2:373b:5b27 with SMTP id h15-20020a2e3a0f000000b002d2373b5b27mr4506597lja.20.1708968384256; Mon, 26 Feb 2024 09:26:24 -0800 (PST) Received: from lion.localdomain (host-92-17-96-232.as13285.net. [92.17.96.232]) by smtp.gmail.com with ESMTPSA id bt1-20020a056000080100b0033d9c7eb63csm9142256wrb.84.2024.02.26.09.26.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 09:26:23 -0800 (PST) From: Caleb Connolly Date: Mon, 26 Feb 2024 17:26:06 +0000 Subject: [PATCH v5 02/39] usb: dwc3-generic: support external vbus regulator MIME-Version: 1.0 Message-Id: <20240226-b4-qcom-common-target-v5-2-10c8e078befb@linaro.org> References: <20240226-b4-qcom-common-target-v5-0-10c8e078befb@linaro.org> In-Reply-To: <20240226-b4-qcom-common-target-v5-0-10c8e078befb@linaro.org> To: Neil Armstrong , Sumit Garg , Ramon Fried , Dzmitry Sankouski , Caleb Connolly , Peng Fan , Jaehoon Chung , Rayagonda Kokatanur , Lukasz Majewski , Sean Anderson , Jorge Ramirez-Ortiz , Stephan Gerhold Cc: Marek Vasut , u-boot@lists.denx.de X-Mailer: b4 0.13-dev-4bd13 X-Developer-Signature: v=1; a=openpgp-sha256; l=2484; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=zy8d/bLtlahzsjEnrt0CqTXILH2QKUQ9ydQgSemoQQE=; b=owGbwMvMwCFYaeA6f6eBkTjjabUkhtQ7J3defPrDVH7z9wJHlp3PGuw52iVzXm8IZ2nMObnao ezaVznFjlIWBkEOBlkxRRbxE8ssm9ZettfYvuACzBxWJpAhDFycAjARcWNGhlk8pjtz+Xolb0xK WiusNSkuajdDUpHU6TvzXQv9uFvndjP8z2kUOzaR8279WnuWZF35Bcf6vmxdz/A38vLsOO6Cr2o n5wIA X-Developer-Key: i=caleb.connolly@linaro.org; a=openpgp; fpr=83B24DA7FE145076BC38BB250CD904EB673A7C47 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Add support for a vbus-supply regulator specified in devicetree. This provides generic support to avoid hardcoded GPIO configuration in board init code. Reviewed-by: Neil Armstrong Signed-off-by: Caleb Connolly --- Cc: Marek Vasut --- drivers/usb/dwc3/dwc3-generic.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c index 6fb2de8a5ace..a379a0002e77 100644 --- a/drivers/usb/dwc3/dwc3-generic.c +++ b/drivers/usb/dwc3/dwc3-generic.c @@ -20,8 +20,9 @@ #include #include #include #include +#include #include #include "core.h" #include "gadget.h" #include @@ -46,8 +47,9 @@ struct dwc3_generic_priv { struct dwc3_generic_host_priv { struct xhci_ctrl xhci_ctrl; struct dwc3_generic_priv gen_priv; + struct udevice *vbus_supply; }; static int dwc3_generic_probe(struct udevice *dev, struct dwc3_generic_priv *priv) @@ -239,23 +241,39 @@ static int dwc3_generic_host_probe(struct udevice *dev) rc = dwc3_generic_probe(dev, &priv->gen_priv); if (rc) return rc; + rc = device_get_supply_regulator(dev, "vbus-supply", &priv->vbus_supply); + if (rc) + debug("%s: No vbus regulator found: %d\n", dev->name, rc); + + /* Only returns an error if regulator is valid and failed to enable due to a driver issue */ + rc = regulator_set_enable_if_allowed(priv->vbus_supply, true); + if (rc) + return rc; + hccr = (struct xhci_hccr *)priv->gen_priv.base; hcor = (struct xhci_hcor *)(priv->gen_priv.base + HC_LENGTH(xhci_readl(&(hccr)->cr_capbase))); - return xhci_register(dev, hccr, hcor); + rc = xhci_register(dev, hccr, hcor); + if (rc) + regulator_set_enable_if_allowed(priv->vbus_supply, false); + + return rc; } static int dwc3_generic_host_remove(struct udevice *dev) { struct dwc3_generic_host_priv *priv = dev_get_priv(dev); int rc; - rc = xhci_deregister(dev); + /* This function always returns 0 */ + xhci_deregister(dev); + + rc = regulator_set_enable_if_allowed(priv->vbus_supply, false); if (rc) - return rc; + debug("%s: Failed to disable vbus regulator: %d\n", dev->name, rc); return dwc3_generic_remove(dev, &priv->gen_priv); }