diff options
| author | Wadim Egorov <w.egorov@phytec.de> | 2016-08-29 07:07:58 -0400 |
|---|---|---|
| committer | Lee Jones <lee.jones@linaro.org> | 2016-08-31 08:48:25 -0400 |
| commit | 2eedcbfc0612c87e22c6325fde49ecf140e5873a (patch) | |
| tree | 9e638506f15d3e297f6f576785a60d9b6ded4c70 /include | |
| parent | 694d0d0bb2030d2e36df73e2d23d5770511dbc8d (diff) | |
mfd: rk808: Add RK818 support
The RK818 chip is a Power Management IC (PMIC) for multimedia and handheld
devices. It contains the following components:
- Regulators
- RTC
- Clocking
- Battery support
Both RK808 and RK818 chips are using a similar register map,
so we can reuse the RTC and Clocking functionality.
Signed-off-by: Wadim Egorov <w.egorov@phytec.de>
Tested-by: Andy Yan <andy.yan@rock-chips.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Diffstat (limited to 'include')
| -rw-r--r-- | include/linux/mfd/rk808.h | 154 |
1 files changed, 145 insertions, 9 deletions
diff --git a/include/linux/mfd/rk808.h b/include/linux/mfd/rk808.h index 441b6ee72691..fc5db6fcb57d 100644 --- a/include/linux/mfd/rk808.h +++ b/include/linux/mfd/rk808.h | |||
| @@ -1,11 +1,15 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * rk808.h for Rockchip RK808 | 2 | * Register definitions for Rockchip's RK808/RK818 PMIC |
| 3 | * | 3 | * |
| 4 | * Copyright (c) 2014, Fuzhou Rockchip Electronics Co., Ltd | 4 | * Copyright (c) 2014, Fuzhou Rockchip Electronics Co., Ltd |
| 5 | * | 5 | * |
| 6 | * Author: Chris Zhong <zyw@rock-chips.com> | 6 | * Author: Chris Zhong <zyw@rock-chips.com> |
| 7 | * Author: Zhang Qing <zhangqing@rock-chips.com> | 7 | * Author: Zhang Qing <zhangqing@rock-chips.com> |
| 8 | * | 8 | * |
| 9 | * Copyright (C) 2016 PHYTEC Messtechnik GmbH | ||
| 10 | * | ||
| 11 | * Author: Wadim Egorov <w.egorov@phytec.de> | ||
| 12 | * | ||
| 9 | * This program is free software; you can redistribute it and/or modify it | 13 | * 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, | 14 | * under the terms and conditions of the GNU General Public License, |
| 11 | * version 2, as published by the Free Software Foundation. | 15 | * version 2, as published by the Free Software Foundation. |
| @@ -16,8 +20,8 @@ | |||
| 16 | * more details. | 20 | * more details. |
| 17 | */ | 21 | */ |
| 18 | 22 | ||
| 19 | #ifndef __LINUX_REGULATOR_rk808_H | 23 | #ifndef __LINUX_REGULATOR_RK808_H |
| 20 | #define __LINUX_REGULATOR_rk808_H | 24 | #define __LINUX_REGULATOR_RK808_H |
| 21 | 25 | ||
| 22 | #include <linux/regulator/machine.h> | 26 | #include <linux/regulator/machine.h> |
| 23 | #include <linux/regmap.h> | 27 | #include <linux/regmap.h> |
| @@ -28,7 +32,7 @@ | |||
| 28 | 32 | ||
| 29 | #define RK808_DCDC1 0 /* (0+RK808_START) */ | 33 | #define RK808_DCDC1 0 /* (0+RK808_START) */ |
| 30 | #define RK808_LDO1 4 /* (4+RK808_START) */ | 34 | #define RK808_LDO1 4 /* (4+RK808_START) */ |
| 31 | #define RK808_NUM_REGULATORS 14 | 35 | #define RK808_NUM_REGULATORS 14 |
| 32 | 36 | ||
| 33 | enum rk808_reg { | 37 | enum rk808_reg { |
| 34 | RK808_ID_DCDC1, | 38 | RK808_ID_DCDC1, |
| @@ -65,6 +69,8 @@ enum rk808_reg { | |||
| 65 | #define RK808_RTC_INT_REG 0x12 | 69 | #define RK808_RTC_INT_REG 0x12 |
| 66 | #define RK808_RTC_COMP_LSB_REG 0x13 | 70 | #define RK808_RTC_COMP_LSB_REG 0x13 |
| 67 | #define RK808_RTC_COMP_MSB_REG 0x14 | 71 | #define RK808_RTC_COMP_MSB_REG 0x14 |
| 72 | #define RK808_ID_MSB 0x17 | ||
| 73 | #define RK808_ID_LSB 0x18 | ||
| 68 | #define RK808_CLK32OUT_REG 0x20 | 74 | #define RK808_CLK32OUT_REG 0x20 |
| 69 | #define RK808_VB_MON_REG 0x21 | 75 | #define RK808_VB_MON_REG 0x21 |
| 70 | #define RK808_THERMAL_REG 0x22 | 76 | #define RK808_THERMAL_REG 0x22 |
| @@ -115,7 +121,92 @@ enum rk808_reg { | |||
| 115 | #define RK808_INT_STS_MSK_REG2 0x4f | 121 | #define RK808_INT_STS_MSK_REG2 0x4f |
| 116 | #define RK808_IO_POL_REG 0x50 | 122 | #define RK808_IO_POL_REG 0x50 |
| 117 | 123 | ||
| 118 | /* IRQ Definitions */ | 124 | /* RK818 */ |
| 125 | #define RK818_DCDC1 0 | ||
| 126 | #define RK818_LDO1 4 | ||
| 127 | #define RK818_NUM_REGULATORS 17 | ||
| 128 | |||
| 129 | enum rk818_reg { | ||
| 130 | RK818_ID_DCDC1, | ||
| 131 | RK818_ID_DCDC2, | ||
| 132 | RK818_ID_DCDC3, | ||
| 133 | RK818_ID_DCDC4, | ||
| 134 | RK818_ID_BOOST, | ||
| 135 | RK818_ID_LDO1, | ||
| 136 | RK818_ID_LDO2, | ||
| 137 | RK818_ID_LDO3, | ||
| 138 | RK818_ID_LDO4, | ||
| 139 | RK818_ID_LDO5, | ||
| 140 | RK818_ID_LDO6, | ||
| 141 | RK818_ID_LDO7, | ||
| 142 | RK818_ID_LDO8, | ||
| 143 | RK818_ID_LDO9, | ||
| 144 | RK818_ID_SWITCH, | ||
| 145 | RK818_ID_HDMI_SWITCH, | ||
| 146 | RK818_ID_OTG_SWITCH, | ||
| 147 | }; | ||
| 148 | |||
| 149 | #define RK818_DCDC_EN_REG 0x23 | ||
| 150 | #define RK818_LDO_EN_REG 0x24 | ||
| 151 | #define RK818_SLEEP_SET_OFF_REG1 0x25 | ||
| 152 | #define RK818_SLEEP_SET_OFF_REG2 0x26 | ||
| 153 | #define RK818_DCDC_UV_STS_REG 0x27 | ||
| 154 | #define RK818_DCDC_UV_ACT_REG 0x28 | ||
| 155 | #define RK818_LDO_UV_STS_REG 0x29 | ||
| 156 | #define RK818_LDO_UV_ACT_REG 0x2a | ||
| 157 | #define RK818_DCDC_PG_REG 0x2b | ||
| 158 | #define RK818_LDO_PG_REG 0x2c | ||
| 159 | #define RK818_VOUT_MON_TDB_REG 0x2d | ||
| 160 | #define RK818_BUCK1_CONFIG_REG 0x2e | ||
| 161 | #define RK818_BUCK1_ON_VSEL_REG 0x2f | ||
| 162 | #define RK818_BUCK1_SLP_VSEL_REG 0x30 | ||
| 163 | #define RK818_BUCK2_CONFIG_REG 0x32 | ||
| 164 | #define RK818_BUCK2_ON_VSEL_REG 0x33 | ||
| 165 | #define RK818_BUCK2_SLP_VSEL_REG 0x34 | ||
| 166 | #define RK818_BUCK3_CONFIG_REG 0x36 | ||
| 167 | #define RK818_BUCK4_CONFIG_REG 0x37 | ||
| 168 | #define RK818_BUCK4_ON_VSEL_REG 0x38 | ||
| 169 | #define RK818_BUCK4_SLP_VSEL_REG 0x39 | ||
| 170 | #define RK818_BOOST_CONFIG_REG 0x3a | ||
| 171 | #define RK818_LDO1_ON_VSEL_REG 0x3b | ||
| 172 | #define RK818_LDO1_SLP_VSEL_REG 0x3c | ||
| 173 | #define RK818_LDO2_ON_VSEL_REG 0x3d | ||
| 174 | #define RK818_LDO2_SLP_VSEL_REG 0x3e | ||
| 175 | #define RK818_LDO3_ON_VSEL_REG 0x3f | ||
| 176 | #define RK818_LDO3_SLP_VSEL_REG 0x40 | ||
| 177 | #define RK818_LDO4_ON_VSEL_REG 0x41 | ||
| 178 | #define RK818_LDO4_SLP_VSEL_REG 0x42 | ||
| 179 | #define RK818_LDO5_ON_VSEL_REG 0x43 | ||
| 180 | #define RK818_LDO5_SLP_VSEL_REG 0x44 | ||
| 181 | #define RK818_LDO6_ON_VSEL_REG 0x45 | ||
| 182 | #define RK818_LDO6_SLP_VSEL_REG 0x46 | ||
| 183 | #define RK818_LDO7_ON_VSEL_REG 0x47 | ||
| 184 | #define RK818_LDO7_SLP_VSEL_REG 0x48 | ||
| 185 | #define RK818_LDO8_ON_VSEL_REG 0x49 | ||
| 186 | #define RK818_LDO8_SLP_VSEL_REG 0x4a | ||
| 187 | #define RK818_BOOST_LDO9_ON_VSEL_REG 0x54 | ||
| 188 | #define RK818_BOOST_LDO9_SLP_VSEL_REG 0x55 | ||
| 189 | #define RK818_DEVCTRL_REG 0x4b | ||
| 190 | #define RK818_INT_STS_REG1 0X4c | ||
| 191 | #define RK818_INT_STS_MSK_REG1 0x4d | ||
| 192 | #define RK818_INT_STS_REG2 0x4e | ||
| 193 | #define RK818_INT_STS_MSK_REG2 0x4f | ||
| 194 | #define RK818_IO_POL_REG 0x50 | ||
| 195 | #define RK818_H5V_EN_REG 0x52 | ||
| 196 | #define RK818_SLEEP_SET_OFF_REG3 0x53 | ||
| 197 | #define RK818_BOOST_LDO9_ON_VSEL_REG 0x54 | ||
| 198 | #define RK818_BOOST_LDO9_SLP_VSEL_REG 0x55 | ||
| 199 | #define RK818_BOOST_CTRL_REG 0x56 | ||
| 200 | #define RK818_DCDC_ILMAX 0x90 | ||
| 201 | #define RK818_USB_CTRL_REG 0xa1 | ||
| 202 | |||
| 203 | #define RK818_H5V_EN BIT(0) | ||
| 204 | #define RK818_REF_RDY_CTRL BIT(1) | ||
| 205 | #define RK818_USB_ILIM_SEL_MASK 0xf | ||
| 206 | #define RK818_USB_ILMIN_2000MA 0x7 | ||
| 207 | #define RK818_USB_CHG_SD_VSEL_MASK 0x70 | ||
| 208 | |||
| 209 | /* RK808 IRQ Definitions */ | ||
| 119 | #define RK808_IRQ_VOUT_LO 0 | 210 | #define RK808_IRQ_VOUT_LO 0 |
| 120 | #define RK808_IRQ_VB_LO 1 | 211 | #define RK808_IRQ_VB_LO 1 |
| 121 | #define RK808_IRQ_PWRON 2 | 212 | #define RK808_IRQ_PWRON 2 |
| @@ -137,6 +228,43 @@ enum rk808_reg { | |||
| 137 | #define RK808_IRQ_PLUG_IN_INT_MSK BIT(0) | 228 | #define RK808_IRQ_PLUG_IN_INT_MSK BIT(0) |
| 138 | #define RK808_IRQ_PLUG_OUT_INT_MSK BIT(1) | 229 | #define RK808_IRQ_PLUG_OUT_INT_MSK BIT(1) |
| 139 | 230 | ||
| 231 | /* RK818 IRQ Definitions */ | ||
| 232 | #define RK818_IRQ_VOUT_LO 0 | ||
| 233 | #define RK818_IRQ_VB_LO 1 | ||
| 234 | #define RK818_IRQ_PWRON 2 | ||
| 235 | #define RK818_IRQ_PWRON_LP 3 | ||
| 236 | #define RK818_IRQ_HOTDIE 4 | ||
| 237 | #define RK818_IRQ_RTC_ALARM 5 | ||
| 238 | #define RK818_IRQ_RTC_PERIOD 6 | ||
| 239 | #define RK818_IRQ_USB_OV 7 | ||
| 240 | #define RK818_IRQ_PLUG_IN 8 | ||
| 241 | #define RK818_IRQ_PLUG_OUT 9 | ||
| 242 | #define RK818_IRQ_CHG_OK 10 | ||
| 243 | #define RK818_IRQ_CHG_TE 11 | ||
| 244 | #define RK818_IRQ_CHG_TS1 12 | ||
| 245 | #define RK818_IRQ_TS2 13 | ||
| 246 | #define RK818_IRQ_CHG_CVTLIM 14 | ||
| 247 | #define RK818_IRQ_DISCHG_ILIM 7 | ||
| 248 | |||
| 249 | #define RK818_IRQ_VOUT_LO_MSK BIT(0) | ||
| 250 | #define RK818_IRQ_VB_LO_MSK BIT(1) | ||
| 251 | #define RK818_IRQ_PWRON_MSK BIT(2) | ||
| 252 | #define RK818_IRQ_PWRON_LP_MSK BIT(3) | ||
| 253 | #define RK818_IRQ_HOTDIE_MSK BIT(4) | ||
| 254 | #define RK818_IRQ_RTC_ALARM_MSK BIT(5) | ||
| 255 | #define RK818_IRQ_RTC_PERIOD_MSK BIT(6) | ||
| 256 | #define RK818_IRQ_USB_OV_MSK BIT(7) | ||
| 257 | #define RK818_IRQ_PLUG_IN_MSK BIT(0) | ||
| 258 | #define RK818_IRQ_PLUG_OUT_MSK BIT(1) | ||
| 259 | #define RK818_IRQ_CHG_OK_MSK BIT(2) | ||
| 260 | #define RK818_IRQ_CHG_TE_MSK BIT(3) | ||
| 261 | #define RK818_IRQ_CHG_TS1_MSK BIT(4) | ||
| 262 | #define RK818_IRQ_TS2_MSK BIT(5) | ||
| 263 | #define RK818_IRQ_CHG_CVTLIM_MSK BIT(6) | ||
| 264 | #define RK818_IRQ_DISCHG_ILIM_MSK BIT(7) | ||
| 265 | |||
| 266 | #define RK818_NUM_IRQ 16 | ||
| 267 | |||
| 140 | #define RK808_VBAT_LOW_2V8 0x00 | 268 | #define RK808_VBAT_LOW_2V8 0x00 |
| 141 | #define RK808_VBAT_LOW_2V9 0x01 | 269 | #define RK808_VBAT_LOW_2V9 0x01 |
| 142 | #define RK808_VBAT_LOW_3V0 0x02 | 270 | #define RK808_VBAT_LOW_3V0 0x02 |
| @@ -191,9 +319,17 @@ enum { | |||
| 191 | BOOST_ILMIN_250MA, | 319 | BOOST_ILMIN_250MA, |
| 192 | }; | 320 | }; |
| 193 | 321 | ||
| 322 | enum { | ||
| 323 | RK808_ID = 0x0000, | ||
| 324 | RK818_ID = 0x8181, | ||
| 325 | }; | ||
| 326 | |||
| 194 | struct rk808 { | 327 | struct rk808 { |
| 195 | struct i2c_client *i2c; | 328 | struct i2c_client *i2c; |
| 196 | struct regmap_irq_chip_data *irq_data; | 329 | struct regmap_irq_chip_data *irq_data; |
| 197 | struct regmap *regmap; | 330 | struct regmap *regmap; |
| 331 | long variant; | ||
| 332 | const struct regmap_config *regmap_cfg; | ||
| 333 | const struct regmap_irq_chip *regmap_irq_chip; | ||
| 198 | }; | 334 | }; |
| 199 | #endif /* __LINUX_REGULATOR_rk808_H */ | 335 | #endif /* __LINUX_REGULATOR_RK808_H */ |
