0001
0002
0003
0004
0005
0006
0007
0008 #ifndef _MFD_MAX77620_H_
0009 #define _MFD_MAX77620_H_
0010
0011 #include <linux/types.h>
0012
0013
0014 #define MAX77620_REG_CNFGGLBL1 0x00
0015 #define MAX77620_REG_CNFGGLBL2 0x01
0016 #define MAX77620_REG_CNFGGLBL3 0x02
0017 #define MAX77620_REG_CNFG1_32K 0x03
0018 #define MAX77620_REG_CNFGBBC 0x04
0019 #define MAX77620_REG_IRQTOP 0x05
0020 #define MAX77620_REG_INTLBT 0x06
0021 #define MAX77620_REG_IRQSD 0x07
0022 #define MAX77620_REG_IRQ_LVL2_L0_7 0x08
0023 #define MAX77620_REG_IRQ_LVL2_L8 0x09
0024 #define MAX77620_REG_IRQ_LVL2_GPIO 0x0A
0025 #define MAX77620_REG_ONOFFIRQ 0x0B
0026 #define MAX77620_REG_NVERC 0x0C
0027 #define MAX77620_REG_IRQTOPM 0x0D
0028 #define MAX77620_REG_INTENLBT 0x0E
0029 #define MAX77620_REG_IRQMASKSD 0x0F
0030 #define MAX77620_REG_IRQ_MSK_L0_7 0x10
0031 #define MAX77620_REG_IRQ_MSK_L8 0x11
0032 #define MAX77620_REG_ONOFFIRQM 0x12
0033 #define MAX77620_REG_STATLBT 0x13
0034 #define MAX77620_REG_STATSD 0x14
0035 #define MAX77620_REG_ONOFFSTAT 0x15
0036
0037
0038 #define MAX77620_REG_SD0 0x16
0039 #define MAX77620_REG_SD1 0x17
0040 #define MAX77620_REG_SD2 0x18
0041 #define MAX77620_REG_SD3 0x19
0042 #define MAX77620_REG_SD4 0x1A
0043 #define MAX77620_REG_DVSSD0 0x1B
0044 #define MAX77620_REG_DVSSD1 0x1C
0045 #define MAX77620_REG_SD0_CFG 0x1D
0046 #define MAX77620_REG_SD1_CFG 0x1E
0047 #define MAX77620_REG_SD2_CFG 0x1F
0048 #define MAX77620_REG_SD3_CFG 0x20
0049 #define MAX77620_REG_SD4_CFG 0x21
0050 #define MAX77620_REG_SD_CFG2 0x22
0051 #define MAX77620_REG_LDO0_CFG 0x23
0052 #define MAX77620_REG_LDO0_CFG2 0x24
0053 #define MAX77620_REG_LDO1_CFG 0x25
0054 #define MAX77620_REG_LDO1_CFG2 0x26
0055 #define MAX77620_REG_LDO2_CFG 0x27
0056 #define MAX77620_REG_LDO2_CFG2 0x28
0057 #define MAX77620_REG_LDO3_CFG 0x29
0058 #define MAX77620_REG_LDO3_CFG2 0x2A
0059 #define MAX77620_REG_LDO4_CFG 0x2B
0060 #define MAX77620_REG_LDO4_CFG2 0x2C
0061 #define MAX77620_REG_LDO5_CFG 0x2D
0062 #define MAX77620_REG_LDO5_CFG2 0x2E
0063 #define MAX77620_REG_LDO6_CFG 0x2F
0064 #define MAX77620_REG_LDO6_CFG2 0x30
0065 #define MAX77620_REG_LDO7_CFG 0x31
0066 #define MAX77620_REG_LDO7_CFG2 0x32
0067 #define MAX77620_REG_LDO8_CFG 0x33
0068 #define MAX77620_REG_LDO8_CFG2 0x34
0069 #define MAX77620_REG_LDO_CFG3 0x35
0070
0071 #define MAX77620_LDO_SLEW_RATE_MASK 0x1
0072
0073
0074 #define MAX77620_TRACK4_MASK BIT(5)
0075 #define MAX77620_TRACK4_SHIFT 5
0076
0077
0078 #define MAX77620_SDX_VOLT_MASK 0xFF
0079 #define MAX77620_SD0_VOLT_MASK 0x3F
0080 #define MAX77620_SD1_VOLT_MASK 0x7F
0081 #define MAX77620_LDO_VOLT_MASK 0x3F
0082
0083 #define MAX77620_REG_GPIO0 0x36
0084 #define MAX77620_REG_GPIO1 0x37
0085 #define MAX77620_REG_GPIO2 0x38
0086 #define MAX77620_REG_GPIO3 0x39
0087 #define MAX77620_REG_GPIO4 0x3A
0088 #define MAX77620_REG_GPIO5 0x3B
0089 #define MAX77620_REG_GPIO6 0x3C
0090 #define MAX77620_REG_GPIO7 0x3D
0091 #define MAX77620_REG_PUE_GPIO 0x3E
0092 #define MAX77620_REG_PDE_GPIO 0x3F
0093 #define MAX77620_REG_AME_GPIO 0x40
0094 #define MAX77620_REG_ONOFFCNFG1 0x41
0095 #define MAX77620_REG_ONOFFCNFG2 0x42
0096
0097
0098 #define MAX77620_REG_FPS_CFG0 0x43
0099 #define MAX77620_REG_FPS_CFG1 0x44
0100 #define MAX77620_REG_FPS_CFG2 0x45
0101 #define MAX77620_REG_FPS_LDO0 0x46
0102 #define MAX77620_REG_FPS_LDO1 0x47
0103 #define MAX77620_REG_FPS_LDO2 0x48
0104 #define MAX77620_REG_FPS_LDO3 0x49
0105 #define MAX77620_REG_FPS_LDO4 0x4A
0106 #define MAX77620_REG_FPS_LDO5 0x4B
0107 #define MAX77620_REG_FPS_LDO6 0x4C
0108 #define MAX77620_REG_FPS_LDO7 0x4D
0109 #define MAX77620_REG_FPS_LDO8 0x4E
0110 #define MAX77620_REG_FPS_SD0 0x4F
0111 #define MAX77620_REG_FPS_SD1 0x50
0112 #define MAX77620_REG_FPS_SD2 0x51
0113 #define MAX77620_REG_FPS_SD3 0x52
0114 #define MAX77620_REG_FPS_SD4 0x53
0115 #define MAX77620_REG_FPS_NONE 0
0116
0117 #define MAX77620_FPS_SRC_MASK 0xC0
0118 #define MAX77620_FPS_SRC_SHIFT 6
0119 #define MAX77620_FPS_PU_PERIOD_MASK 0x38
0120 #define MAX77620_FPS_PU_PERIOD_SHIFT 3
0121 #define MAX77620_FPS_PD_PERIOD_MASK 0x07
0122 #define MAX77620_FPS_PD_PERIOD_SHIFT 0
0123 #define MAX77620_FPS_TIME_PERIOD_MASK 0x38
0124 #define MAX77620_FPS_TIME_PERIOD_SHIFT 3
0125 #define MAX77620_FPS_EN_SRC_MASK 0x06
0126 #define MAX77620_FPS_EN_SRC_SHIFT 1
0127 #define MAX77620_FPS_ENFPS_SW_MASK 0x01
0128 #define MAX77620_FPS_ENFPS_SW 0x01
0129
0130
0131
0132
0133 #define MAX77620_FPS_PERIOD_MIN_US 40
0134 #define MAX20024_FPS_PERIOD_MIN_US 20
0135
0136 #define MAX20024_FPS_PERIOD_MAX_US 2560
0137 #define MAX77620_FPS_PERIOD_MAX_US 5120
0138
0139 #define MAX77620_REG_FPS_GPIO1 0x54
0140 #define MAX77620_REG_FPS_GPIO2 0x55
0141 #define MAX77620_REG_FPS_GPIO3 0x56
0142 #define MAX77620_REG_FPS_RSO 0x57
0143 #define MAX77620_REG_CID0 0x58
0144 #define MAX77620_REG_CID1 0x59
0145 #define MAX77620_REG_CID2 0x5A
0146 #define MAX77620_REG_CID3 0x5B
0147 #define MAX77620_REG_CID4 0x5C
0148 #define MAX77620_REG_CID5 0x5D
0149
0150 #define MAX77620_REG_DVSSD4 0x5E
0151 #define MAX20024_REG_MAX_ADD 0x70
0152
0153 #define MAX77620_CID_DIDM_MASK 0xF0
0154 #define MAX77620_CID_DIDM_SHIFT 4
0155
0156
0157 #define MAX77620_SD_CNF2_ROVS_EN_SD1 BIT(1)
0158 #define MAX77620_SD_CNF2_ROVS_EN_SD0 BIT(2)
0159
0160
0161 #define MAX77620_CID5_DIDM(n) (((n) >> 4) & 0xF)
0162
0163 #define MAX77620_CID5_DIDO(n) ((n) & 0xF)
0164
0165
0166 #define MAX77620_SD_SR_MASK 0xC0
0167 #define MAX77620_SD_SR_SHIFT 6
0168 #define MAX77620_SD_POWER_MODE_MASK 0x30
0169 #define MAX77620_SD_POWER_MODE_SHIFT 4
0170 #define MAX77620_SD_CFG1_ADE_MASK BIT(3)
0171 #define MAX77620_SD_CFG1_ADE_DISABLE 0
0172 #define MAX77620_SD_CFG1_ADE_ENABLE BIT(3)
0173 #define MAX77620_SD_FPWM_MASK 0x04
0174 #define MAX77620_SD_FPWM_SHIFT 2
0175 #define MAX77620_SD_FSRADE_MASK 0x01
0176 #define MAX77620_SD_FSRADE_SHIFT 0
0177 #define MAX77620_SD_CFG1_FPWM_SD_MASK BIT(2)
0178 #define MAX77620_SD_CFG1_FPWM_SD_SKIP 0
0179 #define MAX77620_SD_CFG1_FPWM_SD_FPWM BIT(2)
0180 #define MAX20024_SD_CFG1_MPOK_MASK BIT(1)
0181 #define MAX77620_SD_CFG1_FSRADE_SD_MASK BIT(0)
0182 #define MAX77620_SD_CFG1_FSRADE_SD_DISABLE 0
0183 #define MAX77620_SD_CFG1_FSRADE_SD_ENABLE BIT(0)
0184
0185
0186 #define MAX77620_LDO_POWER_MODE_MASK 0xC0
0187 #define MAX77620_LDO_POWER_MODE_SHIFT 6
0188 #define MAX20024_LDO_CFG2_MPOK_MASK BIT(2)
0189 #define MAX77620_LDO_CFG2_ADE_MASK BIT(1)
0190 #define MAX77620_LDO_CFG2_ADE_DISABLE 0
0191 #define MAX77620_LDO_CFG2_ADE_ENABLE BIT(1)
0192 #define MAX77620_LDO_CFG2_SS_MASK BIT(0)
0193 #define MAX77620_LDO_CFG2_SS_FAST BIT(0)
0194 #define MAX77620_LDO_CFG2_SS_SLOW 0
0195
0196 #define MAX77620_IRQ_TOP_GLBL_MASK BIT(7)
0197 #define MAX77620_IRQ_TOP_SD_MASK BIT(6)
0198 #define MAX77620_IRQ_TOP_LDO_MASK BIT(5)
0199 #define MAX77620_IRQ_TOP_GPIO_MASK BIT(4)
0200 #define MAX77620_IRQ_TOP_RTC_MASK BIT(3)
0201 #define MAX77620_IRQ_TOP_32K_MASK BIT(2)
0202 #define MAX77620_IRQ_TOP_ONOFF_MASK BIT(1)
0203
0204 #define MAX77620_IRQ_LBM_MASK BIT(3)
0205 #define MAX77620_IRQ_TJALRM1_MASK BIT(2)
0206 #define MAX77620_IRQ_TJALRM2_MASK BIT(1)
0207
0208 #define MAX77620_PWR_I2C_ADDR 0x3c
0209 #define MAX77620_RTC_I2C_ADDR 0x68
0210
0211 #define MAX77620_CNFG_GPIO_DRV_MASK BIT(0)
0212 #define MAX77620_CNFG_GPIO_DRV_PUSHPULL BIT(0)
0213 #define MAX77620_CNFG_GPIO_DRV_OPENDRAIN 0
0214 #define MAX77620_CNFG_GPIO_DIR_MASK BIT(1)
0215 #define MAX77620_CNFG_GPIO_DIR_INPUT BIT(1)
0216 #define MAX77620_CNFG_GPIO_DIR_OUTPUT 0
0217 #define MAX77620_CNFG_GPIO_INPUT_VAL_MASK BIT(2)
0218 #define MAX77620_CNFG_GPIO_OUTPUT_VAL_MASK BIT(3)
0219 #define MAX77620_CNFG_GPIO_OUTPUT_VAL_HIGH BIT(3)
0220 #define MAX77620_CNFG_GPIO_OUTPUT_VAL_LOW 0
0221 #define MAX77620_CNFG_GPIO_INT_MASK (0x3 << 4)
0222 #define MAX77620_CNFG_GPIO_INT_FALLING BIT(4)
0223 #define MAX77620_CNFG_GPIO_INT_RISING BIT(5)
0224 #define MAX77620_CNFG_GPIO_DBNC_MASK (0x3 << 6)
0225 #define MAX77620_CNFG_GPIO_DBNC_None (0x0 << 6)
0226 #define MAX77620_CNFG_GPIO_DBNC_8ms (0x1 << 6)
0227 #define MAX77620_CNFG_GPIO_DBNC_16ms (0x2 << 6)
0228 #define MAX77620_CNFG_GPIO_DBNC_32ms (0x3 << 6)
0229
0230 #define MAX77620_IRQ_LVL2_GPIO_EDGE0 BIT(0)
0231 #define MAX77620_IRQ_LVL2_GPIO_EDGE1 BIT(1)
0232 #define MAX77620_IRQ_LVL2_GPIO_EDGE2 BIT(2)
0233 #define MAX77620_IRQ_LVL2_GPIO_EDGE3 BIT(3)
0234 #define MAX77620_IRQ_LVL2_GPIO_EDGE4 BIT(4)
0235 #define MAX77620_IRQ_LVL2_GPIO_EDGE5 BIT(5)
0236 #define MAX77620_IRQ_LVL2_GPIO_EDGE6 BIT(6)
0237 #define MAX77620_IRQ_LVL2_GPIO_EDGE7 BIT(7)
0238
0239 #define MAX77620_CNFG1_32K_OUT0_EN BIT(2)
0240
0241 #define MAX77620_ONOFFCNFG1_SFT_RST BIT(7)
0242 #define MAX77620_ONOFFCNFG1_MRT_MASK 0x38
0243 #define MAX77620_ONOFFCNFG1_MRT_SHIFT 0x3
0244 #define MAX77620_ONOFFCNFG1_SLPEN BIT(2)
0245 #define MAX77620_ONOFFCNFG1_PWR_OFF BIT(1)
0246 #define MAX20024_ONOFFCNFG1_CLRSE 0x18
0247
0248 #define MAX77620_ONOFFCNFG2_SFT_RST_WK BIT(7)
0249 #define MAX77620_ONOFFCNFG2_WD_RST_WK BIT(6)
0250 #define MAX77620_ONOFFCNFG2_SLP_LPM_MSK BIT(5)
0251 #define MAX77620_ONOFFCNFG2_WK_ALARM1 BIT(2)
0252 #define MAX77620_ONOFFCNFG2_WK_EN0 BIT(0)
0253
0254 #define MAX77620_GLBLM_MASK BIT(0)
0255
0256 #define MAX77620_WDTC_MASK 0x3
0257 #define MAX77620_WDTOFFC BIT(4)
0258 #define MAX77620_WDTSLPC BIT(3)
0259 #define MAX77620_WDTEN BIT(2)
0260
0261 #define MAX77620_TWD_MASK 0x3
0262 #define MAX77620_TWD_2s 0x0
0263 #define MAX77620_TWD_16s 0x1
0264 #define MAX77620_TWD_64s 0x2
0265 #define MAX77620_TWD_128s 0x3
0266
0267 #define MAX77620_CNFGGLBL1_LBDAC_EN BIT(7)
0268 #define MAX77620_CNFGGLBL1_MPPLD BIT(6)
0269 #define MAX77620_CNFGGLBL1_LBHYST (BIT(5) | BIT(4))
0270 #define MAX77620_CNFGGLBL1_LBDAC 0x0E
0271 #define MAX77620_CNFGGLBL1_LBRSTEN BIT(0)
0272
0273
0274 #define MAX77620_CNFGBBC_ENABLE BIT(0)
0275 #define MAX77620_CNFGBBC_CURRENT_MASK 0x06
0276 #define MAX77620_CNFGBBC_CURRENT_SHIFT 1
0277 #define MAX77620_CNFGBBC_VOLTAGE_MASK 0x18
0278 #define MAX77620_CNFGBBC_VOLTAGE_SHIFT 3
0279 #define MAX77620_CNFGBBC_LOW_CURRENT_DISABLE BIT(5)
0280 #define MAX77620_CNFGBBC_RESISTOR_MASK 0xC0
0281 #define MAX77620_CNFGBBC_RESISTOR_SHIFT 6
0282
0283 #define MAX77620_FPS_COUNT 3
0284
0285
0286 enum {
0287 MAX77620_IRQ_TOP_GLBL,
0288 MAX77620_IRQ_TOP_SD,
0289 MAX77620_IRQ_TOP_LDO,
0290 MAX77620_IRQ_TOP_GPIO,
0291 MAX77620_IRQ_TOP_RTC,
0292 MAX77620_IRQ_TOP_32K,
0293 MAX77620_IRQ_TOP_ONOFF,
0294 MAX77620_IRQ_LBT_MBATLOW,
0295 MAX77620_IRQ_LBT_TJALRM1,
0296 MAX77620_IRQ_LBT_TJALRM2,
0297 };
0298
0299
0300 enum {
0301 MAX77620_GPIO0,
0302 MAX77620_GPIO1,
0303 MAX77620_GPIO2,
0304 MAX77620_GPIO3,
0305 MAX77620_GPIO4,
0306 MAX77620_GPIO5,
0307 MAX77620_GPIO6,
0308 MAX77620_GPIO7,
0309 MAX77620_GPIO_NR,
0310 };
0311
0312
0313 enum max77620_fps_src {
0314 MAX77620_FPS_SRC_0,
0315 MAX77620_FPS_SRC_1,
0316 MAX77620_FPS_SRC_2,
0317 MAX77620_FPS_SRC_NONE,
0318 MAX77620_FPS_SRC_DEF,
0319 };
0320
0321 enum max77620_chip_id {
0322 MAX77620,
0323 MAX20024,
0324 MAX77663,
0325 };
0326
0327 struct max77620_chip {
0328 struct device *dev;
0329 struct regmap *rmap;
0330
0331 int chip_irq;
0332
0333
0334 enum max77620_chip_id chip_id;
0335
0336 bool sleep_enable;
0337 bool enable_global_lpm;
0338 int shutdown_fps_period[MAX77620_FPS_COUNT];
0339 int suspend_fps_period[MAX77620_FPS_COUNT];
0340
0341 struct regmap_irq_chip_data *top_irq_data;
0342 struct regmap_irq_chip_data *gpio_irq_data;
0343 };
0344
0345 #endif