power: discrete charging solution intial version TCMD driver

Add mmi_chg_tcmd driver for tcmd
Porting from Moto solution :(CR) and fixed build err

Change-Id: I513227c592502ccae5fdcbd77018eb0a3e68d179
Reviewed-on: https://gerrit.mot.com/2059917
Reviewed-by: Huosheng Liao <liaohs@motorola.com>
SME-Granted: SME Approvals Granted
SLTApproved: Slta Waiver
Tested-by: Jira Key
Reviewed-by: Yuecai Liu <liuyc20@motorola.com>
Submit-Approved: Jira Key
This commit is contained in:
gongsc1 2021-09-06 10:52:00 +08:00 • committed by Yuecai Liu
commit 024f6dc9d6
5 changed files with 1363 additions and 0 deletions

View file

@ -0,0 +1,10 @@
DLKM_DIR := motorola/kernel/modules
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := mmi_chg_tcmd.ko
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_PATH := $(KERNEL_MODULES_OUT)
include $(DLKM_DIR)/AndroidKernelModule.mk
include $(call first-makefiles-under,$(LOCAL_PATH))

View file

@ -0,0 +1,5 @@
# add -Wall to try to catch everything we can.
EXTRA_CFLAGS += -Wall
EXTRA_CFLAGS += -I$(ANDROID_BUILD_TOP)/motorola/kernel/modules/include
obj-m += mmi_chg_tcmd.o

View file

@ -0,0 +1,10 @@
KERNEL_SRC ?= /lib/modules/$(shell uname -r)/build
all:
$(MAKE) -C $(KERNEL_SRC) M=$(shell pwd) modules $(KBUILD_OPTIONS)
modules_install:
$(MAKE) INSTALL_MOD_STRIP=1 -C $(KERNEL_SRC) M=$(shell pwd) modules_install
clean:
$(MAKE) -C $(KERNEL_SRC) M=$(PWD) clean

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,61 @@
#ifndef __MOTO_CHG_TCMD_H__
#define __MOTO_CHG_TCMD_H__
enum MOTO_CHG_TCMD_CLIENT_ID {
MOTO_CHG_TCMD_CLIENT_CHG,
MOTO_CHG_TCMD_CLIENT_BAT,
MOTO_CHG_TCMD_CLIENT_AP_ADC,
MOTO_CHG_TCMD_CLIENT_PM_ADC,
MOTO_CHG_TCMD_ClIENT_MAX
};
enum MOTO_ADC_TCMD_CHANNEL {
MOTO_ADC_TCMD_CHANNEL_CPU = 0,
MOTO_ADC_TCMD_CHANNEL_CHG,
MOTO_ADC_TCMD_CHANNEL_PA,
MOTO_ADC_TCMD_CHANNEL_BATID,
MOTO_ADC_TCMD_CHANNEL_VBAT,
MOTO_ADC_TCMD_CHANNEL_MAX
};
struct CHARGER_TEMPERATURE {
__s32 CHARGER_Temp;
__s32 TemperatureR;
};
struct mmi_chg_tcmd_client {
void *data;
int client_id;
bool factory_kill_disable;
#ifdef USE_LIST_HEAD
struct list_head list;
#endif
int (*reg_read)(void *input, unsigned char reg, unsigned char *val);//hex
int (*reg_write)(void *input, unsigned char reg, unsigned char val);//hex
int (*get_chg_current)(void *input, int* val);//unit mA
int (*set_chg_current)(void *input, int val);//unit mA
int (*set_chg_enable)(void *input, int val);
int (*get_usb_current)(void *input, int* val);//unit mA
int (*set_usb_current)(void *input, int val);//unit mA
int (*set_usb_enable)(void *input, int val);
int (*get_usb_voltage)(void *input, int* val);//unit uV
int (*get_charger_type)(void *input, int* val);
int (*get_bat_temp)(void *input, int* val);//unit C
int (*get_bat_voltage)(void *input, int* val);//unit uV
int (*get_bat_ocv)(void *input, int* val);//unit mV
int (*get_bat_id)(void *input, int* val);
int (*get_adc_value)(void *input, int channel, int* val);
};
int mmi_chg_tcmd_register(struct mmi_chg_tcmd_client *client);
#endif