Add the rt linux 4.1.3-rt3 as base
[kvmfornfv.git] / kernel / include / linux / mfd / rk808.h
1 /*
2  * rk808.h for Rockchip RK808
3  *
4  * Copyright (c) 2014, Fuzhou Rockchip Electronics Co., Ltd
5  *
6  * Author: Chris Zhong <zyw@rock-chips.com>
7  * Author: Zhang Qing <zhangqing@rock-chips.com>
8  *
9  * This program is free software; you can redistribute it and/or modify it
10  * under the terms and conditions of the GNU General Public License,
11  * version 2, as published by the Free Software Foundation.
12  *
13  * This program is distributed in the hope it will be useful, but WITHOUT
14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
16  * more details.
17  */
18
19 #ifndef __LINUX_REGULATOR_rk808_H
20 #define __LINUX_REGULATOR_rk808_H
21
22 #include <linux/regulator/machine.h>
23 #include <linux/regmap.h>
24
25 /*
26  * rk808 Global Register Map.
27  */
28
29 #define RK808_DCDC1     0 /* (0+RK808_START) */
30 #define RK808_LDO1      4 /* (4+RK808_START) */
31 #define RK808_NUM_REGULATORS   14
32
33 enum rk808_reg {
34         RK808_ID_DCDC1,
35         RK808_ID_DCDC2,
36         RK808_ID_DCDC3,
37         RK808_ID_DCDC4,
38         RK808_ID_LDO1,
39         RK808_ID_LDO2,
40         RK808_ID_LDO3,
41         RK808_ID_LDO4,
42         RK808_ID_LDO5,
43         RK808_ID_LDO6,
44         RK808_ID_LDO7,
45         RK808_ID_LDO8,
46         RK808_ID_SWITCH1,
47         RK808_ID_SWITCH2,
48 };
49
50 #define RK808_SECONDS_REG       0x00
51 #define RK808_MINUTES_REG       0x01
52 #define RK808_HOURS_REG         0x02
53 #define RK808_DAYS_REG          0x03
54 #define RK808_MONTHS_REG        0x04
55 #define RK808_YEARS_REG         0x05
56 #define RK808_WEEKS_REG         0x06
57 #define RK808_ALARM_SECONDS_REG 0x08
58 #define RK808_ALARM_MINUTES_REG 0x09
59 #define RK808_ALARM_HOURS_REG   0x0a
60 #define RK808_ALARM_DAYS_REG    0x0b
61 #define RK808_ALARM_MONTHS_REG  0x0c
62 #define RK808_ALARM_YEARS_REG   0x0d
63 #define RK808_RTC_CTRL_REG      0x10
64 #define RK808_RTC_STATUS_REG    0x11
65 #define RK808_RTC_INT_REG       0x12
66 #define RK808_RTC_COMP_LSB_REG  0x13
67 #define RK808_RTC_COMP_MSB_REG  0x14
68 #define RK808_CLK32OUT_REG      0x20
69 #define RK808_VB_MON_REG        0x21
70 #define RK808_THERMAL_REG       0x22
71 #define RK808_DCDC_EN_REG       0x23
72 #define RK808_LDO_EN_REG        0x24
73 #define RK808_SLEEP_SET_OFF_REG1        0x25
74 #define RK808_SLEEP_SET_OFF_REG2        0x26
75 #define RK808_DCDC_UV_STS_REG   0x27
76 #define RK808_DCDC_UV_ACT_REG   0x28
77 #define RK808_LDO_UV_STS_REG    0x29
78 #define RK808_LDO_UV_ACT_REG    0x2a
79 #define RK808_DCDC_PG_REG       0x2b
80 #define RK808_LDO_PG_REG        0x2c
81 #define RK808_VOUT_MON_TDB_REG  0x2d
82 #define RK808_BUCK1_CONFIG_REG          0x2e
83 #define RK808_BUCK1_ON_VSEL_REG         0x2f
84 #define RK808_BUCK1_SLP_VSEL_REG        0x30
85 #define RK808_BUCK1_DVS_VSEL_REG        0x31
86 #define RK808_BUCK2_CONFIG_REG          0x32
87 #define RK808_BUCK2_ON_VSEL_REG         0x33
88 #define RK808_BUCK2_SLP_VSEL_REG        0x34
89 #define RK808_BUCK2_DVS_VSEL_REG        0x35
90 #define RK808_BUCK3_CONFIG_REG          0x36
91 #define RK808_BUCK4_CONFIG_REG          0x37
92 #define RK808_BUCK4_ON_VSEL_REG         0x38
93 #define RK808_BUCK4_SLP_VSEL_REG        0x39
94 #define RK808_BOOST_CONFIG_REG          0x3a
95 #define RK808_LDO1_ON_VSEL_REG          0x3b
96 #define RK808_LDO1_SLP_VSEL_REG         0x3c
97 #define RK808_LDO2_ON_VSEL_REG          0x3d
98 #define RK808_LDO2_SLP_VSEL_REG         0x3e
99 #define RK808_LDO3_ON_VSEL_REG          0x3f
100 #define RK808_LDO3_SLP_VSEL_REG         0x40
101 #define RK808_LDO4_ON_VSEL_REG          0x41
102 #define RK808_LDO4_SLP_VSEL_REG         0x42
103 #define RK808_LDO5_ON_VSEL_REG          0x43
104 #define RK808_LDO5_SLP_VSEL_REG         0x44
105 #define RK808_LDO6_ON_VSEL_REG          0x45
106 #define RK808_LDO6_SLP_VSEL_REG         0x46
107 #define RK808_LDO7_ON_VSEL_REG          0x47
108 #define RK808_LDO7_SLP_VSEL_REG         0x48
109 #define RK808_LDO8_ON_VSEL_REG          0x49
110 #define RK808_LDO8_SLP_VSEL_REG         0x4a
111 #define RK808_DEVCTRL_REG       0x4b
112 #define RK808_INT_STS_REG1      0x4c
113 #define RK808_INT_STS_MSK_REG1  0x4d
114 #define RK808_INT_STS_REG2      0x4e
115 #define RK808_INT_STS_MSK_REG2  0x4f
116 #define RK808_IO_POL_REG        0x50
117
118 /* IRQ Definitions */
119 #define RK808_IRQ_VOUT_LO       0
120 #define RK808_IRQ_VB_LO         1
121 #define RK808_IRQ_PWRON         2
122 #define RK808_IRQ_PWRON_LP      3
123 #define RK808_IRQ_HOTDIE        4
124 #define RK808_IRQ_RTC_ALARM     5
125 #define RK808_IRQ_RTC_PERIOD    6
126 #define RK808_IRQ_PLUG_IN_INT   7
127 #define RK808_IRQ_PLUG_OUT_INT  8
128 #define RK808_NUM_IRQ           9
129
130 #define RK808_IRQ_VOUT_LO_MSK           BIT(0)
131 #define RK808_IRQ_VB_LO_MSK             BIT(1)
132 #define RK808_IRQ_PWRON_MSK             BIT(2)
133 #define RK808_IRQ_PWRON_LP_MSK          BIT(3)
134 #define RK808_IRQ_HOTDIE_MSK            BIT(4)
135 #define RK808_IRQ_RTC_ALARM_MSK         BIT(5)
136 #define RK808_IRQ_RTC_PERIOD_MSK        BIT(6)
137 #define RK808_IRQ_PLUG_IN_INT_MSK       BIT(0)
138 #define RK808_IRQ_PLUG_OUT_INT_MSK      BIT(1)
139
140 #define RK808_VBAT_LOW_2V8      0x00
141 #define RK808_VBAT_LOW_2V9      0x01
142 #define RK808_VBAT_LOW_3V0      0x02
143 #define RK808_VBAT_LOW_3V1      0x03
144 #define RK808_VBAT_LOW_3V2      0x04
145 #define RK808_VBAT_LOW_3V3      0x05
146 #define RK808_VBAT_LOW_3V4      0x06
147 #define RK808_VBAT_LOW_3V5      0x07
148 #define VBAT_LOW_VOL_MASK       (0x07 << 0)
149 #define EN_VABT_LOW_SHUT_DOWN   (0x00 << 4)
150 #define EN_VBAT_LOW_IRQ         (0x1 << 4)
151 #define VBAT_LOW_ACT_MASK       (0x1 << 4)
152
153 #define BUCK_ILMIN_MASK         (7 << 0)
154 #define BOOST_ILMIN_MASK        (7 << 0)
155 #define BUCK1_RATE_MASK         (3 << 3)
156 #define BUCK2_RATE_MASK         (3 << 3)
157 #define MASK_ALL        0xff
158
159 #define BUCK_UV_ACT_MASK        0x0f
160 #define BUCK_UV_ACT_DISABLE     0
161
162 #define SWITCH2_EN      BIT(6)
163 #define SWITCH1_EN      BIT(5)
164 #define DEV_OFF_RST     BIT(3)
165
166 #define VB_LO_ACT               BIT(4)
167 #define VB_LO_SEL_3500MV        (7 << 0)
168
169 #define VOUT_LO_INT     BIT(0)
170 #define CLK32KOUT2_EN   BIT(0)
171
172 enum {
173         BUCK_ILMIN_50MA,
174         BUCK_ILMIN_100MA,
175         BUCK_ILMIN_150MA,
176         BUCK_ILMIN_200MA,
177         BUCK_ILMIN_250MA,
178         BUCK_ILMIN_300MA,
179         BUCK_ILMIN_350MA,
180         BUCK_ILMIN_400MA,
181 };
182
183 enum {
184         BOOST_ILMIN_75MA,
185         BOOST_ILMIN_100MA,
186         BOOST_ILMIN_125MA,
187         BOOST_ILMIN_150MA,
188         BOOST_ILMIN_175MA,
189         BOOST_ILMIN_200MA,
190         BOOST_ILMIN_225MA,
191         BOOST_ILMIN_250MA,
192 };
193
194 struct rk808 {
195         struct i2c_client *i2c;
196         struct regmap_irq_chip_data *irq_data;
197         struct regmap *regmap;
198 };
199 #endif /* __LINUX_REGULATOR_rk808_H */