感谢大佬提供支持,https://blog.csdn.net/mike8825/article/details/113431326
mtk系统在sys/class/power_supluy/ac这个下面缺少 current_max,voltage_max 这两个节点
在内核中添加这两个节点可以改善:
kernel-4.19/drivers/misc/mediatek/pmic/mt6370/mt6370_pmu_charger.c
@@ -34,7 +34,7 @@
static int yt_charge_current = 0;
//static int yt_charge_state=0;
-struct mt6370_pmu_charger_data *chg_data_yt;
+struct mt6370_pmu_charger_data *chg_data_yt=NULL;
static bool dbg_log_en;
module_param(dbg_log_en, bool, 0644);
@@ -4512,6 +4512,24 @@ static int charge_create_attr(struct platform_device *pdev)
err = device_create_file(&(pdev->dev), &dev_attr_charge_current);
return err;
}
+
+int getChargerCurrent(void)
+{
+ int result = 500000;
+ bool pwr_rdy = false;
+ if (NULL == chg_data_yt)
+ {
+ return result;
+ }
+ mt6370_pmu_reg_test_bit(chg_data_yt->chip,
+ MT6370_PMU_REG_OVPCTRLSTAT,
+ MT6370_SHIFT_OVPCTRL_UVP_D_STAT, &pwr_rdy);
+ /* Get value from ADC */
+ mt6370_get_adc(chg_data_yt, MT6370_ADC_IBUS, &result);
+ return result;
+}
+EXPORT_SYMBOL(getChargerCurrent);
+
static int mt6370_pmu_charger_probe(struct platform_device *pdev)
kernel-4.19/drivers/power/supply/mt6357-charger-type.c
index 4862336cd07..0b5ba8371ed 100644
@@ -15,7 +15,7 @@
#include <linux/power_supply.h>
#include <mtk_musb.h>
#include <linux/reboot.h>
-
+extern int getChargerCurrent(void);
/* ============================================================ */
/* pmic control start*/
/* ============================================================ */
@@ -113,6 +113,10 @@ static enum power_supply_property chr_type_properties[] = {
static enum power_supply_property mt_ac_properties[] = {
POWER_SUPPLY_PROP_ONLINE,
+ POWER_SUPPLY_PROP_CURRENT_MAX,
+ POWER_SUPPLY_PROP_VOLTAGE_MAX,
};
static enum power_supply_property mt_usb_properties[] = {
@@ -722,6 +726,14 @@ static int mt_ac_get_property(struct power_supply *psy,
(info->type == POWER_SUPPLY_USB_TYPE_CDP))
val->intval = 0;
break;
+ case POWER_SUPPLY_PROP_CURRENT_MAX:
+ val->intval = getChargerCurrent();//500000;
+ break;
+ case POWER_SUPPLY_PROP_VOLTAGE_MAX:
+ val->intval = 5000000;
+ break;
default:
return -EINVAL;
}
转载请标明出处