Skip to content

Commit 63bd50a

Browse files
Josh-Tsaiquinchou77
authored andcommitted
fwk: ucsi: support CCGx UCSI1.x and UCSI2.x message out offset
"CCGx UCSI v2.0 Firmware Design Document" describes the UCSI2.0 message out offset should be 0xF110. BRANCH=fwk-main BUG=https://app.clickup.com/t/86equ4vr1 TEST=UCSI driver does not show the YB in the device manager (v1.1) Signed-off-by: Josh Tsai <Josh_Tsai@compal.com> (cherry picked from commit 0b3138f)
1 parent 62720a3 commit 63bd50a

4 files changed

Lines changed: 21 additions & 4 deletions

File tree

zephyr/program/framework/include/cypress_pd_common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
#define CCG_CONTROL_REG 0xF008
7171
#define CCG_MESSAGE_IN_REG 0xF010
7272
#define CCG_MESSAGE_OUT_REG 0xF020
73+
#define CCG_MESSAGE_OUT_REG_V2 0xF110
7374

7475

7576
/************************************************/

zephyr/program/framework/include/ucsi.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ extern struct ucsi_to_pd_port_map ucsi_pd_port_map[];
7878
int ucsi_write_tunnel(void);
7979
int ucsi_read_tunnel(int controller);
8080
int ucsi_startup(int controller);
81+
int ucsi_message_out_offset(void);
8182
void ucsi_set_debug(bool enable);
8283
void check_ucsi_event_from_host(void);
8384
void record_ucsi_connector_change_event(int controller, int port);

zephyr/program/framework/src/cypress_pd_common.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2277,14 +2277,14 @@ static int cmd_cypd_get_status(int argc, const char **argv)
22772277
}
22782278
CPRINTS("=====UCSI======");
22792279
cypd_read_reg16(i, CCG_VERSION_REG, &data);
2280-
CPRINTS(" Version: 0x%02x", data);
2280+
CPRINTS(" Version: 0x%04x", data);
22812281
cypd_read_reg_block(i, CCG_CCI_REG, data16, 4);
22822282
cypd_print_buff(" CCI:", data16, 4);
22832283
cypd_read_reg_block(i, CCG_CONTROL_REG, data16, 8);
22842284
cypd_print_buff(" Control:", data16, 8);
22852285
cypd_read_reg_block(i, CCG_MESSAGE_IN_REG, data16, 16);
22862286
cypd_print_buff(" Msg In:", data16, 16);
2287-
cypd_read_reg_block(i, CCG_MESSAGE_OUT_REG, data16, 16);
2287+
cypd_read_reg_block(i, ucsi_message_out_offset(), data16, 16);
22882288
cypd_print_buff(" Msg Out:", data16, 16);
22892289
}
22902290

zephyr/program/framework/src/ucsi.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,21 @@ const char *command_names(uint8_t command)
8181
return "";
8282
}
8383

84+
int ucsi_message_out_offset(void)
85+
{
86+
uint16_t *version = (uint16_t *)host_get_memmap(EC_CUSTOMIZED_MEMMAP_UCSI_VERSION);
87+
88+
/*
89+
* version format JJ.M.N
90+
* e.g version 2.1.3 is respresented with value 0x0213
91+
*/
92+
93+
if (*version < 0x0200)
94+
return CCG_MESSAGE_OUT_REG;
95+
else
96+
return CCG_MESSAGE_OUT_REG_V2;
97+
}
98+
8499
int ucsi_write_tunnel(void)
85100
{
86101
uint8_t *message_out = host_get_memmap(EC_CUSTOMIZED_MEMMAP_UCSI_MESSAGE_OUT);
@@ -147,7 +162,7 @@ int ucsi_write_tunnel(void)
147162
}
148163

149164
pd_chip_ucsi_info[controller].wait_ack = 1;
150-
rv = cypd_write_reg_block(controller, CCG_MESSAGE_OUT_REG, message_out, 16);
165+
rv = cypd_write_reg_block(controller, ucsi_message_out_offset(), message_out, 16);
151166
rv = cypd_write_reg_block(controller, CCG_CONTROL_REG, command, 8);
152167
break;
153168
default:
@@ -164,7 +179,7 @@ int ucsi_write_tunnel(void)
164179
continue;
165180
}
166181

167-
rv = cypd_write_reg_block(i, CCG_MESSAGE_OUT_REG, message_out, 16);
182+
rv = cypd_write_reg_block(i, ucsi_message_out_offset(), message_out, 16);
168183
if (rv != EC_SUCCESS)
169184
break;
170185

0 commit comments

Comments
 (0)