Skip to content

Commit 0476683

Browse files
Josh-Tsaiamstan
authored andcommitted
fwk: cypd: add the logic to select the first PD device
The CCG6 PD chip only supports 1.5A + 3A output, EC needs to select the first PD device to allow it to request the 5V/3A PDO. BRANCH=fwk-dogwood-27111 BUG=https://app.clickup.com/t/86etza0y1 TEST=Only one type-c port can request 5V/3A Signed-off-by: Josh Tsai <[email protected]>
1 parent 4b37daa commit 0476683

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

zephyr/program/framework/include/cypress_pd_common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,7 @@ struct pd_port_current_state_t {
521521
int current;
522522
int ac_port;
523523
bool rdo_mismatch;
524+
bool first_pd_device;
524525
enum ccg_c_state c_state; /* What device is attached on the other side */
525526
uint8_t pd_state;
526527
uint8_t cc;

zephyr/program/framework/src/cypress_pd_common.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -999,6 +999,7 @@ static void clear_port_state(int controller, int port)
999999
pd_port_states[port_idx].current = 0;
10001000
pd_port_states[port_idx].voltage = 0;
10011001
pd_port_states[port_idx].rdo_mismatch = false;
1002+
pd_port_states[port_idx].first_pd_device = false;
10021003
}
10031004

10041005
void cypd_update_port_state(int controller, int port)
@@ -1711,6 +1712,7 @@ void cypd_port_int(int controller, int port)
17111712

17121713
/* Read the contract information if we are the source */
17131714
int pd_port = ((controller << 2) + port);
1715+
int another_pd_port = ((controller << 2) + (port ? 0 : 1));
17141716

17151717
if (pd_port_states[pd_port].pd_state == PD_ROLE_SOURCE) {
17161718
i2c_read_offset16_block(i2c_port, addr_flags,
@@ -1721,6 +1723,12 @@ void cypd_port_int(int controller, int port)
17211723
pd_port_states[pd_port].rdo_mismatch = true;
17221724
task_set_event(TASK_ID_CYPD, CCG_EVT_RDO_MISMATCH);
17231725
}
1726+
1727+
/* check if the device is the first 3A pd device or not */
1728+
if (pd_port_states[another_pd_port].pd_state != PD_ROLE_SOURCE ||
1729+
(pd_port_states[another_pd_port].pd_state == PD_ROLE_SOURCE &&
1730+
pd_port_states[another_pd_port].current != 3000))
1731+
pd_port_states[pd_port].first_pd_device = true;
17241732
}
17251733
#ifdef CONFIG_PD_CCG8_EPR
17261734
/* make sure enter EPR mode only process in S0 state */
@@ -1954,7 +1962,8 @@ void cypd_interrupt_handler_task(void *p)
19541962
if (evt & CCG_EVT_RDO_MISMATCH) {
19551963
if (cypd_allow_increase_rdo_profile()) {
19561964
for (i = 0; i < PD_PORT_COUNT; i++) {
1957-
if (pd_port_states[i].rdo_mismatch)
1965+
if (pd_port_states[i].rdo_mismatch &&
1966+
pd_port_states[i].first_pd_device)
19581967
cypd_select_pdo(PORT_TO_CONTROLLER(i),
19591968
PORT_TO_CONTROLLER_PORT(i),
19601969
CCG_PD_CMD_SET_TYPEC_3A);

0 commit comments

Comments
 (0)