Lines Matching +full:tegra186 +full:- +full:bpmp
1 // SPDX-License-Identifier: GPL-2.0-only
12 #include <soc/tegra/bpmp.h>
20 struct tegra_bpmp *bpmp; member
38 * to control the EMC frequency. The top-level directory can be found here:
44 * - available_rates: This file contains a list of valid, space-separated
47 * - min_rate: Writing a value to this file sets the given frequency as the
52 * - max_rate: Similarily to the min_rate file, writing a value to this file
64 for (i = 0; i < emc->num_dvfs; i++) in tegra186_emc_validate_rate()
65 if (rate == emc->dvfs[i].rate) in tegra186_emc_validate_rate()
74 struct tegra186_emc *emc = s->private; in tegra186_emc_debug_available_rates_show()
78 for (i = 0; i < emc->num_dvfs; i++) { in tegra186_emc_debug_available_rates_show()
79 seq_printf(s, "%s%lu", prefix, emc->dvfs[i].rate); in tegra186_emc_debug_available_rates_show()
92 inode->i_private); in tegra186_emc_debug_available_rates_open()
106 *rate = emc->debugfs.min_rate; in tegra186_emc_debug_min_rate_get()
117 return -EINVAL; in tegra186_emc_debug_min_rate_set()
119 err = clk_set_min_rate(emc->clk, rate); in tegra186_emc_debug_min_rate_set()
123 emc->debugfs.min_rate = rate; in tegra186_emc_debug_min_rate_set()
136 *rate = emc->debugfs.max_rate; in tegra186_emc_debug_max_rate_get()
147 return -EINVAL; in tegra186_emc_debug_max_rate_set()
149 err = clk_set_max_rate(emc->clk, rate); in tegra186_emc_debug_max_rate_set()
153 emc->debugfs.max_rate = rate; in tegra186_emc_debug_max_rate_set()
170 emc = devm_kzalloc(&pdev->dev, sizeof(*emc), GFP_KERNEL); in tegra186_emc_probe()
172 return -ENOMEM; in tegra186_emc_probe()
174 emc->bpmp = tegra_bpmp_get(&pdev->dev); in tegra186_emc_probe()
175 if (IS_ERR(emc->bpmp)) in tegra186_emc_probe()
176 return dev_err_probe(&pdev->dev, PTR_ERR(emc->bpmp), "failed to get BPMP\n"); in tegra186_emc_probe()
178 emc->clk = devm_clk_get(&pdev->dev, "emc"); in tegra186_emc_probe()
179 if (IS_ERR(emc->clk)) { in tegra186_emc_probe()
180 err = PTR_ERR(emc->clk); in tegra186_emc_probe()
181 dev_err(&pdev->dev, "failed to get EMC clock: %d\n", err); in tegra186_emc_probe()
186 emc->dev = &pdev->dev; in tegra186_emc_probe()
195 err = tegra_bpmp_transfer(emc->bpmp, &msg); in tegra186_emc_probe()
197 dev_err(&pdev->dev, "failed to EMC DVFS pairs: %d\n", err); in tegra186_emc_probe()
201 err = -EINVAL; in tegra186_emc_probe()
202 dev_err(&pdev->dev, "EMC DVFS MRQ failed: %d (BPMP error code)\n", msg.rx.ret); in tegra186_emc_probe()
206 emc->debugfs.min_rate = ULONG_MAX; in tegra186_emc_probe()
207 emc->debugfs.max_rate = 0; in tegra186_emc_probe()
209 emc->num_dvfs = response.num_pairs; in tegra186_emc_probe()
211 emc->dvfs = devm_kmalloc_array(&pdev->dev, emc->num_dvfs, in tegra186_emc_probe()
212 sizeof(*emc->dvfs), GFP_KERNEL); in tegra186_emc_probe()
213 if (!emc->dvfs) { in tegra186_emc_probe()
214 err = -ENOMEM; in tegra186_emc_probe()
218 dev_dbg(&pdev->dev, "%u DVFS pairs:\n", emc->num_dvfs); in tegra186_emc_probe()
220 for (i = 0; i < emc->num_dvfs; i++) { in tegra186_emc_probe()
221 emc->dvfs[i].rate = response.pairs[i].freq * 1000; in tegra186_emc_probe()
222 emc->dvfs[i].latency = response.pairs[i].latency; in tegra186_emc_probe()
224 if (emc->dvfs[i].rate < emc->debugfs.min_rate) in tegra186_emc_probe()
225 emc->debugfs.min_rate = emc->dvfs[i].rate; in tegra186_emc_probe()
227 if (emc->dvfs[i].rate > emc->debugfs.max_rate) in tegra186_emc_probe()
228 emc->debugfs.max_rate = emc->dvfs[i].rate; in tegra186_emc_probe()
230 dev_dbg(&pdev->dev, " %2u: %lu Hz -> %lu us\n", i, in tegra186_emc_probe()
231 emc->dvfs[i].rate, emc->dvfs[i].latency); in tegra186_emc_probe()
234 err = clk_set_rate_range(emc->clk, emc->debugfs.min_rate, in tegra186_emc_probe()
235 emc->debugfs.max_rate); in tegra186_emc_probe()
237 dev_err(&pdev->dev, in tegra186_emc_probe()
238 "failed to set rate range [%lu-%lu] for %pC\n", in tegra186_emc_probe()
239 emc->debugfs.min_rate, emc->debugfs.max_rate, in tegra186_emc_probe()
240 emc->clk); in tegra186_emc_probe()
244 emc->debugfs.root = debugfs_create_dir("emc", NULL); in tegra186_emc_probe()
245 debugfs_create_file("available_rates", S_IRUGO, emc->debugfs.root, in tegra186_emc_probe()
247 debugfs_create_file("min_rate", S_IRUGO | S_IWUSR, emc->debugfs.root, in tegra186_emc_probe()
249 debugfs_create_file("max_rate", S_IRUGO | S_IWUSR, emc->debugfs.root, in tegra186_emc_probe()
255 tegra_bpmp_put(emc->bpmp); in tegra186_emc_probe()
263 debugfs_remove_recursive(emc->debugfs.root); in tegra186_emc_remove()
264 tegra_bpmp_put(emc->bpmp); in tegra186_emc_remove()
271 { .compatible = "nvidia,tegra186-emc" },
274 { .compatible = "nvidia,tegra194-emc" },
277 { .compatible = "nvidia,tegra234-emc" },
285 .name = "tegra186-emc",
295 MODULE_DESCRIPTION("NVIDIA Tegra186 External Memory Controller driver");