Skip to content

Commit 948e9a0

Browse files
authored
fwk: fix Linux UCSI error message (#968)
Signed-off-by: Josh-Tsai <josh_tsai@compal.com>
1 parent 943a692 commit 948e9a0

File tree

1 file changed

+29
-5
lines changed
  • zephyr/program/lotus/src

1 file changed

+29
-5
lines changed

zephyr/program/lotus/src/ucsi.c

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,15 +148,20 @@ int ucsi_write_tunnel(void)
148148
} else
149149
i = 0;
150150

151-
pd_chip_ucsi_info[i].write_tunnel_complete = 1;
151+
pd_chip_ucsi_info[i].wait_ack = 1;
152152
rv = cypd_write_reg_block(i, CCG_MESSAGE_OUT_REG, message_out, 16);
153153
rv = cypd_write_reg_block(i, CCG_CONTROL_REG, command, 8);
154154
break;
155155
default:
156156
for (i = 0; i < PD_CHIP_COUNT; i++) {
157157

158+
/**
159+
* If the controller does not needs to respond ACK,
160+
* set the read tunnel complete flag.
161+
* Because ec will not write the command to PD chips.
162+
*/
158163
if (*command == UCSI_CMD_ACK_CC_CI &&
159-
pd_chip_ucsi_info[i].write_tunnel_complete == 0) {
164+
pd_chip_ucsi_info[i].wait_ack == 0) {
160165
pd_chip_ucsi_info[i].read_tunnel_complete = 1;
161166
continue;
162167
}
@@ -169,10 +174,14 @@ int ucsi_write_tunnel(void)
169174
if (rv != EC_SUCCESS)
170175
break;
171176

177+
/**
178+
* ACK_CC_CI command is the end of the UCSI command,
179+
* does not need to wait ack.
180+
*/
172181
if (*command == UCSI_CMD_ACK_CC_CI)
173-
pd_chip_ucsi_info[i].write_tunnel_complete = 0;
182+
pd_chip_ucsi_info[i].wait_ack = 0;
174183
else
175-
pd_chip_ucsi_info[i].write_tunnel_complete = 1;
184+
pd_chip_ucsi_info[i].wait_ack = 1;
176185
}
177186
break;
178187
}
@@ -319,12 +328,15 @@ int ucsi_read_tunnel(int controller)
319328
if (!chipset_in_state(CHIPSET_STATE_ON) && !chipset_in_state(CHIPSET_STATE_ANY_OFF))
320329
return EC_SUCCESS;
321330

331+
if (!(memcmp(host_get_memmap(EC_CUSTOMIZED_MEMMAP_UCSI_CONN_CHANGE),
332+
&pd_chip_ucsi_info[controller].cci, 4)))
333+
return EC_ERROR_UNKNOWN;
334+
322335
pd_chip_ucsi_info[controller].read_tunnel_complete = 1;
323336

324337
switch (*host_get_memmap(EC_CUSTOMIZED_MEMMAP_UCSI_COMMAND)) {
325338
case UCSI_CMD_PPM_RESET:
326339
case UCSI_CMD_CANCEL:
327-
case UCSI_CMD_ACK_CC_CI:
328340
case UCSI_CMD_SET_NOTIFICATION_ENABLE:
329341
case UCSI_CMD_GET_CAPABILITY:
330342
case UCSI_CMD_GET_ERROR_STATUS:
@@ -335,6 +347,18 @@ int ucsi_read_tunnel(int controller)
335347
else
336348
read_complete = 0;
337349
break;
350+
case UCSI_CMD_ACK_CC_CI:
351+
if (pd_chip_ucsi_info[0].read_tunnel_complete &&
352+
pd_chip_ucsi_info[1].read_tunnel_complete) {
353+
read_complete = 1;
354+
355+
/* workaround for linux driver */
356+
if ((pd_chip_ucsi_info[controller].cci & CCI_ACKNOWLEDGE_FLAG) !=
357+
pd_chip_ucsi_info[controller].cci)
358+
pd_chip_ucsi_info[controller].wait_ack = 1;
359+
} else
360+
read_complete = 0;
361+
break;
338362
default:
339363
if (pd_chip_ucsi_info[0].read_tunnel_complete ||
340364
pd_chip_ucsi_info[1].read_tunnel_complete)

0 commit comments

Comments
 (0)