sm5602: Add new fgauge sm5602

rhodep have second fgauge sm5602,so add it
the code from fae
sm5602 i2c address is 0x71

Change-Id: Iadb053862c559002cc31b945a5306211833befac
Signed-off-by: wutao <huaqin89@motorola.com>
Reviewed-on: https://gerrit.mot.com/2138848
SME-Granted: SME Approvals Granted
SLTApproved: Slta Waiver
Tested-by: Jira Key
Reviewed-by: Yuecai Liu <liuyc20@motorola.com>
Reviewed-by: Huosheng Liao <liaohs@motorola.com>
Submit-Approved: Jira Key
This commit is contained in:
wutao 2021-12-08 21:13:12 +08:00 • committed by huaqin89
commit f3aa85d1e0
5 changed files with 2926 additions and 0 deletions

View file

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

View file

@ -0,0 +1,7 @@
# add -Wall to try to catch everything we can.
EXTRA_CFLAGS += -Wall
EXTRA_CFLAGS += -I$(ANDROID_BUILD_TOP)/motorola/kernel/modules/include
EXTRA_CFLAGS += -I$(ANDROID_BUILD_TOP)/motorola/kernel/drivers/power/sm5602_fg_mmi
sm5602_fg_mmi-objs += sm5602_fg.o
obj-m += sm5602_fg_mmi.o

View file

@ -0,0 +1,11 @@
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,64 @@
/*
* drivers/battery/sm5602_fg.h
*
* Copyright (C) 2018 SiliconMitus
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*/
#ifndef SM5602_FG_H
#define SM5602_FG_H
#define FG_INIT_MARK 0xA000
#define FG_PARAM_UNLOCK_CODE 0x3700
#define FG_PARAM_LOCK_CODE 0x0000
#define FG_TABLE_LEN 0x18//real table length -1
#define FG_ADD_TABLE_LEN 0x8//real table length -1
#define FG_INIT_B_LEN 0x7//real table length -1
#define ENABLE_EN_TEMP_IN 0x0200
#define ENABLE_EN_TEMP_EX 0x0400
#define ENABLE_EN_BATT_DET 0x0800
#define ENABLE_IOCV_MAN_MODE 0x1000
#define ENABLE_FORCED_SLEEP 0x2000
#define ENABLE_SLEEPMODE_EN 0x4000
#define ENABLE_SHUTDOWN 0x8000
/* REG */
#define FG_REG_SOC_CYCLE 0x0B
#define FG_REG_SOC_CYCLE_CFG 0x15
#define FG_REG_ALPHA 0x20
#define FG_REG_BETA 0x21
#define FG_REG_RS 0x24
#define FG_REG_RS_1 0x25
#define FG_REG_RS_2 0x26
#define FG_REG_RS_3 0x27
#define FG_REG_RS_0 0x29
#define FG_REG_END_V_IDX 0x2F
#define FG_REG_START_LB_V 0x30
#define FG_REG_START_CB_V 0x38
#define FG_REG_START_LB_I 0x40
#define FG_REG_START_CB_I 0x48
#define FG_REG_VOLT_CAL 0x70
#define FG_REG_CURR_IN_OFFSET 0x75
#define FG_REG_CURR_IN_SLOPE 0x76
#define FG_REG_SRADDR 0x8C
#define FG_REG_SRDATA 0x8D
#define FG_REG_SWADDR 0x8E
#define FG_REG_SWDATA 0x8F
#define FG_REG_AGING_CTRL 0x9C
#define FG_TEMP_TABLE_CNT_MAX 0x65
#define FG_PARAM_VERION 0x1E
#define INIT_CHECK_MASK 0x0010
#define DISABLE_RE_INIT 0x0010
#endif /* SM5602_FG_H */