blob: 3bba69c388ca41404b63cc5260f01a12b87d70c8 [file] [log] [blame]
Pratik Patelb8bb4032012-07-22 23:09:11 -07001/* Copyright (c) 2012, The Linux Foundation. All rights reserved.
Pratik Patelc35426a2012-03-17 12:02:53 -07002 *
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
Pratik Patel6fb38342012-06-03 14:51:38 -070013#ifndef _LINUX_CORESIGHT_H
14#define _LINUX_CORESIGHT_H
Pratik Patel43e47bd2012-05-19 18:10:55 -070015
Pratik Patelb84ef9d2012-05-24 14:01:43 -070016#include <linux/device.h>
17
Pratik Patel43e47bd2012-05-19 18:10:55 -070018/* Peripheral id registers (0xFD0-0xFEC) */
Pratik Patel6fb38342012-06-03 14:51:38 -070019#define CORESIGHT_PERIPHIDR4 (0xFD0)
20#define CORESIGHT_PERIPHIDR5 (0xFD4)
21#define CORESIGHT_PERIPHIDR6 (0xFD8)
22#define CORESIGHT_PERIPHIDR7 (0xFDC)
23#define CORESIGHT_PERIPHIDR0 (0xFE0)
24#define CORESIGHT_PERIPHIDR1 (0xFE4)
25#define CORESIGHT_PERIPHIDR2 (0xFE8)
26#define CORESIGHT_PERIPHIDR3 (0xFEC)
Pratik Patel43e47bd2012-05-19 18:10:55 -070027/* Component id registers (0xFF0-0xFFC) */
Pratik Patel6fb38342012-06-03 14:51:38 -070028#define CORESIGHT_COMPIDR0 (0xFF0)
29#define CORESIGHT_COMPIDR1 (0xFF4)
30#define CORESIGHT_COMPIDR2 (0xFF8)
31#define CORESIGHT_COMPIDR3 (0xFFC)
Pratik Patel43e47bd2012-05-19 18:10:55 -070032
33/* DBGv7 with baseline CP14 registers implemented */
34#define ARM_DEBUG_ARCH_V7B (0x3)
35/* DBGv7 with all CP14 registers implemented */
36#define ARM_DEBUG_ARCH_V7 (0x4)
37#define ARM_DEBUG_ARCH_V7_1 (0x5)
38#define ETM_ARCH_V3_3 (0x23)
39#define PFT_ARCH_V1_1 (0x31)
Pratik Patelc35426a2012-03-17 12:02:53 -070040
Pratik Patel6fb38342012-06-03 14:51:38 -070041enum coresight_clk_rate {
42 CORESIGHT_CLK_RATE_OFF,
43 CORESIGHT_CLK_RATE_TRACE,
44 CORESIGHT_CLK_RATE_HSTRACE,
Pratik Patelf17b1472012-05-25 22:23:52 -070045};
46
Pratik Patel6fb38342012-06-03 14:51:38 -070047enum coresight_dev_type {
Pratik Patelb8bb4032012-07-22 23:09:11 -070048 CORESIGHT_DEV_TYPE_NONE,
Pratik Patel6fb38342012-06-03 14:51:38 -070049 CORESIGHT_DEV_TYPE_SINK,
50 CORESIGHT_DEV_TYPE_LINK,
Pratik Patel0a7edd32012-06-08 09:31:55 -070051 CORESIGHT_DEV_TYPE_LINKSINK,
Pratik Patel6fb38342012-06-03 14:51:38 -070052 CORESIGHT_DEV_TYPE_SOURCE,
Pratik Patel0a7edd32012-06-08 09:31:55 -070053};
54
55enum coresight_dev_subtype_sink {
56 CORESIGHT_DEV_SUBTYPE_SINK_NONE,
57 CORESIGHT_DEV_SUBTYPE_SINK_PORT,
58 CORESIGHT_DEV_SUBTYPE_SINK_BUFFER,
59};
60
61enum coresight_dev_subtype_link {
62 CORESIGHT_DEV_SUBTYPE_LINK_NONE,
63 CORESIGHT_DEV_SUBTYPE_LINK_MERG,
64 CORESIGHT_DEV_SUBTYPE_LINK_SPLIT,
65 CORESIGHT_DEV_SUBTYPE_LINK_FIFO,
66};
67
68enum coresight_dev_subtype_source {
69 CORESIGHT_DEV_SUBTYPE_SOURCE_NONE,
70 CORESIGHT_DEV_SUBTYPE_SOURCE_PROC,
71 CORESIGHT_DEV_SUBTYPE_SOURCE_BUS,
72 CORESIGHT_DEV_SUBTYPE_SOURCE_SOFTWARE,
73};
74
75struct coresight_dev_subtype {
76 enum coresight_dev_subtype_sink sink_subtype;
77 enum coresight_dev_subtype_link link_subtype;
78 enum coresight_dev_subtype_source source_subtype;
79};
80
81struct coresight_platform_data {
82 int id;
83 const char *name;
84 int nr_inports;
85 const int *outports;
86 const int *child_ids;
87 const int *child_ports;
88 int nr_outports;
89 bool default_sink;
90};
91
92struct coresight_desc {
93 enum coresight_dev_type type;
94 struct coresight_dev_subtype subtype;
95 const struct coresight_ops *ops;
96 struct coresight_platform_data *pdata;
97 struct device *dev;
98 const struct attribute_group **groups;
99 struct module *owner;
Pratik Patelb84ef9d2012-05-24 14:01:43 -0700100};
101
Pratik Patel6fb38342012-06-03 14:51:38 -0700102struct coresight_connection {
Pratik Patel0a7edd32012-06-08 09:31:55 -0700103 int outport;
Pratik Patelb84ef9d2012-05-24 14:01:43 -0700104 int child_id;
105 int child_port;
Pratik Patel6fb38342012-06-03 14:51:38 -0700106 struct coresight_device *child_dev;
Pratik Patelb84ef9d2012-05-24 14:01:43 -0700107 struct list_head link;
108};
109
Pratik Patel0a7edd32012-06-08 09:31:55 -0700110struct coresight_refcnt {
111 int sink_refcnt;
112 int *link_refcnts;
113 int source_refcnt;
114};
115
Pratik Patel6fb38342012-06-03 14:51:38 -0700116struct coresight_device {
Pratik Patelb84ef9d2012-05-24 14:01:43 -0700117 int id;
Pratik Patel6fb38342012-06-03 14:51:38 -0700118 struct coresight_connection *conns;
Pratik Patelb84ef9d2012-05-24 14:01:43 -0700119 int nr_conns;
Pratik Patel0a7edd32012-06-08 09:31:55 -0700120 enum coresight_dev_type type;
121 struct coresight_dev_subtype subtype;
Pratik Patel6fb38342012-06-03 14:51:38 -0700122 const struct coresight_ops *ops;
Pratik Patelb84ef9d2012-05-24 14:01:43 -0700123 struct device dev;
Pratik Patel0a7edd32012-06-08 09:31:55 -0700124 struct coresight_refcnt refcnt;
125 struct list_head dev_link;
126 struct list_head path_link;
Pratik Patelb84ef9d2012-05-24 14:01:43 -0700127 struct module *owner;
128 bool enable;
129};
130
Pratik Patel6fb38342012-06-03 14:51:38 -0700131#define to_coresight_device(d) container_of(d, struct coresight_device, dev)
Pratik Patelb84ef9d2012-05-24 14:01:43 -0700132
Pratik Patel0a7edd32012-06-08 09:31:55 -0700133struct coresight_ops_sink {
134 int (*enable)(struct coresight_device *csdev);
135 void (*disable)(struct coresight_device *csdev);
Pratik Patelcf7d0452012-07-02 13:57:20 -0700136 void (*abort)(struct coresight_device *csdev);
Pratik Patel0a7edd32012-06-08 09:31:55 -0700137};
138
139struct coresight_ops_link {
140 int (*enable)(struct coresight_device *csdev, int iport, int oport);
141 void (*disable)(struct coresight_device *csdev, int iport, int oport);
142};
143
144struct coresight_ops_source {
145 int (*enable)(struct coresight_device *csdev);
146 void (*disable)(struct coresight_device *csdev);
147};
148
Pratik Patel6fb38342012-06-03 14:51:38 -0700149struct coresight_ops {
Pratik Patel0a7edd32012-06-08 09:31:55 -0700150 const struct coresight_ops_sink *sink_ops;
151 const struct coresight_ops_link *link_ops;
152 const struct coresight_ops_source *source_ops;
Pratik Patelb84ef9d2012-05-24 14:01:43 -0700153};
154
Pratik Patelbf3e77442012-03-18 18:30:43 -0700155#ifdef CONFIG_MSM_QDSS
Pratik Patel0a7edd32012-06-08 09:31:55 -0700156extern struct coresight_device *
157coresight_register(struct coresight_desc *desc);
158extern void coresight_unregister(struct coresight_device *csdev);
159extern int coresight_enable(struct coresight_device *csdev);
160extern void coresight_disable(struct coresight_device *csdev);
Pratik Patelcf7d0452012-07-02 13:57:20 -0700161extern void coresight_abort(void);
Pratik Patelbf3e77442012-03-18 18:30:43 -0700162#else
Pratik Patel0a7edd32012-06-08 09:31:55 -0700163static inline struct coresight_device *
164coresight_register(struct coresight_desc *desc) { return NULL; }
165static inline void coresight_unregister(struct coresight_device *csdev) {}
166static inline int
167coresight_enable(struct coresight_device *csdev) { return -ENOSYS; }
168static inline void coresight_disable(struct coresight_device *csdev) {}
Pratik Patelcf7d0452012-07-02 13:57:20 -0700169static inline void coresight_abort(void) {}
Pratik Patelbf3e77442012-03-18 18:30:43 -0700170#endif
171
Pratik Patelc35426a2012-03-17 12:02:53 -0700172#endif