Lines Matching +full:exynos5260 +full:- +full:clk
1 // SPDX-License-Identifier: GPL-2.0-only
3 * exynos_ppmu.c - Exynos PPMU (Platform Performance Monitoring Unit) support
5 * Copyright (c) 2014-2015 Samsung Electronics Co., Ltd.
11 #include <linux/clk.h>
20 #include <linux/devfreq-event.h>
22 #include "exynos-ppmu.h"
30 struct clk *clk; member
46 { "ppmu-event0-"#name, PPMU_PMNCNT0 }, \
47 { "ppmu-event1-"#name, PPMU_PMNCNT1 }, \
48 { "ppmu-event2-"#name, PPMU_PMNCNT2 }, \
49 { "ppmu-event3-"#name, PPMU_PMNCNT3 }
55 /* For Exynos3250, Exynos4 and Exynos5260 */
68 /* Only for Exynos3250 and Exynos5260 */
72 PPMU_EVENT(mfc-left),
73 PPMU_EVENT(mfc-right),
75 /* Only for Exynos5260 SoCs */
76 PPMU_EVENT(drex0-s0),
77 PPMU_EVENT(drex0-s1),
78 PPMU_EVENT(drex1-s0),
79 PPMU_EVENT(drex1-s1),
90 PPMU_EVENT(d0-cpu),
91 PPMU_EVENT(d0-general),
92 PPMU_EVENT(d0-rt),
93 PPMU_EVENT(d1-cpu),
94 PPMU_EVENT(d1-general),
95 PPMU_EVENT(d1-rt),
103 PPMU_EVENT(dmc0-0),
104 PPMU_EVENT(dmc0-1),
105 PPMU_EVENT(dmc1-0),
106 PPMU_EVENT(dmc1-1),
117 return -EINVAL; in __exynos_ppmu_find_ppmu_id()
122 return __exynos_ppmu_find_ppmu_id(edev->desc->name); in exynos_ppmu_find_ppmu_id()
126 * The devfreq-event ops structure for PPMU v1.1
135 ret = regmap_write(info->regmap, PPMU_CNTENC, in exynos_ppmu_disable()
145 ret = regmap_read(info->regmap, PPMU_PMNC, &pmnc); in exynos_ppmu_disable()
150 ret = regmap_write(info->regmap, PPMU_PMNC, pmnc); in exynos_ppmu_disable()
168 ret = regmap_read(info->regmap, PPMU_CNTENS, &cntens); in exynos_ppmu_set_event()
173 ret = regmap_write(info->regmap, PPMU_CNTENS, cntens); in exynos_ppmu_set_event()
178 ret = regmap_write(info->regmap, PPMU_BEVTxSEL(id), in exynos_ppmu_set_event()
179 edev->desc->event_type); in exynos_ppmu_set_event()
184 ret = regmap_read(info->regmap, PPMU_PMNC, &pmnc); in exynos_ppmu_set_event()
194 ret = regmap_write(info->regmap, PPMU_PMNC, pmnc); in exynos_ppmu_set_event()
212 return -EINVAL; in exynos_ppmu_get_event()
215 ret = regmap_read(info->regmap, PPMU_PMNC, &pmnc); in exynos_ppmu_get_event()
220 ret = regmap_write(info->regmap, PPMU_PMNC, pmnc); in exynos_ppmu_get_event()
225 ret = regmap_read(info->regmap, PPMU_CCNT, &total_count); in exynos_ppmu_get_event()
228 edata->total_count = total_count; in exynos_ppmu_get_event()
235 ret = regmap_read(info->regmap, PPMU_PMNCT(id), &load_count); in exynos_ppmu_get_event()
238 edata->load_count = load_count; in exynos_ppmu_get_event()
241 ret = regmap_read(info->regmap, PPMU_PMCNT3_HIGH, &pmcnt3_high); in exynos_ppmu_get_event()
245 ret = regmap_read(info->regmap, PPMU_PMCNT3_LOW, &pmcnt3_low); in exynos_ppmu_get_event()
249 edata->load_count = ((pmcnt3_high << 8) | pmcnt3_low); in exynos_ppmu_get_event()
252 return -EINVAL; in exynos_ppmu_get_event()
256 ret = regmap_read(info->regmap, PPMU_CNTENC, &cntenc); in exynos_ppmu_get_event()
261 ret = regmap_write(info->regmap, PPMU_CNTENC, cntenc); in exynos_ppmu_get_event()
265 dev_dbg(&edev->dev, "%s (event: %ld/%ld)\n", edev->desc->name, in exynos_ppmu_get_event()
266 edata->load_count, edata->total_count); in exynos_ppmu_get_event()
278 * The devfreq-event ops structure for PPMU v2.0
289 ret = regmap_write(info->regmap, PPMU_V2_FLAG, clear); in exynos_ppmu_v2_disable()
293 ret = regmap_write(info->regmap, PPMU_V2_INTENC, clear); in exynos_ppmu_v2_disable()
297 ret = regmap_write(info->regmap, PPMU_V2_CNTENC, clear); in exynos_ppmu_v2_disable()
301 ret = regmap_write(info->regmap, PPMU_V2_CNT_RESET, clear); in exynos_ppmu_v2_disable()
305 ret = regmap_write(info->regmap, PPMU_V2_CIG_CFG0, 0x0); in exynos_ppmu_v2_disable()
309 ret = regmap_write(info->regmap, PPMU_V2_CIG_CFG1, 0x0); in exynos_ppmu_v2_disable()
313 ret = regmap_write(info->regmap, PPMU_V2_CIG_CFG2, 0x0); in exynos_ppmu_v2_disable()
317 ret = regmap_write(info->regmap, PPMU_V2_CIG_RESULT, 0x0); in exynos_ppmu_v2_disable()
321 ret = regmap_write(info->regmap, PPMU_V2_CNT_AUTO, 0x0); in exynos_ppmu_v2_disable()
325 ret = regmap_write(info->regmap, PPMU_V2_CH_EV0_TYPE, 0x0); in exynos_ppmu_v2_disable()
329 ret = regmap_write(info->regmap, PPMU_V2_CH_EV1_TYPE, 0x0); in exynos_ppmu_v2_disable()
333 ret = regmap_write(info->regmap, PPMU_V2_CH_EV2_TYPE, 0x0); in exynos_ppmu_v2_disable()
337 ret = regmap_write(info->regmap, PPMU_V2_CH_EV3_TYPE, 0x0); in exynos_ppmu_v2_disable()
341 ret = regmap_write(info->regmap, PPMU_V2_SM_ID_V, 0x0); in exynos_ppmu_v2_disable()
345 ret = regmap_write(info->regmap, PPMU_V2_SM_ID_A, 0x0); in exynos_ppmu_v2_disable()
349 ret = regmap_write(info->regmap, PPMU_V2_SM_OTHERS_V, 0x0); in exynos_ppmu_v2_disable()
353 ret = regmap_write(info->regmap, PPMU_V2_SM_OTHERS_A, 0x0); in exynos_ppmu_v2_disable()
357 ret = regmap_write(info->regmap, PPMU_V2_INTERRUPT_RESET, 0x0); in exynos_ppmu_v2_disable()
362 ret = regmap_read(info->regmap, PPMU_V2_PMNC, &pmnc); in exynos_ppmu_v2_disable()
367 ret = regmap_write(info->regmap, PPMU_V2_PMNC, pmnc); in exynos_ppmu_v2_disable()
382 ret = regmap_read(info->regmap, PPMU_V2_CNTENS, &cntens); in exynos_ppmu_v2_set_event()
387 ret = regmap_write(info->regmap, PPMU_V2_CNTENS, cntens); in exynos_ppmu_v2_set_event()
392 ret = regmap_write(info->regmap, PPMU_V2_CH_EVx_TYPE(id), in exynos_ppmu_v2_set_event()
393 edev->desc->event_type); in exynos_ppmu_v2_set_event()
398 ret = regmap_read(info->regmap, PPMU_V2_PMNC, &pmnc); in exynos_ppmu_v2_set_event()
412 ret = regmap_write(info->regmap, PPMU_V2_PMNC, pmnc); in exynos_ppmu_v2_set_event()
431 ret = regmap_read(info->regmap, PPMU_V2_PMNC, &pmnc); in exynos_ppmu_v2_get_event()
436 ret = regmap_write(info->regmap, PPMU_V2_PMNC, pmnc); in exynos_ppmu_v2_get_event()
441 ret = regmap_read(info->regmap, PPMU_V2_CCNT, &total_count); in exynos_ppmu_v2_get_event()
444 edata->total_count = total_count; in exynos_ppmu_v2_get_event()
450 ret = regmap_read(info->regmap, PPMU_V2_PMNCT(id), &count); in exynos_ppmu_v2_get_event()
456 ret = regmap_read(info->regmap, PPMU_V2_PMCNT3_HIGH, in exynos_ppmu_v2_get_event()
461 ret = regmap_read(info->regmap, PPMU_V2_PMCNT3_LOW, &pmcnt_low); in exynos_ppmu_v2_get_event()
468 edata->load_count = load_count; in exynos_ppmu_v2_get_event()
471 ret = regmap_read(info->regmap, PPMU_V2_CNTENC, &cntenc); in exynos_ppmu_v2_get_event()
476 ret = regmap_write(info->regmap, PPMU_V2_CNTENC, cntenc); in exynos_ppmu_v2_get_event()
480 dev_dbg(&edev->dev, "%25s (load: %ld / %ld)\n", edev->desc->name, in exynos_ppmu_v2_get_event()
481 edata->load_count, edata->total_count); in exynos_ppmu_v2_get_event()
493 .compatible = "samsung,exynos-ppmu",
496 .compatible = "samsung,exynos-ppmu-v2",
507 struct device *dev = info->dev; in of_get_devfreq_events()
516 "failed to get child node of devfreq-event devices\n"); in of_get_devfreq_events()
517 return -EINVAL; in of_get_devfreq_events()
524 return -ENOMEM; in of_get_devfreq_events()
526 info->num_events = count; in of_get_devfreq_events()
530 info->ppmu_type = (enum exynos_ppmu_type)of_id->data; in of_get_devfreq_events()
533 return -EINVAL; in of_get_devfreq_events()
553 switch (info->ppmu_type) { in of_get_devfreq_events()
564 of_property_read_string(node, "event-name", &desc[j].name); in of_get_devfreq_events()
565 ret = of_property_read_u32(node, "event-data-type", in of_get_devfreq_events()
572 if (info->ppmu_type == EXYNOS_TYPE_PPMU_V2) { in of_get_devfreq_events()
596 info->desc = desc; in of_get_devfreq_events()
612 struct device *dev = info->dev; in exynos_ppmu_parse_dt()
613 struct device_node *np = dev->of_node; in exynos_ppmu_parse_dt()
620 return -EINVAL; in exynos_ppmu_parse_dt()
628 exynos_ppmu_regmap_config.max_register = resource_size(res) - 4; in exynos_ppmu_parse_dt()
629 info->regmap = devm_regmap_init_mmio(dev, base, in exynos_ppmu_parse_dt()
631 if (IS_ERR(info->regmap)) { in exynos_ppmu_parse_dt()
633 return PTR_ERR(info->regmap); in exynos_ppmu_parse_dt()
636 info->ppmu.clk = devm_clk_get(dev, "ppmu"); in exynos_ppmu_parse_dt()
637 if (IS_ERR(info->ppmu.clk)) { in exynos_ppmu_parse_dt()
638 info->ppmu.clk = NULL; in exynos_ppmu_parse_dt()
658 info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL); in exynos_ppmu_probe()
660 return -ENOMEM; in exynos_ppmu_probe()
662 info->dev = &pdev->dev; in exynos_ppmu_probe()
667 dev_err(&pdev->dev, in exynos_ppmu_probe()
671 desc = info->desc; in exynos_ppmu_probe()
673 size = sizeof(struct devfreq_event_dev *) * info->num_events; in exynos_ppmu_probe()
674 info->edev = devm_kzalloc(&pdev->dev, size, GFP_KERNEL); in exynos_ppmu_probe()
675 if (!info->edev) in exynos_ppmu_probe()
676 return -ENOMEM; in exynos_ppmu_probe()
678 edev = info->edev; in exynos_ppmu_probe()
681 for (i = 0; i < info->num_events; i++) { in exynos_ppmu_probe()
682 edev[i] = devm_devfreq_event_add_edev(&pdev->dev, &desc[i]); in exynos_ppmu_probe()
684 dev_err(&pdev->dev, in exynos_ppmu_probe()
685 "failed to add devfreq-event device\n"); in exynos_ppmu_probe()
689 pr_info("exynos-ppmu: new PPMU device registered %s (%s)\n", in exynos_ppmu_probe()
690 dev_name(&pdev->dev), desc[i].name); in exynos_ppmu_probe()
693 ret = clk_prepare_enable(info->ppmu.clk); in exynos_ppmu_probe()
695 dev_err(&pdev->dev, "failed to prepare ppmu clock\n"); in exynos_ppmu_probe()
706 clk_disable_unprepare(info->ppmu.clk); in exynos_ppmu_remove()
715 .name = "exynos-ppmu",