diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/mfd/tps6105x.h | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/include/linux/mfd/tps6105x.h b/include/linux/mfd/tps6105x.h new file mode 100644 index 000000000000..f259244a56bd --- /dev/null +++ b/include/linux/mfd/tps6105x.h | |||
@@ -0,0 +1,95 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2011 ST-Ericsson SA | ||
3 | * Written on behalf of Linaro for ST-Ericsson | ||
4 | * | ||
5 | * Author: Linus Walleij <linus.walleij@linaro.org> | ||
6 | * | ||
7 | * License terms: GNU General Public License (GPL) version 2 | ||
8 | */ | ||
9 | #ifndef MFD_TPS6105X_H | ||
10 | #define MFD_TPS6105X_H | ||
11 | |||
12 | #include <linux/i2c.h> | ||
13 | |||
14 | /* | ||
15 | * Register definitions to all subdrivers | ||
16 | */ | ||
17 | #define TPS6105X_REG_0 0x00 | ||
18 | #define TPS6105X_REG0_MODE_SHIFT 6 | ||
19 | #define TPS6105X_REG0_MODE_MASK (0x03<<6) | ||
20 | /* These defines for both reg0 and reg1 */ | ||
21 | #define TPS6105X_REG0_MODE_SHUTDOWN 0x00 | ||
22 | #define TPS6105X_REG0_MODE_TORCH 0x01 | ||
23 | #define TPS6105X_REG0_MODE_TORCH_FLASH 0x02 | ||
24 | #define TPS6105X_REG0_MODE_VOLTAGE 0x03 | ||
25 | #define TPS6105X_REG0_VOLTAGE_SHIFT 4 | ||
26 | #define TPS6105X_REG0_VOLTAGE_MASK (3<<4) | ||
27 | #define TPS6105X_REG0_VOLTAGE_450 0 | ||
28 | #define TPS6105X_REG0_VOLTAGE_500 1 | ||
29 | #define TPS6105X_REG0_VOLTAGE_525 2 | ||
30 | #define TPS6105X_REG0_VOLTAGE_500_2 3 | ||
31 | #define TPS6105X_REG0_DIMMING_SHIFT 3 | ||
32 | #define TPS6105X_REG0_TORCHC_SHIFT 0 | ||
33 | #define TPS6105X_REG0_TORCHC_MASK (7<<0) | ||
34 | #define TPS6105X_REG0_TORCHC_0 0x00 | ||
35 | #define TPS6105X_REG0_TORCHC_50 0x01 | ||
36 | #define TPS6105X_REG0_TORCHC_75 0x02 | ||
37 | #define TPS6105X_REG0_TORCHC_100 0x03 | ||
38 | #define TPS6105X_REG0_TORCHC_150 0x04 | ||
39 | #define TPS6105X_REG0_TORCHC_200 0x05 | ||
40 | #define TPS6105X_REG0_TORCHC_250_400 0x06 | ||
41 | #define TPS6105X_REG0_TORCHC_250_500 0x07 | ||
42 | #define TPS6105X_REG_1 0x01 | ||
43 | #define TPS6105X_REG1_MODE_SHIFT 6 | ||
44 | #define TPS6105X_REG1_MODE_MASK (0x03<<6) | ||
45 | #define TPS6105X_REG1_MODE_SHUTDOWN 0x00 | ||
46 | #define TPS6105X_REG1_MODE_TORCH 0x01 | ||
47 | #define TPS6105X_REG1_MODE_TORCH_FLASH 0x02 | ||
48 | #define TPS6105X_REG1_MODE_VOLTAGE 0x03 | ||
49 | #define TPS6105X_REG_2 0x02 | ||
50 | #define TPS6105X_REG_3 0x03 | ||
51 | |||
52 | /** | ||
53 | * enum tps6105x_mode - desired mode for the TPS6105x | ||
54 | * @TPS6105X_MODE_SHUTDOWN: this instance is inactive, not used for anything | ||
55 | * @TPS61905X_MODE_TORCH: this instance is used as a LED, usually a while | ||
56 | * LED, for example as backlight or flashlight. If this is set, the | ||
57 | * TPS6105X will register to the LED framework | ||
58 | * @TPS6105X_MODE_TORCH_FLASH: this instance is used as a flashgun, usually | ||
59 | * in a camera | ||
60 | * @TPS6105X_MODE_VOLTAGE: this instance is used as a voltage regulator and | ||
61 | * will register to the regulator framework | ||
62 | */ | ||
63 | enum tps6105x_mode { | ||
64 | TPS6105X_MODE_SHUTDOWN, | ||
65 | TPS6105X_MODE_TORCH, | ||
66 | TPS6105X_MODE_TORCH_FLASH, | ||
67 | TPS6105X_MODE_VOLTAGE, | ||
68 | }; | ||
69 | |||
70 | /** | ||
71 | * struct tps6105x_platform_data - TPS61905x platform data | ||
72 | * @mode: what mode this instance shall be operated in, | ||
73 | * this is not selectable at runtime | ||
74 | */ | ||
75 | struct tps6105x_platform_data { | ||
76 | enum tps6105x_mode mode; | ||
77 | }; | ||
78 | |||
79 | /** | ||
80 | * struct tps6105x - state holder for the TPS6105x drivers | ||
81 | * @mutex: mutex to serialize I2C accesses | ||
82 | * @i2c_client: corresponding I2C client | ||
83 | */ | ||
84 | struct tps6105x { | ||
85 | struct tps6105x_platform_data *pdata; | ||
86 | struct mutex lock; | ||
87 | struct i2c_client *client; | ||
88 | }; | ||
89 | |||
90 | extern int tps6105x_set(struct tps6105x *tps6105x, u8 reg, u8 value); | ||
91 | extern int tps6105x_get(struct tps6105x *tps6105x, u8 reg, u8 *buf); | ||
92 | extern int tps6105x_mask_and_set(struct tps6105x *tps6105x, u8 reg, | ||
93 | u8 bitmask, u8 bitvalues); | ||
94 | |||
95 | #endif | ||