25 #include <linux/export.h>
27 #include <linux/slab.h>
57 if (!voltdm || IS_ERR(voltdm)) {
58 pr_warning(
"%s: VDD specified does not exist!\n", __func__);
74 unsigned long target_volt)
77 unsigned long volt = 0;
79 if (!voltdm || IS_ERR(voltdm)) {
80 pr_warning(
"%s: VDD specified does not exist!\n", __func__);
85 pr_err(
"%s: No voltage scale API registered for vdd_%s\n",
86 __func__, voltdm->
name);
91 for (i = 0; voltdm->
volt_data[
i].volt_nominal != 0; i++) {
92 if (voltdm->
volt_data[i].volt_nominal >= target_volt) {
99 pr_warning(
"%s: not scaling. OPP voltage for %lu, not found.\n",
100 __func__, target_volt);
104 ret = voltdm->
scale(voltdm, volt);
122 unsigned long target_volt;
124 if (!voltdm || IS_ERR(voltdm)) {
125 pr_warning(
"%s: VDD specified does not exist!\n", __func__);
131 pr_err(
"%s: unable to find current voltage for vdd_%s\n",
132 __func__, voltdm->
name);
154 if (!voltdm || IS_ERR(voltdm)) {
155 pr_warning(
"%s: VDD specified does not exist!\n", __func__);
182 if (!voltdm || IS_ERR(voltdm)) {
183 pr_warning(
"%s: VDD specified does not exist!\n", __func__);
188 pr_warning(
"%s: voltage table does not exist for vdd_%s\n",
189 __func__, voltdm->
name);
193 for (i = 0; voltdm->
volt_data[
i].volt_nominal != 0; i++) {
194 if (voltdm->
volt_data[i].volt_nominal == volt)
198 pr_notice(
"%s: Unable to match the current voltage with the voltage table for vdd_%s\n",
199 __func__, voltdm->
name);
216 if (!voltdm || IS_ERR(voltdm)) {
217 pr_warning(
"%s: VDD specified does not exist!\n", __func__);
237 int voltscale_method)
239 if (!voltdm || IS_ERR(voltdm)) {
240 pr_warning(
"%s: VDD specified does not exist!\n", __func__);
244 switch (voltscale_method) {
252 pr_warn(
"%s: Trying to change the method of voltage scaling to an unsupported one!\n",
268 if (list_empty(&voltdm_list)) {
269 pr_err(
"%s: Voltage driver support not added\n",
281 if (IS_ERR(sys_ck)) {
282 pr_warning(
"%s: Could not get sys clk.\n", __func__);
311 voltdm = temp_voltdm;
331 if (!voltdm || !pwrdm)
334 pr_debug(
"voltagedomain: %s: associating powerdomain %s\n",
364 ret = (*fn)(
voltdm, pwrdm);
389 ret = (*fn)(temp_voltdm,
user);
399 if (!voltdm || !voltdm->
name)
403 list_add(&voltdm->
node, &voltdm_list);
405 pr_debug(
"voltagedomain: registered %s\n", voltdm->
name);
424 voltdm = _voltdm_lookup(name);
443 for (v = voltdms; *
v; v++)
444 _voltdm_register(*v);