From patchwork Fri Dec 8 21:04:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Edwards X-Patchwork-Id: 176034 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp5719460vqy; Fri, 8 Dec 2023 13:05:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IHir2VCYXjBUuhhh1jjbhg6EuMpdL6TbtATzgjHLjjtfVYwcGYCbkUTUgvRHKInaOJBchB5 X-Received: by 2002:a17:90a:6c02:b0:286:6cc1:2cd8 with SMTP id x2-20020a17090a6c0200b002866cc12cd8mr587912pjj.98.1702069531369; Fri, 08 Dec 2023 13:05:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702069531; cv=none; d=google.com; s=arc-20160816; b=ioxwmqKjMOLDYJP1lAQSr1e/+6J4A5Is49FwxoAglwFfEYVbGYUUOOx4+acZD7uWzq VyfKHusEL4Vi/XGeCX1hLGtPZLw7NkPzeLCItyibfhbjjbbeSDe3GCB2/4L+TPfhXI3N XmCeUB8/WZQ4nIauQPCR9QOhiHfPB1QuBs+qaQ0pgn0kTV/m3GHlWWnFV87BYNsbDj5E IRczWE+kkg/7OZOp0NJSwGsHPQEZcioFd6CobsdHL0KtA4SVipRMtGYrZpCdJ0sIqPNe F/eRWPHbFMTC3FYvnprDILypdEDKP0tLIdtrGjIIyejBUoClzTt+A+HAWIdJtqGJbVE0 KGXw== 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 :dkim-signature; bh=X7JrVD5PKv0frUWLpY5zIGIkfAkbUXW6B5RnmTRZ8nk=; fh=d9TSyadBXPDybutOgGlYLsH9jqXf9pJuF0lO8Gj/Fg4=; b=Z8E2ZV7Eryjf78xSpL8eMIf1IxSWSgAbNGsW2U+SNn8U4/sCrmw5iakVYwcABG4hz7 4//YK/BQ6hP707w1XoL12PJp3f042WrJgA9KKLzPxHB00jXSjSnKaEDCbWGgdQlwyvDI B+Gor8i17/9btVHb6gywdlGQnokukEoN1T5IN/awuQNBd8EeJ4sGfRy5ndlPSjIz0Gk3 unBfxg8XcOZQA5x67IYkHfPBu8YOQZ8tLiZkLlKOW3uawdq2DJAES/jAwGzOIMCw5JWl EwHtF5Zc7RKa7cQlISDQWwyY9arefa5KkUIC7oI7xJfGWclTaphwhA77kMvySuhNjnXU Dwyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=e2xgLwD9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id pm17-20020a17090b3c5100b002869aab8f55si2212859pjb.52.2023.12.08.13.05.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Dec 2023 13:05:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=e2xgLwD9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 3ABCB8359395; Fri, 8 Dec 2023 13:05:26 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234293AbjLHVFM (ORCPT + 99 others); Fri, 8 Dec 2023 16:05:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1574766AbjLHVFJ (ORCPT ); Fri, 8 Dec 2023 16:05:09 -0500 Received: from mail-il1-x12e.google.com (mail-il1-x12e.google.com [IPv6:2607:f8b0:4864:20::12e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C0601738; Fri, 8 Dec 2023 13:05:14 -0800 (PST) Received: by mail-il1-x12e.google.com with SMTP id e9e14a558f8ab-35d718382b7so9075705ab.1; Fri, 08 Dec 2023 13:05:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702069513; x=1702674313; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=X7JrVD5PKv0frUWLpY5zIGIkfAkbUXW6B5RnmTRZ8nk=; b=e2xgLwD9psUc+MsvWqMkW0QrVy1p0uKRYDewy97dmO5ey/Rys1z/H0JNaItbtnh7xK /HliAnS4ZAUKIjS5Dwu72S7MQRWXpnmkRgAfVIZHXO2zilbmZIhRdE2JgQIvYrYnquJb 766YkWrtr7l8W4jT18oIBywEk4lkvuu5QccI8HZrgqHkUg1AL589delH3zltxMVfMQdP XiE1PfRzTdZ1jQlvLl24y+Cg19sMSpAUF4bveL2oGrb4gZVL+penr1J57P9Ee7bzbXox AlCcUYt3SQKzUtq2EAQpcLQFmiJRx/QfPWbmpiqmcyqWsZBFtyvPpXaK5IdJviTKUukI 8AnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702069513; x=1702674313; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=X7JrVD5PKv0frUWLpY5zIGIkfAkbUXW6B5RnmTRZ8nk=; b=l7NRnQPxLN1x1QXx+4mYAWJ6if9+KR764tJj4fQzEtwR2LcE6dXUn0uDnWXx98dyxn XThi24Br2CXje+1f2JOhUF2CerxSWcoeZG/gSIwUzHLLuPL+vJHwyh9AUWMW8fHKxgIc etCi7E6TVF/iXBzb2UJskgedjnQXsFeS2UklQzzd7B5iCH8Nhcp0JUEYKMZcD3Ns8fqX oGxqGWAp19o6KsVK5i5haE8mpGJlSbCFFVApdA8PbMXY8PSdtx+/Nd/fFs9cRFRaM0mN o/+uelPkhDHqkuF///8SDIITY9IzsjMUWXOTscNgvDYXlICn1E7GYTkPuV1eMiQdvpGs lFMg== X-Gm-Message-State: AOJu0YyrHz0bB/Ywzt27bdUmbVaCMdRVQ2J/XZ9AqmgPFaRlDhpUqKyh 6NKUFtAIbs1F8Yli0z/xPlM= X-Received: by 2002:a92:c248:0:b0:35c:50f7:b18c with SMTP id k8-20020a92c248000000b0035c50f7b18cmr934433ilo.0.1702069513690; Fri, 08 Dec 2023 13:05:13 -0800 (PST) Received: from celestia.nettie.lan ([2001:470:42c4:101:971d:15c7:de39:3b4b]) by smtp.gmail.com with ESMTPSA id g12-20020a056e020d0c00b0035d5a1760c1sm736458ilj.69.2023.12.08.13.05.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Dec 2023 13:05:13 -0800 (PST) From: Sam Edwards X-Google-Original-From: Sam Edwards To: Mathias Nyman , Thinh Nguyen Cc: Greg Kroah-Hartman , Heiko Stuebner , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Sam Edwards Subject: [PATCH 1/2] xhci: Introduce "disable-usb3" DT property/quirk Date: Fri, 8 Dec 2023 14:04:57 -0700 Message-ID: <20231208210458.912776-2-CFSworks@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231208210458.912776-1-CFSworks@gmail.com> References: <20231208210458.912776-1-CFSworks@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Fri, 08 Dec 2023 13:05:26 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784749261092088691 X-GMAIL-MSGID: 1784749261092088691 Some systems may have xHCI controllers that enumerate USB 3.0 ports, but these ports nevertheless cannot be used. Perhaps enabling them triggers a hardware bug, or perhaps they simply aren't connected and it would be confusing to the user to see an unusable USB 3.0 rhub show up -- whatever the case may be, it's reasonable to want to disable these ports. Add a DT property (and associated quirk) to the xHCI driver that skips over (i.e. ignores and doesn't initialize) any USB 3.0 ports discovered during driver initialization. Signed-off-by: Sam Edwards --- Documentation/devicetree/bindings/usb/usb-xhci.yaml | 4 ++++ drivers/usb/host/xhci-mem.c | 4 ++++ drivers/usb/host/xhci-plat.c | 3 +++ drivers/usb/host/xhci.h | 1 + 4 files changed, 12 insertions(+) diff --git a/Documentation/devicetree/bindings/usb/usb-xhci.yaml b/Documentation/devicetree/bindings/usb/usb-xhci.yaml index 180a261c3e8f..8a64e747260a 100644 --- a/Documentation/devicetree/bindings/usb/usb-xhci.yaml +++ b/Documentation/devicetree/bindings/usb/usb-xhci.yaml @@ -25,6 +25,10 @@ properties: description: Set if the controller has broken port disable mechanism type: boolean + disable-usb3: + description: Ignore (don't initialize, don't use) USB3 ports + type: boolean + imod-interval-ns: description: Interrupt moderation interval default: 5000 diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index 0a37f0d511cf..bf8fcab626e4 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c @@ -1968,6 +1968,10 @@ static void xhci_add_in_port(struct xhci_hcd *xhci, unsigned int num_ports, minor_revision = XHCI_EXT_PORT_MINOR(temp); if (major_revision == 0x03) { + /* Ignore USB3 ports entirely if USB3 support is disabled. */ + if (xhci->quirks & XHCI_DISABLE_USB3) + return; + rhub = &xhci->usb3_rhub; /* * Some hosts incorrectly use sub-minor version for minor diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c index b93161374293..75285fb5bbbc 100644 --- a/drivers/usb/host/xhci-plat.c +++ b/drivers/usb/host/xhci-plat.c @@ -249,6 +249,9 @@ int xhci_plat_probe(struct platform_device *pdev, struct device *sysdev, const s if (device_property_read_bool(tmpdev, "quirk-broken-port-ped")) xhci->quirks |= XHCI_BROKEN_PORT_PED; + if (device_property_read_bool(tmpdev, "disable-usb3")) + xhci->quirks |= XHCI_DISABLE_USB3; + device_property_read_u32(tmpdev, "imod-interval-ns", &xhci->imod_interval); } diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index 5df370482521..c53fbeea478f 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -1906,6 +1906,7 @@ struct xhci_hcd { #define XHCI_RESET_TO_DEFAULT BIT_ULL(44) #define XHCI_ZHAOXIN_TRB_FETCH BIT_ULL(45) #define XHCI_ZHAOXIN_HOST BIT_ULL(46) +#define XHCI_DISABLE_USB3 BIT_ULL(47) unsigned int num_active_eps; unsigned int limit_active_eps; From patchwork Fri Dec 8 21:04:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Edwards X-Patchwork-Id: 176035 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp5719462vqy; Fri, 8 Dec 2023 13:05:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IFbUkfaqFon5GFaptErX5cdcrxBDMuEbaNN0vrv2sMPuT7T5urEMc7TTu9Loi90Uuk6WvSE X-Received: by 2002:a05:6e02:198d:b0:35d:53c6:140 with SMTP id g13-20020a056e02198d00b0035d53c60140mr1060227ilf.32.1702069531823; Fri, 08 Dec 2023 13:05:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702069531; cv=none; d=google.com; s=arc-20160816; b=c913oKMLWueVHDmsnl5Lr4HDC0fnX2169r++dZiTZDDPWg2+Ja39usHSCLNTVvkgO5 IdhT/erF6FRC/nvvZUnveE7n5UlE8vibmL8JiHqzOoYafuYaZSQE54P6cFjYKZdKb+yv +a+3u47fZZEBeCB4y5iil0TlD3G1qvjtxbnBfGYrjaPvNmmSykTyk1ywHObP//mRfQte sWgdRiaVWaIpIbPzCBA+qOgwDvKV9FMngx4ziznHsd/2hlbh7rFJlpa52lipOOq63n6G JCT7MjcE98a/R5pczWQVx0b9/OfOR3LTT8QpFXCGt5FJ77FhXjF/QqVFvY+AQ4HmqbLi hG7g== 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 :dkim-signature; bh=QqvWOUimTI+IzTX35gstFYIO9U9PLoGOpX1jOFzw7Ys=; fh=d9TSyadBXPDybutOgGlYLsH9jqXf9pJuF0lO8Gj/Fg4=; b=sicEV9puLQwPE1XFq6nRJ57vk+jah/1hfa37y8fSaqcsX82B0CBmS/nXl+4XfQOxjm V7KyBsA6ARS5LzJAKVZc8YQdosnO0+fSh/n7/CgV3m6mHt44URi1MqqhR4uJJvZthchG zvZ3yT+CEKOH17A63y5gsC+tcY9KK/4mTd6EeiVekn+WPwpGF5TvuH6EuzkwzxTr77JN AEhOdOdGn4JMrDx+2dnmQfiv5j5AWFFigcXlEqG22C9iDMWR/FOFaJb4TjXA1oJQO+KX pMdLnIXZQ4CmC/odlUoXxN3KAfcFbYo5P5TIvfUkp4xmWcAaIJ5b+Dridcc7PPN6Q7ns D+gA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=VB8vo0Xq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id w69-20020a638248000000b005c6ed253558si1695717pgd.195.2023.12.08.13.05.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Dec 2023 13:05:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=VB8vo0Xq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 5960581FDB84; Fri, 8 Dec 2023 13:05:29 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1574766AbjLHVFR (ORCPT + 99 others); Fri, 8 Dec 2023 16:05:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229826AbjLHVFM (ORCPT ); Fri, 8 Dec 2023 16:05:12 -0500 Received: from mail-il1-x130.google.com (mail-il1-x130.google.com [IPv6:2607:f8b0:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA00E1985; Fri, 8 Dec 2023 13:05:15 -0800 (PST) Received: by mail-il1-x130.google.com with SMTP id e9e14a558f8ab-35d396ae91fso9016175ab.3; Fri, 08 Dec 2023 13:05:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702069515; x=1702674315; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=QqvWOUimTI+IzTX35gstFYIO9U9PLoGOpX1jOFzw7Ys=; b=VB8vo0Xqp7swVF76pi+Avk7GpowXCingFV9/UxArKQEyRHEnu7a0vK583YvK8KIc4G 6UcTaX4bpynXTE3LBca85RfMUeY1PhinVgGlOhr2wQQC1TeaXvXNHkOYvrtFIE/QWHt6 ozZzWGV9HP9XTSn4uZY5HoQW5RMYZDs/omv6N4NpOGrzhDHYuyxexEkcmwibdnz8On88 U2RGVqvWUJCu/EEk7MPx3RfmV2y6I2mwDmQHruu4Quu4hSwlR25zxt+b3c2YLe6grdrJ W0i32/Av3vgTpgEdUvNUMvrlGZwcGk2LFIrPAK/m5mUn6nm/if5HbAkXwzSz0ne/kGwG 0iWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702069515; x=1702674315; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QqvWOUimTI+IzTX35gstFYIO9U9PLoGOpX1jOFzw7Ys=; b=jnjbuA4TVP8fwtXfor1XH65CXAj7buihoiIBJ5XGYz2TW/C2T1G3dIEbANQrryu/YT oFcdHNMr5cGGDz4E5JlMzlCt1MGnpveYE5PyFFbTUxGucI1oX+OyihADMcklpcugTAkJ L03sUwckaJFk8ge9XqbLkMn2nXhfmtoKuxoL3DEUws1geQ+FdFUiVJyOc6fPEA4FjZGD uo7bfYFzvWd6e+nh28OZ1B2kL+pKIsdoO6+mA22z+yC1XXp0WW9kZVERBwgo085Scpf0 VaiTLbApKllRfN7sMv7CPDET3XYLQ14cKEgUt2YKRKaJSKj05Zq7cq8SLG5lhKXLu63E UczA== X-Gm-Message-State: AOJu0Yzqxb8b+4HMHkwDyU3Bfef5hiqRT+sduRWUysMHW7zdpDJkBspQ 76MGQP91/PI3d6ndphYAuRk= X-Received: by 2002:a05:6e02:1bc9:b0:35d:5f9d:d9be with SMTP id x9-20020a056e021bc900b0035d5f9dd9bemr915380ilv.10.1702069514926; Fri, 08 Dec 2023 13:05:14 -0800 (PST) Received: from celestia.nettie.lan ([2001:470:42c4:101:971d:15c7:de39:3b4b]) by smtp.gmail.com with ESMTPSA id g12-20020a056e020d0c00b0035d5a1760c1sm736458ilj.69.2023.12.08.13.05.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Dec 2023 13:05:14 -0800 (PST) From: Sam Edwards X-Google-Original-From: Sam Edwards To: Mathias Nyman , Thinh Nguyen Cc: Greg Kroah-Hartman , Heiko Stuebner , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Sam Edwards Subject: [PATCH 2/2] usb: dwc3: host: Disable USB3 ports if maximum-speed doesn't permit USB3 Date: Fri, 8 Dec 2023 14:04:58 -0700 Message-ID: <20231208210458.912776-3-CFSworks@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231208210458.912776-1-CFSworks@gmail.com> References: <20231208210458.912776-1-CFSworks@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Fri, 08 Dec 2023 13:05:29 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784749261699688486 X-GMAIL-MSGID: 1784749261699688486 The DWC3 core can be configured (during IP instantiation, and/or via configuration signals) not to have any USB3 ports. Some SoCs, however, may have USB3 interfaces enabled that do not have USB3 PHYs driving them. This can be due to a few circumstances, including: a) The hardware designer didn't include USB3 PHYs and neglected to disable the DWC3 core's USB ports (I know of no instance where this has actually happened, however, and it seems pretty unlikely). b) The USB3 PHYs are present but powered off. Perhaps a driver to enable the PHYs has not yet been written or merged, or USB3 capability is unneeded in the system and the system designer would like to conserve power. c) The USB3 PHYs are muxed to a different controller. This can happen if the PHYs support non-USB protocols and one of these alternate functions is needed instead. In these circumstances, if the DWC3 does not receive clear link status indication on an enabled USB3 port, the DWC3 may not allow even USB2 to function: in host mode, the DWC3 generates an endless barrage of PORT_CSC status on the accompanying USB2 port, and the xHCI driver is unable to bring the USB2 port to a functioning state. Fix this by first checking if the maximum-speed property in the DT permits USB3. If not, pass the new `disable-usb3;` property to the virtual xHCI device, causing the xHCI driver not to enable the USB3 ports. This allows USB2 to function even with USB3 PHYs missing/misbehaving, and may be useful even when the USB3 PHYs are well-behaved: a DT author may know that USB3 support is intact, but disconnected (not exposed off-board) and choose to lower the maximum-speed property to avoid an unusable USB3 rhub showing up in sysfs/lsusb where it may mislead end-users. Signed-off-by: Sam Edwards --- drivers/usb/dwc3/host.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/usb/dwc3/host.c b/drivers/usb/dwc3/host.c index 61f57fe5bb78..29f170927e70 100644 --- a/drivers/usb/dwc3/host.c +++ b/drivers/usb/dwc3/host.c @@ -61,7 +61,7 @@ static int dwc3_host_get_irq(struct dwc3 *dwc) int dwc3_host_init(struct dwc3 *dwc) { - struct property_entry props[4]; + struct property_entry props[5]; struct platform_device *xhci; int ret, irq; int prop_idx = 0; @@ -95,6 +95,9 @@ int dwc3_host_init(struct dwc3 *dwc) if (dwc->usb2_lpm_disable) props[prop_idx++] = PROPERTY_ENTRY_BOOL("usb2-lpm-disable"); + if (dwc->maximum_speed == USB_SPEED_FULL || dwc->maximum_speed == USB_SPEED_HIGH) + props[prop_idx++] = PROPERTY_ENTRY_BOOL("disable-usb3"); + /** * WORKAROUND: dwc3 revisions <=3.00a have a limitation * where Port Disable command doesn't work.