mirror of
https://github.com/LineageOS/android_kernel_samsung_msm8226.git
synced 2026-09-28 00:00:22 +02:00
s3ve3g: switched to sec-battery and qpnp-charger drivers
This commit brings up the support for sec-battery and qpnp-charger drivers to s3ve3g devices. Old qpnp-sec-charger driver, a heavily modified qpnp-charger driver by Samsung, caused internal issues such as no CPU deep sleep on Android 6.0+. Following nodes will be removed: /sys/module/qpnp_sec_charger Following nodes will be added: /sys/class/power_supply/pogo /sys/class/power_supply/ps /sys/class/power_supply/qpnp-chg /sys/class/power_supply/wireless /sys/module/qpnp_charger Requires Samsung's charger_monitor binary with proper permissions set to nodes (see above) at init to interact with userspace Change-Id: I1af484378b3a8dc6c3819a8670852be433131f32
This commit is contained in:
committed by
Francescodario Cuzzocrea
parent
d589ce7a35
commit
144ee58965
@@ -0,0 +1,80 @@
|
||||
/* Copyright (c) 2013, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 and
|
||||
* only version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
&soc {
|
||||
battery {
|
||||
status = "okay";
|
||||
compatible = "samsung,sec-battery";
|
||||
battery,vendor = "SDI SDI";
|
||||
battery,charger_name = "qpnp-chg";
|
||||
battery,fuelgauge_name = "bms";
|
||||
battery,technology = <2>; /* POWER_SUPPLY_TECHNOLOGY_LION */
|
||||
|
||||
battery,chip_vendor = "QCOM";
|
||||
battery,temp_adc_type = <1>; /* SEC_BATTERY_ADC_TYPE_AP */
|
||||
|
||||
battery,polling_time = <10 30 30 30 3600>;
|
||||
|
||||
battery,adc_check_count = <5>;
|
||||
|
||||
battery,cable_check_type = <4>; /* SEC_BATTERY_CABLE_CHECK_PSY */
|
||||
battery,cable_source_type = <3>; /* SEC_BATTERY_CABLE_SOURCE_EXTERNAL */
|
||||
battery,event_waiting_time = <600>;
|
||||
battery,polling_type = <1>; /* SEC_BATTERY_MONITOR_ALARM */
|
||||
battery,monitor_initial_count = <3>;
|
||||
|
||||
battery,battery_check_type = <5>; /* SEC_BATTERY_CHECK_CHARGER */
|
||||
battery,check_count = <0>;
|
||||
battery,check_adc_max = <1440>;
|
||||
battery,check_adc_min = <0>;
|
||||
|
||||
battery,ovp_uvlo_check_type = <3>; /* SEC_BATTERY_OVP_UVLO_CHGPOLLING */
|
||||
|
||||
battery,thermal_source = <2>; /* SEC_BATTERY_THERMAL_SOURCE_ADC */
|
||||
battery,temp_check_type = <2>; /* SEC_BATTERY_TEMP_CHECK_TEMP */
|
||||
battery,temp_check_count = <1>;
|
||||
battery,full_check_type = <2>; /* SEC_BATTERY_FULLCHARGED_FG_CURRENT */
|
||||
battery,full_check_type_2nd = <3>; /* SEC_BATTERY_FULLCHARGED_TIME */
|
||||
battery,full_check_count = <2>;
|
||||
battery,chg_gpio_full_check = <0>;
|
||||
battery,chg_polarity_full_check = <1>;
|
||||
|
||||
/* SEC_BATTERY_FULL_CONDITION_SOC |
|
||||
SEC_BATTERY_FULL_CONDITION_NOTIMEFULL |
|
||||
SEC_BATTERY_FULL_CONDITION_VCELL */
|
||||
battery,full_condition_type = <13>;
|
||||
battery,full_condition_soc = <95>;
|
||||
battery,full_condition_vcell = <4250>;
|
||||
|
||||
battery,recharge_check_count = <1>;
|
||||
battery,recharge_condition_type = <4>; /* SEC_BATTERY_RECHARGE_CONDITION_VCELL */
|
||||
battery,recharge_condition_soc = <98>;
|
||||
battery,recharge_condition_vcell = <4300>;
|
||||
|
||||
battery,charging_total_time = <21600>;
|
||||
battery,recharging_total_time = <5400>;
|
||||
battery,charging_reset_time = <0>;
|
||||
|
||||
charger {
|
||||
status = "disable"
|
||||
/* Charger */
|
||||
battery,charger_name = "qpnp-chg";
|
||||
battery,ovp_uvlo_check_type = <3>; /* SEC_BATTERY_OVP_UVLO_CHGPOLLING */
|
||||
battery,full_check_type = <2>; /* SEC_BATTERY_FULLCHARGED_FG_CURRENT */
|
||||
|
||||
battery,input_current_limit = <1000 500 500 1000 500 1000 1000 500 500 1000 650 1000 1000 500 500 300 1000 1000 300 1000 1000 500 500>;
|
||||
battery,fast_charging_current = <1000 0 500 1000 500 1000 1000 500 0 1000 750 1000 1000 (-1) 500 300 1000 1000 300 1000 1000 0 0>;
|
||||
battery,full_check_current_1st = <170 0 170 170 170 170 170 170 0 170 170 170 170 0 170 170 170 170 170 170 170 0 0>;
|
||||
battery,full_check_current_2nd = <2400 0 2400 2400 2400 2400 2400 2400 0 2400 2400 2400 2400 0 2400 2400 2400 2400 2400 2400 2400 0 0>;
|
||||
};
|
||||
};
|
||||
};
|
||||
@@ -13,6 +13,7 @@
|
||||
/include/ "dsi-panel-s6e8aa0a-720p-video.dtsi"
|
||||
/include/ "msm8226-camera-sensor-mtp-s3ve-r01.dtsi"
|
||||
/include/ "msm8226-sm5502.dtsi"
|
||||
/include/ "msm8226-sec-s3ve3geur-battery-data.dtsi"
|
||||
/*/include/ "msm8226-s3ve-sensor-r01.dtsi"*/
|
||||
|
||||
&soc {
|
||||
@@ -412,9 +413,6 @@
|
||||
qcom,pm8226@0 {
|
||||
pm8226_chg: qcom,charger {
|
||||
qcom,ext-ovp-present = <0>;
|
||||
sec,temp-high-recover-event = <470>;
|
||||
sec,temp-high-recover-normal = <470>;
|
||||
sec,temp-high-recover-lpm = <470>;
|
||||
};
|
||||
|
||||
qcom,leds@a300 {
|
||||
@@ -623,14 +621,31 @@
|
||||
};
|
||||
};
|
||||
|
||||
/ {
|
||||
mtp_batterydata: qcom,battery-data {
|
||||
qcom,rpull-up-kohm = <100>;
|
||||
qcom,vref-batt-therm = <1800000>;
|
||||
|
||||
/include/ "batterydata-palladium.dtsi"
|
||||
/include/ "batterydata-mtp-3000mah.dtsi"
|
||||
};
|
||||
};
|
||||
|
||||
&pm8226_bms {
|
||||
status = "ok"
|
||||
qcom,enable-fcc-learning;
|
||||
qcom,min-fcc-learning-soc = <20>;
|
||||
qcom,min-fcc-ocv-pc = <30>;
|
||||
qcom,min-fcc-learning-samples = <5>;
|
||||
qcom,fcc-resolution = <10>;
|
||||
qcom,battery-data = <&mtp_batterydata>;
|
||||
};
|
||||
|
||||
&pm8226_chg {
|
||||
qcom,charging-disabled;
|
||||
sec,imax-ta = <1000>;
|
||||
sec,imax-usb = <500>;
|
||||
qcom,battery-data = <&mtp_batterydata>;
|
||||
qcom,cool-bat-decidegc = <(-50)>;
|
||||
qcom,warm-bat-decidegc = <700>;
|
||||
};
|
||||
|
||||
&slim_msm {
|
||||
|
||||
@@ -2304,12 +2304,14 @@ CONFIG_POWER_SUPPLY=y
|
||||
# CONFIG_BATTERY_BQ27541 is not set
|
||||
# CONFIG_BATTERY_BQ28400 is not set
|
||||
# CONFIG_QPNP_CHARGER is not set
|
||||
CONFIG_QPNP_SEC_CHARGER=y
|
||||
CONFIG_NOT_USE_EXT_OVP=y
|
||||
CONFIG_BATTERY_SAMSUNG=y
|
||||
CONFIG_BATTERY_SAMSUNG_DATA_FILE="s3ve3g_battery_data.h"
|
||||
CONFIG_QPNP_CHARGER=y
|
||||
# CONFIG_LTC4088_CHARGER is not set
|
||||
CONFIG_BATTERY_BCL=y
|
||||
# CONFIG_CHARGER_SMB347 is not set
|
||||
CONFIG_QPNP_BMS=y
|
||||
# CONFIG_BATTERY_SWELLING is not set
|
||||
CONFIG_HWMON=y
|
||||
# CONFIG_HWMON_VID is not set
|
||||
# CONFIG_HWMON_DEBUG_CHIP is not set
|
||||
@@ -3797,9 +3799,6 @@ CONFIG_DEVFREQ_GOV_MSM_CPUFREQ=y
|
||||
#
|
||||
# CONFIG_CORESIGHT is not set
|
||||
# CONFIG_BIF is not set
|
||||
# CONFIG_BATTERY_SAMSUNG is not set
|
||||
# CONFIG_BATTERY_SAMSUNG_DATA is not set
|
||||
# CONFIG_BATTERY_SWELLING is not set
|
||||
# CONFIG_CHARGER_SM5414 is not set
|
||||
CONFIG_SAMSUNG_LPM_MODE=y
|
||||
# CONFIG_SAMSUNG_BATTERY_ENG_TEST is not set
|
||||
|
||||
@@ -2304,12 +2304,14 @@ CONFIG_POWER_SUPPLY=y
|
||||
# CONFIG_BATTERY_BQ27541 is not set
|
||||
# CONFIG_BATTERY_BQ28400 is not set
|
||||
# CONFIG_QPNP_CHARGER is not set
|
||||
CONFIG_QPNP_SEC_CHARGER=y
|
||||
CONFIG_NOT_USE_EXT_OVP=y
|
||||
CONFIG_BATTERY_SAMSUNG=y
|
||||
CONFIG_BATTERY_SAMSUNG_DATA_FILE="s3ve3g_battery_data.h"
|
||||
CONFIG_QPNP_CHARGER=y
|
||||
# CONFIG_LTC4088_CHARGER is not set
|
||||
CONFIG_BATTERY_BCL=y
|
||||
# CONFIG_CHARGER_SMB347 is not set
|
||||
CONFIG_QPNP_BMS=y
|
||||
# CONFIG_BATTERY_SWELLING is not set
|
||||
CONFIG_HWMON=y
|
||||
# CONFIG_HWMON_VID is not set
|
||||
# CONFIG_HWMON_DEBUG_CHIP is not set
|
||||
@@ -3797,9 +3799,6 @@ CONFIG_DEVFREQ_GOV_MSM_CPUFREQ=y
|
||||
#
|
||||
# CONFIG_CORESIGHT is not set
|
||||
# CONFIG_BIF is not set
|
||||
# CONFIG_BATTERY_SAMSUNG is not set
|
||||
# CONFIG_BATTERY_SAMSUNG_DATA is not set
|
||||
# CONFIG_BATTERY_SWELLING is not set
|
||||
# CONFIG_CHARGER_SM5414 is not set
|
||||
CONFIG_SAMSUNG_LPM_MODE=y
|
||||
# CONFIG_SAMSUNG_BATTERY_ENG_TEST is not set
|
||||
|
||||
@@ -2304,12 +2304,14 @@ CONFIG_POWER_SUPPLY=y
|
||||
# CONFIG_BATTERY_BQ27541 is not set
|
||||
# CONFIG_BATTERY_BQ28400 is not set
|
||||
# CONFIG_QPNP_CHARGER is not set
|
||||
CONFIG_QPNP_SEC_CHARGER=y
|
||||
CONFIG_NOT_USE_EXT_OVP=y
|
||||
CONFIG_BATTERY_SAMSUNG=y
|
||||
CONFIG_BATTERY_SAMSUNG_DATA_FILE="s3ve3g_battery_data.h"
|
||||
CONFIG_QPNP_CHARGER=y
|
||||
# CONFIG_LTC4088_CHARGER is not set
|
||||
CONFIG_BATTERY_BCL=y
|
||||
# CONFIG_CHARGER_SMB347 is not set
|
||||
CONFIG_QPNP_BMS=y
|
||||
# CONFIG_BATTERY_SWELLING is not set
|
||||
CONFIG_HWMON=y
|
||||
# CONFIG_HWMON_VID is not set
|
||||
# CONFIG_HWMON_DEBUG_CHIP is not set
|
||||
@@ -3797,9 +3799,6 @@ CONFIG_DEVFREQ_GOV_MSM_CPUFREQ=y
|
||||
#
|
||||
# CONFIG_CORESIGHT is not set
|
||||
# CONFIG_BIF is not set
|
||||
# CONFIG_BATTERY_SAMSUNG is not set
|
||||
# CONFIG_BATTERY_SAMSUNG_DATA is not set
|
||||
# CONFIG_BATTERY_SWELLING is not set
|
||||
# CONFIG_CHARGER_SM5414 is not set
|
||||
# CONFIG_SAMSUNG_LPM_MODE is not set
|
||||
# CONFIG_SAMSUNG_BATTERY_ENG_TEST is not set
|
||||
|
||||
@@ -89,9 +89,12 @@ CONFIG_TORCH_FIX=y
|
||||
# CONFIG_IR_REMOCON_MC96 is not set
|
||||
|
||||
#Battery charging & BMS
|
||||
CONFIG_QPNP_SEC_CHARGER=y
|
||||
CONFIG_BATTERY_SAMSUNG=y
|
||||
CONFIG_BATTERY_SAMSUNG_DATA_FILE="s3ve3g_battery_data.h"
|
||||
CONFIG_QPNP_CHARGER=y
|
||||
CONFIG_BATTERY_BCL=y
|
||||
CONFIG_QPNP_BMS=y
|
||||
# CONFIG_BATTERY_SWELLING is not set
|
||||
|
||||
#Sec Thermistor
|
||||
CONFIG_SEC_THERMISTOR=y
|
||||
@@ -114,6 +117,3 @@ CONFIG_SEC_DHA_SOL_MAL=y
|
||||
# QCOM DEBUG
|
||||
CONFIG_MSM_RTB=y
|
||||
CONFIG_MSM_RTB_SEPARATE_CPUS=y
|
||||
|
||||
# DO NOT EXT OVP
|
||||
CONFIG_NOT_USE_EXT_OVP=y
|
||||
|
||||
Executable
+82
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* battery_data.h
|
||||
* Samsung Mobile Battery data Header
|
||||
*
|
||||
*
|
||||
* Copyright (C) 2012 Samsung Electronics, Inc.
|
||||
*
|
||||
*
|
||||
* This software is licensed under the terms of the GNU General Public
|
||||
* License version 2, as published by the Free Software Foundation, and
|
||||
* may be copied, distributed, and modified under those terms.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __SEC_BATTERY_DATA_H
|
||||
#define __SEC_BATTERY_DATA_H __FILE__
|
||||
|
||||
static void * samsung_battery_data;
|
||||
|
||||
#define CAPACITY_MAX 1000
|
||||
#define CAPACITY_MAX_MARGIN 50
|
||||
#define CAPACITY_MIN 0
|
||||
|
||||
static sec_bat_adc_table_data_t temp_table[] = {
|
||||
{26537, 800},
|
||||
{26849, 750},
|
||||
{27211, 700},
|
||||
{27627, 650},
|
||||
{28117, 600},
|
||||
{28713, 550},
|
||||
{29403, 500},
|
||||
{30205, 450},
|
||||
{31075, 400},
|
||||
{32026, 350},
|
||||
{33014, 300},
|
||||
{34117, 250},
|
||||
{35115, 200},
|
||||
{36121, 150},
|
||||
{37212, 100},
|
||||
{38190, 50},
|
||||
{39006, 0},
|
||||
{39813, -50},
|
||||
{40490, -100},
|
||||
{41084, -150},
|
||||
{41537, -200},
|
||||
};
|
||||
|
||||
static sec_bat_adc_table_data_t chg_temp_table[] = {
|
||||
{0, 0},
|
||||
};
|
||||
|
||||
#define TEMP_HIGH_THRESHOLD_EVENT 600
|
||||
#define TEMP_HIGH_RECOVERY_EVENT 470
|
||||
#define TEMP_LOW_THRESHOLD_EVENT (-50)
|
||||
#define TEMP_LOW_RECOVERY_EVENT 0
|
||||
#define TEMP_HIGH_THRESHOLD_NORMAL 600
|
||||
#define TEMP_HIGH_RECOVERY_NORMAL 470
|
||||
#define TEMP_LOW_THRESHOLD_NORMAL (-50)
|
||||
#define TEMP_LOW_RECOVERY_NORMAL 0
|
||||
#define TEMP_HIGH_THRESHOLD_LPM 600
|
||||
#define TEMP_HIGH_RECOVERY_LPM 470
|
||||
#define TEMP_LOW_THRESHOLD_LPM (-50)
|
||||
#define TEMP_LOW_RECOVERY_LPM 0
|
||||
|
||||
#if defined(CONFIG_BATTERY_SWELLING)
|
||||
#define BATT_SWELLING_HIGH_TEMP_BLOCK 500
|
||||
#define BATT_SWELLING_HIGH_TEMP_RECOV 450
|
||||
#define BATT_SWELLING_LOW_TEMP_BLOCK 50
|
||||
#define BATT_SWELLING_LOW_TEMP_RECOV 100
|
||||
#define BATT_SWELLING_HIGH_CHG_CURRENT 0
|
||||
#define BATT_SWELLING_LOW_CHG_CURRENT 0
|
||||
#define BATT_SWELLING_DROP_FLOAT_VOLTAGE 4200
|
||||
#define BATT_SWELLING_HIGH_RECHG_VOLTAGE 4150
|
||||
#define BATT_SWELLING_LOW_RECHG_VOLTAGE 4050
|
||||
#endif
|
||||
|
||||
#endif /* __SEC_BATTERY_DATA_H */
|
||||
@@ -1900,12 +1900,13 @@ static void sec_bat_check_changed_soc(
|
||||
dev_info(battery->dev, "%s: prev_reported_soc = %d, soc = %d\n",
|
||||
__func__, battery->prev_reported_soc, value->intval);
|
||||
}
|
||||
#if !defined(CONFIG_MACH_S3VE3G_EUR) // update immediately on s3ve3g devices
|
||||
/* if soc have been chaged, only change soc by 1
|
||||
* soc in increased ? (previous + 1) : (previous - 1) */
|
||||
value->intval = (value->intval > battery->prev_reported_soc) ?
|
||||
(battery->prev_reported_soc + 1) :
|
||||
(battery->prev_reported_soc - 1);
|
||||
|
||||
#endif
|
||||
if (value->intval > 100)
|
||||
value->intval = 100;
|
||||
else if (value->intval < 0)
|
||||
|
||||
@@ -1607,7 +1607,7 @@ qpnp_chg_vddmax_and_trim_set(struct qpnp_chg_chip *chip,
|
||||
voltage, trim_mv, vddmax, trim);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if !defined(CONFIG_BATTERY_SAMSUNG) || (defined(CONFIG_BATTERY_SAMSUNG) && defined(CONFIG_BATTERY_SWELLING))
|
||||
static int
|
||||
qpnp_chg_vddmax_get(struct qpnp_chg_chip *chip)
|
||||
{
|
||||
@@ -1622,6 +1622,7 @@ qpnp_chg_vddmax_get(struct qpnp_chg_chip *chip)
|
||||
|
||||
return QPNP_CHG_V_MIN_MV + (int)vddmax * QPNP_CHG_V_STEP_MV;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* JEITA compliance logic */
|
||||
static void
|
||||
@@ -5553,7 +5554,9 @@ static enum power_supply_property sec_qpnp_chg_props[] = {
|
||||
POWER_SUPPLY_PROP_INPUT_CURRENT_TRIM,
|
||||
POWER_SUPPLY_PROP_INPUT_CURRENT_SETTLED,
|
||||
POWER_SUPPLY_PROP_VOLTAGE_MIN,
|
||||
#if defined(CONFIG_BATTERY_SWELLING)
|
||||
POWER_SUPPLY_PROP_VOLTAGE_MAX,
|
||||
#endif
|
||||
POWER_SUPPLY_PROP_INPUT_VOLTAGE_REGULATION,
|
||||
};
|
||||
|
||||
@@ -5568,7 +5571,9 @@ sec_qpnp_chg_property_is_writeable(struct power_supply *psy,
|
||||
case POWER_SUPPLY_PROP_INPUT_CURRENT_TRIM:
|
||||
case POWER_SUPPLY_PROP_INPUT_CURRENT_SETTLED:
|
||||
case POWER_SUPPLY_PROP_VOLTAGE_MIN:
|
||||
#if defined(CONFIG_BATTERY_SWELLING)
|
||||
case POWER_SUPPLY_PROP_VOLTAGE_MAX:
|
||||
#endif
|
||||
case POWER_SUPPLY_PROP_COOL_TEMP:
|
||||
case POWER_SUPPLY_PROP_WARM_TEMP:
|
||||
case POWER_SUPPLY_PROP_CAPACITY:
|
||||
@@ -5644,9 +5649,11 @@ sec_qpnp_chg_get_property(struct power_supply *psy,
|
||||
case POWER_SUPPLY_PROP_VOLTAGE_MIN:
|
||||
val->intval = qpnp_chg_vinmin_get(chip) * 1000;
|
||||
break;
|
||||
#if defined(CONFIG_BATTERY_SWELLING)
|
||||
case POWER_SUPPLY_PROP_VOLTAGE_MAX:
|
||||
val->intval = qpnp_chg_vddmax_get(chip);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
@@ -5764,11 +5771,13 @@ sec_qpnp_chg_set_property(struct power_supply *psy,
|
||||
case POWER_SUPPLY_PROP_VOLTAGE_MIN:
|
||||
qpnp_chg_vinmin_set(chip, val->intval / 1000);
|
||||
break;
|
||||
#if defined(CONFIG_BATTERY_SWELLING)
|
||||
case POWER_SUPPLY_PROP_VOLTAGE_MAX:
|
||||
pr_info("set cv(%dmV)",val->intval);
|
||||
qpnp_chg_vddmax_and_trim_set(chip, val->intval,
|
||||
chip->delta_vddmax_mv);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user