usb: typec: ucsi: add support for Cypress CCGx
PATCH v13 2/2 usb: typec: ucsi: add support for Cypress CCGx
Quoted 7 lines · Ajay Gupta
Quoted 6 lines · Ajay Gupta
Quoted 5 lines
Latest NVIDIA GPU cards have a Cypress CCGx Type-C controller over I2C interface.
This UCSI I2C driver uses I2C bus driver interface for communicating with Type-C controller.
Quoted 8 lines
Quoted 8 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ /* + * Flush CCGx RESPONSE queue by acking interrupts. Above ucsicontrol
Review
Quoted 5 lines
(quoted diff) +5
-0+ * register write will push response which must be cleared. + */ + status = ccg_read(uc, CCGX_RAB_INTR_REG, &data, sizeof(data)); + if (status < 0) + return status;
(1)
Quoted 5 lines
Quoted 5 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ do { + status = ccg_write(uc, CCGX_RAB_INTR_REG, &data,sizeof(data));
Review
Quoted 2 lines
(quoted diff) +2
-0+ if (status < 0) + return status;
(2)
Quoted 10 lines
Quoted 10 lines
Review
Quoted 4 lines
(quoted diff) +4
-0+ + usleep_range(10000, 11000); + + status = ccg_read(uc, CCGX_RAB_INTR_REG, &data,sizeof(data));
Review
Quoted 3 lines
(quoted diff) +3
-0+ if (status < 0) + return status; + } while ((data != 0x00) && count--);What's the significance of that count?
Quoted 4 lines
It is like a retry count to clear interrupt status.
Quoted 1 line
Shouldn't you return
-ETIMEDOUTif count == 0?Yes. Good catch. Does the below fix looks ok?
At least for me looks OK (I dunno why I missed that what Heikki found recently). Nevertheless, I have one more question about (1) and (2) above.
Is it necessary to do one more read before do-while loop?
Quoted 17 lines
do {
status = ccg_write(uc, CCGX_RAB_INTR_REG, &data, sizeof(data));
if (status < 0)
return status;
usleep_range(10000, 11000);
status = ccg_read(uc, CCGX_RAB_INTR_REG, &data, sizeof(data));
if (status < 0)
return status;
if (!data)
return 0;
} while (data && count--);
return -ETIMEDOUT;