Skip to contentSkip to conversation

usb: typec: ucsi: add support for Cypress CCGx

PATCH Superseded Andy Shevchenko 1 participant 1 message Oct 25, 2018 USB

v13 of 14 Superseded Latest is v14 →

lore
Share & tools
lore
#0 lore raw

PATCH v13 2/2 usb: typec: ucsi: add support for Cypress CCGx

Quoted 42 lines · Ajay Gupta

Hi Andy

Quoted 40 lines
Quoted 6 lines
Quoted 5 lines
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 ucsi

control

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 14 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?

It is like a retry count to clear interrupt status.

Quoted 1 line

Shouldn't you return -ETIMEDOUT if count == 0?

Yes. Good catch. Does the below fix looks ok?

Quoted 7 lines
Quoted 5 lines

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?

Yes, we need to read to get interrupt status bits and then write them back to clear the status.

Ah, I see, but why you not reorganize it to put this into do-while loop?

do {
read
write
check for data
sleep
} while (--count);

Also note predecrement.