diff options
Diffstat (limited to 'include/linux/regulator/driver.h')
| -rw-r--r-- | include/linux/regulator/driver.h | 73 | 
1 files changed, 65 insertions, 8 deletions
diff --git a/include/linux/regulator/driver.h b/include/linux/regulator/driver.h index fa8b55b8191..b0432cc2b16 100644 --- a/include/linux/regulator/driver.h +++ b/include/linux/regulator/driver.h @@ -19,6 +19,7 @@  #include <linux/notifier.h>  #include <linux/regulator/consumer.h> +struct regmap;  struct regulator_dev;  struct regulator_init_data; @@ -45,6 +46,7 @@ enum regulator_status {   *               The driver should select the voltage closest to min_uV.   * @set_voltage_sel: Set the voltage for the regulator using the specified   *                   selector. + * @map_voltage: Convert a voltage into a selector   * @get_voltage: Return the currently configured voltage for the regulator.   * @get_voltage_sel: Return the currently configured voltage selector for the   *                   regulator. @@ -90,6 +92,7 @@ struct regulator_ops {  	/* get/set regulator voltage */  	int (*set_voltage) (struct regulator_dev *, int min_uV, int max_uV,  			    unsigned *selector); +	int (*map_voltage)(struct regulator_dev *, int min_uV, int max_uV);  	int (*set_voltage_sel) (struct regulator_dev *, unsigned selector);  	int (*get_voltage) (struct regulator_dev *);  	int (*get_voltage_sel) (struct regulator_dev *); @@ -148,19 +151,30 @@ enum regulator_type {  };  /** - * struct regulator_desc - Regulator descriptor + * struct regulator_desc - Static regulator descriptor   * - * Each regulator registered with the core is described with a structure of - * this type. + * Each regulator registered with the core is described with a + * structure of this type and a struct regulator_config.  This + * structure contains the non-varying parts of the regulator + * description.   *   * @name: Identifying name for the regulator.   * @supply_name: Identifying the regulator supply   * @id: Numerical identifier for the regulator. - * @n_voltages: Number of selectors available for ops.list_voltage().   * @ops: Regulator operations table.   * @irq: Interrupt number for the regulator.   * @type: Indicates if the regulator is a voltage or current regulator.   * @owner: Module providing the regulator, used for refcounting. + * + * @n_voltages: Number of selectors available for ops.list_voltage(). + * + * @min_uV: Voltage given by the lowest selector (if linear mapping) + * @uV_step: Voltage increase with each selector (if linear mapping) + * + * @vsel_reg: Register for selector when using regulator_regmap_X_voltage_ + * @vsel_mask: Mask for register bitfield used for selector + * @enable_reg: Register for control when using regmap enable/disable ops + * @enable_mask: Mask for control when using regmap enable/disable ops   */  struct regulator_desc {  	const char *name; @@ -171,6 +185,36 @@ struct regulator_desc {  	int irq;  	enum regulator_type type;  	struct module *owner; + +	unsigned int min_uV; +	unsigned int uV_step; + +	unsigned int vsel_reg; +	unsigned int vsel_mask; +	unsigned int enable_reg; +	unsigned int enable_mask; +}; + +/** + * struct regulator_config - Dynamic regulator descriptor + * + * Each regulator registered with the core is described with a + * structure of this type and a struct regulator_desc.  This structure + * contains the runtime variable parts of the regulator description. + * + * @dev: struct device for the regulator + * @init_data: platform provided init data, passed through by driver + * @driver_data: private regulator data + * @of_node: OpenFirmware node to parse for device tree bindings (may be + *           NULL). + * @regmap: regmap to use for core regmap helpers + */ +struct regulator_config { +	struct device *dev; +	const struct regulator_init_data *init_data; +	void *driver_data; +	struct device_node *of_node; +	struct regmap *regmap;  };  /* @@ -184,7 +228,7 @@ struct regulator_desc {   * no other direct access).   */  struct regulator_dev { -	struct regulator_desc *desc; +	const struct regulator_desc *desc;  	int exclusive;  	u32 use_count;  	u32 open_count; @@ -201,6 +245,7 @@ struct regulator_dev {  	struct device dev;  	struct regulation_constraints *constraints;  	struct regulator *supply;	/* for tree */ +	struct regmap *regmap;  	struct delayed_work disable_work;  	int deferred_disables; @@ -210,9 +255,9 @@ struct regulator_dev {  	struct dentry *debugfs;  }; -struct regulator_dev *regulator_register(struct regulator_desc *regulator_desc, -	struct device *dev, const struct regulator_init_data *init_data, -	void *driver_data, struct device_node *of_node); +struct regulator_dev * +regulator_register(const struct regulator_desc *regulator_desc, +		   const struct regulator_config *config);  void regulator_unregister(struct regulator_dev *rdev);  int regulator_notifier_call_chain(struct regulator_dev *rdev, @@ -224,6 +269,18 @@ int rdev_get_id(struct regulator_dev *rdev);  int regulator_mode_to_status(unsigned int); +int regulator_list_voltage_linear(struct regulator_dev *rdev, +				  unsigned int selector); +int regulator_map_voltage_linear(struct regulator_dev *rdev, +				  int min_uV, int max_uV); +int regulator_map_voltage_iterate(struct regulator_dev *rdev, +				  int min_uV, int max_uV); +int regulator_get_voltage_sel_regmap(struct regulator_dev *rdev); +int regulator_set_voltage_sel_regmap(struct regulator_dev *rdev, unsigned sel); +int regulator_is_enabled_regmap(struct regulator_dev *rdev); +int regulator_enable_regmap(struct regulator_dev *rdev); +int regulator_disable_regmap(struct regulator_dev *rdev); +  void *regulator_get_init_drvdata(struct regulator_init_data *reg_init_data);  #endif  |