From: Jinsu Park Date: Tue, 19 Nov 2019 05:01:52 +0000 (+0900) Subject: [RAMEN9610-20929][9610] usbpd cc instead of vbus X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=ae091dd3514edf27c978d6a935c046a4d44a26bc;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git [RAMEN9610-20929][9610] usbpd cc instead of vbus Change-Id: I34765d950ae47f1056a84fdf198e4b5e65028765 Signed-off-by: Jinsu Park --- diff --git a/drivers/ccic/s2mu106-usbpd.c b/drivers/ccic/s2mu106-usbpd.c index 97a966e4582b..cc5c4e4b2bd5 100644 --- a/drivers/ccic/s2mu106-usbpd.c +++ b/drivers/ccic/s2mu106-usbpd.c @@ -1059,6 +1059,28 @@ static int s2mu106_set_otg_control(void *_data, int val) return 0; } +static int s2mu106_cc_instead_of_vbus(void *_data, int enable) +{ + struct usbpd_data *data = (struct usbpd_data *)_data; + struct s2mu106_usbpd_data *pdic_data = data->phy_driver_data; + struct i2c_client *i2c = pdic_data->i2c; + u8 val; + + //Setting for CC Detection with Vbus + //It is recognized that Vbus falls when CC line falls + s2mu106_usbpd_read_reg(i2c, S2MU106_REG_PLUG_CTRL_VBUS_MUX, &val); + val &= ~S2MU106_REG_RD_OR_VBUS_MUX_SEL; + s2mu106_usbpd_write_reg(i2c, S2MU106_REG_PLUG_CTRL_VBUS_MUX, val); + s2mu106_usbpd_read_reg(i2c, S2MU106_REG_PLUG_CTRL, &val); + if (enable) + val |= S2MU106_REG_PLUG_CTRL_ATTACH_OPT_EN; + else + val &= ~S2MU106_REG_PLUG_CTRL_ATTACH_OPT_EN; + s2mu106_usbpd_write_reg(i2c, S2MU106_REG_PLUG_CTRL, val); + + return 0; +} + static int s2mu106_set_cc_control(void *_data, int val) { struct usbpd_data *data = (struct usbpd_data *) _data; @@ -3143,8 +3165,9 @@ static usbpd_phy_ops_type s2mu106_ops = { .driver_reset = s2mu106_driver_reset, .set_otg_control = s2mu106_set_otg_control, .set_cc_control = s2mu106_set_cc_control, + .cc_instead_of_vbus = s2mu106_cc_instead_of_vbus, .get_side_check = s2mu106_get_side_check, - .pr_swap = s2mu106_pr_swap, + .pr_swap = s2mu106_pr_swap, .vbus_on_check = s2mu106_vbus_on_check, .set_pwr_opmode = s2mu106_set_pwr_opmode, .set_rp_control = s2mu106_set_rp_control, diff --git a/drivers/ccic/usbpd.c b/drivers/ccic/usbpd.c index 532bdec4b002..e0073cb7642b 100644 --- a/drivers/ccic/usbpd.c +++ b/drivers/ccic/usbpd.c @@ -328,6 +328,7 @@ void usbpd_set_ops(struct device *dev, usbpd_phy_ops_type *ops) pd_data->phy_ops.poll_status = ops->poll_status; pd_data->phy_ops.driver_reset = ops->driver_reset; pd_data->phy_ops.set_otg_control = ops->set_otg_control; + pd_data->phy_ops.cc_instead_of_vbus = ops->cc_instead_of_vbus; pd_data->phy_ops.set_cc_control = ops->set_cc_control; pd_data->phy_ops.get_side_check = ops->get_side_check; pd_data->phy_ops.pr_swap = ops->pr_swap; diff --git a/drivers/ccic/usbpd_policy.c b/drivers/ccic/usbpd_policy.c index b91461a521a5..3263b5d5e51b 100644 --- a/drivers/ccic/usbpd_policy.c +++ b/drivers/ccic/usbpd_policy.c @@ -303,6 +303,10 @@ policy_state usbpd_policy_src_transition_supply(struct policy_data *policy) return ret; usbpd_send_ctrl_msg(pd_data, &policy->tx_msg_header, USBPD_PS_RDY, USBPD_DFP, USBPD_SOURCE); + + /* Check CC instead of Vbus */ + pd_data->phy_ops.cc_instead_of_vbus(pd_data, 1); + pd_data->phy_ops.set_rp_control(pd_data, PLUG_CTRL_RP180); ret = PE_SRC_Ready; diff --git a/include/linux/ccic/usbpd.h b/include/linux/ccic/usbpd.h index e8651457fe14..42fe9117d0dc 100644 --- a/include/linux/ccic/usbpd.h +++ b/include/linux/ccic/usbpd.h @@ -348,6 +348,7 @@ typedef struct usbpd_phy_ops { bool (*poll_status)(void *); void (*driver_reset)(void *); int (*set_otg_control)(void *, int); + int (*cc_instead_of_vbus)(void*, int); int (*set_cc_control)(void *, int); void (*pr_swap)(void *, int); int (*vbus_on_check)(void *);