Skip to content

Commit 71ef301

Browse files
LeilaCY-Linquinchou77
authored andcommitted
fwk: let connector remap port not to overwrite the other memory location
The connector change indicated port's size is 7 bits. We should keep the memory's 8th-bit value. Add the 8th-bit value back when we rewrite the EC_CUSTOMIZED_MEMMAP_UCSI_CTR_SPECIFIC shared memory. fix commit 64c85ed BRANCH=fwk-main BUG=https://app.clickup.com/t/86ervu6rf BUG=https://app.clickup.com/t/86er6n76t TEST=check HLK test item all pass Signed-off-by: LeilaCY-Lin <LeilaCY_Lin@compal.com> (cherry picked from commit 52ff80e)
1 parent 63bd50a commit 71ef301

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

  • zephyr/program/framework/src

zephyr/program/framework/src/ucsi.c

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ int ucsi_write_tunnel(void)
104104
int controller = 0;
105105
int offset = 0;
106106
int rv = EC_SUCCESS;
107+
int new_port = 0;
107108

108109
/**
109110
* Note that CONTROL data has always to be written after MESSAGE_OUT data is written
@@ -156,8 +157,13 @@ int ucsi_write_tunnel(void)
156157
CPRINTS("UCSI write invalid type-c port:%d",
157158
change_connector_indicator);
158159
} else {
159-
*host_get_memmap(EC_CUSTOMIZED_MEMMAP_UCSI_CTR_SPECIFIC + offset) =
160-
ucsi_pd_port_map[change_connector_indicator-1].pd_controller_port;
160+
new_port =
161+
ucsi_pd_port_map[change_connector_indicator-1].pd_controller_port;
162+
if (new_port != change_connector_indicator) {
163+
*host_get_memmap(EC_CUSTOMIZED_MEMMAP_UCSI_CTR_SPECIFIC + offset) =
164+
(*host_get_memmap(EC_CUSTOMIZED_MEMMAP_UCSI_CTR_SPECIFIC + offset)
165+
& 0x80) | new_port;
166+
}
161167
controller = ucsi_pd_port_map[change_connector_indicator-1].pd_controller;
162168
}
163169

@@ -322,6 +328,7 @@ int ucsi_read_tunnel(int controller)
322328
int rv, port_indicator;
323329
int message_in_max_length;
324330
uint16_t *version = (uint16_t *)host_get_memmap(EC_CUSTOMIZED_MEMMAP_UCSI_VERSION);
331+
int new_port = 0;
325332

326333
if (ucsi_debug_enable && pd_chip_ucsi_info[controller].read_tunnel_complete == 1 &&
327334
(pd_chip_ucsi_info[controller].cci & CCI_BUSY_FLAG) == 0) {
@@ -340,8 +347,11 @@ int ucsi_read_tunnel(int controller)
340347
if (ucsi_debug_enable && port_indicator > PORTS_PER_CONTROLLER)
341348
CPRINTS("UCSI read invalid type-c port:%d", port_indicator);
342349
} else {
343-
pd_chip_ucsi_info[controller].cci = (pd_chip_ucsi_info[controller].cci & 0xFFFFFF01)
344-
| (pd_ucsi_port_map[controller*2+port_indicator-1] << 1);
350+
new_port = (pd_ucsi_port_map[controller*2+port_indicator-1]);
351+
if (port_indicator != new_port) {
352+
pd_chip_ucsi_info[controller].cci = (pd_chip_ucsi_info[controller].cci
353+
& 0xFFFFFF01) | (new_port << 1);
354+
}
345355
}
346356

347357
message_in_max_length = (*version < 0x0200) ? 16 : 34;

0 commit comments

Comments
 (0)