1 /* include/linux/regulator/rk808.h
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.
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.
13 #ifndef __LINUX_REGULATOR_rk808_H
14 #define __LINUX_REGULATOR_rk808_H
16 #include <linux/regulator/machine.h>
17 #include <linux/wakelock.h>
18 #include <linux/regmap.h>
19 #ifdef CONFIG_HAS_EARLYSUSPEND
20 #include <linux/earlysuspend.h>
22 //#define RK808_START 30
24 #define RK808_DCDC1 0 //(0+RK808_START)
26 #define RK808_LDO1 4 //(4+RK808_START)
28 #define RK808_SECONDS_REG 0x00
29 #define RK808_MINUTES_REG 0x01
30 #define RK808_HOURS_REG 0x02
31 #define RK808_DAYS_REG 0x03
32 #define RK808_MONTHS_REG 0x04
33 #define RK808_YEARS_REG 0x05
34 #define RK808_WEEKS_REG 0x06
35 #define RK808_ALARM_SECONDS_REG 0x07
36 #define RK808_ALARM_MINUTES_REG 0x08
37 #define RK808_ALARM_HOURS_REG 0x09
38 #define RK808_ALARM_DAYS_REG 0x0a
39 #define RK808_ALARM_MONTHS_REG 0x0b
40 #define RK808_ALARM_YEARS_REG 0x0c
41 #define RK808_RTC_CTRL_REG 0x10
42 #define RK808_RTC_STATUS_REG 0x11
43 #define RK808_RTC_INT_REG 0x12
44 #define RK808_RTC_COMP_LSB_REG 0x13
45 #define RK808_RTC_COMP_MSB_REG 0x14
46 #define RK808_CLK32OUT_REG 0x20
47 #define RK808_VB_MON_REG 0x21
48 #define RK808_THERMAL_REG 0x22
49 #define RK808_DCDC_EN_REG 0x23
50 #define RK808_LDO_EN_REG 0x24
51 #define RK808_SLEEP_SET_OFF_REG1 0x25
52 #define RK808_SLEEP_SET_OFF_REG2 0x26
53 #define RK808_DCDC_UV_STS_REG 0x27
54 #define RK808_DCDC_UV_ACT_REG 0x28
55 #define RK808_LDO_UV_STS_REG 0x29
56 #define RK808_LDO_UV_ACT_REG 0x2a
57 #define RK808_DCDC_PG_REG 0x2b
58 #define RK808_LDO_PG_REG 0x2c
59 #define RK808_VOUT_MON_TDB_REG 0x2d
60 #define RK808_BUCK1_CONFIG_REG 0x2e
61 #define RK808_BUCK1_ON_REG 0x2f
62 #define RK808_BUCK1_SLP_REG 0x30
63 #define RK808_BUCK1_DVS_REG 0x31
64 #define RK808_BUCK2_CONFIG_REG 0x32
65 #define RK808_BUCK2_ON_REG 0x33
66 #define RK808_BUCK2_SLP_REG 0x34
67 #define RK808_BUCK2_DVS_REG 0x35
68 #define RK808_BUCK3_CONFIG_REG 0x36
69 #define RK808_BUCK4_CONFIG_REG 0x37
70 #define RK808_BUCK4_ON_REG 0x38
71 #define RK808_BUCK4_SLP_VSEL_REG 0x39
72 #define RK808_BOOST_CONFIG_REG 0x3a
73 #define RK808_LDO1_ON_VSEL_REG 0x3b
74 #define RK808_LDO1_SLP_VSEL_REG 0x3c
75 #define RK808_LDO2_ON_VSEL_REG 0x3d
76 #define RK808_LDO2_SLP_VSEL_REG 0x3e
77 #define RK808_LDO3_ON_VSEL_REG 0x3f
78 #define RK808_LDO3_SLP_VSEL_REG 0x40
79 #define RK808_LDO4_ON_VSEL_REG 0x41
80 #define RK808_LDO4_SLP_VSEL_REG 0x42
81 #define RK808_LDO5_ON_VSEL_REG 0x43
82 #define RK808_LDO5_SLP_VSEL_REG 0x44
83 #define RK808_LDO6_ON_VSEL_REG 0x45
84 #define RK808_LDO6_SLP_VSEL_REG 0x46
85 #define RK808_LDO7_ON_VSEL_REG 0x47
86 #define RK808_LDO7_SLP_VSEL_REG 0x48
87 #define RK808_LDO8_ON_VSEL_REG 0x49
88 #define RK808_LDO8_SLP_VSEL_REG 0x4a
89 #define RK808_DEVCTRL_REG 0x4b
90 #define RK808_INT_STS_REG1 0X4c
91 #define RK808_INT_STS_MSK_REG1 0X4d
92 #define RK808_INT_STS_REG2 0X4e
93 #define RK808_INT_STS_MSK_REG2 0X4f
94 #define RK808_IO_POL_REG 0X50
97 #define RK808_IRQ_VOUT_LO 0
98 #define RK808_IRQ_VB_LO 1
99 #define RK808_IRQ_PWRON 2
100 #define RK808_IRQ_PWRON_LP 3
101 #define RK808_IRQ_HOTDIE 4
102 #define RK808_IRQ_RTC_ALARM 5
103 #define RK808_IRQ_RTC_PERIOD 6
105 #define RK808_NUM_IRQ 9
107 #define rk808_NUM_REGULATORS 12
109 #define RK808_VBAT_LOW_2V8 0x00
110 #define RK808_VBAT_LOW_2V9 0x01
111 #define RK808_VBAT_LOW_3V0 0x02
112 #define RK808_VBAT_LOW_3V1 0x03
113 #define RK808_VBAT_LOW_3V2 0x04
114 #define RK808_VBAT_LOW_3V3 0x05
115 #define RK808_VBAT_LOW_3V4 0x06
116 #define RK808_VBAT_LOW_3V5 0x07
117 #define VBAT_LOW_VOL_MASK (0x07 << 0)
118 #define EN_VABT_LOW_SHUT_DOWN (0x00 << 4)
119 #define EN_VBAT_LOW_IRQ (0x1 <<4 )
120 #define VBAT_LOW_ACT_MASK (0x1 << 4)
129 struct regulator_init_data *rk808_init_data[rk808_NUM_REGULATORS];
130 struct device_node *of_node[rk808_NUM_REGULATORS];
131 int pmic_sleep_gpio; /* */
132 unsigned int dcdc_slp_voltage[3]; /* buckx_voltage in uV */
134 unsigned int ldo_slp_voltage[7];
137 struct rk808_regulator_subdev {
139 struct regulator_init_data *initdata;
144 struct mutex io_lock;
145 struct i2c_client *i2c;
147 struct regulator_dev **rdev;
148 struct wake_lock irq_wake;
149 // struct early_suspend rk808_suspend;
150 struct mutex irq_lock;
157 struct regmap *regmap;
158 struct irq_domain *irq_domain;
159 int (*read)(struct rk808 *rk808, u8 reg, int size, void *dest);
160 int (*write)(struct rk808 *rk808, u8 reg, int size, void *src);
161 int pmic_sleep_gpio; /* */
162 unsigned int dcdc_slp_voltage[3]; /* buckx_voltage in uV */
164 unsigned int ldo_slp_voltage[7];
167 struct rk808_platform_data {
169 struct rk808_regulator_subdev *regulators;
172 struct irq_domain *irq_domain;
175 int rk808_irq_init(struct rk808 *rk808, int irq,struct rk808_board *pdata);
176 int rk808_i2c_read(struct rk808 *rk808, char reg, int count,u8 *dest);
177 //int rk808_i2c_read(struct i2c_client *i2c, char reg, int count,u16 *dest);
178 // int rk808_i2c_read(struct rk808 *rk808 , u8 reg, int bytes,void *dest);
179 int rk808_i2c_write(struct rk808 *rk808, char reg, int count, const u8 src);
180 int rk808_set_bits(struct rk808 *rk808, u8 reg, u8 mask, u8 val);
181 int rk808_clear_bits(struct rk808 *rk808, u8 reg, u8 mask);
182 u8 rk808_reg_read(struct rk808 *rk808, u8 reg);
183 int rk808_reg_write(struct rk808 *rk808, u8 reg, u8 val);
184 int rk808_bulk_read(struct rk808 *rk808, u8 reg,
186 int rk808_bulk_write(struct rk808 *rk808, u8 reg,
188 int rk808_device_shutdown(void);