Lines Matching +full:nxp +full:- +full:i
1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright 2020 NXP.
4 * NXP PCA9450 pmic driver
55 .max_register = PCA9450_MAX_REGISTER - 1,
164 int ret, i; in buck_set_dvs() local
168 if (ret == -EINVAL) in buck_set_dvs()
173 for (i = 0; i < desc->n_voltages; i++) { in buck_set_dvs()
174 ret = regulator_desc_list_voltage_linear_range(desc, i); in buck_set_dvs()
178 i <<= ffs(desc->vsel_mask) - 1; in buck_set_dvs()
179 ret = regmap_update_bits(regmap, reg, mask, i); in buck_set_dvs()
189 ret = regmap_update_bits(regmap, regulator->desc.enable_reg, in buck_set_dvs()
201 const struct pc9450_dvs_config *dvs = &data->dvs; in pca9450_set_dvs_levels()
204 int i, ret = 0; in pca9450_set_dvs_levels() local
206 for (i = 0; i < PCA9450_DVS_LEVEL_MAX; i++) { in pca9450_set_dvs_levels()
207 switch (i) { in pca9450_set_dvs_levels()
209 prop = "nxp,dvs-run-voltage"; in pca9450_set_dvs_levels()
210 reg = dvs->run_reg; in pca9450_set_dvs_levels()
211 mask = dvs->run_mask; in pca9450_set_dvs_levels()
214 prop = "nxp,dvs-standby-voltage"; in pca9450_set_dvs_levels()
215 reg = dvs->standby_reg; in pca9450_set_dvs_levels()
216 mask = dvs->standby_mask; in pca9450_set_dvs_levels()
219 return -EINVAL; in pca9450_set_dvs_levels()
222 ret = buck_set_dvs(desc, np, cfg->regmap, prop, reg, mask); in pca9450_set_dvs_levels()
848 struct regmap *regmap = pca9450->regmap; in pca9450_irq_handler()
854 dev_err(pca9450->dev, in pca9450_irq_handler()
860 dev_warn(pca9450->dev, "PWRON interrupt.\n"); in pca9450_irq_handler()
863 dev_warn(pca9450->dev, "WDOGB interrupt.\n"); in pca9450_irq_handler()
866 dev_warn(pca9450->dev, "VRFLT1 interrupt.\n"); in pca9450_irq_handler()
869 dev_warn(pca9450->dev, "VRFLT2 interrupt.\n"); in pca9450_irq_handler()
872 dev_warn(pca9450->dev, "LOWVSYS interrupt.\n"); in pca9450_irq_handler()
875 dev_warn(pca9450->dev, "IRQ_THERM_105 interrupt.\n"); in pca9450_irq_handler()
878 dev_warn(pca9450->dev, "IRQ_THERM_125 interrupt.\n"); in pca9450_irq_handler()
886 of_device_get_match_data(&i2c->dev); in pca9450_i2c_probe()
890 unsigned int device_id, i; in pca9450_i2c_probe() local
894 pca9450 = devm_kzalloc(&i2c->dev, sizeof(struct pca9450), GFP_KERNEL); in pca9450_i2c_probe()
896 return -ENOMEM; in pca9450_i2c_probe()
901 pca9450->rcnt = ARRAY_SIZE(pca9450a_regulators); in pca9450_i2c_probe()
905 pca9450->rcnt = ARRAY_SIZE(pca9450bc_regulators); in pca9450_i2c_probe()
909 pca9450->rcnt = ARRAY_SIZE(pca9451a_regulators); in pca9450_i2c_probe()
912 dev_err(&i2c->dev, "Unknown device type"); in pca9450_i2c_probe()
913 return -EINVAL; in pca9450_i2c_probe()
916 pca9450->irq = i2c->irq; in pca9450_i2c_probe()
917 pca9450->type = type; in pca9450_i2c_probe()
918 pca9450->dev = &i2c->dev; in pca9450_i2c_probe()
920 dev_set_drvdata(&i2c->dev, pca9450); in pca9450_i2c_probe()
922 pca9450->regmap = devm_regmap_init_i2c(i2c, in pca9450_i2c_probe()
924 if (IS_ERR(pca9450->regmap)) { in pca9450_i2c_probe()
925 dev_err(&i2c->dev, "regmap initialization failed\n"); in pca9450_i2c_probe()
926 return PTR_ERR(pca9450->regmap); in pca9450_i2c_probe()
929 ret = regmap_read(pca9450->regmap, PCA9450_REG_DEV_ID, &device_id); in pca9450_i2c_probe()
931 dev_err(&i2c->dev, "Read device id error\n"); in pca9450_i2c_probe()
939 dev_err(&i2c->dev, "Device id(%x) mismatched\n", in pca9450_i2c_probe()
941 return -EINVAL; in pca9450_i2c_probe()
944 for (i = 0; i < pca9450->rcnt; i++) { in pca9450_i2c_probe()
949 r = ®ulator_desc[i]; in pca9450_i2c_probe()
950 desc = &r->desc; in pca9450_i2c_probe()
952 config.regmap = pca9450->regmap; in pca9450_i2c_probe()
953 config.dev = pca9450->dev; in pca9450_i2c_probe()
955 rdev = devm_regulator_register(pca9450->dev, desc, &config); in pca9450_i2c_probe()
958 dev_err(pca9450->dev, in pca9450_i2c_probe()
960 desc->name, ret); in pca9450_i2c_probe()
965 if (pca9450->irq) { in pca9450_i2c_probe()
966 ret = devm_request_threaded_irq(pca9450->dev, pca9450->irq, NULL, in pca9450_i2c_probe()
969 "pca9450-irq", pca9450); in pca9450_i2c_probe()
971 dev_err(pca9450->dev, "Failed to request IRQ: %d\n", in pca9450_i2c_probe()
972 pca9450->irq); in pca9450_i2c_probe()
976 ret = regmap_update_bits(pca9450->regmap, PCA9450_REG_INT1_MSK, in pca9450_i2c_probe()
981 dev_err(&i2c->dev, "Unmask irq error\n"); in pca9450_i2c_probe()
987 ret = regmap_clear_bits(pca9450->regmap, PCA9450_REG_BUCK123_DVS, in pca9450_i2c_probe()
990 dev_err(&i2c->dev, "Failed to clear PRESET_EN bit: %d\n", ret); in pca9450_i2c_probe()
994 if (of_property_read_bool(i2c->dev.of_node, "nxp,wdog_b-warm-reset")) in pca9450_i2c_probe()
1000 ret = regmap_update_bits(pca9450->regmap, PCA9450_REG_RESET_CTRL, in pca9450_i2c_probe()
1003 dev_err(&i2c->dev, "Failed to set WDOG_B reset behavior\n"); in pca9450_i2c_probe()
1007 if (of_property_read_bool(i2c->dev.of_node, "nxp,i2c-lt-enable")) { in pca9450_i2c_probe()
1009 ret = regmap_update_bits(pca9450->regmap, PCA9450_REG_CONFIG2, in pca9450_i2c_probe()
1012 dev_err(&i2c->dev, in pca9450_i2c_probe()
1023 pca9450->sd_vsel_gpio = gpiod_get_optional(pca9450->dev, "sd-vsel", GPIOD_OUT_HIGH); in pca9450_i2c_probe()
1025 if (IS_ERR(pca9450->sd_vsel_gpio)) { in pca9450_i2c_probe()
1026 dev_err(&i2c->dev, "Failed to get SD_VSEL GPIO\n"); in pca9450_i2c_probe()
1027 return PTR_ERR(pca9450->sd_vsel_gpio); in pca9450_i2c_probe()
1030 dev_info(&i2c->dev, "%s probed.\n", in pca9450_i2c_probe()
1039 .compatible = "nxp,pca9450a",
1043 .compatible = "nxp,pca9450b",
1047 .compatible = "nxp,pca9450c",
1051 .compatible = "nxp,pca9451a",
1060 .name = "nxp-pca9450",
1069 MODULE_AUTHOR("Robin Gong <yibin.gong@nxp.com>");
1070 MODULE_DESCRIPTION("NXP PCA9450 Power Management IC driver");