| Yong Shen | 167e3d8 | 2010-12-14 14:00:54 +0800 | [diff] [blame] | 1 | /* | 
 | 2 |  * mc13xxx.h - regulators for the Freescale mc13xxx PMIC | 
 | 3 |  * | 
 | 4 |  *  Copyright (C) 2010 Yong Shen <yong.shen@linaro.org> | 
 | 5 |  * | 
 | 6 |  * This program is free software; you can redistribute it and/or modify | 
 | 7 |  * it under the terms of the GNU General Public License as published by | 
 | 8 |  * the Free Software Foundation; either version 2 of the License, or | 
 | 9 |  * (at your option) any later version. | 
 | 10 |  */ | 
 | 11 |  | 
 | 12 | #ifndef __LINUX_REGULATOR_MC13XXX_H | 
 | 13 | #define __LINUX_REGULATOR_MC13XXX_H | 
 | 14 |  | 
 | 15 | #include <linux/regulator/driver.h> | 
 | 16 |  | 
 | 17 | struct mc13xxx_regulator { | 
 | 18 | 	struct regulator_desc desc; | 
 | 19 | 	int reg; | 
 | 20 | 	int enable_bit; | 
 | 21 | 	int vsel_reg; | 
 | 22 | 	int vsel_shift; | 
 | 23 | 	int vsel_mask; | 
 | 24 | 	int hi_bit; | 
| Yong Shen | 167e3d8 | 2010-12-14 14:00:54 +0800 | [diff] [blame] | 25 | }; | 
 | 26 |  | 
 | 27 | struct mc13xxx_regulator_priv { | 
 | 28 | 	struct mc13xxx *mc13xxx; | 
 | 29 | 	u32 powermisc_pwgt_state; | 
 | 30 | 	struct mc13xxx_regulator *mc13xxx_regulators; | 
| Shawn Guo | 93bcb23 | 2011-12-21 23:00:46 +0800 | [diff] [blame] | 31 | 	int num_regulators; | 
| Yong Shen | 167e3d8 | 2010-12-14 14:00:54 +0800 | [diff] [blame] | 32 | 	struct regulator_dev *regulators[]; | 
 | 33 | }; | 
 | 34 |  | 
| Yong Shen | 167e3d8 | 2010-12-14 14:00:54 +0800 | [diff] [blame] | 35 | extern int mc13xxx_fixed_regulator_set_voltage(struct regulator_dev *rdev, | 
 | 36 | 		int min_uV, int max_uV, unsigned *selector); | 
| Yong Shen | 167e3d8 | 2010-12-14 14:00:54 +0800 | [diff] [blame] | 37 |  | 
| Shawn Guo | 93bcb23 | 2011-12-21 23:00:46 +0800 | [diff] [blame] | 38 | #ifdef CONFIG_OF | 
 | 39 | extern int mc13xxx_get_num_regulators_dt(struct platform_device *pdev); | 
 | 40 | extern struct mc13xxx_regulator_init_data *mc13xxx_parse_regulators_dt( | 
 | 41 | 	struct platform_device *pdev, struct mc13xxx_regulator *regulators, | 
 | 42 | 	int num_regulators); | 
 | 43 | #else | 
 | 44 | static inline int mc13xxx_get_num_regulators_dt(struct platform_device *pdev) | 
 | 45 | { | 
 | 46 | 	return -ENODEV; | 
 | 47 | } | 
 | 48 |  | 
 | 49 | static inline struct mc13xxx_regulator_init_data *mc13xxx_parse_regulators_dt( | 
 | 50 | 	struct platform_device *pdev, struct mc13xxx_regulator *regulators, | 
 | 51 | 	int num_regulators) | 
 | 52 | { | 
 | 53 | 	return NULL; | 
 | 54 | } | 
 | 55 | #endif | 
 | 56 |  | 
