blob: e37d80561985df64f9497e0aa26a4718e5c24ab5 [file] [log] [blame]
Liam Girdwood571a3542008-04-30 15:42:28 +01001/*
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 Girdwood571a3542008-04-30 15:42:28 +010021struct regulator_dev;
Liam Girdwooda5766f12008-10-10 13:22:20 +010022struct regulator_init_data;
Liam Girdwood571a3542008-04-30 15:42:28 +010023
24/**
25 * struct regulator_ops - regulator operations.
26 *
27 * This struct describes regulator operations.
28 */
29struct 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 Brown3de89602008-09-09 16:21:17 +010054 * its parent PMIC enters a global STANDBY/HIBERNATE state */
Liam Girdwood571a3542008-04-30 15:42:28 +010055
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 */
70enum regulator_type {
71 REGULATOR_VOLTAGE,
72 REGULATOR_CURRENT,
73};
74
75/**
76 * struct regulator_desc - Regulator descriptor
77 *
78 */
79struct 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 Girdwood571a3542008-04-30 15:42:28 +010088struct regulator_dev *regulator_register(struct regulator_desc *regulator_desc,
Liam Girdwooda5766f12008-10-10 13:22:20 +010089 struct device *dev, void *driver_data);
Liam Girdwood571a3542008-04-30 15:42:28 +010090void regulator_unregister(struct regulator_dev *rdev);
91
92int regulator_notifier_call_chain(struct regulator_dev *rdev,
93 unsigned long event, void *data);
94
95void *rdev_get_drvdata(struct regulator_dev *rdev);
Liam Girdwooda5766f12008-10-10 13:22:20 +010096struct device *rdev_get_dev(struct regulator_dev *rdev);
Liam Girdwood571a3542008-04-30 15:42:28 +010097int rdev_get_id(struct regulator_dev *rdev);
98
Liam Girdwooda5766f12008-10-10 13:22:20 +010099void *regulator_get_init_drvdata(struct regulator_init_data *reg_init_data);
100
Liam Girdwood571a3542008-04-30 15:42:28 +0100101#endif