Lines Matching full:emc

42  * to control the EMC frequency. The top-level directory can be found here:
44 * /sys/kernel/debug/emc
49 * EMC frequencies.
53 * configured EMC frequency, this will cause the frequency to be
58 * the value is lower than the currently configured EMC frequency, this
63 static bool tegra186_emc_validate_rate(struct tegra186_emc *emc, in tegra186_emc_validate_rate() argument
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() local
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()
95 struct tegra186_emc *emc = data; in tegra186_emc_debug_min_rate_get() local
97 *rate = emc->debugfs.min_rate; in tegra186_emc_debug_min_rate_get()
104 struct tegra186_emc *emc = data; in tegra186_emc_debug_min_rate_set() local
107 if (!tegra186_emc_validate_rate(emc, rate)) 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()
125 struct tegra186_emc *emc = data; in tegra186_emc_debug_max_rate_get() local
127 *rate = emc->debugfs.max_rate; in tegra186_emc_debug_max_rate_get()
134 struct tegra186_emc *emc = data; in tegra186_emc_debug_max_rate_set() local
137 if (!tegra186_emc_validate_rate(emc, rate)) 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()
153 static int tegra186_emc_get_emc_dvfs_latency(struct tegra186_emc *emc) in tegra186_emc_get_emc_dvfs_latency() argument
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()
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()
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
222 * @src: ICC node for External Memory Controller (EMC)
258 static int tegra_emc_interconnect_init(struct tegra186_emc *emc) in tegra_emc_interconnect_init() argument
260 struct tegra_mc *mc = dev_get_drvdata(emc->dev->parent); 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()
282 icc_node_add(node, &emc->provider); 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()
316 struct tegra186_emc *emc; in tegra186_emc_probe() local
319 emc = devm_kzalloc(&pdev->dev, sizeof(*emc), GFP_KERNEL); in tegra186_emc_probe()
320 if (!emc) 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()
334 platform_set_drvdata(pdev, emc); 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()
338 err = tegra186_emc_get_emc_dvfs_latency(emc); in tegra186_emc_probe()
344 if (tegra_bpmp_mrq_is_supported(emc->bpmp, MRQ_BWMGR_INT)) { in tegra186_emc_probe()
349 * earlier than BPMP. So, save the BPMP ref got from the EMC in tegra186_emc_probe()
352 mc->bpmp = emc->bpmp; in tegra186_emc_probe()
362 err = tegra_emc_interconnect_init(emc); in tegra186_emc_probe()
372 tegra_bpmp_put(emc->bpmp); in tegra186_emc_probe()
379 struct tegra186_emc *emc = platform_get_drvdata(pdev); in tegra186_emc_remove() local
381 debugfs_remove_recursive(emc->debugfs.root); 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",