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

Signed-off-by: Ajay Gupta <[email protected]>
---
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(+)

diff --git a/drivers/usb/typec/ucsi/ucsi_ccg.c 
b/drivers/usb/typec/ucsi/ucsi_ccg.c
index 3155ee6be357..f71387a21693 100644
--- a/drivers/usb/typec/ucsi/ucsi_ccg.c
+++ b/drivers/usb/typec/ucsi/ucsi_ccg.c
@@ -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)
@@ -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)
+               uc->port_num = 2;
+       else
+               uc->port_num = 1;
+
        status = devm_request_threaded_irq(dev, client->irq, NULL,
                                           ccg_irq_handler,
                                           IRQF_ONESHOT | IRQF_TRIGGER_HIGH,
-- 
2.17.1

Reply via email to