linux/drivers/power/supply/max77976_charger.c

// SPDX-License-Identifier: GPL-2.0+
/*
 * max77976_charger.c - Driver for the Maxim MAX77976 battery charger
 *
 * Copyright (C) 2021 Luca Ceresoli
 * Author: Luca Ceresoli <[email protected]>
 */

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

#define MAX77976_DRIVER_NAME
#define MAX77976_CHIP_ID

static const char *max77976_manufacturer	=;
static const char *max77976_model		=;

/* --------------------------------------------------------------------------
 * Register map
 */

#define MAX77976_REG_CHIP_ID
#define MAX77976_REG_CHIP_REVISION
#define MAX77976_REG_CHG_INT_OK
#define MAX77976_REG_CHG_DETAILS_01
#define MAX77976_REG_CHG_CNFG_00
#define MAX77976_REG_CHG_CNFG_02
#define MAX77976_REG_CHG_CNFG_06
#define MAX77976_REG_CHG_CNFG_09

/* CHG_DETAILS_01.CHG_DTLS values */
enum max77976_charging_state {};

/* CHG_DETAILS_01.BAT_DTLS values */
enum max77976_battery_state {};

/* CHG_CNFG_00.MODE values */
enum max77976_mode {};

/* CHG_CNFG_02.CHG_CC: charge current limit, 100..5500 mA, 50 mA steps */
#define MAX77976_CHG_CC_STEP
#define MAX77976_CHG_CC_MIN
#define MAX77976_CHG_CC_MAX

/* CHG_CNFG_09.CHGIN_ILIM: input current limit, 100..3200 mA, 100 mA steps */
#define MAX77976_CHGIN_ILIM_STEP
#define MAX77976_CHGIN_ILIM_MIN
#define MAX77976_CHGIN_ILIM_MAX

enum max77976_field_idx {};

static const struct reg_field max77976_reg_field[MAX77976_N_REGMAP_FIELDS] =;

static const struct regmap_config max77976_regmap_config =;

/* --------------------------------------------------------------------------
 * Data structures
 */

struct max77976 {};

/* --------------------------------------------------------------------------
 * power_supply properties
 */

static int max77976_get_status(struct max77976 *chg, int *val)
{}

static int max77976_get_charge_type(struct max77976 *chg, int *val)
{}

static int max77976_get_health(struct max77976 *chg, int *val)
{}

static int max77976_get_online(struct max77976 *chg, int *val)
{}

static int max77976_get_integer(struct max77976 *chg, enum max77976_field_idx fidx,
				unsigned int clamp_min, unsigned int clamp_max,
				unsigned int mult, int *val)
{}

static int max77976_set_integer(struct max77976 *chg, enum max77976_field_idx fidx,
				unsigned int clamp_min, unsigned int clamp_max,
				unsigned int div, int val)
{}

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

static int max77976_set_property(struct power_supply *psy,
				 enum power_supply_property psp,
				 const union power_supply_propval *val)
{
	struct max77976 *chg = power_supply_get_drvdata(psy);
	int err = 0;

	switch (psp) {
	case POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT:
		err = max77976_set_integer(chg, CHG_CC,
					   MAX77976_CHG_CC_MIN,
					   MAX77976_CHG_CC_MAX,
					   MAX77976_CHG_CC_STEP,
					   val->intval);
		break;
	case POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT:
		err = max77976_set_integer(chg, CHGIN_ILIM,
					   MAX77976_CHGIN_ILIM_MIN,
					   MAX77976_CHGIN_ILIM_MAX,
					   MAX77976_CHGIN_ILIM_STEP,
					   val->intval);
		break;
	default:
		err = -EINVAL;
	}

	return err;
};

static int max77976_property_is_writeable(struct power_supply *psy,
					  enum power_supply_property psp)
{}

static enum power_supply_property max77976_psy_props[] =;

static const struct power_supply_desc max77976_psy_desc =;

/* --------------------------------------------------------------------------
 * Entry point
 */

static int max77976_detect(struct max77976 *chg)
{}

static int max77976_configure(struct max77976 *chg)
{}

static int max77976_probe(struct i2c_client *client)
{}

static const struct i2c_device_id max77976_i2c_id[] =;
MODULE_DEVICE_TABLE(i2c, max77976_i2c_id);

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

static struct i2c_driver max77976_driver =;
module_i2c_driver();

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