blob: b0e35eec6499bf4367da462c1f180c77821336e2 [file] [log] [blame]
Mathieu Poirier8a9fd832018-04-18 16:05:18 -06001/* SPDX-License-Identifier: GPL-2.0 */
Mathieu Poirier0bcbf2e2016-02-17 17:52:01 -07002/*
3 * Copyright(C) 2015 Linaro Limited. All rights reserved.
4 * Author: Mathieu Poirier <mathieu.poirier@linaro.org>
Mathieu Poirier0bcbf2e2016-02-17 17:52:01 -07005 */
6
7#ifndef _LINUX_CORESIGHT_PMU_H
8#define _LINUX_CORESIGHT_PMU_H
9
10#define CORESIGHT_ETM_PMU_NAME "cs_etm"
Mathieu Poirier17534ce2016-02-17 17:52:02 -070011#define CORESIGHT_ETM_PMU_SEED 0x10
Mathieu Poirier0bcbf2e2016-02-17 17:52:01 -070012
13/* ETMv3.5/PTM's ETMCR config bit */
14#define ETM_OPT_CYCACC 12
Mathieu Poirier82500a82019-04-25 13:52:52 -060015#define ETM_OPT_CTXTID 14
Mathieu Poirier0bcbf2e2016-02-17 17:52:01 -070016#define ETM_OPT_TS 28
Mike Leachb97971b2017-08-02 10:22:01 -060017#define ETM_OPT_RETSTK 29
Mathieu Poirier0bcbf2e2016-02-17 17:52:01 -070018
Mike Leachdf770ff2017-08-02 10:22:19 -060019/* ETMv4 CONFIGR programming bits for the ETM OPTs */
20#define ETM4_CFG_BIT_CYCACC 4
Mathieu Poirier82500a82019-04-25 13:52:52 -060021#define ETM4_CFG_BIT_CTXTID 6
Mike Leachdf770ff2017-08-02 10:22:19 -060022#define ETM4_CFG_BIT_TS 11
23#define ETM4_CFG_BIT_RETSTK 12
24
Mathieu Poirier17534ce2016-02-17 17:52:02 -070025static inline int coresight_get_trace_id(int cpu)
26{
27 /*
28 * A trace ID of value 0 is invalid, so let's start at some
29 * random value that fits in 7 bits and go from there. Since
30 * the common convention is to have data trace IDs be I(N) + 1,
31 * set instruction trace IDs as a function of the CPU number.
32 */
33 return (CORESIGHT_ETM_PMU_SEED + (cpu * 2));
34}
35
Mathieu Poirier0bcbf2e2016-02-17 17:52:01 -070036#endif