| Liam Girdwood | 571a354 | 2008-04-30 15:42:28 +0100 | [diff] [blame] | 1 | /* | 
|  | 2 | * driver.h -- SoC Regulator driver support. | 
|  | 3 | * | 
|  | 4 | * Copyright (C) 2007, 2008 Wolfson Microelectronics PLC. | 
|  | 5 | * | 
|  | 6 | * Author: Liam Girdwood <lg@opensource.wolfsonmicro.com> | 
|  | 7 | * | 
|  | 8 | * This program is free software; you can redistribute it and/or modify | 
|  | 9 | * it under the terms of the GNU General Public License version 2 as | 
|  | 10 | * published by the Free Software Foundation. | 
|  | 11 | * | 
|  | 12 | * Regulator Driver Interface. | 
|  | 13 | */ | 
|  | 14 |  | 
|  | 15 | #ifndef __LINUX_REGULATOR_DRIVER_H_ | 
|  | 16 | #define __LINUX_REGULATOR_DRIVER_H_ | 
|  | 17 |  | 
|  | 18 | #include <linux/device.h> | 
|  | 19 | #include <linux/regulator/consumer.h> | 
|  | 20 |  | 
| Liam Girdwood | 571a354 | 2008-04-30 15:42:28 +0100 | [diff] [blame] | 21 | struct regulator_dev; | 
| Liam Girdwood | a5766f1 | 2008-10-10 13:22:20 +0100 | [diff] [blame] | 22 | struct regulator_init_data; | 
| Liam Girdwood | 571a354 | 2008-04-30 15:42:28 +0100 | [diff] [blame] | 23 |  | 
|  | 24 | /** | 
|  | 25 | * struct regulator_ops - regulator operations. | 
|  | 26 | * | 
|  | 27 | * This struct describes regulator operations. | 
|  | 28 | */ | 
|  | 29 | struct regulator_ops { | 
|  | 30 |  | 
|  | 31 | /* get/set regulator voltage */ | 
|  | 32 | int (*set_voltage) (struct regulator_dev *, int min_uV, int max_uV); | 
|  | 33 | int (*get_voltage) (struct regulator_dev *); | 
|  | 34 |  | 
|  | 35 | /* get/set regulator current  */ | 
|  | 36 | int (*set_current_limit) (struct regulator_dev *, | 
|  | 37 | int min_uA, int max_uA); | 
|  | 38 | int (*get_current_limit) (struct regulator_dev *); | 
|  | 39 |  | 
|  | 40 | /* enable/disable regulator */ | 
|  | 41 | int (*enable) (struct regulator_dev *); | 
|  | 42 | int (*disable) (struct regulator_dev *); | 
|  | 43 | int (*is_enabled) (struct regulator_dev *); | 
|  | 44 |  | 
|  | 45 | /* get/set regulator operating mode (defined in regulator.h) */ | 
|  | 46 | int (*set_mode) (struct regulator_dev *, unsigned int mode); | 
|  | 47 | unsigned int (*get_mode) (struct regulator_dev *); | 
|  | 48 |  | 
|  | 49 | /* get most efficient regulator operating mode for load */ | 
|  | 50 | unsigned int (*get_optimum_mode) (struct regulator_dev *, int input_uV, | 
|  | 51 | int output_uV, int load_uA); | 
|  | 52 |  | 
|  | 53 | /* the operations below are for configuration of regulator state when | 
| Mark Brown | 3de8960 | 2008-09-09 16:21:17 +0100 | [diff] [blame] | 54 | * its parent PMIC enters a global STANDBY/HIBERNATE state */ | 
| Liam Girdwood | 571a354 | 2008-04-30 15:42:28 +0100 | [diff] [blame] | 55 |  | 
|  | 56 | /* set regulator suspend voltage */ | 
|  | 57 | int (*set_suspend_voltage) (struct regulator_dev *, int uV); | 
|  | 58 |  | 
|  | 59 | /* enable/disable regulator in suspend state */ | 
|  | 60 | int (*set_suspend_enable) (struct regulator_dev *); | 
|  | 61 | int (*set_suspend_disable) (struct regulator_dev *); | 
|  | 62 |  | 
|  | 63 | /* set regulator suspend operating mode (defined in regulator.h) */ | 
|  | 64 | int (*set_suspend_mode) (struct regulator_dev *, unsigned int mode); | 
|  | 65 | }; | 
|  | 66 |  | 
|  | 67 | /* | 
|  | 68 | * Regulators can either control voltage or current. | 
|  | 69 | */ | 
|  | 70 | enum regulator_type { | 
|  | 71 | REGULATOR_VOLTAGE, | 
|  | 72 | REGULATOR_CURRENT, | 
|  | 73 | }; | 
|  | 74 |  | 
|  | 75 | /** | 
|  | 76 | * struct regulator_desc - Regulator descriptor | 
|  | 77 | * | 
|  | 78 | */ | 
|  | 79 | struct regulator_desc { | 
|  | 80 | const char *name; | 
|  | 81 | int id; | 
|  | 82 | struct regulator_ops *ops; | 
|  | 83 | int irq; | 
|  | 84 | enum regulator_type type; | 
|  | 85 | struct module *owner; | 
|  | 86 | }; | 
|  | 87 |  | 
| Liam Girdwood | 571a354 | 2008-04-30 15:42:28 +0100 | [diff] [blame] | 88 | struct regulator_dev *regulator_register(struct regulator_desc *regulator_desc, | 
| Liam Girdwood | a5766f1 | 2008-10-10 13:22:20 +0100 | [diff] [blame] | 89 | struct device *dev, void *driver_data); | 
| Liam Girdwood | 571a354 | 2008-04-30 15:42:28 +0100 | [diff] [blame] | 90 | void regulator_unregister(struct regulator_dev *rdev); | 
|  | 91 |  | 
|  | 92 | int regulator_notifier_call_chain(struct regulator_dev *rdev, | 
|  | 93 | unsigned long event, void *data); | 
|  | 94 |  | 
|  | 95 | void *rdev_get_drvdata(struct regulator_dev *rdev); | 
| Liam Girdwood | a5766f1 | 2008-10-10 13:22:20 +0100 | [diff] [blame] | 96 | struct device *rdev_get_dev(struct regulator_dev *rdev); | 
| Liam Girdwood | 571a354 | 2008-04-30 15:42:28 +0100 | [diff] [blame] | 97 | int rdev_get_id(struct regulator_dev *rdev); | 
|  | 98 |  | 
| Liam Girdwood | a5766f1 | 2008-10-10 13:22:20 +0100 | [diff] [blame] | 99 | void *regulator_get_init_drvdata(struct regulator_init_data *reg_init_data); | 
|  | 100 |  | 
| Liam Girdwood | 571a354 | 2008-04-30 15:42:28 +0100 | [diff] [blame] | 101 | #endif |