Skip to contentSkip to conversation

usb: typec: ucsi: add get_fw_info function

PATCH Superseded Heikki Krogerus 1 participant 1 message Jan 25, 2019 USB

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/7 usb: typec: ucsi: add get_fw_info function

Quoted 44 lines · Ajay Gupta

Hi Heikki,

Quoted 33 lines
Quoted 33 lines

Function is to get the details of ccg firmware and device version.

---
 drivers/usb/typec/ucsi/ucsi_ccg.c | 76
++++++++++++++++++++++++++++++-
 1 file changed, 74 insertions(+), 2 deletions(-)
drivers/usb/typec/ucsi/ucsi_ccg.c +16 -0
index de8a43bdff68..4d35279ab853 100644
@@ -17,15 +17,46 @@
 #include <asm/unaligned.h>
 #include "ucsi.h"
 
+struct ccg_dev_info {
+	u8 fw_mode:2;
+	u8 two_pd_ports:2;
+	u8 row_size_256:2;
+	u8:1; /* reserved */
+	u8 hpi_v2_mode:1;
+	u8 bl_mode:1;
+	u8 cfgtbl_invalid:1;
+	u8 fw1_invalid:1;
+	u8 fw2_invalid:1;
+	u8:4; /* reserved */
+	u16 silicon_id;
+	u16 bl_last_row;
+} __packed;
+
+struct version_format {
Quoted 8 lines

drivers/usb/typec/ucsi/ucsi_ccg.c line 40

Quoted 5 lines
drivers/usb/typec/ucsi/ucsi_ccg.c +5 -0
+	u16 build;
+	u8 patch;
+	u8 min:4;
+	u8 maj:4;
+};

Don't use bit fields. We shouldn't use them even in the core ucsi driver with the message data structures like we do.

Quoted 2 lines

So are you saying to remove bit fields from structure and instead use shift and mask on u8 variable to get bit fields?

Yes, exactly.

thanks,