Skip to contentSkip to conversation

usb: typec: ucsi: add support for Cypress CCGx

PATCH Superseded Ajay Gupta 1 participant 1 message Aug 31, 2018 USB

v4 of 13 Superseded Latest is v13 →

lore
Share & tools
lore

Ajay Gupta

author
#0 lore raw

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

Hi Andy,

Quoted 18 lines
Quoted 8 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.

Changes from v3 -> v4
Fixed comments from Andy

Unfortunatelly not all comments was addressed, see below.

Review

Quoted 6 lines
(quoted diff) +6 -0
+               if (err == ARRAY_SIZE(msgs)) {
+                       err = 0;
+               } else if (err >= 0) {
+                       dev_err(dev, "i2c_transfer failed, err %d\n", err);
+                       return -EIO;
+               }
Quoted 7 lines

Shouldn't be simple
if (err < 0) {
...
return err;
}

?

Ok, will fix

Quoted 9 lines

Review

Quoted 7 lines
(quoted diff) +6 -0
+       if (err == ARRAY_SIZE(msgs)) {
+               err = 0;
+       } else if (err >= 0) {
+               dev_err(dev, "i2c_transfer failed, err %d\n", err);
+               return -EIO;
+       }

Ditto.

ok

Quoted 8 lines

Review

Quoted 6 lines
(quoted diff) +4 -0
+       struct device *dev = uc->dev;
+       u8 data[64];
+       int err;
 
+       unsigned int count = 10;

Move this line upper a bit.

ok

Quoted 8 lines

Review

Quoted 4 lines
(quoted diff) +3 -0
+       unsigned char buf[3] = {
+               CCGX_I2C_RAB_INTR_REG & 0xff, CCGX_I2C_RAB_INTR_REG >>
+ 8, 0x0};

This should follow the style you applied earlier in the same file.

Also, & 0xff is redundant (better just to use >> 0).

Ok, even ">> 0" will be redundant so will just drop "& 0xff".

Quoted 4 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+       struct ucsi_ccg *uc = container_of(ppm,
+               struct ucsi_ccg, ppm);

One line?

ok

Quoted 8 lines

Review

Quoted 6 lines
(quoted diff) +4 -0
+static int ucsi_ccg_cmd(struct ucsi_ppm *ppm, struct ucsi_control
+*ctrl) {
+       struct ucsi_ccg *uc = container_of(ppm, struct ucsi_ccg, ppm);
 
+       int err = 0;

Redundant assignment.

ok

Quoted 8 lines
Quoted 7 lines
(quoted diff) +6 -0
+
+       ppm->data->ctrl.raw_cmd = ctrl->raw_cmd;
+       err = ucsi_ccg_send_data(uc);
+
+       return err;
+}
Quoted 4 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+static int ucsi_ccg_probe(struct i2c_client *client,
+                         const struct i2c_device_id *id)

One line?

It crosses column width of 80. It takes total 85.

Quoted 7 lines

Review

Quoted 5 lines
(quoted diff) +3 -0
+static const struct i2c_device_id ucsi_ccg_device_id[] = {
+       {"ccgx-ucsi", 0},
 
+       {},

Terminator better w/o comma.

Ok.

Quoted 4 lines

Review

Quoted 3 lines
(quoted diff) +2 -0
+};
+MODULE_DEVICE_TABLE(i2c, ucsi_ccg_device_id);

Thanks
Ajay

--
nvpublic
--

Quoted 3 lines

--
With Best Regards,
Andy Shevchenko