Lines Matching +full:tegra186 +full:- +full:mc

1 // SPDX-License-Identifier: GPL-2.0-only
14 #include "mc.h"
42 * to control the EMC frequency. The top-level directory can be found here:
48 * - available_rates: This file contains a list of valid, space-separated
51 * - min_rate: Writing a value to this file sets the given frequency as the
56 * - max_rate: Similarily to the min_rate file, writing a value to this file
68 for (i = 0; i < emc->num_dvfs; i++) in tegra186_emc_validate_rate()
69 if (rate == emc->dvfs[i].rate) in tegra186_emc_validate_rate()
78 struct tegra186_emc *emc = s->private; in tegra186_emc_debug_available_rates_show()
82 for (i = 0; i < emc->num_dvfs; i++) { in tegra186_emc_debug_available_rates_show()
83 seq_printf(s, "%s%lu", prefix, emc->dvfs[i].rate); in tegra186_emc_debug_available_rates_show()
97 *rate = emc->debugfs.min_rate; in tegra186_emc_debug_min_rate_get()
108 return -EINVAL; in tegra186_emc_debug_min_rate_set()
110 err = clk_set_min_rate(emc->clk, rate); in tegra186_emc_debug_min_rate_set()
114 emc->debugfs.min_rate = rate; in tegra186_emc_debug_min_rate_set()
127 *rate = emc->debugfs.max_rate; in tegra186_emc_debug_max_rate_get()
138 return -EINVAL; in tegra186_emc_debug_max_rate_set()
140 err = clk_set_max_rate(emc->clk, rate); in tegra186_emc_debug_max_rate_set()
144 emc->debugfs.max_rate = rate; in tegra186_emc_debug_max_rate_set()
167 err = tegra_bpmp_transfer(emc->bpmp, &msg); in tegra186_emc_get_emc_dvfs_latency()
169 dev_err(emc->dev, "failed to EMC DVFS pairs: %d\n", err); in tegra186_emc_get_emc_dvfs_latency()
173 dev_err(emc->dev, "EMC DVFS MRQ failed: %d (BPMP error code)\n", msg.rx.ret); in tegra186_emc_get_emc_dvfs_latency()
174 return -EINVAL; in tegra186_emc_get_emc_dvfs_latency()
177 emc->debugfs.min_rate = ULONG_MAX; in tegra186_emc_get_emc_dvfs_latency()
178 emc->debugfs.max_rate = 0; in tegra186_emc_get_emc_dvfs_latency()
180 emc->num_dvfs = response.num_pairs; in tegra186_emc_get_emc_dvfs_latency()
182 emc->dvfs = devm_kmalloc_array(emc->dev, emc->num_dvfs, sizeof(*emc->dvfs), GFP_KERNEL); in tegra186_emc_get_emc_dvfs_latency()
183 if (!emc->dvfs) in tegra186_emc_get_emc_dvfs_latency()
184 return -ENOMEM; in tegra186_emc_get_emc_dvfs_latency()
186 dev_dbg(emc->dev, "%u DVFS pairs:\n", emc->num_dvfs); in tegra186_emc_get_emc_dvfs_latency()
188 for (i = 0; i < emc->num_dvfs; i++) { in tegra186_emc_get_emc_dvfs_latency()
189 emc->dvfs[i].rate = response.pairs[i].freq * 1000; in tegra186_emc_get_emc_dvfs_latency()
190 emc->dvfs[i].latency = response.pairs[i].latency; in tegra186_emc_get_emc_dvfs_latency()
192 if (emc->dvfs[i].rate < emc->debugfs.min_rate) in tegra186_emc_get_emc_dvfs_latency()
193 emc->debugfs.min_rate = emc->dvfs[i].rate; in tegra186_emc_get_emc_dvfs_latency()
195 if (emc->dvfs[i].rate > emc->debugfs.max_rate) in tegra186_emc_get_emc_dvfs_latency()
196 emc->debugfs.max_rate = emc->dvfs[i].rate; in tegra186_emc_get_emc_dvfs_latency()
198 dev_dbg(emc->dev, " %2u: %lu Hz -> %lu us\n", i, in tegra186_emc_get_emc_dvfs_latency()
199 emc->dvfs[i].rate, emc->dvfs[i].latency); in tegra186_emc_get_emc_dvfs_latency()
202 err = clk_set_rate_range(emc->clk, emc->debugfs.min_rate, emc->debugfs.max_rate); in tegra186_emc_get_emc_dvfs_latency()
204 dev_err(emc->dev, "failed to set rate range [%lu-%lu] for %pC\n", in tegra186_emc_get_emc_dvfs_latency()
205 emc->debugfs.min_rate, emc->debugfs.max_rate, emc->clk); in tegra186_emc_get_emc_dvfs_latency()
209 emc->debugfs.root = debugfs_create_dir("emc", NULL); in tegra186_emc_get_emc_dvfs_latency()
210 debugfs_create_file("available_rates", 0444, emc->debugfs.root, emc, in tegra186_emc_get_emc_dvfs_latency()
212 debugfs_create_file("min_rate", 0644, emc->debugfs.root, emc, in tegra186_emc_get_emc_dvfs_latency()
214 debugfs_create_file("max_rate", 0644, emc->debugfs.root, emc, in tegra186_emc_get_emc_dvfs_latency()
221 * tegra_emc_icc_set_bw() - Set BW api for EMC provider
225 * Do nothing here as info to BPMP-FW is now passed in the BW set function
226 * of the MC driver. BPMP-FW sets the final Freq based on the passed values.
240 list_for_each_entry(node, &provider->nodes, node_list) { in tegra_emc_of_icc_xlate()
241 if (node->id != TEGRA_ICC_EMEM) in tegra_emc_of_icc_xlate()
247 return ERR_PTR(-EPROBE_DEFER); in tegra_emc_of_icc_xlate()
260 struct tegra_mc *mc = dev_get_drvdata(emc->dev->parent); in tegra_emc_interconnect_init() local
261 const struct tegra_mc_soc *soc = mc->soc; in tegra_emc_interconnect_init()
265 emc->provider.dev = emc->dev; in tegra_emc_interconnect_init()
266 emc->provider.set = tegra_emc_icc_set_bw; in tegra_emc_interconnect_init()
267 emc->provider.data = &emc->provider; in tegra_emc_interconnect_init()
268 emc->provider.aggregate = soc->icc_ops->aggregate; in tegra_emc_interconnect_init()
269 emc->provider.xlate = tegra_emc_of_icc_xlate; in tegra_emc_interconnect_init()
270 emc->provider.get_bw = tegra_emc_icc_get_init_bw; in tegra_emc_interconnect_init()
272 icc_provider_init(&emc->provider); in tegra_emc_interconnect_init()
281 node->name = "External Memory Controller"; in tegra_emc_interconnect_init()
282 icc_node_add(node, &emc->provider); in tegra_emc_interconnect_init()
296 node->name = "External Memory (DRAM)"; in tegra_emc_interconnect_init()
297 icc_node_add(node, &emc->provider); in tegra_emc_interconnect_init()
299 err = icc_provider_register(&emc->provider); in tegra_emc_interconnect_init()
306 icc_nodes_remove(&emc->provider); in tegra_emc_interconnect_init()
308 dev_err(emc->dev, "failed to initialize ICC: %d\n", err); in tegra_emc_interconnect_init()
315 struct tegra_mc *mc = dev_get_drvdata(pdev->dev.parent); in tegra186_emc_probe() local
319 emc = devm_kzalloc(&pdev->dev, sizeof(*emc), GFP_KERNEL); in tegra186_emc_probe()
321 return -ENOMEM; in tegra186_emc_probe()
323 emc->bpmp = tegra_bpmp_get(&pdev->dev); in tegra186_emc_probe()
324 if (IS_ERR(emc->bpmp)) in tegra186_emc_probe()
325 return dev_err_probe(&pdev->dev, PTR_ERR(emc->bpmp), "failed to get BPMP\n"); in tegra186_emc_probe()
327 emc->clk = devm_clk_get(&pdev->dev, "emc"); in tegra186_emc_probe()
328 if (IS_ERR(emc->clk)) { in tegra186_emc_probe()
329 err = PTR_ERR(emc->clk); in tegra186_emc_probe()
330 dev_err(&pdev->dev, "failed to get EMC clock: %d\n", err); in tegra186_emc_probe()
335 emc->dev = &pdev->dev; in tegra186_emc_probe()
337 if (tegra_bpmp_mrq_is_supported(emc->bpmp, MRQ_EMC_DVFS_LATENCY)) { in tegra186_emc_probe()
343 if (mc && mc->soc->icc_ops) { in tegra186_emc_probe()
344 if (tegra_bpmp_mrq_is_supported(emc->bpmp, MRQ_BWMGR_INT)) { in tegra186_emc_probe()
345 mc->bwmgr_mrq_supported = true; in tegra186_emc_probe()
348 * MC driver probe can't get BPMP reference as it gets probed in tegra186_emc_probe()
350 * DT node in the mc->bpmp and use it in MC's icc_set hook. in tegra186_emc_probe()
352 mc->bpmp = emc->bpmp; in tegra186_emc_probe()
357 * Initialize the ICC even if BPMP-FW doesn't support 'MRQ_BWMGR_INT'. in tegra186_emc_probe()
358 * Use the flag 'mc->bwmgr_mrq_supported' within MC driver and return in tegra186_emc_probe()
359 * EINVAL instead of passing the request to BPMP-FW later when the BW in tegra186_emc_probe()
364 mc->bpmp = NULL; in tegra186_emc_probe()
372 tegra_bpmp_put(emc->bpmp); in tegra186_emc_probe()
378 struct tegra_mc *mc = dev_get_drvdata(pdev->dev.parent); in tegra186_emc_remove() local
381 debugfs_remove_recursive(emc->debugfs.root); in tegra186_emc_remove()
383 mc->bpmp = NULL; in tegra186_emc_remove()
384 tegra_bpmp_put(emc->bpmp); in tegra186_emc_remove()
389 { .compatible = "nvidia,tegra186-emc" },
392 { .compatible = "nvidia,tegra194-emc" },
395 { .compatible = "nvidia,tegra234-emc" },
403 .name = "tegra186-emc",
414 MODULE_DESCRIPTION("NVIDIA Tegra186 External Memory Controller driver");