Lines Matching +full:0 +full:- +full:8
1 // SPDX-License-Identifier: GPL-2.0
19 MT6360_SLAVE_TCPC = 0,
35 #define MT6360_TCPC_SLAVEID 0x4E
36 #define MT6360_PMIC_SLAVEID 0x1A
37 #define MT6360_LDO_SLAVEID 0x64
38 #define MT6360_PMU_SLAVEID 0x34
40 #define MT6360_REG_TCPCSTART 0x00
41 #define MT6360_REG_TCPCEND 0xFF
42 #define MT6360_REG_PMICSTART 0x100
43 #define MT6360_REG_PMICEND 0x13B
44 #define MT6360_REG_LDOSTART 0x200
45 #define MT6360_REG_LDOEND 0x21C
46 #define MT6360_REG_PMUSTART 0x300
47 #define MT6360_PMU_DEV_INFO 0x300
48 #define MT6360_PMU_CHG_IRQ1 0x3D0
49 #define MT6360_PMU_CHG_MASK1 0x3F0
50 #define MT6360_REG_PMUEND 0x3FF
54 #define CHIP_VEN_MASK 0xF0
55 #define CHIP_VEN_MT6360 0x50
56 #define CHIP_REV_MASK 0x0F
58 #define MT6360_ADDRESS_MASK 0x3F
59 #define MT6360_DATA_SIZE_1_BYTE 0x00
60 #define MT6360_DATA_SIZE_2_BYTES 0x40
61 #define MT6360_DATA_SIZE_3_BYTES 0x80
62 #define MT6360_DATA_SIZE_4_BYTES 0xC0
64 #define MT6360_CRC8_POLYNOMIAL 0x7
76 #define I2C_ADDR_XLATE_8BIT(_addr, _rw) (((_addr & 0x7F) << 1) + _rw)
78 /* reg 0 -> 0 ~ 7 */
83 /* REG 1 -> 8 ~ 15 */
90 /* REG 2 -> 16 ~ 23 */
91 /* REG 3 -> 24 ~ 31 */
98 /* REG 4 -> 32 ~ 39 */
106 /* REG 5 -> 40 ~ 47 */
115 /* REG 6 -> 48 ~ 55 */
123 /* REG 7 -> 56 ~ 63 */
132 /* REG 8 -> 64 ~ 71 */
141 /* REG 9 -> 72 ~ 79 */
148 /* REG 10 -> 80 ~ 87 */
155 /* REG 11 -> 88 ~ 95 */
156 /* REG 12 -> 96 ~ 103 */
161 /* REG 13 -> 104 ~ 111 */
166 /* REG 14 -> 112 ~ 119 */
173 /* REG 15 -> 120 ~ 127 */
182 REGMAP_IRQ_REG_LINE(MT6360_CHG_TREG_EVT, 8),
183 REGMAP_IRQ_REG_LINE(MT6360_CHG_AICR_EVT, 8),
184 REGMAP_IRQ_REG_LINE(MT6360_CHG_MIVR_EVT, 8),
185 REGMAP_IRQ_REG_LINE(MT6360_PWR_RDY_EVT, 8),
186 REGMAP_IRQ_REG_LINE(MT6360_CHG_BATSYSUV_EVT, 8),
187 REGMAP_IRQ_REG_LINE(MT6360_FLED_CHG_VINOVP_EVT, 8),
188 REGMAP_IRQ_REG_LINE(MT6360_CHG_VSYSUV_EVT, 8),
189 REGMAP_IRQ_REG_LINE(MT6360_CHG_VSYSOV_EVT, 8),
190 REGMAP_IRQ_REG_LINE(MT6360_CHG_VBATOV_EVT, 8),
191 REGMAP_IRQ_REG_LINE(MT6360_CHG_VBUSOV_EVT, 8),
192 REGMAP_IRQ_REG_LINE(MT6360_WD_PMU_DET, 8),
193 REGMAP_IRQ_REG_LINE(MT6360_WD_PMU_DONE, 8),
194 REGMAP_IRQ_REG_LINE(MT6360_CHG_TMRI, 8),
195 REGMAP_IRQ_REG_LINE(MT6360_CHG_ADPBADI, 8),
196 REGMAP_IRQ_REG_LINE(MT6360_CHG_RVPI, 8),
197 REGMAP_IRQ_REG_LINE(MT6360_OTPI, 8),
198 REGMAP_IRQ_REG_LINE(MT6360_CHG_AICCMEASL, 8),
199 REGMAP_IRQ_REG_LINE(MT6360_CHGDET_DONEI, 8),
200 REGMAP_IRQ_REG_LINE(MT6360_WDTMRI, 8),
201 REGMAP_IRQ_REG_LINE(MT6360_SSFINISHI, 8),
202 REGMAP_IRQ_REG_LINE(MT6360_CHG_RECHGI, 8),
203 REGMAP_IRQ_REG_LINE(MT6360_CHG_TERMI, 8),
204 REGMAP_IRQ_REG_LINE(MT6360_CHG_IEOCI, 8),
205 REGMAP_IRQ_REG_LINE(MT6360_PUMPX_DONEI, 8),
206 REGMAP_IRQ_REG_LINE(MT6360_BAT_OVP_ADC_EVT, 8),
207 REGMAP_IRQ_REG_LINE(MT6360_TYPEC_OTP_EVT, 8),
208 REGMAP_IRQ_REG_LINE(MT6360_ADC_WAKEUP_EVT, 8),
209 REGMAP_IRQ_REG_LINE(MT6360_ADC_DONEI, 8),
210 REGMAP_IRQ_REG_LINE(MT6360_BST_BATUVI, 8),
211 REGMAP_IRQ_REG_LINE(MT6360_BST_VBUSOVI, 8),
212 REGMAP_IRQ_REG_LINE(MT6360_BST_OLPI, 8),
213 REGMAP_IRQ_REG_LINE(MT6360_ATTACH_I, 8),
214 REGMAP_IRQ_REG_LINE(MT6360_DETACH_I, 8),
215 REGMAP_IRQ_REG_LINE(MT6360_QC30_STPDONE, 8),
216 REGMAP_IRQ_REG_LINE(MT6360_QC_VBUSDET_DONE, 8),
217 REGMAP_IRQ_REG_LINE(MT6360_HVDCP_DET, 8),
218 REGMAP_IRQ_REG_LINE(MT6360_CHGDETI, 8),
219 REGMAP_IRQ_REG_LINE(MT6360_DCDTI, 8),
220 REGMAP_IRQ_REG_LINE(MT6360_FOD_DONE_EVT, 8),
221 REGMAP_IRQ_REG_LINE(MT6360_FOD_OV_EVT, 8),
222 REGMAP_IRQ_REG_LINE(MT6360_CHRDET_UVP_EVT, 8),
223 REGMAP_IRQ_REG_LINE(MT6360_CHRDET_OVP_EVT, 8),
224 REGMAP_IRQ_REG_LINE(MT6360_CHRDET_EXT_EVT, 8),
225 REGMAP_IRQ_REG_LINE(MT6360_FOD_LR_EVT, 8),
226 REGMAP_IRQ_REG_LINE(MT6360_FOD_HR_EVT, 8),
227 REGMAP_IRQ_REG_LINE(MT6360_FOD_DISCHG_FAIL_EVT, 8),
228 REGMAP_IRQ_REG_LINE(MT6360_USBID_EVT, 8),
229 REGMAP_IRQ_REG_LINE(MT6360_APWDTRST_EVT, 8),
230 REGMAP_IRQ_REG_LINE(MT6360_EN_EVT, 8),
231 REGMAP_IRQ_REG_LINE(MT6360_QONB_RST_EVT, 8),
232 REGMAP_IRQ_REG_LINE(MT6360_MRSTB_EVT, 8),
233 REGMAP_IRQ_REG_LINE(MT6360_OTP_EVT, 8),
234 REGMAP_IRQ_REG_LINE(MT6360_VDDAOV_EVT, 8),
235 REGMAP_IRQ_REG_LINE(MT6360_SYSUV_EVT, 8),
236 REGMAP_IRQ_REG_LINE(MT6360_FLED_STRBPIN_EVT, 8),
237 REGMAP_IRQ_REG_LINE(MT6360_FLED_TORPIN_EVT, 8),
238 REGMAP_IRQ_REG_LINE(MT6360_FLED_TX_EVT, 8),
239 REGMAP_IRQ_REG_LINE(MT6360_FLED_LVF_EVT, 8),
240 REGMAP_IRQ_REG_LINE(MT6360_FLED2_SHORT_EVT, 8),
241 REGMAP_IRQ_REG_LINE(MT6360_FLED1_SHORT_EVT, 8),
242 REGMAP_IRQ_REG_LINE(MT6360_FLED2_STRB_EVT, 8),
243 REGMAP_IRQ_REG_LINE(MT6360_FLED1_STRB_EVT, 8),
244 REGMAP_IRQ_REG_LINE(MT6360_FLED2_STRB_TO_EVT, 8),
245 REGMAP_IRQ_REG_LINE(MT6360_FLED1_STRB_TO_EVT, 8),
246 REGMAP_IRQ_REG_LINE(MT6360_FLED2_TOR_EVT, 8),
247 REGMAP_IRQ_REG_LINE(MT6360_FLED1_TOR_EVT, 8),
248 REGMAP_IRQ_REG_LINE(MT6360_BUCK1_PGB_EVT, 8),
249 REGMAP_IRQ_REG_LINE(MT6360_BUCK1_OC_EVT, 8),
250 REGMAP_IRQ_REG_LINE(MT6360_BUCK1_OV_EVT, 8),
251 REGMAP_IRQ_REG_LINE(MT6360_BUCK1_UV_EVT, 8),
252 REGMAP_IRQ_REG_LINE(MT6360_BUCK2_PGB_EVT, 8),
253 REGMAP_IRQ_REG_LINE(MT6360_BUCK2_OC_EVT, 8),
254 REGMAP_IRQ_REG_LINE(MT6360_BUCK2_OV_EVT, 8),
255 REGMAP_IRQ_REG_LINE(MT6360_BUCK2_UV_EVT, 8),
256 REGMAP_IRQ_REG_LINE(MT6360_LDO1_OC_EVT, 8),
257 REGMAP_IRQ_REG_LINE(MT6360_LDO2_OC_EVT, 8),
258 REGMAP_IRQ_REG_LINE(MT6360_LDO3_OC_EVT, 8),
259 REGMAP_IRQ_REG_LINE(MT6360_LDO5_OC_EVT, 8),
260 REGMAP_IRQ_REG_LINE(MT6360_LDO6_OC_EVT, 8),
261 REGMAP_IRQ_REG_LINE(MT6360_LDO7_OC_EVT, 8),
262 REGMAP_IRQ_REG_LINE(MT6360_LDO1_PGB_EVT, 8),
263 REGMAP_IRQ_REG_LINE(MT6360_LDO2_PGB_EVT, 8),
264 REGMAP_IRQ_REG_LINE(MT6360_LDO3_PGB_EVT, 8),
265 REGMAP_IRQ_REG_LINE(MT6360_LDO5_PGB_EVT, 8),
266 REGMAP_IRQ_REG_LINE(MT6360_LDO6_PGB_EVT, 8),
267 REGMAP_IRQ_REG_LINE(MT6360_LDO7_PGB_EVT, 8),
337 MFD_CELL_OF("mt6360-adc", mt6360_adc_resources,
338 NULL, 0, 0, "mediatek,mt6360-adc"),
339 MFD_CELL_OF("mt6360-chg", mt6360_chg_resources,
340 NULL, 0, 0, "mediatek,mt6360-chg"),
341 MFD_CELL_OF("mt6360-led", mt6360_led_resources,
342 NULL, 0, 0, "mediatek,mt6360-led"),
343 MFD_CELL_RES("mt6360-regulator", mt6360_regulator_resources),
344 MFD_CELL_OF("mt6360-tcpc", NULL,
345 NULL, 0, 0, "mediatek,mt6360-tcpc"),
353 ret = regmap_read(ddata->regmap, MT6360_PMU_DEV_INFO, &info); in mt6360_check_vendor_info()
354 if (ret < 0) in mt6360_check_vendor_info()
358 dev_err(ddata->dev, "Device not supported\n"); in mt6360_check_vendor_info()
359 return -ENODEV; in mt6360_check_vendor_info()
362 ddata->chip_rev = info & CHIP_REV_MASK; in mt6360_check_vendor_info()
364 return 0; in mt6360_check_vendor_info()
376 /* Address is already in encoded [5:0] */ in mt6360_xlate_pmicldo_addr()
393 return -EINVAL; in mt6360_xlate_pmicldo_addr()
396 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 ret = -EIO; in mt6360_regmap_read()
443 crc = crc8(ddata->crc8_tbl, buf, val_size + MT6360_CRC_PREDATA_OFFSET, 0); in mt6360_regmap_read()
445 ret = -EIO; in mt6360_regmap_read()
453 return (ret < 0) ? ret : 0; in mt6360_regmap_read()
465 int write_size = val_size - MT6360_REGMAP_REG_BYTE_SIZE; in mt6360_regmap_write()
469 return -EINVAL; in mt6360_regmap_write()
471 i2c = ddata->i2c[bank]; in mt6360_regmap_write()
475 ret = mt6360_xlate_pmicldo_addr(®_addr, val_size - MT6360_REGMAP_REG_BYTE_SIZE); in mt6360_regmap_write()
476 if (ret < 0) in mt6360_regmap_write()
482 return -ENOMEM; in mt6360_regmap_write()
484 buf[0] = I2C_ADDR_XLATE_8BIT(i2c->addr, I2C_SMBUS_WRITE); in mt6360_regmap_write()
489 buf[val_size] = crc8(ddata->crc8_tbl, buf, val_size, 0); in mt6360_regmap_write()
527 .val_bits = 8,
539 ddata = devm_kzalloc(&client->dev, sizeof(*ddata), GFP_KERNEL); in mt6360_probe()
541 return -ENOMEM; in mt6360_probe()
543 ddata->dev = &client->dev; in mt6360_probe()
546 for (i = 0; i < MT6360_SLAVE_MAX - 1; i++) { in mt6360_probe()
547 ddata->i2c[i] = devm_i2c_new_dummy_device(&client->dev, in mt6360_probe()
548 client->adapter, in mt6360_probe()
550 if (IS_ERR(ddata->i2c[i])) { in mt6360_probe()
551 dev_err(&client->dev, in mt6360_probe()
552 "Failed to get new dummy I2C device for address 0x%x", in mt6360_probe()
554 return PTR_ERR(ddata->i2c[i]); in mt6360_probe()
557 ddata->i2c[MT6360_SLAVE_MAX - 1] = client; in mt6360_probe()
559 crc8_populate_msb(ddata->crc8_tbl, MT6360_CRC8_POLYNOMIAL); in mt6360_probe()
560 ddata->regmap = devm_regmap_init(ddata->dev, &mt6360_regmap_bus, ddata, in mt6360_probe()
562 if (IS_ERR(ddata->regmap)) { in mt6360_probe()
563 dev_err(&client->dev, "Failed to register regmap\n"); in mt6360_probe()
564 return PTR_ERR(ddata->regmap); in mt6360_probe()
571 ret = devm_regmap_add_irq_chip(&client->dev, ddata->regmap, client->irq, in mt6360_probe()
572 0, 0, &mt6360_irq_chip, in mt6360_probe()
573 &ddata->irq_data); in mt6360_probe()
575 dev_err(&client->dev, "Failed to add Regmap IRQ Chip\n"); in mt6360_probe()
579 ret = devm_mfd_add_devices(&client->dev, PLATFORM_DEVID_AUTO, in mt6360_probe()
581 0, regmap_irq_get_domain(ddata->irq_data)); in mt6360_probe()
583 dev_err(&client->dev, in mt6360_probe()
588 return 0; in mt6360_probe()
596 enable_irq_wake(i2c->irq); in mt6360_suspend()
598 return 0; in mt6360_suspend()
607 disable_irq_wake(i2c->irq); in mt6360_resume()
609 return 0; in mt6360_resume()