Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Register definitions for Rockchip's RK808/RK818 PMIC
0004  *
0005  * Copyright (c) 2014, Fuzhou Rockchip Electronics Co., Ltd
0006  *
0007  * Author: Chris Zhong <zyw@rock-chips.com>
0008  * Author: Zhang Qing <zhangqing@rock-chips.com>
0009  *
0010  * Copyright (C) 2016 PHYTEC Messtechnik GmbH
0011  *
0012  * Author: Wadim Egorov <w.egorov@phytec.de>
0013  */
0014 
0015 #ifndef __LINUX_REGULATOR_RK808_H
0016 #define __LINUX_REGULATOR_RK808_H
0017 
0018 #include <linux/regulator/machine.h>
0019 #include <linux/regmap.h>
0020 
0021 /*
0022  * rk808 Global Register Map.
0023  */
0024 
0025 #define RK808_DCDC1 0 /* (0+RK808_START) */
0026 #define RK808_LDO1  4 /* (4+RK808_START) */
0027 #define RK808_NUM_REGULATORS    14
0028 
0029 enum rk808_reg {
0030     RK808_ID_DCDC1,
0031     RK808_ID_DCDC2,
0032     RK808_ID_DCDC3,
0033     RK808_ID_DCDC4,
0034     RK808_ID_LDO1,
0035     RK808_ID_LDO2,
0036     RK808_ID_LDO3,
0037     RK808_ID_LDO4,
0038     RK808_ID_LDO5,
0039     RK808_ID_LDO6,
0040     RK808_ID_LDO7,
0041     RK808_ID_LDO8,
0042     RK808_ID_SWITCH1,
0043     RK808_ID_SWITCH2,
0044 };
0045 
0046 #define RK808_SECONDS_REG   0x00
0047 #define RK808_MINUTES_REG   0x01
0048 #define RK808_HOURS_REG     0x02
0049 #define RK808_DAYS_REG      0x03
0050 #define RK808_MONTHS_REG    0x04
0051 #define RK808_YEARS_REG     0x05
0052 #define RK808_WEEKS_REG     0x06
0053 #define RK808_ALARM_SECONDS_REG 0x08
0054 #define RK808_ALARM_MINUTES_REG 0x09
0055 #define RK808_ALARM_HOURS_REG   0x0a
0056 #define RK808_ALARM_DAYS_REG    0x0b
0057 #define RK808_ALARM_MONTHS_REG  0x0c
0058 #define RK808_ALARM_YEARS_REG   0x0d
0059 #define RK808_RTC_CTRL_REG  0x10
0060 #define RK808_RTC_STATUS_REG    0x11
0061 #define RK808_RTC_INT_REG   0x12
0062 #define RK808_RTC_COMP_LSB_REG  0x13
0063 #define RK808_RTC_COMP_MSB_REG  0x14
0064 #define RK808_ID_MSB        0x17
0065 #define RK808_ID_LSB        0x18
0066 #define RK808_CLK32OUT_REG  0x20
0067 #define RK808_VB_MON_REG    0x21
0068 #define RK808_THERMAL_REG   0x22
0069 #define RK808_DCDC_EN_REG   0x23
0070 #define RK808_LDO_EN_REG    0x24
0071 #define RK808_SLEEP_SET_OFF_REG1    0x25
0072 #define RK808_SLEEP_SET_OFF_REG2    0x26
0073 #define RK808_DCDC_UV_STS_REG   0x27
0074 #define RK808_DCDC_UV_ACT_REG   0x28
0075 #define RK808_LDO_UV_STS_REG    0x29
0076 #define RK808_LDO_UV_ACT_REG    0x2a
0077 #define RK808_DCDC_PG_REG   0x2b
0078 #define RK808_LDO_PG_REG    0x2c
0079 #define RK808_VOUT_MON_TDB_REG  0x2d
0080 #define RK808_BUCK1_CONFIG_REG      0x2e
0081 #define RK808_BUCK1_ON_VSEL_REG     0x2f
0082 #define RK808_BUCK1_SLP_VSEL_REG    0x30
0083 #define RK808_BUCK1_DVS_VSEL_REG    0x31
0084 #define RK808_BUCK2_CONFIG_REG      0x32
0085 #define RK808_BUCK2_ON_VSEL_REG     0x33
0086 #define RK808_BUCK2_SLP_VSEL_REG    0x34
0087 #define RK808_BUCK2_DVS_VSEL_REG    0x35
0088 #define RK808_BUCK3_CONFIG_REG      0x36
0089 #define RK808_BUCK4_CONFIG_REG      0x37
0090 #define RK808_BUCK4_ON_VSEL_REG     0x38
0091 #define RK808_BUCK4_SLP_VSEL_REG    0x39
0092 #define RK808_BOOST_CONFIG_REG      0x3a
0093 #define RK808_LDO1_ON_VSEL_REG      0x3b
0094 #define RK808_LDO1_SLP_VSEL_REG     0x3c
0095 #define RK808_LDO2_ON_VSEL_REG      0x3d
0096 #define RK808_LDO2_SLP_VSEL_REG     0x3e
0097 #define RK808_LDO3_ON_VSEL_REG      0x3f
0098 #define RK808_LDO3_SLP_VSEL_REG     0x40
0099 #define RK808_LDO4_ON_VSEL_REG      0x41
0100 #define RK808_LDO4_SLP_VSEL_REG     0x42
0101 #define RK808_LDO5_ON_VSEL_REG      0x43
0102 #define RK808_LDO5_SLP_VSEL_REG     0x44
0103 #define RK808_LDO6_ON_VSEL_REG      0x45
0104 #define RK808_LDO6_SLP_VSEL_REG     0x46
0105 #define RK808_LDO7_ON_VSEL_REG      0x47
0106 #define RK808_LDO7_SLP_VSEL_REG     0x48
0107 #define RK808_LDO8_ON_VSEL_REG      0x49
0108 #define RK808_LDO8_SLP_VSEL_REG     0x4a
0109 #define RK808_DEVCTRL_REG   0x4b
0110 #define RK808_INT_STS_REG1  0x4c
0111 #define RK808_INT_STS_MSK_REG1  0x4d
0112 #define RK808_INT_STS_REG2  0x4e
0113 #define RK808_INT_STS_MSK_REG2  0x4f
0114 #define RK808_IO_POL_REG    0x50
0115 
0116 /* RK818 */
0117 #define RK818_DCDC1         0
0118 #define RK818_LDO1          4
0119 #define RK818_NUM_REGULATORS        17
0120 
0121 enum rk818_reg {
0122     RK818_ID_DCDC1,
0123     RK818_ID_DCDC2,
0124     RK818_ID_DCDC3,
0125     RK818_ID_DCDC4,
0126     RK818_ID_BOOST,
0127     RK818_ID_LDO1,
0128     RK818_ID_LDO2,
0129     RK818_ID_LDO3,
0130     RK818_ID_LDO4,
0131     RK818_ID_LDO5,
0132     RK818_ID_LDO6,
0133     RK818_ID_LDO7,
0134     RK818_ID_LDO8,
0135     RK818_ID_LDO9,
0136     RK818_ID_SWITCH,
0137     RK818_ID_HDMI_SWITCH,
0138     RK818_ID_OTG_SWITCH,
0139 };
0140 
0141 #define RK818_DCDC_EN_REG       0x23
0142 #define RK818_LDO_EN_REG        0x24
0143 #define RK818_SLEEP_SET_OFF_REG1    0x25
0144 #define RK818_SLEEP_SET_OFF_REG2    0x26
0145 #define RK818_DCDC_UV_STS_REG       0x27
0146 #define RK818_DCDC_UV_ACT_REG       0x28
0147 #define RK818_LDO_UV_STS_REG        0x29
0148 #define RK818_LDO_UV_ACT_REG        0x2a
0149 #define RK818_DCDC_PG_REG       0x2b
0150 #define RK818_LDO_PG_REG        0x2c
0151 #define RK818_VOUT_MON_TDB_REG      0x2d
0152 #define RK818_BUCK1_CONFIG_REG      0x2e
0153 #define RK818_BUCK1_ON_VSEL_REG     0x2f
0154 #define RK818_BUCK1_SLP_VSEL_REG    0x30
0155 #define RK818_BUCK2_CONFIG_REG      0x32
0156 #define RK818_BUCK2_ON_VSEL_REG     0x33
0157 #define RK818_BUCK2_SLP_VSEL_REG    0x34
0158 #define RK818_BUCK3_CONFIG_REG      0x36
0159 #define RK818_BUCK4_CONFIG_REG      0x37
0160 #define RK818_BUCK4_ON_VSEL_REG     0x38
0161 #define RK818_BUCK4_SLP_VSEL_REG    0x39
0162 #define RK818_BOOST_CONFIG_REG      0x3a
0163 #define RK818_LDO1_ON_VSEL_REG      0x3b
0164 #define RK818_LDO1_SLP_VSEL_REG     0x3c
0165 #define RK818_LDO2_ON_VSEL_REG      0x3d
0166 #define RK818_LDO2_SLP_VSEL_REG     0x3e
0167 #define RK818_LDO3_ON_VSEL_REG      0x3f
0168 #define RK818_LDO3_SLP_VSEL_REG     0x40
0169 #define RK818_LDO4_ON_VSEL_REG      0x41
0170 #define RK818_LDO4_SLP_VSEL_REG     0x42
0171 #define RK818_LDO5_ON_VSEL_REG      0x43
0172 #define RK818_LDO5_SLP_VSEL_REG     0x44
0173 #define RK818_LDO6_ON_VSEL_REG      0x45
0174 #define RK818_LDO6_SLP_VSEL_REG     0x46
0175 #define RK818_LDO7_ON_VSEL_REG      0x47
0176 #define RK818_LDO7_SLP_VSEL_REG     0x48
0177 #define RK818_LDO8_ON_VSEL_REG      0x49
0178 #define RK818_LDO8_SLP_VSEL_REG     0x4a
0179 #define RK818_BOOST_LDO9_ON_VSEL_REG    0x54
0180 #define RK818_BOOST_LDO9_SLP_VSEL_REG   0x55
0181 #define RK818_DEVCTRL_REG       0x4b
0182 #define RK818_INT_STS_REG1      0X4c
0183 #define RK818_INT_STS_MSK_REG1      0x4d
0184 #define RK818_INT_STS_REG2      0x4e
0185 #define RK818_INT_STS_MSK_REG2      0x4f
0186 #define RK818_IO_POL_REG        0x50
0187 #define RK818_H5V_EN_REG        0x52
0188 #define RK818_SLEEP_SET_OFF_REG3    0x53
0189 #define RK818_BOOST_LDO9_ON_VSEL_REG    0x54
0190 #define RK818_BOOST_LDO9_SLP_VSEL_REG   0x55
0191 #define RK818_BOOST_CTRL_REG        0x56
0192 #define RK818_DCDC_ILMAX        0x90
0193 #define RK818_USB_CTRL_REG      0xa1
0194 
0195 #define RK818_H5V_EN            BIT(0)
0196 #define RK818_REF_RDY_CTRL      BIT(1)
0197 #define RK818_USB_ILIM_SEL_MASK     0xf
0198 #define RK818_USB_ILMIN_2000MA      0x7
0199 #define RK818_USB_CHG_SD_VSEL_MASK  0x70
0200 
0201 /* RK805 */
0202 enum rk805_reg {
0203     RK805_ID_DCDC1,
0204     RK805_ID_DCDC2,
0205     RK805_ID_DCDC3,
0206     RK805_ID_DCDC4,
0207     RK805_ID_LDO1,
0208     RK805_ID_LDO2,
0209     RK805_ID_LDO3,
0210 };
0211 
0212 /* CONFIG REGISTER */
0213 #define RK805_VB_MON_REG        0x21
0214 #define RK805_THERMAL_REG       0x22
0215 
0216 /* POWER CHANNELS ENABLE REGISTER */
0217 #define RK805_DCDC_EN_REG       0x23
0218 #define RK805_SLP_DCDC_EN_REG       0x25
0219 #define RK805_SLP_LDO_EN_REG        0x26
0220 #define RK805_LDO_EN_REG        0x27
0221 
0222 /* BUCK AND LDO CONFIG REGISTER */
0223 #define RK805_BUCK_LDO_SLP_LP_EN_REG    0x2A
0224 #define RK805_BUCK1_CONFIG_REG      0x2E
0225 #define RK805_BUCK1_ON_VSEL_REG     0x2F
0226 #define RK805_BUCK1_SLP_VSEL_REG    0x30
0227 #define RK805_BUCK2_CONFIG_REG      0x32
0228 #define RK805_BUCK2_ON_VSEL_REG     0x33
0229 #define RK805_BUCK2_SLP_VSEL_REG    0x34
0230 #define RK805_BUCK3_CONFIG_REG      0x36
0231 #define RK805_BUCK4_CONFIG_REG      0x37
0232 #define RK805_BUCK4_ON_VSEL_REG     0x38
0233 #define RK805_BUCK4_SLP_VSEL_REG    0x39
0234 #define RK805_LDO1_ON_VSEL_REG      0x3B
0235 #define RK805_LDO1_SLP_VSEL_REG     0x3C
0236 #define RK805_LDO2_ON_VSEL_REG      0x3D
0237 #define RK805_LDO2_SLP_VSEL_REG     0x3E
0238 #define RK805_LDO3_ON_VSEL_REG      0x3F
0239 #define RK805_LDO3_SLP_VSEL_REG     0x40
0240 
0241 /* INTERRUPT REGISTER */
0242 #define RK805_PWRON_LP_INT_TIME_REG 0x47
0243 #define RK805_PWRON_DB_REG      0x48
0244 #define RK805_DEV_CTRL_REG      0x4B
0245 #define RK805_INT_STS_REG       0x4C
0246 #define RK805_INT_STS_MSK_REG       0x4D
0247 #define RK805_GPIO_IO_POL_REG       0x50
0248 #define RK805_OUT_REG           0x52
0249 #define RK805_ON_SOURCE_REG     0xAE
0250 #define RK805_OFF_SOURCE_REG        0xAF
0251 
0252 #define RK805_NUM_REGULATORS        7
0253 
0254 #define RK805_PWRON_FALL_RISE_INT_EN    0x0
0255 #define RK805_PWRON_FALL_RISE_INT_MSK   0x81
0256 
0257 /* RK805 IRQ Definitions */
0258 #define RK805_IRQ_PWRON_RISE        0
0259 #define RK805_IRQ_VB_LOW        1
0260 #define RK805_IRQ_PWRON         2
0261 #define RK805_IRQ_PWRON_LP      3
0262 #define RK805_IRQ_HOTDIE        4
0263 #define RK805_IRQ_RTC_ALARM     5
0264 #define RK805_IRQ_RTC_PERIOD        6
0265 #define RK805_IRQ_PWRON_FALL        7
0266 
0267 #define RK805_IRQ_PWRON_RISE_MSK    BIT(0)
0268 #define RK805_IRQ_VB_LOW_MSK        BIT(1)
0269 #define RK805_IRQ_PWRON_MSK     BIT(2)
0270 #define RK805_IRQ_PWRON_LP_MSK      BIT(3)
0271 #define RK805_IRQ_HOTDIE_MSK        BIT(4)
0272 #define RK805_IRQ_RTC_ALARM_MSK     BIT(5)
0273 #define RK805_IRQ_RTC_PERIOD_MSK    BIT(6)
0274 #define RK805_IRQ_PWRON_FALL_MSK    BIT(7)
0275 
0276 #define RK805_PWR_RISE_INT_STATUS   BIT(0)
0277 #define RK805_VB_LOW_INT_STATUS     BIT(1)
0278 #define RK805_PWRON_INT_STATUS      BIT(2)
0279 #define RK805_PWRON_LP_INT_STATUS   BIT(3)
0280 #define RK805_HOTDIE_INT_STATUS     BIT(4)
0281 #define RK805_ALARM_INT_STATUS      BIT(5)
0282 #define RK805_PERIOD_INT_STATUS     BIT(6)
0283 #define RK805_PWR_FALL_INT_STATUS   BIT(7)
0284 
0285 #define RK805_BUCK1_2_ILMAX_MASK    (3 << 6)
0286 #define RK805_BUCK3_4_ILMAX_MASK        (3 << 3)
0287 #define RK805_RTC_PERIOD_INT_MASK   (1 << 6)
0288 #define RK805_RTC_ALARM_INT_MASK    (1 << 5)
0289 #define RK805_INT_ALARM_EN      (1 << 3)
0290 #define RK805_INT_TIMER_EN      (1 << 2)
0291 
0292 /* RK808 IRQ Definitions */
0293 #define RK808_IRQ_VOUT_LO   0
0294 #define RK808_IRQ_VB_LO     1
0295 #define RK808_IRQ_PWRON     2
0296 #define RK808_IRQ_PWRON_LP  3
0297 #define RK808_IRQ_HOTDIE    4
0298 #define RK808_IRQ_RTC_ALARM 5
0299 #define RK808_IRQ_RTC_PERIOD    6
0300 #define RK808_IRQ_PLUG_IN_INT   7
0301 #define RK808_IRQ_PLUG_OUT_INT  8
0302 #define RK808_NUM_IRQ       9
0303 
0304 #define RK808_IRQ_VOUT_LO_MSK       BIT(0)
0305 #define RK808_IRQ_VB_LO_MSK     BIT(1)
0306 #define RK808_IRQ_PWRON_MSK     BIT(2)
0307 #define RK808_IRQ_PWRON_LP_MSK      BIT(3)
0308 #define RK808_IRQ_HOTDIE_MSK        BIT(4)
0309 #define RK808_IRQ_RTC_ALARM_MSK     BIT(5)
0310 #define RK808_IRQ_RTC_PERIOD_MSK    BIT(6)
0311 #define RK808_IRQ_PLUG_IN_INT_MSK   BIT(0)
0312 #define RK808_IRQ_PLUG_OUT_INT_MSK  BIT(1)
0313 
0314 /* RK818 IRQ Definitions */
0315 #define RK818_IRQ_VOUT_LO   0
0316 #define RK818_IRQ_VB_LO     1
0317 #define RK818_IRQ_PWRON     2
0318 #define RK818_IRQ_PWRON_LP  3
0319 #define RK818_IRQ_HOTDIE    4
0320 #define RK818_IRQ_RTC_ALARM 5
0321 #define RK818_IRQ_RTC_PERIOD    6
0322 #define RK818_IRQ_USB_OV    7
0323 #define RK818_IRQ_PLUG_IN   8
0324 #define RK818_IRQ_PLUG_OUT  9
0325 #define RK818_IRQ_CHG_OK    10
0326 #define RK818_IRQ_CHG_TE    11
0327 #define RK818_IRQ_CHG_TS1   12
0328 #define RK818_IRQ_TS2       13
0329 #define RK818_IRQ_CHG_CVTLIM    14
0330 #define RK818_IRQ_DISCHG_ILIM   15
0331 
0332 #define RK818_IRQ_VOUT_LO_MSK       BIT(0)
0333 #define RK818_IRQ_VB_LO_MSK     BIT(1)
0334 #define RK818_IRQ_PWRON_MSK     BIT(2)
0335 #define RK818_IRQ_PWRON_LP_MSK      BIT(3)
0336 #define RK818_IRQ_HOTDIE_MSK        BIT(4)
0337 #define RK818_IRQ_RTC_ALARM_MSK     BIT(5)
0338 #define RK818_IRQ_RTC_PERIOD_MSK    BIT(6)
0339 #define RK818_IRQ_USB_OV_MSK        BIT(7)
0340 #define RK818_IRQ_PLUG_IN_MSK       BIT(0)
0341 #define RK818_IRQ_PLUG_OUT_MSK      BIT(1)
0342 #define RK818_IRQ_CHG_OK_MSK        BIT(2)
0343 #define RK818_IRQ_CHG_TE_MSK        BIT(3)
0344 #define RK818_IRQ_CHG_TS1_MSK       BIT(4)
0345 #define RK818_IRQ_TS2_MSK       BIT(5)
0346 #define RK818_IRQ_CHG_CVTLIM_MSK    BIT(6)
0347 #define RK818_IRQ_DISCHG_ILIM_MSK   BIT(7)
0348 
0349 #define RK818_NUM_IRQ       16
0350 
0351 #define RK808_VBAT_LOW_2V8  0x00
0352 #define RK808_VBAT_LOW_2V9  0x01
0353 #define RK808_VBAT_LOW_3V0  0x02
0354 #define RK808_VBAT_LOW_3V1  0x03
0355 #define RK808_VBAT_LOW_3V2  0x04
0356 #define RK808_VBAT_LOW_3V3  0x05
0357 #define RK808_VBAT_LOW_3V4  0x06
0358 #define RK808_VBAT_LOW_3V5  0x07
0359 #define VBAT_LOW_VOL_MASK   (0x07 << 0)
0360 #define EN_VABT_LOW_SHUT_DOWN   (0x00 << 4)
0361 #define EN_VBAT_LOW_IRQ     (0x1 << 4)
0362 #define VBAT_LOW_ACT_MASK   (0x1 << 4)
0363 
0364 #define BUCK_ILMIN_MASK     (7 << 0)
0365 #define BOOST_ILMIN_MASK    (7 << 0)
0366 #define BUCK1_RATE_MASK     (3 << 3)
0367 #define BUCK2_RATE_MASK     (3 << 3)
0368 #define MASK_ALL    0xff
0369 
0370 #define BUCK_UV_ACT_MASK    0x0f
0371 #define BUCK_UV_ACT_DISABLE 0
0372 
0373 #define SWITCH2_EN  BIT(6)
0374 #define SWITCH1_EN  BIT(5)
0375 #define DEV_OFF_RST BIT(3)
0376 #define DEV_RST     BIT(2)
0377 #define DEV_OFF     BIT(0)
0378 #define RTC_STOP    BIT(0)
0379 
0380 #define VB_LO_ACT       BIT(4)
0381 #define VB_LO_SEL_3500MV    (7 << 0)
0382 
0383 #define VOUT_LO_INT BIT(0)
0384 #define CLK32KOUT2_EN   BIT(0)
0385 
0386 #define TEMP115C            0x0c
0387 #define TEMP_HOTDIE_MSK         0x0c
0388 #define SLP_SD_MSK          (0x3 << 2)
0389 #define SHUTDOWN_FUN            (0x2 << 2)
0390 #define SLEEP_FUN           (0x1 << 2)
0391 #define RK8XX_ID_MSK            0xfff0
0392 #define PWM_MODE_MSK            BIT(7)
0393 #define FPWM_MODE           BIT(7)
0394 #define AUTO_PWM_MODE           0
0395 
0396 enum rk817_reg_id {
0397     RK817_ID_DCDC1 = 0,
0398     RK817_ID_DCDC2,
0399     RK817_ID_DCDC3,
0400     RK817_ID_DCDC4,
0401     RK817_ID_LDO1,
0402     RK817_ID_LDO2,
0403     RK817_ID_LDO3,
0404     RK817_ID_LDO4,
0405     RK817_ID_LDO5,
0406     RK817_ID_LDO6,
0407     RK817_ID_LDO7,
0408     RK817_ID_LDO8,
0409     RK817_ID_LDO9,
0410     RK817_ID_BOOST,
0411     RK817_ID_BOOST_OTG_SW,
0412     RK817_NUM_REGULATORS
0413 };
0414 
0415 enum rk809_reg_id {
0416     RK809_ID_DCDC5 = RK817_ID_BOOST,
0417     RK809_ID_SW1,
0418     RK809_ID_SW2,
0419     RK809_NUM_REGULATORS
0420 };
0421 
0422 #define RK817_SECONDS_REG       0x00
0423 #define RK817_MINUTES_REG       0x01
0424 #define RK817_HOURS_REG         0x02
0425 #define RK817_DAYS_REG          0x03
0426 #define RK817_MONTHS_REG        0x04
0427 #define RK817_YEARS_REG         0x05
0428 #define RK817_WEEKS_REG         0x06
0429 #define RK817_ALARM_SECONDS_REG     0x07
0430 #define RK817_ALARM_MINUTES_REG     0x08
0431 #define RK817_ALARM_HOURS_REG       0x09
0432 #define RK817_ALARM_DAYS_REG        0x0a
0433 #define RK817_ALARM_MONTHS_REG      0x0b
0434 #define RK817_ALARM_YEARS_REG       0x0c
0435 #define RK817_RTC_CTRL_REG      0xd
0436 #define RK817_RTC_STATUS_REG        0xe
0437 #define RK817_RTC_INT_REG       0xf
0438 #define RK817_RTC_COMP_LSB_REG      0x10
0439 #define RK817_RTC_COMP_MSB_REG      0x11
0440 
0441 /* RK817 Codec Registers */
0442 #define RK817_CODEC_DTOP_VUCTL      0x12
0443 #define RK817_CODEC_DTOP_VUCTIME    0x13
0444 #define RK817_CODEC_DTOP_LPT_SRST   0x14
0445 #define RK817_CODEC_DTOP_DIGEN_CLKE 0x15
0446 #define RK817_CODEC_AREF_RTCFG0     0x16
0447 #define RK817_CODEC_AREF_RTCFG1     0x17
0448 #define RK817_CODEC_AADC_CFG0       0x18
0449 #define RK817_CODEC_AADC_CFG1       0x19
0450 #define RK817_CODEC_DADC_VOLL       0x1a
0451 #define RK817_CODEC_DADC_VOLR       0x1b
0452 #define RK817_CODEC_DADC_SR_ACL0    0x1e
0453 #define RK817_CODEC_DADC_ALC1       0x1f
0454 #define RK817_CODEC_DADC_ALC2       0x20
0455 #define RK817_CODEC_DADC_NG     0x21
0456 #define RK817_CODEC_DADC_HPF        0x22
0457 #define RK817_CODEC_DADC_RVOLL      0x23
0458 #define RK817_CODEC_DADC_RVOLR      0x24
0459 #define RK817_CODEC_AMIC_CFG0       0x27
0460 #define RK817_CODEC_AMIC_CFG1       0x28
0461 #define RK817_CODEC_DMIC_PGA_GAIN   0x29
0462 #define RK817_CODEC_DMIC_LMT1       0x2a
0463 #define RK817_CODEC_DMIC_LMT2       0x2b
0464 #define RK817_CODEC_DMIC_NG1        0x2c
0465 #define RK817_CODEC_DMIC_NG2        0x2d
0466 #define RK817_CODEC_ADAC_CFG0       0x2e
0467 #define RK817_CODEC_ADAC_CFG1       0x2f
0468 #define RK817_CODEC_DDAC_POPD_DACST 0x30
0469 #define RK817_CODEC_DDAC_VOLL       0x31
0470 #define RK817_CODEC_DDAC_VOLR       0x32
0471 #define RK817_CODEC_DDAC_SR_LMT0    0x35
0472 #define RK817_CODEC_DDAC_LMT1       0x36
0473 #define RK817_CODEC_DDAC_LMT2       0x37
0474 #define RK817_CODEC_DDAC_MUTE_MIXCTL    0x38
0475 #define RK817_CODEC_DDAC_RVOLL      0x39
0476 #define RK817_CODEC_DDAC_RVOLR      0x3a
0477 #define RK817_CODEC_AHP_ANTI0       0x3b
0478 #define RK817_CODEC_AHP_ANTI1       0x3c
0479 #define RK817_CODEC_AHP_CFG0        0x3d
0480 #define RK817_CODEC_AHP_CFG1        0x3e
0481 #define RK817_CODEC_AHP_CP      0x3f
0482 #define RK817_CODEC_ACLASSD_CFG1    0x40
0483 #define RK817_CODEC_ACLASSD_CFG2    0x41
0484 #define RK817_CODEC_APLL_CFG0       0x42
0485 #define RK817_CODEC_APLL_CFG1       0x43
0486 #define RK817_CODEC_APLL_CFG2       0x44
0487 #define RK817_CODEC_APLL_CFG3       0x45
0488 #define RK817_CODEC_APLL_CFG4       0x46
0489 #define RK817_CODEC_APLL_CFG5       0x47
0490 #define RK817_CODEC_DI2S_CKM        0x48
0491 #define RK817_CODEC_DI2S_RSD        0x49
0492 #define RK817_CODEC_DI2S_RXCR1      0x4a
0493 #define RK817_CODEC_DI2S_RXCR2      0x4b
0494 #define RK817_CODEC_DI2S_RXCMD_TSD  0x4c
0495 #define RK817_CODEC_DI2S_TXCR1      0x4d
0496 #define RK817_CODEC_DI2S_TXCR2      0x4e
0497 #define RK817_CODEC_DI2S_TXCR3_TXCMD    0x4f
0498 
0499 /* RK817_CODEC_DI2S_CKM */
0500 #define RK817_I2S_MODE_MASK     (0x1 << 0)
0501 #define RK817_I2S_MODE_MST      (0x1 << 0)
0502 #define RK817_I2S_MODE_SLV      (0x0 << 0)
0503 
0504 /* RK817_CODEC_DDAC_MUTE_MIXCTL */
0505 #define DACMT_MASK          (0x1 << 0)
0506 #define DACMT_ENABLE            (0x1 << 0)
0507 #define DACMT_DISABLE           (0x0 << 0)
0508 
0509 /* RK817_CODEC_DI2S_RXCR2 */
0510 #define VDW_RX_24BITS           (0x17)
0511 #define VDW_RX_16BITS           (0x0f)
0512 
0513 /* RK817_CODEC_DI2S_TXCR2 */
0514 #define VDW_TX_24BITS           (0x17)
0515 #define VDW_TX_16BITS           (0x0f)
0516 
0517 /* RK817_CODEC_AMIC_CFG0 */
0518 #define MIC_DIFF_MASK           (0x1 << 7)
0519 #define MIC_DIFF_DIS            (0x0 << 7)
0520 #define MIC_DIFF_EN         (0x1 << 7)
0521 
0522 #define RK817_POWER_EN_REG(i)       (0xb1 + (i))
0523 #define RK817_POWER_SLP_EN_REG(i)   (0xb5 + (i))
0524 
0525 #define RK817_POWER_CONFIG      (0xb9)
0526 
0527 #define RK817_BUCK_CONFIG_REG(i)    (0xba + (i) * 3)
0528 
0529 #define RK817_BUCK1_ON_VSEL_REG     0xBB
0530 #define RK817_BUCK1_SLP_VSEL_REG    0xBC
0531 
0532 #define RK817_BUCK2_CONFIG_REG      0xBD
0533 #define RK817_BUCK2_ON_VSEL_REG     0xBE
0534 #define RK817_BUCK2_SLP_VSEL_REG    0xBF
0535 
0536 #define RK817_BUCK3_CONFIG_REG      0xC0
0537 #define RK817_BUCK3_ON_VSEL_REG     0xC1
0538 #define RK817_BUCK3_SLP_VSEL_REG    0xC2
0539 
0540 #define RK817_BUCK4_CONFIG_REG      0xC3
0541 #define RK817_BUCK4_ON_VSEL_REG     0xC4
0542 #define RK817_BUCK4_SLP_VSEL_REG    0xC5
0543 
0544 #define RK817_LDO_ON_VSEL_REG(idx)  (0xcc + (idx) * 2)
0545 #define RK817_BOOST_OTG_CFG     (0xde)
0546 
0547 #define RK817_ID_MSB            0xed
0548 #define RK817_ID_LSB            0xee
0549 
0550 #define RK817_SYS_STS           0xf0
0551 #define RK817_SYS_CFG(i)        (0xf1 + (i))
0552 
0553 #define RK817_ON_SOURCE_REG     0xf5
0554 #define RK817_OFF_SOURCE_REG        0xf6
0555 
0556 /* INTERRUPT REGISTER */
0557 #define RK817_INT_STS_REG0      0xf8
0558 #define RK817_INT_STS_MSK_REG0      0xf9
0559 #define RK817_INT_STS_REG1      0xfa
0560 #define RK817_INT_STS_MSK_REG1      0xfb
0561 #define RK817_INT_STS_REG2      0xfc
0562 #define RK817_INT_STS_MSK_REG2      0xfd
0563 #define RK817_GPIO_INT_CFG      0xfe
0564 
0565 /* IRQ Definitions */
0566 #define RK817_IRQ_PWRON_FALL        0
0567 #define RK817_IRQ_PWRON_RISE        1
0568 #define RK817_IRQ_PWRON         2
0569 #define RK817_IRQ_PWMON_LP      3
0570 #define RK817_IRQ_HOTDIE        4
0571 #define RK817_IRQ_RTC_ALARM     5
0572 #define RK817_IRQ_RTC_PERIOD        6
0573 #define RK817_IRQ_VB_LO         7
0574 #define RK817_IRQ_PLUG_IN       8
0575 #define RK817_IRQ_PLUG_OUT      9
0576 #define RK817_IRQ_CHRG_TERM     10
0577 #define RK817_IRQ_CHRG_TIME     11
0578 #define RK817_IRQ_CHRG_TS       12
0579 #define RK817_IRQ_USB_OV        13
0580 #define RK817_IRQ_CHRG_IN_CLMP      14
0581 #define RK817_IRQ_BAT_DIS_ILIM      15
0582 #define RK817_IRQ_GATE_GPIO     16
0583 #define RK817_IRQ_TS_GPIO       17
0584 #define RK817_IRQ_CODEC_PD      18
0585 #define RK817_IRQ_CODEC_PO      19
0586 #define RK817_IRQ_CLASSD_MUTE_DONE  20
0587 #define RK817_IRQ_CLASSD_OCP        21
0588 #define RK817_IRQ_BAT_OVP               22
0589 #define RK817_IRQ_CHRG_BAT_HI       23
0590 #define RK817_IRQ_END           (RK817_IRQ_CHRG_BAT_HI + 1)
0591 
0592 /*
0593  * rtc_ctrl 0xd
0594  * same as 808, except bit4
0595  */
0596 #define RK817_RTC_CTRL_RSV4     BIT(4)
0597 
0598 /* power config 0xb9 */
0599 #define RK817_BUCK3_FB_RES_MSK      BIT(6)
0600 #define RK817_BUCK3_FB_RES_INTER    BIT(6)
0601 #define RK817_BUCK3_FB_RES_EXT      0
0602 
0603 /* buck config 0xba */
0604 #define RK817_RAMP_RATE_OFFSET      6
0605 #define RK817_RAMP_RATE_MASK        (0x3 << RK817_RAMP_RATE_OFFSET)
0606 #define RK817_RAMP_RATE_3MV_PER_US  (0x0 << RK817_RAMP_RATE_OFFSET)
0607 #define RK817_RAMP_RATE_6_3MV_PER_US    (0x1 << RK817_RAMP_RATE_OFFSET)
0608 #define RK817_RAMP_RATE_12_5MV_PER_US   (0x2 << RK817_RAMP_RATE_OFFSET)
0609 #define RK817_RAMP_RATE_25MV_PER_US (0x3 << RK817_RAMP_RATE_OFFSET)
0610 
0611 /* sys_cfg1 0xf2 */
0612 #define RK817_HOTDIE_TEMP_MSK       (0x3 << 4)
0613 #define RK817_HOTDIE_85         (0x0 << 4)
0614 #define RK817_HOTDIE_95         (0x1 << 4)
0615 #define RK817_HOTDIE_105        (0x2 << 4)
0616 #define RK817_HOTDIE_115        (0x3 << 4)
0617 
0618 #define RK817_TSD_TEMP_MSK      BIT(6)
0619 #define RK817_TSD_140           0
0620 #define RK817_TSD_160           BIT(6)
0621 
0622 #define RK817_CLK32KOUT2_EN     BIT(7)
0623 
0624 /* sys_cfg3 0xf4 */
0625 #define RK817_SLPPIN_FUNC_MSK       (0x3 << 3)
0626 #define SLPPIN_NULL_FUN         (0x0 << 3)
0627 #define SLPPIN_SLP_FUN          (0x1 << 3)
0628 #define SLPPIN_DN_FUN           (0x2 << 3)
0629 #define SLPPIN_RST_FUN          (0x3 << 3)
0630 
0631 #define RK817_RST_FUNC_MSK      (0x3 << 6)
0632 #define RK817_RST_FUNC_SFT      (6)
0633 #define RK817_RST_FUNC_CNT      (3)
0634 #define RK817_RST_FUNC_DEV      (0) /* reset the dev */
0635 #define RK817_RST_FUNC_REG      (0x1 << 6) /* reset the reg only */
0636 
0637 #define RK817_SLPPOL_MSK        BIT(5)
0638 #define RK817_SLPPOL_H          BIT(5)
0639 #define RK817_SLPPOL_L          (0)
0640 
0641 /* gpio&int 0xfe */
0642 #define RK817_INT_POL_MSK       BIT(1)
0643 #define RK817_INT_POL_H         BIT(1)
0644 #define RK817_INT_POL_L         0
0645 #define RK809_BUCK5_CONFIG(i)       (RK817_BOOST_OTG_CFG + (i) * 1)
0646 
0647 enum {
0648     BUCK_ILMIN_50MA,
0649     BUCK_ILMIN_100MA,
0650     BUCK_ILMIN_150MA,
0651     BUCK_ILMIN_200MA,
0652     BUCK_ILMIN_250MA,
0653     BUCK_ILMIN_300MA,
0654     BUCK_ILMIN_350MA,
0655     BUCK_ILMIN_400MA,
0656 };
0657 
0658 enum {
0659     BOOST_ILMIN_75MA,
0660     BOOST_ILMIN_100MA,
0661     BOOST_ILMIN_125MA,
0662     BOOST_ILMIN_150MA,
0663     BOOST_ILMIN_175MA,
0664     BOOST_ILMIN_200MA,
0665     BOOST_ILMIN_225MA,
0666     BOOST_ILMIN_250MA,
0667 };
0668 
0669 enum {
0670     RK805_BUCK1_2_ILMAX_2500MA,
0671     RK805_BUCK1_2_ILMAX_3000MA,
0672     RK805_BUCK1_2_ILMAX_3500MA,
0673     RK805_BUCK1_2_ILMAX_4000MA,
0674 };
0675 
0676 enum {
0677     RK805_BUCK3_ILMAX_1500MA,
0678     RK805_BUCK3_ILMAX_2000MA,
0679     RK805_BUCK3_ILMAX_2500MA,
0680     RK805_BUCK3_ILMAX_3000MA,
0681 };
0682 
0683 enum {
0684     RK805_BUCK4_ILMAX_2000MA,
0685     RK805_BUCK4_ILMAX_2500MA,
0686     RK805_BUCK4_ILMAX_3000MA,
0687     RK805_BUCK4_ILMAX_3500MA,
0688 };
0689 
0690 enum {
0691     RK805_ID = 0x8050,
0692     RK808_ID = 0x0000,
0693     RK809_ID = 0x8090,
0694     RK817_ID = 0x8170,
0695     RK818_ID = 0x8180,
0696 };
0697 
0698 struct rk808 {
0699     struct i2c_client       *i2c;
0700     struct regmap_irq_chip_data *irq_data;
0701     struct regmap           *regmap;
0702     long                variant;
0703     const struct regmap_config  *regmap_cfg;
0704     const struct regmap_irq_chip    *regmap_irq_chip;
0705 };
0706 #endif /* __LINUX_REGULATOR_RK808_H */