0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef __LINUX_MFD_TPS65218_H
0011 #define __LINUX_MFD_TPS65218_H
0012
0013 #include <linux/i2c.h>
0014 #include <linux/regulator/driver.h>
0015 #include <linux/regulator/machine.h>
0016 #include <linux/bitops.h>
0017
0018
0019 #define TPS65218 0xF0
0020
0021
0022 #define TPS65218_I2C_ID 0x24
0023
0024
0025 #define TPS65218_REG_CHIPID 0x00
0026 #define TPS65218_REG_INT1 0x01
0027 #define TPS65218_REG_INT2 0x02
0028 #define TPS65218_REG_INT_MASK1 0x03
0029 #define TPS65218_REG_INT_MASK2 0x04
0030 #define TPS65218_REG_STATUS 0x05
0031 #define TPS65218_REG_CONTROL 0x06
0032 #define TPS65218_REG_FLAG 0x07
0033
0034 #define TPS65218_REG_PASSWORD 0x10
0035 #define TPS65218_REG_ENABLE1 0x11
0036 #define TPS65218_REG_ENABLE2 0x12
0037 #define TPS65218_REG_CONFIG1 0x13
0038 #define TPS65218_REG_CONFIG2 0x14
0039 #define TPS65218_REG_CONFIG3 0x15
0040 #define TPS65218_REG_CONTROL_DCDC1 0x16
0041 #define TPS65218_REG_CONTROL_DCDC2 0x17
0042 #define TPS65218_REG_CONTROL_DCDC3 0x18
0043 #define TPS65218_REG_CONTROL_DCDC4 0x19
0044 #define TPS65218_REG_CONTRL_SLEW_RATE 0x1A
0045 #define TPS65218_REG_CONTROL_LDO1 0x1B
0046 #define TPS65218_REG_SEQ1 0x20
0047 #define TPS65218_REG_SEQ2 0x21
0048 #define TPS65218_REG_SEQ3 0x22
0049 #define TPS65218_REG_SEQ4 0x23
0050 #define TPS65218_REG_SEQ5 0x24
0051 #define TPS65218_REG_SEQ6 0x25
0052 #define TPS65218_REG_SEQ7 0x26
0053
0054
0055 #define TPS65218_CHIPID_CHIP_MASK 0xF8
0056 #define TPS65218_CHIPID_REV_MASK 0x07
0057
0058 #define TPS65218_REV_1_0 0x0
0059 #define TPS65218_REV_1_1 0x1
0060 #define TPS65218_REV_2_0 0x2
0061 #define TPS65218_REV_2_1 0x3
0062
0063 #define TPS65218_INT1_VPRG BIT(5)
0064 #define TPS65218_INT1_AC BIT(4)
0065 #define TPS65218_INT1_PB BIT(3)
0066 #define TPS65218_INT1_HOT BIT(2)
0067 #define TPS65218_INT1_CC_AQC BIT(1)
0068 #define TPS65218_INT1_PRGC BIT(0)
0069
0070 #define TPS65218_INT2_LS3_F BIT(5)
0071 #define TPS65218_INT2_LS2_F BIT(4)
0072 #define TPS65218_INT2_LS1_F BIT(3)
0073 #define TPS65218_INT2_LS3_I BIT(2)
0074 #define TPS65218_INT2_LS2_I BIT(1)
0075 #define TPS65218_INT2_LS1_I BIT(0)
0076
0077 #define TPS65218_INT_MASK1_VPRG BIT(5)
0078 #define TPS65218_INT_MASK1_AC BIT(4)
0079 #define TPS65218_INT_MASK1_PB BIT(3)
0080 #define TPS65218_INT_MASK1_HOT BIT(2)
0081 #define TPS65218_INT_MASK1_CC_AQC BIT(1)
0082 #define TPS65218_INT_MASK1_PRGC BIT(0)
0083
0084 #define TPS65218_INT_MASK2_LS3_F BIT(5)
0085 #define TPS65218_INT_MASK2_LS2_F BIT(4)
0086 #define TPS65218_INT_MASK2_LS1_F BIT(3)
0087 #define TPS65218_INT_MASK2_LS3_I BIT(2)
0088 #define TPS65218_INT_MASK2_LS2_I BIT(1)
0089 #define TPS65218_INT_MASK2_LS1_I BIT(0)
0090
0091 #define TPS65218_STATUS_FSEAL BIT(7)
0092 #define TPS65218_STATUS_EE BIT(6)
0093 #define TPS65218_STATUS_AC_STATE BIT(5)
0094 #define TPS65218_STATUS_PB_STATE BIT(4)
0095 #define TPS65218_STATUS_STATE_MASK 0xC
0096 #define TPS65218_STATUS_CC_STAT 0x3
0097
0098 #define TPS65218_CONTROL_OFFNPFO BIT(1)
0099 #define TPS65218_CONTROL_CC_AQ BIT(0)
0100
0101 #define TPS65218_FLAG_GPO3_FLG BIT(7)
0102 #define TPS65218_FLAG_GPO2_FLG BIT(6)
0103 #define TPS65218_FLAG_GPO1_FLG BIT(5)
0104 #define TPS65218_FLAG_LDO1_FLG BIT(4)
0105 #define TPS65218_FLAG_DC4_FLG BIT(3)
0106 #define TPS65218_FLAG_DC3_FLG BIT(2)
0107 #define TPS65218_FLAG_DC2_FLG BIT(1)
0108 #define TPS65218_FLAG_DC1_FLG BIT(0)
0109
0110 #define TPS65218_ENABLE1_DC6_EN BIT(5)
0111 #define TPS65218_ENABLE1_DC5_EN BIT(4)
0112 #define TPS65218_ENABLE1_DC4_EN BIT(3)
0113 #define TPS65218_ENABLE1_DC3_EN BIT(2)
0114 #define TPS65218_ENABLE1_DC2_EN BIT(1)
0115 #define TPS65218_ENABLE1_DC1_EN BIT(0)
0116
0117 #define TPS65218_ENABLE2_GPIO3 BIT(6)
0118 #define TPS65218_ENABLE2_GPIO2 BIT(5)
0119 #define TPS65218_ENABLE2_GPIO1 BIT(4)
0120 #define TPS65218_ENABLE2_LS3_EN BIT(3)
0121 #define TPS65218_ENABLE2_LS2_EN BIT(2)
0122 #define TPS65218_ENABLE2_LS1_EN BIT(1)
0123 #define TPS65218_ENABLE2_LDO1_EN BIT(0)
0124
0125
0126 #define TPS65218_CONFIG1_TRST BIT(7)
0127 #define TPS65218_CONFIG1_GPO2_BUF BIT(6)
0128 #define TPS65218_CONFIG1_IO1_SEL BIT(5)
0129 #define TPS65218_CONFIG1_PGDLY_MASK 0x18
0130 #define TPS65218_CONFIG1_STRICT BIT(2)
0131 #define TPS65218_CONFIG1_UVLO_MASK 0x3
0132 #define TPS65218_CONFIG1_UVLO_2750000 0x0
0133 #define TPS65218_CONFIG1_UVLO_2950000 0x1
0134 #define TPS65218_CONFIG1_UVLO_3250000 0x2
0135 #define TPS65218_CONFIG1_UVLO_3350000 0x3
0136
0137 #define TPS65218_CONFIG2_DC12_RST BIT(7)
0138 #define TPS65218_CONFIG2_UVLOHYS BIT(6)
0139 #define TPS65218_CONFIG2_LS3ILIM_MASK 0xC
0140 #define TPS65218_CONFIG2_LS2ILIM_MASK 0x3
0141
0142 #define TPS65218_CONFIG3_LS3NPFO BIT(5)
0143 #define TPS65218_CONFIG3_LS2NPFO BIT(4)
0144 #define TPS65218_CONFIG3_LS1NPFO BIT(3)
0145 #define TPS65218_CONFIG3_LS3DCHRG BIT(2)
0146 #define TPS65218_CONFIG3_LS2DCHRG BIT(1)
0147 #define TPS65218_CONFIG3_LS1DCHRG BIT(0)
0148
0149 #define TPS65218_CONTROL_DCDC1_PFM BIT(7)
0150 #define TPS65218_CONTROL_DCDC1_MASK 0x7F
0151
0152 #define TPS65218_CONTROL_DCDC2_PFM BIT(7)
0153 #define TPS65218_CONTROL_DCDC2_MASK 0x3F
0154
0155 #define TPS65218_CONTROL_DCDC3_PFM BIT(7)
0156 #define TPS65218_CONTROL_DCDC3_MASK 0x3F
0157
0158 #define TPS65218_CONTROL_DCDC4_PFM BIT(7)
0159 #define TPS65218_CONTROL_DCDC4_MASK 0x3F
0160
0161 #define TPS65218_SLEW_RATE_GO BIT(7)
0162 #define TPS65218_SLEW_RATE_GODSBL BIT(6)
0163 #define TPS65218_SLEW_RATE_SLEW_MASK 0x7
0164
0165 #define TPS65218_CONTROL_LDO1_MASK 0x3F
0166
0167 #define TPS65218_SEQ1_DLY8 BIT(7)
0168 #define TPS65218_SEQ1_DLY7 BIT(6)
0169 #define TPS65218_SEQ1_DLY6 BIT(5)
0170 #define TPS65218_SEQ1_DLY5 BIT(4)
0171 #define TPS65218_SEQ1_DLY4 BIT(3)
0172 #define TPS65218_SEQ1_DLY3 BIT(2)
0173 #define TPS65218_SEQ1_DLY2 BIT(1)
0174 #define TPS65218_SEQ1_DLY1 BIT(0)
0175
0176 #define TPS65218_SEQ2_DLYFCTR BIT(7)
0177 #define TPS65218_SEQ2_DLY9 BIT(0)
0178
0179 #define TPS65218_SEQ3_DC2_SEQ_MASK 0xF0
0180 #define TPS65218_SEQ3_DC1_SEQ_MASK 0xF
0181
0182 #define TPS65218_SEQ4_DC4_SEQ_MASK 0xF0
0183 #define TPS65218_SEQ4_DC3_SEQ_MASK 0xF
0184
0185 #define TPS65218_SEQ5_DC6_SEQ_MASK 0xF0
0186 #define TPS65218_SEQ5_DC5_SEQ_MASK 0xF
0187
0188 #define TPS65218_SEQ6_LS1_SEQ_MASK 0xF0
0189 #define TPS65218_SEQ6_LDO1_SEQ_MASK 0xF
0190
0191 #define TPS65218_SEQ7_GPO3_SEQ_MASK 0xF0
0192 #define TPS65218_SEQ7_GPO1_SEQ_MASK 0xF
0193 #define TPS65218_PROTECT_NONE 0
0194 #define TPS65218_PROTECT_L1 1
0195
0196 enum tps65218_regulator_id {
0197
0198 TPS65218_DCDC_1,
0199 TPS65218_DCDC_2,
0200 TPS65218_DCDC_3,
0201 TPS65218_DCDC_4,
0202 TPS65218_DCDC_5,
0203 TPS65218_DCDC_6,
0204
0205 TPS65218_LDO_1,
0206
0207 TPS65218_LS_2,
0208 TPS65218_LS_3,
0209 };
0210
0211 #define TPS65218_MAX_REG_ID TPS65218_LDO_1
0212
0213
0214 #define TPS65218_NUM_DCDC 6
0215
0216 #define TPS65218_NUM_LDO 1
0217
0218 #define TPS65218_NUM_LS 2
0219
0220 #define TPS65218_NUM_REGULATOR (TPS65218_NUM_DCDC + TPS65218_NUM_LDO \
0221 + TPS65218_NUM_LS)
0222
0223
0224 enum tps65218_irqs {
0225
0226 TPS65218_PRGC_IRQ,
0227 TPS65218_CC_AQC_IRQ,
0228 TPS65218_HOT_IRQ,
0229 TPS65218_PB_IRQ,
0230 TPS65218_AC_IRQ,
0231 TPS65218_VPRG_IRQ,
0232 TPS65218_INVALID1_IRQ,
0233 TPS65218_INVALID2_IRQ,
0234
0235 TPS65218_LS1_I_IRQ,
0236 TPS65218_LS2_I_IRQ,
0237 TPS65218_LS3_I_IRQ,
0238 TPS65218_LS1_F_IRQ,
0239 TPS65218_LS2_F_IRQ,
0240 TPS65218_LS3_F_IRQ,
0241 TPS65218_INVALID3_IRQ,
0242 TPS65218_INVALID4_IRQ,
0243 };
0244
0245
0246
0247
0248
0249
0250
0251 struct tps65218 {
0252 struct device *dev;
0253 unsigned int id;
0254 u8 rev;
0255
0256 struct mutex tps_lock;
0257
0258 int irq;
0259 u32 irq_mask;
0260 struct regmap_irq_chip_data *irq_data;
0261 struct regulator_desc desc[TPS65218_NUM_REGULATOR];
0262 struct regmap *regmap;
0263 u8 *strobes;
0264 };
0265
0266 int tps65218_reg_write(struct tps65218 *tps, unsigned int reg,
0267 unsigned int val, unsigned int level);
0268 int tps65218_set_bits(struct tps65218 *tps, unsigned int reg,
0269 unsigned int mask, unsigned int val, unsigned int level);
0270 int tps65218_clear_bits(struct tps65218 *tps, unsigned int reg,
0271 unsigned int mask, unsigned int level);
0272
0273 #endif