From patchwork Fri Feb 23 00:58:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 205166 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp311978dyb; Thu, 22 Feb 2024 16:59:30 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVdOjM1fVSalC7o/m2YOQsiZTYjYJ9Qem8GWAvX/7n0ep+qi0OH4g4qyOzusBWgmDnRhZMqtg/epT5aqHQyWwYB4/RPHw== X-Google-Smtp-Source: AGHT+IE9DwAu0UBE47X2i//mvA1KZftihAmqQfv/6tFu3puFp/b5zhnmGeLDNLboAe23x6GUaPOo X-Received: by 2002:a05:622a:170b:b0:42e:57a5:beb4 with SMTP id h11-20020a05622a170b00b0042e57a5beb4mr1057448qtk.38.1708649970327; Thu, 22 Feb 2024 16:59:30 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708649970; cv=pass; d=google.com; s=arc-20160816; b=h8xDwCzxWvAYSg2mHyjbzYH0JecHmpXU3hsdTRe2qq0O9wAAmcYjOqlS/IMahbz1ND qLr0QBGjbaVDRMSJBKcyxRPYoZs3ewde2jwyYoijn9tCf+z5jl9yIlwK5n+7EHTY/A2s FYVoxlVPiEmfC/VpAHM/wZPyRDo4W1pA1hJ9c2VBXHApIN41rBYHt2R5wtAg3Ag3FgY3 KX7WZkSaZnjkwUqAFWRqdOQYBiCc9YhifuapUl6dUgp3SfiRQ7FFfIzd96JzvAAJZBDp pUngn37yyuARK7SzcSzSUYubIQlqHtIeJ+TFNJF0tlrtqYLjQ1WmbpQ3gOjwR1+PZymn ziSw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=zUukn0iRYfq5PWEhEP7nadIeFb7HXOkHlZH9C2/kzss=; fh=9uvxIWBstD00nq+idv1WcRi1YfDKBDNHvboSi4qfECQ=; b=xD31YI+HAkjKD9jJfjVbPHzrvrpfW4lvLgYC/hHr0bBVbnSQ1OEnLpPDKTpbOUnUUr hT9oINTz0x7+nQ1D1cbshG6Hh+4DKRt0DKyalYQmPNnkile8YS9s5vI3ImIz/nAL8tT9 zS9W6Z5PJ2IGfpV48mESzrq0BxW7UiNKpa/ar8alf+tNxcKpwd98HCqQ104plJd07/fB 6UMQ7/mee34UC+Q5hoQTkfBrBGZl0ujUK4SZ2psCyIvaWy+7tfS0rcFAkLwAHxH1CXwS MM6u6SMiY5pNuZULhhW0S+PuJS18qtyegQ1jqZ4zwdtNstuYdccp94J52LTExGdL9TAQ 0B+Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=CAFwyX3f; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-77596-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-77596-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id jv14-20020a05622aa08e00b0042c06c5c1dbsi12366979qtb.596.2024.02.22.16.59.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 16:59:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-77596-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=CAFwyX3f; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-77596-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-77596-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 1588B1C21070 for ; Fri, 23 Feb 2024 00:59:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 05F9FD26B; Fri, 23 Feb 2024 00:58:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="CAFwyX3f" Received: from mail-yb1-f171.google.com (mail-yb1-f171.google.com [209.85.219.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 87C90AD5A for ; Fri, 23 Feb 2024 00:58:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708649911; cv=none; b=bvtYUFPPqtDQu88J7cccgRqruNTu/rqdXnxWG2PyHCeUu0Co7lLRNl8alzT9GlwO9nPuPpm9qe8NF1wgM8Qta3n78MeGuzuX1G/3KLslAJwc1gB/P+GQpqTwJ8JR2MoC0TA1qMyEYHYNZsmvBsuG/FiDjVWbbdbSS2ZCh+m+7gs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708649911; c=relaxed/simple; bh=O1sCSpMrQuVP4Z+oTQDMovl4p0LxmLa8st/+UmNeCw0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nWovj9Cbam4FVW95qkXqT/XdVocEqAUwfIizA0X/kZ1yEKvEGH9AvpFCeUAQd4HZLBvf/h7XWkxgbjsTSMexTocP9c7Vr8dsDYPr3sX0tDOVXKmYZzTDpCw3IjsjzcTyDxZHaI0xRhfhVZAssXSU+0eN7xVk3kxy3f8JsjmwnLM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=CAFwyX3f; arc=none smtp.client-ip=209.85.219.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-yb1-f171.google.com with SMTP id 3f1490d57ef6-dccb1421bdeso379578276.1 for ; Thu, 22 Feb 2024 16:58:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1708649907; x=1709254707; 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=zUukn0iRYfq5PWEhEP7nadIeFb7HXOkHlZH9C2/kzss=; b=CAFwyX3fxgveUxR6RRagHZ0b5uYjW3EJcZI7PhECpmON6zPyrEAVevDtujCj/Skgig 03ocYUmFJfQTcEnYMryirpfeHbgy4xOFT9nDbnejihvG5tqyiOvLcs4MtwHshsGDGxVd Cm/UO3BoivmdSODWec8kjMKY5G2z9zgivCEVY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708649907; x=1709254707; 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=zUukn0iRYfq5PWEhEP7nadIeFb7HXOkHlZH9C2/kzss=; b=mjxQaeRd/wWvKJD9rucVRogYVuS3Yh4sIijUrj2YkgV0H/77od5VPiEpee+f1oRfE1 ipEsQ1BoAOeomc21x8gCYauyRBqDGGaSOwK4P2K23QuDPwed3vQ9VQv1WLgBTtz2nLrj FksOXNpqfXIHf9uciOk2IFdQv2E/rfsijxjc9/0BZ2PJY15wLGlVSf9G3MTDrmq2U+QG 1HZvOHSKd0OR3yUXFcVw0EzaCq5cUf2NHst3l6Nt7hgpvs+HxdY/M/TXmWT9poyvvFZi oFyXy1YZKVutvhG8Zs6t6QfsS6hDplxJ5BReuB5iAz08z1m6PwqDV1wk8E4ds/g0YLQI mWmQ== X-Gm-Message-State: AOJu0Yw4JfsDfeNlEr8+/mNxhSgNqDH1nzeOWG3hHBw0d/E+3i9n64Q/ FZH7nWM7z7Om7KJ2tGhZBX6zGT1WsVxu+aMvP5FQQTKFwPdabvBO+D54f0MeSQ== X-Received: by 2002:a25:c244:0:b0:dc6:a8c6:c9e5 with SMTP id s65-20020a25c244000000b00dc6a8c6c9e5mr877740ybf.26.1708649907539; Thu, 22 Feb 2024 16:58:27 -0800 (PST) Received: from localhost (175.199.125.34.bc.googleusercontent.com. [34.125.199.175]) by smtp.gmail.com with UTF8SMTPSA id p14-20020a056a0026ce00b006e4887b13ffsm4820031pfw.1.2024.02.22.16.58.26 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 22 Feb 2024 16:58:27 -0800 (PST) From: Stephen Boyd To: Greg Kroah-Hartman , Rob Herring Cc: linux-kernel@vger.kernel.org, patches@lists.linux.dev, devicetree@vger.kernel.org, Douglas Anderson , Pin-yen Lin , Herve Codina , Alan Stern , Heikki Krogerus , Roy Luo , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Kaehlcke , linux-usb@vger.kernel.org, maciek swiech Subject: [PATCH v2 1/2] dt-bindings: usb: Add downstream facing ports to realtek binding Date: Thu, 22 Feb 2024 16:58:20 -0800 Message-ID: <20240223005823.3074029-2-swboyd@chromium.org> X-Mailer: git-send-email 2.44.0.rc0.258.g7320e95886-goog In-Reply-To: <20240223005823.3074029-1-swboyd@chromium.org> References: <20240223005823.3074029-1-swboyd@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791649351288667640 X-GMAIL-MSGID: 1791649351288667640 Add a graph with 4 output endpoints to this hub binding to support the scenario where a downstream facing port is connected to a device that isn't a connector or a USB device with a VID:PID. This will be used to connect downstream facing ports to USB type-c switches so the USB superspeed and high speed lanes can be put onto USB connectors. Cc: Rob Herring Cc: Krzysztof Kozlowski Cc: Conor Dooley Cc: Matthias Kaehlcke Cc: Cc: Cc: Pin-yen Lin Cc: maciek swiech Signed-off-by: Stephen Boyd Reviewed-by: Rob Herring --- .../bindings/usb/realtek,rts5411.yaml | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/Documentation/devicetree/bindings/usb/realtek,rts5411.yaml b/Documentation/devicetree/bindings/usb/realtek,rts5411.yaml index f0784d2e86da..0874fc21f66f 100644 --- a/Documentation/devicetree/bindings/usb/realtek,rts5411.yaml +++ b/Documentation/devicetree/bindings/usb/realtek,rts5411.yaml @@ -21,6 +21,12 @@ properties: reg: true + '#address-cells': + const: 1 + + '#size-cells': + const: 0 + vdd-supply: description: phandle to the regulator that provides power to the hub. @@ -30,6 +36,36 @@ properties: description: phandle to the peer hub on the controller. + ports: + $ref: /schemas/graph.yaml#/properties/ports + + properties: + port@1: + $ref: /schemas/graph.yaml#/properties/port + description: + 1st downstream facing USB port + + port@2: + $ref: /schemas/graph.yaml#/properties/port + description: + 2nd downstream facing USB port + + port@3: + $ref: /schemas/graph.yaml#/properties/port + description: + 3rd downstream facing USB port + + port@4: + $ref: /schemas/graph.yaml#/properties/port + description: + 4th downstream facing USB port + +patternProperties: + '^.*@[1-4]$': + description: The hard wired USB devices + type: object + $ref: /schemas/usb/usb-device.yaml + required: - peer-hub - compatible @@ -50,6 +86,13 @@ examples: reg = <1>; vdd-supply = <&pp3300_hub>; peer-hub = <&hub_3_0>; + #address-cells = <1>; + #size-cells = <0>; + /* USB 2.0 device on port 2 */ + device@2 { + compatible = "usb123,4567"; + reg = <2>; + }; }; /* 3.0 hub on port 2 */ @@ -58,5 +101,17 @@ examples: reg = <2>; vdd-supply = <&pp3300_hub>; peer-hub = <&hub_2_0>; + + ports { + #address-cells = <1>; + #size-cells = <0>; + /* Type-A connector on port 4 */ + port@4 { + reg = <4>; + endpoint { + remote-endpoint = <&usb_a0_ss>; + }; + }; + }; }; }; From patchwork Fri Feb 23 00:58:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 205167 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp312701dyb; Thu, 22 Feb 2024 17:00:57 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVFMyg+TYpwozxkT7famplJ1fp/LI0S+X2KvnSJ5sglTkLytpMBCZcRbVpXitQerSqsrm2G3wrNCjy+5EsREaRXDmZggg== X-Google-Smtp-Source: AGHT+IGfwJSJ8hJiJ5txFIGC49jsEkSk++0Xhg+kztQcCmZzNOlroSKMiSlGemhSXw96Lp69+Fd4 X-Received: by 2002:a05:6870:8585:b0:21f:2010:3651 with SMTP id f5-20020a056870858500b0021f20103651mr636062oal.48.1708650057526; Thu, 22 Feb 2024 17:00:57 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708650057; cv=pass; d=google.com; s=arc-20160816; b=IWfq4Ht9TtYUY6O52REzNCFc5MT2Gl4R8b72zNSrPVHNvNvPzHsBVXxT0YAZxBu7gf ARDH3ONVepCqWKt4lMF/DeyE39PNvEfWt0ecHwYOPyOe84Td1Z/xLdrPlw2ncOFRGrng D/gJA/VwgEfHGlpKUtmWQ/E/x2vWiTyW7nkhrG4qN41v/o9kP0KAf+fzj14FuSIvgOks VRno3hMG5kHCPmtZbhP2En4a5aGLWSjbcVy5Jvc6V2OG0KUr8Xqhw8uP1SoRsvEiG9ne tAS1XQU/ONe4vPYZ12PELOE7ShM/cRNF6C6u+fjXvDaLXxlWpAXKgkbrKEQxJW8lp1hR k30A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=UFIGIcteJ9nUdBATIDe99Xci9kTl4VUk6xpdoWZYz+c=; fh=OO2C8QjAlhWF0jJWhkjdzrW4/V1fOEue/wz1dx8aBEE=; b=CneiEq0XfwDU+Oj1olRrrSNglYwnLq75zIu4Eb9/5DPI6TvksbFTS1y7Oz1hXdTalh XlMseOervbPPTHulWPRTZczW6iGpaZQtf5qW63OHzOee02Q9TPIxpnkX0rloUeTGRE+V AmpHNrCtHytnwcool5L11H5VSvYcssEZvde+txDbXxW7gGhhARJQgVqaR17Y6hQJUzDv /HeVLEQIC2gOJk59zmh1X+18dMn5xvaek/oBmNUQXSnG6LAhOpnKFGs0M8s4f8D1DqWp abDBQOOmlK6/Y8ZZuvt2EQWTRyKB6oyxWy18PuBFM5d9sTGFk3tJK1Z7uIROCTkY0TlL M10g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=YQP7kBy5; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-77597-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-77597-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id u190-20020a6385c7000000b005dc42755289si11172600pgd.488.2024.02.22.17.00.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 17:00:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-77597-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=YQP7kBy5; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-77597-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-77597-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 8C05DB21C52 for ; Fri, 23 Feb 2024 00:59:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F2641DDAA; Fri, 23 Feb 2024 00:58:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="YQP7kBy5" Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C50E5B642 for ; Fri, 23 Feb 2024 00:58:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708649911; cv=none; b=BNDjeJVkW9C/n1TogjJsNKM+zYz8tuh7cTtb0dB5OkYRO6J56clFONXHmM17tu/+LvdLEKAq/FcziO/VshZNgdsLWIbSWiYrOcFvmOfFJtfNN7ILaZbT96/yK9GAQXo3LkfASqoLQ4gUqK1wcSYNgnYe9UD2sVr2w7vFyXH3OPg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708649911; c=relaxed/simple; bh=v27iEZktilH2OnIdu1MjAvZd2ZBk3RvhRJ0/3icnfgs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CH1ZVhBhlEfWVKKlBW+UYD3j2NI4oylFS/RtWsDa4XO1A0/xZFuvf5sSZ3WMu83ooNlKWhsrqbhfnJW5ml7j/ftgcNG/4W7ZEPw+9mn1u2Tvm0ekBk2nLImEylB1PZiR0LLpN46HOxCRJCb/GcM8Oy6oyNDV4VWW5fA1gg1XN1U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=YQP7kBy5; arc=none smtp.client-ip=209.85.216.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-pj1-f47.google.com with SMTP id 98e67ed59e1d1-29951f5c2e7so326770a91.1 for ; Thu, 22 Feb 2024 16:58:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1708649909; x=1709254709; 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=UFIGIcteJ9nUdBATIDe99Xci9kTl4VUk6xpdoWZYz+c=; b=YQP7kBy5Xy3MOEWlVIcw/TuOWvCiTYhxMIIqKjBK770Lm1+Bik8jBQL77HFVwQzGgN cV4F/HZg+qPmiftfWx4MQUEJYRF17FZpqhRTHFivQcOSLw07Xr4/GEbKDP/TI+J4DaQi W5ggriQwi2juyi8Q+UMWoGVrIKTcuELuVaoRc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708649909; x=1709254709; 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=UFIGIcteJ9nUdBATIDe99Xci9kTl4VUk6xpdoWZYz+c=; b=g1M4KSRJ4wdHKA00YUz7P/yZkzaLyVyOGcuiQLu7134uaiAU/8e736FpWiftHo2NOB EOERYt8y6nH5abVnEXuqW5LZNh4dn+flN/8uZzAKdRLhVGHR2MzDdP4H8ySxMj23cPhQ tLxkhRiwSQo/IOBBmNBRd7P+0lySUiIFEzmc9qDXy7xK8jnAik67t8inIBqzHbQ+aufQ zx67FttI8anbpc7ct78V1j9epo2IWmb2nCAaqhh1SozImlXw9Xk50tM5ClaQyrD32bNg MLL0dHPB1Etj/rz+gfTnwuhUOsSbXvWAH4lV55yodU/47CvP66gVEIesBHxViYrIA2D5 uNiQ== X-Gm-Message-State: AOJu0YxFXotJsz8BxlPpGidPcNBsd4ii952EFZBGhwvRzwj2d3z5wtK2 VgQ7u4HrN48m4RRespbzK3ReGW6+7hXk7LtOUafhIsB5aTQxImL6YA/C2LaIrpxPfLtK05Th3zo = X-Received: by 2002:a17:90a:5ae2:b0:299:4397:621c with SMTP id n89-20020a17090a5ae200b002994397621cmr440115pji.43.1708649909121; Thu, 22 Feb 2024 16:58:29 -0800 (PST) Received: from localhost (175.199.125.34.bc.googleusercontent.com. [34.125.199.175]) by smtp.gmail.com with UTF8SMTPSA id m21-20020a17090ab79500b00298e11b600dsm116430pjr.27.2024.02.22.16.58.28 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 22 Feb 2024 16:58:28 -0800 (PST) From: Stephen Boyd To: Greg Kroah-Hartman , Rob Herring Cc: linux-kernel@vger.kernel.org, patches@lists.linux.dev, devicetree@vger.kernel.org, Douglas Anderson , Pin-yen Lin , Herve Codina , Alan Stern , Heikki Krogerus , Roy Luo , Matthias Kaehlcke , linux-usb@vger.kernel.org, maciek swiech Subject: [PATCH v2 2/2] usb: core: Set connect_type of ports based on DT node Date: Thu, 22 Feb 2024 16:58:21 -0800 Message-ID: <20240223005823.3074029-3-swboyd@chromium.org> X-Mailer: git-send-email 2.44.0.rc0.258.g7320e95886-goog In-Reply-To: <20240223005823.3074029-1-swboyd@chromium.org> References: <20240223005823.3074029-1-swboyd@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791649442878316027 X-GMAIL-MSGID: 1791649442878316027 When a USB hub is described in DT, such as any device that matches the onboard-hub driver, the connect_type is set to "unknown" or USB_PORT_CONNECT_TYPE_UNKNOWN. This makes any device plugged into that USB port report their 'removable' device attribute as "unknown". ChromeOS userspace would like to know if the USB device is actually removable or not so that security policies can be applied. Improve the connect_type attribute for ports, and in turn the removable attribute for USB devices, by looking for child devices with a reg property or an OF graph when the device is described in DT. If the graph exists, endpoints that are connected to a remote node must be something like a usb-{a,b,c}-connector compatible node, or an intermediate node like a redriver, and not a hardwired USB device on the board. Set the connect_type to USB_PORT_CONNECT_TYPE_HOT_PLUG in this case because the device is going to be plugged in. Set the connect_type to USB_PORT_CONNECT_TYPE_HARD_WIRED if there's a child node for the port like 'device@2' for port2. Set the connect_type to USB_PORT_NOT_USED if there isn't an endpoint or child node corresponding to the port number. To make sure things don't change, only set the port to not used if there are child nodes. This way an onboard hub connect_type doesn't change until ports are added or child nodes are added to describe hardwired devices. It's assumed that all ports or no ports will be described for a device. Cc: Matthias Kaehlcke Cc: Cc: Cc: Pin-yen Lin Cc: maciek swiech Signed-off-by: Stephen Boyd --- drivers/usb/core/of.c | 71 +++++++++++++++++++++++++++++++++++++++++ drivers/usb/core/port.c | 2 ++ include/linux/usb/of.h | 7 ++++ 3 files changed, 80 insertions(+) diff --git a/drivers/usb/core/of.c b/drivers/usb/core/of.c index db4ccf9ce3d9..f1a499ee482c 100644 --- a/drivers/usb/core/of.c +++ b/drivers/usb/core/of.c @@ -8,6 +8,7 @@ */ #include +#include #include /** @@ -75,6 +76,76 @@ bool usb_of_has_combined_node(struct usb_device *udev) } EXPORT_SYMBOL_GPL(usb_of_has_combined_node); +static bool usb_of_has_devices_or_graph(const struct usb_device *hub) +{ + const struct device_node *np = hub->dev.of_node; + struct device_node *child; + + if (of_graph_is_present(np)) + return true; + + for_each_child_of_node(np, child) + if (of_property_present(child, "reg")) + return true; + + return false; +} + +/** + * usb_of_get_connect_type() - get a USB hub's port connect_type + * @hub: hub to which port is for @port1 + * @port1: one-based index of port + * + * Get the connect_type of @port1 based on the device node for @hub. If the + * port is described in the OF graph, the connect_type is "hotplug". If the + * @hub has a child device has with a 'reg' property equal to @port1 the + * connect_type is "hard-wired". If there isn't an OF graph or child node at + * all then the connect_type is "unknown". Otherwise, the port is considered + * "unused" because it isn't described at all. + * + * Return: A connect_type for @port1 based on the device node for @hub. + */ +enum usb_port_connect_type usb_of_get_connect_type(struct usb_device *hub, int port1) +{ + struct device_node *np, *child, *ep, *remote_np; + enum usb_port_connect_type connect_type; + + /* Only set connect_type if binding has ports/hardwired devices. */ + if (!usb_of_has_devices_or_graph(hub)) + return USB_PORT_CONNECT_TYPE_UNKNOWN; + + /* Assume port is unused if there's a graph or a child node. */ + connect_type = USB_PORT_NOT_USED; + + np = hub->dev.of_node; + /* + * Hotplug ports are connected to an available remote node, e.g. + * usb-a-connector compatible node, in the OF graph. + */ + if (of_graph_is_present(np)) { + ep = of_graph_get_endpoint_by_regs(np, port1, -1); + if (ep) { + remote_np = of_graph_get_remote_port_parent(ep); + of_node_put(ep); + if (of_device_is_available(remote_np)) + connect_type = USB_PORT_CONNECT_TYPE_HOT_PLUG; + of_node_put(remote_np); + } + } + + /* + * Hard-wired ports are child nodes with a reg property corresponding + * to the port number, i.e. a usb device. + */ + child = usb_of_get_device_node(hub, port1); + if (of_device_is_available(child)) + connect_type = USB_PORT_CONNECT_TYPE_HARD_WIRED; + of_node_put(child); + + return connect_type; +} +EXPORT_SYMBOL_GPL(usb_of_get_connect_type); + /** * usb_of_get_interface_node() - get a USB interface node * @udev: USB device of interface diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c index c628c1abc907..da910d3e40f6 100644 --- a/drivers/usb/core/port.c +++ b/drivers/usb/core/port.c @@ -11,6 +11,7 @@ #include #include #include +#include #include "hub.h" @@ -708,6 +709,7 @@ int usb_hub_create_port_device(struct usb_hub *hub, int port1) return -ENOMEM; } + port_dev->connect_type = usb_of_get_connect_type(hdev, port1); hub->ports[port1 - 1] = port_dev; port_dev->portnum = port1; set_bit(port1, hub->power_bits); diff --git a/include/linux/usb/of.h b/include/linux/usb/of.h index 98487fd7ab11..de42f14bd280 100644 --- a/include/linux/usb/of.h +++ b/include/linux/usb/of.h @@ -6,6 +6,7 @@ #ifndef __LINUX_USB_OF_H #define __LINUX_USB_OF_H +#include #include #include #include @@ -17,6 +18,7 @@ enum usb_dr_mode of_usb_get_dr_mode_by_phy(struct device_node *np, int arg0); bool of_usb_host_tpl_support(struct device_node *np); int of_usb_update_otg_caps(struct device_node *np, struct usb_otg_caps *otg_caps); +enum usb_port_connect_type usb_of_get_connect_type(struct usb_device *hub, int port1); struct device_node *usb_of_get_device_node(struct usb_device *hub, int port1); bool usb_of_has_combined_node(struct usb_device *udev); struct device_node *usb_of_get_interface_node(struct usb_device *udev, @@ -37,6 +39,11 @@ static inline int of_usb_update_otg_caps(struct device_node *np, { return 0; } +static inline enum usb_port_connect_type +usb_of_get_connect_type(const struct usb_device *hub, int port1) +{ + return USB_PORT_CONNECT_TYPE_UNKNOWN; +} static inline struct device_node * usb_of_get_device_node(struct usb_device *hub, int port1) {