7ede72c9e456b360c244d51635384ed3837d8be2
[firefly-linux-kernel-4.4.55.git] / include / linux / mfd / rk808.h
1 /* include/linux/regulator/rk808.h
2  *
3  * This software is licensed under the terms of the GNU General Public
4  * License version 2, as published by the Free Software Foundation, and
5  * may be copied, distributed, and modified under those terms.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10  * GNU General Public License for more details.
11  *
12  */
13 #ifndef __LINUX_REGULATOR_rk808_H
14 #define __LINUX_REGULATOR_rk808_H
15
16 #include <linux/regulator/machine.h>
17 #include <linux/wakelock.h>
18 #include <linux/earlysuspend.h>
19
20 //#define RK808_START 30
21
22 #define RK808_DCDC1  0                     //(0+RK808_START) 
23
24 #define RK808_LDO1 4                //(4+RK808_START)
25
26 #define RK808_SECONDS_REG 0x00
27 #define RK808_MINUTES_REG 0x01
28 #define RK808_HOURS_REG 0x02
29 #define RK808_DAYS_REG 0x03
30 #define RK808_MONTHS_REG 0x04
31 #define RK808_YEARS_REG 0x05
32 #define RK808_WEEKS_REG 0x06
33 #define RK808_ALARM_SECONDS_REG 0x07
34 #define RK808_ALARM_MINUTES_REG 0x08
35 #define RK808_ALARM_HOURS_REG 0x09
36 #define RK808_ALARM_DAYS_REG 0x0a
37 #define RK808_ALARM_MONTHS_REG 0x0b
38 #define RK808_ALARM_YEARS_REG 0x0c
39 #define RK808_RTC_CTRL_REG 0x10
40 #define RK808_RTC_STATUS_REG 0x11
41 #define RK808_RTC_INT_REG 0x12
42 #define RK808_RTC_COMP_LSB_REG 0x13
43 #define RK808_RTC_COMP_MSB_REG 0x14
44 #define RK808_CLK32OUT_REG 0x20
45 #define RK808_VB_MON_REG 0x21
46 #define RK808_THERMAL_REG 0x22
47 #define RK808_DCDC_EN_REG 0x23
48 #define RK808_LDO_EN_REG 0x24
49 #define RK808_SLEEP_SET_OFF_REG1 0x25
50 #define RK808_SLEEP_SET_OFF_REG2 0x26
51 #define RK808_DCDC_UV_STS_REG 0x27
52 #define RK808_DCDC_UV_ACT_REG 0x28
53 #define RK808_LDO_UV_STS_REG 0x29
54 #define RK808_LDO_UV_ACT_REG 0x2a
55 #define RK808_DCDC_PG_REG 0x2b
56 #define RK808_LDO_PG_REG 0x2c
57 #define RK808_VOUT_MON_TDB_REG 0x2d
58 #define RK808_BUCK1_CONFIG_REG 0x2e
59 #define RK808_BUCK1_ON_REG 0x2f
60 #define RK808_BUCK1_SLP_REG 0x30
61 #define RK808_BUCK1_DVS_REG 0x31
62 #define RK808_BUCK2_CONFIG_REG 0x32
63 #define RK808_BUCK2_ON_REG 0x33
64 #define RK808_BUCK2_SLP_REG 0x34
65 #define RK808_BUCK2_DVS_REG 0x35
66 #define RK808_BUCK3_CONFIG_REG 0x36
67 #define RK808_BUCK4_CONFIG_REG 0x37
68 #define RK808_BUCK4_ON_REG 0x38
69 #define RK808_BUCK4_SLP_VSEL_REG 0x39
70 #define RK808_BOOST_CONFIG_REG 0x3a
71 #define RK808_LDO1_ON_VSEL_REG 0x3b
72 #define RK808_LDO1_SLP_VSEL_REG 0x3c
73 #define RK808_LDO2_ON_VSEL_REG 0x3d
74 #define RK808_LDO2_SLP_VSEL_REG 0x3e
75 #define RK808_LDO3_ON_VSEL_REG 0x3f
76 #define RK808_LDO3_SLP_VSEL_REG 0x40
77 #define RK808_LDO4_ON_VSEL_REG 0x41
78 #define RK808_LDO4_SLP_VSEL_REG 0x42
79 #define RK808_LDO5_ON_VSEL_REG 0x43
80 #define RK808_LDO5_SLP_VSEL_REG 0x44
81 #define RK808_LDO6_ON_VSEL_REG 0x45
82 #define RK808_LDO6_SLP_VSEL_REG 0x46
83 #define RK808_LDO7_ON_VSEL_REG 0x47
84 #define RK808_LDO7_SLP_VSEL_REG 0x48
85 #define RK808_LDO8_ON_VSEL_REG 0x49
86 #define RK808_LDO8_SLP_VSEL_REG 0x4a
87 #define RK808_DEVCTRL_REG 0x4b
88 #define RK808_INT_STS_REG1 0X4c
89 #define RK808_INT_STS_MSK_REG1 0X4d
90 #define RK808_INT_STS_REG2 0X4e
91 #define RK808_INT_STS_MSK_REG2 0X4d
92 #define RK808_IO_POL_REG 0X50
93
94 /* IRQ Definitions */
95 #define RK808_IRQ_VOUT_LO                       0
96 #define RK808_IRQ_VB_LO                         1
97 #define RK808_IRQ_PWRON                         2
98 #define RK808_IRQ_PWRON_LP                              3
99 #define RK808_IRQ_HOTDIE                                4
100 #define RK808_IRQ_RTC_ALARM                             5
101 #define RK808_IRQ_RTC_PERIOD                            6
102
103 #define RK808_NUM_IRQ  9
104
105 #define rk808_NUM_REGULATORS 12
106 struct rk808;
107
108 struct rk808_regulator_subdev {
109         int id;
110         struct regulator_init_data *initdata;
111 };
112
113 struct rk808 {
114         struct device *dev;
115         struct mutex io_lock;
116         struct i2c_client *i2c;
117         int num_regulators;
118         struct regulator_dev **rdev;
119         struct wake_lock        irq_wake;
120         struct early_suspend rk808_suspend;
121         struct mutex irq_lock;
122         int irq_base;
123         int irq_num;
124         int chip_irq;
125         u32 irq_mask;
126         int (*read)(struct rk808 *rk808, u8 reg, int size, void *dest);
127         int (*write)(struct rk808 *rk808, u8 reg, int size, void *src);
128 };
129
130 struct rk808_platform_data {
131         int num_regulators;
132         int (*pre_init)(struct rk808 *rk808);
133         int (*set_init)(struct rk808 *rk808);
134         struct rk808_regulator_subdev *regulators;
135         int irq;
136         int irq_base;
137 };
138
139 int rk808_irq_init(struct rk808 *rk808, int irq,struct rk808_platform_data *pdata);
140  int rk808_i2c_read(struct rk808 *rk808, char reg, int count,u8 *dest);
141 //int rk808_i2c_read(struct i2c_client *i2c, char reg, int count,u16 *dest);
142 // int rk808_i2c_read(struct rk808 *rk808 , u8 reg, int bytes,void *dest); 
143 int rk808_i2c_write(struct rk808 *rk808, char reg, int count, const u8 src);
144 int rk808_set_bits(struct rk808 *rk808, u8 reg, u8 mask, u8 val);
145 int rk808_clear_bits(struct rk808 *rk808, u8 reg, u8 mask);
146 u8 rk808_reg_read(struct rk808 *rk808, u8 reg);
147 int rk808_reg_write(struct rk808 *rk808, u8 reg, u8 val);
148 int rk808_bulk_read(struct rk808 *rk808, u8 reg,
149                      int count, u8 *buf);
150 int rk808_bulk_write(struct rk808 *rk808, u8 reg,
151                      int count, u8 *buf);
152 int rk808_device_shutdown(void);
153
154 #endif
155