1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * mc13xxx.h - regulators for the Freescale mc13xxx PMIC
5 * Copyright (C) 2010 Yong Shen <yong.shen@linaro.org>
8 #ifndef __LINUX_REGULATOR_MC13XXX_H
9 #define __LINUX_REGULATOR_MC13XXX_H
11 #include <linux/regulator/driver.h>
13 struct mc13xxx_regulator
{
14 struct regulator_desc desc
;
22 struct mc13xxx_regulator_priv
{
23 struct mc13xxx
*mc13xxx
;
24 u32 powermisc_pwgt_state
;
25 struct mc13xxx_regulator
*mc13xxx_regulators
;
27 struct regulator_dev
*regulators
[];
30 extern int mc13xxx_fixed_regulator_set_voltage(struct regulator_dev
*rdev
,
31 int min_uV
, int max_uV
, unsigned *selector
);
34 extern int mc13xxx_get_num_regulators_dt(struct platform_device
*pdev
);
35 extern struct mc13xxx_regulator_init_data
*mc13xxx_parse_regulators_dt(
36 struct platform_device
*pdev
, struct mc13xxx_regulator
*regulators
,
39 static inline int mc13xxx_get_num_regulators_dt(struct platform_device
*pdev
)
44 static inline struct mc13xxx_regulator_init_data
*mc13xxx_parse_regulators_dt(
45 struct platform_device
*pdev
, struct mc13xxx_regulator
*regulators
,
52 extern const struct regulator_ops mc13xxx_regulator_ops
;
53 extern const struct regulator_ops mc13xxx_fixed_regulator_ops
;
55 #define MC13xxx_DEFINE(prefix, _name, _node, _reg, _vsel_reg, _voltages, _ops) \
56 [prefix ## _name] = { \
59 .n_voltages = ARRAY_SIZE(_voltages), \
60 .volt_table = _voltages, \
62 .type = REGULATOR_VOLTAGE, \
63 .id = prefix ## _name, \
64 .owner = THIS_MODULE, \
66 .reg = prefix ## _reg, \
67 .enable_bit = prefix ## _reg ## _ ## _name ## EN, \
68 .vsel_reg = prefix ## _vsel_reg, \
69 .vsel_shift = prefix ## _vsel_reg ## _ ## _name ## VSEL,\
70 .vsel_mask = prefix ## _vsel_reg ## _ ## _name ## VSEL_M,\
73 #define MC13xxx_FIXED_DEFINE(prefix, _name, _node, _reg, _voltages, _ops) \
74 [prefix ## _name] = { \
77 .n_voltages = ARRAY_SIZE(_voltages), \
78 .volt_table = _voltages, \
80 .type = REGULATOR_VOLTAGE, \
81 .id = prefix ## _name, \
82 .owner = THIS_MODULE, \
84 .reg = prefix ## _reg, \
85 .enable_bit = prefix ## _reg ## _ ## _name ## EN, \
88 #define MC13xxx_GPO_DEFINE(prefix, _name, _node, _reg, _voltages, _ops) \
89 [prefix ## _name] = { \
92 .n_voltages = ARRAY_SIZE(_voltages), \
93 .volt_table = _voltages, \
95 .type = REGULATOR_VOLTAGE, \
96 .id = prefix ## _name, \
97 .owner = THIS_MODULE, \
99 .reg = prefix ## _reg, \
100 .enable_bit = prefix ## _reg ## _ ## _name ## EN, \
103 #define MC13xxx_DEFINE_SW(_name, _node, _reg, _vsel_reg, _voltages, ops) \
104 MC13xxx_DEFINE(SW, _name, _node, _reg, _vsel_reg, _voltages, ops)
105 #define MC13xxx_DEFINE_REGU(_name, _node, _reg, _vsel_reg, _voltages, ops) \
106 MC13xxx_DEFINE(REGU, _name, _node, _reg, _vsel_reg, _voltages, ops)