e37d80561985df64f9497e0aa26a4718e5c24ab5
[pandora-kernel.git] / include / linux / regulator / driver.h
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
21 struct regulator_dev;
22 struct regulator_init_data;
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
54          * its parent PMIC enters a global STANDBY/HIBERNATE state */
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
88 struct regulator_dev *regulator_register(struct regulator_desc *regulator_desc,
89         struct device *dev, void *driver_data);
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);
96 struct device *rdev_get_dev(struct regulator_dev *rdev);
97 int rdev_get_id(struct regulator_dev *rdev);
98
99 void *regulator_get_init_drvdata(struct regulator_init_data *reg_init_data);
100
101 #endif