Lines Matching +full:vout +full:- +full:supply
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * userspace-consumer.c
20 #include <linux/regulator/userspace-consumer.h>
39 return sprintf(buf, "%s\n", data->name); in name_show()
47 if (data->enabled) in state_show()
73 mutex_lock(&data->lock); in state_store()
74 if (enabled != data->enabled) { in state_store()
76 ret = regulator_bulk_enable(data->num_supplies, in state_store()
77 data->supplies); in state_store()
79 ret = regulator_bulk_disable(data->num_supplies, in state_store()
80 data->supplies); in state_store()
83 data->enabled = enabled; in state_store()
87 mutex_unlock(&data->lock); in state_store()
107 if (attr == &dev_attr_name.attr && !data->name) in attr_visible()
110 return attr->mode; in attr_visible()
125 pdata = dev_get_platdata(&pdev->dev); in regulator_userspace_consumer_probe()
127 if (!pdev->dev.of_node) in regulator_userspace_consumer_probe()
128 return -EINVAL; in regulator_userspace_consumer_probe()
133 pdata->no_autoswitch = true; in regulator_userspace_consumer_probe()
134 pdata->num_supplies = 1; in regulator_userspace_consumer_probe()
135 pdata->supplies = devm_kzalloc(&pdev->dev, sizeof(*pdata->supplies), GFP_KERNEL); in regulator_userspace_consumer_probe()
136 if (!pdata->supplies) in regulator_userspace_consumer_probe()
137 return -ENOMEM; in regulator_userspace_consumer_probe()
138 pdata->supplies[0].supply = "vout"; in regulator_userspace_consumer_probe()
141 if (pdata->num_supplies < 1) { in regulator_userspace_consumer_probe()
142 dev_err(&pdev->dev, "At least one supply required\n"); in regulator_userspace_consumer_probe()
143 return -EINVAL; in regulator_userspace_consumer_probe()
146 drvdata = devm_kzalloc(&pdev->dev, in regulator_userspace_consumer_probe()
150 return -ENOMEM; in regulator_userspace_consumer_probe()
152 drvdata->name = pdata->name; in regulator_userspace_consumer_probe()
153 drvdata->num_supplies = pdata->num_supplies; in regulator_userspace_consumer_probe()
154 drvdata->supplies = pdata->supplies; in regulator_userspace_consumer_probe()
155 drvdata->no_autoswitch = pdata->no_autoswitch; in regulator_userspace_consumer_probe()
157 mutex_init(&drvdata->lock); in regulator_userspace_consumer_probe()
159 ret = devm_regulator_bulk_get_exclusive(&pdev->dev, drvdata->num_supplies, in regulator_userspace_consumer_probe()
160 drvdata->supplies); in regulator_userspace_consumer_probe()
162 return dev_err_probe(&pdev->dev, ret, "Failed to get supplies\n"); in regulator_userspace_consumer_probe()
166 ret = sysfs_create_group(&pdev->dev.kobj, &attr_group); in regulator_userspace_consumer_probe()
170 if (pdata->init_on && !pdata->no_autoswitch) { in regulator_userspace_consumer_probe()
171 ret = regulator_bulk_enable(drvdata->num_supplies, in regulator_userspace_consumer_probe()
172 drvdata->supplies); in regulator_userspace_consumer_probe()
174 dev_err(&pdev->dev, in regulator_userspace_consumer_probe()
180 ret = regulator_is_enabled(pdata->supplies[0].consumer); in regulator_userspace_consumer_probe()
182 dev_err(&pdev->dev, "Failed to get regulator status\n"); in regulator_userspace_consumer_probe()
185 drvdata->enabled = !!ret; in regulator_userspace_consumer_probe()
190 sysfs_remove_group(&pdev->dev.kobj, &attr_group); in regulator_userspace_consumer_probe()
199 sysfs_remove_group(&pdev->dev.kobj, &attr_group); in regulator_userspace_consumer_remove()
201 if (data->enabled && !data->no_autoswitch) in regulator_userspace_consumer_remove()
202 regulator_bulk_disable(data->num_supplies, data->supplies); in regulator_userspace_consumer_remove()
206 { .compatible = "regulator-output", },
215 .name = "reg-userspace-consumer",