From: zain wang Date: Fri, 19 May 2017 05:47:09 +0000 (+0800) Subject: mfd: fusb302: Add is_pd_support to struct fusb30x_chip X-Git-Tag: release-20171130_firefly~4^2~521 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=8bb22ed2c8bebf20713fe08ecdd49ad9f23abfab;p=firefly-linux-kernel-4.4.55.git mfd: fusb302: Add is_pd_support to struct fusb30x_chip As the PD spec, we ough to tell policy engine if the cable support PD, some state would run depend on this value. Change-Id: Ied725ecb53f71a5e367b1ca91acd7f23372c54a1 Signed-off-by: zain wang --- diff --git a/drivers/mfd/fusb302.c b/drivers/mfd/fusb302.c index e0c9468b8d20..62c4d0016ddc 100644 --- a/drivers/mfd/fusb302.c +++ b/drivers/mfd/fusb302.c @@ -1402,6 +1402,8 @@ static void fusb_state_disabled(struct fusb30x_chip *chip, int evt) static void fusb_state_unattached(struct fusb30x_chip *chip, int evt) { chip->notify.is_cc_connected = 0; + chip->is_pd_support = 0; + if ((evt & EVENT_CC) && chip->cc_state) { if (chip->cc_state & 0x04) set_state(chip, attach_wait_sink); @@ -1550,12 +1552,13 @@ static void fusb_state_src_discovery(struct fusb30x_chip *chip, int evt) default: if (evt & EVENT_TIMER_STATE) { set_state(chip, policy_src_send_caps); - } else if ((evt & EVENT_TIMER_MUX) && - (chip->hardrst_count > N_HARDRESET_COUNT)) { - if (chip->notify.is_pd_connected) + } else if (evt & EVENT_TIMER_MUX) { + if (!chip->is_pd_support) + set_state(chip, disabled); + else if (chip->hardrst_count > N_HARDRESET_COUNT) set_state(chip, error_recovery); else - set_state(chip, disabled); + set_state(chip, policy_src_send_hardrst); } break; } @@ -1582,6 +1585,7 @@ static void fusb_state_src_send_caps(struct fusb30x_chip *chip, int evt) chip->timer_state); chip->timer_mux = T_DISABLED; chip->sub_state++; + chip->is_pd_support = 1; } else if (tmp == tx_failed) { set_state(chip, policy_src_discovery); break; @@ -1603,10 +1607,12 @@ static void fusb_state_src_send_caps(struct fusb30x_chip *chip, int evt) else set_state(chip, disabled); } else if (evt & EVENT_TIMER_MUX) { - if (chip->notify.is_pd_connected) + if (!chip->is_pd_support) set_state(chip, disabled); - else + else if (chip->hardrst_count > N_HARDRESET_COUNT) set_state(chip, error_recovery); + else + set_state(chip, policy_src_send_hardrst); } break; } @@ -1886,17 +1892,22 @@ static void fusb_state_snk_wait_caps(struct fusb30x_chip *chip, int evt) if (evt & EVENT_RX) { if (PD_HEADER_CNT(chip->rec_head) && PD_HEADER_TYPE(chip->rec_head) == DMT_SOURCECAPABILITIES) { + chip->is_pd_support = 1; chip->timer_mux = T_DISABLED; set_state(chip, policy_snk_evaluate_caps); } } else if (evt & EVENT_TIMER_STATE) { - if (chip->hardrst_count <= N_HARDRESET_COUNT) + if (chip->hardrst_count <= N_HARDRESET_COUNT) { set_state(chip, policy_snk_send_hardrst); - else - set_state(chip, disabled); + } else { + if (chip->is_pd_support) + set_state(chip, error_recovery); + else + set_state(chip, disabled); + } } else if ((evt & EVENT_TIMER_MUX) && (chip->hardrst_count > N_HARDRESET_COUNT)) { - if (chip->notify.is_pd_connected) + if (chip->is_pd_support) set_state(chip, error_recovery); else set_state(chip, disabled); diff --git a/drivers/mfd/fusb302.h b/drivers/mfd/fusb302.h index 8d98e94120a9..905a0c8ef33b 100644 --- a/drivers/mfd/fusb302.h +++ b/drivers/mfd/fusb302.h @@ -430,6 +430,7 @@ struct fusb30x_chip { u32 vdm_id; u8 chip_id; bool vconn_enabled; + bool is_pd_support; int togdone_pullup; int pd_output_vol; int pd_output_cur;