aboutsummaryrefslogtreecommitdiff
path: root/arch/arm/mach-ux500/include/mach/regulator.h
blob: 75ff3340359a668cc1767da576c4dd7186fcec87 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/*
 * Copyright (C) ST-Ericsson SA 2010
 *
 * Author: Bengt Jonsson <bengt.jonsson@stericsson.com> for ST-Ericsson,
 *	   Jonas Aaberg <jonas.aberg@stericsson.com> for ST-Ericsson
 *
 * License Terms: GNU General Public License v2
 *
 */

#ifndef MACH_UX500_REGULATOR_H
#define MACH_UX500_REGULATOR_H

#include <linux/device.h>

struct ux500_regulator;

#ifdef CONFIG_REGULATOR
/*
 * NOTE! The device will be connected to the correct regulator by this
 * new framework. A list with connections will match up dev_name(dev)
 * to the specific regulator. This follows the same principle as the
 * normal regulator framework.
 *
 * This framework shall only be used in special cases when a regulator
 * has to be enabled/disabled in atomic context.
 */

/**
 * ux500_regulator_get()
 *
 * @dev: Drivers device struct
 *
 * Returns a ux500_regulator struct. Shall be used as argument for
 * ux500_regulator_atomic_enable/disable calls.
 * Return ERR_PTR(-EINVAL) upon no matching regulator found.
 */
struct ux500_regulator *__must_check ux500_regulator_get(struct device *dev);

/**
 * ux500_regulator_atomic_enable()
 *
 * @regulator: Regulator handle, provided from ux500_regulator_get.
 *
 * The enable/disable functions keep an internal counter, so every
 * enable must be paired with an disable in order to turn off regulator.
 */
int ux500_regulator_atomic_enable(struct ux500_regulator *regulator);

/**
 * ux500_regulator_atomic_disable()
 *
 * @regulator: Regulator handle, provided from ux500_regulator_get.
 *
 */
int ux500_regulator_atomic_disable(struct ux500_regulator *regulator);

/**
 * ux500_regulator_put()
 *
 * @regulator: Regulator handle, provided from ux500_regulator_get.
 */
void ux500_regulator_put(struct ux500_regulator *regulator);
#else
static inline struct ux500_regulator *__must_check
ux500_regulator_get(struct device *dev)
{
	return ERR_PTR(-EINVAL);
}

static inline int
ux500_regulator_atomic_enable(struct ux500_regulator *regulator)
{
	return -EINVAL;
}

static inline int
ux500_regulator_atomic_disable(struct ux500_regulator *regulator)
{
	return -EINVAL;
}

static inline void ux500_regulator_put(struct ux500_regulator *regulator)
{
}
#endif

#endif