linux/drivers/power/supply/max1721x_battery.c

/*
 * 1-Wire implementation for Maxim Semiconductor
 * MAX7211/MAX17215 standalone fuel gauge chip
 *
 * Copyright (C) 2017 Radioavionica Corporation
 * Author: Alex A. Mihaylov <[email protected]>
 *
 * Use consistent with the GNU GPL is permitted,
 * provided that this copyright notice is
 * preserved in its entirety in all copies and derived works.
 *
 */

#include <linux/module.h>
#include <linux/slab.h>
#include <linux/w1.h>
#include <linux/regmap.h>
#include <linux/power_supply.h>

#define W1_MAX1721X_FAMILY_ID
#define DEF_DEV_NAME_MAX17211
#define DEF_DEV_NAME_MAX17215
#define DEF_DEV_NAME_UNKNOWN
#define DEF_MFG_NAME

#define PSY_MAX_NAME_LEN

/* Number of valid register addresses in W1 mode */
#define MAX1721X_MAX_REG_NR

/* Factory settings (nonvolatile registers) (W1 specific) */
#define MAX1721X_REG_NRSENSE
/* Strings */
#define MAX1721X_REG_MFG_STR
#define MAX1721X_REG_MFG_NUMB
#define MAX1721X_REG_DEV_STR
#define MAX1721X_REG_DEV_NUMB
/* HEX Strings */
#define MAX1721X_REG_SER_HEX

/* MAX172XX Output Registers for W1 chips */
#define MAX172XX_REG_STATUS
#define MAX172XX_BAT_PRESENT
#define MAX172XX_REG_DEVNAME
#define MAX172XX_DEV_MASK
#define MAX172X1_DEV
#define MAX172X5_DEV
#define MAX172XX_REG_TEMP
#define MAX172XX_REG_BATT
#define MAX172XX_REG_CURRENT
#define MAX172XX_REG_AVGCURRENT
#define MAX172XX_REG_REPSOC
#define MAX172XX_REG_DESIGNCAP
#define MAX172XX_REG_REPCAP
#define MAX172XX_REG_TTE
#define MAX172XX_REG_TTF

struct max17211_device_info {};

/* Convert regs value to power_supply units */

static inline int max172xx_time_to_ps(unsigned int reg)
{}

static inline int max172xx_percent_to_ps(unsigned int reg)
{}

static inline int max172xx_voltage_to_ps(unsigned int reg)
{}

static inline 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 inline int max172xx_temperature_to_ps(unsigned int reg)
{}

/*
 * Calculating current registers resolution:
 *
 * RSense stored in 10^-5 Ohm, so measurement 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 inline int max172xx_current_to_voltage(unsigned int reg)
{}


static inline struct max17211_device_info *
to_device_info(struct power_supply *psy)
{}

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

static enum power_supply_property max1721x_battery_props[] =;

static int get_string(struct max17211_device_info *info,
			uint16_t reg, uint8_t nr, char *str)
{}

/* Maxim say: Serial number is a hex string up to 12 hex characters */
static int get_sn_string(struct max17211_device_info *info, char *str)
{}

/*
 * MAX1721x registers description for w1-regmap
 */
static const struct regmap_range max1721x_allow_range[] =;

static const struct regmap_range max1721x_deny_range[] =;

static const struct regmap_access_table max1721x_regs =;

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

static const struct regmap_access_table max1721x_volatile_regs =;

/*
 * W1-regmap config
 */
static const struct regmap_config max1721x_regmap_w1_config =;

static int devm_w1_max1721x_add_device(struct w1_slave *sl)
{}

static const struct w1_family_ops w1_max1721x_fops =;

static struct w1_family w1_max1721x_family =;

module_w1_family();

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