tizen 2.4 release
[profile/mobile/platform/kernel/linux-3.10-sc7730.git] / include / linux / mfd / lm3632.h
1 /*
2  * TI LM3632 MFD Driver
3  *
4  * Copyright 2015 Texas Instruments
5  *
6  * Author: Milo Kim <milo.kim@ti.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  */
13
14 #ifndef __MFD_LM3632_H__
15 #define __MFD_LM3632_H__
16
17 #include <linux/gpio.h>
18 #include <linux/pwm.h>
19 #include <linux/regmap.h>
20 #include <linux/regulator/machine.h>
21
22 /* Registers */
23 #define LM3632_REG_CONFIG1              0x02
24 #define LM3632_OVP_MASK                 (BIT(5) | BIT(6) | BIT(7))
25 #define LM3632_OVP_25V                  BIT(6)
26
27 #define LM3632_REG_CONFIG2              0x03
28 #define LM3632_SWFREQ_MASK              BIT(7)
29 #define LM3632_SWFREQ_1MHZ              BIT(7)
30
31 #define LM3632_REG_BRT_LSB              0x04
32 #define LM3632_BRT_LSB_MASK             (BIT(0) | BIT(1) | BIT(2))
33 #define LM3632_REG_BRT_MSB              0x05
34 #define LM3632_BRT_MSB_SHIFT            3
35
36 #define LM3632_REG_IO_CTRL              0x09
37 #define LM3632_PWM_MASK                 BIT(6)
38 #define LM3632_PWM_SHIFT                6
39
40 #define LM3632_REG_ENABLE               0x0A
41 #define LM3632_BL_EN_MASK               BIT(0)
42 #define LM3632_BL_EN_SHIFT              0
43 #define LM3632_BL_STRING_MASK           (BIT(3) | BIT(4))
44 #define LM3632_BL_ONE_STRING            BIT(4)
45 #define LM3632_BL_TWO_STRINGS           BIT(3)
46
47 #define LM3632_REG_BIAS_CONFIG          0x0C
48 #define LM3632_EXT_EN_MASK              BIT(0)
49 #define LM3632_EN_VNEG_MASK             BIT(1)
50 #define LM3632_EN_VPOS_MASK             BIT(2)
51
52 #define LM3632_REG_VOUT_BOOST           0x0D
53 #define LM3632_REG_VOUT_POS             0x0E
54 #define LM3632_REG_VOUT_NEG             0x0F
55 #define LM3632_VOUT_MASK                0x3F
56
57 #define LM3632_MAX_REGISTERS            0x10
58
59 #define LM3632_NUM_REGULATORS           3
60
61 /*
62  * struct lm3632_backlight_platform_data
63  * @name: Backlight driver name
64  * @is_full_strings: set true if two strings are used
65  * @pwm_period: Platform specific PWM period value. unit is nano
66  */
67 struct lm3632_backlight_platform_data {
68         const char *name;
69         bool is_full_strings;
70
71         /* Only valid in case of PWM mode */
72         unsigned int pwm_period;
73 };
74
75 /*
76  * struct lm3632_platform_data
77  * @en_gpio: GPIO for chip enable pin
78  * @lcm_en1_gpio: GPIO for VPOS LDO
79  * @lcm_en2_gpio: GPIO for VNEG LDO
80  * @regulator_data: Regulator initial data for LCD bias
81  * @bl_pdata: Backlight platform data
82  */
83 struct lm3632_platform_data {
84         int en_gpio;
85         int lcm_en1_gpio;
86         int lcm_en2_gpio;
87         struct regulator_init_data *regulator_data[LM3632_NUM_REGULATORS];
88         struct lm3632_backlight_platform_data *bl_pdata;
89 };
90
91 /*
92  * struct lm3632
93  * @dev: Parent device pointer
94  * @regmap: Used for i2c communcation on accessing registers
95  * @pdata: LMU platform specific data
96  */
97 struct lm3632 {
98         struct device *dev;
99         struct regmap *regmap;
100         struct lm3632_platform_data *pdata;
101 };
102
103 int lm3632_read_byte(struct lm3632 *lm3632, u8 reg, u8 *read);
104 int lm3632_write_byte(struct lm3632 *lm3632, u8 reg, u8 data);
105 int lm3632_update_bits(struct lm3632 *lm3632, u8 reg, u8 mask, u8 data);
106 #endif