BSP : add CCIC TRY SNK FUNCTION
authorJunhan Bae <junhan84.bae@samsung.com>
Mon, 19 Nov 2018 07:40:16 +0000 (16:40 +0900)
committerxiest1 <xiest1@lenovo.com>
Tue, 5 Nov 2019 09:29:58 +0000 (17:29 +0800)
    [9609][EVB] drivers: add ccic try snk function

    Bug:HQ00000000

    Workaround:no

Change-Id: I6d1165e226065505d2e4ea7b3914247a60b1f88e

arch/arm64/configs/robusta2_evb_defconfig
drivers/ccic/Kconfig
drivers/ccic/s2mu106-usbpd.c

index b5ef1d708a5e0eb74c080aa80d4643a91c7b2ea3..edc4cf49a4737e784f732d20e1c2810241a9871d 100755 (executable)
@@ -493,6 +493,7 @@ CONFIG_USE_CCIC=y
 CONFIG_CCIC_S2MU106=y
 CONFIG_CCIC_VDM=y
 CONFIG_CCIC_SYSFS=y
+CONFIG_CCIC_TRY_SNK=y
 CONFIG_EXT2_FS=y
 CONFIG_EXT3_FS=y
 CONFIG_EXT4_FS_SECURITY=y
index d08787d1e94e023bcbe1f1c6729a9e41f40b2700..f3d3c69a3e6ce274f745d87074815eb97fb0741b 100755 (executable)
@@ -28,6 +28,14 @@ config CCIC_S2MU106
          If you say yes here you will get support for
          for the S2MU106 USBPD chip.
 
+config CCIC_TRY_SNK
+       bool "Using USB PD TRY SNK FUNCTION"
+       depends on USE_CCIC
+       default n
+       help
+         If you say yes here you will get support for
+         Try Snk Function.
+
 config CCIC_VDM
        bool "Using USB PD VDM Message"
        depends on USE_CCIC
index 28a791d81672c591aad25c6a58cef74b492ad12e..cb9e2f3979626986dcb3362f7771bfb61389e514 100644 (file)
@@ -2150,6 +2150,7 @@ static void s2mu106_usbpd_detach_init(struct s2mu106_usbpd_data *pdic_data)
        struct device *dev = pdic_data->dev;
        struct usbpd_data *pd_data = dev_get_drvdata(dev);
        int ret = 0;
+       u8 data = 0;
 
        dev_info(dev, "%s\n", __func__);
 
@@ -2175,6 +2176,24 @@ static void s2mu106_usbpd_detach_init(struct s2mu106_usbpd_data *pdic_data)
 
        pdic_data->status_reg = 0;
        usbpd_reinit(dev);
+#ifdef CONFIG_CCIC_TRY_SNK
+       s2mu106_usbpd_read_reg(i2c, S2MU106_REG_PLUG_CTRL_PORT, &data);
+       data &= ~(S2MU106_REG_PLUG_CTRL_MODE_MASK | S2MU106_REG_PLUG_CTRL_RP_SEL_MASK);
+       data |= S2MU106_REG_PLUG_CTRL_DRP | S2MU106_REG_PLUG_CTRL_RP180;
+       s2mu106_usbpd_write_reg(i2c, S2MU106_REG_PLUG_CTRL_PORT, data);
+
+       s2mu106_usbpd_read_reg(i2c, S2MU106_REG_PLUG_CTRL, &data);
+       data |= S2MU106_REG_PLUG_CTRL_UFP_ATTACH_OPT;
+       s2mu106_usbpd_write_reg(i2c, S2MU106_REG_PLUG_CTRL, data);
+
+       s2mu106_usbpd_read_reg(i2c, S2MU106_REG_PLUG_CTRL_SET_RD, &data);
+       data &= ~S2MU106_REG_USB31_EN;
+       s2mu106_usbpd_write_reg(i2c, S2MU106_REG_PLUG_CTRL_SET_RD, data);
+
+       s2mu106_usbpd_read_reg(i2c, S2MU106_REG_PLUG_CTRL_DET, &data);
+       data |= S2MU106_REG_DET_RD_OR_VBUS;
+       s2mu106_usbpd_write_reg(i2c, S2MU106_REG_PLUG_CTRL_DET, data);
+#endif
        pdic_data->rid = REG_RID_MAX;
        pdic_data->check_rid_wa = false;
        pdic_data->is_factory_mode = false;