Lines Matching +full:coresight +full:- +full:cti

1 // SPDX-License-Identifier: GPL-2.0
8 #include <linux/coresight.h>
15 #include "coresight-cti.h"
25 * include\dt-bindings\arm\coresight-cti-dt.h
85 struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); in enable_show()
87 spin_lock(&drvdata->spinlock); in enable_show()
88 enable_req = drvdata->config.enable_req_count; in enable_show()
89 powered = drvdata->config.hw_powered; in enable_show()
90 enabled = drvdata->config.hw_enabled; in enable_show()
91 spin_unlock(&drvdata->spinlock); in enable_show()
105 struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); in enable_store()
112 ret = pm_runtime_resume_and_get(dev->parent); in enable_store()
115 ret = cti_enable(drvdata->csdev, CS_MODE_SYSFS, NULL); in enable_store()
117 pm_runtime_put(dev->parent); in enable_store()
119 ret = cti_disable(drvdata->csdev, NULL); in enable_store()
121 pm_runtime_put(dev->parent); in enable_store()
135 struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); in powered_show()
137 spin_lock(&drvdata->spinlock); in powered_show()
138 powered = drvdata->config.hw_powered; in powered_show()
139 spin_unlock(&drvdata->spinlock); in powered_show()
148 struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); in ctmid_show()
150 return sprintf(buf, "%d\n", drvdata->ctidev.ctm_id); in ctmid_show()
158 struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); in nr_trigger_cons_show()
160 return sprintf(buf, "%d\n", drvdata->ctidev.nr_trig_con); in nr_trigger_cons_show()
179 struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); in coresight_cti_reg_show()
183 pm_runtime_get_sync(dev->parent); in coresight_cti_reg_show()
184 spin_lock(&drvdata->spinlock); in coresight_cti_reg_show()
185 if (drvdata->config.hw_powered) in coresight_cti_reg_show()
186 val = readl_relaxed(drvdata->base + cti_attr->off); in coresight_cti_reg_show()
187 spin_unlock(&drvdata->spinlock); in coresight_cti_reg_show()
188 pm_runtime_put_sync(dev->parent); in coresight_cti_reg_show()
197 struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); in coresight_cti_reg_store()
202 return -EINVAL; in coresight_cti_reg_store()
204 pm_runtime_get_sync(dev->parent); in coresight_cti_reg_store()
205 spin_lock(&drvdata->spinlock); in coresight_cti_reg_store()
206 if (drvdata->config.hw_powered) in coresight_cti_reg_store()
207 cti_write_single_reg(drvdata, cti_attr->off, val); in coresight_cti_reg_store()
208 spin_unlock(&drvdata->spinlock); in coresight_cti_reg_store()
209 pm_runtime_put_sync(dev->parent); in coresight_cti_reg_store()
238 /* coresight management registers */
254 /* CTI low level programming registers */
264 struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); in cti_reg32_show()
265 struct cti_config *config = &drvdata->config; in cti_reg32_show()
267 spin_lock(&drvdata->spinlock); in cti_reg32_show()
269 CS_UNLOCK(drvdata->base); in cti_reg32_show()
270 val = readl_relaxed(drvdata->base + reg_offset); in cti_reg32_show()
273 CS_LOCK(drvdata->base); in cti_reg32_show()
277 spin_unlock(&drvdata->spinlock); in cti_reg32_show()
290 struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); in cti_reg32_store()
291 struct cti_config *config = &drvdata->config; in cti_reg32_store()
294 return -EINVAL; in cti_reg32_store()
296 spin_lock(&drvdata->spinlock); in cti_reg32_store()
304 spin_unlock(&drvdata->spinlock); in cti_reg32_store()
308 /* Standard macro for simple rw cti config registers */
314 struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); \
316 &drvdata->config.cfgname, offset); \
323 struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); \
325 &drvdata->config.cfgname, offset); \
334 struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); in inout_sel_show()
336 val = (u32)drvdata->config.ctiinout_sel; in inout_sel_show()
345 struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); in inout_sel_store()
348 return -EINVAL; in inout_sel_store()
349 if (val > (CTIINOUTEN_MAX - 1)) in inout_sel_store()
350 return -EINVAL; in inout_sel_store()
352 spin_lock(&drvdata->spinlock); in inout_sel_store()
353 drvdata->config.ctiinout_sel = val; in inout_sel_store()
354 spin_unlock(&drvdata->spinlock); in inout_sel_store()
365 struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); in inen_show()
367 spin_lock(&drvdata->spinlock); in inen_show()
368 index = drvdata->config.ctiinout_sel; in inen_show()
369 val = drvdata->config.ctiinen[index]; in inen_show()
370 spin_unlock(&drvdata->spinlock); in inen_show()
380 struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); in inen_store()
381 struct cti_config *config = &drvdata->config; in inen_store()
384 return -EINVAL; in inen_store()
386 spin_lock(&drvdata->spinlock); in inen_store()
387 index = config->ctiinout_sel; in inen_store()
388 config->ctiinen[index] = val; in inen_store()
393 spin_unlock(&drvdata->spinlock); in inen_store()
404 struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); in outen_show()
406 spin_lock(&drvdata->spinlock); in outen_show()
407 index = drvdata->config.ctiinout_sel; in outen_show()
408 val = drvdata->config.ctiouten[index]; in outen_show()
409 spin_unlock(&drvdata->spinlock); in outen_show()
419 struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); in outen_store()
420 struct cti_config *config = &drvdata->config; in outen_store()
423 return -EINVAL; in outen_store()
425 spin_lock(&drvdata->spinlock); in outen_store()
426 index = config->ctiinout_sel; in outen_store()
427 config->ctiouten[index] = val; in outen_store()
432 spin_unlock(&drvdata->spinlock); in outen_store()
444 return -EINVAL; in intack_store()
460 struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); in appclear_store()
461 struct cti_config *config = &drvdata->config; in appclear_store()
464 return -EINVAL; in appclear_store()
466 spin_lock(&drvdata->spinlock); in appclear_store()
469 config->ctiappset &= ~val; in appclear_store()
474 spin_unlock(&drvdata->spinlock); in appclear_store()
484 struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); in apppulse_store()
485 struct cti_config *config = &drvdata->config; in apppulse_store()
488 return -EINVAL; in apppulse_store()
490 spin_lock(&drvdata->spinlock); in apppulse_store()
495 spin_unlock(&drvdata->spinlock); in apppulse_store()
533 /* CTI channel x-trigger programming */
540 int items, err = -EINVAL; in cti_trig_op_parse()
596 return -EINVAL; in chan_gate_enable_store()
606 struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); in chan_gate_enable_show()
607 struct cti_config *cfg = &drvdata->config; in chan_gate_enable_show()
608 unsigned long ctigate_bitmask = cfg->ctigate; in chan_gate_enable_show()
611 if (cfg->ctigate == 0) in chan_gate_enable_show()
615 cfg->nr_ctm_channels); in chan_gate_enable_show()
627 return -EINVAL; in chan_gate_disable_store()
640 return -EINVAL; in chan_op_parse()
682 struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); in trig_filter_enable_show()
684 spin_lock(&drvdata->spinlock); in trig_filter_enable_show()
685 val = drvdata->config.trig_filter_enable; in trig_filter_enable_show()
686 spin_unlock(&drvdata->spinlock); in trig_filter_enable_show()
695 struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); in trig_filter_enable_store()
698 return -EINVAL; in trig_filter_enable_store()
700 spin_lock(&drvdata->spinlock); in trig_filter_enable_store()
701 drvdata->config.trig_filter_enable = !!val; in trig_filter_enable_store()
702 spin_unlock(&drvdata->spinlock); in trig_filter_enable_store()
711 struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); in trigout_filtered_show()
712 struct cti_config *cfg = &drvdata->config; in trigout_filtered_show()
713 int size = 0, nr_trig_max = cfg->nr_trig_max; in trigout_filtered_show()
714 unsigned long mask = cfg->trig_out_filter; in trigout_filtered_show()
728 struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); in chan_xtrigs_reset_store()
729 struct cti_config *config = &drvdata->config; in chan_xtrigs_reset_store()
731 spin_lock(&drvdata->spinlock); in chan_xtrigs_reset_store()
733 /* clear the CTI trigger / channel programming registers */ in chan_xtrigs_reset_store()
734 for (i = 0; i < config->nr_trig_max; i++) { in chan_xtrigs_reset_store()
735 config->ctiinen[i] = 0; in chan_xtrigs_reset_store()
736 config->ctiouten[i] = 0; in chan_xtrigs_reset_store()
740 config->ctigate = GENMASK(config->nr_ctm_channels - 1, 0); in chan_xtrigs_reset_store()
741 config->asicctl = 0; in chan_xtrigs_reset_store()
742 config->ctiappset = 0; in chan_xtrigs_reset_store()
743 config->ctiinout_sel = 0; in chan_xtrigs_reset_store()
744 config->xtrig_rchan_sel = 0; in chan_xtrigs_reset_store()
750 spin_unlock(&drvdata->spinlock); in chan_xtrigs_reset_store()
764 struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); in chan_xtrigs_sel_store()
767 return -EINVAL; in chan_xtrigs_sel_store()
768 if (val > (drvdata->config.nr_ctm_channels - 1)) in chan_xtrigs_sel_store()
769 return -EINVAL; in chan_xtrigs_sel_store()
771 spin_lock(&drvdata->spinlock); in chan_xtrigs_sel_store()
772 drvdata->config.xtrig_rchan_sel = val; in chan_xtrigs_sel_store()
773 spin_unlock(&drvdata->spinlock); in chan_xtrigs_sel_store()
782 struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); in chan_xtrigs_sel_show()
784 spin_lock(&drvdata->spinlock); in chan_xtrigs_sel_show()
785 val = drvdata->config.xtrig_rchan_sel; in chan_xtrigs_sel_show()
786 spin_unlock(&drvdata->spinlock); in chan_xtrigs_sel_show()
796 struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); in chan_xtrigs_in_show()
797 struct cti_config *cfg = &drvdata->config; in chan_xtrigs_in_show()
799 int nr_trig_max = drvdata->config.nr_trig_max; in chan_xtrigs_in_show()
800 u32 chan_mask = BIT(cfg->xtrig_rchan_sel); in chan_xtrigs_in_show()
803 if (chan_mask & cfg->ctiinen[reg_idx]) in chan_xtrigs_in_show()
816 struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); in chan_xtrigs_out_show()
817 struct cti_config *cfg = &drvdata->config; in chan_xtrigs_out_show()
819 int nr_trig_max = drvdata->config.nr_trig_max; in chan_xtrigs_out_show()
820 u32 chan_mask = BIT(cfg->xtrig_rchan_sel); in chan_xtrigs_out_show()
823 if (chan_mask & cfg->ctiouten[reg_idx]) in chan_xtrigs_out_show()
835 struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); in print_chan_list()
836 struct cti_config *config = &drvdata->config; in print_chan_list()
841 spin_lock(&drvdata->spinlock); in print_chan_list()
842 for (i = 0; i < config->nr_trig_max; i++) { in print_chan_list()
843 inuse_bits |= config->ctiinen[i]; in print_chan_list()
844 inuse_bits |= config->ctiouten[i]; in print_chan_list()
846 spin_unlock(&drvdata->spinlock); in print_chan_list()
853 chan_mask = GENMASK(config->nr_ctm_channels - 1, 0); in print_chan_list()
856 config->nr_ctm_channels); in print_chan_list()
903 * of groups. e.g. in sysfs:-
915 struct cti_trig_con *con = (struct cti_trig_con *)ext_attr->var; in con_name_show()
917 return sprintf(buf, "%s\n", con->con_dev_name); in con_name_show()
926 struct cti_trig_con *con = (struct cti_trig_con *)ext_attr->var; in trigin_sig_show()
927 struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); in trigin_sig_show()
928 struct cti_config *cfg = &drvdata->config; in trigin_sig_show()
929 unsigned long mask = con->con_in->used_mask; in trigin_sig_show()
931 return bitmap_print_to_pagebuf(true, buf, &mask, cfg->nr_trig_max); in trigin_sig_show()
940 struct cti_trig_con *con = (struct cti_trig_con *)ext_attr->var; in trigout_sig_show()
941 struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); in trigout_sig_show()
942 struct cti_config *cfg = &drvdata->config; in trigout_sig_show()
943 unsigned long mask = con->con_out->used_mask; in trigout_sig_show()
945 return bitmap_print_to_pagebuf(true, buf, &mask, cfg->nr_trig_max); in trigout_sig_show()
953 struct cti_trig_grp *grp = in ? con->con_in : con->con_out; in cti_sig_type_name()
955 if (used_count < grp->nr_sigs) in cti_sig_type_name()
956 idx = grp->sig_types[used_count]; in cti_sig_type_name()
966 struct cti_trig_con *con = (struct cti_trig_con *)ext_attr->var; in trigin_type_show()
970 for (sig_idx = 0; sig_idx < con->con_in->nr_sigs; sig_idx++) { in trigin_type_show()
984 struct cti_trig_con *con = (struct cti_trig_con *)ext_attr->var; in trigout_type_show()
988 for (sig_idx = 0; sig_idx < con->con_out->nr_sigs; sig_idx++) { in trigout_type_show()
1023 eattr->attr.attr.name = name; in cti_create_con_sysfs_attr()
1024 eattr->attr.attr.mode = 0444; in cti_create_con_sysfs_attr()
1027 eattr->attr.show = show_fns[attr_type]; in cti_create_con_sysfs_attr()
1029 return -ENOMEM; in cti_create_con_sysfs_attr()
1032 return -ENOMEM; in cti_create_con_sysfs_attr()
1034 eattr->var = con; in cti_create_con_sysfs_attr()
1035 con->con_attrs[attr_idx] = &eattr->attr.attr; in cti_create_con_sysfs_attr()
1041 sysfs_attr_init(con->con_attrs[attr_idx]); in cti_create_con_sysfs_attr()
1057 group->name = devm_kasprintf(dev, GFP_KERNEL, "triggers%d", con_idx); in cti_create_con_sysfs_group()
1058 if (!group->name) in cti_create_con_sysfs_group()
1061 grp_idx = con_idx + CORESIGHT_CTI_STATIC_GROUPS_MAX - 1; in cti_create_con_sysfs_group()
1062 ctidev->con_groups[grp_idx] = group; in cti_create_con_sysfs_group()
1063 tc->attr_group = group; in cti_create_con_sysfs_group()
1074 int err = -ENOMEM; in cti_create_con_attr_set()
1078 return -ENOMEM; in cti_create_con_attr_set()
1081 tc->con_attrs = devm_kcalloc(dev, CTI_CON_ATTR_MAX + 1, in cti_create_con_attr_set()
1083 if (!tc->con_attrs) in cti_create_con_attr_set()
1084 return -ENOMEM; in cti_create_con_attr_set()
1091 if (tc->con_in->nr_sigs > 0) { in cti_create_con_attr_set()
1105 if (tc->con_out->nr_sigs > 0) { in cti_create_con_attr_set()
1118 attr_group->attrs = tc->con_attrs; in cti_create_con_attr_set()
1122 /* create the array of group pointers for the CTI sysfs groups */
1128 nr_groups = ctidev->nr_trig_con + CORESIGHT_CTI_STATIC_GROUPS_MAX; in cti_create_cons_groups()
1129 ctidev->con_groups = devm_kcalloc(dev, nr_groups, in cti_create_cons_groups()
1132 if (!ctidev->con_groups) in cti_create_cons_groups()
1133 return -ENOMEM; in cti_create_cons_groups()
1139 struct cti_device *ctidev = &drvdata->ctidev; in cti_create_cons_sysfs()
1148 for (i = 0; i < (CORESIGHT_CTI_STATIC_GROUPS_MAX - 1); i++) in cti_create_cons_sysfs()
1149 ctidev->con_groups[i] = coresight_cti_groups[i]; in cti_create_cons_sysfs()
1152 list_for_each_entry(tc, &ctidev->trig_cons, node) { in cti_create_cons_sysfs()