From patchwork Tue Apr 21 08:17:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 1274080 X-Patchwork-Delegate: marek.vasut@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=baylibre-com.20150623.gappssmtp.com header.i=@baylibre-com.20150623.gappssmtp.com header.a=rsa-sha256 header.s=20150623 header.b=Si0xFObX; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 495xK06S6Sz9sP7 for ; Tue, 21 Apr 2020 18:18:12 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 36B26804CD; Tue, 21 Apr 2020 10:18:05 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=baylibre.com 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=baylibre-com.20150623.gappssmtp.com header.i=@baylibre-com.20150623.gappssmtp.com header.b="Si0xFObX"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E66B280574; Tue, 21 Apr 2020 10:17:58 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) (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 6A554800A9 for ; Tue, 21 Apr 2020 10:17:55 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=narmstrong@baylibre.com Received: by mail-wr1-x441.google.com with SMTP id j1so9964399wrt.1 for ; Tue, 21 Apr 2020 01:17:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=C3LPGZ2DkYBx4ELdfVMIxPvPGCcgSPABTiRJ//sGZc8=; b=Si0xFObXXRgkcOfyVp/5JczYnkSZV6Yb2nAlCIzOKeEGNbFzd147WTZL151acz1QBN IjyCKEIR+9QRjkUQg8q6b+A5cMINYaTMcMHBHXlDY4jaWOdcHG7nqY3/5lIBos0pDs5k kW/fSZwUsOE9bg4dxnJ1zcGeCM/Kbnl8TJsU6zhXCMxtH7aBiuJHWzInzEtGL8hOZpnA tuFMgVj7W/fUw6R/vtWO8Cl7/XT7ze4fG01lCvr3A/sgYDYu/V31bKexc55hGxrkBBsC zDW2UzUnUt59QS+lXAu055/hXWkwYfn8FLqGzsV4lAFjzihGURU+gachBglv6J3Nyq1G myqw== 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:mime-version :content-transfer-encoding; bh=C3LPGZ2DkYBx4ELdfVMIxPvPGCcgSPABTiRJ//sGZc8=; b=hbfwczqFA5kwzTg979C+9URHb6IQJclGiWzBNdNvyjKBQqiu/LGi1ep2Ytt8uEWjFH D6asQllpU9X/dWNg9fMgfpyMlBvndkg2SAHK3B72VfoK/yH0O6YR8o3F6KA8o1pVVjtX 7bunoHloew17KYLidtLNleeN15kn/lfQ81N51TyZRMdXf8qjnfhvnYiRVyTeK5MC+eWW pyZ0HHa+DzCYIPVoTiPgR/5yKZPhgiM4D1JsqQggEOXEeqsUuW9+uaAxvZI+JP3ycUbj mSac8oUT8HG58IVyvwSMpRJSMxFCfhi8a4Qz63DGst78AcjKs1uO9Pn/hfB4MiUnC1y7 lBBw== X-Gm-Message-State: AGi0PuYjRgyZkhYmVa3d2SRjGuP1zA4DS1KdquEVfDkOMdc+4EMhyXz3 3/OErTw2VmAj4c+s15bPgID6CA== X-Google-Smtp-Source: APiQypLH9dEAFZ2KrRum++inGA2MTd1QFlsQxGTbuzqR4hPV7COLdrhJWj6otxCs1gngpNiwSD7Lhw== X-Received: by 2002:a05:6000:14c:: with SMTP id r12mr22158169wrx.62.1587457069091; Tue, 21 Apr 2020 01:17:49 -0700 (PDT) Received: from localhost.localdomain ([2a01:e35:2ec0:82b0:39cc:a07:8b48:cc56]) by smtp.gmail.com with ESMTPSA id x18sm2715886wrv.12.2020.04.21.01.17.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Apr 2020 01:17:48 -0700 (PDT) From: Neil Armstrong To: u-boot-amlogic@groups.io, marex@denx.de Cc: u-boot@lists.denx.de, Neil Armstrong Subject: [PATCH v2] usb: dwc3-meson-g12a: add power-on/off of the PHYs Date: Tue, 21 Apr 2020 10:17:42 +0200 Message-Id: <20200421081742.24628-1-narmstrong@baylibre.com> X-Mailer: git-send-email 2.22.0 MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 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.102.2 at phobos.denx.de X-Virus-Status: Clean Power on/off the PHYs to enable power to the USB ports, fixing USB support on Khadas VIM3/VIM3L boards. The G12A USB complex has at least 2 USB2 PHYs, but one is muxed between the DWC2 and DWC3 controller and the other one directly connected to the DWC3 controller. The USB3+PCIe combo PHY is muxed between the DWC3 controller and a DW-PCIE controller. All PHYs are optional, but it's type (usb2/usb3) and position are important to determine it's capabilities, thus they are stored in a fixed size array and the phy-name determines it's position, it's position determining it's type and functionnalities. This is why we need to loop over the array to power on all the DT provided PHYs. Signed-off-by: Neil Armstrong Reviewed-by: Marek Vasut --- Changes since v1: - removed extra space before semicolon - added clarification in commit message drivers/usb/dwc3/dwc3-meson-g12a.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/usb/dwc3/dwc3-meson-g12a.c b/drivers/usb/dwc3/dwc3-meson-g12a.c index d4453f8784..de964d6c10 100644 --- a/drivers/usb/dwc3/dwc3-meson-g12a.c +++ b/drivers/usb/dwc3/dwc3-meson-g12a.c @@ -408,6 +408,15 @@ static int dwc3_meson_g12a_probe(struct udevice *dev) goto err_phy_init; } + for (i = 0; i < PHY_COUNT; ++i) { + if (!priv->phys[i].dev) + continue; + + ret = generic_phy_power_on(&priv->phys[i]); + if (ret) + goto err_phy_init; + } + return 0; err_phy_init: @@ -430,6 +439,13 @@ static int dwc3_meson_g12a_remove(struct udevice *dev) clk_release_all(&priv->clk, 1); + for (i = 0; i < PHY_COUNT; ++i) { + if (!priv->phys[i].dev) + continue; + + generic_phy_power_off(&priv->phys[i]); + } + for (i = 0 ; i < PHY_COUNT ; ++i) { if (!priv->phys[i].dev) continue;