Lines Matching +full:dvs +full:- +full:gpio
1 // SPDX-License-Identifier: GPL-2.0-only
13 #include <linux/gpio/consumer.h>
88 /* Default DVS Mode */
92 /* dump registers in regmap-debugfs */
160 ret = regmap_read(lp->regmap, addr, &val); in lp872x_read_byte()
162 dev_err(lp->dev, "failed to read 0x%.2x\n", addr); in lp872x_read_byte()
172 return regmap_write(lp->regmap, addr, data); in lp872x_write_byte()
178 return regmap_update_bits(lp->regmap, addr, mask, data); in lp872x_update_bits()
183 enum lp872x_id chip = lp->chipid; in lp872x_get_timestep_usec()
203 return -EINVAL; in lp872x_get_timestep_usec()
212 return -EINVAL; in lp872x_get_timestep_usec()
233 addr = LP872X_LDO1_VOUT + rid - LP8725_ID_BASE; in lp872x_regulator_enable_time()
239 return -EINVAL; in lp872x_regulator_enable_time()
252 struct gpio_desc *gpio) in lp872x_set_dvs() argument
257 gpiod_set_value(gpio, state); in lp872x_set_dvs()
258 lp->dvs_pin = state; in lp872x_set_dvs()
272 addr = (lp->dvs_pin == GPIOD_OUT_HIGH) ? in lp872x_select_buck_vout_addr()
286 addr = (lp->dvs_pin == GPIOD_OUT_HIGH) ? in lp872x_select_buck_vout_addr()
321 struct lp872x_dvs *dvs = lp->pdata ? lp->pdata->dvs : NULL; in lp872x_buck_set_voltage_sel() local
323 if (dvs && dvs->gpio) in lp872x_buck_set_voltage_sel()
324 lp872x_set_dvs(lp, dvs->vsel, dvs->gpio); in lp872x_buck_set_voltage_sel()
328 return -EINVAL; in lp872x_buck_set_voltage_sel()
342 return -EINVAL; in lp872x_buck_get_voltage_sel()
374 return -EINVAL; in lp872x_buck_set_mode()
382 return -EINVAL; in lp872x_buck_set_mode()
408 return -EINVAL; in lp872x_buck_get_mode()
677 struct lp872x_dvs *dvs = lp->pdata ? lp->pdata->dvs : NULL; in lp872x_init_dvs() local
682 if (!dvs) in lp872x_init_dvs()
685 if (!dvs->gpio) in lp872x_init_dvs()
688 pinstate = dvs->init_state; in lp872x_init_dvs()
689 dvs->gpio = devm_gpiod_get_optional(lp->dev, "ti,dvs", pinstate); in lp872x_init_dvs()
691 if (IS_ERR(dvs->gpio)) { in lp872x_init_dvs()
692 dev_err(lp->dev, "gpio request err: %ld\n", PTR_ERR(dvs->gpio)); in lp872x_init_dvs()
693 return PTR_ERR(dvs->gpio); in lp872x_init_dvs()
696 lp->dvs_pin = pinstate; in lp872x_init_dvs()
701 return lp872x_update_bits(lp, LP872X_GENERAL_CFG, mask[lp->chipid], in lp872x_init_dvs()
702 default_dvs_mode[lp->chipid]); in lp872x_init_dvs()
707 if (!lp->pdata) in lp872x_hw_enable()
708 return -EINVAL; in lp872x_hw_enable()
710 if (!lp->pdata->enable_gpio) in lp872x_hw_enable()
713 /* Always set enable GPIO high. */ in lp872x_hw_enable()
714 lp->pdata->enable_gpio = devm_gpiod_get_optional(lp->dev, "enable", GPIOD_OUT_HIGH); in lp872x_hw_enable()
715 if (IS_ERR(lp->pdata->enable_gpio)) { in lp872x_hw_enable()
716 dev_err(lp->dev, "gpio request err: %ld\n", PTR_ERR(lp->pdata->enable_gpio)); in lp872x_hw_enable()
717 return PTR_ERR(lp->pdata->enable_gpio); in lp872x_hw_enable()
721 if (lp->chipid == LP8720) in lp872x_hw_enable()
731 struct lp872x_platform_data *pdata = lp->pdata; in lp872x_config()
734 if (!pdata || !pdata->update_config) in lp872x_config()
737 ret = lp872x_write_byte(lp, LP872X_GENERAL_CFG, pdata->general_config); in lp872x_config()
748 struct lp872x_platform_data *pdata = lp->pdata; in lp872x_find_regulator_init_data()
754 for (i = 0; i < lp->num_regulators; i++) { in lp872x_find_regulator_init_data()
755 if (pdata->regulator_data[i].id == id) in lp872x_find_regulator_init_data()
756 return pdata->regulator_data[i].init_data; in lp872x_find_regulator_init_data()
769 for (i = 0; i < lp->num_regulators; i++) { in lp872x_regulator_register()
770 desc = (lp->chipid == LP8720) ? &lp8720_regulator_desc[i] : in lp872x_regulator_register()
773 cfg.dev = lp->dev; in lp872x_regulator_register()
774 cfg.init_data = lp872x_find_regulator_init_data(desc->id, lp); in lp872x_regulator_register()
776 cfg.regmap = lp->regmap; in lp872x_regulator_register()
778 rdev = devm_regulator_register(lp->dev, desc, &cfg); in lp872x_regulator_register()
780 dev_err(lp->dev, "regulator register err"); in lp872x_regulator_register()
822 struct device_node *np = dev->of_node; in lp872x_populate_pdata_from_dt()
832 return ERR_PTR(-ENOMEM); in lp872x_populate_pdata_from_dt()
834 of_property_read_u8(np, "ti,general-config", &pdata->general_config); in lp872x_populate_pdata_from_dt()
835 pdata->update_config = of_property_read_bool(np, "ti,update-config"); in lp872x_populate_pdata_from_dt()
837 pdata->dvs = devm_kzalloc(dev, sizeof(struct lp872x_dvs), GFP_KERNEL); in lp872x_populate_pdata_from_dt()
838 if (!pdata->dvs) in lp872x_populate_pdata_from_dt()
839 return ERR_PTR(-ENOMEM); in lp872x_populate_pdata_from_dt()
841 of_property_read_u8(np, "ti,dvs-vsel", (u8 *)&pdata->dvs->vsel); in lp872x_populate_pdata_from_dt()
842 of_property_read_u8(np, "ti,dvs-state", &dvs_state); in lp872x_populate_pdata_from_dt()
843 pdata->dvs->init_state = dvs_state ? GPIOD_OUT_HIGH : GPIOD_OUT_LOW; in lp872x_populate_pdata_from_dt()
866 pdata->regulator_data[i].id = in lp872x_populate_pdata_from_dt()
868 pdata->regulator_data[i].init_data = match[i].init_data; in lp872x_populate_pdata_from_dt()
892 if (cl->dev.of_node) { in lp872x_probe()
893 pdata = lp872x_populate_pdata_from_dt(&cl->dev, in lp872x_probe()
894 (enum lp872x_id)id->driver_data); in lp872x_probe()
898 pdata = dev_get_platdata(&cl->dev); in lp872x_probe()
901 lp = devm_kzalloc(&cl->dev, sizeof(struct lp872x), GFP_KERNEL); in lp872x_probe()
903 return -ENOMEM; in lp872x_probe()
905 lp->num_regulators = lp872x_num_regulators[id->driver_data]; in lp872x_probe()
907 lp->regmap = devm_regmap_init_i2c(cl, &lp872x_regmap_config); in lp872x_probe()
908 if (IS_ERR(lp->regmap)) { in lp872x_probe()
909 ret = PTR_ERR(lp->regmap); in lp872x_probe()
910 dev_err(&cl->dev, "regmap init i2c err: %d\n", ret); in lp872x_probe()
914 lp->dev = &cl->dev; in lp872x_probe()
915 lp->pdata = pdata; in lp872x_probe()
916 lp->chipid = id->driver_data; in lp872x_probe()