[9610] usbpd Rp default to Contract.
authorJunhan Bae <junhan84.bae@samsung.com>
Tue, 5 Nov 2019 11:47:43 +0000 (20:47 +0900)
committerxiest1 <xiest1@lenovo.com>
Fri, 8 Nov 2019 06:24:14 +0000 (14:24 +0800)
Change-Id: I653309e3f33eefa61b202fc0c073941fd8ead9ec
Signed-off-by: Junhan Bae <junhan84.bae@samsung.com>
drivers/ccic/s2mu106-usbpd.c
drivers/ccic/usbpd.c
drivers/ccic/usbpd_policy.c
include/linux/ccic/usbpd.h

index bd93121893081009a04f4bcdd4f06973ea5e76e7..97a966e4582b0b9ac0c401907127c5c81a79c444 100644 (file)
@@ -1072,6 +1072,18 @@ static int s2mu106_set_cc_control(void *_data, int val)
        return ret;
 }
 
+static int s2mu106_set_rp_control(void *_data, int val)
+{
+       struct usbpd_data *data = (struct usbpd_data *) _data;
+       struct s2mu106_usbpd_data *pdic_data = data->phy_driver_data;
+
+       mutex_lock(&pdic_data->cc_mutex);
+       s2mu106_usbpd_set_rp_scr_sel(pdic_data, val);
+       mutex_unlock(&pdic_data->cc_mutex);
+
+       return 0;
+}
+
 static int s2mu106_vbus_on_check(void *_data)
 {
        struct usbpd_data *data = (struct usbpd_data *) _data;
@@ -2405,7 +2417,6 @@ static int s2mu106_check_port_detect(struct s2mu106_usbpd_data *pdic_data)
                        dev_err(&i2c->dev, "%s, abnormal attach\n", __func__);
                        return -1;
                }
-               s2mu106_usbpd_set_rp_scr_sel(pdic_data, PLUG_CTRL_RP180);
                ret = s2mu106_usbpd_check_accessory(pdic_data);
                if (ret < 0) {
                        dev_info(&i2c->dev, "%s attach accessory\n", __func__);
@@ -3136,6 +3147,7 @@ static usbpd_phy_ops_type s2mu106_ops = {
        .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,
 };
 
 #if defined CONFIG_PM
index c441086e9a77cff400ff2d2cd6a1e61c0268ab64..532bdec4b0020056f467c6587f9ec74f4913fca5 100644 (file)
@@ -332,6 +332,7 @@ void usbpd_set_ops(struct device *dev, usbpd_phy_ops_type *ops)
        pd_data->phy_ops.get_side_check = ops->get_side_check;
        pd_data->phy_ops.pr_swap = ops->pr_swap;
        pd_data->phy_ops.vbus_on_check = ops->vbus_on_check;
+       pd_data->phy_ops.set_rp_control = ops->set_rp_control;
        pd_data->phy_ops.set_pwr_opmode = ops->set_pwr_opmode;
 }
 
index d08449200175938c1cb4b81db85f5d751eabd561..b91461a521a5cd63e574d1e21351b8cbddd0ee0d 100644 (file)
@@ -303,6 +303,8 @@ 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);
+                       pd_data->phy_ops.set_rp_control(pd_data, PLUG_CTRL_RP180);
+
                        ret = PE_SRC_Ready;
                        break;
                }
index 3e293d08c0969e95e49dae5ad189a8908192c099..e8651457fe1436c204af8b32789727def8804a5e 100644 (file)
@@ -351,6 +351,7 @@ typedef struct usbpd_phy_ops {
        int    (*set_cc_control)(void *, int);
        void    (*pr_swap)(void *, int);
        int    (*vbus_on_check)(void *);
+       int             (*set_rp_control)(void *, int);
        int             (*get_side_check)(void *_data);
        void    (*set_pwr_opmode)(void *_data, int mode);
 } usbpd_phy_ops_type;