Lines Matching +full:devfreq +full:- +full:event
1 // SPDX-License-Identifier: GPL-2.0-only
3 * exynos-nocp.c - Exynos NoC (Network On Chip) Probe support
11 #include <linux/devfreq-event.h>
17 #include "exynos-nocp.h"
30 * The devfreq-event ops structure for nocp probe.
38 ret = regmap_update_bits(nocp->regmap, NOCP_MAIN_CTL, in exynos_nocp_set_event()
41 dev_err(nocp->dev, "failed to disable the NoC probe device\n"); in exynos_nocp_set_event()
46 ret = regmap_write(nocp->regmap, NOCP_STAT_PERIOD, 0x0); in exynos_nocp_set_event()
51 ret = regmap_update_bits(nocp->regmap, NOCP_COUNTERS_0_SRC, in exynos_nocp_set_event()
57 ret = regmap_update_bits(nocp->regmap, NOCP_COUNTERS_1_SRC, in exynos_nocp_set_event()
63 ret = regmap_update_bits(nocp->regmap, NOCP_COUNTERS_2_SRC, in exynos_nocp_set_event()
69 ret = regmap_update_bits(nocp->regmap, NOCP_COUNTERS_3_SRC, in exynos_nocp_set_event()
77 ret = regmap_write(nocp->regmap, NOCP_STAT_ALARM_MIN, 0x0); in exynos_nocp_set_event()
81 ret = regmap_write(nocp->regmap, NOCP_STAT_ALARM_MAX, 0x0); in exynos_nocp_set_event()
86 ret = regmap_update_bits(nocp->regmap, NOCP_COUNTERS_0_ALARM_MODE, in exynos_nocp_set_event()
92 ret = regmap_update_bits(nocp->regmap, NOCP_COUNTERS_1_ALARM_MODE, in exynos_nocp_set_event()
98 ret = regmap_update_bits(nocp->regmap, NOCP_COUNTERS_2_ALARM_MODE, in exynos_nocp_set_event()
104 ret = regmap_update_bits(nocp->regmap, NOCP_COUNTERS_3_ALARM_MODE, in exynos_nocp_set_event()
111 ret = regmap_update_bits(nocp->regmap, NOCP_MAIN_CTL, in exynos_nocp_set_event()
118 ret = regmap_update_bits(nocp->regmap, NOCP_CFG_CTL, in exynos_nocp_set_event()
125 ret = regmap_update_bits(nocp->regmap, NOCP_MAIN_CTL, in exynos_nocp_set_event()
135 if (regmap_update_bits(nocp->regmap, NOCP_MAIN_CTL, in exynos_nocp_set_event()
137 dev_err(nocp->dev, "Failed to reset NoC probe device\n"); in exynos_nocp_set_event()
151 ret = regmap_read(nocp->regmap, NOCP_COUNTERS_0_VAL, &counter[0]); in exynos_nocp_get_event()
155 ret = regmap_read(nocp->regmap, NOCP_COUNTERS_1_VAL, &counter[1]); in exynos_nocp_get_event()
159 ret = regmap_read(nocp->regmap, NOCP_COUNTERS_2_VAL, &counter[2]); in exynos_nocp_get_event()
163 ret = regmap_read(nocp->regmap, NOCP_COUNTERS_3_VAL, &counter[3]); in exynos_nocp_get_event()
167 edata->load_count = ((counter[1] << 16) | counter[0]); in exynos_nocp_get_event()
168 edata->total_count = ((counter[3] << 16) | counter[2]); in exynos_nocp_get_event()
170 dev_dbg(&edev->dev, "%s (event: %ld/%ld)\n", edev->desc->name, in exynos_nocp_get_event()
171 edata->load_count, edata->total_count); in exynos_nocp_get_event()
176 dev_err(nocp->dev, "Failed to read the counter of NoC probe device\n"); in exynos_nocp_get_event()
187 { .compatible = "samsung,exynos5420-nocp", },
202 struct device *dev = nocp->dev; in exynos_nocp_parse_dt()
203 struct device_node *np = dev->of_node; in exynos_nocp_parse_dt()
209 return -EINVAL; in exynos_nocp_parse_dt()
212 nocp->clk = devm_clk_get(dev, "nocp"); in exynos_nocp_parse_dt()
213 if (IS_ERR(nocp->clk)) in exynos_nocp_parse_dt()
214 nocp->clk = NULL; in exynos_nocp_parse_dt()
221 exynos_nocp_regmap_config.max_register = resource_size(res) - 4; in exynos_nocp_parse_dt()
223 nocp->regmap = devm_regmap_init_mmio(dev, base, in exynos_nocp_parse_dt()
225 if (IS_ERR(nocp->regmap)) { in exynos_nocp_parse_dt()
227 return PTR_ERR(nocp->regmap); in exynos_nocp_parse_dt()
235 struct device *dev = &pdev->dev; in exynos_nocp_probe()
236 struct device_node *np = dev->of_node; in exynos_nocp_probe()
240 nocp = devm_kzalloc(&pdev->dev, sizeof(*nocp), GFP_KERNEL); in exynos_nocp_probe()
242 return -ENOMEM; in exynos_nocp_probe()
244 nocp->dev = &pdev->dev; in exynos_nocp_probe()
249 dev_err(&pdev->dev, in exynos_nocp_probe()
254 /* Add devfreq-event device to measure the bandwidth of NoC */ in exynos_nocp_probe()
255 nocp->desc.ops = &exynos_nocp_ops; in exynos_nocp_probe()
256 nocp->desc.driver_data = nocp; in exynos_nocp_probe()
257 nocp->desc.name = np->full_name; in exynos_nocp_probe()
258 nocp->edev = devm_devfreq_event_add_edev(&pdev->dev, &nocp->desc); in exynos_nocp_probe()
259 if (IS_ERR(nocp->edev)) { in exynos_nocp_probe()
260 dev_err(&pdev->dev, in exynos_nocp_probe()
261 "failed to add devfreq-event device\n"); in exynos_nocp_probe()
262 return PTR_ERR(nocp->edev); in exynos_nocp_probe()
266 ret = clk_prepare_enable(nocp->clk); in exynos_nocp_probe()
268 dev_err(&pdev->dev, "failed to prepare ppmu clock\n"); in exynos_nocp_probe()
272 pr_info("exynos-nocp: new NoC Probe device registered: %s\n", in exynos_nocp_probe()
282 clk_disable_unprepare(nocp->clk); in exynos_nocp_remove()
289 .name = "exynos-nocp",