From nobody Thu Oct 2 16:48:57 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 918AD1B4141; Sun, 14 Sep 2025 12:56:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757854608; cv=none; b=fkXMI0ZZHzzzKEpZ1PYx9fKl4HQiL7aXpF37AX84CZKyOEM4SiVyqai4iehVuiTeZ1nn9IPMc+Z11yXKPYaD8sHxDdE49/5nyd63CdbgDpqQCwUXV4FUqArDxx4ZDgeK7S0QHzWwKYd2LxGkx1SeZaEdJyYATrGE/tm9mAVYLfE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757854608; c=relaxed/simple; bh=5qN1hUYg/yBslXEFHt0WeCqqqta8eTqmgCNW+CF8HKk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=CdSZMyzkadiB7hDrgnvUWEBhabB7g/ehKAbwXMw8esn95v5IumaL+XVQ2IdoBYr90bJ383SiRpRbrHjSFTCWpvXaA2p+BaA0ePDAtFgfvPVQwXGAbTY0yH71k7q+zNrRv2WBmjufLZRNE1rzzG6Yj6Ja1hkg1wU4gtlsaILoE8E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=aE81kzam; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="aE81kzam" Received: by smtp.kernel.org (Postfix) with ESMTPS id 2BED9C4CEF7; Sun, 14 Sep 2025 12:56:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757854608; bh=5qN1hUYg/yBslXEFHt0WeCqqqta8eTqmgCNW+CF8HKk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=aE81kzamKD2tlYSp9L3Eur2qhzhRfskxp8Ahe5hLEYWCSvfPxZEVXRqeF7SrWx40A RnabcaX+lcJRj887aGkveANQnTxdmho0q1sHRFpxYgYzUS8a2V4lIdh6ukOWPqYWlV BnkbC/l5KR3WShVdU1NulN39PJAFj4nC3Q0Q8MJ9n8RgLeU2hEZudN/MN5POBKx0VE fYYDvBJQVxrTwuj0mfO9Js760EjYwMiMm42aEUf59ArgFT5nUHmROzvV0bbE1RTvpC ta/sgKXaGkBUWPRCfoftidGzBiXLs4FyfrNLn6eyvJEo5bZVArF26kScxwvgE0zjp9 M62l7jAV7LiaQ== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1CC85CAC582; Sun, 14 Sep 2025 12:56:48 +0000 (UTC) From: Sven Peter Date: Sun, 14 Sep 2025 12:56:06 +0000 Subject: [PATCH 01/11] usb: typec: tipd: Clear interrupts first Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250914-apple-usb3-tipd-v1-1-4e99c8649024@kernel.org> References: <20250914-apple-usb3-tipd-v1-0-4e99c8649024@kernel.org> In-Reply-To: <20250914-apple-usb3-tipd-v1-0-4e99c8649024@kernel.org> To: Heikki Krogerus , Greg Kroah-Hartman Cc: Janne Grunau , Neal Gompa , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org, Sven Peter , stable@kernel.org X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3434; i=sven@kernel.org; h=from:subject:message-id; bh=5qN1hUYg/yBslXEFHt0WeCqqqta8eTqmgCNW+CF8HKk=; b=owGbwMvMwCHmIlirolUq95LxtFoSQ8ax3eXmpxaJGW7hWvku6r/UlmL1WZzVa39n3rHYbfzm/ 3ydczOzOkpZGMQ4GGTFFFm277c3ffLwjeDSTZfew8xhZQIZwsDFKQATOSDKyHAtf1se//3Tsldn r9gafFjd2yItkudRSr397lsdIsVTwv4z/NPp7X316dnxSfaHhG4uzFl0/m7i9U+SGfoHNCqzLvR KP+EAAA== X-Developer-Key: i=sven@kernel.org; a=openpgp; fpr=A1E3E34A2B3C820DBC4955E5993B08092F131F93 X-Endpoint-Received: by B4 Relay for sven@kernel.org/default with auth_id=407 Right now the interrupt handler first reads all updated status registers and only then clears the interrupts. It's possible that a duplicate interrupt for a changed register or plug state comes in after the interrupts have been processed but before they have been cleared: * plug is inserted, TPS_REG_INT_PLUG_EVENT is set * TPS_REG_INT_EVENT1 is read * tps6598x_handle_plug_event() has run and registered the plug * plug is removed again, TPS_REG_INT_PLUG_EVENT is set (again) * TPS_REG_INT_CLEAR1 is written, TPS_REG_INT_PLUG_EVENT is cleared We then have no plug connected and no pending interrupt but the tipd core still thinks there is a plug. It's possible to trigger this with e.g. a slightly broken Type-C to USB A converter. Fix this by first clearing the interrupts and only then reading the updated registers. Fixes: 45188f27b3d0 ("usb: typec: tipd: Add support for Apple CD321X") Fixes: 0a4c005bd171 ("usb: typec: driver for TI TPS6598x USB Power Delivery= controllers") Cc: stable@kernel.org Reviewed-by: Heikki Krogerus Reviewed-by: Neal Gompa Signed-off-by: Sven Peter --- drivers/usb/typec/tipd/core.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index dcf141ada07812295a6f07e41d77f95f98116010..1c80296c3b273e24ceacb3feff4= 32c4f6e6835cc 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -545,24 +545,23 @@ static irqreturn_t cd321x_interrupt(int irq, void *da= ta) if (!event) goto err_unlock; =20 + tps6598x_write64(tps, TPS_REG_INT_CLEAR1, event); + if (!tps6598x_read_status(tps, &status)) - goto err_clear_ints; + goto err_unlock; =20 if (event & APPLE_CD_REG_INT_POWER_STATUS_UPDATE) if (!tps6598x_read_power_status(tps)) - goto err_clear_ints; + goto err_unlock; =20 if (event & APPLE_CD_REG_INT_DATA_STATUS_UPDATE) if (!tps6598x_read_data_status(tps)) - goto err_clear_ints; + goto err_unlock; =20 /* Handle plug insert or removal */ if (event & APPLE_CD_REG_INT_PLUG_EVENT) tps6598x_handle_plug_event(tps, status); =20 -err_clear_ints: - tps6598x_write64(tps, TPS_REG_INT_CLEAR1, event); - err_unlock: mutex_unlock(&tps->lock); =20 @@ -668,25 +667,24 @@ static irqreturn_t tps6598x_interrupt(int irq, void *= data) if (!(event1[0] | event1[1] | event2[0] | event2[1])) goto err_unlock; =20 + tps6598x_block_write(tps, TPS_REG_INT_CLEAR1, event1, intev_len); + tps6598x_block_write(tps, TPS_REG_INT_CLEAR2, event2, intev_len); + if (!tps6598x_read_status(tps, &status)) - goto err_clear_ints; + goto err_unlock; =20 if ((event1[0] | event2[0]) & TPS_REG_INT_POWER_STATUS_UPDATE) if (!tps6598x_read_power_status(tps)) - goto err_clear_ints; + goto err_unlock; =20 if ((event1[0] | event2[0]) & TPS_REG_INT_DATA_STATUS_UPDATE) if (!tps6598x_read_data_status(tps)) - goto err_clear_ints; + goto err_unlock; =20 /* Handle plug insert or removal */ if ((event1[0] | event2[0]) & TPS_REG_INT_PLUG_EVENT) tps6598x_handle_plug_event(tps, status); =20 -err_clear_ints: - tps6598x_block_write(tps, TPS_REG_INT_CLEAR1, event1, intev_len); - tps6598x_block_write(tps, TPS_REG_INT_CLEAR2, event2, intev_len); - err_unlock: mutex_unlock(&tps->lock); =20 --=20 2.34.1 From nobody Thu Oct 2 16:48:57 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 917FE155A4E; Sun, 14 Sep 2025 12:56:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757854608; cv=none; b=EZtSvYdnPKGU93qe+3BrwnmRpvikK78JwsA8y5dkG7kTjGCdrBAURDwHUysFr3qa8yWNZM3PelfcLU1/aE0pp6y7DAzRQZGGwvft7WFhsO/7wW7Sre8msGd51qC9HHe/TV3ihBXfFG2tAxBm9+yas3evDl/aartfeK/brYIqhZc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757854608; c=relaxed/simple; bh=PWktnbKRR/csBSa+TtAeLTOjYJ8uGFc3oo299yXS8Bk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=MTKUZ53tCvEfGVNQSf7+TP7Am+o7eNkEiqmOuU/HW+3/6oX+9CkPhPbmyQM7iSrZ3drlmTdxJSYG4/16WC7K/ZiGqWDXreCTxzRT2PbSeXhg8M45TNcg5+7NiOJ3o2qyTAlSaROZuFrvM4U9c/rjyTzW3UF4jtuSdubijs2USOo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=MrK7XiSk; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="MrK7XiSk" Received: by smtp.kernel.org (Postfix) with ESMTPS id 3ADC8C4CEF5; Sun, 14 Sep 2025 12:56:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757854608; bh=PWktnbKRR/csBSa+TtAeLTOjYJ8uGFc3oo299yXS8Bk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=MrK7XiSkUkQbBf8PHxjrdsNy3szbKC63xIH73M2Mmpg1PBjnxS8dC0YToYh9ImGWC qmY1KAQTgBxq0rUWJ0mLZqxDMjOfoiIQPCDp4c8Z60wGTj81PmAcYDh/86zgHmRz57 5n46ANLsDVujUgRGzXBS/itJSaapbCMrFjYdgJk3+87GKep5XUIIIKtmg4x0wJm9Hd pLugNsI2REuPZwg5EDYCylVnKzgCJLvbK6rclrdbrbf3QX+hB0VwjhfgkzxN3MEgTg 4qfma2vWthjCF/G6EtjsaT2DDa5pW5RSeYwpd91Q0rrMgJtaculv1ikIPJVmt/NGto YizflX96D2Nag== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2AA69CAC594; Sun, 14 Sep 2025 12:56:48 +0000 (UTC) From: Sven Peter Date: Sun, 14 Sep 2025 12:56:07 +0000 Subject: [PATCH 02/11] usb: typec: tipd: Move initial irq mask to tipd_data Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250914-apple-usb3-tipd-v1-2-4e99c8649024@kernel.org> References: <20250914-apple-usb3-tipd-v1-0-4e99c8649024@kernel.org> In-Reply-To: <20250914-apple-usb3-tipd-v1-0-4e99c8649024@kernel.org> To: Heikki Krogerus , Greg Kroah-Hartman Cc: Janne Grunau , Neal Gompa , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org, Sven Peter X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3274; i=sven@kernel.org; h=from:subject:message-id; bh=PWktnbKRR/csBSa+TtAeLTOjYJ8uGFc3oo299yXS8Bk=; b=owGbwMvMwCHmIlirolUq95LxtFoSQ8ax3ZWnNi1l1+uPmrJ70m6BRIn6Tff6bR4bhm6v+qTrE bNiYp1kRykLgxgHg6yYIsv2/famTx6+EVy66dJ7mDmsTCBDGLg4BWAi+VqMDFe454eVH1vL+FtT ZP3SBak+XzJeTmp58mp7QNv8pdYiNQYM/2vfndrw/hFb/937Ex83TLR8p26723Lp4pM5iZNcvu5 u38oOAA== X-Developer-Key: i=sven@kernel.org; a=openpgp; fpr=A1E3E34A2B3C820DBC4955E5993B08092F131F93 X-Endpoint-Received: by B4 Relay for sven@kernel.org/default with auth_id=407 Since the irq mask was originally added more tipd variants have been introduced and there's now struct tipd_data. Move the initial mask in there. Reviewed-by: Heikki Krogerus Reviewed-by: Neal Gompa Signed-off-by: Sven Peter --- drivers/usb/typec/tipd/core.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index 1c80296c3b273e24ceacb3feff432c4f6e6835cc..6d8bcbc9cad8a1394e066504d4c= 5ca570edd4e4f 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -112,6 +112,7 @@ struct tps6598x; =20 struct tipd_data { irq_handler_t irq_handler; + u64 irq_mask1; int (*register_port)(struct tps6598x *tps, struct fwnode_handle *node); void (*trace_power_status)(u16 status); void (*trace_status)(u32 status); @@ -1298,7 +1299,6 @@ static int tps6598x_probe(struct i2c_client *client) u32 status; u32 vid; int ret; - u64 mask1; =20 tps =3D devm_kzalloc(&client->dev, sizeof(*tps), GFP_KERNEL); if (!tps) @@ -1337,16 +1337,6 @@ static int tps6598x_probe(struct i2c_client *client) if (ret) return ret; =20 - /* CD321X chips have all interrupts masked initially */ - mask1 =3D APPLE_CD_REG_INT_POWER_STATUS_UPDATE | - APPLE_CD_REG_INT_DATA_STATUS_UPDATE | - APPLE_CD_REG_INT_PLUG_EVENT; - - } else { - /* Enable power status, data status and plug event interrupts */ - mask1 =3D TPS_REG_INT_POWER_STATUS_UPDATE | - TPS_REG_INT_DATA_STATUS_UPDATE | - TPS_REG_INT_PLUG_EVENT; } =20 tps->data =3D i2c_get_match_data(client); @@ -1364,7 +1354,7 @@ static int tps6598x_probe(struct i2c_client *client) return ret; } =20 - ret =3D tps6598x_write64(tps, TPS_REG_INT_MASK1, mask1); + ret =3D tps6598x_write64(tps, TPS_REG_INT_MASK1, tps->data->irq_mask1); if (ret) goto err_reset_controller; =20 @@ -1527,6 +1517,9 @@ static const struct dev_pm_ops tps6598x_pm_ops =3D { =20 static const struct tipd_data cd321x_data =3D { .irq_handler =3D cd321x_interrupt, + .irq_mask1 =3D APPLE_CD_REG_INT_POWER_STATUS_UPDATE | + APPLE_CD_REG_INT_DATA_STATUS_UPDATE | + APPLE_CD_REG_INT_PLUG_EVENT, .register_port =3D tps6598x_register_port, .trace_power_status =3D trace_tps6598x_power_status, .trace_status =3D trace_tps6598x_status, @@ -1536,6 +1529,9 @@ static const struct tipd_data cd321x_data =3D { =20 static const struct tipd_data tps6598x_data =3D { .irq_handler =3D tps6598x_interrupt, + .irq_mask1 =3D TPS_REG_INT_POWER_STATUS_UPDATE | + TPS_REG_INT_DATA_STATUS_UPDATE | + TPS_REG_INT_PLUG_EVENT, .register_port =3D tps6598x_register_port, .trace_power_status =3D trace_tps6598x_power_status, .trace_status =3D trace_tps6598x_status, @@ -1546,6 +1542,9 @@ static const struct tipd_data tps6598x_data =3D { =20 static const struct tipd_data tps25750_data =3D { .irq_handler =3D tps25750_interrupt, + .irq_mask1 =3D TPS_REG_INT_POWER_STATUS_UPDATE | + TPS_REG_INT_DATA_STATUS_UPDATE | + TPS_REG_INT_PLUG_EVENT, .register_port =3D tps25750_register_port, .trace_power_status =3D trace_tps25750_power_status, .trace_status =3D trace_tps25750_status, --=20 2.34.1 From nobody Thu Oct 2 16:48:57 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 9803F1E7C18; Sun, 14 Sep 2025 12:56:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757854608; cv=none; b=R9MYeeFSgeXMSiH43RzZMKAWFNnaXk2Ypzb0K2vqlE297QDg+a0crsknHIPjnKI2eAkTTG0/PalCSSxib6OiVYfRdxq2p0osPoqhXOh4A2CZ+8vCdl78L2Lf9ZGxFwUXJ0kJ2mdJoxaM9zNy1Is8Dmgah2YmlWquQfwpIzF2ncU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757854608; c=relaxed/simple; bh=sUkw4q4IY9bSBtfRWTCcqxsVU/bRRgymfhNhDOYa7GM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=tT71uMxQ8SP58gcVf2okM3GZww9wEdW/rEoaEutgc3RVf61EPEzcEhKAWSZqzRzsrVvNr6IcJC4H4BRLP7jAee5Mw3sMllK1kwfy1sjYOjQ34bFgPzd35Un74OzHmo8XjXXybMnENZoq0EtsGUPuG2hfd8unv66lHZr1mPGETDc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=UKIriVvi; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="UKIriVvi" Received: by smtp.kernel.org (Postfix) with ESMTPS id 4765BC4CEFD; Sun, 14 Sep 2025 12:56:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757854608; bh=sUkw4q4IY9bSBtfRWTCcqxsVU/bRRgymfhNhDOYa7GM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=UKIriVviyUhz8icNz7vYIZIyWaQo2Ume4+meCG3F82iYctnWeBsLBv04fHA1ORYFL goUJuNn6iCYECVoe6zenmbb7Fn9CbXCHcLQAo1H6mRDRFWvBBrlRkaKhOEv5PeSOA/ 67fm8/bvlcpFc4USAWcxW+SIIWPXJG7YjA3wrOumBcUu0j18BoAOFsTbmDpBX1dKzL r+WU1Zv6373AO/YeyS8z5WnCaleljYvgq8vC6qnAwkgkR9KFf1ZhGV8niVZWmw67Yw TX7ChdhBWhihjWcfUBZ0YBGZNLUn7SactmuwuQPnb5hn57ud0dwmaRjgGu7rCvRpGA UFOHDaEUuGYnA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 392A5CAC58F; Sun, 14 Sep 2025 12:56:48 +0000 (UTC) From: Sven Peter Date: Sun, 14 Sep 2025 12:56:08 +0000 Subject: [PATCH 03/11] usb: typec: tipd: Move switch_power_state to tipd_data Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250914-apple-usb3-tipd-v1-3-4e99c8649024@kernel.org> References: <20250914-apple-usb3-tipd-v1-0-4e99c8649024@kernel.org> In-Reply-To: <20250914-apple-usb3-tipd-v1-0-4e99c8649024@kernel.org> To: Heikki Krogerus , Greg Kroah-Hartman Cc: Janne Grunau , Neal Gompa , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org, Sven Peter X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2365; i=sven@kernel.org; h=from:subject:message-id; bh=sUkw4q4IY9bSBtfRWTCcqxsVU/bRRgymfhNhDOYa7GM=; b=owGbwMvMwCHmIlirolUq95LxtFoSQ8ax3dUsr4w3vX+QVSXGvMxFZcrDtVoXH5RLtggZ/rJZ/ /2estWfjlIWBjEOBlkxRZbt++1Nnzx8I7h006X3MHNYmUCGMHBxCsBEOC4wMvx2C9vxyGm3uVL+ 22CjJTeOqO9RmHLXoSz7d4bkrAbP3JUMv9n1lYzm+l3In8Zg+X23Yu43lV3TPnLxqn08GaAu0HR UnBkA X-Developer-Key: i=sven@kernel.org; a=openpgp; fpr=A1E3E34A2B3C820DBC4955E5993B08092F131F93 X-Endpoint-Received: by B4 Relay for sven@kernel.org/default with auth_id=407 When support for CD321x was originally added no other hardware variant was supported and there was no need for struct tipd_data. Now that it exists move the special case in there so that we can drop the of_device_is_compatible_check entirely. Reviewed-by: Heikki Krogerus Reviewed-by: Neal Gompa Signed-off-by: Sven Peter --- drivers/usb/typec/tipd/core.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index 6d8bcbc9cad8a1394e066504d4c5ca570edd4e4f..4815c5c462837865a5f9d37bbc1= 39249c82c2f75 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -118,6 +118,7 @@ struct tipd_data { void (*trace_status)(u32 status); int (*apply_patch)(struct tps6598x *tps); int (*init)(struct tps6598x *tps); + int (*switch_power_state)(struct tps6598x *tps, u8 target_state); int (*reset)(struct tps6598x *tps); }; =20 @@ -1293,7 +1294,6 @@ tps25750_register_port(struct tps6598x *tps, struct f= wnode_handle *fwnode) =20 static int tps6598x_probe(struct i2c_client *client) { - struct device_node *np =3D client->dev.of_node; struct tps6598x *tps; struct fwnode_handle *fwnode; u32 status; @@ -1331,18 +1331,16 @@ static int tps6598x_probe(struct i2c_client *client) if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) tps->i2c_protocol =3D true; =20 - if (np && of_device_is_compatible(np, "apple,cd321x")) { - /* Switch CD321X chips to the correct system power state */ - ret =3D cd321x_switch_power_state(tps, TPS_SYSTEM_POWER_STATE_S0); - if (ret) - return ret; - - } - tps->data =3D i2c_get_match_data(client); if (!tps->data) return -EINVAL; =20 + if (tps->data->switch_power_state) { + ret =3D tps->data->switch_power_state(tps, TPS_SYSTEM_POWER_STATE_S0); + if (ret) + return ret; + } + /* Make sure the controller has application firmware running */ ret =3D tps6598x_check_mode(tps); if (ret < 0) @@ -1525,6 +1523,7 @@ static const struct tipd_data cd321x_data =3D { .trace_status =3D trace_tps6598x_status, .init =3D cd321x_init, .reset =3D cd321x_reset, + .switch_power_state =3D cd321x_switch_power_state, }; =20 static const struct tipd_data tps6598x_data =3D { --=20 2.34.1 From nobody Thu Oct 2 16:48:57 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 DC12126CE04; Sun, 14 Sep 2025 12:56:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757854609; cv=none; b=pQVcMaLBSs6ZvkRio6egDiO+7r73E4/nQnt9IDuMRHJ9CshSspp0XnDBKSXcIOAvuprgu2Jw0JgVluh+XfEKv7EYnoJTMPMBaippA02VlB564N95K0VqOkkHcdynk7yyp3HjrLrXo07pSiJWJ86PvjmC5BVcYXqZf1x1s2+RsQc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757854609; c=relaxed/simple; bh=bkv8jzt0SlhPpGAzBP2M8JpCFXBPIbTEJnxp6p0XalI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Me3lGYLOip8sgKu8lTNVDrWlBngKsm9nIybfs5vqxMVQpyO7Uvs2k+jAzecy4VKKSEm9SdoDj2pETRv8WvzFf4MUP7R6vkh4VVEqZ9wjgIfUOx54ogKJ+ahP+Ey+WcXVVIc5eoc9uCPGQ5p5jCZfB92dEJbadvHuTZ0xJKMMkgk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=DLr8NEOJ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="DLr8NEOJ" Received: by smtp.kernel.org (Postfix) with ESMTPS id 4DB05C4CEFB; Sun, 14 Sep 2025 12:56:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757854608; bh=bkv8jzt0SlhPpGAzBP2M8JpCFXBPIbTEJnxp6p0XalI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=DLr8NEOJI+EWwgLIw/sjWoQtam15iOEQ5xG5nR4uotN6ha4LFHoa9dHn4XDJp2fqu kKcHecuYr59bZU4PG4i7UA6dvUq36O+69Vw/whoCqLgDXZLowN7gzJvLWxNOi7m16q IRQZYOzC8/RjUyAqk7RU1qbbRO/pS39WbPrzMqhXL+wiaqHXTvjhGmqTtYVCbPTgSR iZk0FI1AJYaBf92UV+66hwvacH8dmreWPOAYRrRHjIX6WnehVGUaBsmsvLgBXOu7yj 0Aye4AlZNtZVHzxL9wlb4x3ClNOhOZFB28RmbTd4z7eNRq+vjSBG+PVUwZ0TgWw2hm /JD+1z/drr4Ng== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4650FCAC582; Sun, 14 Sep 2025 12:56:48 +0000 (UTC) From: Sven Peter Date: Sun, 14 Sep 2025 12:56:09 +0000 Subject: [PATCH 04/11] usb: typec: tipd: Trace data status for CD321x correctly Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250914-apple-usb3-tipd-v1-4-4e99c8649024@kernel.org> References: <20250914-apple-usb3-tipd-v1-0-4e99c8649024@kernel.org> In-Reply-To: <20250914-apple-usb3-tipd-v1-0-4e99c8649024@kernel.org> To: Heikki Krogerus , Greg Kroah-Hartman Cc: Janne Grunau , Neal Gompa , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org, Sven Peter X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=5739; i=sven@kernel.org; h=from:subject:message-id; bh=bkv8jzt0SlhPpGAzBP2M8JpCFXBPIbTEJnxp6p0XalI=; b=owGbwMvMwCHmIlirolUq95LxtFoSQ8ax3TWOx5a5PDk+//kDq4+bnjO8VtS7GLfdIn6ayaaYu 3xVNbcud5SyMIhxMMiKKbJs329v+uThG8Glmy69h5nDygQyhIGLUwAmMsmdkaF7c6PJOa7Q3B0f Qn/kPk8KmmF+c6Jx2F2huKD0Ov5zd/cwMkys3p097WyZ0Y69JX+UpkeZNDW+/cS/vTZRr1ymQe5 OFgsA X-Developer-Key: i=sven@kernel.org; a=openpgp; fpr=A1E3E34A2B3C820DBC4955E5993B08092F131F93 X-Endpoint-Received: by B4 Relay for sven@kernel.org/default with auth_id=407 Some bits inside the CD321x TPS_DATA_STATUS register have a different function compared to the original tipd chip. Add these and introduce a separate trace function to show them correctly. Reviewed-by: Heikki Krogerus Reviewed-by: Neal Gompa Signed-off-by: Sven Peter --- drivers/usb/typec/tipd/core.c | 8 +++++++- drivers/usb/typec/tipd/tps6598x.h | 5 +++++ drivers/usb/typec/tipd/trace.h | 39 +++++++++++++++++++++++++++++++++++= ++++ 3 files changed, 51 insertions(+), 1 deletion(-) diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index 4815c5c462837865a5f9d37bbc139249c82c2f75..19d713937870304e68325a441b0= de63eb5db3b80 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -114,6 +114,7 @@ struct tipd_data { irq_handler_t irq_handler; u64 irq_mask1; int (*register_port)(struct tps6598x *tps, struct fwnode_handle *node); + void (*trace_data_status)(u32 status); void (*trace_power_status)(u16 status); void (*trace_status)(u32 status); int (*apply_patch)(struct tps6598x *tps); @@ -492,7 +493,9 @@ static bool tps6598x_read_data_status(struct tps6598x *= tps) dev_err(tps->dev, "failed to read data status: %d\n", ret); return false; } - trace_tps6598x_data_status(data_status); + + if (tps->data->trace_data_status) + tps->data->trace_data_status(data_status); =20 return true; } @@ -1519,6 +1522,7 @@ static const struct tipd_data cd321x_data =3D { APPLE_CD_REG_INT_DATA_STATUS_UPDATE | APPLE_CD_REG_INT_PLUG_EVENT, .register_port =3D tps6598x_register_port, + .trace_data_status =3D trace_cd321x_data_status, .trace_power_status =3D trace_tps6598x_power_status, .trace_status =3D trace_tps6598x_status, .init =3D cd321x_init, @@ -1532,6 +1536,7 @@ static const struct tipd_data tps6598x_data =3D { TPS_REG_INT_DATA_STATUS_UPDATE | TPS_REG_INT_PLUG_EVENT, .register_port =3D tps6598x_register_port, + .trace_data_status =3D trace_tps6598x_data_status, .trace_power_status =3D trace_tps6598x_power_status, .trace_status =3D trace_tps6598x_status, .apply_patch =3D tps6598x_apply_patch, @@ -1545,6 +1550,7 @@ static const struct tipd_data tps25750_data =3D { TPS_REG_INT_DATA_STATUS_UPDATE | TPS_REG_INT_PLUG_EVENT, .register_port =3D tps25750_register_port, + .trace_data_status =3D trace_tps6598x_data_status, .trace_power_status =3D trace_tps25750_power_status, .trace_status =3D trace_tps25750_status, .apply_patch =3D tps25750_apply_patch, diff --git a/drivers/usb/typec/tipd/tps6598x.h b/drivers/usb/typec/tipd/tps= 6598x.h index cecb8d11d23972dab0d8c15458b4052af7510b03..03edbb77bbd6d8093b2560db83e= 5913e25d06154 100644 --- a/drivers/usb/typec/tipd/tps6598x.h +++ b/drivers/usb/typec/tipd/tps6598x.h @@ -197,6 +197,11 @@ #define TPS_DATA_STATUS_FORCE_LSX BIT(23) #define TPS_DATA_STATUS_POWER_MISMATCH BIT(24) =20 +/* modified TPS_REG_DATA_STATUS bits for CD321x (and likely also TPS65987D= DK) */ +#define CD321X_DATA_STATUS_HPD_IRQ BIT(14) +#define CD321X_DATA_STATUS_HPD_LEVEL BIT(15) +#define CD321X_DATA_STATUS_USB4_CONNECTION BIT(23) + #define TPS_DATA_STATUS_DP_PIN_ASSIGNMENT_MASK GENMASK(11, 10) #define TPS_DATA_STATUS_DP_PIN_ASSIGNMENT(x) \ TPS_FIELD_GET(TPS_DATA_STATUS_DP_PIN_ASSIGNMENT_MASK, (x)) diff --git a/drivers/usb/typec/tipd/trace.h b/drivers/usb/typec/tipd/trace.h index bea383f2db9de5bbf1804fbad9ee6b134407b932..e9e40425138a01f15e35867f38f= 62e13623dbcec 100644 --- a/drivers/usb/typec/tipd/trace.h +++ b/drivers/usb/typec/tipd/trace.h @@ -217,6 +217,26 @@ { TPS_DATA_STATUS_FORCE_LSX, "FORCE_LSX" }, \ { TPS_DATA_STATUS_POWER_MISMATCH, "POWER_MISMATCH" }) =20 +#define show_cd321x_data_status_flags(data_status) \ + __print_flags(data_status & TPS_DATA_STATUS_FLAGS_MASK, "|", \ + { TPS_DATA_STATUS_DATA_CONNECTION, "DATA_CONNECTION" }, \ + { TPS_DATA_STATUS_UPSIDE_DOWN, "DATA_UPSIDE_DOWN" }, \ + { TPS_DATA_STATUS_ACTIVE_CABLE, "ACTIVE_CABLE" }, \ + { TPS_DATA_STATUS_USB2_CONNECTION, "USB2_CONNECTION" }, \ + { TPS_DATA_STATUS_USB3_CONNECTION, "USB3_CONNECTION" }, \ + { TPS_DATA_STATUS_USB3_GEN2, "USB3_GEN2" }, \ + { TPS_DATA_STATUS_USB_DATA_ROLE, "USB_DATA_ROLE" }, \ + { TPS_DATA_STATUS_DP_CONNECTION, "DP_CONNECTION" }, \ + { TPS_DATA_STATUS_DP_SINK, "DP_SINK" }, \ + { CD321X_DATA_STATUS_HPD_IRQ, "HPD_IRQ" }, \ + { CD321X_DATA_STATUS_HPD_LEVEL, "HPD_LEVEL" }, \ + { TPS_DATA_STATUS_TBT_CONNECTION, "TBT_CONNECTION" }, \ + { TPS_DATA_STATUS_TBT_TYPE, "TBT_TYPE" }, \ + { TPS_DATA_STATUS_OPTICAL_CABLE, "OPTICAL_CABLE" }, \ + { TPS_DATA_STATUS_ACTIVE_LINK_TRAIN, "ACTIVE_LINK_TRAIN" }, \ + { CD321X_DATA_STATUS_USB4_CONNECTION, "USB4" }, \ + { TPS_DATA_STATUS_POWER_MISMATCH, "POWER_MISMATCH" }) + #define show_data_status_dp_pin_assignment(data_status) \ __print_symbolic(TPS_DATA_STATUS_DP_SPEC_PIN_ASSIGNMENT(data_status), \ { TPS_DATA_STATUS_DP_SPEC_PIN_ASSIGNMENT_E, "E" }, \ @@ -388,6 +408,25 @@ TRACE_EVENT(tps6598x_data_status, ) ); =20 +TRACE_EVENT(cd321x_data_status, + TP_PROTO(u32 data_status), + TP_ARGS(data_status), + + TP_STRUCT__entry( + __field(u32, data_status) + ), + + TP_fast_assign( + __entry->data_status =3D data_status; + ), + + TP_printk("%s%s%s", + show_cd321x_data_status_flags(__entry->data_status), + __entry->data_status & TPS_DATA_STATUS_DP_CONNECTION ? ", DP pinout " = : "", + maybe_show_data_status_dp_pin_assignment(__entry->data_status) + ) +); + #endif /* _TPS6598X_TRACE_H_ */ =20 /* This part must be outside protection */ --=20 2.34.1 From nobody Thu Oct 2 16:48:57 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 DD08A26CE23; Sun, 14 Sep 2025 12:56:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757854609; cv=none; b=UMeBvAGqF4YkWxjfcWAp8Seccs/0XaCVMu4gB1bA697KwrR814W8NkNhmPpyTqnjyPoMsOtYd3YqUocPY7npH5TcpG7eChjbH8ZHFb+LKf9lIIvpw784J2CJ7pmeX7W7IR6Ek+PHOIOt9soXUG9i42ZT+YM3K0YKLvenpavSpWE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757854609; c=relaxed/simple; bh=nZk44p+QqpioWkfSX5+bKeVart8pQqEx9xjGIa/iQGY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=VemlHlZ+SCsGdA3oY6sfE3JyJkrfNtdSxV/Rsj9SWjXIy3lxgWKtaOFmy3ajDibH+kyYCU16Xic84m169C2f8kX9YM985A/jZS4thGZue45rZ4kVZKldlcOJVZDMJa4ukAajte2FsxCdPOsENlMcmgobJbhiM9HLSuSjAy8qE9A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=aIECAbE+; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="aIECAbE+" Received: by smtp.kernel.org (Postfix) with ESMTPS id 59F23C4CEFF; Sun, 14 Sep 2025 12:56:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757854608; bh=nZk44p+QqpioWkfSX5+bKeVart8pQqEx9xjGIa/iQGY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=aIECAbE+E4sSQUK65ku7nSLVgiur9eEdHaThjB7yOF3HNhn2gVJccPdKe7pjxmccE 3zovb7PO3l6y3N6WPhmLeJNiODZ9mPPb45lT07+6rN2K9iyHGUSdLEviS3lCwjyd54 7bcMJcOFabkfQ3bGYLlFz4efVIQJIZmVeopF2HYV6IU+fJPi0Z9iwWyYNUEvcfJBNx oWWR9mSRTXhtTk+y7FfMGPKaQAe9hCvfnuqemjkW+17WBNzsvvFWUdd8E6vwHCI1ax 9gw9CoS0tq5qLsHIvmGOb0xy7KqKfhz5UU0K38eVfdmMi4NKtgj7GoQfIHNFc4XQNK Gq/KsEjk8PMDw== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 537B1CAC597; Sun, 14 Sep 2025 12:56:48 +0000 (UTC) From: Sven Peter Date: Sun, 14 Sep 2025 12:56:10 +0000 Subject: [PATCH 05/11] usb: typec: tipd: Add cd321x struct with separate size Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250914-apple-usb3-tipd-v1-5-4e99c8649024@kernel.org> References: <20250914-apple-usb3-tipd-v1-0-4e99c8649024@kernel.org> In-Reply-To: <20250914-apple-usb3-tipd-v1-0-4e99c8649024@kernel.org> To: Heikki Krogerus , Greg Kroah-Hartman Cc: Janne Grunau , Neal Gompa , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org, Sven Peter X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3612; i=sven@kernel.org; h=from:subject:message-id; bh=nZk44p+QqpioWkfSX5+bKeVart8pQqEx9xjGIa/iQGY=; b=owGbwMvMwCHmIlirolUq95LxtFoSQ8ax3XXXeGo/cS64FZzr0VBfuOOJ08LZDfe2sJjYfhDU9 njHybm6o5SFQYyDQVZMkWX7fnvTJw/fCC7ddOk9zBxWJpAhDFycAjAR3zhGhsd/r5yxm+Z99z6j gcqcsPxq32Xli15WKzfe9/nVo1ySO4eR4dzc/72zq9otPnX/aZghd2uby8rJeqli7+7//bS8euH JD+wA X-Developer-Key: i=sven@kernel.org; a=openpgp; fpr=A1E3E34A2B3C820DBC4955E5993B08092F131F93 X-Endpoint-Received: by B4 Relay for sven@kernel.org/default with auth_id=407 We're about to add more fields to struct tps6598x which are only relevant for Apple's CD321x and to ensure that we don't waste memory everywhere for those add a separate struct for cd321x and prepare to allocate more space inside probe. Reviewed-by: Heikki Krogerus Reviewed-by: Neal Gompa Signed-off-by: Sven Peter --- drivers/usb/typec/tipd/core.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index 19d713937870304e68325a441b0de63eb5db3b80..51b0f3be8b66a743ddc3ea96c1b= 25f597a1e8f6c 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -113,6 +113,7 @@ struct tps6598x; struct tipd_data { irq_handler_t irq_handler; u64 irq_mask1; + size_t tps_struct_size; int (*register_port)(struct tps6598x *tps, struct fwnode_handle *node); void (*trace_data_status)(u32 status); void (*trace_power_status)(u16 status); @@ -148,6 +149,10 @@ struct tps6598x { const struct tipd_data *data; }; =20 +struct cd321x { + struct tps6598x tps; +}; + static enum power_supply_property tps6598x_psy_props[] =3D { POWER_SUPPLY_PROP_USB_TYPE, POWER_SUPPLY_PROP_ONLINE, @@ -1297,18 +1302,24 @@ tps25750_register_port(struct tps6598x *tps, struct= fwnode_handle *fwnode) =20 static int tps6598x_probe(struct i2c_client *client) { + const struct tipd_data *data; struct tps6598x *tps; struct fwnode_handle *fwnode; u32 status; u32 vid; int ret; =20 - tps =3D devm_kzalloc(&client->dev, sizeof(*tps), GFP_KERNEL); + data =3D i2c_get_match_data(client); + if (!data) + return -EINVAL; + + tps =3D devm_kzalloc(&client->dev, data->tps_struct_size, GFP_KERNEL); if (!tps) return -ENOMEM; =20 mutex_init(&tps->lock); tps->dev =3D &client->dev; + tps->data =3D data; =20 tps->reset =3D devm_gpiod_get_optional(tps->dev, "reset", GPIOD_OUT_LOW); if (IS_ERR(tps->reset)) @@ -1334,10 +1345,6 @@ static int tps6598x_probe(struct i2c_client *client) if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) tps->i2c_protocol =3D true; =20 - tps->data =3D i2c_get_match_data(client); - if (!tps->data) - return -EINVAL; - if (tps->data->switch_power_state) { ret =3D tps->data->switch_power_state(tps, TPS_SYSTEM_POWER_STATE_S0); if (ret) @@ -1521,6 +1528,7 @@ static const struct tipd_data cd321x_data =3D { .irq_mask1 =3D APPLE_CD_REG_INT_POWER_STATUS_UPDATE | APPLE_CD_REG_INT_DATA_STATUS_UPDATE | APPLE_CD_REG_INT_PLUG_EVENT, + .tps_struct_size =3D sizeof(struct cd321x), .register_port =3D tps6598x_register_port, .trace_data_status =3D trace_cd321x_data_status, .trace_power_status =3D trace_tps6598x_power_status, @@ -1535,6 +1543,7 @@ static const struct tipd_data tps6598x_data =3D { .irq_mask1 =3D TPS_REG_INT_POWER_STATUS_UPDATE | TPS_REG_INT_DATA_STATUS_UPDATE | TPS_REG_INT_PLUG_EVENT, + .tps_struct_size =3D sizeof(struct tps6598x), .register_port =3D tps6598x_register_port, .trace_data_status =3D trace_tps6598x_data_status, .trace_power_status =3D trace_tps6598x_power_status, @@ -1549,6 +1558,7 @@ static const struct tipd_data tps25750_data =3D { .irq_mask1 =3D TPS_REG_INT_POWER_STATUS_UPDATE | TPS_REG_INT_DATA_STATUS_UPDATE | TPS_REG_INT_PLUG_EVENT, + .tps_struct_size =3D sizeof(struct tps6598x), .register_port =3D tps25750_register_port, .trace_data_status =3D trace_tps6598x_data_status, .trace_power_status =3D trace_tps25750_power_status, --=20 2.34.1 From nobody Thu Oct 2 16:48:57 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 DCFE526CE0F; Sun, 14 Sep 2025 12:56:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757854609; cv=none; b=gYvt+Hu6VAJL/n9QxgdUqHvz4o863I/V8XJSwgvLwwUF2+zw7Ow+GaHLCq/0E2+Prj2y4vlNsyOzvZqGsNAdLICQR6O2+gY4KVZ9lADzwAR48BZBnPLJ0MVhSyd+SHD7vVNp+j7JWcfnil75AeXYzRkFXPdhbQDb7+Gda8t7GMU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757854609; c=relaxed/simple; bh=Ja/ouRqKzMAB5q3ltXQSrR3nQhDkrwWQY9JfEOnd8P0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=I1DP3V/J2m0dW+H6oIHwClp0aVXHUcw4RA7SLGgOTkzgQfriH3kNpDnQ+1gYNh4/PjuX5d53bTNcxo+LI+U9af3uWJYL0AIHNDC8rGfMfBvyebNLhYH7H6r817It+SChN9t7XXtMDeq9DL4lTpTswl8Eyz9d9Bxqlc5aPDibsO8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=hjtxgRmR; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="hjtxgRmR" Received: by smtp.kernel.org (Postfix) with ESMTPS id 67FE7C113CF; Sun, 14 Sep 2025 12:56:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757854608; bh=Ja/ouRqKzMAB5q3ltXQSrR3nQhDkrwWQY9JfEOnd8P0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=hjtxgRmRJxe9zKjxyWB6jscQM58Z2Romu7oY2TFxjwabNVEiH5yJUbLO51Waz5H49 j7RHxKGnPJ3W/482g97pqCMHpwUVOHJDbu2qhudiPHUe6NjBrxh6AxcfXPm5t0ejbS RPyPKSVcrUbjtcchnQ2YTL1JgvAaaHItIAZ0q+VxOia+WxxhHPgbn3KcnASsJ+9miZ R7DX/3Mo4r2PDe9YMlXyCNxB+2RDF5vBqMYMCJUhbxu7JD0WTgzew5jGjlTctuxO88 Ljz27Daka2PcR5hAEwZd6bdGqZm36JxgOOTbPFDq+HNSrv7fgfZmW4Mso/4/N4qxB/ GEGhsQnNsFz0w== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 611D6CAC598; Sun, 14 Sep 2025 12:56:48 +0000 (UTC) From: Sven Peter Date: Sun, 14 Sep 2025 12:56:11 +0000 Subject: [PATCH 06/11] usb: typec: tipd: Read USB4, Thunderbolt and DisplayPort status for cd321x Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250914-apple-usb3-tipd-v1-6-4e99c8649024@kernel.org> References: <20250914-apple-usb3-tipd-v1-0-4e99c8649024@kernel.org> In-Reply-To: <20250914-apple-usb3-tipd-v1-0-4e99c8649024@kernel.org> To: Heikki Krogerus , Greg Kroah-Hartman Cc: Janne Grunau , Neal Gompa , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org, Sven Peter X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=5790; i=sven@kernel.org; h=from:subject:message-id; bh=Ja/ouRqKzMAB5q3ltXQSrR3nQhDkrwWQY9JfEOnd8P0=; b=owGbwMvMwCHmIlirolUq95LxtFoSQ8ax3fUcdXnfq/Y1Rdx/3hLsOCddX+5s7Dzt5VJr/+7UZ 7uwsWR9RykLgxgHg6yYIsv2/famTx6+EVy66dJ7mDmsTCBDGLg4BWAiNTcYGebG3LwexRLsqLns nZ1r60I21Rd5BocYHwf8atWMeK/csYDhN8tb1mPyh39deJBm/fLmpM8OIVW3GRnE2hfkx+oq1Hu wcAMA X-Developer-Key: i=sven@kernel.org; a=openpgp; fpr=A1E3E34A2B3C820DBC4955E5993B08092F131F93 X-Endpoint-Received: by B4 Relay for sven@kernel.org/default with auth_id=407 CD321x supports various alternate modes and stores information once these are entered into separate status registers. Read those when they are active when reading TPS_DATA_STATUS to prepare supporting these. Reviewed-by: Heikki Krogerus Reviewed-by: Neal Gompa Signed-off-by: Sven Peter --- drivers/usb/typec/tipd/core.c | 80 +++++++++++++++++++++++++++++++++++++++= +--- 1 file changed, 76 insertions(+), 4 deletions(-) diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index 51b0f3be8b66a743ddc3ea96c1b25f597a1e8f6c..afd11b3e1ae596c7f3283e4336a= aa57874c9378d 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -35,14 +35,18 @@ #define TPS_REG_INT_MASK2 0x17 #define TPS_REG_INT_CLEAR1 0x18 #define TPS_REG_INT_CLEAR2 0x19 -#define TPS_REG_SYSTEM_POWER_STATE 0x20 #define TPS_REG_STATUS 0x1a +#define TPS_REG_SYSTEM_POWER_STATE 0x20 +#define TPS_REG_USB4_STATUS 0x24 #define TPS_REG_SYSTEM_CONF 0x28 #define TPS_REG_CTRL_CONF 0x29 #define TPS_REG_BOOT_STATUS 0x2D #define TPS_REG_POWER_STATUS 0x3f #define TPS_REG_PD_STATUS 0x40 #define TPS_REG_RX_IDENTITY_SOP 0x48 +#define TPS_REG_CF_VID_STATUS 0x5e +#define TPS_REG_DP_SID_STATUS 0x58 +#define TPS_REG_INTEL_VID_STATUS 0x59 #define TPS_REG_DATA_STATUS 0x5f #define TPS_REG_SLEEP_CONF 0x70 =20 @@ -85,6 +89,31 @@ struct tps6598x_rx_identity_reg { struct usb_pd_identity identity; } __packed; =20 +/* TPS_REG_USB4_STATUS */ +struct tps6598x_usb4_status_reg { + u8 mode_status; + __le32 eudo; + __le32 unknown; +} __packed; + +/* TPS_REG_DP_SID_STATUS */ +struct tps6598x_dp_sid_status_reg { + u8 mode_status; + __le32 status_tx; + __le32 status_rx; + __le32 configure; + __le32 mode_data; +} __packed; + +/* TPS_REG_INTEL_VID_STATUS */ +struct tps6598x_intel_vid_status_reg { + u8 mode_status; + __le32 attention_vdo; + __le16 enter_vdo; + __le16 device_mode; + __le16 cable_mode; +} __packed; + /* Standard Task return codes */ #define TPS_TASK_TIMEOUT 1 #define TPS_TASK_REJECTED 3 @@ -121,6 +150,7 @@ struct tipd_data { int (*apply_patch)(struct tps6598x *tps); int (*init)(struct tps6598x *tps); int (*switch_power_state)(struct tps6598x *tps, u8 target_state); + bool (*read_data_status)(struct tps6598x *tps); int (*reset)(struct tps6598x *tps); }; =20 @@ -151,6 +181,10 @@ struct tps6598x { =20 struct cd321x { struct tps6598x tps; + + struct tps6598x_dp_sid_status_reg dp_sid_status; + struct tps6598x_intel_vid_status_reg intel_vid_status; + struct tps6598x_usb4_status_reg usb4_status; }; =20 static enum power_supply_property tps6598x_psy_props[] =3D { @@ -505,6 +539,41 @@ static bool tps6598x_read_data_status(struct tps6598x = *tps) return true; } =20 +static bool cd321x_read_data_status(struct tps6598x *tps) +{ + struct cd321x *cd321x =3D container_of(tps, struct cd321x, tps); + int ret; + + ret =3D tps6598x_read_data_status(tps); + if (ret < 0) + return false; + + if (tps->data_status & TPS_DATA_STATUS_DP_CONNECTION) { + ret =3D tps6598x_block_read(tps, TPS_REG_DP_SID_STATUS, + &cd321x->dp_sid_status, sizeof(cd321x->dp_sid_status)); + if (ret) + dev_err(tps->dev, "Failed to read DP SID Status: %d\n", + ret); + } + + if (tps->data_status & TPS_DATA_STATUS_TBT_CONNECTION) { + ret =3D tps6598x_block_read(tps, TPS_REG_INTEL_VID_STATUS, + &cd321x->intel_vid_status, sizeof(cd321x->intel_vid_status)); + if (ret) + dev_err(tps->dev, "Failed to read Intel VID Status: %d\n", ret); + } + + if (tps->data_status & CD321X_DATA_STATUS_USB4_CONNECTION) { + ret =3D tps6598x_block_read(tps, TPS_REG_USB4_STATUS, + &cd321x->usb4_status, sizeof(cd321x->usb4_status)); + if (ret) + dev_err(tps->dev, + "Failed to read USB4 Status: %d\n", ret); + } + + return true; +} + static bool tps6598x_read_power_status(struct tps6598x *tps) { u16 pwr_status; @@ -565,7 +634,7 @@ static irqreturn_t cd321x_interrupt(int irq, void *data) goto err_unlock; =20 if (event & APPLE_CD_REG_INT_DATA_STATUS_UPDATE) - if (!tps6598x_read_data_status(tps)) + if (!tps->data->read_data_status(tps)) goto err_unlock; =20 /* Handle plug insert or removal */ @@ -614,7 +683,7 @@ static irqreturn_t tps25750_interrupt(int irq, void *da= ta) goto err_clear_ints; =20 if (event[0] & TPS_REG_INT_DATA_STATUS_UPDATE) - if (!tps6598x_read_data_status(tps)) + if (!tps->data->read_data_status(tps)) goto err_clear_ints; =20 /* @@ -688,7 +757,7 @@ static irqreturn_t tps6598x_interrupt(int irq, void *da= ta) goto err_unlock; =20 if ((event1[0] | event2[0]) & TPS_REG_INT_DATA_STATUS_UPDATE) - if (!tps6598x_read_data_status(tps)) + if (!tps->data->read_data_status(tps)) goto err_unlock; =20 /* Handle plug insert or removal */ @@ -1534,6 +1603,7 @@ static const struct tipd_data cd321x_data =3D { .trace_power_status =3D trace_tps6598x_power_status, .trace_status =3D trace_tps6598x_status, .init =3D cd321x_init, + .read_data_status =3D cd321x_read_data_status, .reset =3D cd321x_reset, .switch_power_state =3D cd321x_switch_power_state, }; @@ -1550,6 +1620,7 @@ static const struct tipd_data tps6598x_data =3D { .trace_status =3D trace_tps6598x_status, .apply_patch =3D tps6598x_apply_patch, .init =3D tps6598x_init, + .read_data_status =3D tps6598x_read_data_status, .reset =3D tps6598x_reset, }; =20 @@ -1565,6 +1636,7 @@ static const struct tipd_data tps25750_data =3D { .trace_status =3D trace_tps25750_status, .apply_patch =3D tps25750_apply_patch, .init =3D tps25750_init, + .read_data_status =3D tps6598x_read_data_status, .reset =3D tps25750_reset, }; =20 --=20 2.34.1 From nobody Thu Oct 2 16:48:57 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 D8FCA26C3A4; Sun, 14 Sep 2025 12:56:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757854608; cv=none; b=qdhAPql/gXhOSuBodHs/57nTf7Lep2VSn8iiLJrMqigDbMlRUpZFXLGbQLnrzIZy4vWqR33RFdmQz1H/iZ0OtDXohoe7U99Zbjser3DCETLTOqXb15PN+yjjYi1Zohv7NOyjb2sGCUN8bN5gWY9ES5PqvJdQv2/dpzxhdLn8yfg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757854608; c=relaxed/simple; bh=90KthqrDnapyUT4Ni6YoQa7BmryV8lEQlLoxgEjdzu4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=asikKM1hhJHR43g4BbTSrlTmxPGq8ppEdOOtSaQW4HUIhI0wrA0lhT9/cp5IIIHkk8tjXX67EJkgd5f8IjgbOr0a7P6z2sY+GH15hRAqliS9HXzkFJ3VLhxWlH9jJA/maeGqOyAj0N3eJoJFuwUBLlfLgr/Zz9qz4inV+5AXWBU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=rwTO3DfC; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="rwTO3DfC" Received: by smtp.kernel.org (Postfix) with ESMTPS id 7510EC4CEFE; Sun, 14 Sep 2025 12:56:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757854608; bh=90KthqrDnapyUT4Ni6YoQa7BmryV8lEQlLoxgEjdzu4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=rwTO3DfCaxpC9VK08AgOrbIS8Pl4wFV+d98fL1mLuHuT/TXiHYBbqBBTc9vpb5Zh6 4tSc4MlJnywdR+uCDXioK4uReXGsSWDTVcdE73ic+ByfWANguj9o2n2ZBpUS19DtRk CNUXij8mT9mA1FYtpZe3PWHIeJKzIi69tXuZa/eFEYYCCQy0N28lvYDT0aepTaAIX3 9crOsloafIHDsrV/1fZZFMaSM2Ns3OOnAL6wBIf2Qqnx+dhDHfYy+mZZPl/Taw++qo HMLxvU3lrSmXFiiHMGEXlhh/9J1hPV26BiKWrvmkVwHRfDbfzTpVdpoR7ZgFFqznqw i3Xf06tbX1D5g== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6CC37CAC587; Sun, 14 Sep 2025 12:56:48 +0000 (UTC) From: Sven Peter Date: Sun, 14 Sep 2025 12:56:12 +0000 Subject: [PATCH 07/11] usb: typec: tipd: Register DisplayPort and Thunderbolt altmodes for cd321x Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250914-apple-usb3-tipd-v1-7-4e99c8649024@kernel.org> References: <20250914-apple-usb3-tipd-v1-0-4e99c8649024@kernel.org> In-Reply-To: <20250914-apple-usb3-tipd-v1-0-4e99c8649024@kernel.org> To: Heikki Krogerus , Greg Kroah-Hartman Cc: Janne Grunau , Neal Gompa , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org, Sven Peter X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=5651; i=sven@kernel.org; h=from:subject:message-id; bh=90KthqrDnapyUT4Ni6YoQa7BmryV8lEQlLoxgEjdzu4=; b=owGbwMvMwCHmIlirolUq95LxtFoSQ8ax3Y0a6/95ej9KOTEl/se0C+FfHj7OsuI7V6cmu3vPh SlTmoxyOkpZGMQ4GGTFFFm277c3ffLwjeDSTZfew8xhZQIZwsDFKQATMV3PyPB70wbpPsNKvVqm 3Ts4vya92FFivvZEoUq26FnvL2knFKwZ/unEGt2O6ri8/M+yraUv/m7qtil5PeucjMmL8jUev21 197EDAA== X-Developer-Key: i=sven@kernel.org; a=openpgp; fpr=A1E3E34A2B3C820DBC4955E5993B08092F131F93 X-Endpoint-Received: by B4 Relay for sven@kernel.org/default with auth_id=407 Ports equipped with a CD321x are only found on Apple Silicon machines and always support DisplayPort, Thunderbolt and USB4. Register these port modes unconditionally. Reviewed-by: Heikki Krogerus Reviewed-by: Neal Gompa Signed-off-by: Sven Peter --- drivers/usb/typec/tipd/core.c | 85 +++++++++++++++++++++++++++++++++++++++= ++-- 1 file changed, 82 insertions(+), 3 deletions(-) diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index afd11b3e1ae596c7f3283e4336aaa57874c9378d..c7cf936e5a61a331271c05b68ff= 1b77b89c0f643 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -16,6 +16,8 @@ #include #include #include +#include +#include #include #include #include @@ -144,6 +146,7 @@ struct tipd_data { u64 irq_mask1; size_t tps_struct_size; int (*register_port)(struct tps6598x *tps, struct fwnode_handle *node); + void (*unregister_port)(struct tps6598x *tps); void (*trace_data_status)(u32 status); void (*trace_power_status)(u16 status); void (*trace_status)(u32 status); @@ -185,6 +188,9 @@ struct cd321x { struct tps6598x_dp_sid_status_reg dp_sid_status; struct tps6598x_intel_vid_status_reg intel_vid_status; struct tps6598x_usb4_status_reg usb4_status; + + struct typec_altmode *port_altmode_dp; + struct typec_altmode *port_altmode_tbt; }; =20 static enum power_supply_property tps6598x_psy_props[] =3D { @@ -964,6 +970,76 @@ tps6598x_register_port(struct tps6598x *tps, struct fw= node_handle *fwnode) return 0; } =20 +static int cd321x_register_port_altmodes(struct cd321x *cd321x) +{ + struct typec_altmode_desc desc; + struct typec_altmode *amode; + + memset(&desc, 0, sizeof(desc)); + desc.svid =3D USB_TYPEC_DP_SID; + desc.mode =3D USB_TYPEC_DP_MODE; + desc.vdo =3D DP_CONF_SET_PIN_ASSIGN(BIT(DP_PIN_ASSIGN_C) | BIT(DP_PIN_ASS= IGN_D)); + desc.vdo |=3D DP_CAP_DFP_D; + amode =3D typec_port_register_altmode(cd321x->tps.port, &desc); + if (IS_ERR(amode)) + return PTR_ERR(amode); + cd321x->port_altmode_dp =3D amode; + + memset(&desc, 0, sizeof(desc)); + desc.svid =3D USB_TYPEC_TBT_SID; + desc.mode =3D TYPEC_ANY_MODE; + amode =3D typec_port_register_altmode(cd321x->tps.port, &desc); + if (IS_ERR(amode)) { + typec_unregister_altmode(cd321x->port_altmode_dp); + cd321x->port_altmode_dp =3D NULL; + return PTR_ERR(amode); + } + cd321x->port_altmode_tbt =3D amode; + + return 0; +} + +static int +cd321x_register_port(struct tps6598x *tps, struct fwnode_handle *fwnode) +{ + struct cd321x *cd321x =3D container_of(tps, struct cd321x, tps); + int ret; + + ret =3D tps6598x_register_port(tps, fwnode); + if (ret) + return ret; + + ret =3D cd321x_register_port_altmodes(cd321x); + if (ret) + goto err_unregister_port; + + typec_set_mode(tps->port, TYPEC_STATE_SAFE); + + return 0; + +err_unregister_port: + typec_unregister_port(tps->port); + return ret; +} + +static void +tps6598x_unregister_port(struct tps6598x *tps) +{ + typec_unregister_port(tps->port); +} + +static void +cd321x_unregister_port(struct tps6598x *tps) +{ + struct cd321x *cd321x =3D container_of(tps, struct cd321x, tps); + + typec_unregister_altmode(cd321x->port_altmode_dp); + cd321x->port_altmode_dp =3D NULL; + typec_unregister_altmode(cd321x->port_altmode_tbt); + cd321x->port_altmode_tbt =3D NULL; + typec_unregister_port(tps->port); +} + static int tps_request_firmware(struct tps6598x *tps, const struct firmwar= e **fw, const char **firmware_name) { @@ -1505,7 +1581,7 @@ static int tps6598x_probe(struct i2c_client *client) err_disconnect: tps6598x_disconnect(tps, 0); err_unregister_port: - typec_unregister_port(tps->port); + tps->data->unregister_port(tps); err_role_put: usb_role_switch_put(tps->role_sw); err_fwnode_put: @@ -1529,7 +1605,7 @@ static void tps6598x_remove(struct i2c_client *client) devm_free_irq(tps->dev, client->irq, tps); =20 tps6598x_disconnect(tps, 0); - typec_unregister_port(tps->port); + tps->data->unregister_port(tps); usb_role_switch_put(tps->role_sw); =20 /* Reset PD controller to remove any applied patch */ @@ -1598,7 +1674,8 @@ static const struct tipd_data cd321x_data =3D { APPLE_CD_REG_INT_DATA_STATUS_UPDATE | APPLE_CD_REG_INT_PLUG_EVENT, .tps_struct_size =3D sizeof(struct cd321x), - .register_port =3D tps6598x_register_port, + .register_port =3D cd321x_register_port, + .unregister_port =3D cd321x_unregister_port, .trace_data_status =3D trace_cd321x_data_status, .trace_power_status =3D trace_tps6598x_power_status, .trace_status =3D trace_tps6598x_status, @@ -1615,6 +1692,7 @@ static const struct tipd_data tps6598x_data =3D { TPS_REG_INT_PLUG_EVENT, .tps_struct_size =3D sizeof(struct tps6598x), .register_port =3D tps6598x_register_port, + .unregister_port =3D tps6598x_unregister_port, .trace_data_status =3D trace_tps6598x_data_status, .trace_power_status =3D trace_tps6598x_power_status, .trace_status =3D trace_tps6598x_status, @@ -1631,6 +1709,7 @@ static const struct tipd_data tps25750_data =3D { TPS_REG_INT_PLUG_EVENT, .tps_struct_size =3D sizeof(struct tps6598x), .register_port =3D tps25750_register_port, + .unregister_port =3D tps6598x_unregister_port, .trace_data_status =3D trace_tps6598x_data_status, .trace_power_status =3D trace_tps25750_power_status, .trace_status =3D trace_tps25750_status, --=20 2.34.1 From nobody Thu Oct 2 16:48:57 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 DD80326CE32; Sun, 14 Sep 2025 12:56:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757854609; cv=none; b=MYen8zQ0WE9zOdpYZFdSrTg2NRQM6ReBGscsElZgnTLaMdT4DVwsarwyHsSMqsUfkaGOaWH6OAjDg3wTgpZ8lqFwIYTBha3rxbo+pTiD6XTf22YiyNf7PoApxRwBlKPseYG2mSzjERoYiUIHfx4LjQ3FFMe3aKzeY2CoqK7arv0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757854609; c=relaxed/simple; bh=vOCSchiqykXCoVM7fs9znsbVw4UvLeu+/CcSAFHKCss=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=mcvi19by4NP+YrG1Oql+3YATWV1itizLX5tj+gDVDHJ8EF6Hl04vmMCZgwoLqDohQ3M3M/oC2EDmlOJL3SWHZ9JEBdkAFPe7/I688qEJD4CMNKL3TpLjUC2vCvw4MMeeHxZhckD++Bu49GHHiwbYOGguerLUh8gxtwg5Lp8amfo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=VRkdzLI8; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="VRkdzLI8" Received: by smtp.kernel.org (Postfix) with ESMTPS id 828DDC16AAE; Sun, 14 Sep 2025 12:56:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757854608; bh=vOCSchiqykXCoVM7fs9znsbVw4UvLeu+/CcSAFHKCss=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=VRkdzLI8aXCkPTftCtYSvhS0yi6xG7iIeE5bYLTAM1jFOVZYXJu3LV5d+76dHXnta mlmcnuySMKsQIOIaY1AhnLeC0U0JcZblVIUixdNFQSb0b7f2TOnVTs9WNOlkHhQf6a q7xW+FzMjtkrs9ZzNr09C/BP+/RV0X9mTLpDBdzBJqEXRxvnRnfz6Qoaqk9xvSTru2 vBXw2KsTNPrDrCFbJYDLRs/fQUM7Oep10BDxEEH9ZK8IrfrQMZdnuqQhQsC5Un4G1o FWl55ssNbHe7p3IQpgFUL7TLia8gnT+Oc2bBn1w1VIO+pDRAOtkQYP4vflEwBK9diz QY6miSD8fx5qw== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 799E4CAC58F; Sun, 14 Sep 2025 12:56:48 +0000 (UTC) From: Sven Peter Date: Sun, 14 Sep 2025 12:56:13 +0000 Subject: [PATCH 08/11] usb: typec: tipd: Update partner identity when power status was updated Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250914-apple-usb3-tipd-v1-8-4e99c8649024@kernel.org> References: <20250914-apple-usb3-tipd-v1-0-4e99c8649024@kernel.org> In-Reply-To: <20250914-apple-usb3-tipd-v1-0-4e99c8649024@kernel.org> To: Heikki Krogerus , Greg Kroah-Hartman Cc: Janne Grunau , Neal Gompa , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org, Sven Peter , Hector Martin X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1354; i=sven@kernel.org; h=from:subject:message-id; bh=rY6V5NMDdkiVm06hCdoOp7C9X1kzTeKeAD8FlJOwjT0=; b=owGbwMvMwCHmIlirolUq95LxtFoSQ8ax3c1eu7J+1bkbGjw67pdp3510yy7oQaDmhx9GeqvOq USX2E/sKGVhEONgkBVTZNm+3970ycM3gks3XXoPM4eVCWQIAxenAEzk2F1Ghkd6Jj1dRwsvHa+8 cM1X8mDEMltubt2iTYx2LlaiV04aXWNkWNVcX3opq3zTqybJv6r/J3u92WwsqP6nlzdCxGj19l4 1ZgA= X-Developer-Key: i=sven@kernel.org; a=openpgp; fpr=A1E3E34A2B3C820DBC4955E5993B08092F131F93 X-Endpoint-Received: by B4 Relay for sven@kernel.org/default with auth_id=407 From: Hector Martin Whenever the power status is changed make sure to also update the partner identity to be able to detect changes once de-bouncing and mode changes are added for CD321x. Signed-off-by: Hector Martin Reviewed-by: Neal Gompa Signed-off-by: Sven Peter --- drivers/usb/typec/tipd/core.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index c7cf936e5a61a331271c05b68ff1b77b89c0f643..e16c6c07c72a3e285f1fc94db72= bed8dc3217a1d 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -635,9 +635,16 @@ static irqreturn_t cd321x_interrupt(int irq, void *dat= a) if (!tps6598x_read_status(tps, &status)) goto err_unlock; =20 - if (event & APPLE_CD_REG_INT_POWER_STATUS_UPDATE) + if (event & APPLE_CD_REG_INT_POWER_STATUS_UPDATE) { if (!tps6598x_read_power_status(tps)) goto err_unlock; + if (TPS_POWER_STATUS_PWROPMODE(tps->pwr_status) =3D=3D TYPEC_PWR_MODE_PD= ) { + if (tps6598x_read_partner_identity(tps)) { + dev_err(tps->dev, "failed to read partner identity\n"); + tps->partner_identity =3D (struct usb_pd_identity) {0}; + } + } + } =20 if (event & APPLE_CD_REG_INT_DATA_STATUS_UPDATE) if (!tps->data->read_data_status(tps)) --=20 2.34.1 From nobody Thu Oct 2 16:48:57 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 DAC7C26CE03; Sun, 14 Sep 2025 12:56:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757854608; cv=none; b=e2foS7WYf0f1YMzEnBprB1HI5XJ/L+wcVCG2s5LTmi43OPBMs9FnWUa8jKpZQq1v1xfi2W6yFDLwCkJsIlCvsPrX0WAbSjRy1nJJbnmN/P8VWQkXoa987o19LEaWidw/CeeTUwHxVtCTlRJ/dXKpQeslW4MILdnbJzzhnPMZOkU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757854608; c=relaxed/simple; bh=GGf5QllyT61ysY566RYqLFNgno0l8ltEvVdR6bQN+qM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qROBFkfYLaUmxRHoF4Qwf62l0R0VGRGSRwBnaMaMSuFxDCkdxPdtDGaH3MrznjPG2K9fROagRAwEiIis69SBzvMGaQ0z4RUwhblrHBiVT4T5bv1d0PE03Z0c6zIDGaMiFEU4xnhdb5t5JJcgBMw7XxTbeYguqtLuuQ20MrUOPgo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dUiC/OiP; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="dUiC/OiP" Received: by smtp.kernel.org (Postfix) with ESMTPS id 9116BC113D0; Sun, 14 Sep 2025 12:56:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757854608; bh=GGf5QllyT61ysY566RYqLFNgno0l8ltEvVdR6bQN+qM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=dUiC/OiPYVS67Ur/9+AsrvRREGlm8DN1DpiNoBw52tkpafCjIOzwwZKVpzpQeY0YF cRCAGhcg5/Ip0c7K8DqHXDbX6lplqkc5LlnyIEYDHfmm69pCDCXZahusoAf0JTxsod 2xCQEvpLXRDo5OiNi6dLRooc+veev4v3p/Rud3P5DoJxC4i2mWbjYQd40Arf5loYZZ q8HTJbQHgO5mHGURKk0nAMty5TyRPONgO9pC0EDl6J1QYpiuXvPT9KLcaROIwnJv4M TJL/5+iPh+znhMxR+4UttogN09YOSNAVvZ+RzXZy2uQd6SAM5nB4CerZwI4RvEhujX d6qE3roA9M2qg== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8B193CAC587; Sun, 14 Sep 2025 12:56:48 +0000 (UTC) From: Sven Peter Date: Sun, 14 Sep 2025 12:56:14 +0000 Subject: [PATCH 09/11] usb: typec: tipd: Use read_power_status function in probe Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250914-apple-usb3-tipd-v1-9-4e99c8649024@kernel.org> References: <20250914-apple-usb3-tipd-v1-0-4e99c8649024@kernel.org> In-Reply-To: <20250914-apple-usb3-tipd-v1-0-4e99c8649024@kernel.org> To: Heikki Krogerus , Greg Kroah-Hartman Cc: Janne Grunau , Neal Gompa , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org, Sven Peter , Hector Martin X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1337; i=sven@kernel.org; h=from:subject:message-id; bh=bWtfpNYNeM/tSnjKG/cu9lo0fgNBV8UwebqdAD8QF6w=; b=owGbwMvMwCHmIlirolUq95LxtFoSQ8ax3W0fT4QWvHjcHsSxxazpQTznhJi5f6z3y7An5ln3b P2nOPtnRykLgxgHg6yYIsv2/famTx6+EVy66dJ7mDmsTCBDGLg4BWAiO9YxMizxXdt8xmyvCMd+ OT/u2Xp5b2WOnH/htPnnscbuD14rN9ow/FN4cELDUCZsyTmfYg3HXOOccPE1d5Z0z/hxp3zW177 8cBYA X-Developer-Key: i=sven@kernel.org; a=openpgp; fpr=A1E3E34A2B3C820DBC4955E5993B08092F131F93 X-Endpoint-Received: by B4 Relay for sven@kernel.org/default with auth_id=407 From: Hector Martin We need the initial power status to be able to reliably detect connector changes once we introduce de-bouncing for CD321x next. read_power_status takes care of this and also forwards the status to the trace subsystem so let's use that instead of open-coding it inside probe. Signed-off-by: Hector Martin Reviewed-by: Heikki Krogerus Reviewed-by: Neal Gompa Signed-off-by: Sven Peter --- drivers/usb/typec/tipd/core.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index e16c6c07c72a3e285f1fc94db72bed8dc3217a1d..f546f4ae563af3d411ec6591fe9= c3b122e4efaab 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -1549,11 +1549,8 @@ static int tps6598x_probe(struct i2c_client *client) goto err_role_put; =20 if (status & TPS_STATUS_PLUG_PRESENT) { - ret =3D tps6598x_read16(tps, TPS_REG_POWER_STATUS, &tps->pwr_status); - if (ret < 0) { - dev_err(tps->dev, "failed to read power status: %d\n", ret); + if (!tps6598x_read_power_status(tps)) goto err_unregister_port; - } ret =3D tps6598x_connect(tps, status); if (ret) dev_err(&client->dev, "failed to register partner\n"); --=20 2.34.1 From nobody Thu Oct 2 16:48:57 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 C99CA26B2D3; Sun, 14 Sep 2025 12:56:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757854608; cv=none; b=TNVVnWgWqxVw9tnumT2Xk8fo5VQXId7esWItMZGto6h4SujFk2rZoXIeYNX+mBy6rGWPZmgZZ+IsfKynBW2EUrdUFze5i/VIIFhC8M/RXXDztzW+wk/uvd6frYYZZlAFm1pOja5/R+5iVV4Yqg7/LKDoT+5F7Iw76E5WfFdNIjY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757854608; c=relaxed/simple; bh=n4r7zMHDw/fPAOcEpKAkNiWA7bMT/Gk7NMP0eqPegkY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=gPNzMV62TEiEdL38mcYMzb7YLtE8CezaM2M0BURnjLGwfb1zsjRAt3eNBflKpZBS7J0uTC9JBB8FLBbn0O0hmUn++5r6il7GXgyzr24AzrahtcXtSHsUuZAZypUbC7JyPELraEBKO0Q04BqPZi30hwzsx8Bu9VcJHoodlD6JQ7g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=GM70exrU; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="GM70exrU" Received: by smtp.kernel.org (Postfix) with ESMTPS id 9C748C116B1; Sun, 14 Sep 2025 12:56:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757854608; bh=n4r7zMHDw/fPAOcEpKAkNiWA7bMT/Gk7NMP0eqPegkY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=GM70exrUvCkp2VCAXOJiUKn+Z4tj1+T8uSrT32ZEsG0/B7Z74yLzH0CT47sje+w0r 8eA/HYlhfe1AA6h4MDnlFGuJiTDgRScQw1vzlU1XQk4udUy82TJp7tpB/3pqA8ylVe rQU7OCqi3ZZ8YX7W670D7TBB+A5cGx805prxYKueQgUNamFNrHeMs9iSPQnAdrc3nT yg1CWhL4ydmXp6rwNcX8v9CsQx3tT2Orsb/JCAmHBnoz/5qwvQpfNkPr6kRnenaI07 72hoA7IRtTXZJOsaXC72rr8gBTZf8G0oO0cUMigWHFdJz8maX9j/07aIKQNyj469Zn eWTtSk4TNRrOw== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 97B98CAC598; Sun, 14 Sep 2025 12:56:48 +0000 (UTC) From: Sven Peter Date: Sun, 14 Sep 2025 12:56:15 +0000 Subject: [PATCH 10/11] usb: typec: tipd: Read data status in probe and cache its value Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250914-apple-usb3-tipd-v1-10-4e99c8649024@kernel.org> References: <20250914-apple-usb3-tipd-v1-0-4e99c8649024@kernel.org> In-Reply-To: <20250914-apple-usb3-tipd-v1-0-4e99c8649024@kernel.org> To: Heikki Krogerus , Greg Kroah-Hartman Cc: Janne Grunau , Neal Gompa , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org, Sven Peter , Hector Martin X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1585; i=sven@kernel.org; h=from:subject:message-id; bh=SEqFsdZj9wQbFtYLraoDyZILplcZKiIw4Wc/CN9A6bM=; b=owGbwMvMwCHmIlirolUq95LxtFoSQ8ax3R3KDnc5D/soHDFte8ez7pDPf1GvbN65wT4Mj0Mll u659+lbRykLgxgHg6yYIsv2/famTx6+EVy66dJ7mDmsTCBDGLg4BWAi7w0ZGfYv3iFd9mtTW2v9 0d1Lth41ipia1Tzt+f5U+4Ucgb+uHFdkZJjUeyaPZcEPpqe1lQECrt+ktZJ+vuW5/cLsyNqzh/b /i2ADAA== X-Developer-Key: i=sven@kernel.org; a=openpgp; fpr=A1E3E34A2B3C820DBC4955E5993B08092F131F93 X-Endpoint-Received: by B4 Relay for sven@kernel.org/default with auth_id=407 From: Hector Martin Just like for power status we also need to keep track of data status to be able to detect mode changes once we introduce de-bouncing for CD321x. Read it during probe and keep a cached copy of its value. Signed-off-by: Hector Martin Reviewed-by: Heikki Krogerus Reviewed-by: Neal Gompa Signed-off-by: Sven Peter --- drivers/usb/typec/tipd/core.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index f546f4ae563af3d411ec6591fe9c3b122e4efaab..f347e5bc625497ddff270e3e9e4= d2ddaf3ca6bc1 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -176,6 +176,7 @@ struct tps6598x { =20 int wakeup; u32 status; /* status reg */ + u32 data_status; u16 pwr_status; struct delayed_work wq_poll; =20 @@ -538,6 +539,7 @@ static bool tps6598x_read_data_status(struct tps6598x *= tps) dev_err(tps->dev, "failed to read data status: %d\n", ret); return false; } + tps->data_status =3D data_status; =20 if (tps->data->trace_data_status) tps->data->trace_data_status(data_status); @@ -1551,6 +1553,8 @@ static int tps6598x_probe(struct i2c_client *client) if (status & TPS_STATUS_PLUG_PRESENT) { if (!tps6598x_read_power_status(tps)) goto err_unregister_port; + if (!tps->data->read_data_status(tps)) + goto err_unregister_port; ret =3D tps6598x_connect(tps, status); if (ret) dev_err(&client->dev, "failed to register partner\n"); --=20 2.34.1 From nobody Thu Oct 2 16:48:57 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 F020126D4F6; Sun, 14 Sep 2025 12:56:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757854609; cv=none; b=Ol0suR1vPPdy7FvphY8DgqQrIGFs0HICBhuHzgwnq9mk7MvBxdiWNU5/0s5aq+NJxTmLsSLlPL5J3M6E/zoZraRW1TpLtMX+9+bqmBMlpCGGsBm15KAqgl1yOlTBbCiquaUuJ72cl1G+5TchLlWdW5iC29cQcV84G+j06NlI8yk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757854609; c=relaxed/simple; bh=0D1krhrtHYyXa05zbXteLefYDTNxciRkFiB+TtKW5Jk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Gu7ecc42RoqzGNgBv9Vn7GR16Td+0LVu+xOBf8cFprpJbBG3KYLDbXuAsDrK6FuBF+FQo7q9fl3sWWivO1+jH9z1gXeNAdceSx+ig+tm4guzJJziq1j1qX9nnrPCglJ4tS7Wz7PTToF8+LFU3cy2W7EKpOpXyb9uo+WbU+Yf3BQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=VC4IgxeU; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="VC4IgxeU" Received: by smtp.kernel.org (Postfix) with ESMTPS id AAAE8C19421; Sun, 14 Sep 2025 12:56:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757854608; bh=0D1krhrtHYyXa05zbXteLefYDTNxciRkFiB+TtKW5Jk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=VC4IgxeU10p1oXC12WTrSnFJOKe3usipXfh7dL8Eka1LBCtW4iElnbRmTgRUuQafP Xuw4+bOFIkVntJsy89DgkkQXqC0Y/2HDm5lFiB9qjt4OYYay2JxaSTw9/6EEV1nM2W UYHZUC4fwXbf56Yyb8AQlzl2nuJbH+2frdfjmcoy7oeExMmK/7mdEZgMMErCeEzHeQ DBr8kgmOZQyBaHV4PLBqaBpVrvnyYPEx421Ph+/sUXRNsRuC7UHxaYquyITwo4AufZ YKtuFDWKnJya9fPrqlQfKSm9jhTkurjC/TMaJDPkvMLeWNuVn+Twta575mrkfg8H2b WteeteMonJc6g== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id A40EFCAC594; Sun, 14 Sep 2025 12:56:48 +0000 (UTC) From: Sven Peter Date: Sun, 14 Sep 2025 12:56:16 +0000 Subject: [PATCH 11/11] usb: typec: tipd: Handle mode transitions for CD321x Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250914-apple-usb3-tipd-v1-11-4e99c8649024@kernel.org> References: <20250914-apple-usb3-tipd-v1-0-4e99c8649024@kernel.org> In-Reply-To: <20250914-apple-usb3-tipd-v1-0-4e99c8649024@kernel.org> To: Heikki Krogerus , Greg Kroah-Hartman Cc: Janne Grunau , Neal Gompa , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org, Sven Peter , Hector Martin X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=15951; i=sven@kernel.org; h=from:subject:message-id; bh=rh1BHrS3f0P6pTaz0xpQMxUHduFv9MoOplUkdu9/z2E=; b=owGbwMvMwCHmIlirolUq95LxtFoSQ8ax3Z0ls9tEK4xVL2wTa0vc3KizOFH58GqHR5e8bpucd k2O32bZUcrCIMbBICumyLJ9v73pk4dvBJduuvQeZg4rE8gQBi5OAZjIv2qGf0ZTtRhOTePlFMzd 8eXK+d6bri/EHgV1LH1jypPZ2P139guGf7Y9m6oc+QOupPCqyvl471FrYw089pXVvVT5Vmw744V T3AA= X-Developer-Key: i=sven@kernel.org; a=openpgp; fpr=A1E3E34A2B3C820DBC4955E5993B08092F131F93 X-Endpoint-Received: by B4 Relay for sven@kernel.org/default with auth_id=407 From: Hector Martin On Apple Silicon machines there is no control over which alt mode is chosen. The CD321x' firmware negotiates the target mode on its own and only lets the main CPU know after the mode has already been chosen. Especially after plugging a new cable in this can result to quick mode changes from e.g. power only -> USB3 only -> USB3+DisplayPort in a short time. It is not possile to influence this in any way and we also do not get direct access to the PDOs or VDOs exchanged via USB PD. Additionally, mode changes must be tightly synchronized between DWC3 and the Type C PHY and most mode changes require a full reset of DWC3 to make the port work correctly. This is all done synchronously from the role switch handler inside the DWC3 glue driver on these machines to avoid tripping any failsafes or watchdogs inside the Type-C PHY that may, in the worst case, reset the entire SoC. To be able to control all this we trigger the entire process in the correct order directly from the TIPD driver and de-bounce any mode changes to avoid tearing down and re-setting DWC3 back up multiple times any time a new connection is made. Signed-off-by: Hector Martin Reviewed-by: Heikki Krogerus Reviewed-by: Neal Gompa Co-developed-by: Sven Peter Signed-off-by: Sven Peter --- drivers/usb/typec/tipd/core.c | 290 ++++++++++++++++++++++++++++++++++++++= +++- 1 file changed, 286 insertions(+), 4 deletions(-) diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index f347e5bc625497ddff270e3e9e4d2ddaf3ca6bc1..2b1049c9a6f3c4300f4a25a97fe= 502c47e82a134 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -120,6 +121,9 @@ struct tps6598x_intel_vid_status_reg { #define TPS_TASK_TIMEOUT 1 #define TPS_TASK_REJECTED 3 =20 +/* Debounce delay for mode changes, in milliseconds */ +#define CD321X_DEBOUNCE_DELAY_MS 500 + enum { TPS_MODE_APP, TPS_MODE_BOOT, @@ -145,6 +149,7 @@ struct tipd_data { irq_handler_t irq_handler; u64 irq_mask1; size_t tps_struct_size; + void (*remove)(struct tps6598x *tps); int (*register_port)(struct tps6598x *tps, struct fwnode_handle *node); void (*unregister_port)(struct tps6598x *tps); void (*trace_data_status)(u32 status); @@ -155,6 +160,7 @@ struct tipd_data { int (*switch_power_state)(struct tps6598x *tps, u8 target_state); bool (*read_data_status)(struct tps6598x *tps); int (*reset)(struct tps6598x *tps); + int (*connect)(struct tps6598x *tps, u32 status); }; =20 struct tps6598x { @@ -183,6 +189,17 @@ struct tps6598x { const struct tipd_data *data; }; =20 +struct cd321x_status { + u32 status; + u32 pwr_status; + u32 data_status; + u32 status_changed; + struct usb_pd_identity partner_identity; + struct tps6598x_dp_sid_status_reg dp_sid_status; + struct tps6598x_intel_vid_status_reg intel_vid_status; + struct tps6598x_usb4_status_reg usb4_status; +}; + struct cd321x { struct tps6598x tps; =20 @@ -192,6 +209,13 @@ struct cd321x { =20 struct typec_altmode *port_altmode_dp; struct typec_altmode *port_altmode_tbt; + + struct typec_mux *mux; + struct typec_mux_state state; + + struct cd321x_status update_status; + struct delayed_work update_work; + struct usb_pd_identity cur_partner_identity; }; =20 static enum power_supply_property tps6598x_psy_props[] =3D { @@ -613,6 +637,233 @@ static void tps6598x_handle_plug_event(struct tps6598= x *tps, u32 status) } } =20 +static void cd321x_typec_update_mode(struct tps6598x *tps, struct cd321x_s= tatus *st) +{ + struct cd321x *cd321x =3D container_of(tps, struct cd321x, tps); + + if (!(st->data_status & TPS_DATA_STATUS_DATA_CONNECTION)) { + if (cd321x->state.mode =3D=3D TYPEC_STATE_SAFE) + return; + cd321x->state.alt =3D NULL; + cd321x->state.mode =3D TYPEC_STATE_SAFE; + cd321x->state.data =3D NULL; + typec_mux_set(cd321x->mux, &cd321x->state); + } else if (st->data_status & TPS_DATA_STATUS_DP_CONNECTION) { + struct typec_displayport_data dp_data; + unsigned long mode; + + switch (TPS_DATA_STATUS_DP_SPEC_PIN_ASSIGNMENT(st->data_status)) { + case TPS_DATA_STATUS_DP_SPEC_PIN_ASSIGNMENT_A: + mode =3D TYPEC_DP_STATE_A; + break; + case TPS_DATA_STATUS_DP_SPEC_PIN_ASSIGNMENT_B: + mode =3D TYPEC_DP_STATE_B; + break; + case TPS_DATA_STATUS_DP_SPEC_PIN_ASSIGNMENT_C: + mode =3D TYPEC_DP_STATE_C; + break; + case TPS_DATA_STATUS_DP_SPEC_PIN_ASSIGNMENT_D: + mode =3D TYPEC_DP_STATE_D; + break; + case TPS_DATA_STATUS_DP_SPEC_PIN_ASSIGNMENT_E: + mode =3D TYPEC_DP_STATE_E; + break; + case TPS_DATA_STATUS_DP_SPEC_PIN_ASSIGNMENT_F: + mode =3D TYPEC_DP_STATE_F; + break; + default: + dev_err(tps->dev, "Invalid DP pin assignment\n"); + return; + } + + if (cd321x->state.alt =3D=3D cd321x->port_altmode_dp && + cd321x->state.mode =3D=3D mode) { + return; + } + + dp_data.status =3D le32_to_cpu(st->dp_sid_status.status_rx); + dp_data.conf =3D le32_to_cpu(st->dp_sid_status.configure); + cd321x->state.alt =3D cd321x->port_altmode_dp; + cd321x->state.data =3D &dp_data; + cd321x->state.mode =3D mode; + typec_mux_set(cd321x->mux, &cd321x->state); + } else if (st->data_status & TPS_DATA_STATUS_TBT_CONNECTION) { + struct typec_thunderbolt_data tbt_data; + + if (cd321x->state.alt =3D=3D cd321x->port_altmode_tbt && + cd321x->state.mode =3D=3D TYPEC_TBT_MODE) + return; + + tbt_data.cable_mode =3D le16_to_cpu(st->intel_vid_status.cable_mode); + tbt_data.device_mode =3D le16_to_cpu(st->intel_vid_status.device_mode); + tbt_data.enter_vdo =3D le16_to_cpu(st->intel_vid_status.enter_vdo); + cd321x->state.alt =3D cd321x->port_altmode_tbt; + cd321x->state.mode =3D TYPEC_TBT_MODE; + cd321x->state.data =3D &tbt_data; + typec_mux_set(cd321x->mux, &cd321x->state); + } else if (st->data_status & CD321X_DATA_STATUS_USB4_CONNECTION) { + struct enter_usb_data eusb_data; + + if (cd321x->state.alt =3D=3D NULL && cd321x->state.mode =3D=3D TYPEC_MOD= E_USB4) + return; + + eusb_data.eudo =3D le32_to_cpu(st->usb4_status.eudo); + eusb_data.active_link_training =3D + !!(st->data_status & TPS_DATA_STATUS_ACTIVE_LINK_TRAIN); + + cd321x->state.alt =3D NULL; + cd321x->state.data =3D &eusb_data; + cd321x->state.mode =3D TYPEC_MODE_USB4; + typec_mux_set(cd321x->mux, &cd321x->state); + } else { + if (cd321x->state.alt =3D=3D NULL && cd321x->state.mode =3D=3D TYPEC_STA= TE_USB) + return; + cd321x->state.alt =3D NULL; + cd321x->state.mode =3D TYPEC_STATE_USB; + cd321x->state.data =3D NULL; + typec_mux_set(cd321x->mux, &cd321x->state); + } + + /* Clear data since it's no longer used after typec_mux_set and points to= the stack */ + cd321x->state.data =3D NULL; +} + +static void cd321x_update_work(struct work_struct *work) +{ + struct cd321x *cd321x =3D container_of(to_delayed_work(work), + struct cd321x, update_work); + struct tps6598x *tps =3D &cd321x->tps; + struct cd321x_status st; + + guard(mutex)(&tps->lock); + + st =3D cd321x->update_status; + cd321x->update_status.status_changed =3D 0; + + bool old_connected =3D !!tps->partner; + bool new_connected =3D st.status & TPS_STATUS_PLUG_PRESENT; + bool was_disconnected =3D st.status_changed & TPS_STATUS_PLUG_PRESENT; + + bool usb_connection =3D st.data_status & + (TPS_DATA_STATUS_USB2_CONNECTION | TPS_DATA_STATUS_USB3_CONNECTIO= N); + + enum usb_role old_role =3D usb_role_switch_get_role(tps->role_sw); + enum usb_role new_role =3D USB_ROLE_NONE; + enum typec_pwr_opmode pwr_opmode =3D TYPEC_PWR_MODE_USB; + enum typec_orientation orientation =3D TYPEC_ORIENTATION_NONE; + + if (usb_connection) { + if (tps->data_status & TPS_DATA_STATUS_USB_DATA_ROLE) + new_role =3D USB_ROLE_DEVICE; + else + new_role =3D USB_ROLE_HOST; + } + + if (new_connected) { + pwr_opmode =3D TPS_POWER_STATUS_PWROPMODE(st.pwr_status); + orientation =3D TPS_STATUS_TO_UPSIDE_DOWN(st.status) ? + TYPEC_ORIENTATION_REVERSE : TYPEC_ORIENTATION_NORMAL; + } + + bool is_pd =3D pwr_opmode =3D=3D TYPEC_PWR_MODE_PD; + bool partner_changed =3D old_connected && new_connected && + (was_disconnected || + (is_pd && memcmp(&st.partner_identity, + &cd321x->cur_partner_identity, sizeof(struct usb_pd_identity)))); + + /* If we are switching from an active role, transition to USB_ROLE_NONE f= irst */ + if (old_role !=3D USB_ROLE_NONE && (new_role !=3D old_role || was_disconn= ected)) + usb_role_switch_set_role(tps->role_sw, USB_ROLE_NONE); + + /* Process partner disconnection or change */ + if (!new_connected || partner_changed) { + if (!IS_ERR(tps->partner)) + typec_unregister_partner(tps->partner); + tps->partner =3D NULL; + } + + /* If there was a disconnection, set PHY to off */ + if (!new_connected || was_disconnected) { + cd321x->state.alt =3D NULL; + cd321x->state.mode =3D TYPEC_STATE_SAFE; + cd321x->state.data =3D NULL; + typec_set_mode(tps->port, TYPEC_STATE_SAFE); + } + + /* Update Type-C properties */ + typec_set_pwr_opmode(tps->port, pwr_opmode); + typec_set_pwr_role(tps->port, TPS_STATUS_TO_TYPEC_PORTROLE(st.status)); + typec_set_vconn_role(tps->port, TPS_STATUS_TO_TYPEC_VCONN(st.status)); + typec_set_orientation(tps->port, orientation); + typec_set_data_role(tps->port, TPS_STATUS_TO_TYPEC_DATAROLE(st.status)); + power_supply_changed(tps->psy); + + /* If the plug is disconnected, we are done */ + if (!new_connected) + return; + + /* Set up partner if we were previously disconnected (or changed). */ + if (!tps->partner) { + struct typec_partner_desc desc; + + desc.usb_pd =3D is_pd; + desc.accessory =3D TYPEC_ACCESSORY_NONE; /* XXX: handle accessories */ + desc.identity =3D NULL; + + if (desc.usb_pd) + desc.identity =3D &st.partner_identity; + + tps->partner =3D typec_register_partner(tps->port, &desc); + if (IS_ERR(tps->partner)) + dev_warn(tps->dev, "%s: failed to register partnet\n", __func__); + + if (desc.identity) { + typec_partner_set_identity(tps->partner); + cd321x->cur_partner_identity =3D st.partner_identity; + } + } + + /* Update the TypeC MUX/PHY state */ + cd321x_typec_update_mode(tps, &st); + + /* Launch the USB role switch */ + usb_role_switch_set_role(tps->role_sw, new_role); + + power_supply_changed(tps->psy); +} + +static void cd321x_queue_status(struct cd321x *cd321x) +{ + cd321x->update_status.status_changed |=3D cd321x->update_status.status ^ = cd321x->tps.status; + + cd321x->update_status.status =3D cd321x->tps.status; + cd321x->update_status.pwr_status =3D cd321x->tps.pwr_status; + cd321x->update_status.data_status =3D cd321x->tps.data_status; + + cd321x->update_status.partner_identity =3D cd321x->tps.partner_identity; + cd321x->update_status.dp_sid_status =3D cd321x->dp_sid_status; + cd321x->update_status.intel_vid_status =3D cd321x->intel_vid_status; + cd321x->update_status.usb4_status =3D cd321x->usb4_status; +} + +static int cd321x_connect(struct tps6598x *tps, u32 status) +{ + struct cd321x *cd321x =3D container_of(tps, struct cd321x, tps); + + tps->status =3D status; + cd321x_queue_status(cd321x); + + /* + * Cancel pending work if not already running, then requeue after CD321X_= DEBOUNCE_DELAY_MS + * regardless since the work function will check for any plug or altmodes= changes since + * its last run anyway. + */ + cancel_delayed_work(&cd321x->update_work); + schedule_delayed_work(&cd321x->update_work, msecs_to_jiffies(CD321X_DEBOU= NCE_DELAY_MS)); + + return 0; +} + static irqreturn_t cd321x_interrupt(int irq, void *data) { struct tps6598x *tps =3D data; @@ -652,9 +903,8 @@ static irqreturn_t cd321x_interrupt(int irq, void *data) if (!tps->data->read_data_status(tps)) goto err_unlock; =20 - /* Handle plug insert or removal */ - if (event & APPLE_CD_REG_INT_PLUG_EVENT) - tps6598x_handle_plug_event(tps, status); + /* Can be called uncondtionally since it will check for any changes itsel= f */ + cd321x_connect(tps, status); =20 err_unlock: mutex_unlock(&tps->lock); @@ -1014,6 +1264,8 @@ cd321x_register_port(struct tps6598x *tps, struct fwn= ode_handle *fwnode) struct cd321x *cd321x =3D container_of(tps, struct cd321x, tps); int ret; =20 + INIT_DELAYED_WORK(&cd321x->update_work, cd321x_update_work); + ret =3D tps6598x_register_port(tps, fwnode); if (ret) return ret; @@ -1022,10 +1274,24 @@ cd321x_register_port(struct tps6598x *tps, struct f= wnode_handle *fwnode) if (ret) goto err_unregister_port; =20 + cd321x->mux =3D fwnode_typec_mux_get(fwnode); + if (IS_ERR(cd321x->mux)) { + ret =3D PTR_ERR(cd321x->mux); + goto err_unregister_altmodes; + } + + cd321x->state.alt =3D NULL; + cd321x->state.mode =3D TYPEC_STATE_SAFE; + cd321x->state.data =3D NULL; typec_set_mode(tps->port, TYPEC_STATE_SAFE); =20 return 0; =20 +err_unregister_altmodes: + typec_unregister_altmode(cd321x->port_altmode_dp); + typec_unregister_altmode(cd321x->port_altmode_tbt); + cd321x->port_altmode_dp =3D NULL; + cd321x->port_altmode_tbt =3D NULL; err_unregister_port: typec_unregister_port(tps->port); return ret; @@ -1042,6 +1308,8 @@ cd321x_unregister_port(struct tps6598x *tps) { struct cd321x *cd321x =3D container_of(tps, struct cd321x, tps); =20 + typec_mux_put(cd321x->mux); + cd321x->mux =3D NULL; typec_unregister_altmode(cd321x->port_altmode_dp); cd321x->port_altmode_dp =3D NULL; typec_unregister_altmode(cd321x->port_altmode_tbt); @@ -1454,6 +1722,13 @@ tps25750_register_port(struct tps6598x *tps, struct = fwnode_handle *fwnode) return 0; } =20 +static void cd321x_remove(struct tps6598x *tps) +{ + struct cd321x *cd321x =3D container_of(tps, struct cd321x, tps); + + cancel_delayed_work_sync(&cd321x->update_work); +} + static int tps6598x_probe(struct i2c_client *client) { const struct tipd_data *data; @@ -1555,7 +1830,7 @@ static int tps6598x_probe(struct i2c_client *client) goto err_unregister_port; if (!tps->data->read_data_status(tps)) goto err_unregister_port; - ret =3D tps6598x_connect(tps, status); + ret =3D tps->data->connect(tps, status); if (ret) dev_err(&client->dev, "failed to register partner\n"); } @@ -1612,6 +1887,9 @@ static void tps6598x_remove(struct i2c_client *client) else devm_free_irq(tps->dev, client->irq, tps); =20 + if (tps->data->remove) + tps->data->remove(tps); + tps6598x_disconnect(tps, 0); tps->data->unregister_port(tps); usb_role_switch_put(tps->role_sw); @@ -1682,6 +1960,7 @@ static const struct tipd_data cd321x_data =3D { APPLE_CD_REG_INT_DATA_STATUS_UPDATE | APPLE_CD_REG_INT_PLUG_EVENT, .tps_struct_size =3D sizeof(struct cd321x), + .remove =3D cd321x_remove, .register_port =3D cd321x_register_port, .unregister_port =3D cd321x_unregister_port, .trace_data_status =3D trace_cd321x_data_status, @@ -1691,6 +1970,7 @@ static const struct tipd_data cd321x_data =3D { .read_data_status =3D cd321x_read_data_status, .reset =3D cd321x_reset, .switch_power_state =3D cd321x_switch_power_state, + .connect =3D cd321x_connect, }; =20 static const struct tipd_data tps6598x_data =3D { @@ -1708,6 +1988,7 @@ static const struct tipd_data tps6598x_data =3D { .init =3D tps6598x_init, .read_data_status =3D tps6598x_read_data_status, .reset =3D tps6598x_reset, + .connect =3D tps6598x_connect, }; =20 static const struct tipd_data tps25750_data =3D { @@ -1725,6 +2006,7 @@ static const struct tipd_data tps25750_data =3D { .init =3D tps25750_init, .read_data_status =3D tps6598x_read_data_status, .reset =3D tps25750_reset, + .connect =3D tps6598x_connect, }; =20 static const struct of_device_id tps6598x_of_match[] =3D { --=20 2.34.1