linux/drivers/power/supply/88pm860x_battery.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * Battery driver for Marvell 88PM860x PMIC
 *
 * Copyright (c) 2012 Marvell International Ltd.
 * Author:	Jett Zhou <[email protected]>
 *		Haojian Zhuang <[email protected]>
 */

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/slab.h>
#include <linux/mutex.h>
#include <linux/string.h>
#include <linux/power_supply.h>
#include <linux/mfd/88pm860x.h>
#include <linux/delay.h>

/* bit definitions of Status Query Interface 2 */
#define STATUS2_CHG
#define STATUS2_BAT
#define STATUS2_VBUS

/* bit definitions of Measurement Enable 1 Register */
#define MEAS1_TINT
#define MEAS1_GP1

/* bit definitions of Measurement Enable 3 Register */
#define MEAS3_IBAT
#define MEAS3_BAT_DET
#define MEAS3_CC

/* bit definitions of Measurement Off Time Register */
#define MEAS_OFF_SLEEP_EN

/* bit definitions of GPADC Bias Current 2 Register */
#define GPBIAS2_GPADC1_SET
/* GPADC1 Bias Current value in uA unit */
#define GPBIAS2_GPADC1_UA

/* bit definitions of GPADC Misc 1 Register */
#define GPMISC1_GPADC_EN

/* bit definitions of Charger Control 6 Register */
#define CC6_BAT_DET_GPADC1

/* bit definitions of Coulomb Counter Reading Register */
#define CCNT_AVG_SEL

/* bit definitions of RTC miscellaneous Register1 */
#define RTC_SOC_5LSB

/* bit definitions of RTC Register1 */
#define RTC_SOC_3MSB

/* bit definitions of Power up Log register */
#define BAT_WU_LOG

/* coulomb counter index */
#define CCNT_POS1
#define CCNT_POS2
#define CCNT_NEG1
#define CCNT_NEG2
#define CCNT_SPOS
#define CCNT_SNEG

/* OCV -- Open Circuit Voltage */
#define OCV_MODE_ACTIVE
#define OCV_MODE_SLEEP

/* Vbat range of CC for measuring Rbat */
#define LOW_BAT_THRESHOLD
#define VBATT_RESISTOR_MIN
#define VBATT_RESISTOR_MAX

/* TBAT for batt, TINT for chip itself */
#define PM860X_TEMP_TINT
#define PM860X_TEMP_TBAT

/*
 * Battery temperature based on NTC resistor, defined
 * corresponding resistor value  -- Ohm / C degeree.
 */
#define TBAT_NEG_25D
#define TBAT_NEG_10D
#define TBAT_0D
#define TBAT_10D
#define TBAT_20D
#define TBAT_30D
#define TBAT_40D

struct pm860x_battery_info {};

struct ccnt {};

/*
 * State of Charge.
 * The first number is mAh(=3.6C), and the second number is percent point.
 */
static int array_soc[][2] =;

static struct ccnt ccnt_data;

/*
 * register 1 bit[7:0] -- bit[11:4] of measured value of voltage
 * register 0 bit[3:0] -- bit[3:0] of measured value of voltage
 */
static int measure_12bit_voltage(struct pm860x_battery_info *info,
				 int offset, int *data)
{}

static int measure_vbatt(struct pm860x_battery_info *info, int state,
			 int *data)
{}

/*
 * Return value is signed data.
 * Negative value means discharging, and positive value means charging.
 */
static int measure_current(struct pm860x_battery_info *info, int *data)
{}

static int set_charger_current(struct pm860x_battery_info *info, int data,
			       int *old)
{}

static int read_ccnt(struct pm860x_battery_info *info, int offset,
		     int *ccnt)
{}

static int calc_ccnt(struct pm860x_battery_info *info, struct ccnt *ccnt)
{}

static int clear_ccnt(struct pm860x_battery_info *info, struct ccnt *ccnt)
{}

/* Calculate Open Circuit Voltage */
static int calc_ocv(struct pm860x_battery_info *info, int *ocv)
{}

/* Calculate State of Charge (percent points) */
static int calc_soc(struct pm860x_battery_info *info, int state, int *soc)
{}

static irqreturn_t pm860x_coulomb_handler(int irq, void *data)
{}

static irqreturn_t pm860x_batt_handler(int irq, void *data)
{}

static void pm860x_init_battery(struct pm860x_battery_info *info)
{}

static void set_temp_threshold(struct pm860x_battery_info *info,
			       int min, int max)
{}

static int measure_temp(struct pm860x_battery_info *info, int *data)
{}

static int calc_resistor(struct pm860x_battery_info *info)
{}

static int calc_capacity(struct pm860x_battery_info *info, int *cap)
{}

static void pm860x_external_power_changed(struct power_supply *psy)
{}

static int pm860x_batt_get_prop(struct power_supply *psy,
				enum power_supply_property psp,
				union power_supply_propval *val)
{}

static int pm860x_batt_set_prop(struct power_supply *psy,
				       enum power_supply_property psp,
				       const union power_supply_propval *val)
{}


static enum power_supply_property pm860x_batt_props[] =;

static const struct power_supply_desc pm860x_battery_desc =;

static int pm860x_battery_probe(struct platform_device *pdev)
{}

#ifdef CONFIG_PM_SLEEP
static int pm860x_battery_suspend(struct device *dev)
{}

static int pm860x_battery_resume(struct device *dev)
{}
#endif

static SIMPLE_DEV_PM_OPS(pm860x_battery_pm_ops,
			pm860x_battery_suspend, pm860x_battery_resume);

static struct platform_driver pm860x_battery_driver =;
module_platform_driver();

MODULE_DESCRIPTION();
MODULE_LICENSE();