lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210918120934.28252-8-sven@svenpeter.dev>
Date:   Sat, 18 Sep 2021 14:09:32 +0200
From:   Sven Peter <sven@...npeter.dev>
To:     Heikki Krogerus <heikki.krogerus@...ux.intel.com>
Cc:     Sven Peter <sven@...npeter.dev>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Guido Günther <agx@...xcpu.org>,
        "Bryan O'Donoghue" <bryan.odonoghue@...aro.org>,
        linux-usb@...r.kernel.org, linux-kernel@...r.kernel.org,
        Hector Martin <marcan@...can.st>,
        Mohamed Mediouni <mohamed.mediouni@...amail.com>,
        Stan Skowronek <stan@...ellium.com>,
        Mark Kettenis <mark.kettenis@...all.nl>,
        Alexander Graf <graf@...zon.com>,
        Alyssa Rosenzweig <alyssa@...enzweig.io>
Subject: [RFT PATCH 7/9] usb: typec: tipd: Add support for apple,cd321x

After all the preparations in the previous commits we can now finally
add support for the Apple CD321x chip which is a variant of the TI TPS
6598x chip. The major differences are the changed interrupt numbers and
the concurrent connection to the SMC which we must not disturb.

Signed-off-by: Sven Peter <sven@...npeter.dev>
---
 drivers/usb/typec/tipd/core.c     | 10 ++++++++++
 drivers/usb/typec/tipd/tps6598x.h |  6 ++++++
 drivers/usb/typec/tipd/trace.h    | 27 +++++++++++++++++++++++++++
 3 files changed, 43 insertions(+)

diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c
index 2058e8cca631..e96b17fe6af6 100644
--- a/drivers/usb/typec/tipd/core.c
+++ b/drivers/usb/typec/tipd/core.c
@@ -788,8 +788,18 @@ static const struct tps6598x_hw ti_tps6598x_data = {
 	.irq_trace = trace_tps6598x_irq,
 };
 
+static const struct tps6598x_hw apple_cd321x_data = {
+	.use_int1 = true,
+	.use_int2 = false,
+	.irq_power_status_update = APPLE_TPS_REG_INT_POWER_STATUS_UPDATE,
+	.irq_data_status_update = APPLE_TPS_REG_INT_DATA_STATUS_UPDATE,
+	.irq_plug_event = APPLE_TPS_REG_INT_PLUG_EVENT,
+	.irq_trace = trace_cd321x_irq,
+};
+
 static const struct of_device_id tps6598x_of_match[] = {
 	{ .compatible = "ti,tps6598x", .data = &ti_tps6598x_data },
+	{ .compatible = "apple,cd321x", .data = &apple_cd321x_data },
 	{}
 };
 MODULE_DEVICE_TABLE(of, tps6598x_of_match);
diff --git a/drivers/usb/typec/tipd/tps6598x.h b/drivers/usb/typec/tipd/tps6598x.h
index 003a577be216..36b482733297 100644
--- a/drivers/usb/typec/tipd/tps6598x.h
+++ b/drivers/usb/typec/tipd/tps6598x.h
@@ -129,6 +129,12 @@
 #define TPS_REG_INT_HARD_RESET				BIT(1)
 #define TPS_REG_INT_PD_SOFT_RESET			BIT(0)
 
+/* Apple-specific TPS_REG_INT_* bits */
+#define APPLE_TPS_REG_INT_DATA_STATUS_UPDATE		BIT(10)
+#define APPLE_TPS_REG_INT_POWER_STATUS_UPDATE		BIT(9)
+#define APPLE_TPS_REG_INT_STATUS_UPDATE			BIT(8)
+#define APPLE_TPS_REG_INT_PLUG_EVENT			BIT(1)
+
 /* TPS_REG_POWER_STATUS bits */
 #define TPS_POWER_STATUS_CONNECTION(x)  TPS_FIELD_GET(BIT(0), (x))
 #define TPS_POWER_STATUS_SOURCESINK(x)	TPS_FIELD_GET(BIT(1), (x))
diff --git a/drivers/usb/typec/tipd/trace.h b/drivers/usb/typec/tipd/trace.h
index 5d09d6f78930..090633a1ae1d 100644
--- a/drivers/usb/typec/tipd/trace.h
+++ b/drivers/usb/typec/tipd/trace.h
@@ -67,6 +67,13 @@
 		{ TPS_REG_INT_USER_VID_ALT_MODE_ATTN_VDM,	"USER_VID_ALT_MODE_ATTN_VDM" }, \
 		{ TPS_REG_INT_USER_VID_ALT_MODE_OTHER_VDM,	"USER_VID_ALT_MODE_OTHER_VDM" })
 
+#define show_cd321x_irq_flags(flags) \
+	__print_flags_u64(flags, "|", \
+		{ APPLE_TPS_REG_INT_PLUG_EVENT,			"PLUG_EVENT" }, \
+		{ APPLE_TPS_REG_INT_POWER_STATUS_UPDATE,	"POWER_STATUS_UPDATE" }, \
+		{ APPLE_TPS_REG_INT_STATUS_UPDATE,		"DATA_STATUS_UPDATE" }, \
+		{ APPLE_TPS_REG_INT_PLUG_EVENT,			"STATUS_UPDATE" })
+
 #define TPS6598X_STATUS_FLAGS_MASK (GENMASK(31, 0) ^ (TPS_STATUS_CONN_STATE_MASK | \
 						      TPS_STATUS_PP_5V0_SWITCH_MASK | \
 						      TPS_STATUS_PP_HV_SWITCH_MASK | \
@@ -207,6 +214,26 @@ TRACE_EVENT(tps6598x_irq,
 		      show_irq_flags(__entry->event2))
 );
 
+TRACE_EVENT(cd321x_irq,
+	    TP_PROTO(u64 event1,
+		     u64 event2),
+	    TP_ARGS(event1, event2),
+
+	    TP_STRUCT__entry(
+			     __field(u64, event1)
+			     __field(u64, event2)
+			     ),
+
+	    TP_fast_assign(
+			   __entry->event1 = event1;
+			   __entry->event2 = event2;
+			   ),
+
+	    TP_printk("event1=%s, event2=%s",
+		      show_cd321x_irq_flags(__entry->event1),
+		      show_cd321x_irq_flags(__entry->event2))
+);
+
 TRACE_EVENT(tps6598x_status,
 	    TP_PROTO(u32 status),
 	    TP_ARGS(status),
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