MTK OTG记录

1.deconfig中配置了CONFIG_USB_MTK_OTG=y,

dws配置

--- a/alps/kernel-4.19/drivers/misc/mediatek/dws/mt6765/k62v1_64_bsp.dws
+++ b/alps/kernel-4.19/drivers/misc/mediatek/dws/mt6765/k62v1_64_bsp.dws
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!--dct_version="2.5" buid_sn="161102" dws_modification_time="07.08.2024.17:08:08"-->
+<!--dct_version="2.5" buid_sn="161102" dws_modification_time="08.08.2024.17:11:07"-->
 <dct_cfg>
     <general chip="MT6765">
         <proj>MT6765</proj>
@@ -105,7 +105,7 @@
                 <debounce_en>Disable</debounce_en>
             </eint23>
             <eint41>
-                <varName>TCPC_PD</varName>
+                <varName>OTG_IDDIG</varName>
                 <debounce_time>0</debounce_time>
                 <polarity>Low</polarity>
                 <sensitive_level>Edge</sensitive_level>
@@ -564,7 +564,7 @@
                 <inpull_selhigh>true</inpull_selhigh>
                 <def_dir>IN</def_dir>
                 <out_high>false</out_high>
-                <varName0>GPIO_USB_TYPEC_EINT_PIN</varName0>
+                <varName0>GPIO_OTG_IDDIG_EINT_PIN</varName0>
                 <smt>false</smt>
                 <ies>true</ies>
             </gpio41>

2.没有6370的,需要自己去拉充电ic的5v电压,例如

--- a/alps/kernel-4.19/drivers/misc/mediatek/usb20/mt6765/usb20_host.c
+++ b/alps/kernel-4.19/drivers/misc/mediatek/usb20/mt6765/usb20_host.c
@@ -67,7 +67,7 @@ static void mt_usb_host_disconnect(int delay);
 struct device_node             *usb_node;
 static int iddig_eint_num;
 static ktime_t ktime_start, ktime_end;
-static struct regulator *reg_vbus;
+//static struct regulator *reg_vbus;
 
 static struct musb_fifo_cfg fifo_cfg_host[] = {
 { .hw_ep_num = 1, .style = MUSB_FIFO_TX,
@@ -121,17 +121,23 @@ bool usb20_check_vbus_on(void)
        DBG(0, "vbus_on<%d>\n", vbus_on);
        return vbus_on;
 }

+#if IS_ENABLED(CONFIG_CHARGER_ETA6937)
 
+extern void eta6937_set_otg_en(unsigned int val);
+
+#endif

 static void _set_vbus(int is_on)
 {
-       if (!reg_vbus) {
-               DBG(0, "vbus_init\n");
-               reg_vbus = regulator_get(mtk_musb->controller, "usb-otg-vbus");
-               if (IS_ERR_OR_NULL(reg_vbus)) {
-                       DBG(0, "failed to get vbus\n");
-                       return;
-               }
-       }
+       //if (!reg_vbus) {
+       //      DBG(0, "vbus_init\n");
+       //      reg_vbus = regulator_get(mtk_musb->controller, "usb-otg-vbus");
+       //      if (IS_ERR_OR_NULL(reg_vbus)) {
+       //              DBG(0, "failed to get vbus\n");
+       //              return;
+       //      }
+       //}
 
        DBG(0, "op<%d>, status<%d>\n", is_on, vbus_on);
        if (is_on && !vbus_on) {
@@ -140,21 +146,27 @@ static void _set_vbus(int is_on)
                 */
                vbus_on = true;
 
-               if (regulator_set_voltage(reg_vbus, 5000000, 5000000))
-                       DBG(0, "vbus regulator set voltage failed\n");
-
-               if (regulator_set_current_limit(reg_vbus, 1500000, 1800000))
-                       DBG(0, "vbus regulator set current limit failed\n");
-
-               if (regulator_enable(reg_vbus))
-                       DBG(0, "vbus regulator enable failed\n");
+               //if (regulator_set_voltage(reg_vbus, 5000000, 5000000))
+               //      DBG(0, "vbus regulator set voltage failed\n");
+               //
+               //if (regulator_set_current_limit(reg_vbus, 1500000, 1800000))
+               //      DBG(0, "vbus regulator set current limit failed\n");
+               //
+               //if (regulator_enable(reg_vbus))
+               //      DBG(0, "vbus regulator enable failed\n");
+               #if IS_ENABLED(CONFIG_CHARGER_ETA6937)
+           eta6937_set_otg_en(vbus_on);
+        #endif
 
        } else if (!is_on && vbus_on) {
                /* disable VBUS 1st then update flag
                 * to make host mode correct used by PMIC
                 */
                vbus_on = false;
-               regulator_disable(reg_vbus);
+               //regulator_disable(reg_vbus);
+               #if IS_ENABLED(CONFIG_CHARGER_ETA6937)
+           eta6937_set_otg_en(vbus_on);
+        #endif
        }
 }

3.注意,充电ic的5v有一个定时器(看门狗),这里的异常了,所以在别的地方进行了定时器操作

--- a/alps/kernel-4.19/drivers/misc/mediatek/thermal/mt6765/src/mtk_pmic_efuse.c
+++ b/alps/kernel-4.19/drivers/misc/mediatek/thermal/mt6765/src/mtk_pmic_efuse.c
@@ -299,6 +299,16 @@ void mtktspmic_get_from_dts(struct platform_device *pdev)
 }
 #endif
 

+#if !IS_ENABLED(CONFIG_TCPC_CLASS)
+extern bool mt_usb_is_device(void);
+#if IS_ENABLED(CONFIG_CHARGER_ETA6937)
+extern void eta6937_set_tmr_rst(unsigned int val);
+ extern void eta6937_set_otg_en(unsigned int val);
+#endif
+#endif

 int mtktspmic_get_hw_temp(void)
 {
        int temp = 0, temp1 = 0;
@@ -345,6 +355,17 @@ int mtktspmic_get_hw_temp(void)
        }
 
        mutex_unlock(&TSPMIC_lock);

+#if !IS_ENABLED(CONFIG_TCPC_CLASS)
+    if (!mt_usb_is_device()) {
+#if IS_ENABLED(CONFIG_CHARGER_ETA6937)
+       eta6937_set_otg_en(1);
+       eta6937_set_tmr_rst(1);
+#endif
+    }
+#endif
 
        return temp1;
 }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值