0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef __LINUX_MFD_TPS65217_H
0011 #define __LINUX_MFD_TPS65217_H
0012
0013 #include <linux/i2c.h>
0014 #include <linux/regulator/driver.h>
0015 #include <linux/regulator/machine.h>
0016
0017
0018 #define TPS65217 0xF0
0019
0020
0021 #define TPS65217_I2C_ID 0x24
0022
0023
0024 #define TPS65217_REG_CHIPID 0X00
0025 #define TPS65217_REG_PPATH 0X01
0026 #define TPS65217_REG_INT 0X02
0027 #define TPS65217_REG_CHGCONFIG0 0X03
0028 #define TPS65217_REG_CHGCONFIG1 0X04
0029 #define TPS65217_REG_CHGCONFIG2 0X05
0030 #define TPS65217_REG_CHGCONFIG3 0X06
0031 #define TPS65217_REG_WLEDCTRL1 0X07
0032 #define TPS65217_REG_WLEDCTRL2 0X08
0033 #define TPS65217_REG_MUXCTRL 0X09
0034 #define TPS65217_REG_STATUS 0X0A
0035 #define TPS65217_REG_PASSWORD 0X0B
0036 #define TPS65217_REG_PGOOD 0X0C
0037 #define TPS65217_REG_DEFPG 0X0D
0038 #define TPS65217_REG_DEFDCDC1 0X0E
0039 #define TPS65217_REG_DEFDCDC2 0X0F
0040 #define TPS65217_REG_DEFDCDC3 0X10
0041 #define TPS65217_REG_DEFSLEW 0X11
0042 #define TPS65217_REG_DEFLDO1 0X12
0043 #define TPS65217_REG_DEFLDO2 0X13
0044 #define TPS65217_REG_DEFLS1 0X14
0045 #define TPS65217_REG_DEFLS2 0X15
0046 #define TPS65217_REG_ENABLE 0X16
0047 #define TPS65217_REG_DEFUVLO 0X18
0048 #define TPS65217_REG_SEQ1 0X19
0049 #define TPS65217_REG_SEQ2 0X1A
0050 #define TPS65217_REG_SEQ3 0X1B
0051 #define TPS65217_REG_SEQ4 0X1C
0052 #define TPS65217_REG_SEQ5 0X1D
0053 #define TPS65217_REG_SEQ6 0X1E
0054
0055 #define TPS65217_REG_MAX TPS65217_REG_SEQ6
0056
0057
0058 #define TPS65217_CHIPID_CHIP_MASK 0xF0
0059 #define TPS65217_CHIPID_REV_MASK 0x0F
0060
0061 #define TPS65217_PPATH_ACSINK_ENABLE BIT(7)
0062 #define TPS65217_PPATH_USBSINK_ENABLE BIT(6)
0063 #define TPS65217_PPATH_AC_PW_ENABLE BIT(5)
0064 #define TPS65217_PPATH_USB_PW_ENABLE BIT(4)
0065 #define TPS65217_PPATH_AC_CURRENT_MASK 0x0C
0066 #define TPS65217_PPATH_USB_CURRENT_MASK 0x03
0067
0068 #define TPS65217_INT_PBM BIT(6)
0069 #define TPS65217_INT_ACM BIT(5)
0070 #define TPS65217_INT_USBM BIT(4)
0071 #define TPS65217_INT_PBI BIT(2)
0072 #define TPS65217_INT_ACI BIT(1)
0073 #define TPS65217_INT_USBI BIT(0)
0074 #define TPS65217_INT_SHIFT 4
0075 #define TPS65217_INT_MASK (TPS65217_INT_PBM | TPS65217_INT_ACM | \
0076 TPS65217_INT_USBM)
0077
0078 #define TPS65217_CHGCONFIG0_TREG BIT(7)
0079 #define TPS65217_CHGCONFIG0_DPPM BIT(6)
0080 #define TPS65217_CHGCONFIG0_TSUSP BIT(5)
0081 #define TPS65217_CHGCONFIG0_TERMI BIT(4)
0082 #define TPS65217_CHGCONFIG0_ACTIVE BIT(3)
0083 #define TPS65217_CHGCONFIG0_CHGTOUT BIT(2)
0084 #define TPS65217_CHGCONFIG0_PCHGTOUT BIT(1)
0085 #define TPS65217_CHGCONFIG0_BATTEMP BIT(0)
0086
0087 #define TPS65217_CHGCONFIG1_TMR_MASK 0xC0
0088 #define TPS65217_CHGCONFIG1_TMR_ENABLE BIT(5)
0089 #define TPS65217_CHGCONFIG1_NTC_TYPE BIT(4)
0090 #define TPS65217_CHGCONFIG1_RESET BIT(3)
0091 #define TPS65217_CHGCONFIG1_TERM BIT(2)
0092 #define TPS65217_CHGCONFIG1_SUSP BIT(1)
0093 #define TPS65217_CHGCONFIG1_CHG_EN BIT(0)
0094
0095 #define TPS65217_CHGCONFIG2_DYNTMR BIT(7)
0096 #define TPS65217_CHGCONFIG2_VPREGHG BIT(6)
0097 #define TPS65217_CHGCONFIG2_VOREG_MASK 0x30
0098
0099 #define TPS65217_CHGCONFIG3_ICHRG_MASK 0xC0
0100 #define TPS65217_CHGCONFIG3_DPPMTH_MASK 0x30
0101 #define TPS65217_CHGCONFIG2_PCHRGT BIT(3)
0102 #define TPS65217_CHGCONFIG2_TERMIF 0x06
0103 #define TPS65217_CHGCONFIG2_TRANGE BIT(0)
0104
0105 #define TPS65217_WLEDCTRL1_ISINK_ENABLE BIT(3)
0106 #define TPS65217_WLEDCTRL1_ISEL BIT(2)
0107 #define TPS65217_WLEDCTRL1_FDIM_MASK 0x03
0108
0109 #define TPS65217_WLEDCTRL2_DUTY_MASK 0x7F
0110
0111 #define TPS65217_MUXCTRL_MUX_MASK 0x07
0112
0113 #define TPS65217_STATUS_OFF BIT(7)
0114 #define TPS65217_STATUS_ACPWR BIT(3)
0115 #define TPS65217_STATUS_USBPWR BIT(2)
0116 #define TPS65217_STATUS_PB BIT(0)
0117
0118 #define TPS65217_PASSWORD_REGS_UNLOCK 0x7D
0119
0120 #define TPS65217_PGOOD_LDO3_PG BIT(6)
0121 #define TPS65217_PGOOD_LDO4_PG BIT(5)
0122 #define TPS65217_PGOOD_DC1_PG BIT(4)
0123 #define TPS65217_PGOOD_DC2_PG BIT(3)
0124 #define TPS65217_PGOOD_DC3_PG BIT(2)
0125 #define TPS65217_PGOOD_LDO1_PG BIT(1)
0126 #define TPS65217_PGOOD_LDO2_PG BIT(0)
0127
0128 #define TPS65217_DEFPG_LDO1PGM BIT(3)
0129 #define TPS65217_DEFPG_LDO2PGM BIT(2)
0130 #define TPS65217_DEFPG_PGDLY_MASK 0x03
0131
0132 #define TPS65217_DEFDCDCX_XADJX BIT(7)
0133 #define TPS65217_DEFDCDCX_DCDC_MASK 0x3F
0134
0135 #define TPS65217_DEFSLEW_GO BIT(7)
0136 #define TPS65217_DEFSLEW_GODSBL BIT(6)
0137 #define TPS65217_DEFSLEW_PFM_EN1 BIT(5)
0138 #define TPS65217_DEFSLEW_PFM_EN2 BIT(4)
0139 #define TPS65217_DEFSLEW_PFM_EN3 BIT(3)
0140 #define TPS65217_DEFSLEW_SLEW_MASK 0x07
0141
0142 #define TPS65217_DEFLDO1_LDO1_MASK 0x0F
0143
0144 #define TPS65217_DEFLDO2_TRACK BIT(6)
0145 #define TPS65217_DEFLDO2_LDO2_MASK 0x3F
0146
0147 #define TPS65217_DEFLDO3_LDO3_EN BIT(5)
0148 #define TPS65217_DEFLDO3_LDO3_MASK 0x1F
0149
0150 #define TPS65217_DEFLDO4_LDO4_EN BIT(5)
0151 #define TPS65217_DEFLDO4_LDO4_MASK 0x1F
0152
0153 #define TPS65217_ENABLE_LS1_EN BIT(6)
0154 #define TPS65217_ENABLE_LS2_EN BIT(5)
0155 #define TPS65217_ENABLE_DC1_EN BIT(4)
0156 #define TPS65217_ENABLE_DC2_EN BIT(3)
0157 #define TPS65217_ENABLE_DC3_EN BIT(2)
0158 #define TPS65217_ENABLE_LDO1_EN BIT(1)
0159 #define TPS65217_ENABLE_LDO2_EN BIT(0)
0160
0161 #define TPS65217_DEFUVLO_UVLOHYS BIT(2)
0162 #define TPS65217_DEFUVLO_UVLO_MASK 0x03
0163
0164 #define TPS65217_SEQ1_DC1_SEQ_MASK 0xF0
0165 #define TPS65217_SEQ1_DC2_SEQ_MASK 0x0F
0166
0167 #define TPS65217_SEQ2_DC3_SEQ_MASK 0xF0
0168 #define TPS65217_SEQ2_LDO1_SEQ_MASK 0x0F
0169
0170 #define TPS65217_SEQ3_LDO2_SEQ_MASK 0xF0
0171 #define TPS65217_SEQ3_LDO3_SEQ_MASK 0x0F
0172
0173 #define TPS65217_SEQ4_LDO4_SEQ_MASK 0xF0
0174
0175 #define TPS65217_SEQ5_DLY1_MASK 0xC0
0176 #define TPS65217_SEQ5_DLY2_MASK 0x30
0177 #define TPS65217_SEQ5_DLY3_MASK 0x0C
0178 #define TPS65217_SEQ5_DLY4_MASK 0x03
0179
0180 #define TPS65217_SEQ6_DLY5_MASK 0xC0
0181 #define TPS65217_SEQ6_DLY6_MASK 0x30
0182 #define TPS65217_SEQ6_SEQUP BIT(2)
0183 #define TPS65217_SEQ6_SEQDWN BIT(1)
0184 #define TPS65217_SEQ6_INSTDWN BIT(0)
0185
0186 #define TPS65217_MAX_REGISTER 0x1E
0187 #define TPS65217_PROTECT_NONE 0
0188 #define TPS65217_PROTECT_L1 1
0189 #define TPS65217_PROTECT_L2 2
0190
0191
0192 enum tps65217_regulator_id {
0193
0194 TPS65217_DCDC_1,
0195 TPS65217_DCDC_2,
0196 TPS65217_DCDC_3,
0197
0198 TPS65217_LDO_1,
0199 TPS65217_LDO_2,
0200 TPS65217_LDO_3,
0201 TPS65217_LDO_4,
0202 };
0203
0204 #define TPS65217_MAX_REG_ID TPS65217_LDO_4
0205
0206
0207 #define TPS65217_NUM_DCDC 3
0208
0209 #define TPS65217_NUM_LDO 4
0210
0211 #define TPS65217_NUM_REGULATOR (TPS65217_NUM_DCDC + TPS65217_NUM_LDO)
0212
0213 enum tps65217_bl_isel {
0214 TPS65217_BL_ISET1 = 1,
0215 TPS65217_BL_ISET2,
0216 };
0217
0218 enum tps65217_bl_fdim {
0219 TPS65217_BL_FDIM_100HZ,
0220 TPS65217_BL_FDIM_200HZ,
0221 TPS65217_BL_FDIM_500HZ,
0222 TPS65217_BL_FDIM_1000HZ,
0223 };
0224
0225 struct tps65217_bl_pdata {
0226 enum tps65217_bl_isel isel;
0227 enum tps65217_bl_fdim fdim;
0228 int dft_brightness;
0229 };
0230
0231
0232 #define TPS65217_IRQ_USB 0
0233 #define TPS65217_IRQ_AC 1
0234 #define TPS65217_IRQ_PB 2
0235 #define TPS65217_NUM_IRQ 3
0236
0237
0238
0239
0240
0241
0242
0243 struct tps65217_board {
0244 struct regulator_init_data *tps65217_init_data[TPS65217_NUM_REGULATOR];
0245 struct device_node *of_node[TPS65217_NUM_REGULATOR];
0246 struct tps65217_bl_pdata *bl_pdata;
0247 };
0248
0249
0250
0251
0252
0253
0254
0255 struct tps65217 {
0256 struct device *dev;
0257 struct tps65217_board *pdata;
0258 struct regulator_desc desc[TPS65217_NUM_REGULATOR];
0259 struct regmap *regmap;
0260 u8 *strobes;
0261 struct irq_domain *irq_domain;
0262 struct mutex irq_lock;
0263 u8 irq_mask;
0264 int irq;
0265 };
0266
0267 static inline struct tps65217 *dev_to_tps65217(struct device *dev)
0268 {
0269 return dev_get_drvdata(dev);
0270 }
0271
0272 int tps65217_reg_read(struct tps65217 *tps, unsigned int reg,
0273 unsigned int *val);
0274 int tps65217_reg_write(struct tps65217 *tps, unsigned int reg,
0275 unsigned int val, unsigned int level);
0276 int tps65217_set_bits(struct tps65217 *tps, unsigned int reg,
0277 unsigned int mask, unsigned int val, unsigned int level);
0278 int tps65217_clear_bits(struct tps65217 *tps, unsigned int reg,
0279 unsigned int mask, unsigned int level);
0280
0281 #endif