mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-09 05:39:54 -04:00
Bringup sgm4154x charger driver to Moto product
1. Fix the build issue on Androd S 2. Support externel USB power supply for charger input detection 3. Support battery fuel gauge power supply to query battery status 4. Register the charger to mmi charger driver architecture Change-Id: I852a176657964b4a8914176333171c0ab6d81b51 Signed-off-by: yanyh2 <yanyh2@motorola.com> Reviewed-on: https://gerrit.mot.com/2168097 SME-Granted: SME Approvals Granted SLTApproved: Slta Waiver Tested-by: Jira Key Reviewed-by: Jianqi Yang <yangj@motorola.com> Submit-Approved: Jira Key
This commit is contained in:
parent
9a2b3304dd
commit
c35ac191dc
6 changed files with 1316 additions and 213 deletions
14
drivers/power/sgm4154x_charger_lite/Android.mk
Normal file
14
drivers/power/sgm4154x_charger_lite/Android.mk
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
DLKM_DIR := motorola/kernel/modules
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
LOCAL_MODULE := sgm4154x_charger_lite.ko
|
||||
|
||||
KERNEL_CFLAGS += CONFIG_SGM4154X_CHARGER_NAME=$(SGM4154X_CHARGER_NAME)
|
||||
KBUILD_OPTIONS += CONFIG_SGM4154X_CHARGER_NAME=$(SGM4154X_CHARGER_NAME)
|
||||
|
||||
LOCAL_MODULE_PATH := $(KERNEL_MODULES_OUT)
|
||||
LOCAL_ADDITIONAL_DEPENDENCIES := $(KERNEL_MODULES_OUT)/mmi_charger.ko
|
||||
KBUILD_OPTIONS_GKI += GKI_OBJ_MODULE_DIR=gki
|
||||
include $(DLKM_DIR)/AndroidKernelModule.mk
|
||||
25
drivers/power/sgm4154x_charger_lite/Kbuild
Normal file
25
drivers/power/sgm4154x_charger_lite/Kbuild
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
# add -Wall to try to catch everything we can.
|
||||
EXTRA_CFLAGS += -Wall
|
||||
EXTRA_CFLAGS += -I$(ANDROID_BUILD_TOP)/motorola/kernel/modules/include \
|
||||
-I$(ANDROID_BUILD_TOP)/motorola/kernel/modules/drivers/power/sgm4154x_charger_lite \
|
||||
-I$(ANDROID_BUILD_TOP)/motorola/kernel/modules/drivers/power/mmi_charger
|
||||
|
||||
ifeq ($(CONFIG_SGM4154X_CHARGER_NAME),)
|
||||
EXTRA_CFLAGS += -D__SGM41516D_CHIP_ID__
|
||||
endif
|
||||
ifeq ($(CONFIG_SGM4154X_CHARGER_NAME),sgm41541)
|
||||
EXTRA_CFLAGS += -D__SGM41541_CHIP_ID__
|
||||
endif
|
||||
ifeq ($(CONFIG_SGM4154X_CHARGER_NAME),sgm41542)
|
||||
EXTRA_CFLAGS += -D__SGM41542_CHIP_ID__
|
||||
endif
|
||||
ifeq ($(CONFIG_SGM4154X_CHARGER_NAME),sgm41516)
|
||||
EXTRA_CFLAGS += -D__SGM41516_CHIP_ID__
|
||||
endif
|
||||
ifeq ($(CONFIG_SGM4154X_CHARGER_NAME),sgm41516D)
|
||||
EXTRA_CFLAGS += -D__SGM41516D_CHIP_ID__
|
||||
endif
|
||||
|
||||
obj-m += sgm4154x_charger_lite.o
|
||||
|
||||
KBUILD_EXTRA_SYMBOLS += $(CURDIR)/$(KBUILD_EXTMOD)/../mmi_charger/$(GKI_OBJ_MODULE_DIR)/Module.symvers
|
||||
16
drivers/power/sgm4154x_charger_lite/Makefile
Normal file
16
drivers/power/sgm4154x_charger_lite/Makefile
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
all: modules
|
||||
|
||||
modules:
|
||||
$(MAKE) -C $(KERNEL_SRC) M=$(M) modules $(KBUILD_OPTIONS)
|
||||
|
||||
modules_install:
|
||||
$(MAKE) INSTALL_MOD_STRIP=1 -C $(KERNEL_SRC) M=$(M) modules_install
|
||||
|
||||
%:
|
||||
$(MAKE) -C $(KERNEL_SRC) M=$(M) $@ $(KBUILD_OPTIONS)
|
||||
|
||||
clean:
|
||||
rm -f *.o *.ko *.mod.c *.mod.o *~ .*.cmd Module.symvers
|
||||
rm -rf .tmp_versions
|
||||
|
||||
KBUILD_EXTRA_SYMBOLS += $(CURDIR)/$(KBUILD_EXTMOD)/../mmi_charger/$(GKI_OBJ_MODULE_DIR)/Module.symvers
|
||||
215
drivers/power/sgm4154x_charger_lite/README
Normal file
215
drivers/power/sgm4154x_charger_lite/README
Normal file
|
|
@ -0,0 +1,215 @@
|
|||
Motorola Mobility. sgm4154x_charger_lite Specific Bindings
|
||||
|
||||
This sgm4154x charger driver is a lite version to support battery
|
||||
charging without BC1.2 charger type detection over DP/DM or OTG
|
||||
function.
|
||||
It utilizes an external USB power supply to query the input status
|
||||
and charger type.
|
||||
|
||||
This charger driver can work independently or cooperate with Motorola
|
||||
mmi_charger under the new Motorola charger driver architecture, so as
|
||||
to support multiple batteries system design.
|
||||
|
||||
Motorola charger driver architecture:
|
||||
-----------------------------------------------------------------------------------------------------------
|
||||
Userspace Common Interfaces for Charging Features and Factory Test
|
||||
-----------------------------------------------------------------------------------------------------------
|
||||
Kernel mmi_charger (Motorola demo, step, flash-fast charging,
|
||||
/ \ factory and debugging interfaces)
|
||||
/ \
|
||||
qti_glink_charger sgm4154x_charger_lite
|
||||
(base battery charging) (flip battery charging)
|
||||
| |
|
||||
| |
|
||||
------------glink-------------i2c--------------------------------------------------------------------------
|
||||
| |
|
||||
| |
|
||||
ADSP sgm4154x-chip
|
||||
|
||||
|
||||
devicetree properties description:
|
||||
- vdd-i2c-supply
|
||||
Usage: optional
|
||||
Value Type: pointer to power regulator
|
||||
Definition: power regulator to supply pullup power for i2c data lines
|
||||
|
||||
- sgm,irq-gpio
|
||||
Usage: mandatory
|
||||
Value Type: gpio
|
||||
Definition: input gpio used as chip irq line
|
||||
|
||||
- sgm,chg-en-gpio
|
||||
Usage: optional
|
||||
Value Type: gpio
|
||||
Definition: output gpio used as chip nCE pin controlling
|
||||
|
||||
- init-charger-disabled
|
||||
Usage: optional
|
||||
Value Type: bool
|
||||
Definition: Disable charger IC in initial state
|
||||
|
||||
- vrechg-millivolt
|
||||
Usage: optional
|
||||
Value Type: u32
|
||||
Definition: voltage diff with full voltage to trigger battery recharging
|
||||
|
||||
- iprechg-microamp
|
||||
Usage: optional
|
||||
Value Type: u32
|
||||
Definition: charging current in uA in precharging stage
|
||||
|
||||
- iterm-microamp
|
||||
Usage: optional
|
||||
Value Type: u32
|
||||
Definition: charging termination current in uA
|
||||
|
||||
- ichg-max-microamp
|
||||
Usage: optional
|
||||
Value Type: u32
|
||||
Definition: maximum charging current in uA
|
||||
|
||||
- vchg-max-microvolt
|
||||
Usage: optional
|
||||
Value Type: u32
|
||||
Definition: maximum charging voltage in uV
|
||||
|
||||
- ichg-microamp
|
||||
Usage: optional
|
||||
Value Type: u32
|
||||
Definition: initial charging current in uA
|
||||
|
||||
- vchg-microvolt
|
||||
Usage: optional
|
||||
Value Type: u32
|
||||
Definition: initial charging voltage in uV
|
||||
|
||||
- input-current-limit-microamp
|
||||
Usage: optional
|
||||
Value Type: u32
|
||||
Definition: USB input current limitation in uA
|
||||
|
||||
- mmi,ext-usb-psy-name
|
||||
Usage: optional
|
||||
Value Type: string
|
||||
Definition: Name of the external USB power supply which provides
|
||||
USB input status and information
|
||||
|
||||
- mmi,fg-psy-name
|
||||
Usage: optional
|
||||
Value Type: string
|
||||
Definition: Name of the battery FG power supply which provides
|
||||
battery status and information
|
||||
|
||||
- mmi,mmi-temp-zones
|
||||
Usage: optional
|
||||
Value Type: Array of tuples of <u32>
|
||||
Definition: Unlimited array of arrays. Each internal array needs to have a set
|
||||
of 4 bytes, each one representing this sequence: Temperature (in degC), Step
|
||||
"Normalized" Voltage (in millivolts), Full Rate "FCC" Current (in milliamps),
|
||||
and Taper Rate "FCC Normalized" Current (in milliamps). These values are
|
||||
related to charging limitations based on temperature specifications. Note that
|
||||
setting a voltage to '0' means that it doesn't matter the battery voltage on
|
||||
that defined temperature range to perform necessary tapering. To understand how
|
||||
Those values are used, please check the "IEEE Charging Compliance" section below.
|
||||
In order to support charging current limit based on battery voltage in the same
|
||||
temperature zone, one zone allows to have multiple lines with ascending sequence
|
||||
by float voltage. First find the temperature zone, and then find the right one
|
||||
among the same zone according to current battery voltage.
|
||||
|
||||
- mmi,df-serialnum
|
||||
Usage: optional
|
||||
Value Type: <string>
|
||||
Definition: The default battery serial number for charging profile selection
|
||||
and battery identification.
|
||||
|
||||
- mmi,chrg-iterm-ma
|
||||
Usage: optional
|
||||
Value Type: <u32>
|
||||
Definition: It will define taper current on battery (in milliamps). If charging
|
||||
current becomes below this value, it indicates FULL charging. If not defined,
|
||||
defaults to 300.
|
||||
|
||||
- mmi,fg-iterm-ma
|
||||
Usage: optional
|
||||
Value Type: <u32>
|
||||
Definition: It will define charging current on battery (in milliamps) as the
|
||||
threshold for the fuel gauge to decide reporting FULL capacity. If not defined,
|
||||
defaults to 350.
|
||||
|
||||
- mmi,vfloat-comp-uv
|
||||
Usage: optional
|
||||
Value Type: <u32>
|
||||
Definition: This is a tolerance, in uV, for battery floating voltage when
|
||||
charging is being limited. Such situation can happen when either battery is
|
||||
close to full or when there's thermal mitigation on charging. If not set,
|
||||
defaults to 0.
|
||||
|
||||
- mmi,max-fv-mv
|
||||
Usage: optional
|
||||
Value Type: <u32>
|
||||
Definition: It will define the maximum battery charging voltage (in milliamps).
|
||||
This value is used as the max float voltage for battery charging. If not
|
||||
defined, defaults to 4400.
|
||||
|
||||
- mmi,max-fcc-ma
|
||||
Usage: optional
|
||||
Value Type: <u32>
|
||||
Definition: It will define maximum charging current on battery (in milliamps)
|
||||
If not defined, defaults to 4000.
|
||||
|
||||
- mmi,demo-fv-mv
|
||||
Usage: optional
|
||||
Value Type: <u32>
|
||||
Definition: It will define the maximum battery charging voltage (in milliamps)
|
||||
in demo mode. This value is used as the max float voltage for battery charging in
|
||||
demo mode. If not defined, defaults to 4000.
|
||||
|
||||
- mmi,mmi-ffc-zones
|
||||
Usage: optional
|
||||
Value Type: Array of tuples of <u32>
|
||||
Definition: Unlimited array of arrays. Each internal array needs to have a set
|
||||
of 4 data members, each one representing this sequence: Temperature (in degC),
|
||||
maximum Float Voltage (in millivolts), charging terminated current(in milliamps),
|
||||
and Fuel Gauge FULL terminated current (in milliamps). These values are
|
||||
related to charging limitations based on temperature specifications when the
|
||||
battery supports Flash Fast Charging.
|
||||
|
||||
Example:
|
||||
sgm4154x_charger: sgm4154x@6B {
|
||||
compatible = "sgm,sgm41516D";
|
||||
reg = <0x6B>;
|
||||
|
||||
vdd-i2c-supply = <&S10B>;
|
||||
pinctrl-names = "default";
|
||||
pinctrl-0 = <&sgm4154x_irq_default &sgm4154x_ce_default>;
|
||||
|
||||
interrupt-parent = <&tlmm>;
|
||||
interrupts = <51 0>; //irq num base on hardware design
|
||||
sgm,irq-gpio = <&tlmm 51 0>; //irq num base on hardware design
|
||||
sgm,chg-en-gpio = <&pm8350c_gpios 2 GPIO_ACTIVE_HIGH>; //gpio num base on hardware design
|
||||
|
||||
init-charger-disabled;
|
||||
vrechg-millivolt = <200>;
|
||||
iprechg-microamp = <180000>;
|
||||
iterm-microamp = <200000>;
|
||||
ichg-max-microamp = <1200000>;
|
||||
vchg-max-microvolt = <4600000>;
|
||||
ichg-microamp = <700000>;
|
||||
vchg-microvolt = <4400000>;
|
||||
input-current-limit-microamp = <1200000>;
|
||||
|
||||
mmi,ext-usb-psy-name = "usb";
|
||||
mmi,fg-psy-name = "fg_flip_battery";
|
||||
mmi,chrg-iterm-ma = <50>;
|
||||
mmi,fg-iterm-ma = <100>;
|
||||
mmi,max-fv-mv = <4480>;
|
||||
mmi,max-fcc-ma = <1214>;
|
||||
mmi,demo-fv-mv = <4000>;
|
||||
mmi,df-serialnum = "SB18D44720";
|
||||
mmi,mmi-temp-zones = <0 4200 136 0>,
|
||||
<10 4250 340 204>,
|
||||
<15 0 679 476>,
|
||||
<45 4300 1214 883>,
|
||||
<45 4350 883 679>,
|
||||
<60 4200 679 0>;
|
||||
};
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -7,10 +7,12 @@
|
|||
|
||||
#include <linux/i2c.h>
|
||||
|
||||
#include "mmi_charger.h"
|
||||
|
||||
#define SGM4154x_MANUFACTURER "Texas Instruments"
|
||||
|
||||
//#define __SGM41541_CHIP_ID__
|
||||
#define __SGM41542_CHIP_ID__
|
||||
//#define __SGM41542_CHIP_ID__
|
||||
//#define __SGM41516_CHIP_ID__
|
||||
//#define __SGM41516D_CHIP_ID__
|
||||
|
||||
|
|
@ -48,7 +50,15 @@
|
|||
#define SGM4154x_INPUT_DET 0x0e
|
||||
#define SGM4154x_CHRG_CTRL_f 0x0f
|
||||
|
||||
/*rerun apsd*/
|
||||
#define SGM4154x_IINDET_EN_MASK GENMASK(7, 7)
|
||||
#define SGM4154x_IINDET_EN BIT(7)
|
||||
|
||||
/* charge status flags */
|
||||
#define SGM4154x_IINDPM_INT_MASK GENMASK(0, 0)
|
||||
#define SGM4154x_IINDPM_INT_DISABLE BIT(0)
|
||||
#define SGM4154x_VINDPM_INT_MASK GENMASK(1, 1)
|
||||
#define SGM4154x_VINDPM_INT_DISABLE BIT(1)
|
||||
#define SGM4154x_CHRG_EN BIT(4)
|
||||
#define SGM4154x_HIZ_EN BIT(7)
|
||||
#define SGM4154x_TERM_EN BIT(7)
|
||||
|
|
@ -56,6 +66,7 @@
|
|||
#define SGM4154x_DPDM_ONGOING BIT(7)
|
||||
#define SGM4154x_VBUS_GOOD BIT(7)
|
||||
|
||||
#define SGM4154X_BOOST_LIM_MASK GENMASK(7, 7)
|
||||
#define SGM4154x_OTG_MASK GENMASK(5, 4)
|
||||
#define SGM4154x_OTG_EN BIT(5)
|
||||
|
||||
|
|
@ -75,6 +86,11 @@
|
|||
|
||||
#define SGM4154x_WDT_RST_MASK BIT(6)
|
||||
|
||||
/*En termniataion*/
|
||||
#define SGM4154x_EN_TERM_MASK GENMASK(7,7)
|
||||
#define SGM4154x_EN_TERM_DISABLE 0
|
||||
#define SGM4154x_EN_TERM_ENABLE BIT(7)
|
||||
|
||||
/* SAFETY TIMER SET */
|
||||
#define SGM4154x_SAFETY_TIMER_MASK GENMASK(3, 3)
|
||||
#define SGM4154x_SAFETY_TIMER_DISABLE 0
|
||||
|
|
@ -173,6 +189,9 @@
|
|||
#define SGM4154x_PUMPX_DN BIT(5)
|
||||
|
||||
/* customer define jeita paramter */
|
||||
#define SGM4154x_JEITA_ENABLE_MASK GENMASK(0, 0)
|
||||
#define SGM4154x_JEITA_ENABLE BIT(0)
|
||||
#define SGM4154x_JEITA_DISABLE 0
|
||||
#define JEITA_TEMP_ABOVE_T4_CV 0
|
||||
#define JEITA_TEMP_T3_TO_T4_CV 4100000
|
||||
#define JEITA_TEMP_T2_TO_T3_CV 4350000
|
||||
|
|
@ -208,6 +227,8 @@ struct sgm4154x_init_data {
|
|||
u32 vlim; /* minimum system voltage limit */
|
||||
u32 max_ichg;
|
||||
u32 max_vreg;
|
||||
u32 vrechg;
|
||||
bool charger_disabled;
|
||||
};
|
||||
|
||||
struct sgm4154x_state {
|
||||
|
|
@ -225,6 +246,10 @@ struct sgm4154x_state {
|
|||
u8 health;
|
||||
u8 chrg_fault;
|
||||
u8 ntc_fault;
|
||||
|
||||
u32 ibus_limit;
|
||||
u32 vbus_adc;
|
||||
u32 ibus_adc;
|
||||
};
|
||||
|
||||
struct sgm4154x_jeita {
|
||||
|
|
@ -252,6 +277,17 @@ struct sgm4154x_jeita {
|
|||
int temp_neg_10_thres;
|
||||
};
|
||||
|
||||
struct sgm_mmi_charger {
|
||||
struct sgm4154x_device *sgm;
|
||||
struct mmi_battery_info batt_info;
|
||||
struct mmi_charger_info chg_info;
|
||||
struct mmi_charger_cfg chg_cfg;
|
||||
struct mmi_charger_constraint constraint;
|
||||
struct mmi_charger_driver *driver;
|
||||
u32 chrg_taper_cnt;
|
||||
struct power_supply *fg_psy;
|
||||
};
|
||||
|
||||
struct sgm4154x_device {
|
||||
struct i2c_client *client;
|
||||
struct device *dev;
|
||||
|
|
@ -287,6 +323,15 @@ struct sgm4154x_device {
|
|||
struct wakeup_source *charger_wakelock;
|
||||
bool enable_sw_jeita;
|
||||
struct sgm4154x_jeita data;
|
||||
bool enable_hw_jeita;
|
||||
|
||||
struct dentry *debug_root;
|
||||
|
||||
int chg_en_gpio;
|
||||
bool use_ext_usb_psy;
|
||||
struct regulator *vdd_i2c_vreg;
|
||||
struct notifier_block psy_nb;
|
||||
struct sgm_mmi_charger *mmi_charger;
|
||||
};
|
||||
|
||||
#endif /* _SGM4154x_CHARGER_H */
|
||||
|
|
|
|||
Loading…
Reference in a new issue