Lines Matching +full:cros +full:- +full:ec +full:- +full:regulator
1 // SPDX-License-Identifier: GPL-2.0-only
9 #include <linux/regulator/driver.h>
10 #include <linux/regulator/machine.h>
11 #include <linux/regulator/of_regulator.h>
29 .index = data->index, in cros_ec_regulator_enable()
33 return cros_ec_cmd(data->ec_dev, 0, EC_CMD_REGULATOR_ENABLE, &cmd, in cros_ec_regulator_enable()
41 .index = data->index, in cros_ec_regulator_disable()
45 return cros_ec_cmd(data->ec_dev, 0, EC_CMD_REGULATOR_ENABLE, &cmd, in cros_ec_regulator_disable()
53 .index = data->index, in cros_ec_regulator_is_enabled()
58 ret = cros_ec_cmd(data->ec_dev, 0, EC_CMD_REGULATOR_IS_ENABLED, &cmd, in cros_ec_regulator_is_enabled()
70 if (selector >= data->num_voltages) in cros_ec_regulator_list_voltage()
71 return -EINVAL; in cros_ec_regulator_list_voltage()
73 return data->voltages_mV[selector] * 1000; in cros_ec_regulator_list_voltage()
80 .index = data->index, in cros_ec_regulator_get_voltage()
85 ret = cros_ec_cmd(data->ec_dev, 0, EC_CMD_REGULATOR_GET_VOLTAGE, &cmd, in cros_ec_regulator_get_voltage()
99 .index = data->index, in cros_ec_regulator_set_voltage()
109 return -EINVAL; in cros_ec_regulator_set_voltage()
111 return cros_ec_cmd(data->ec_dev, 0, EC_CMD_REGULATOR_SET_VOLTAGE, &cmd, in cros_ec_regulator_set_voltage()
128 .index = data->index, in cros_ec_regulator_init_info()
133 ret = cros_ec_cmd(data->ec_dev, 0, EC_CMD_REGULATOR_GET_INFO, &cmd, in cros_ec_regulator_init_info()
138 data->num_voltages = in cros_ec_regulator_init_info()
140 data->voltages_mV = in cros_ec_regulator_init_info()
142 sizeof(u16) * data->num_voltages, GFP_KERNEL); in cros_ec_regulator_init_info()
143 if (!data->voltages_mV) in cros_ec_regulator_init_info()
144 return -ENOMEM; in cros_ec_regulator_init_info()
146 data->desc.n_voltages = data->num_voltages; in cros_ec_regulator_init_info()
149 resp.name[ARRAY_SIZE(resp.name) - 1] = '\0'; in cros_ec_regulator_init_info()
150 data->desc.name = devm_kstrdup(dev, resp.name, GFP_KERNEL); in cros_ec_regulator_init_info()
151 if (!data->desc.name) in cros_ec_regulator_init_info()
152 return -ENOMEM; in cros_ec_regulator_init_info()
159 struct device *dev = &pdev->dev; in cros_ec_regulator_probe()
160 struct device_node *np = dev->of_node; in cros_ec_regulator_probe()
168 &pdev->dev, sizeof(struct cros_ec_regulator_data), GFP_KERNEL); in cros_ec_regulator_probe()
170 return -ENOMEM; in cros_ec_regulator_probe()
172 drvdata->ec_dev = dev_get_drvdata(dev->parent); in cros_ec_regulator_probe()
173 desc = &drvdata->desc; in cros_ec_regulator_probe()
177 return -EINVAL; in cros_ec_regulator_probe()
179 ret = of_property_read_u32(np, "reg", &drvdata->index); in cros_ec_regulator_probe()
183 desc->owner = THIS_MODULE; in cros_ec_regulator_probe()
184 desc->type = REGULATOR_VOLTAGE; in cros_ec_regulator_probe()
185 desc->ops = &cros_ec_regulator_voltage_ops; in cros_ec_regulator_probe()
191 cfg.dev = &pdev->dev; in cros_ec_regulator_probe()
196 drvdata->dev = devm_regulator_register(dev, &drvdata->desc, &cfg); in cros_ec_regulator_probe()
197 if (IS_ERR(drvdata->dev)) { in cros_ec_regulator_probe()
198 ret = PTR_ERR(drvdata->dev); in cros_ec_regulator_probe()
199 dev_err(&pdev->dev, "Failed to register regulator: %d\n", ret); in cros_ec_regulator_probe()
209 { .compatible = "google,cros-ec-regulator", },
217 .name = "cros-ec-regulator",
226 MODULE_DESCRIPTION("ChromeOS EC controlled regulator");
227 MODULE_AUTHOR("Pi-Hsun Shih <pihsun@chromium.org>");