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 enable_req = atomic_read(&drvdata->config.enable_req_count); in enable_show()
88 spin_lock(&drvdata->spinlock); 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 = cti_enable(drvdata->csdev); in enable_store()
114 ret = cti_disable(drvdata->csdev); in enable_store()
126 struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); in powered_show()
128 spin_lock(&drvdata->spinlock); in powered_show()
129 powered = drvdata->config.hw_powered; in powered_show()
130 spin_unlock(&drvdata->spinlock); in powered_show()
139 struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); in ctmid_show()
141 return sprintf(buf, "%d\n", drvdata->ctidev.ctm_id); in ctmid_show()
149 struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); in nr_trigger_cons_show()
151 return sprintf(buf, "%d\n", drvdata->ctidev.nr_trig_con); in nr_trigger_cons_show()
171 struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); \
173 pm_runtime_get_sync(dev->parent); \
174 spin_lock(&drvdata->spinlock); \
175 if (drvdata->config.hw_powered) \
176 val = readl_relaxed(drvdata->base + offset); \
177 spin_unlock(&drvdata->spinlock); \
178 pm_runtime_put_sync(dev->parent); \
183 /* coresight management registers */
211 /* CTI low level programming registers */
221 struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); in cti_reg32_show()
222 struct cti_config *config = &drvdata->config; in cti_reg32_show()
224 spin_lock(&drvdata->spinlock); in cti_reg32_show()
226 CS_UNLOCK(drvdata->base); in cti_reg32_show()
227 val = readl_relaxed(drvdata->base + reg_offset); in cti_reg32_show()
230 CS_LOCK(drvdata->base); in cti_reg32_show()
234 spin_unlock(&drvdata->spinlock); in cti_reg32_show()
247 struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); in cti_reg32_store()
248 struct cti_config *config = &drvdata->config; in cti_reg32_store()
251 return -EINVAL; in cti_reg32_store()
253 spin_lock(&drvdata->spinlock); in cti_reg32_store()
261 spin_unlock(&drvdata->spinlock); in cti_reg32_store()
265 /* Standard macro for simple rw cti config registers */
271 struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); \
273 &drvdata->config.cfgname, offset); \
280 struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); \
282 &drvdata->config.cfgname, offset); \
291 struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); in inout_sel_show()
293 val = (u32)drvdata->config.ctiinout_sel; in inout_sel_show()
302 struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); in inout_sel_store()
305 return -EINVAL; in inout_sel_store()
306 if (val > (CTIINOUTEN_MAX - 1)) in inout_sel_store()
307 return -EINVAL; in inout_sel_store()
309 spin_lock(&drvdata->spinlock); in inout_sel_store()
310 drvdata->config.ctiinout_sel = val; in inout_sel_store()
311 spin_unlock(&drvdata->spinlock); in inout_sel_store()
322 struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); in inen_show()
324 spin_lock(&drvdata->spinlock); in inen_show()
325 index = drvdata->config.ctiinout_sel; in inen_show()
326 val = drvdata->config.ctiinen[index]; in inen_show()
327 spin_unlock(&drvdata->spinlock); in inen_show()
337 struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); in inen_store()
338 struct cti_config *config = &drvdata->config; in inen_store()
341 return -EINVAL; in inen_store()
343 spin_lock(&drvdata->spinlock); in inen_store()
344 index = config->ctiinout_sel; in inen_store()
345 config->ctiinen[index] = val; in inen_store()
350 spin_unlock(&drvdata->spinlock); in inen_store()
361 struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); in outen_show()
363 spin_lock(&drvdata->spinlock); in outen_show()
364 index = drvdata->config.ctiinout_sel; in outen_show()
365 val = drvdata->config.ctiouten[index]; in outen_show()
366 spin_unlock(&drvdata->spinlock); in outen_show()
376 struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); in outen_store()
377 struct cti_config *config = &drvdata->config; in outen_store()
380 return -EINVAL; in outen_store()
382 spin_lock(&drvdata->spinlock); in outen_store()
383 index = config->ctiinout_sel; in outen_store()
384 config->ctiouten[index] = val; in outen_store()
389 spin_unlock(&drvdata->spinlock); in outen_store()
401 return -EINVAL; in intack_store()
417 struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); in appclear_store()
418 struct cti_config *config = &drvdata->config; in appclear_store()
421 return -EINVAL; in appclear_store()
423 spin_lock(&drvdata->spinlock); in appclear_store()
426 config->ctiappset &= ~val; in appclear_store()
431 spin_unlock(&drvdata->spinlock); in appclear_store()
441 struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); in apppulse_store()
442 struct cti_config *config = &drvdata->config; in apppulse_store()
445 return -EINVAL; in apppulse_store()
447 spin_lock(&drvdata->spinlock); in apppulse_store()
452 spin_unlock(&drvdata->spinlock); in apppulse_store()
474 struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); \
476 pm_runtime_get_sync(dev->parent); \
477 spin_lock(&drvdata->spinlock); \
478 if (drvdata->config.hw_powered) \
479 val = readl_relaxed(drvdata->base + offset); \
480 spin_unlock(&drvdata->spinlock); \
481 pm_runtime_put_sync(dev->parent); \
489 struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); \
492 return -EINVAL; \
494 pm_runtime_get_sync(dev->parent); \
495 spin_lock(&drvdata->spinlock); \
496 if (drvdata->config.hw_powered) \
498 spin_unlock(&drvdata->spinlock); \
499 pm_runtime_put_sync(dev->parent); \
510 struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); \
513 return -EINVAL; \
515 pm_runtime_get_sync(dev->parent); \
516 spin_lock(&drvdata->spinlock); \
517 if (drvdata->config.hw_powered) \
519 spin_unlock(&drvdata->spinlock); \
520 pm_runtime_put_sync(dev->parent); \
565 /* CTI channel x-trigger programming */
572 int items, err = -EINVAL; in cti_trig_op_parse()
628 return -EINVAL; in chan_gate_enable_store()
638 struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); in chan_gate_enable_show()
639 struct cti_config *cfg = &drvdata->config; in chan_gate_enable_show()
640 unsigned long ctigate_bitmask = cfg->ctigate; in chan_gate_enable_show()
643 if (cfg->ctigate == 0) in chan_gate_enable_show()
647 cfg->nr_ctm_channels); in chan_gate_enable_show()
659 return -EINVAL; in chan_gate_disable_store()
672 return -EINVAL; in chan_op_parse()
714 struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); in trig_filter_enable_show()
716 spin_lock(&drvdata->spinlock); in trig_filter_enable_show()
717 val = drvdata->config.trig_filter_enable; in trig_filter_enable_show()
718 spin_unlock(&drvdata->spinlock); in trig_filter_enable_show()
727 struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); in trig_filter_enable_store()
730 return -EINVAL; in trig_filter_enable_store()
732 spin_lock(&drvdata->spinlock); in trig_filter_enable_store()
733 drvdata->config.trig_filter_enable = !!val; in trig_filter_enable_store()
734 spin_unlock(&drvdata->spinlock); in trig_filter_enable_store()
743 struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); in trigout_filtered_show()
744 struct cti_config *cfg = &drvdata->config; in trigout_filtered_show()
745 int size = 0, nr_trig_max = cfg->nr_trig_max; in trigout_filtered_show()
746 unsigned long mask = cfg->trig_out_filter; in trigout_filtered_show()
760 struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); in chan_xtrigs_reset_store()
761 struct cti_config *config = &drvdata->config; in chan_xtrigs_reset_store()
763 spin_lock(&drvdata->spinlock); in chan_xtrigs_reset_store()
765 /* clear the CTI trigger / channel programming registers */ in chan_xtrigs_reset_store()
766 for (i = 0; i < config->nr_trig_max; i++) { in chan_xtrigs_reset_store()
767 config->ctiinen[i] = 0; in chan_xtrigs_reset_store()
768 config->ctiouten[i] = 0; in chan_xtrigs_reset_store()
772 config->ctigate = GENMASK(config->nr_ctm_channels - 1, 0); in chan_xtrigs_reset_store()
773 config->asicctl = 0; in chan_xtrigs_reset_store()
774 config->ctiappset = 0; in chan_xtrigs_reset_store()
775 config->ctiinout_sel = 0; in chan_xtrigs_reset_store()
776 config->xtrig_rchan_sel = 0; in chan_xtrigs_reset_store()
782 spin_unlock(&drvdata->spinlock); in chan_xtrigs_reset_store()
796 struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); in chan_xtrigs_sel_store()
799 return -EINVAL; in chan_xtrigs_sel_store()
800 if (val > (drvdata->config.nr_ctm_channels - 1)) in chan_xtrigs_sel_store()
801 return -EINVAL; in chan_xtrigs_sel_store()
803 spin_lock(&drvdata->spinlock); in chan_xtrigs_sel_store()
804 drvdata->config.xtrig_rchan_sel = val; in chan_xtrigs_sel_store()
805 spin_unlock(&drvdata->spinlock); in chan_xtrigs_sel_store()
814 struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); in chan_xtrigs_sel_show()
816 spin_lock(&drvdata->spinlock); in chan_xtrigs_sel_show()
817 val = drvdata->config.xtrig_rchan_sel; in chan_xtrigs_sel_show()
818 spin_unlock(&drvdata->spinlock); in chan_xtrigs_sel_show()
828 struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); in chan_xtrigs_in_show()
829 struct cti_config *cfg = &drvdata->config; in chan_xtrigs_in_show()
831 int nr_trig_max = drvdata->config.nr_trig_max; in chan_xtrigs_in_show()
832 u32 chan_mask = BIT(cfg->xtrig_rchan_sel); in chan_xtrigs_in_show()
835 if (chan_mask & cfg->ctiinen[reg_idx]) in chan_xtrigs_in_show()
848 struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); in chan_xtrigs_out_show()
849 struct cti_config *cfg = &drvdata->config; in chan_xtrigs_out_show()
851 int nr_trig_max = drvdata->config.nr_trig_max; in chan_xtrigs_out_show()
852 u32 chan_mask = BIT(cfg->xtrig_rchan_sel); in chan_xtrigs_out_show()
855 if (chan_mask & cfg->ctiouten[reg_idx]) in chan_xtrigs_out_show()
867 struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); in print_chan_list()
868 struct cti_config *config = &drvdata->config; in print_chan_list()
873 spin_lock(&drvdata->spinlock); in print_chan_list()
874 for (i = 0; i < config->nr_trig_max; i++) { in print_chan_list()
875 inuse_bits |= config->ctiinen[i]; in print_chan_list()
876 inuse_bits |= config->ctiouten[i]; in print_chan_list()
878 spin_unlock(&drvdata->spinlock); in print_chan_list()
885 chan_mask = GENMASK(config->nr_ctm_channels - 1, 0); in print_chan_list()
888 config->nr_ctm_channels); in print_chan_list()
935 * of groups. e.g. in sysfs:-
947 struct cti_trig_con *con = (struct cti_trig_con *)ext_attr->var; in con_name_show()
949 return sprintf(buf, "%s\n", con->con_dev_name); in con_name_show()
958 struct cti_trig_con *con = (struct cti_trig_con *)ext_attr->var; in trigin_sig_show()
959 struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); in trigin_sig_show()
960 struct cti_config *cfg = &drvdata->config; in trigin_sig_show()
961 unsigned long mask = con->con_in->used_mask; in trigin_sig_show()
963 return bitmap_print_to_pagebuf(true, buf, &mask, cfg->nr_trig_max); in trigin_sig_show()
972 struct cti_trig_con *con = (struct cti_trig_con *)ext_attr->var; in trigout_sig_show()
973 struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); in trigout_sig_show()
974 struct cti_config *cfg = &drvdata->config; in trigout_sig_show()
975 unsigned long mask = con->con_out->used_mask; in trigout_sig_show()
977 return bitmap_print_to_pagebuf(true, buf, &mask, cfg->nr_trig_max); in trigout_sig_show()
985 struct cti_trig_grp *grp = in ? con->con_in : con->con_out; in cti_sig_type_name()
987 if (used_count < grp->nr_sigs) in cti_sig_type_name()
988 idx = grp->sig_types[used_count]; in cti_sig_type_name()
998 struct cti_trig_con *con = (struct cti_trig_con *)ext_attr->var; in trigin_type_show()
1002 for (sig_idx = 0; sig_idx < con->con_in->nr_sigs; sig_idx++) { in trigin_type_show()
1016 struct cti_trig_con *con = (struct cti_trig_con *)ext_attr->var; in trigout_type_show()
1020 for (sig_idx = 0; sig_idx < con->con_out->nr_sigs; sig_idx++) { in trigout_type_show()
1055 eattr->attr.attr.name = name; in cti_create_con_sysfs_attr()
1056 eattr->attr.attr.mode = 0444; in cti_create_con_sysfs_attr()
1059 eattr->attr.show = show_fns[attr_type]; in cti_create_con_sysfs_attr()
1061 return -ENOMEM; in cti_create_con_sysfs_attr()
1064 return -ENOMEM; in cti_create_con_sysfs_attr()
1066 eattr->var = con; in cti_create_con_sysfs_attr()
1067 con->con_attrs[attr_idx] = &eattr->attr.attr; in cti_create_con_sysfs_attr()
1073 sysfs_attr_init(con->con_attrs[attr_idx]); in cti_create_con_sysfs_attr()
1089 group->name = devm_kasprintf(dev, GFP_KERNEL, "triggers%d", con_idx); in cti_create_con_sysfs_group()
1090 if (!group->name) in cti_create_con_sysfs_group()
1093 grp_idx = con_idx + CORESIGHT_CTI_STATIC_GROUPS_MAX - 1; in cti_create_con_sysfs_group()
1094 ctidev->con_groups[grp_idx] = group; in cti_create_con_sysfs_group()
1095 tc->attr_group = group; in cti_create_con_sysfs_group()
1106 int err = -ENOMEM; in cti_create_con_attr_set()
1110 return -ENOMEM; in cti_create_con_attr_set()
1113 tc->con_attrs = devm_kcalloc(dev, CTI_CON_ATTR_MAX + 1, in cti_create_con_attr_set()
1115 if (!tc->con_attrs) in cti_create_con_attr_set()
1116 return -ENOMEM; in cti_create_con_attr_set()
1123 if (tc->con_in->nr_sigs > 0) { in cti_create_con_attr_set()
1137 if (tc->con_out->nr_sigs > 0) { in cti_create_con_attr_set()
1150 attr_group->attrs = tc->con_attrs; in cti_create_con_attr_set()
1154 /* create the array of group pointers for the CTI sysfs groups */
1160 nr_groups = ctidev->nr_trig_con + CORESIGHT_CTI_STATIC_GROUPS_MAX; in cti_create_cons_groups()
1161 ctidev->con_groups = devm_kcalloc(dev, nr_groups, in cti_create_cons_groups()
1164 if (!ctidev->con_groups) in cti_create_cons_groups()
1165 return -ENOMEM; in cti_create_cons_groups()
1171 struct cti_device *ctidev = &drvdata->ctidev; in cti_create_cons_sysfs()
1180 for (i = 0; i < (CORESIGHT_CTI_STATIC_GROUPS_MAX - 1); i++) in cti_create_cons_sysfs()
1181 ctidev->con_groups[i] = coresight_cti_groups[i]; in cti_create_cons_sysfs()
1184 list_for_each_entry(tc, &ctidev->trig_cons, node) { in cti_create_cons_sysfs()