Lines Matching refs:emc

59 static bool tegra186_emc_validate_rate(struct tegra186_emc *emc,  in tegra186_emc_validate_rate()  argument
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() local
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()
104 struct tegra186_emc *emc = data; in tegra186_emc_debug_min_rate_get() local
106 *rate = emc->debugfs.min_rate; in tegra186_emc_debug_min_rate_get()
113 struct tegra186_emc *emc = data; in tegra186_emc_debug_min_rate_set() local
116 if (!tegra186_emc_validate_rate(emc, rate)) 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()
134 struct tegra186_emc *emc = data; in tegra186_emc_debug_max_rate_get() local
136 *rate = emc->debugfs.max_rate; in tegra186_emc_debug_max_rate_get()
143 struct tegra186_emc *emc = data; in tegra186_emc_debug_max_rate_set() local
146 if (!tegra186_emc_validate_rate(emc, rate)) 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()
166 struct tegra186_emc *emc; in tegra186_emc_probe() local
170 emc = devm_kzalloc(&pdev->dev, sizeof(*emc), GFP_KERNEL); in tegra186_emc_probe()
171 if (!emc) 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()
185 platform_set_drvdata(pdev, emc); 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()
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()
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()
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()
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()
246 emc, &tegra186_emc_debug_available_rates_fops); in tegra186_emc_probe()
247 debugfs_create_file("min_rate", S_IRUGO | S_IWUSR, emc->debugfs.root, in tegra186_emc_probe()
248 emc, &tegra186_emc_debug_min_rate_fops); in tegra186_emc_probe()
249 debugfs_create_file("max_rate", S_IRUGO | S_IWUSR, emc->debugfs.root, in tegra186_emc_probe()
250 emc, &tegra186_emc_debug_max_rate_fops); in tegra186_emc_probe()
255 tegra_bpmp_put(emc->bpmp); in tegra186_emc_probe()
261 struct tegra186_emc *emc = platform_get_drvdata(pdev); in tegra186_emc_remove() local
263 debugfs_remove_recursive(emc->debugfs.root); in tegra186_emc_remove()
264 tegra_bpmp_put(emc->bpmp); in tegra186_emc_remove()