linux/drivers/regulator/hi6421-regulator.c

// SPDX-License-Identifier: GPL-2.0
//
// Device driver for regulators in Hi6421 IC
//
// Copyright (c) <2011-2014> HiSilicon Technologies Co., Ltd.
//              http://www.hisilicon.com
// Copyright (c) <2013-2014> Linaro Ltd.
//              https://www.linaro.org
//
// Author: Guodong Xu <[email protected]>

#include <linux/slab.h>
#include <linux/device.h>
#include <linux/module.h>
#include <linux/err.h>
#include <linux/platform_device.h>
#include <linux/of.h>
#include <linux/regmap.h>
#include <linux/regulator/driver.h>
#include <linux/regulator/machine.h>
#include <linux/regulator/of_regulator.h>
#include <linux/mfd/hi6421-pmic.h>

/*
 * struct hi6421_regulator_pdata - Hi6421 regulator data of platform device
 * @lock: mutex to serialize regulator enable
 */
struct hi6421_regulator_pdata {};

/*
 * struct hi6421_regulator_info - hi6421 regulator information
 * @desc: regulator description
 * @mode_mask: ECO mode bitmask of LDOs; for BUCKs, this masks sleep
 * @eco_microamp: eco mode load upper limit (in uA), valid for LDOs only
 */
struct hi6421_regulator_info {};

/* HI6421 regulators */
enum hi6421_regulator_id {};

/* LDO 0, 4~7, 9~14, 16~20 have same voltage table. */
static const unsigned int ldo_0_voltages[] =;

/* LDO 8, 15 have same voltage table. */
static const unsigned int ldo_8_voltages[] =;

/* Ranges are sorted in ascending order. */
static const struct linear_range ldo_audio_volt_range[] =;

static const unsigned int buck_3_voltages[] =;

static const unsigned int buck_4_voltages[] =;

static const unsigned int buck_5_voltages[] =;

static const struct regulator_ops hi6421_ldo_ops;
static const struct regulator_ops hi6421_ldo_linear_ops;
static const struct regulator_ops hi6421_ldo_linear_range_ops;
static const struct regulator_ops hi6421_buck012_ops;
static const struct regulator_ops hi6421_buck345_ops;

#define HI6421_LDO_ENABLE_TIME
/*
 * _id - LDO id name string
 * _match - of match name string
 * v_table - voltage table
 * vreg - voltage select register
 * vmask - voltage select mask
 * ereg - enable register
 * emask - enable mask
 * odelay - off/on delay time in uS
 * ecomask - eco mode mask
 * ecoamp - eco mode load uppler limit in uA
 */
#define HI6421_LDO(_id, _match, v_table, vreg, vmask, ereg, emask,	\
		   odelay, ecomask, ecoamp)

/* HI6421 LDO1~3 are linear voltage regulators at fixed uV_step
 *
 * _id - LDO id name string
 * _match - of match name string
 * _min_uV - minimum voltage supported in uV
 * n_volt - number of votages available
 * vstep - voltage increase in each linear step in uV
 * vreg - voltage select register
 * vmask - voltage select mask
 * ereg - enable register
 * emask - enable mask
 * odelay - off/on delay time in uS
 * ecomask - eco mode mask
 * ecoamp - eco mode load uppler limit in uA
 */
#define HI6421_LDO_LINEAR(_id, _match, _min_uV, n_volt, vstep, vreg, vmask,\
			  ereg, emask, odelay, ecomask, ecoamp)

/* HI6421 LDOAUDIO is a linear voltage regulator with two 4-step ranges
 *
 * _id - LDO id name string
 * _match - of match name string
 * n_volt - number of votages available
 * volt_ranges - array of linear_range
 * vstep - voltage increase in each linear step in uV
 * vreg - voltage select register
 * vmask - voltage select mask
 * ereg - enable register
 * emask - enable mask
 * odelay - off/on delay time in uS
 * ecomask - eco mode mask
 * ecoamp - eco mode load uppler limit in uA
 */
#define HI6421_LDO_LINEAR_RANGE(_id, _match, n_volt, volt_ranges, vreg, vmask,\
				ereg, emask, odelay, ecomask, ecoamp)

/* HI6421 BUCK0/1/2 are linear voltage regulators at fixed uV_step
 *
 * _id - BUCK0/1/2 id name string
 * _match - of match name string
 * vreg - voltage select register
 * vmask - voltage select mask
 * ereg - enable register
 * emask - enable mask
 * sleepmask - mask of sleep mode
 * etime - enable time
 * odelay - off/on delay time in uS
 */
#define HI6421_BUCK012(_id, _match, vreg, vmask, ereg, emask, sleepmask,\
			etime, odelay)

/* HI6421 BUCK3/4/5 share similar configurations as LDOs, with exception
 *  that it supports SLEEP mode, so has different .ops.
 *
 * _id - LDO id name string
 * _match - of match name string
 * v_table - voltage table
 * vreg - voltage select register
 * vmask - voltage select mask
 * ereg - enable register
 * emask - enable mask
 * odelay - off/on delay time in uS
 * sleepmask - mask of sleep mode
 */
#define HI6421_BUCK345(_id, _match, v_table, vreg, vmask, ereg, emask,	\
			odelay, sleepmask)

/* HI6421 regulator information */
static struct hi6421_regulator_info
		hi6421_regulator_info[HI6421_NUM_REGULATORS] =;

static int hi6421_regulator_enable(struct regulator_dev *rdev)
{}

static unsigned int hi6421_regulator_ldo_get_mode(struct regulator_dev *rdev)
{}

static unsigned int hi6421_regulator_buck_get_mode(struct regulator_dev *rdev)
{}

static int hi6421_regulator_ldo_set_mode(struct regulator_dev *rdev,
						unsigned int mode)
{}

static int hi6421_regulator_buck_set_mode(struct regulator_dev *rdev,
						unsigned int mode)
{}

static unsigned int
hi6421_regulator_ldo_get_optimum_mode(struct regulator_dev *rdev,
			int input_uV, int output_uV, int load_uA)
{}

static const struct regulator_ops hi6421_ldo_ops =;

static const struct regulator_ops hi6421_ldo_linear_ops =;

static const struct regulator_ops hi6421_ldo_linear_range_ops =;

static const struct regulator_ops hi6421_buck012_ops =;

static const struct regulator_ops hi6421_buck345_ops =;

static int hi6421_regulator_probe(struct platform_device *pdev)
{}

static const struct platform_device_id hi6421_regulator_table[] =;
MODULE_DEVICE_TABLE(platform, hi6421_regulator_table);

static struct platform_driver hi6421_regulator_driver =;
module_platform_driver();

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