Lines Matching +full:regulator +full:- +full:coupled +full:- +full:max +full:- +full:spread

1 // SPDX-License-Identifier: GPL-2.0+
4 * Copyright (C) 2019 GRATE-DRIVER project
7 * Copyright (C) 2010-2011 NVIDIA Corporation
10 #define pr_fmt(fmt) "tegra voltage-coupler: " fmt
15 #include <linux/regulator/coupler.h>
16 #include <linux/regulator/driver.h>
17 #include <linux/regulator/machine.h>
42 if (tegra->core_min_uV > 0) in tegra30_core_limit()
43 return tegra->core_min_uV; in tegra30_core_limit()
49 core_max_uV = max(core_cur_uV, 1200000); in tegra30_core_limit()
58 * whatever maximum value defined via board's device-tree. in tegra30_core_limit()
60 tegra->core_min_uV = core_max_uV; in tegra30_core_limit()
62 pr_info("core minimum voltage limited to %duV\n", tegra->core_min_uV); in tegra30_core_limit()
64 return tegra->core_min_uV; in tegra30_core_limit()
93 return -EINVAL; in tegra30_core_cpu_limit()
118 max_spread = cpu_rdev->constraints->max_spread[0]; in tegra30_voltage_update()
119 cpu_max_step = cpu_rdev->constraints->max_uV_step; in tegra30_voltage_update()
120 core_max_step = core_rdev->constraints->max_uV_step; in tegra30_voltage_update()
123 pr_err_once("cpu-core max-spread is undefined in device-tree\n"); in tegra30_voltage_update()
128 pr_err_once("cpu max-step is undefined in device-tree\n"); in tegra30_voltage_update()
133 pr_err_once("core max-step is undefined in device-tree\n"); in tegra30_voltage_update()
155 cpu_min_uV = core_min_uV - max_spread; in tegra30_voltage_update()
176 * CPU's regulator may not have any consumers, hence the voltage in tegra30_voltage_update()
192 core_min_uV = max(core_min_uV, tegra30_core_cpu_limit(cpu_min_uV)); in tegra30_voltage_update()
208 cpu_target_uV = max(cpu_uV - cpu_max_step, cpu_min_uV); in tegra30_voltage_update()
209 cpu_target_uV = max(core_uV - max_spread, cpu_target_uV); in tegra30_voltage_update()
228 core_target_uV = max(core_min_limited_uV, core_min_uV); in tegra30_voltage_update()
234 core_target_uV = max(core_target_uV, core_uV - core_max_step); in tegra30_voltage_update()
258 struct regulator_dev *core_rdev = tegra->core_rdev; in tegra30_regulator_balance_voltage()
259 struct regulator_dev *cpu_rdev = tegra->cpu_rdev; in tegra30_regulator_balance_voltage()
262 pr_err("regulators are not coupled properly\n"); in tegra30_regulator_balance_voltage()
263 return -EINVAL; in tegra30_regulator_balance_voltage()
273 struct device_node *np = rdev->dev.of_node; in tegra30_regulator_attach()
275 if (of_property_read_bool(np, "nvidia,tegra-core-regulator") && in tegra30_regulator_attach()
276 !tegra->core_rdev) { in tegra30_regulator_attach()
277 tegra->core_rdev = rdev; in tegra30_regulator_attach()
281 if (of_property_read_bool(np, "nvidia,tegra-cpu-regulator") && in tegra30_regulator_attach()
282 !tegra->cpu_rdev) { in tegra30_regulator_attach()
283 tegra->cpu_rdev = rdev; in tegra30_regulator_attach()
287 return -EINVAL; in tegra30_regulator_attach()
295 if (tegra->core_rdev == rdev) { in tegra30_regulator_detach()
296 tegra->core_rdev = NULL; in tegra30_regulator_detach()
300 if (tegra->cpu_rdev == rdev) { in tegra30_regulator_detach()
301 tegra->cpu_rdev = NULL; in tegra30_regulator_detach()
305 return -EINVAL; in tegra30_regulator_detach()