Lines Matching +full:vsel +full:- +full:active +full:- +full:low

1 // SPDX-License-Identifier: GPL-2.0-only
37 #define RT6160_N_VOUTS ((RT6160_VOUT_MAXUV - RT6160_VOUT_MINUV) / RT6160_VOUT_STPUV + 1)
56 if (!priv->enable_gpio) in rt6160_enable()
59 gpiod_set_value_cansleep(priv->enable_gpio, 1); in rt6160_enable()
60 priv->enable_state = true; in rt6160_enable()
64 regcache_cache_only(priv->regmap, false); in rt6160_enable()
65 return regcache_sync(priv->regmap); in rt6160_enable()
72 if (!priv->enable_gpio) in rt6160_disable()
73 return -EINVAL; in rt6160_disable()
76 regcache_cache_only(priv->regmap, true); in rt6160_disable()
77 regcache_mark_dirty(priv->regmap); in rt6160_disable()
79 priv->enable_state = false; in rt6160_disable()
80 gpiod_set_value_cansleep(priv->enable_gpio, 0); in rt6160_disable()
89 return priv->enable_state ? 1 : 0; in rt6160_is_enabled()
105 dev_err(&rdev->dev, "mode not supported\n"); in rt6160_set_mode()
106 return -EINVAL; in rt6160_set_mode()
132 int vsel; in rt6160_set_suspend_voltage() local
134 vsel = regulator_map_voltage_linear(rdev, uV, uV); in rt6160_set_suspend_voltage()
135 if (vsel < 0) in rt6160_set_suspend_voltage()
136 return vsel; in rt6160_set_suspend_voltage()
138 if (rdev->desc->vsel_reg == RT6160_REG_VSELL) in rt6160_set_suspend_voltage()
144 RT6160_VSEL_MASK, vsel); in rt6160_set_suspend_voltage()
236 priv = devm_kzalloc(&i2c->dev, sizeof(*priv), GFP_KERNEL); in rt6160_probe()
238 return -ENOMEM; in rt6160_probe()
241 device_property_present(&i2c->dev, "richtek,vsel-active-low"); in rt6160_probe()
243 priv->enable_gpio = devm_gpiod_get_optional(&i2c->dev, "enable", GPIOD_OUT_HIGH); in rt6160_probe()
244 if (IS_ERR(priv->enable_gpio)) { in rt6160_probe()
245 dev_err(&i2c->dev, "Failed to get 'enable' gpio\n"); in rt6160_probe()
246 return PTR_ERR(priv->enable_gpio); in rt6160_probe()
248 priv->enable_state = true; in rt6160_probe()
252 priv->regmap = devm_regmap_init_i2c(i2c, &rt6160_regmap_config); in rt6160_probe()
253 if (IS_ERR(priv->regmap)) { in rt6160_probe()
254 ret = PTR_ERR(priv->regmap); in rt6160_probe()
255 dev_err(&i2c->dev, "Failed to init regmap (%d)\n", ret); in rt6160_probe()
259 ret = regmap_read(priv->regmap, RT6160_REG_DEVID, &devid); in rt6160_probe()
264 dev_err(&i2c->dev, "VID not correct [0x%02x]\n", devid); in rt6160_probe()
265 return -ENODEV; in rt6160_probe()
268 priv->desc.name = "rt6160-buckboost"; in rt6160_probe()
269 priv->desc.type = REGULATOR_VOLTAGE; in rt6160_probe()
270 priv->desc.owner = THIS_MODULE; in rt6160_probe()
271 priv->desc.min_uV = RT6160_VOUT_MINUV; in rt6160_probe()
272 priv->desc.uV_step = RT6160_VOUT_STPUV; in rt6160_probe()
274 priv->desc.vsel_reg = RT6160_REG_VSELL; in rt6160_probe()
276 priv->desc.vsel_reg = RT6160_REG_VSELH; in rt6160_probe()
277 priv->desc.vsel_mask = RT6160_VSEL_MASK; in rt6160_probe()
278 priv->desc.n_voltages = RT6160_N_VOUTS; in rt6160_probe()
279 priv->desc.ramp_reg = RT6160_REG_CNTL; in rt6160_probe()
280 priv->desc.ramp_mask = RT6160_RAMPRATE_MASK; in rt6160_probe()
281 priv->desc.ramp_delay_table = rt6160_ramp_tables; in rt6160_probe()
282 priv->desc.n_ramp_values = ARRAY_SIZE(rt6160_ramp_tables); in rt6160_probe()
283 priv->desc.of_map_mode = rt6160_of_map_mode; in rt6160_probe()
284 priv->desc.ops = &rt6160_regulator_ops; in rt6160_probe()
286 regulator_cfg.dev = &i2c->dev; in rt6160_probe()
287 regulator_cfg.of_node = i2c->dev.of_node; in rt6160_probe()
288 regulator_cfg.regmap = priv->regmap; in rt6160_probe()
290 regulator_cfg.init_data = of_get_regulator_init_data(&i2c->dev, i2c->dev.of_node, in rt6160_probe()
291 &priv->desc); in rt6160_probe()
293 rdev = devm_regulator_register(&i2c->dev, &priv->desc, &regulator_cfg); in rt6160_probe()
295 dev_err(&i2c->dev, "Failed to register regulator\n"); in rt6160_probe()