Lines Matching +full:- +full:- +full:pfuze200
1 // SPDX-License-Identifier: GPL-2.0+
3 // Copyright (C) 2011-2013 Freescale Semiconductor, Inc. All Rights Reserved.
63 enum chips { PFUZE100, PFUZE200, PFUZE3000 = 3, PFUZE3001 = 0x31, }; enumerator
111 { .compatible = "fsl,pfuze200", .data = (void *)PFUZE200},
126 switch (pfuze100->chip_id) { in pfuze100_set_ramp_delay()
134 case PFUZE200: in pfuze100_set_ramp_delay()
146 ramp_bits = (ramp_delay >> 1) - (ramp_delay >> 3); in pfuze100_set_ramp_delay()
149 ret = regmap_update_bits(pfuze100->regmap, in pfuze100_set_ramp_delay()
150 rdev->desc->vsel_reg + 4, in pfuze100_set_ramp_delay()
153 dev_err(pfuze100->dev, "ramp failed, err %d\n", ret); in pfuze100_set_ramp_delay()
155 ret = -EACCES; in pfuze100_set_ramp_delay()
239 .n_voltages = ((max) - (min)) / (step) + 1, \
277 .n_voltages = ((max) - (min)) / (step) + 1, \
313 .n_voltages = ((max) - (min)) / (step) + 1, \
355 .n_voltages = ((max) - (min)) / (step) + 1, \
390 PFUZE100_SW_REG(PFUZE200, SW1AB, PFUZE100_SW1ABVOL, 300000, 1875000, 25000),
391 PFUZE100_SW_REG(PFUZE200, SW2, PFUZE100_SW2VOL, 400000, 1975000, 25000),
392 PFUZE100_SW_REG(PFUZE200, SW3A, PFUZE100_SW3AVOL, 400000, 1975000, 25000),
393 PFUZE100_SW_REG(PFUZE200, SW3B, PFUZE100_SW3BVOL, 400000, 1975000, 25000),
394 PFUZE100_SWB_REG(PFUZE200, SWBST, PFUZE100_SWBSTCON1, 0x3 , pfuze100_swbst),
395 PFUZE100_SWB_REG(PFUZE200, VSNVS, PFUZE100_VSNVSVOL, 0x7, pfuze100_vsnvs),
396 PFUZE100_FIXED_REG(PFUZE200, VREFDDR, PFUZE100_VREFDDRCON, 750000),
397 PFUZE100_VGEN_REG(PFUZE200, VGEN1, PFUZE100_VGEN1VOL, 800000, 1550000, 50000),
398 PFUZE100_VGEN_REG(PFUZE200, VGEN2, PFUZE100_VGEN2VOL, 800000, 1550000, 50000),
399 PFUZE100_VGEN_REG(PFUZE200, VGEN3, PFUZE100_VGEN3VOL, 1800000, 3300000, 100000),
400 PFUZE100_VGEN_REG(PFUZE200, VGEN4, PFUZE100_VGEN4VOL, 1800000, 3300000, 100000),
401 PFUZE100_VGEN_REG(PFUZE200, VGEN5, PFUZE100_VGEN5VOL, 1800000, 3300000, 100000),
402 PFUZE100_VGEN_REG(PFUZE200, VGEN6, PFUZE100_VGEN6VOL, 1800000, 3300000, 100000),
403 PFUZE100_COIN_REG(PFUZE200, COIN, PFUZE100_COINVOL, 0x7, pfuze100_coin),
455 /* PFUZE200 */
511 struct device *dev = chip->dev; in pfuze_parse_regulators_dt()
515 np = of_node_get(dev->of_node); in pfuze_parse_regulators_dt()
517 return -EINVAL; in pfuze_parse_regulators_dt()
519 if (of_property_read_bool(np, "fsl,pfuze-support-disable-sw")) in pfuze_parse_regulators_dt()
520 chip->flags |= PFUZE_FLAG_DISABLE_SW; in pfuze_parse_regulators_dt()
526 return -EINVAL; in pfuze_parse_regulators_dt()
529 switch (chip->chip_id) { in pfuze_parse_regulators_dt()
540 case PFUZE200: in pfuze_parse_regulators_dt()
577 struct pfuze_chip *syspm_pfuze_chip = data->cb_data; in pfuze_power_off_prepare()
579 dev_info(syspm_pfuze_chip->dev, "Configure standby mode for power off"); in pfuze_power_off_prepare()
582 regmap_update_bits(syspm_pfuze_chip->regmap, PFUZE100_SW1ABMODE, in pfuze_power_off_prepare()
584 regmap_update_bits(syspm_pfuze_chip->regmap, PFUZE100_SW1CMODE, in pfuze_power_off_prepare()
586 regmap_update_bits(syspm_pfuze_chip->regmap, PFUZE100_SW2MODE, in pfuze_power_off_prepare()
588 regmap_update_bits(syspm_pfuze_chip->regmap, PFUZE100_SW3AMODE, in pfuze_power_off_prepare()
590 regmap_update_bits(syspm_pfuze_chip->regmap, PFUZE100_SW3BMODE, in pfuze_power_off_prepare()
592 regmap_update_bits(syspm_pfuze_chip->regmap, PFUZE100_SW4MODE, in pfuze_power_off_prepare()
595 regmap_update_bits(syspm_pfuze_chip->regmap, PFUZE100_VGEN1VOL, in pfuze_power_off_prepare()
598 regmap_update_bits(syspm_pfuze_chip->regmap, PFUZE100_VGEN2VOL, in pfuze_power_off_prepare()
601 regmap_update_bits(syspm_pfuze_chip->regmap, PFUZE100_VGEN3VOL, in pfuze_power_off_prepare()
604 regmap_update_bits(syspm_pfuze_chip->regmap, PFUZE100_VGEN4VOL, in pfuze_power_off_prepare()
607 regmap_update_bits(syspm_pfuze_chip->regmap, PFUZE100_VGEN5VOL, in pfuze_power_off_prepare()
610 regmap_update_bits(syspm_pfuze_chip->regmap, PFUZE100_VGEN6VOL, in pfuze_power_off_prepare()
621 if (pfuze_chip->chip_id != PFUZE100) { in pfuze_power_off_prepare_init()
622 dev_warn(pfuze_chip->dev, "Requested pm_power_off_prepare handler for not supported chip\n"); in pfuze_power_off_prepare_init()
623 return -ENODEV; in pfuze_power_off_prepare_init()
626 err = devm_register_sys_off_handler(pfuze_chip->dev, in pfuze_power_off_prepare_init()
632 dev_err(pfuze_chip->dev, "failed to register sys-off handler: %d\n", in pfuze_power_off_prepare_init()
645 ret = regmap_read(pfuze_chip->regmap, PFUZE100_DEVICEID, &value); in pfuze_identify()
649 if (((value & 0x0f) == 0x8) && (pfuze_chip->chip_id == PFUZE100)) { in pfuze_identify()
651 * Freescale misprogrammed 1-3% of parts prior to week 8 of 2013 in pfuze_identify()
654 dev_info(pfuze_chip->dev, "Assuming misprogrammed ID=0x8"); in pfuze_identify()
655 } else if ((value & 0x0f) != pfuze_chip->chip_id && in pfuze_identify()
656 (value & 0xf0) >> 4 != pfuze_chip->chip_id && in pfuze_identify()
657 (value != pfuze_chip->chip_id)) { in pfuze_identify()
659 dev_warn(pfuze_chip->dev, "Illegal ID: %x\n", value); in pfuze_identify()
660 return -ENODEV; in pfuze_identify()
663 ret = regmap_read(pfuze_chip->regmap, PFUZE100_REVID, &value); in pfuze_identify()
666 dev_info(pfuze_chip->dev, in pfuze_identify()
670 ret = regmap_read(pfuze_chip->regmap, PFUZE100_FABID, &value); in pfuze_identify()
673 dev_info(pfuze_chip->dev, "FAB: %x, FIN: %x\n", in pfuze_identify()
682 .max_register = PFUZE_NUMREGS - 1,
696 pfuze_chip = devm_kzalloc(&client->dev, sizeof(*pfuze_chip), in pfuze100_regulator_probe()
699 return -ENOMEM; in pfuze100_regulator_probe()
701 if (client->dev.of_node) { in pfuze100_regulator_probe()
703 &client->dev); in pfuze100_regulator_probe()
705 dev_err(&client->dev, "Error: No device match found\n"); in pfuze100_regulator_probe()
706 return -ENODEV; in pfuze100_regulator_probe()
708 pfuze_chip->chip_id = (int)(long)match->data; in pfuze100_regulator_probe()
710 pfuze_chip->chip_id = id->driver_data; in pfuze100_regulator_probe()
712 dev_err(&client->dev, "No dts match or id table match found\n"); in pfuze100_regulator_probe()
713 return -ENODEV; in pfuze100_regulator_probe()
717 pfuze_chip->dev = &client->dev; in pfuze100_regulator_probe()
719 pfuze_chip->regmap = devm_regmap_init_i2c(client, &pfuze_regmap_config); in pfuze100_regulator_probe()
720 if (IS_ERR(pfuze_chip->regmap)) { in pfuze100_regulator_probe()
721 ret = PTR_ERR(pfuze_chip->regmap); in pfuze100_regulator_probe()
722 dev_err(&client->dev, in pfuze100_regulator_probe()
729 dev_err(&client->dev, "unrecognized pfuze chip ID!\n"); in pfuze100_regulator_probe()
734 switch (pfuze_chip->chip_id) { in pfuze100_regulator_probe()
736 pfuze_chip->pfuze_regulators = pfuze3001_regulators; in pfuze100_regulator_probe()
743 pfuze_chip->pfuze_regulators = pfuze3000_regulators; in pfuze100_regulator_probe()
749 case PFUZE200: in pfuze100_regulator_probe()
750 pfuze_chip->pfuze_regulators = pfuze200_regulators; in pfuze100_regulator_probe()
757 pfuze_chip->pfuze_regulators = pfuze100_regulators; in pfuze100_regulator_probe()
763 dev_info(&client->dev, "pfuze%s found.\n", in pfuze100_regulator_probe()
764 (pfuze_chip->chip_id == PFUZE100) ? "100" : in pfuze100_regulator_probe()
765 (((pfuze_chip->chip_id == PFUZE200) ? "200" : in pfuze100_regulator_probe()
766 ((pfuze_chip->chip_id == PFUZE3000) ? "3000" : "3001")))); in pfuze100_regulator_probe()
768 memcpy(pfuze_chip->regulator_descs, pfuze_chip->pfuze_regulators, in pfuze100_regulator_probe()
780 desc = &pfuze_chip->regulator_descs[i].desc; in pfuze100_regulator_probe()
786 ret = regmap_read(pfuze_chip->regmap, in pfuze100_regulator_probe()
787 desc->vsel_reg, &val); in pfuze100_regulator_probe()
789 dev_err(&client->dev, "Fails to read from the register.\n"); in pfuze100_regulator_probe()
794 if (pfuze_chip->chip_id == PFUZE3000 || in pfuze100_regulator_probe()
795 pfuze_chip->chip_id == PFUZE3001) { in pfuze100_regulator_probe()
796 desc->volt_table = pfuze3000_sw2hi; in pfuze100_regulator_probe()
797 desc->n_voltages = ARRAY_SIZE(pfuze3000_sw2hi); in pfuze100_regulator_probe()
799 desc->min_uV = 800000; in pfuze100_regulator_probe()
800 desc->uV_step = 50000; in pfuze100_regulator_probe()
801 desc->n_voltages = 51; in pfuze100_regulator_probe()
812 if (pfuze_chip->flags & PFUZE_FLAG_DISABLE_SW) { in pfuze100_regulator_probe()
813 if (pfuze_chip->chip_id == PFUZE100 || in pfuze100_regulator_probe()
814 pfuze_chip->chip_id == PFUZE200) { in pfuze100_regulator_probe()
815 if (pfuze_chip->regulator_descs[i].sw_reg) { in pfuze100_regulator_probe()
816 desc->ops = &pfuze100_sw_disable_regulator_ops; in pfuze100_regulator_probe()
817 desc->enable_val = 0x8; in pfuze100_regulator_probe()
818 desc->disable_val = 0x0; in pfuze100_regulator_probe()
819 desc->enable_time = 500; in pfuze100_regulator_probe()
824 config.dev = &client->dev; in pfuze100_regulator_probe()
829 pfuze_chip->regulators[i] = in pfuze100_regulator_probe()
830 devm_regulator_register(&client->dev, desc, &config); in pfuze100_regulator_probe()
831 if (IS_ERR(pfuze_chip->regulators[i])) { in pfuze100_regulator_probe()
832 dev_err(&client->dev, "register regulator%s failed\n", in pfuze100_regulator_probe()
833 pfuze_chip->pfuze_regulators[i].desc.name); in pfuze100_regulator_probe()
834 return PTR_ERR(pfuze_chip->regulators[i]); in pfuze100_regulator_probe()
838 if (of_property_read_bool(client->dev.of_node, in pfuze100_regulator_probe()
839 "fsl,pmic-stby-poweroff")) in pfuze100_regulator_probe()
847 .name = "pfuze100-regulator",