coresight: etm3x: adding operation mode for etm_enable()
[firefly-linux-kernel-4.4.55.git] / drivers / hwtracing / coresight / coresight-priv.h
1 /* Copyright (c) 2011-2012, The Linux Foundation. All rights reserved.
2  *
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License version 2 and
5  * only version 2 as published by the Free Software Foundation.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10  * GNU General Public License for more details.
11  */
12
13 #ifndef _CORESIGHT_PRIV_H
14 #define _CORESIGHT_PRIV_H
15
16 #include <linux/bitops.h>
17 #include <linux/io.h>
18 #include <linux/coresight.h>
19
20 /*
21  * Coresight management registers (0xf00-0xfcc)
22  * 0xfa0 - 0xfa4: Management    registers in PFTv1.0
23  *                Trace         registers in PFTv1.1
24  */
25 #define CORESIGHT_ITCTRL        0xf00
26 #define CORESIGHT_CLAIMSET      0xfa0
27 #define CORESIGHT_CLAIMCLR      0xfa4
28 #define CORESIGHT_LAR           0xfb0
29 #define CORESIGHT_LSR           0xfb4
30 #define CORESIGHT_AUTHSTATUS    0xfb8
31 #define CORESIGHT_DEVID         0xfc8
32 #define CORESIGHT_DEVTYPE       0xfcc
33
34 #define TIMEOUT_US              100
35 #define BMVAL(val, lsb, msb)    ((val & GENMASK(msb, lsb)) >> lsb)
36
37 enum cs_mode {
38         CS_MODE_DISABLED,
39         CS_MODE_SYSFS,
40         CS_MODE_PERF,
41 };
42
43 static inline void CS_LOCK(void __iomem *addr)
44 {
45         do {
46                 /* Wait for things to settle */
47                 mb();
48                 writel_relaxed(0x0, addr + CORESIGHT_LAR);
49         } while (0);
50 }
51
52 static inline void CS_UNLOCK(void __iomem *addr)
53 {
54         do {
55                 writel_relaxed(CORESIGHT_UNLOCK, addr + CORESIGHT_LAR);
56                 /* Make sure everyone has seen this */
57                 mb();
58         } while (0);
59 }
60
61 void coresight_disable_path(struct list_head *path);
62 int coresight_enable_path(struct list_head *path);
63 struct coresight_device *coresight_get_sink(struct list_head *path);
64 struct list_head *coresight_build_path(struct coresight_device *csdev);
65 void coresight_release_path(struct list_head *path);
66
67 #ifdef CONFIG_CORESIGHT_SOURCE_ETM3X
68 extern int etm_readl_cp14(u32 off, unsigned int *val);
69 extern int etm_writel_cp14(u32 off, u32 val);
70 #else
71 static inline int etm_readl_cp14(u32 off, unsigned int *val) { return 0; }
72 static inline int etm_writel_cp14(u32 off, u32 val) { return 0; }
73 #endif
74
75 #endif