| 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; | 
 | 25 | 	int const *voltages; | 
 | 26 | }; | 
 | 27 |  | 
 | 28 | struct mc13xxx_regulator_priv { | 
 | 29 | 	struct mc13xxx *mc13xxx; | 
 | 30 | 	u32 powermisc_pwgt_state; | 
 | 31 | 	struct mc13xxx_regulator *mc13xxx_regulators; | 
| Shawn Guo | 93bcb23 | 2011-12-21 23:00:46 +0800 | [diff] [blame] | 32 | 	int num_regulators; | 
| Yong Shen | 167e3d8 | 2010-12-14 14:00:54 +0800 | [diff] [blame] | 33 | 	struct regulator_dev *regulators[]; | 
 | 34 | }; | 
 | 35 |  | 
 | 36 | extern int mc13xxx_sw_regulator(struct regulator_dev *rdev); | 
 | 37 | extern int mc13xxx_sw_regulator_is_enabled(struct regulator_dev *rdev); | 
 | 38 | extern int mc13xxx_get_best_voltage_index(struct regulator_dev *rdev, | 
 | 39 | 						int min_uV, int max_uV); | 
 | 40 | extern int mc13xxx_regulator_list_voltage(struct regulator_dev *rdev, | 
 | 41 | 						unsigned selector); | 
 | 42 | extern int mc13xxx_fixed_regulator_set_voltage(struct regulator_dev *rdev, | 
 | 43 | 		int min_uV, int max_uV, unsigned *selector); | 
 | 44 | extern int mc13xxx_fixed_regulator_get_voltage(struct regulator_dev *rdev); | 
 | 45 |  | 
| Shawn Guo | 93bcb23 | 2011-12-21 23:00:46 +0800 | [diff] [blame] | 46 | #ifdef CONFIG_OF | 
 | 47 | extern int mc13xxx_get_num_regulators_dt(struct platform_device *pdev); | 
 | 48 | extern struct mc13xxx_regulator_init_data *mc13xxx_parse_regulators_dt( | 
 | 49 | 	struct platform_device *pdev, struct mc13xxx_regulator *regulators, | 
 | 50 | 	int num_regulators); | 
 | 51 | #else | 
 | 52 | static inline int mc13xxx_get_num_regulators_dt(struct platform_device *pdev) | 
 | 53 | { | 
 | 54 | 	return -ENODEV; | 
 | 55 | } | 
 | 56 |  | 
 | 57 | static inline struct mc13xxx_regulator_init_data *mc13xxx_parse_regulators_dt( | 
 | 58 | 	struct platform_device *pdev, struct mc13xxx_regulator *regulators, | 
 | 59 | 	int num_regulators) | 
 | 60 | { | 
 | 61 | 	return NULL; | 
 | 62 | } | 
 | 63 | #endif | 
 | 64 |  | 
| Yong Shen | 167e3d8 | 2010-12-14 14:00:54 +0800 | [diff] [blame] | 65 | extern struct regulator_ops mc13xxx_regulator_ops; | 
 | 66 | extern struct regulator_ops mc13xxx_fixed_regulator_ops; | 
 | 67 |  | 
 | 68 | #define MC13xxx_DEFINE(prefix, _name, _reg, _vsel_reg, _voltages, _ops)	\ | 
 | 69 | 	[prefix ## _name] = {				\ | 
 | 70 | 		.desc = {						\ | 
| Shawn Guo | 3a5d031 | 2011-12-21 23:00:45 +0800 | [diff] [blame] | 71 | 			.name = #_name,					\ | 
| Yong Shen | 167e3d8 | 2010-12-14 14:00:54 +0800 | [diff] [blame] | 72 | 			.n_voltages = ARRAY_SIZE(_voltages),		\ | 
 | 73 | 			.ops = &_ops,			\ | 
 | 74 | 			.type = REGULATOR_VOLTAGE,			\ | 
 | 75 | 			.id = prefix ## _name,		\ | 
 | 76 | 			.owner = THIS_MODULE,				\ | 
 | 77 | 		},							\ | 
 | 78 | 		.reg = prefix ## _reg,				\ | 
 | 79 | 		.enable_bit = prefix ## _reg ## _ ## _name ## EN,	\ | 
 | 80 | 		.vsel_reg = prefix ## _vsel_reg,			\ | 
 | 81 | 		.vsel_shift = prefix ## _vsel_reg ## _ ## _name ## VSEL,\ | 
 | 82 | 		.vsel_mask = prefix ## _vsel_reg ## _ ## _name ## VSEL_M,\ | 
 | 83 | 		.voltages =  _voltages,					\ | 
 | 84 | 	} | 
 | 85 |  | 
 | 86 | #define MC13xxx_FIXED_DEFINE(prefix, _name, _reg, _voltages, _ops)	\ | 
 | 87 | 	[prefix ## _name] = {				\ | 
 | 88 | 		.desc = {						\ | 
| Shawn Guo | 3a5d031 | 2011-12-21 23:00:45 +0800 | [diff] [blame] | 89 | 			.name = #_name,					\ | 
| Yong Shen | 167e3d8 | 2010-12-14 14:00:54 +0800 | [diff] [blame] | 90 | 			.n_voltages = ARRAY_SIZE(_voltages),		\ | 
 | 91 | 			.ops = &_ops,		\ | 
 | 92 | 			.type = REGULATOR_VOLTAGE,			\ | 
 | 93 | 			.id = prefix ## _name,		\ | 
 | 94 | 			.owner = THIS_MODULE,				\ | 
 | 95 | 		},							\ | 
 | 96 | 		.reg = prefix ## _reg,				\ | 
 | 97 | 		.enable_bit = prefix ## _reg ## _ ## _name ## EN,	\ | 
 | 98 | 		.voltages =  _voltages,					\ | 
 | 99 | 	} | 
 | 100 |  | 
 | 101 | #define MC13xxx_GPO_DEFINE(prefix, _name, _reg,  _voltages, _ops)	\ | 
 | 102 | 	[prefix ## _name] = {				\ | 
 | 103 | 		.desc = {						\ | 
| Shawn Guo | 3a5d031 | 2011-12-21 23:00:45 +0800 | [diff] [blame] | 104 | 			.name = #_name,					\ | 
| Yong Shen | 167e3d8 | 2010-12-14 14:00:54 +0800 | [diff] [blame] | 105 | 			.n_voltages = ARRAY_SIZE(_voltages),		\ | 
 | 106 | 			.ops = &_ops,		\ | 
 | 107 | 			.type = REGULATOR_VOLTAGE,			\ | 
 | 108 | 			.id = prefix ## _name,		\ | 
 | 109 | 			.owner = THIS_MODULE,				\ | 
 | 110 | 		},							\ | 
 | 111 | 		.reg = prefix ## _reg,				\ | 
 | 112 | 		.enable_bit = prefix ## _reg ## _ ## _name ## EN,	\ | 
 | 113 | 		.voltages =  _voltages,					\ | 
 | 114 | 	} | 
 | 115 |  | 
 | 116 | #define MC13xxx_DEFINE_SW(_name, _reg, _vsel_reg, _voltages, ops)	\ | 
 | 117 | 	MC13xxx_DEFINE(SW, _name, _reg, _vsel_reg, _voltages, ops) | 
 | 118 | #define MC13xxx_DEFINE_REGU(_name, _reg, _vsel_reg, _voltages, ops)	\ | 
 | 119 | 	MC13xxx_DEFINE(REGU, _name, _reg, _vsel_reg, _voltages, ops) | 
 | 120 |  | 
 | 121 | #endif |