linux/drivers/power/supply/ucs1002_power.c

// SPDX-License-Identifier: GPL-2.0+
/*
 * Driver for UCS1002 Programmable USB Port Power Controller
 *
 * Copyright (C) 2019 Zodiac Inflight Innovations
 */
#include <linux/bits.h>
#include <linux/freezer.h>
#include <linux/gpio/consumer.h>
#include <linux/i2c.h>
#include <linux/interrupt.h>
#include <linux/kernel.h>
#include <linux/kthread.h>
#include <linux/device.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_irq.h>
#include <linux/power_supply.h>
#include <linux/regmap.h>
#include <linux/regulator/driver.h>
#include <linux/regulator/of_regulator.h>

/* UCS1002 Registers */
#define UCS1002_REG_CURRENT_MEASUREMENT

/*
 * The Total Accumulated Charge registers store the total accumulated
 * charge delivered from the VS source to a portable device. The total
 * value is calculated using four registers, from 01h to 04h. The bit
 * weighting of the registers is given in mA/hrs.
 */
#define UCS1002_REG_TOTAL_ACC_CHARGE

/* Other Status Register */
#define UCS1002_REG_OTHER_STATUS
#define F_ADET_PIN
#define F_CHG_ACT

/* Interrupt Status */
#define UCS1002_REG_INTERRUPT_STATUS
#define F_ERR
#define F_DISCHARGE_ERR
#define F_RESET
#define F_MIN_KEEP_OUT
#define F_TSD
#define F_OVER_VOLT
#define F_BACK_VOLT
#define F_OVER_ILIM

/* Pin Status Register */
#define UCS1002_REG_PIN_STATUS
#define UCS1002_PWR_STATE_MASK
#define F_PWR_EN_PIN
#define F_M2_PIN
#define F_M1_PIN
#define F_EM_EN_PIN
#define F_SEL_PIN
#define F_ACTIVE_MODE_MASK
#define F_ACTIVE_MODE_PASSTHROUGH
#define F_ACTIVE_MODE_DEDICATED
#define F_ACTIVE_MODE_BC12_DCP
#define F_ACTIVE_MODE_BC12_SDP
#define F_ACTIVE_MODE_BC12_CDP

/* General Configuration Register */
#define UCS1002_REG_GENERAL_CFG
#define F_RATION_EN

/* Emulation Configuration Register */
#define UCS1002_REG_EMU_CFG

/* Switch Configuration Register */
#define UCS1002_REG_SWITCH_CFG
#define F_PIN_IGNORE
#define F_EM_EN_SET
#define F_M2_SET
#define F_M1_SET
#define F_S0_SET
#define F_PWR_EN_SET
#define F_LATCH_SET
#define V_SET_ACTIVE_MODE_MASK
#define V_SET_ACTIVE_MODE_PASSTHROUGH
#define V_SET_ACTIVE_MODE_DEDICATED
#define V_SET_ACTIVE_MODE_BC12_DCP
#define V_SET_ACTIVE_MODE_BC12_SDP
#define V_SET_ACTIVE_MODE_BC12_CDP

/* Current Limit Register */
#define UCS1002_REG_ILIMIT
#define UCS1002_ILIM_SW_MASK

/* Product ID */
#define UCS1002_REG_PRODUCT_ID
#define UCS1002_PRODUCT_ID

/* Manufacture name */
#define UCS1002_MANUFACTURER

struct ucs1002_info {};

static enum power_supply_property ucs1002_props[] =;

static int ucs1002_get_online(struct ucs1002_info *info,
			      union power_supply_propval *val)
{}

static int ucs1002_get_charge(struct ucs1002_info *info,
			      union power_supply_propval *val)
{}

static int ucs1002_get_current(struct ucs1002_info *info,
			       union power_supply_propval *val)
{}

/*
 * The Current Limit register stores the maximum current used by the
 * port switch. The range is from 500mA to 2.5 A.
 */
static const u32 ucs1002_current_limit_uA[] =;

static int ucs1002_get_max_current(struct ucs1002_info *info,
				   union power_supply_propval *val)
{}

static int ucs1002_set_max_current(struct ucs1002_info *info, u32 val)
{}

static enum power_supply_usb_type ucs1002_usb_types[] =;

static int ucs1002_set_usb_type(struct ucs1002_info *info, int val)
{}

static int ucs1002_get_usb_type(struct ucs1002_info *info,
				union power_supply_propval *val)
{}

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

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

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

static const struct power_supply_desc ucs1002_charger_desc =;

static void ucs1002_health_poll(struct work_struct *work)
{}

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

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

static int ucs1002_regulator_enable(struct regulator_dev *rdev)
{}

static const struct regulator_ops ucs1002_regulator_ops =;

static const struct regulator_desc ucs1002_regulator_descriptor =;

static int ucs1002_probe(struct i2c_client *client)
{}

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

static struct i2c_driver ucs1002_driver =;
module_i2c_driver();

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