Loading...
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright(C) 2020 Linaro Limited. All rights reserved.
4 * Author: Mike Leach <mike.leach@linaro.org>
5 */
6
7#include "coresight-config.h"
8
9/* ETMv4 includes and features */
10#if IS_ENABLED(CONFIG_CORESIGHT_SOURCE_ETM4X)
11#include "coresight-etm4x-cfg.h"
12
13/* preload configurations and features */
14
15/* preload in features for ETMv4 */
16
17/* strobe feature */
18static struct cscfg_parameter_desc strobe_params[] = {
19 {
20 .name = "window",
21 .value = 5000,
22 },
23 {
24 .name = "period",
25 .value = 10000,
26 },
27};
28
29static struct cscfg_regval_desc strobe_regs[] = {
30 /* resource selectors */
31 {
32 .type = CS_CFG_REG_TYPE_RESOURCE,
33 .offset = TRCRSCTLRn(2),
34 .hw_info = ETM4_CFG_RES_SEL,
35 .val32 = 0x20001,
36 },
37 {
38 .type = CS_CFG_REG_TYPE_RESOURCE,
39 .offset = TRCRSCTLRn(3),
40 .hw_info = ETM4_CFG_RES_SEQ,
41 .val32 = 0x20002,
42 },
43 /* strobe window counter 0 - reload from param 0 */
44 {
45 .type = CS_CFG_REG_TYPE_RESOURCE | CS_CFG_REG_TYPE_VAL_SAVE,
46 .offset = TRCCNTVRn(0),
47 .hw_info = ETM4_CFG_RES_CTR,
48 },
49 {
50 .type = CS_CFG_REG_TYPE_RESOURCE | CS_CFG_REG_TYPE_VAL_PARAM,
51 .offset = TRCCNTRLDVRn(0),
52 .hw_info = ETM4_CFG_RES_CTR,
53 .val32 = 0,
54 },
55 {
56 .type = CS_CFG_REG_TYPE_RESOURCE,
57 .offset = TRCCNTCTLRn(0),
58 .hw_info = ETM4_CFG_RES_CTR,
59 .val32 = 0x10001,
60 },
61 /* strobe period counter 1 - reload from param 1 */
62 {
63 .type = CS_CFG_REG_TYPE_RESOURCE | CS_CFG_REG_TYPE_VAL_SAVE,
64 .offset = TRCCNTVRn(1),
65 .hw_info = ETM4_CFG_RES_CTR,
66 },
67 {
68 .type = CS_CFG_REG_TYPE_RESOURCE | CS_CFG_REG_TYPE_VAL_PARAM,
69 .offset = TRCCNTRLDVRn(1),
70 .hw_info = ETM4_CFG_RES_CTR,
71 .val32 = 1,
72 },
73 {
74 .type = CS_CFG_REG_TYPE_RESOURCE,
75 .offset = TRCCNTCTLRn(1),
76 .hw_info = ETM4_CFG_RES_CTR,
77 .val32 = 0x8102,
78 },
79 /* sequencer */
80 {
81 .type = CS_CFG_REG_TYPE_RESOURCE,
82 .offset = TRCSEQEVRn(0),
83 .hw_info = ETM4_CFG_RES_SEQ,
84 .val32 = 0x0081,
85 },
86 {
87 .type = CS_CFG_REG_TYPE_RESOURCE,
88 .offset = TRCSEQEVRn(1),
89 .hw_info = ETM4_CFG_RES_SEQ,
90 .val32 = 0x0000,
91 },
92 /* view-inst */
93 {
94 .type = CS_CFG_REG_TYPE_STD | CS_CFG_REG_TYPE_VAL_MASK,
95 .offset = TRCVICTLR,
96 .val32 = 0x0003,
97 .mask32 = 0x0003,
98 },
99 /* end of regs */
100};
101
102struct cscfg_feature_desc strobe_etm4x = {
103 .name = "strobing",
104 .description = "Generate periodic trace capture windows.\n"
105 "parameter \'window\': a number of CPU cycles (W)\n"
106 "parameter \'period\': trace enabled for W cycles every period x W cycles\n",
107 .match_flags = CS_CFG_MATCH_CLASS_SRC_ETM4,
108 .nr_params = ARRAY_SIZE(strobe_params),
109 .params_desc = strobe_params,
110 .nr_regs = ARRAY_SIZE(strobe_regs),
111 .regs_desc = strobe_regs,
112};
113
114/* create an autofdo configuration */
115
116/* we will provide 9 sets of preset parameter values */
117#define AFDO_NR_PRESETS 9
118/* the total number of parameters in used features */
119#define AFDO_NR_PARAMS ARRAY_SIZE(strobe_params)
120
121static const char *afdo_ref_names[] = {
122 "strobing",
123};
124
125/*
126 * set of presets leaves strobing window constant while varying period to allow
127 * experimentation with mark / space ratios for various workloads
128 */
129static u64 afdo_presets[AFDO_NR_PRESETS][AFDO_NR_PARAMS] = {
130 { 5000, 2 },
131 { 5000, 4 },
132 { 5000, 8 },
133 { 5000, 16 },
134 { 5000, 64 },
135 { 5000, 128 },
136 { 5000, 512 },
137 { 5000, 1024 },
138 { 5000, 4096 },
139};
140
141struct cscfg_config_desc afdo_etm4x = {
142 .name = "autofdo",
143 .description = "Setup ETMs with strobing for autofdo\n"
144 "Supplied presets allow experimentation with mark-space ratio for various loads\n",
145 .nr_feat_refs = ARRAY_SIZE(afdo_ref_names),
146 .feat_ref_names = afdo_ref_names,
147 .nr_presets = AFDO_NR_PRESETS,
148 .nr_total_params = AFDO_NR_PARAMS,
149 .presets = &afdo_presets[0][0],
150};
151
152/* end of ETM4x configurations */
153#endif /* IS_ENABLED(CONFIG_CORESIGHT_SOURCE_ETM4X) */
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright(C) 2020 Linaro Limited. All rights reserved.
4 * Author: Mike Leach <mike.leach@linaro.org>
5 */
6
7#include "coresight-config.h"
8
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"
13
14/* preload configurations and features */
15
16/* preload in features for ETMv4 */
17
18/* strobe feature */
19static struct cscfg_parameter_desc strobe_params[] = {
20 {
21 .name = "window",
22 .value = 5000,
23 },
24 {
25 .name = "period",
26 .value = 10000,
27 },
28};
29
30static struct cscfg_regval_desc strobe_regs[] = {
31 /* resource selectors */
32 {
33 .type = CS_CFG_REG_TYPE_RESOURCE,
34 .offset = TRCRSCTLRn(2),
35 .hw_info = ETM4_CFG_RES_SEL,
36 .val32 = 0x20001,
37 },
38 {
39 .type = CS_CFG_REG_TYPE_RESOURCE,
40 .offset = TRCRSCTLRn(3),
41 .hw_info = ETM4_CFG_RES_SEQ,
42 .val32 = 0x20002,
43 },
44 /* strobe window counter 0 - reload from param 0 */
45 {
46 .type = CS_CFG_REG_TYPE_RESOURCE | CS_CFG_REG_TYPE_VAL_SAVE,
47 .offset = TRCCNTVRn(0),
48 .hw_info = ETM4_CFG_RES_CTR,
49 },
50 {
51 .type = CS_CFG_REG_TYPE_RESOURCE | CS_CFG_REG_TYPE_VAL_PARAM,
52 .offset = TRCCNTRLDVRn(0),
53 .hw_info = ETM4_CFG_RES_CTR,
54 .val32 = 0,
55 },
56 {
57 .type = CS_CFG_REG_TYPE_RESOURCE,
58 .offset = TRCCNTCTLRn(0),
59 .hw_info = ETM4_CFG_RES_CTR,
60 .val32 = 0x10001,
61 },
62 /* strobe period counter 1 - reload from param 1 */
63 {
64 .type = CS_CFG_REG_TYPE_RESOURCE | CS_CFG_REG_TYPE_VAL_SAVE,
65 .offset = TRCCNTVRn(1),
66 .hw_info = ETM4_CFG_RES_CTR,
67 },
68 {
69 .type = CS_CFG_REG_TYPE_RESOURCE | CS_CFG_REG_TYPE_VAL_PARAM,
70 .offset = TRCCNTRLDVRn(1),
71 .hw_info = ETM4_CFG_RES_CTR,
72 .val32 = 1,
73 },
74 {
75 .type = CS_CFG_REG_TYPE_RESOURCE,
76 .offset = TRCCNTCTLRn(1),
77 .hw_info = ETM4_CFG_RES_CTR,
78 .val32 = 0x8102,
79 },
80 /* sequencer */
81 {
82 .type = CS_CFG_REG_TYPE_RESOURCE,
83 .offset = TRCSEQEVRn(0),
84 .hw_info = ETM4_CFG_RES_SEQ,
85 .val32 = 0x0081,
86 },
87 {
88 .type = CS_CFG_REG_TYPE_RESOURCE,
89 .offset = TRCSEQEVRn(1),
90 .hw_info = ETM4_CFG_RES_SEQ,
91 .val32 = 0x0000,
92 },
93 /* view-inst */
94 {
95 .type = CS_CFG_REG_TYPE_STD | CS_CFG_REG_TYPE_VAL_MASK,
96 .offset = TRCVICTLR,
97 .val32 = 0x0003,
98 .mask32 = 0x0003,
99 },
100 /* end of regs */
101};
102
103struct cscfg_feature_desc strobe_etm4x = {
104 .name = "strobing",
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,
113};
114
115/* create an autofdo configuration */
116
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)
121
122static const char *afdo_ref_names[] = {
123 "strobing",
124};
125
126/*
127 * set of presets leaves strobing window constant while varying period to allow
128 * experimentation with mark / space ratios for various workloads
129 */
130static u64 afdo_presets[AFDO_NR_PRESETS][AFDO_NR_PARAMS] = {
131 { 5000, 2 },
132 { 5000, 4 },
133 { 5000, 8 },
134 { 5000, 16 },
135 { 5000, 64 },
136 { 5000, 128 },
137 { 5000, 512 },
138 { 5000, 1024 },
139 { 5000, 4096 },
140};
141
142struct cscfg_config_desc afdo_etm4x = {
143 .name = "autofdo",
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],
151};
152
153/* end of ETM4x configurations */
154#endif /* IS_ENABLED(CONFIG_CORESIGHT_SOURCE_ETM4X) */