MTK电池充电充满后自动断电,电池少于百分之20%再继续充电(如果重新插电源,电池少于100%,就立即充电

28 篇文章 0 订阅
25 篇文章 1 订阅

MTK电池充电充满后自动断电

电池少于百分之20%再继续充电,如果重新插电源,电池少于100%,就立即充电

device/mediateksample/k53v1_64_bsp/init.project.rc

chown system system /proc/smb/ScreenComm
     chmod 0660 /proc/smb/ScreenComm
 
-
+    chmod 0777 /sys/devices/platform/mt-pmic/charger_status
 
 
 on init

kernel-3.18/drivers/misc/mediatek/power/mt6735/pmic.c

void homekey_int_handler_r(void)
 #endif
 }
 
+int g_charger_plusin = 0;
+extern void set_charger_first(int nfirststatus);
+int get_pulgstatus(void)
+{
+       return g_charger_plusin;
+}
 void chrdet_int_handler(void)
 {
-       PMICLOG("[chrdet_int_handler]CHRDET status = %d....\n",
-               pmic_get_register_value(PMIC_RGS_CHRDET));
+int ntmp = pmic_get_register_value(PMIC_RGS_CHRDET);
+       PMICLOG("sansan [chrdet_int_handler]CHRDET status = %d....\n",
+               ntmp);
+       if(ntmp == 1)
+       {
+               g_charger_plusin = 1;
+       }
+       else
+       {
+               g_charger_plusin = 0;
+               set_charger_first(0);
+       }
 
 #ifdef CONFIG_MTK_KERNEL_POWER_OFF_CHARGING
        if (!upmu_get_rgs_chrdet()) {
@@ -4815,6 +4831,17 @@ static ssize_t store_dlpt_level(struct device *dev, struct device_attribute *att
 static DEVICE_ATTR(dlpt_level, 0664, show_dlpt_level, store_dlpt_level);       /*664 */
 #endif
 
+extern int get_charger_status(void);
+static ssize_t show_charger_status(struct device *dev, struct device_attribute *attr, char *buf)
+{
+       return sprintf(buf, "%d", get_charger_status());
+}
+static ssize_t store_charger_status(struct device *dev, struct device_attribute *attr, const char *buf,
+                             size_t size)
+{
+       return size;
+}
+static DEVICE_ATTR(charger_status, 0664, show_charger_status, store_charger_status);
 /*****************************************************************************
  * system function
  ******************************************************************************/
@@ -4967,6 +4994,7 @@ static int __init pmic_mt_probe(struct platform_device *dev)
 
        ret_device_file = device_create_file(&(dev->dev), &dev_attr_pmic_access);
        ret_device_file = device_create_file(&(dev->dev), &dev_attr_pmic_dvt);
+       ret_device_file = device_create_file(&(dev->dev), &dev_attr_charger_status);
 
 #ifdef LOW_BATTERY_PROTECT
        ret_device_file = device_create_file(&(dev->dev), &dev_attr_low_battery_protect_ut);

kernel-3.18/drivers/power/mediatek/battery_common.c

static enum power_supply_property battery_props[] = {
        POWER_SUPPLY_PROP_adjust_power,
 };
 
+int get_soc(void)
+{      
+       return BMT_status.UI_SOC;
+}
 /*void check_battery_exist(void);*/
 void charging_suspend_enable(void)
 {

kernel-3.18/drivers/power/mediatek/linear_charging.c

static void pchr_sw_cv_charing_current_check(void)
                battery_log(BAT_LOG_CRTI, "[BATTERY] Sw CV set charging current Error!\n");
 }
 
+extern int get_soc(void);
+extern int get_pulgstatus(void);
+int g_isnot_first = 0;
+int g_int_charger_status = 0;
+int get_charger_status(void)
+{
+       return g_int_charger_status;
+}
+void set_charger_first(int nfirststatus)
+{
+       g_isnot_first = nfirststatus;
+}
+int get_charger_first(void)
+{
+       return g_isnot_first;
+}
 static void pchr_turn_on_charging(void)
 {
 #if !defined(CONFIG_MTK_JEITA_STANDARD_SUPPORT)
@@ -1112,7 +1128,23 @@ static void pchr_turn_on_charging(void)
 #endif
        unsigned int charging_enable = KAL_TRUE;
 
-       battery_log(BAT_LOG_FULL, "[BATTERY] pchr_turn_on_charging()!\r\n");
+       if((get_pulgstatus() == 1) && (g_isnot_first == 0) && (get_soc()>= 100))
+       {
+               g_isnot_first = 1;
+               charging_enable = KAL_FALSE;
+               battery_charging_control(CHARGING_CMD_ENABLE, &charging_enable);
+               g_int_charger_status = 2;
+               return;
+       }
+       if((get_pulgstatus() == 1) && (g_isnot_first == 1) && (get_soc()> 20))
+       {
+               charging_enable = KAL_FALSE;
+               battery_charging_control(CHARGING_CMD_ENABLE, &charging_enable);
+               g_int_charger_status = 2;
+               return;
+       }
+       g_int_charger_status = 0;
+       battery_log(BAT_LOG_FULL, "[BATTERY] sansan pchr_turn_on_charging()!\r\n");
 
        if (BMT_status.bat_charging_state == CHR_ERROR) {
                battery_log(BAT_LOG_CRTI, "[BATTERY] Charger Error, turn OFF charging !\n");

vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/BatteryMeterView.java

 public class BatteryMeterView extends LinearLayout implements
     @Override
     public void onBatteryLevelChanged(int level, boolean pluggedIn, boolean charging) {
         mDrawable.setBatteryLevel(level);
-        // M: In case battery protection, it stop charging, but still plugged, it will
-        // also wrongly show the charging icon.
-        mDrawable.setCharging(pluggedIn && charging);
+               try{
+                       BufferedReader reader = new BufferedReader(new FileReader("/sys/devices/platform/mt-pmic/charger_status"));
+                       String result = reader.readLine();
+                       if (result != null) {
+                               if(result.equals("2"))
+                               {
+                               mDrawable.setCharging(false);
+                               }
+                               else
+                               {
+                                       mDrawable.setCharging(pluggedIn);
+                               }
+                       }
+               }catch(IOException e){
+                       e.printStackTrace();
+               }
         mLevel = level;
         updatePercentText();
         setContentDescription(
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值