Lines Matching +full:tegra186 +full:- +full:bpmp

1 // SPDX-License-Identifier: GPL-2.0-only
7 #include <linux/dma-mapping.h>
12 #include <soc/tegra/bpmp.h>
13 #include <soc/tegra/bpmp-abi.h>
28 /* CPU0 - A57 Cluster */
33 /* CPU1 - Denver Cluster */
38 /* CPU2 - Denver Cluster */
43 /* CPU3 - A57 Cluster */
48 /* CPU4 - A57 Cluster */
53 /* CPU5 - A57 Cluster */
75 unsigned int cluster = data->cpus[policy->cpu].bpmp_cluster_id; in tegra186_cpufreq_init()
77 policy->freq_table = data->clusters[cluster].table; in tegra186_cpufreq_init()
78 policy->cpuinfo.transition_latency = 300 * 1000; in tegra186_cpufreq_init()
79 policy->driver_data = NULL; in tegra186_cpufreq_init()
88 struct cpufreq_frequency_table *tbl = policy->freq_table + index; in tegra186_cpufreq_set_target()
89 unsigned int edvd_offset = data->cpus[policy->cpu].edvd_offset; in tegra186_cpufreq_set_target()
90 u32 edvd_val = tbl->driver_data; in tegra186_cpufreq_set_target()
92 writel(edvd_val, data->regs + edvd_offset); in tegra186_cpufreq_set_target()
109 edvd_offset = data->cpus[policy->cpu].edvd_offset; in tegra186_cpufreq_get()
110 ndiv = readl(data->regs + edvd_offset) & EDVD_CORE_VOLT_FREQ_F_MASK; in tegra186_cpufreq_get()
111 cluster_id = data->cpus[policy->cpu].bpmp_cluster_id; in tegra186_cpufreq_get()
112 cluster = &data->clusters[cluster_id]; in tegra186_cpufreq_get()
115 return (cluster->ref_clk_khz * ndiv) / cluster->div; in tegra186_cpufreq_get()
119 .name = "tegra186",
130 struct platform_device *pdev, struct tegra_bpmp *bpmp, in init_vhint_table() argument
141 virt = dma_alloc_coherent(bpmp->dev, sizeof(*data), &phys, in init_vhint_table()
144 return ERR_PTR(-ENOMEM); in init_vhint_table()
157 err = tegra_bpmp_transfer(bpmp, &msg); in init_vhint_table()
163 for (i = data->vfloor; i <= data->vceil; i++) { in init_vhint_table()
164 u16 ndiv = data->ndiv[i]; in init_vhint_table()
166 if (ndiv < data->ndiv_min || ndiv > data->ndiv_max) in init_vhint_table()
170 if (i > 0 && ndiv == data->ndiv[i - 1]) in init_vhint_table()
176 table = devm_kcalloc(&pdev->dev, num_rates + 1, sizeof(*table), in init_vhint_table()
179 table = ERR_PTR(-ENOMEM); in init_vhint_table()
183 cluster->ref_clk_khz = data->ref_clk_hz / 1000; in init_vhint_table()
184 cluster->div = data->pdiv * data->mdiv; in init_vhint_table()
186 for (i = data->vfloor, j = 0; i <= data->vceil; i++) { in init_vhint_table()
188 u16 ndiv = data->ndiv[i]; in init_vhint_table()
191 if (ndiv < data->ndiv_min || ndiv > data->ndiv_max) in init_vhint_table()
195 if (i > 0 && ndiv == data->ndiv[i - 1]) in init_vhint_table()
202 point->driver_data = edvd_val; in init_vhint_table()
203 point->frequency = (cluster->ref_clk_khz * ndiv) / cluster->div; in init_vhint_table()
209 dma_free_coherent(bpmp->dev, sizeof(*data), virt, phys); in init_vhint_table()
217 struct tegra_bpmp *bpmp; in tegra186_cpufreq_probe() local
220 data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); in tegra186_cpufreq_probe()
222 return -ENOMEM; in tegra186_cpufreq_probe()
224 data->clusters = devm_kcalloc(&pdev->dev, TEGRA186_NUM_CLUSTERS, in tegra186_cpufreq_probe()
225 sizeof(*data->clusters), GFP_KERNEL); in tegra186_cpufreq_probe()
226 if (!data->clusters) in tegra186_cpufreq_probe()
227 return -ENOMEM; in tegra186_cpufreq_probe()
229 data->cpus = tegra186_cpus; in tegra186_cpufreq_probe()
231 bpmp = tegra_bpmp_get(&pdev->dev); in tegra186_cpufreq_probe()
232 if (IS_ERR(bpmp)) in tegra186_cpufreq_probe()
233 return PTR_ERR(bpmp); in tegra186_cpufreq_probe()
235 data->regs = devm_platform_ioremap_resource(pdev, 0); in tegra186_cpufreq_probe()
236 if (IS_ERR(data->regs)) { in tegra186_cpufreq_probe()
237 err = PTR_ERR(data->regs); in tegra186_cpufreq_probe()
242 struct tegra186_cpufreq_cluster *cluster = &data->clusters[i]; in tegra186_cpufreq_probe()
244 cluster->table = init_vhint_table(pdev, bpmp, cluster, i); in tegra186_cpufreq_probe()
245 if (IS_ERR(cluster->table)) { in tegra186_cpufreq_probe()
246 err = PTR_ERR(cluster->table); in tegra186_cpufreq_probe()
256 tegra_bpmp_put(bpmp); in tegra186_cpufreq_probe()
269 { .compatible = "nvidia,tegra186-ccplex-cluster", },
276 .name = "tegra186-cpufreq",
285 MODULE_DESCRIPTION("NVIDIA Tegra186 cpufreq driver");