2019-05-27 13:55:01 +07:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
2010-12-14 13:00:54 +07: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 22:00:46 +07:00
|
|
|
int num_regulators;
|
2010-12-14 13:00:54 +07:00
|
|
|
struct regulator_dev *regulators[];
|
|
|
|
};
|
|
|
|
|
|
|
|
extern int mc13xxx_fixed_regulator_set_voltage(struct regulator_dev *rdev,
|
|
|
|
int min_uV, int max_uV, unsigned *selector);
|
|
|
|
|
2011-12-21 22:00:46 +07: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 13:29:24 +07:00
|
|
|
int num_regulators);
|
2011-12-21 22:00:46 +07: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 13:29:24 +07:00
|
|
|
int num_regulators)
|
2011-12-21 22:00:46 +07:00
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2019-03-01 21:20:53 +07:00
|
|
|
extern const struct regulator_ops mc13xxx_regulator_ops;
|
|
|
|
extern const struct regulator_ops mc13xxx_fixed_regulator_ops;
|
2010-12-14 13:00:54 +07:00
|
|
|
|
2019-01-25 22:37:04 +07:00
|
|
|
#define MC13xxx_DEFINE(prefix, _name, _node, _reg, _vsel_reg, _voltages, _ops) \
|
2010-12-14 13:00:54 +07:00
|
|
|
[prefix ## _name] = { \
|
|
|
|
.desc = { \
|
2019-01-25 22:37:04 +07:00
|
|
|
.name = #_node, \
|
2010-12-14 13:00:54 +07:00
|
|
|
.n_voltages = ARRAY_SIZE(_voltages), \
|
2012-06-08 14:41:48 +07:00
|
|
|
.volt_table = _voltages, \
|
2010-12-14 13:00:54 +07: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 22:37:04 +07:00
|
|
|
#define MC13xxx_FIXED_DEFINE(prefix, _name, _node, _reg, _voltages, _ops) \
|
2010-12-14 13:00:54 +07:00
|
|
|
[prefix ## _name] = { \
|
|
|
|
.desc = { \
|
2019-01-25 22:37:04 +07:00
|
|
|
.name = #_node, \
|
2010-12-14 13:00:54 +07:00
|
|
|
.n_voltages = ARRAY_SIZE(_voltages), \
|
2012-06-08 14:41:48 +07:00
|
|
|
.volt_table = _voltages, \
|
2010-12-14 13:00:54 +07:00
|
|
|
.ops = &_ops, \
|
|
|
|
.type = REGULATOR_VOLTAGE, \
|
|
|
|
.id = prefix ## _name, \
|
|
|
|
.owner = THIS_MODULE, \
|
|
|
|
}, \
|
|
|
|
.reg = prefix ## _reg, \
|
|
|
|
.enable_bit = prefix ## _reg ## _ ## _name ## EN, \
|
|
|
|
}
|
|
|
|
|
2019-01-25 22:37:04 +07:00
|
|
|
#define MC13xxx_GPO_DEFINE(prefix, _name, _node, _reg, _voltages, _ops) \
|
2010-12-14 13:00:54 +07:00
|
|
|
[prefix ## _name] = { \
|
|
|
|
.desc = { \
|
2019-01-25 22:37:04 +07:00
|
|
|
.name = #_node, \
|
2010-12-14 13:00:54 +07:00
|
|
|
.n_voltages = ARRAY_SIZE(_voltages), \
|
2012-06-08 14:41:48 +07:00
|
|
|
.volt_table = _voltages, \
|
2010-12-14 13:00:54 +07:00
|
|
|
.ops = &_ops, \
|
|
|
|
.type = REGULATOR_VOLTAGE, \
|
|
|
|
.id = prefix ## _name, \
|
|
|
|
.owner = THIS_MODULE, \
|
|
|
|
}, \
|
|
|
|
.reg = prefix ## _reg, \
|
|
|
|
.enable_bit = prefix ## _reg ## _ ## _name ## EN, \
|
|
|
|
}
|
|
|
|
|
2019-01-25 22:37:04 +07: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 13:00:54 +07:00
|
|
|
|
|
|
|
#endif
|