feat: charge: initialize pump charger sc8551a driver

CHAMPION-25

Change-Id: I32bf77d04fc5c67f52dcc7ec8081a3feb4b08795
Signed-off-by: zhangguoliang <zhangguoliang3@xiaomi.com>
This commit is contained in:
zhangguoliang
2021-08-27 19:18:34 +08:00
committed by zhangguoliang3
parent 888ea2ae84
commit a87fbef0f1
6 changed files with 2943 additions and 9 deletions
+23 -9
View File
@@ -374,6 +374,15 @@ config BQ25618
---help---
The BQ25618 are battery charger for lithium-ion batteries.
config SC8551
bool "SC8551 Battery charger support"
default n
select I2C
select I2C_SC8551
depends on BATTERY_CHARGER
---help---
The SC8551 are battery charger for lithium-ion batteries.
config MCP73871
bool "Microchip MCP73871 Battery charger support"
default n
@@ -401,19 +410,20 @@ config DEBUG_BQ25618
endif # BQ25618
if SC8551
config DEBUG_SC8551
bool "SC8551 Debug Features"
default n
---help---
Enable SC8551 battery management debug features.
endif # SC8551
config BATTERY_GAUGE
bool "Battery Fuel Gauge support"
default n
config CW2218
bool "CW2218 Battery fuel gauge support"
default n
select I2C
depends on BATTERY_GAUGE
---help---
The CW2218 is an ultra-compact, system-side or pack-side fuel gauging
IC for Lithium-ion based batteries used in wearable and portable devices
config MAX1704X
bool "MAX1704X Battery fuel gauge support"
default n
@@ -459,6 +469,10 @@ config I2C_BQ25618
bool
default y if BQ25618
config I2C_SC8551
bool
default y if SC8551
config I2C_MAX1704X
bool
default y if MAX1704X
+4
View File
@@ -99,6 +99,10 @@ ifeq ($(CONFIG_I2C_BQ2429X),y)
CSRCS += bq2429x.c
endif
ifeq ($(CONFIG_I2C_SC8551),y)
CSRCS += sc8551.c
endif
# Add the BQ256XX I2C-based battery charger driver
ifeq ($(CONFIG_I2C_BQ25618),y)
File diff suppressed because it is too large Load Diff
+147
View File
@@ -0,0 +1,147 @@
/****************************************************************************
* drivers/power/sc8551.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
#ifndef __INCLUDE_NUTTX_POWER_SC8551_H
#define __INCLUDE_NUTTX_POWER_SC8551_H
/****************************************************************************
* Included Files
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
struct sc8551_cfg_s
{
bool bat_ovp_disable;
bool bat_ocp_disable;
bool bat_ovp_alm_disable;
bool bat_ocp_alm_disable;
int bat_ovp_th;
int bat_ovp_alm_th;
int bat_ocp_th;
int bat_ocp_alm_th;
bool bus_ovp_alm_disable;
bool bus_ocp_disable;
bool bus_ocp_alm_disable;
int bus_ovp_th;
int bus_ovp_alm_th;
int bus_ocp_th;
int bus_ocp_alm_th;
bool bat_ucp_alm_disable;
int bat_ucp_alm_th;
int ac_ovp_th;
bool bat_therm_disable;
bool bus_therm_disable;
bool die_therm_disable;
int bat_therm_th; /* in % */
int bus_therm_th; /* in % */
int die_therm_th; /* in degC */
int sense_r_mohm;
};
struct sc8551_stat_s
{
int part_no;
int revision;
int mode;
bool batt_present;
bool vbus_present;
bool usb_present;
bool charge_enabled; /* Register bit status */
/* ADC reading */
int vbat_volt;
int vbus_volt;
int vout_volt;
int vac_volt;
int ibat_curr;
int ibus_curr;
int bat_temp;
int bus_temp;
int die_temp;
/* alarm/fault status */
bool bat_ovp_fault;
bool bat_ocp_fault;
bool bus_ovp_fault;
bool bus_ocp_fault;
bool bat_ovp_alarm;
bool bat_ocp_alarm;
bool bus_ovp_alarm;
bool bus_ocp_alarm;
bool bat_ucp_alarm;
bool bat_therm_alarm;
bool bus_therm_alarm;
bool die_therm_alarm;
bool bat_therm_fault;
bool bus_therm_fault;
bool die_therm_fault;
bool therm_shutdown_flag;
bool therm_shutdown_stat;
bool vbat_reg;
bool ibat_reg;
int prev_alarm;
int prev_fault;
int chg_ma;
int chg_mv;
int charge_state;
};
typedef enum
{
ADC_IBUS,
ADC_VBUS,
ADC_VAC,
ADC_VOUT,
ADC_VBAT,
ADC_IBAT,
ADC_TBUS,
ADC_TBAT,
ADC_TDIE,
ADC_MAX_NUM,
}ADC_CH;
#endif
File diff suppressed because it is too large Load Diff