Lines Matching +full:micro +full:- +full:watts

1 // SPDX-License-Identifier: GPL-2.0
63 policy = cpufreq_cpu_get_raw(cpu_dev->id); in mtk_cpufreq_get_cpu_power()
65 return -EINVAL; in mtk_cpufreq_get_cpu_power()
67 data = policy->driver_data; in mtk_cpufreq_get_cpu_power()
69 for (i = 0; i < data->nr_opp; i++) { in mtk_cpufreq_get_cpu_power()
70 if (data->table[i].frequency < *KHz) in mtk_cpufreq_get_cpu_power()
73 i--; in mtk_cpufreq_get_cpu_power()
75 *KHz = data->table[i].frequency; in mtk_cpufreq_get_cpu_power()
76 /* Provide micro-Watts value to the Energy Model */ in mtk_cpufreq_get_cpu_power()
77 *uW = readl_relaxed(data->reg_bases[REG_EM_POWER_TBL] + in mtk_cpufreq_get_cpu_power()
86 struct mtk_cpufreq_data *data = policy->driver_data; in mtk_cpufreq_hw_target_index()
88 writel_relaxed(index, data->reg_bases[REG_FREQ_PERF_STATE]); in mtk_cpufreq_hw_target_index()
103 data = policy->driver_data; in mtk_cpufreq_hw_get()
105 index = readl_relaxed(data->reg_bases[REG_FREQ_PERF_STATE]); in mtk_cpufreq_hw_get()
106 index = min(index, LUT_MAX_ENTRIES - 1); in mtk_cpufreq_hw_get()
108 return data->table[index].frequency; in mtk_cpufreq_hw_get()
114 struct mtk_cpufreq_data *data = policy->driver_data; in mtk_cpufreq_hw_fast_switch()
119 writel_relaxed(index, data->reg_bases[REG_FREQ_PERF_STATE]); in mtk_cpufreq_hw_fast_switch()
121 return policy->freq_table[index].frequency; in mtk_cpufreq_hw_fast_switch()
127 struct device *dev = &pdev->dev; in mtk_cpu_create_freq_table()
131 data->table = devm_kcalloc(dev, LUT_MAX_ENTRIES + 1, in mtk_cpu_create_freq_table()
132 sizeof(*data->table), GFP_KERNEL); in mtk_cpu_create_freq_table()
133 if (!data->table) in mtk_cpu_create_freq_table()
134 return -ENOMEM; in mtk_cpu_create_freq_table()
136 base_table = data->reg_bases[REG_FREQ_LUT_TABLE]; in mtk_cpu_create_freq_table()
145 data->table[i].frequency = freq; in mtk_cpu_create_freq_table()
147 dev_dbg(dev, "index=%d freq=%d\n", i, data->table[i].frequency); in mtk_cpu_create_freq_table()
152 data->table[i].frequency = CPUFREQ_TABLE_END; in mtk_cpu_create_freq_table()
153 data->nr_opp = i; in mtk_cpu_create_freq_table()
163 struct device *dev = &pdev->dev; in mtk_cpu_resources_init()
172 return -ENOMEM; in mtk_cpu_resources_init()
174 ret = of_perf_domain_get_sharing_cpumask(policy->cpu, "performance-domains", in mtk_cpu_resources_init()
175 "#performance-domain-cells", in mtk_cpu_resources_init()
176 policy->cpus, &args); in mtk_cpu_resources_init()
186 return -ENODEV; in mtk_cpu_resources_init()
189 if (!request_mem_region(res->start, resource_size(res), res->name)) { in mtk_cpu_resources_init()
191 return -EBUSY; in mtk_cpu_resources_init()
194 base = ioremap(res->start, resource_size(res)); in mtk_cpu_resources_init()
197 ret = -ENOMEM; in mtk_cpu_resources_init()
201 data->base = base; in mtk_cpu_resources_init()
202 data->res = res; in mtk_cpu_resources_init()
205 data->reg_bases[i] = base + offsets[i]; in mtk_cpu_resources_init()
209 dev_info(dev, "Domain-%d failed to create freq table\n", index); in mtk_cpu_resources_init()
213 policy->freq_table = data->table; in mtk_cpu_resources_init()
214 policy->driver_data = data; in mtk_cpu_resources_init()
218 release_mem_region(res->start, resource_size(res)); in mtk_cpu_resources_init()
233 dev_info(&pdev->dev, "CPUFreq resource init failed\n"); in mtk_cpufreq_hw_cpu_init()
237 data = policy->driver_data; in mtk_cpufreq_hw_cpu_init()
239 latency = readl_relaxed(data->reg_bases[REG_FREQ_LATENCY]) * 1000; in mtk_cpufreq_hw_cpu_init()
243 policy->cpuinfo.transition_latency = latency; in mtk_cpufreq_hw_cpu_init()
244 policy->fast_switch_possible = true; in mtk_cpufreq_hw_cpu_init()
247 writel_relaxed(0x1, data->reg_bases[REG_FREQ_ENABLE]); in mtk_cpufreq_hw_cpu_init()
248 if (readl_poll_timeout(data->reg_bases[REG_FREQ_HW_STATE], sig, in mtk_cpufreq_hw_cpu_init()
253 policy->cpu); in mtk_cpufreq_hw_cpu_init()
254 return -ENODEV; in mtk_cpufreq_hw_cpu_init()
257 pr_info("SVS of CPU%d is not enabled\n", policy->cpu); in mtk_cpufreq_hw_cpu_init()
265 struct mtk_cpufreq_data *data = policy->driver_data; in mtk_cpufreq_hw_cpu_exit()
266 struct resource *res = data->res; in mtk_cpufreq_hw_cpu_exit()
267 void __iomem *base = data->base; in mtk_cpufreq_hw_cpu_exit()
270 writel_relaxed(0x0, data->reg_bases[REG_FREQ_ENABLE]); in mtk_cpufreq_hw_cpu_exit()
272 release_mem_region(res->start, resource_size(res)); in mtk_cpufreq_hw_cpu_exit()
280 struct mtk_cpufreq_data *data = policy->driver_data; in mtk_cpufreq_register_em()
282 em_dev_register_perf_domain(get_cpu_device(policy->cpu), data->nr_opp, in mtk_cpufreq_register_em()
283 &em_cb, policy->cpus, true); in mtk_cpufreq_register_em()
297 .name = "mtk-cpufreq-hw",
312 return dev_err_probe(&pdev->dev, -EPROBE_DEFER, in mtk_cpufreq_hw_driver_probe()
317 return dev_err_probe(&pdev->dev, PTR_ERR(cpu_reg), in mtk_cpufreq_hw_driver_probe()
322 data = of_device_get_match_data(&pdev->dev); in mtk_cpufreq_hw_driver_probe()
324 return -EINVAL; in mtk_cpufreq_hw_driver_probe()
331 dev_err(&pdev->dev, "CPUFreq HW driver failed to register\n"); in mtk_cpufreq_hw_driver_probe()
342 { .compatible = "mediatek,cpufreq-hw", .data = &cpufreq_mtk_offsets },
351 .name = "mtk-cpufreq-hw",
358 MODULE_DESCRIPTION("Mediatek cpufreq-hw driver");