Skip to contentSkip to conversation

usb: typec: ucsi: add port num info

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

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 3/6 usb: typec: ucsi: add port num info

Quoted 25 lines · Ajay Gupta

Read PD port number information and save. It will be required while sending PD_PORT_ENABLE command.

---
Changes from v1:
- Updated commit message
- Used mask and shift instead of bitfield

 drivers/usb/typec/ucsi/ucsi_ccg.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/usb/typec/ucsi/ucsi_ccg.c +1 -0
index 3155ee6be357..f71387a21693 100644
@@ -172,6 +172,7 @@ struct ucsi_ccg {
 #define DEV_CMD_PENDING	1
 	struct ccg_resp dev_resp;
 	u8 cmd_resp;
+	int port_num;
 };
 
 static int ccg_read(struct ucsi_ccg *uc, u16 rab, u8 *data, u32 len)

drivers/usb/typec/ucsi/ucsi_ccg.c static int ucsi_ccg_probe(struct i2c_client *client, · line 531

Quoted 5 lines
drivers/usb/typec/ucsi/ucsi_ccg.c +2 -0
@@ -526,6 +527,12 @@ static int ucsi_ccg_probe(struct i2c_client *client,
 		return status;
 	}
 
+	if ((uc->info.mode & CCG_DEVINFO_PDPORTS_MASK) >>
+			CCG_DEVINFO_PDPORTS_SHIFT)

No need to shift.

drivers/usb/typec/ucsi/ucsi_ccg.c static int ucsi_ccg_probe(struct i2c_client *client, · line 534

Quoted 3 lines
drivers/usb/typec/ucsi/ucsi_ccg.c +3 -0
+		uc->port_num = 2;
+	else
+		uc->port_num = 1;
        uc->port_num = 1

	if (uc->info.mode & CCG_DEVINFO_PDPORTS_MASK)
                uc->port_num++;

Or just:

        uc->port_num = !!(uc->info.mode & CCG_DEVINFO_PDPORTS_MASK) + 1;

thanks,