| Yong Shen | 167e3d8 | 2010-12-14 14:00:54 +0800 | [diff] [blame] | 57 | extern struct regulator_ops mc13xxx_regulator_ops; | 
 | 58 | extern struct regulator_ops mc13xxx_fixed_regulator_ops; | 
 | 59 |  | 
 | 60 | #define MC13xxx_DEFINE(prefix, _name, _reg, _vsel_reg, _voltages, _ops)	\ | 
 | 61 | 	[prefix ## _name] = {				\ | 
 | 62 | 		.desc = {						\ | 
| Shawn Guo | 3a5d031 | 2011-12-21 23:00:45 +0800 | [diff] [blame] | 63 | 			.name = #_name,					\ | 
| Yong Shen | 167e3d8 | 2010-12-14 14:00:54 +0800 | [diff] [blame] | 64 | 			.n_voltages = ARRAY_SIZE(_voltages),		\ | 
| Axel Lin | 34e74f3 | 2012-06-08 15:41:48 +0800 | [diff] [blame] | 65 | 			.volt_table =  _voltages,			\ | 
| Yong Shen | 167e3d8 | 2010-12-14 14:00:54 +0800 | [diff] [blame] | 66 | 			.ops = &_ops,			\ | 
 | 67 | 			.type = REGULATOR_VOLTAGE,			\ | 
 | 68 | 			.id = prefix ## _name,		\ | 
 | 69 | 			.owner = THIS_MODULE,				\ | 
 | 70 | 		},							\ | 
 | 71 | 		.reg = prefix ## _reg,				\ | 
 | 72 | 		.enable_bit = prefix ## _reg ## _ ## _name ## EN,	\ | 
 | 73 | 		.vsel_reg = prefix ## _vsel_reg,			\ | 
 | 74 | 		.vsel_shift = prefix ## _vsel_reg ## _ ## _name ## VSEL,\ | 
 | 75 | 		.vsel_mask = prefix ## _vsel_reg ## _ ## _name ## VSEL_M,\ | 
| Yong Shen | 167e3d8 | 2010-12-14 14:00:54 +0800 | [diff] [blame] | 76 | 	} | 
 | 77 |  | 
 | 78 | #define MC13xxx_FIXED_DEFINE(prefix, _name, _reg, _voltages, _ops)	\ | 
 | 79 | 	[prefix ## _name] = {				\ | 
 | 80 | 		.desc = {						\ | 
| Shawn Guo | 3a5d031 | 2011-12-21 23:00:45 +0800 | [diff] [blame] | 81 | 			.name = #_name,					\ | 
| Yong Shen | 167e3d8 | 2010-12-14 14:00:54 +0800 | [diff] [blame] | 82 | 			.n_voltages = ARRAY_SIZE(_voltages),		\ | 
| Axel Lin | 34e74f3 | 2012-06-08 15:41:48 +0800 | [diff] [blame] | 83 | 			.volt_table =  _voltages,			\ | 
| Yong Shen | 167e3d8 | 2010-12-14 14:00:54 +0800 | [diff] [blame] | 84 | 			.ops = &_ops,		\ | 
 | 85 | 			.type = REGULATOR_VOLTAGE,			\ | 
 | 86 | 			.id = prefix ## _name,		\ | 
 | 87 | 			.owner = THIS_MODULE,				\ | 
 | 88 | 		},							\ | 
 | 89 | 		.reg = prefix ## _reg,				\ | 
 | 90 | 		.enable_bit = prefix ## _reg ## _ ## _name ## EN,	\ | 
| Yong Shen | 167e3d8 | 2010-12-14 14:00:54 +0800 | [diff] [blame] | 91 | 	} | 
 | 92 |  | 
 | 93 | #define MC13xxx_GPO_DEFINE(prefix, _name, _reg,  _voltages, _ops)	\ | 
 | 94 | 	[prefix ## _name] = {				\ | 
 | 95 | 		.desc = {						\ | 
| Shawn Guo | 3a5d031 | 2011-12-21 23:00:45 +0800 | [diff] [blame] | 96 | 			.name = #_name,					\ | 
| Yong Shen | 167e3d8 | 2010-12-14 14:00:54 +0800 | [diff] [blame] | 97 | 			.n_voltages = ARRAY_SIZE(_voltages),		\ | 
| Axel Lin | 34e74f3 | 2012-06-08 15:41:48 +0800 | [diff] [blame] | 98 | 			.volt_table =  _voltages,			\ | 
| Yong Shen | 167e3d8 | 2010-12-14 14:00:54 +0800 | [diff] [blame] | 99 | 			.ops = &_ops,		\ | 
 | 100 | 			.type = REGULATOR_VOLTAGE,			\ | 
 | 101 | 			.id = prefix ## _name,		\ | 
 | 102 | 			.owner = THIS_MODULE,				\ | 
 | 103 | 		},							\ | 
 | 104 | 		.reg = prefix ## _reg,				\ | 
 | 105 | 		.enable_bit = prefix ## _reg ## _ ## _name ## EN,	\ | 
| Yong Shen | 167e3d8 | 2010-12-14 14:00:54 +0800 | [diff] [blame] | 106 | 	} | 
 | 107 |  | 
 | 108 | #define MC13xxx_DEFINE_SW(_name, _reg, _vsel_reg, _voltages, ops)	\ | 
 | 109 | 	MC13xxx_DEFINE(SW, _name, _reg, _vsel_reg, _voltages, ops) | 
 | 110 | #define MC13xxx_DEFINE_REGU(_name, _reg, _vsel_reg, _voltages, ops)	\ | 
 | 111 | 	MC13xxx_DEFINE(REGU, _name, _reg, _vsel_reg, _voltages, ops) | 
 | 112 |  | 
 | 113 | #endif |