From patchwork Tue Feb 13 13:00:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heikki Krogerus X-Patchwork-Id: 200423 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp517141dyb; Tue, 13 Feb 2024 05:01:50 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU/g4ofPLPph2Dcc/gZ6zleKiFSZiXI4GvcrqgO7eBnOoF3nFFg3WKDuG/QG4ZlqNNxTyN0VmIPHS8xYNLsdXQD6h4Gyw== X-Google-Smtp-Source: AGHT+IHR825DiAgN607b0wip625O/7671mSSW2kgUUEzn9CmTMl/HqQQpB3C5FHc/3nGZWpnyl0P X-Received: by 2002:aa7:d90e:0:b0:562:429:66e1 with SMTP id a14-20020aa7d90e000000b00562042966e1mr717196edr.21.1707829310083; Tue, 13 Feb 2024 05:01:50 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707829310; cv=pass; d=google.com; s=arc-20160816; b=X7mjNNCQLIzjK5eDSLwjJpGjoBb+lwMy1dm1hK+2qG66b0wLZRIVbB9I8VvfHgFdpb khFSpKeFEO7UaIhKf1CVYDcl/L027Kyhm+kep8h4H1Bdg38yW/5w5RFOixFitAaEFGt9 dO81TX/gRkN2+OYc2m6qaJu9vbjcUCS6ArhX6Xspp7pjG9Ka/14ocUu+3Xe/7Dkt0c8I dumnNPCqiH/zOOpA+vBjahYcUUDa+2fEsaO5d3kQMZrWLnjO3dIJD8FeMtZH00fso0EG rfUM+3muUzy8KQVq6L4YIVpNxvMBg/AWbv/yqtl/blwDz+RpbISlXCQqdRkyfGvviAqr kZhA== 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=Id1kXEmgbvhsjNsRFfcvA9HSMtMImcLL5ffkY+gRtuQ=; fh=syxXKvMwxQUt6lPDZMLcCvtniQ1Bc144qjee5+Rublc=; b=UKWsgDuDDcyPZUiN2Ur8TJ8oE9Hbw/1jyTni8aDtocjQD9M/nzd/+5t56b2FogVsmq 7SPmKeJ9bkOwAHWh8RrFu5f+4kgbbkcRmBCuUaQEFDznVlbfSWHY8XSFx1FkCgvvXtKZ 1lFbS01hOGylEu6WT4zmaqdAlVCXuUtbZO9pEVgHXsVsVfzShHJZynQILXSq6EjePzhB boQ7QQNC3VEv1hVH3q4iM0Hhg5Qa9tVnOQ46z0I/ybJSLrgrspPZSF/OP4wu6RLRb5l5 GY/P/uJIyKqSVhkmSZV+/vdZmd1jejTB/pRd30FLfFLBvsYwVr2z9m/jTfrJGnp4hDyH 6xrw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=nyIsDATi; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-63550-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63550-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Forwarded-Encrypted: i=2; AJvYcCWKDGL4RaJB8S60K3AcmVjHpVQc6gR0SxthLw2KKztLv6+QY9WDgvB5nQfSzea6f+5ItRH/3VVikvuNx8m1bQrNS5Mp6A== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id u13-20020a50eacd000000b00561a837743csi2169259edp.12.2024.02.13.05.01.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 05:01:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-63550-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=nyIsDATi; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-63550-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63550-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com 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 am.mirrors.kernel.org (Postfix) with ESMTPS id CF86A1F212A1 for ; Tue, 13 Feb 2024 13:01:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 05F2B5103F; Tue, 13 Feb 2024 13:00:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="nyIsDATi" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CCF895024A; Tue, 13 Feb 2024 13:00:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.20 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707829229; cv=none; b=mL0qV+EM5tSGB6IuLxRd5D9oDDxalBCuVw06cI/iNna2YkBz55xnlFZdNWM11U3q2k8ZAFKthplXPC7iP9kzK5uKULxVST72s1eBJZRo4GTIpLlP1x6oPBf/03fHHuh+uwGsdmanLAkl6KZHa2bn34nwJwk+hpjmr2sRwXtzPPw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707829229; c=relaxed/simple; bh=GPXSlwYiixoQscrKQneXqLxQNPyv7GTgiXwdLZGez6A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CtSA7KWIhKAKqfuf346jyAgOuGdbIrtc9EUU7HHKlAMqrfxk7YpNjqp6aniOMkbzLYlbH6tesb7aLvXkdpOTJ/dgVEq8YN/ULOh+XGxChxmLmeyCCiW+5F3b9c1FjbLnmguTGsXvfoH0jIfVuoT3dfMxNA3s8rGHHr9MbKbB9jA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=nyIsDATi; arc=none smtp.client-ip=198.175.65.20 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707829228; x=1739365228; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=GPXSlwYiixoQscrKQneXqLxQNPyv7GTgiXwdLZGez6A=; b=nyIsDATitK9+bInlP9qABfewtbzMs2zWdotgBNBq5M3dYi+vzn9UX2Xt ez2sUozyZu7rsMkLMASJxEA7bod/iIMgFgX6uLDoNdmJF2H8FVha8hGEm ZnBV4JVPXGhXFXUASmjctfzmNYpHMboipvBxL/MuF+Arb66wPwBKaGeZ3 XjJsAQVTst0MR49qAwut6JKYTThc2oJZIqYEIVwmYTC17qt3Q6Cf1ZzB1 yXkQ71gkK2/lj370shF70BVQSKpiPXgTk0f+5PsyUpvzD6Ru4OG6orVRJ N2ZeFHsq2MghbCckT48QFlo0JoMWKoTQYjjz4QeL/PEQDyer9DXKPhM3q Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10982"; a="1708886" X-IronPort-AV: E=Sophos;i="6.06,157,1705392000"; d="scan'208";a="1708886" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orvoesa112.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Feb 2024 05:00:27 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10982"; a="935348370" X-IronPort-AV: E=Sophos;i="6.06,157,1705392000"; d="scan'208";a="935348370" Received: from black.fi.intel.com (HELO black.fi.intel.com.) ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 13 Feb 2024 05:00:23 -0800 From: Heikki Krogerus To: Prashant Malani , Greg Kroah-Hartman Cc: Benson Leung , Tzung-Bi Shih , Guenter Roeck , Emilie Roberts , "Nyman, Mathias" , "Regupathy, Rajaram" , "Radjacoumar, Shyam Sundar" , Samuel Jacob , Uday Bhat , linux-usb@vger.kernel.org, chrome-platform@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/2] usb: roles: Link the switch to its connector Date: Tue, 13 Feb 2024 15:00:17 +0200 Message-ID: <20240213130018.3029991-2-heikki.krogerus@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240213130018.3029991-1-heikki.krogerus@linux.intel.com> References: <20240213130018.3029991-1-heikki.krogerus@linux.intel.com> 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: 1790788826549147363 X-GMAIL-MSGID: 1790788826549147363 This is probable useful information to have in user space in general, but it's primarily needed for the xHCI DbC (Debug Capability). When xHCI DbC is being used, the USB port needs to be muxed to the xHCI even in device role. In xHCI DbC mode, the xHCI is the USB device controller. Tested-by: Uday Bhat Signed-off-by: Heikki Krogerus Reviewed-by: Prashant Malani --- .../ABI/testing/sysfs-class-usb_role | 6 +++ drivers/usb/roles/class.c | 40 ++++++++++++++++++- 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-class-usb_role b/Documentation/ABI/testing/sysfs-class-usb_role index 3b810a425a52..9fab3f06679e 100644 --- a/Documentation/ABI/testing/sysfs-class-usb_role +++ b/Documentation/ABI/testing/sysfs-class-usb_role @@ -19,3 +19,9 @@ Description: - none - host - device + +What: /sys/class/usb_role//connector +Date: Feb 2024 +Contact: Heikki Krogerus +Description: + Optional symlink to the USB Type-C connector. diff --git a/drivers/usb/roles/class.c b/drivers/usb/roles/class.c index ae41578bd014..4ad03c93c17f 100644 --- a/drivers/usb/roles/class.c +++ b/drivers/usb/roles/class.c @@ -7,6 +7,7 @@ * Hans de Goede */ +#include #include #include #include @@ -34,6 +35,32 @@ struct usb_role_switch { #define to_role_switch(d) container_of(d, struct usb_role_switch, dev) +static int connector_bind(struct device *dev, struct device *connector, void *data) +{ + int ret; + + ret = sysfs_create_link(&dev->kobj, &connector->kobj, "connector"); + if (ret) + return ret; + + ret = sysfs_create_link(&connector->kobj, &dev->kobj, "usb-role-switch"); + if (ret) + sysfs_remove_link(&dev->kobj, "connector"); + + return ret; +} + +static void connector_unbind(struct device *dev, struct device *connector, void *data) +{ + sysfs_remove_link(&connector->kobj, "usb-role-switch"); + sysfs_remove_link(&dev->kobj, "connector"); +} + +static const struct component_ops connector_ops = { + .bind = connector_bind, + .unbind = connector_unbind, +}; + /** * usb_role_switch_set_role - Set USB role for a switch * @sw: USB role switch @@ -352,6 +379,12 @@ usb_role_switch_register(struct device *parent, return ERR_PTR(ret); } + if (dev_fwnode(&sw->dev)) { + ret = component_add(&sw->dev, &connector_ops); + if (ret) + dev_warn(&sw->dev, "failed to add component\n"); + } + /* TODO: Symlinks for the host port and the device controller. */ return sw; @@ -366,8 +399,11 @@ EXPORT_SYMBOL_GPL(usb_role_switch_register); */ void usb_role_switch_unregister(struct usb_role_switch *sw) { - if (!IS_ERR_OR_NULL(sw)) - device_unregister(&sw->dev); + if (IS_ERR_OR_NULL(sw)) + return; + if (dev_fwnode(&sw->dev)) + component_del(&sw->dev, &connector_ops); + device_unregister(&sw->dev); } EXPORT_SYMBOL_GPL(usb_role_switch_unregister); From patchwork Tue Feb 13 13:00:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heikki Krogerus X-Patchwork-Id: 200491 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp613763dyb; Tue, 13 Feb 2024 07:30:14 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUq6iC6yX1uRN3K2/zL++o9x6Wc3OM9hrM7ub6mxQguzTQEEm24Otot0QpkH0ofG9Ea4YsQRKe31zv76xuLxVkJ0HTbCw== X-Google-Smtp-Source: AGHT+IERHtSbYv7uCjRAZ4qZinf6IbY/JHKSSRRPTycFkHWZL0La8nmklL+MxzagV4seKhxIApvY X-Received: by 2002:a17:903:41d1:b0:1db:4962:949e with SMTP id u17-20020a17090341d100b001db4962949emr1106572ple.27.1707838214510; Tue, 13 Feb 2024 07:30:14 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707838214; cv=pass; d=google.com; s=arc-20160816; b=P81nHWkL9nfe3b0Jiiq5I1mh/gZdYtvCLatZmx0xyMSqT6+eBqlcy8NV4P6LNwZoEF FeHliQb3ajMA/H0mRqXjjV7CVe2XB6Bsut7Cmbyj9y/wRRUf9pvceNmdrb8yw6pRM0KX l6nQpGRXgU+B1R3NUWSglgJ8UdpXCrYequQYLJWAmbY/qoik9xsnOXwX2WT7G54r0elb PVKU+MgQ2j9z5FJZ3AjuzNsLhPaJ5TbTufUKhAHsnT6pe7XmvXK/ZvUHN8EJSugjDX6x nbEnkMkoIVB8JbPa3okSrpFMS6nBQuBlaZF500kDwnbB93j5H3MEzGrYZAsCKL+7Lsmt ebSg== 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=kkGQ35KdVssLSX5zrrlXzox3ioRslheQdObqrgpivhA=; fh=bQDO9Ttz8jM4pTKc/vm85P8LfoAGJ1krQLVu/rGIaRA=; b=qvvevrh/s9C0gy/yixkp8HNUdyUnF157720YyF06vFZuoMmSeN8YpMIczu/QQk4isp MJQKiMWWDPnOhP0EOYzQQPvCuDgS88EgauG/yHvR8vmtzl/KmjKPSiu/dR3OjA6HeUIA 9sRvO9UYZH+QHDItXdbjYouQYhTe3foL/PvJviYyI/2B8gFizhKbXr4n7/+egtmgCeM4 gTRYBsrNKHfkFUAR7S87R0JbuC4daj8dh0gEBCL0vMVLgf8cmRnGQ3YasD9L8iLKKk5W YQJUXttd57lx0wrMEg8jDxv/4scKYZ7pk+KT/kxzd87jRy2MiqMy3cZHV0Xh1k0NoYdP IRBg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=loBi76Bu; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-63551-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63551-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Forwarded-Encrypted: i=2; AJvYcCVX9qHompFZz43uNLjou3SASr1utJdH66v3J4vCmJiygoPukLhLM+hCDezdsgeTuEVJ+rGksJzQkNDri67lMnzLAQyi3A== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id dq19-20020a056a020f9300b005cd813c23besi2197295pgb.415.2024.02.13.07.30.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 07:30:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-63551-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=loBi76Bu; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-63551-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63551-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id BFB1128B0A6 for ; Tue, 13 Feb 2024 13:01:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CC610524A7; Tue, 13 Feb 2024 13:00:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="loBi76Bu" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D374D51039; Tue, 13 Feb 2024 13:00:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.20 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707829233; cv=none; b=KQiO76iCGJ88gmybRzYfl94r2RDOen6xJgP4FA3xO6sz1bMASvvnKmN4y06BIky9DNxBtena8qVOjyDVmeUWW+ledzxvbwHVhDPSXG1oThBLirc77nvtaz9F34kDZyjt2thVACZ10SfmnJtFmjc38Icoua9M6J+Siroo0Ly0sXk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707829233; c=relaxed/simple; bh=FPXgBnSmS+6sKYbXhTyHNlC+korVLPzZkGCgDSeKV5I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=U1vbQa0nz8ePesFnxlrgoWdhQV18PA25FzbbxeDZN24HPWcXD7WUo+p6sWeWQxRW0u9GvRghYzNxv2uOm/ivzQFRiHFISr5dPCxw6BUkvbBt0okvKsI0YiiTWQjWfmd6zxVoO9ShRtAK7rKrfELRSaF1ncMq49ARXIE5PTNgqgc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=loBi76Bu; arc=none smtp.client-ip=198.175.65.20 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707829232; x=1739365232; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=FPXgBnSmS+6sKYbXhTyHNlC+korVLPzZkGCgDSeKV5I=; b=loBi76BuShhYeDmHFGG/8Iramm+LjE8Vau7YaP2GUObELxoqJcfqgURq s9Dn+4Vp61VJEa6zRgxazhMK616QqUE+kuQuxoZSqJwyL60bxTgOXFq9k K39fHnzWYFjFqwY+sM2UUNcmhGFNaZR1LrjTVd20dtrkpG8HPyD7eiL+m 27Emin+V+lIRdh7Xh2RHOE9oxFPEe4HvDIKPZytmUFOscf2OP0moWGK4A GbBrlKN9VU6zXiqavOZMdyZZy3xu4LEC0Qd2DkZomtztmdvRMvXdfIzfw voWEBvTeWMDUS6jSzWs5JFO3WI87p0fd5RCcEm5qc2E0LQIZDB0paIXPK g==; X-IronPort-AV: E=McAfee;i="6600,9927,10982"; a="1708904" X-IronPort-AV: E=Sophos;i="6.06,157,1705392000"; d="scan'208";a="1708904" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orvoesa112.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Feb 2024 05:00:31 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10982"; a="935348383" X-IronPort-AV: E=Sophos;i="6.06,157,1705392000"; d="scan'208";a="935348383" Received: from black.fi.intel.com (HELO black.fi.intel.com.) ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 13 Feb 2024 05:00:27 -0800 From: Heikki Krogerus To: Prashant Malani , Greg Kroah-Hartman Cc: Benson Leung , Tzung-Bi Shih , Guenter Roeck , Emilie Roberts , "Nyman, Mathias" , "Regupathy, Rajaram" , "Radjacoumar, Shyam Sundar" , Samuel Jacob , Uday Bhat , linux-usb@vger.kernel.org, chrome-platform@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/2] platform/chrome: cros_ec_typec: Make sure the USB role switch has PLD Date: Tue, 13 Feb 2024 15:00:18 +0200 Message-ID: <20240213130018.3029991-3-heikki.krogerus@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240213130018.3029991-1-heikki.krogerus@linux.intel.com> References: <20240213130018.3029991-1-heikki.krogerus@linux.intel.com> 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: 1790798163488369256 X-GMAIL-MSGID: 1790798163488369256 The USB role switch does not always have the _PLD (Physical Location of Device) in ACPI tables. If it's missing, assigning the PLD hash of the port to the switch. That should guarantee that the USB Type-C port mapping code is always able to find the connection between the two (the port and the switch). Tested-by: Uday Bhat Signed-off-by: Heikki Krogerus Acked-by: Prashant Malani --- drivers/platform/chrome/cros_ec_typec.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c index 2b2f14a1b711..4d305876ec08 100644 --- a/drivers/platform/chrome/cros_ec_typec.c +++ b/drivers/platform/chrome/cros_ec_typec.c @@ -24,6 +24,23 @@ #define DP_PORT_VDO (DP_CONF_SET_PIN_ASSIGN(BIT(DP_PIN_ASSIGN_C) | BIT(DP_PIN_ASSIGN_D)) | \ DP_CAP_DFP_D | DP_CAP_RECEPTACLE) +static void cros_typec_role_switch_quirk(struct fwnode_handle *fwnode) +{ +#ifdef CONFIG_ACPI + struct fwnode_handle *switch_fwnode; + + /* Supply the USB role switch with the correct pld_crc if it's missing. */ + switch_fwnode = fwnode_find_reference(fwnode, "usb-role-switch", 0); + if (!IS_ERR_OR_NULL(switch_fwnode)) { + struct acpi_device *adev = to_acpi_device_node(switch_fwnode); + + if (adev && !adev->pld_crc) + adev->pld_crc = to_acpi_device_node(fwnode)->pld_crc; + fwnode_handle_put(switch_fwnode); + } +#endif +} + static int cros_typec_parse_port_props(struct typec_capability *cap, struct fwnode_handle *fwnode, struct device *dev) @@ -66,6 +83,8 @@ static int cros_typec_parse_port_props(struct typec_capability *cap, cap->prefer_role = ret; } + cros_typec_role_switch_quirk(fwnode); + cap->fwnode = fwnode; return 0;