linux/drivers/power/supply/bd99954-charger.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * ROHM BD99954 charger driver
 *
 * Copyright (C) 2020 Rohm Semiconductors
 *	Originally written by:
 *		Mikko Mutanen <[email protected]>
 *		Markus Laine <[email protected]>
 *	Bugs added by:
 *		Matti Vaittinen <[email protected]>
 */

/*
 *   The battery charging profile of BD99954.
 *
 *   Curve (1) represents charging current.
 *   Curve (2) represents battery voltage.
 *
 *   The BD99954 data sheet divides charging to three phases.
 *   a) Trickle-charge with constant current (8).
 *   b) pre-charge with constant current (6)
 *   c) fast-charge, first with constant current (5) phase. After
 *      the battery voltage has reached target level (4) we have constant
 *      voltage phase until charging current has dropped to termination
 *      level (7)
 *
 *    V ^                                                        ^ I
 *      .                                                        .
 *      .                                                        .
 *(4)` `.` ` ` ` ` ` ` ` ` ` ` ` ` ` ----------------------------.
 *      .                           :/                           .
 *      .                     o----+/:/ ` ` ` ` ` ` ` ` ` ` ` ` `.` ` (5)
 *      .                     +   ::  +                          .
 *      .                     +  /-   --                         .
 *      .                     +`/-     +                         .
 *      .                     o/-      -:                        .
 *      .                    .s.        +`                       .
 *      .                  .--+         `/                       .
 *      .               ..``  +          .:                      .
 *      .             -`      +           --                     .
 *      .    (2)  ...``       +            :-                    .
 *      .    ...``            +             -:                   .
 *(3)` `.`.""  ` ` ` `+-------- ` ` ` ` ` ` `.:` ` ` ` ` ` ` ` ` .` ` (6)
 *      .             +                       `:.                .
 *      .             +                         -:               .
 *      .             +                           -:.            .
 *      .             +                             .--.         .
 *      .   (1)       +                                `.+` ` ` `.` ` (7)
 *      -..............` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` + ` ` ` .` ` (8)
 *      .                                                +       -
 *      -------------------------------------------------+++++++++-->
 *      |   trickle   |  pre  |          fast            |
 *
 * Details of DT properties for different limits can be found from BD99954
 * device tree binding documentation.
 */

#include <linux/delay.h>
#include <linux/gpio/consumer.h>
#include <linux/interrupt.h>
#include <linux/i2c.h>
#include <linux/kernel.h>
#include <linux/linear_range.h>
#include <linux/module.h>
#include <linux/mod_devicetable.h>
#include <linux/power_supply.h>
#include <linux/property.h>
#include <linux/regmap.h>
#include <linux/types.h>

#include "bd99954-charger.h"

/* Initial field values, converted to initial register values */
struct bd9995x_init_data {};

struct bd9995x_state {};

struct bd9995x_device {};

static const struct regmap_range bd9995x_readonly_reg_ranges[] =;

static const struct regmap_access_table bd9995x_writeable_regs =;

static const struct regmap_range bd9995x_volatile_reg_ranges[] =;

static const struct regmap_access_table bd9995x_volatile_regs =;

static const struct regmap_range_cfg regmap_range_cfg[] =;

static const struct regmap_config bd9995x_regmap_config =;

enum bd9995x_chrg_fault {};

static int bd9995x_get_prop_batt_health(struct bd9995x_device *bd)
{}

static int bd9995x_get_prop_charge_type(struct bd9995x_device *bd)
{}

static bool bd9995x_get_prop_batt_present(struct bd9995x_device *bd)
{}

static int bd9995x_get_prop_batt_voltage(struct bd9995x_device *bd)
{}

static int bd9995x_get_prop_batt_current(struct bd9995x_device *bd)
{}

#define DEFAULT_BATTERY_TEMPERATURE

static int bd9995x_get_prop_batt_temp(struct bd9995x_device *bd)
{}

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

static int bd9995x_get_chip_state(struct bd9995x_device *bd,
				  struct bd9995x_state *state)
{}

static irqreturn_t bd9995x_irq_handler_thread(int irq, void *private)
{}

static int __bd9995x_chip_reset(struct bd9995x_device *bd)
{}

static int bd9995x_hw_init(struct bd9995x_device *bd)
{}

static enum power_supply_property bd9995x_power_supply_props[] =;

static const struct power_supply_desc bd9995x_power_supply_desc =;

/*
 * Limit configurations for vbus-input-current and vcc-vacp-input-current
 * Minimum limit is 0 uA. Max is 511 * 32000 uA = 16352000 uA. This is
 * configured by writing a register so that each increment in register
 * value equals to 32000 uA limit increment.
 *
 * Eg, value 0x0 is limit 0, value 0x1 is limit 32000, ...
 * Describe the setting in linear_range table.
 */
static const struct linear_range input_current_limit_ranges[] =;

/* Possible trickle, pre-charging and termination current values */
static const struct linear_range charging_current_ranges[] =;

/*
 * Fast charging voltage regulation, starting re-charging limit
 * and battery over voltage protection have same possible values
 */
static const struct linear_range charge_voltage_regulation_ranges[] =;

/* Possible VSYS voltage regulation values */
static const struct linear_range vsys_voltage_regulation_ranges[] =;

/* Possible settings for switching from trickle to pre-charging limits */
static const struct linear_range trickle_to_pre_threshold_ranges[] =;

/* Possible current values for fast-charging constant current phase */
static const struct linear_range fast_charge_current_ranges[] =;

struct battery_init {};

struct dt_init {};

static int bd9995x_fw_probe(struct bd9995x_device *bd)
{}

static void bd9995x_chip_reset(void *bd)
{}

static int bd9995x_probe(struct i2c_client *client)
{}

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

static struct i2c_driver bd9995x_driver =;
module_i2c_driver();

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