linux/drivers/power/supply/max1720x_battery.c

// SPDX-License-Identifier: GPL-2.0+
/*
 * Fuel gauge driver for Maxim 17201/17205
 *
 * based on max1721x_battery.c
 *
 * Copyright (C) 2024 Liebherr-Electronics and Drives GmbH
 */

#include <linux/bitfield.h>
#include <linux/i2c.h>
#include <linux/module.h>
#include <linux/power_supply.h>
#include <linux/regmap.h>

#include <asm/unaligned.h>

/* Nonvolatile registers */
#define MAX1720X_NRSENSE

/* ModelGauge m5 */
#define MAX172XX_STATUS
#define MAX172XX_STATUS_BAT_ABSENT
#define MAX172XX_REPCAP
#define MAX172XX_REPSOC
#define MAX172XX_TEMP
#define MAX172XX_CURRENT
#define MAX172XX_AVG_CURRENT
#define MAX172XX_TTE
#define MAX172XX_AVG_TA
#define MAX172XX_CYCLES
#define MAX172XX_DESIGN_CAP
#define MAX172XX_AVG_VCELL
#define MAX172XX_TTF
#define MAX172XX_DEV_NAME
#define MAX172XX_DEV_NAME_TYPE_MASK
#define MAX172XX_DEV_NAME_TYPE_MAX17201
#define MAX172XX_DEV_NAME_TYPE_MAX17205
#define MAX172XX_QR_TABLE10
#define MAX172XX_BATT
#define MAX172XX_ATAVCAP

static const char *const max1720x_manufacturer =;
static const char *const max17201_model =;
static const char *const max17205_model =;

struct max1720x_device_info {};

/*
 * Model Gauge M5 Algorithm output register
 * Volatile data (must not be cached)
 */
static const struct regmap_range max1720x_volatile_allow[] =;

static const struct regmap_range max1720x_readable_allow[] =;

static const struct regmap_range max1720x_readable_deny[] =;

static const struct regmap_access_table max1720x_readable_regs =;

static const struct regmap_access_table max1720x_volatile_regs =;

static const struct regmap_config max1720x_regmap_cfg =;

static const enum power_supply_property max1720x_battery_props[] =;

/* Convert regs value to power_supply units */

static int max172xx_time_to_ps(unsigned int reg)
{}

static int max172xx_percent_to_ps(unsigned int reg)
{}

static int max172xx_voltage_to_ps(unsigned int reg)
{}

static int max172xx_capacity_to_ps(unsigned int reg)
{}

/*
 * Current and temperature is signed values, so unsigned regs
 * value must be converted to signed type
 */

static int max172xx_temperature_to_ps(unsigned int reg)
{}

/*
 * Calculating current registers resolution:
 *
 * RSense stored in 10^-5 Ohm, so mesaurment voltage must be
 * in 10^-11 Volts for get current in uA.
 * 16 bit current reg fullscale +/-51.2mV is 102400 uV.
 * So: 102400 / 65535 * 10^5 = 156252
 */
static int max172xx_current_to_voltage(unsigned int reg)
{}

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

static int max1720x_probe_sense_resistor(struct i2c_client *client,
					 struct max1720x_device_info *info)
{}

static const struct power_supply_desc max1720x_bat_desc =;

static int max1720x_probe(struct i2c_client *client)
{}

static const struct of_device_id max1720x_of_match[] =;
MODULE_DEVICE_TABLE(of, max1720x_of_match);

static struct i2c_driver max1720x_i2c_driver =;
module_i2c_driver();

MODULE_LICENSE();
MODULE_AUTHOR();
MODULE_DESCRIPTION();