1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright(C) 2020 Linaro Limited. All rights reserved.
4 * Author: Mike Leach <mike.leach@linaro.org>
7 #include "coresight-config.h"
9 /* ETMv4 includes and features */
10 #if IS_ENABLED(CONFIG_CORESIGHT_SOURCE_ETM4X)
11 #include "coresight-etm4x-cfg.h"
12 #include "coresight-cfg-preload.h"
14 /* preload configurations and features */
16 /* preload in features for ETMv4 */
19 static struct cscfg_parameter_desc strobe_params
[] = {
30 static struct cscfg_regval_desc strobe_regs
[] = {
31 /* resource selectors */
33 .type
= CS_CFG_REG_TYPE_RESOURCE
,
34 .offset
= TRCRSCTLRn(2),
35 .hw_info
= ETM4_CFG_RES_SEL
,
39 .type
= CS_CFG_REG_TYPE_RESOURCE
,
40 .offset
= TRCRSCTLRn(3),
41 .hw_info
= ETM4_CFG_RES_SEQ
,
44 /* strobe window counter 0 - reload from param 0 */
46 .type
= CS_CFG_REG_TYPE_RESOURCE
| CS_CFG_REG_TYPE_VAL_SAVE
,
47 .offset
= TRCCNTVRn(0),
48 .hw_info
= ETM4_CFG_RES_CTR
,
51 .type
= CS_CFG_REG_TYPE_RESOURCE
| CS_CFG_REG_TYPE_VAL_PARAM
,
52 .offset
= TRCCNTRLDVRn(0),
53 .hw_info
= ETM4_CFG_RES_CTR
,
57 .type
= CS_CFG_REG_TYPE_RESOURCE
,
58 .offset
= TRCCNTCTLRn(0),
59 .hw_info
= ETM4_CFG_RES_CTR
,
62 /* strobe period counter 1 - reload from param 1 */
64 .type
= CS_CFG_REG_TYPE_RESOURCE
| CS_CFG_REG_TYPE_VAL_SAVE
,
65 .offset
= TRCCNTVRn(1),
66 .hw_info
= ETM4_CFG_RES_CTR
,
69 .type
= CS_CFG_REG_TYPE_RESOURCE
| CS_CFG_REG_TYPE_VAL_PARAM
,
70 .offset
= TRCCNTRLDVRn(1),
71 .hw_info
= ETM4_CFG_RES_CTR
,
75 .type
= CS_CFG_REG_TYPE_RESOURCE
,
76 .offset
= TRCCNTCTLRn(1),
77 .hw_info
= ETM4_CFG_RES_CTR
,
82 .type
= CS_CFG_REG_TYPE_RESOURCE
,
83 .offset
= TRCSEQEVRn(0),
84 .hw_info
= ETM4_CFG_RES_SEQ
,
88 .type
= CS_CFG_REG_TYPE_RESOURCE
,
89 .offset
= TRCSEQEVRn(1),
90 .hw_info
= ETM4_CFG_RES_SEQ
,
95 .type
= CS_CFG_REG_TYPE_STD
| CS_CFG_REG_TYPE_VAL_MASK
,
103 struct cscfg_feature_desc strobe_etm4x
= {
105 .description
= "Generate periodic trace capture windows.\n"
106 "parameter \'window\': a number of CPU cycles (W)\n"
107 "parameter \'period\': trace enabled for W cycles every period x W cycles\n",
108 .match_flags
= CS_CFG_MATCH_CLASS_SRC_ETM4
,
109 .nr_params
= ARRAY_SIZE(strobe_params
),
110 .params_desc
= strobe_params
,
111 .nr_regs
= ARRAY_SIZE(strobe_regs
),
112 .regs_desc
= strobe_regs
,
115 /* create an autofdo configuration */
117 /* we will provide 9 sets of preset parameter values */
118 #define AFDO_NR_PRESETS 9
119 /* the total number of parameters in used features */
120 #define AFDO_NR_PARAMS ARRAY_SIZE(strobe_params)
122 static const char *afdo_ref_names
[] = {
127 * set of presets leaves strobing window constant while varying period to allow
128 * experimentation with mark / space ratios for various workloads
130 static u64 afdo_presets
[AFDO_NR_PRESETS
][AFDO_NR_PARAMS
] = {
142 struct cscfg_config_desc afdo_etm4x
= {
144 .description
= "Setup ETMs with strobing for autofdo\n"
145 "Supplied presets allow experimentation with mark-space ratio for various loads\n",
146 .nr_feat_refs
= ARRAY_SIZE(afdo_ref_names
),
147 .feat_ref_names
= afdo_ref_names
,
148 .nr_presets
= AFDO_NR_PRESETS
,
149 .nr_total_params
= AFDO_NR_PARAMS
,
150 .presets
= &afdo_presets
[0][0],
153 /* end of ETM4x configurations */
154 #endif /* IS_ENABLED(CONFIG_CORESIGHT_SOURCE_ETM4X) */