2019-05-27 06:55:01 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
2010-12-14 06:00:54 +00:00
|
|
|
/*
|
|
|
|
* mc13xxx.h - regulators for the Freescale mc13xxx PMIC
|
|
|
|
*
|
|
|
|
* Copyright (C) 2010 Yong Shen <yong.shen@linaro.org>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __LINUX_REGULATOR_MC13XXX_H
|
|
|
|
#define __LINUX_REGULATOR_MC13XXX_H
|
|
|
|
|
|
|
|
#include <linux/regulator/driver.h>
|
|
|
|
|
|
|
|
struct mc13xxx_regulator {
|
|
|
|
struct regulator_desc desc;
|
|
|
|
int reg;
|
|
|
|
int enable_bit;
|
|
|
|
int vsel_reg;
|
|
|
|
int vsel_shift;
|
|
|
|
int vsel_mask;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct mc13xxx_regulator_priv {
|
|
|
|
struct mc13xxx *mc13xxx;
|
|
|
|
u32 powermisc_pwgt_state;
|
|
|
|
struct mc13xxx_regulator *mc13xxx_regulators;
|
2011-12-21 15:00:46 +00:00
|
|
|
int num_regulators;
|
2023-09-22 17:54:02 +00:00
|
|
|
struct regulator_dev *regulators[] __counted_by(num_regulators);
|
2010-12-14 06:00:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
extern int mc13xxx_fixed_regulator_set_voltage(struct regulator_dev *rdev,
|
|
|
|
int min_uV, int max_uV, unsigned *selector);
|
|
|
|
|
2011-12-21 15:00:46 +00:00
|
|
|
#ifdef CONFIG_OF
|
|
|
|
extern int mc13xxx_get_num_regulators_dt(struct platform_device *pdev);
|
|
|
|
extern struct mc13xxx_regulator_init_data *mc13xxx_parse_regulators_dt(
|
|
|
|
struct platform_device *pdev, struct mc13xxx_regulator *regulators,
|
2013-04-27 06:29:24 +00:00
|
|
|
int num_regulators);
|
2011-12-21 15:00:46 +00:00
|
|
|
#else
|
|
|
|
static inline int mc13xxx_get_num_regulators_dt(struct platform_device *pdev)
|
|
|
|
{
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline struct mc13xxx_regulator_init_data *mc13xxx_parse_regulators_dt(
|
|
|
|
struct platform_device *pdev, struct mc13xxx_regulator *regulators,
|
2013-04-27 06:29:24 +00:00
|
|
|
int num_regulators)
|
2011-12-21 15:00:46 +00:00
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2019-03-01 14:20:53 +00:00
|
|
|
extern const struct regulator_ops mc13xxx_regulator_ops;
|
|
|
|
extern const struct regulator_ops mc13xxx_fixed_regulator_ops;
|
2010-12-14 06:00:54 +00:00
|
|
|
|
2019-01-25 15:37:04 +00:00
|
|
|
#define MC13xxx_DEFINE(prefix, _name, _node, _reg, _vsel_reg, _voltages, _ops) \
|
2010-12-14 06:00:54 +00:00
|
|
|
[prefix ## _name] = { \
|
|
|
|
.desc = { \
|
2019-01-25 15:37:04 +00:00
|
|
|
.name = #_node, \
|
2010-12-14 06:00:54 +00:00
|
|
|
.n_voltages = ARRAY_SIZE(_voltages), \
|
2012-06-08 07:41:48 +00:00
|
|
|
.volt_table = _voltages, \
|
2010-12-14 06:00:54 +00:00
|
|
|
.ops = &_ops, \
|
|
|
|
.type = REGULATOR_VOLTAGE, \
|
|
|
|
.id = prefix ## _name, \
|
|
|
|
.owner = THIS_MODULE, \
|
|
|
|
}, \
|
|
|
|
.reg = prefix ## _reg, \
|
|
|
|
.enable_bit = prefix ## _reg ## _ ## _name ## EN, \
|
|
|
|
.vsel_reg = prefix ## _vsel_reg, \
|
|
|
|
.vsel_shift = prefix ## _vsel_reg ## _ ## _name ## VSEL,\
|
|
|
|
.vsel_mask = prefix ## _vsel_reg ## _ ## _name ## VSEL_M,\
|
|
|
|
}
|
|
|
|
|
2019-01-25 15:37:04 +00:00
|
|
|
#define MC13xxx_FIXED_DEFINE(prefix, _name, _node, _reg, _voltages, _ops) \
|
2010-12-14 06:00:54 +00:00
|
|
|
[prefix ## _name] = { \
|
|
|
|
.desc = { \
|
2019-01-25 15:37:04 +00:00
|
|
|
.name = #_node, \
|
2010-12-14 06:00:54 +00:00
|
|
|
.n_voltages = ARRAY_SIZE(_voltages), \
|
2012-06-08 07:41:48 +00:00
|
|
|
.volt_table = _voltages, \
|
2010-12-14 06:00:54 +00:00
|
|
|
.ops = &_ops, \
|
|
|
|
.type = REGULATOR_VOLTAGE, \
|
|
|
|
.id = prefix ## _name, \
|
|
|
|
.owner = THIS_MODULE, \
|
|
|
|
}, \
|
|
|
|
.reg = prefix ## _reg, \
|
|
|
|
.enable_bit = prefix ## _reg ## _ ## _name ## EN, \
|
|
|
|
}
|
|
|
|
|
2019-01-25 15:37:04 +00:00
|
|
|
#define MC13xxx_GPO_DEFINE(prefix, _name, _node, _reg, _voltages, _ops) \
|
2010-12-14 06:00:54 +00:00
|
|
|
[prefix ## _name] = { \
|
|
|
|
.desc = { \
|
2019-01-25 15:37:04 +00:00
|
|
|
.name = #_node, \
|
2010-12-14 06:00:54 +00:00
|
|
|
.n_voltages = ARRAY_SIZE(_voltages), \
|
2012-06-08 07:41:48 +00:00
|
|
|
.volt_table = _voltages, \
|
2010-12-14 06:00:54 +00:00
|
|
|
.ops = &_ops, \
|
|
|
|
.type = REGULATOR_VOLTAGE, \
|
|
|
|
.id = prefix ## _name, \
|
|
|
|
.owner = THIS_MODULE, \
|
|
|
|
}, \
|
|
|
|
.reg = prefix ## _reg, \
|
|
|
|
.enable_bit = prefix ## _reg ## _ ## _name ## EN, \
|
|
|
|
}
|
|
|
|
|
2019-01-25 15:37:04 +00:00
|
|
|
#define MC13xxx_DEFINE_SW(_name, _node, _reg, _vsel_reg, _voltages, ops) \
|
|
|
|
MC13xxx_DEFINE(SW, _name, _node, _reg, _vsel_reg, _voltages, ops)
|
|
|
|
#define MC13xxx_DEFINE_REGU(_name, _node, _reg, _vsel_reg, _voltages, ops) \
|
|
|
|
MC13xxx_DEFINE(REGU, _name, _node, _reg, _vsel_reg, _voltages, ops)
|
2010-12-14 06:00:54 +00:00
|
|
|
|
|
|
|
#endif
|