From nobody Thu Feb 2 11:25:55 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4P6xLD1tGpz3cxbd; Thu, 2 Feb 2023 11:25:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4P6xLD0H8bz4C9V; Thu, 2 Feb 2023 11:25:56 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675337156; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=bjc5kI1PD/WOuBqoUfPmgInYRMWEfQSYroawez/O104=; b=I/GXcAFBDBIhNpN6S3y8Ta5r+MaDU7lZkCK9Hj5mfd/otF3USdv/KmFXvWM52m2VVaQFyZ o8q2iA2iIwJ3+OmVrKnoY8SwBawsGHztWjYG501SEjdbmVLWDPDCLu5rFqAoLyT6fQg9Vm 4VxITVEUug3rKyCtZE9Vc0ovAWQMuVKpF75z/DX7gxXh1X3QN2xEcyx9NWbEPytzlTyVDU JoAc4ZmAxlzZne/Adqge2w46rboP2mu4crC5YBiBsv11HIXvidEGdL+zi0n37FiVT78U0h vPR3A2Qc9F74icBG6lfDaK9VM7R7p4hDbNnCWSaTd3b9I2sADwsM3NQSru6B6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675337156; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=bjc5kI1PD/WOuBqoUfPmgInYRMWEfQSYroawez/O104=; b=Ktdlt/N70aiWzOegOnLiQmMfshwVWeSR82FB8x4jZve254bbN3lpbUODAWKQGFdF7AWFuM j65MkK3zEdBiuYkaeMpP1ORPQIR6zeG+WlulyeXfkCiGoC8W8uD3vbQ7RVFpspNCvRBV8f T/+dZo1n6a4dD4j7DREhP9ea2Pwpx9UQ4YmbSomxg3TIidnkvP7lW7LTOxiU2Uh6V98jgm UAIoQDDr57x5AJw6ooeyYsjbVr24nygHuB8GOSAihGS4KmkgXp9tW3aIFLUZG5mFtTT9CJ DNLfrwIvCerPMEI1nwB8JP7G6oI5UW3KyXYF8n+M2OUht84sMYlyn6z7iWeH+g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1675337156; a=rsa-sha256; cv=none; b=x7e3rRqXrG1AKN/LAX9T0Vsoqieq2KpSHbQC49gNiKYA/AcYWQqydppesscHZtaetyjLIH tz+6EDzSwbeOtgSwukfRPqZt1O8EhWdEu3qmnQdjkayMgNDrY+PH9YGjJUeAEPLd+Lk2MV /blVRhcLq+fFgqvjjGfqQRfULkUSBQv29TR9TCAKkDRgztWEVFO4WbdrpCk1mCB3IrO4ta fMoZCYNIa60NcFRbeY0OAc68f6V4DqM8Y4CpiZM5XvMGMqN0mgPFqEDXwiInMTHItLZ+dC VT/Cy7ybl2q+RK2x07Yvr7f7HnHVNBUYNAtiLD27X08p5+/Z5qigxtN7ytHy1Q== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4P6xLC6TWqzsdt; Thu, 2 Feb 2023 11:25:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 312BPtZZ091174; Thu, 2 Feb 2023 11:25:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 312BPtT0091173; Thu, 2 Feb 2023 11:25:55 GMT (envelope-from git) Date: Thu, 2 Feb 2023 11:25:55 GMT Message-Id: <202302021125.312BPtT0091173@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Emmanuel Vadot Subject: git: e83f76ac2188 - stable/13 - usb/dwc3: Only force USB2 based on the PHY register and IP version List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: manu X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: e83f76ac2188ae7aaf9913d352c23940b9e385d7 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by manu: URL: https://cgit.FreeBSD.org/src/commit/?id=e83f76ac2188ae7aaf9913d352c23940b9e385d7 commit e83f76ac2188ae7aaf9913d352c23940b9e385d7 Author: Emmanuel Vadot AuthorDate: 2022-11-15 12:54:49 +0000 Commit: Emmanuel Vadot CommitDate: 2023-02-02 11:25:47 +0000 usb/dwc3: Only force USB2 based on the PHY register and IP version We shouldn't force USB2 only based on if we have an external PHY. The internal PHY register tell us what link speed we can acheive and we need to force USB2 only if it cannot do USB3. This is only available after revision 0x290A of the dwc3 IP. Reviewed by: andrew Differential Revision: https://reviews.freebsd.org/D37394 Fixed: 1331c0f44b6a ("Add support for RockChip RK356X to DWC3 driver.") Sponsored by: Beckhoff Automation GmbH & Co. KG (cherry picked from commit d47f5f2886f082281ae6f97dd5fe9440ad31e6d5) --- sys/dev/usb/controller/dwc3.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/sys/dev/usb/controller/dwc3.c b/sys/dev/usb/controller/dwc3.c index 40405927685e..d5e3b3f50a9d 100644 --- a/sys/dev/usb/controller/dwc3.c +++ b/sys/dev/usb/controller/dwc3.c @@ -458,12 +458,19 @@ snps_dwc3_common_attach(device_t dev, bool is_fdt) error = phy_get_by_ofw_name(dev, node, "usb3-phy", &usb3_phy); if (error == 0 && usb3_phy != NULL) phy_enable(usb3_phy); - else { - reg = DWC3_READ(sc, DWC3_GUCTL1); - if (bootverbose) - device_printf(dev, "Forcing USB2 clock only\n"); - reg |= DWC3_GUCTL1_DEV_FORCE_20_CLK_FOR_30_CLK; - DWC3_WRITE(sc, DWC3_GUCTL1, reg); + if (sc->snpsversion == DWC3_IP_ID) { + if (sc->snpsrevision >= 0x290A) { + uint32_t hwparams3; + + hwparams3 = DWC3_READ(sc, DWC3_GHWPARAMS3); + if (DWC3_HWPARAMS3_SSPHY(hwparams3) == DWC3_HWPARAMS3_SSPHY_DISABLE) { + reg = DWC3_READ(sc, DWC3_GUCTL1); + if (bootverbose) + device_printf(dev, "Forcing USB2 clock only\n"); + reg |= DWC3_GUCTL1_DEV_FORCE_20_CLK_FOR_30_CLK; + DWC3_WRITE(sc, DWC3_GUCTL1, reg); + } + } } snps_dwc3_configure_phy(sc, node); skip_phys: