Lines Matching +full:0 +full:- +full:8
1 // SPDX-License-Identifier: GPL-2.0
20 MT6360_SLAVE_TCPC = 0,
36 #define MT6360_TCPC_SLAVEID 0x4E
37 #define MT6360_PMIC_SLAVEID 0x1A
38 #define MT6360_LDO_SLAVEID 0x64
39 #define MT6360_PMU_SLAVEID 0x34
41 #define MT6360_REG_TCPCSTART 0x00
42 #define MT6360_REG_TCPCEND 0xFF
43 #define MT6360_REG_PMICSTART 0x100
44 #define MT6360_REG_PMICEND 0x13B
45 #define MT6360_REG_LDOSTART 0x200
46 #define MT6360_REG_LDOEND 0x21C
47 #define MT6360_REG_PMUSTART 0x300
48 #define MT6360_PMU_DEV_INFO 0x300
49 #define MT6360_PMU_CHG_IRQ1 0x3D0
50 #define MT6360_PMU_CHG_MASK1 0x3F0
51 #define MT6360_REG_PMUEND 0x3FF
55 #define CHIP_VEN_MASK 0xF0
56 #define CHIP_VEN_MT6360 0x50
57 #define CHIP_REV_MASK 0x0F
59 #define MT6360_ADDRESS_MASK 0x3F
60 #define MT6360_DATA_SIZE_1_BYTE 0x00
61 #define MT6360_DATA_SIZE_2_BYTES 0x40
62 #define MT6360_DATA_SIZE_3_BYTES 0x80
63 #define MT6360_DATA_SIZE_4_BYTES 0xC0
65 #define MT6360_CRC8_POLYNOMIAL 0x7
77 #define I2C_ADDR_XLATE_8BIT(_addr, _rw) (((_addr & 0x7F) << 1) + _rw)
79 /* reg 0 -> 0 ~ 7 */
84 /* REG 1 -> 8 ~ 15 */
91 /* REG 2 -> 16 ~ 23 */
92 /* REG 3 -> 24 ~ 31 */
99 /* REG 4 -> 32 ~ 39 */
107 /* REG 5 -> 40 ~ 47 */
116 /* REG 6 -> 48 ~ 55 */
124 /* REG 7 -> 56 ~ 63 */
133 /* REG 8 -> 64 ~ 71 */
142 /* REG 9 -> 72 ~ 79 */
149 /* REG 10 -> 80 ~ 87 */
156 /* REG 11 -> 88 ~ 95 */
157 /* REG 12 -> 96 ~ 103 */
162 /* REG 13 -> 104 ~ 111 */
167 /* REG 14 -> 112 ~ 119 */
174 /* REG 15 -> 120 ~ 127 */
183 REGMAP_IRQ_REG_LINE(MT6360_CHG_TREG_EVT, 8),
184 REGMAP_IRQ_REG_LINE(MT6360_CHG_AICR_EVT, 8),
185 REGMAP_IRQ_REG_LINE(MT6360_CHG_MIVR_EVT, 8),
186 REGMAP_IRQ_REG_LINE(MT6360_PWR_RDY_EVT, 8),
187 REGMAP_IRQ_REG_LINE(MT6360_CHG_BATSYSUV_EVT, 8),
188 REGMAP_IRQ_REG_LINE(MT6360_FLED_CHG_VINOVP_EVT, 8),
189 REGMAP_IRQ_REG_LINE(MT6360_CHG_VSYSUV_EVT, 8),
190 REGMAP_IRQ_REG_LINE(MT6360_CHG_VSYSOV_EVT, 8),
191 REGMAP_IRQ_REG_LINE(MT6360_CHG_VBATOV_EVT, 8),
192 REGMAP_IRQ_REG_LINE(MT6360_CHG_VBUSOV_EVT, 8),
193 REGMAP_IRQ_REG_LINE(MT6360_WD_PMU_DET, 8),
194 REGMAP_IRQ_REG_LINE(MT6360_WD_PMU_DONE, 8),
195 REGMAP_IRQ_REG_LINE(MT6360_CHG_TMRI, 8),
196 REGMAP_IRQ_REG_LINE(MT6360_CHG_ADPBADI, 8),
197 REGMAP_IRQ_REG_LINE(MT6360_CHG_RVPI, 8),
198 REGMAP_IRQ_REG_LINE(MT6360_OTPI, 8),
199 REGMAP_IRQ_REG_LINE(MT6360_CHG_AICCMEASL, 8),
200 REGMAP_IRQ_REG_LINE(MT6360_CHGDET_DONEI, 8),
201 REGMAP_IRQ_REG_LINE(MT6360_WDTMRI, 8),
202 REGMAP_IRQ_REG_LINE(MT6360_SSFINISHI, 8),
203 REGMAP_IRQ_REG_LINE(MT6360_CHG_RECHGI, 8),
204 REGMAP_IRQ_REG_LINE(MT6360_CHG_TERMI, 8),
205 REGMAP_IRQ_REG_LINE(MT6360_CHG_IEOCI, 8),
206 REGMAP_IRQ_REG_LINE(MT6360_PUMPX_DONEI, 8),
207 REGMAP_IRQ_REG_LINE(MT6360_BAT_OVP_ADC_EVT, 8),
208 REGMAP_IRQ_REG_LINE(MT6360_TYPEC_OTP_EVT, 8),
209 REGMAP_IRQ_REG_LINE(MT6360_ADC_WAKEUP_EVT, 8),
210 REGMAP_IRQ_REG_LINE(MT6360_ADC_DONEI, 8),
211 REGMAP_IRQ_REG_LINE(MT6360_BST_BATUVI, 8),
212 REGMAP_IRQ_REG_LINE(MT6360_BST_VBUSOVI, 8),
213 REGMAP_IRQ_REG_LINE(MT6360_BST_OLPI, 8),
214 REGMAP_IRQ_REG_LINE(MT6360_ATTACH_I, 8),
215 REGMAP_IRQ_REG_LINE(MT6360_DETACH_I, 8),
216 REGMAP_IRQ_REG_LINE(MT6360_QC30_STPDONE, 8),
217 REGMAP_IRQ_REG_LINE(MT6360_QC_VBUSDET_DONE, 8),
218 REGMAP_IRQ_REG_LINE(MT6360_HVDCP_DET, 8),
219 REGMAP_IRQ_REG_LINE(MT6360_CHGDETI, 8),
220 REGMAP_IRQ_REG_LINE(MT6360_DCDTI, 8),
221 REGMAP_IRQ_REG_LINE(MT6360_FOD_DONE_EVT, 8),
222 REGMAP_IRQ_REG_LINE(MT6360_FOD_OV_EVT, 8),
223 REGMAP_IRQ_REG_LINE(MT6360_CHRDET_UVP_EVT, 8),
224 REGMAP_IRQ_REG_LINE(MT6360_CHRDET_OVP_EVT, 8),
225 REGMAP_IRQ_REG_LINE(MT6360_CHRDET_EXT_EVT, 8),
226 REGMAP_IRQ_REG_LINE(MT6360_FOD_LR_EVT, 8),
227 REGMAP_IRQ_REG_LINE(MT6360_FOD_HR_EVT, 8),
228 REGMAP_IRQ_REG_LINE(MT6360_FOD_DISCHG_FAIL_EVT, 8),
229 REGMAP_IRQ_REG_LINE(MT6360_USBID_EVT, 8),
230 REGMAP_IRQ_REG_LINE(MT6360_APWDTRST_EVT, 8),
231 REGMAP_IRQ_REG_LINE(MT6360_EN_EVT, 8),
232 REGMAP_IRQ_REG_LINE(MT6360_QONB_RST_EVT, 8),
233 REGMAP_IRQ_REG_LINE(MT6360_MRSTB_EVT, 8),
234 REGMAP_IRQ_REG_LINE(MT6360_OTP_EVT, 8),
235 REGMAP_IRQ_REG_LINE(MT6360_VDDAOV_EVT, 8),
236 REGMAP_IRQ_REG_LINE(MT6360_SYSUV_EVT, 8),
237 REGMAP_IRQ_REG_LINE(MT6360_FLED_STRBPIN_EVT, 8),
238 REGMAP_IRQ_REG_LINE(MT6360_FLED_TORPIN_EVT, 8),
239 REGMAP_IRQ_REG_LINE(MT6360_FLED_TX_EVT, 8),
240 REGMAP_IRQ_REG_LINE(MT6360_FLED_LVF_EVT, 8),
241 REGMAP_IRQ_REG_LINE(MT6360_FLED2_SHORT_EVT, 8),
242 REGMAP_IRQ_REG_LINE(MT6360_FLED1_SHORT_EVT, 8),
243 REGMAP_IRQ_REG_LINE(MT6360_FLED2_STRB_EVT, 8),
244 REGMAP_IRQ_REG_LINE(MT6360_FLED1_STRB_EVT, 8),
245 REGMAP_IRQ_REG_LINE(MT6360_FLED2_STRB_TO_EVT, 8),
246 REGMAP_IRQ_REG_LINE(MT6360_FLED1_STRB_TO_EVT, 8),
247 REGMAP_IRQ_REG_LINE(MT6360_FLED2_TOR_EVT, 8),
248 REGMAP_IRQ_REG_LINE(MT6360_FLED1_TOR_EVT, 8),
249 REGMAP_IRQ_REG_LINE(MT6360_BUCK1_PGB_EVT, 8),
250 REGMAP_IRQ_REG_LINE(MT6360_BUCK1_OC_EVT, 8),
251 REGMAP_IRQ_REG_LINE(MT6360_BUCK1_OV_EVT, 8),
252 REGMAP_IRQ_REG_LINE(MT6360_BUCK1_UV_EVT, 8),
253 REGMAP_IRQ_REG_LINE(MT6360_BUCK2_PGB_EVT, 8),
254 REGMAP_IRQ_REG_LINE(MT6360_BUCK2_OC_EVT, 8),
255 REGMAP_IRQ_REG_LINE(MT6360_BUCK2_OV_EVT, 8),
256 REGMAP_IRQ_REG_LINE(MT6360_BUCK2_UV_EVT, 8),
257 REGMAP_IRQ_REG_LINE(MT6360_LDO1_OC_EVT, 8),
258 REGMAP_IRQ_REG_LINE(MT6360_LDO2_OC_EVT, 8),
259 REGMAP_IRQ_REG_LINE(MT6360_LDO3_OC_EVT, 8),
260 REGMAP_IRQ_REG_LINE(MT6360_LDO5_OC_EVT, 8),
261 REGMAP_IRQ_REG_LINE(MT6360_LDO6_OC_EVT, 8),
262 REGMAP_IRQ_REG_LINE(MT6360_LDO7_OC_EVT, 8),
263 REGMAP_IRQ_REG_LINE(MT6360_LDO1_PGB_EVT, 8),
264 REGMAP_IRQ_REG_LINE(MT6360_LDO2_PGB_EVT, 8),
265 REGMAP_IRQ_REG_LINE(MT6360_LDO3_PGB_EVT, 8),
266 REGMAP_IRQ_REG_LINE(MT6360_LDO5_PGB_EVT, 8),
267 REGMAP_IRQ_REG_LINE(MT6360_LDO6_PGB_EVT, 8),
268 REGMAP_IRQ_REG_LINE(MT6360_LDO7_PGB_EVT, 8),
338 MFD_CELL_OF("mt6360-adc", mt6360_adc_resources,
339 NULL, 0, 0, "mediatek,mt6360-adc"),
340 MFD_CELL_OF("mt6360-chg", mt6360_chg_resources,
341 NULL, 0, 0, "mediatek,mt6360-chg"),
342 MFD_CELL_OF("mt6360-led", mt6360_led_resources,
343 NULL, 0, 0, "mediatek,mt6360-led"),
344 MFD_CELL_RES("mt6360-regulator", mt6360_regulator_resources),
345 MFD_CELL_OF("mt6360-tcpc", NULL,
346 NULL, 0, 0, "mediatek,mt6360-tcpc"),
354 ret = regmap_read(ddata->regmap, MT6360_PMU_DEV_INFO, &info); in mt6360_check_vendor_info()
355 if (ret < 0) in mt6360_check_vendor_info()
359 dev_err(ddata->dev, "Device not supported\n"); in mt6360_check_vendor_info()
360 return -ENODEV; in mt6360_check_vendor_info()
363 ddata->chip_rev = info & CHIP_REV_MASK; in mt6360_check_vendor_info()
365 return 0; in mt6360_check_vendor_info()
377 /* Address is already in encoded [5:0] */ in mt6360_xlate_pmicldo_addr()
394 return -EINVAL; in mt6360_xlate_pmicldo_addr()
397 return 0; in mt6360_xlate_pmicldo_addr()
414 return -EINVAL; in mt6360_regmap_read()
416 i2c = ddata->i2c[bank]; in mt6360_regmap_read()
421 if (ret < 0) in mt6360_regmap_read()
428 return -ENOMEM; in mt6360_regmap_read()
430 buf[0] = I2C_ADDR_XLATE_8BIT(i2c->addr, I2C_SMBUS_READ); in mt6360_regmap_read()
435 if (ret < 0) in mt6360_regmap_read()
438 return -EIO; in mt6360_regmap_read()
441 crc = crc8(ddata->crc8_tbl, buf, val_size + MT6360_CRC_PREDATA_OFFSET, 0); in mt6360_regmap_read()
443 return -EIO; in mt6360_regmap_read()
448 return 0; in mt6360_regmap_read()
460 int write_size = val_size - MT6360_REGMAP_REG_BYTE_SIZE; in mt6360_regmap_write()
464 return -EINVAL; in mt6360_regmap_write()
466 i2c = ddata->i2c[bank]; in mt6360_regmap_write()
470 ret = mt6360_xlate_pmicldo_addr(®_addr, val_size - MT6360_REGMAP_REG_BYTE_SIZE); in mt6360_regmap_write()
471 if (ret < 0) in mt6360_regmap_write()
477 return -ENOMEM; in mt6360_regmap_write()
479 buf[0] = I2C_ADDR_XLATE_8BIT(i2c->addr, I2C_SMBUS_WRITE); in mt6360_regmap_write()
484 buf[val_size] = crc8(ddata->crc8_tbl, buf, val_size, 0); in mt6360_regmap_write()
522 .val_bits = 8,
534 ddata = devm_kzalloc(&client->dev, sizeof(*ddata), GFP_KERNEL); in mt6360_probe()
536 return -ENOMEM; in mt6360_probe()
538 ddata->dev = &client->dev; in mt6360_probe()
541 for (i = 0; i < MT6360_SLAVE_MAX - 1; i++) { in mt6360_probe()
542 ddata->i2c[i] = devm_i2c_new_dummy_device(&client->dev, in mt6360_probe()
543 client->adapter, in mt6360_probe()
545 if (IS_ERR(ddata->i2c[i])) { in mt6360_probe()
546 dev_err(&client->dev, in mt6360_probe()
547 "Failed to get new dummy I2C device for address 0x%x", in mt6360_probe()
549 return PTR_ERR(ddata->i2c[i]); in mt6360_probe()
552 ddata->i2c[MT6360_SLAVE_MAX - 1] = client; in mt6360_probe()
554 crc8_populate_msb(ddata->crc8_tbl, MT6360_CRC8_POLYNOMIAL); in mt6360_probe()
555 ddata->regmap = devm_regmap_init(ddata->dev, &mt6360_regmap_bus, ddata, in mt6360_probe()
557 if (IS_ERR(ddata->regmap)) { in mt6360_probe()
558 dev_err(&client->dev, "Failed to register regmap\n"); in mt6360_probe()
559 return PTR_ERR(ddata->regmap); in mt6360_probe()
566 ret = devm_regmap_add_irq_chip(&client->dev, ddata->regmap, client->irq, in mt6360_probe()
567 0, 0, &mt6360_irq_chip, in mt6360_probe()
568 &ddata->irq_data); in mt6360_probe()
570 dev_err(&client->dev, "Failed to add Regmap IRQ Chip\n"); in mt6360_probe()
574 ret = devm_mfd_add_devices(&client->dev, PLATFORM_DEVID_AUTO, in mt6360_probe()
576 0, regmap_irq_get_domain(ddata->irq_data)); in mt6360_probe()
578 dev_err(&client->dev, in mt6360_probe()
583 return 0; in mt6360_probe()
591 enable_irq_wake(i2c->irq); in mt6360_suspend()
593 return 0; in mt6360_suspend()
602 disable_irq_wake(i2c->irq); in mt6360_resume()
604 return 0; in mt6360_resume()