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