Lines Matching +full:tegra30 +full:- +full:emc
1 // SPDX-License-Identifier: GPL-2.0+
3 * Voltage regulators coupler for NVIDIA Tegra30
4 * Copyright (C) 2019 GRATE-DRIVER project
7 * Copyright (C) 2010-2011 NVIDIA Corporation
10 #define pr_fmt(fmt) "tegra voltage-coupler: " fmt
48 * Tegra30 SoC has critical DVFS-capable devices that are in tegra30_core_limit()
49 * permanently-active or active at a boot time, like EMC in tegra30_core_limit()
55 * the state of all DVFS-critical CORE devices is synced. in tegra30_core_limit()
57 if (tegra_pmc_core_domain_state_synced() && !tegra->sys_reboot_mode) { in tegra30_core_limit()
62 if (tegra->core_min_uV > 0) in tegra30_core_limit()
63 return tegra->core_min_uV; in tegra30_core_limit()
78 * whatever maximum value defined via board's device-tree. in tegra30_core_limit()
80 tegra->core_min_uV = core_max_uV; in tegra30_core_limit()
82 pr_info("core voltage initialized to %duV\n", tegra->core_min_uV); in tegra30_core_limit()
84 return tegra->core_min_uV; in tegra30_core_limit()
113 return -EINVAL; in tegra30_core_cpu_limit()
136 * by the CORE voltage. This applies to all Tegra30 SoC's. in tegra30_voltage_update()
138 max_spread = cpu_rdev->constraints->max_spread[0]; in tegra30_voltage_update()
139 cpu_max_step = cpu_rdev->constraints->max_uV_step; in tegra30_voltage_update()
140 core_max_step = core_rdev->constraints->max_uV_step; in tegra30_voltage_update()
143 pr_err_once("cpu-core max-spread is undefined in device-tree\n"); in tegra30_voltage_update()
148 pr_err_once("cpu max-step is undefined in device-tree\n"); in tegra30_voltage_update()
153 pr_err_once("core max-step is undefined in device-tree\n"); in tegra30_voltage_update()
175 cpu_min_uV = core_min_uV - max_spread; in tegra30_voltage_update()
196 if (!tegra->cpu_min_uV) in tegra30_voltage_update()
197 tegra->cpu_min_uV = cpu_uV; in tegra30_voltage_update()
223 if (tegra->sys_reboot_mode) in tegra30_voltage_update()
224 cpu_min_uV = max(cpu_min_uV, tegra->cpu_min_uV); in tegra30_voltage_update()
236 cpu_target_uV = max(cpu_uV - cpu_max_step, cpu_min_uV); in tegra30_voltage_update()
237 cpu_target_uV = max(core_uV - max_spread, cpu_target_uV); in tegra30_voltage_update()
262 core_target_uV = max(core_target_uV, core_uV - core_max_step); in tegra30_voltage_update()
286 struct regulator_dev *core_rdev = tegra->core_rdev; in tegra30_regulator_balance_voltage()
287 struct regulator_dev *cpu_rdev = tegra->cpu_rdev; in tegra30_regulator_balance_voltage()
291 return -EINVAL; in tegra30_regulator_balance_voltage()
294 tegra->sys_reboot_mode = READ_ONCE(tegra->sys_reboot_mode_req); in tegra30_regulator_balance_voltage()
304 if (!tegra->core_rdev || !tegra->cpu_rdev) in tegra30_regulator_prepare_reboot()
307 WRITE_ONCE(tegra->sys_reboot_mode_req, true); in tegra30_regulator_prepare_reboot()
310 * Some devices use CPU soft-reboot method and in this case we in tegra30_regulator_prepare_reboot()
314 err = regulator_sync_voltage_rdev(tegra->cpu_rdev); in tegra30_regulator_prepare_reboot()
318 err = regulator_sync_voltage_rdev(tegra->core_rdev); in tegra30_regulator_prepare_reboot()
322 WRITE_ONCE(tegra->sys_reboot_mode_req, sys_reboot_mode); in tegra30_regulator_prepare_reboot()
348 struct device_node *np = rdev->dev.of_node; in tegra30_regulator_attach()
350 if (of_property_read_bool(np, "nvidia,tegra-core-regulator") && in tegra30_regulator_attach()
351 !tegra->core_rdev) { in tegra30_regulator_attach()
352 tegra->core_rdev = rdev; in tegra30_regulator_attach()
356 if (of_property_read_bool(np, "nvidia,tegra-cpu-regulator") && in tegra30_regulator_attach()
357 !tegra->cpu_rdev) { in tegra30_regulator_attach()
358 tegra->cpu_rdev = rdev; in tegra30_regulator_attach()
362 return -EINVAL; in tegra30_regulator_attach()
376 return -EPERM; in tegra30_regulator_detach()
378 if (tegra->core_rdev == rdev) { in tegra30_regulator_detach()
379 tegra->core_rdev = NULL; in tegra30_regulator_detach()
383 if (tegra->cpu_rdev == rdev) { in tegra30_regulator_detach()
384 tegra->cpu_rdev = NULL; in tegra30_regulator_detach()
388 return -EINVAL; in tegra30_regulator_detach()
404 if (!of_machine_is_compatible("nvidia,tegra30")) in tegra_regulator_coupler_init()