Pushkar Joshi | 85688c6 | 2012-12-06 10:52:02 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved. |
Pratik Patel | c35426a | 2012-03-17 12:02:53 -0700 | [diff] [blame] | 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 | |
Pratik Patel | 6fb3834 | 2012-06-03 14:51:38 -0700 | [diff] [blame] | 13 | #ifndef _LINUX_CORESIGHT_H |
| 14 | #define _LINUX_CORESIGHT_H |
Pratik Patel | 43e47bd | 2012-05-19 18:10:55 -0700 | [diff] [blame] | 15 | |
Pratik Patel | b84ef9d | 2012-05-24 14:01:43 -0700 | [diff] [blame] | 16 | #include <linux/device.h> |
| 17 | |
Pratik Patel | 43e47bd | 2012-05-19 18:10:55 -0700 | [diff] [blame] | 18 | /* Peripheral id registers (0xFD0-0xFEC) */ |
Pratik Patel | 6fb3834 | 2012-06-03 14:51:38 -0700 | [diff] [blame] | 19 | #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 Patel | 43e47bd | 2012-05-19 18:10:55 -0700 | [diff] [blame] | 27 | /* Component id registers (0xFF0-0xFFC) */ |
Pratik Patel | 6fb3834 | 2012-06-03 14:51:38 -0700 | [diff] [blame] | 28 | #define CORESIGHT_COMPIDR0 (0xFF0) |
| 29 | #define CORESIGHT_COMPIDR1 (0xFF4) |
| 30 | #define CORESIGHT_COMPIDR2 (0xFF8) |
| 31 | #define CORESIGHT_COMPIDR3 (0xFFC) |
Pratik Patel | 43e47bd | 2012-05-19 18:10:55 -0700 | [diff] [blame] | 32 | |
Pushkar Joshi | 85688c6 | 2012-12-06 10:52:02 -0800 | [diff] [blame] | 33 | #define ETM_ARCH_V1_0 (0x00) |
| 34 | #define ETM_ARCH_V1_2 (0x02) |
Pratik Patel | 43e47bd | 2012-05-19 18:10:55 -0700 | [diff] [blame] | 35 | #define ETM_ARCH_V3_3 (0x23) |
Pushkar Joshi | 85688c6 | 2012-12-06 10:52:02 -0800 | [diff] [blame] | 36 | #define ETM_ARCH_V3_5 (0x25) |
| 37 | #define PFT_ARCH_MAJOR (0x30) |
Pratik Patel | 43e47bd | 2012-05-19 18:10:55 -0700 | [diff] [blame] | 38 | #define PFT_ARCH_V1_1 (0x31) |
Pratik Patel | c35426a | 2012-03-17 12:02:53 -0700 | [diff] [blame] | 39 | |
Pratik Patel | 6fb3834 | 2012-06-03 14:51:38 -0700 | [diff] [blame] | 40 | enum coresight_clk_rate { |
| 41 | CORESIGHT_CLK_RATE_OFF, |
| 42 | CORESIGHT_CLK_RATE_TRACE, |
| 43 | CORESIGHT_CLK_RATE_HSTRACE, |
Pratik Patel | f17b147 | 2012-05-25 22:23:52 -0700 | [diff] [blame] | 44 | }; |
| 45 | |
Pratik Patel | 6fb3834 | 2012-06-03 14:51:38 -0700 | [diff] [blame] | 46 | enum coresight_dev_type { |
Pratik Patel | b8bb403 | 2012-07-22 23:09:11 -0700 | [diff] [blame] | 47 | CORESIGHT_DEV_TYPE_NONE, |
Pratik Patel | 6fb3834 | 2012-06-03 14:51:38 -0700 | [diff] [blame] | 48 | CORESIGHT_DEV_TYPE_SINK, |
| 49 | CORESIGHT_DEV_TYPE_LINK, |
Pratik Patel | 0a7edd3 | 2012-06-08 09:31:55 -0700 | [diff] [blame] | 50 | CORESIGHT_DEV_TYPE_LINKSINK, |
Pratik Patel | 6fb3834 | 2012-06-03 14:51:38 -0700 | [diff] [blame] | 51 | CORESIGHT_DEV_TYPE_SOURCE, |
Pratik Patel | 0a7edd3 | 2012-06-08 09:31:55 -0700 | [diff] [blame] | 52 | }; |
| 53 | |
| 54 | enum coresight_dev_subtype_sink { |
| 55 | CORESIGHT_DEV_SUBTYPE_SINK_NONE, |
| 56 | CORESIGHT_DEV_SUBTYPE_SINK_PORT, |
| 57 | CORESIGHT_DEV_SUBTYPE_SINK_BUFFER, |
| 58 | }; |
| 59 | |
| 60 | enum coresight_dev_subtype_link { |
| 61 | CORESIGHT_DEV_SUBTYPE_LINK_NONE, |
| 62 | CORESIGHT_DEV_SUBTYPE_LINK_MERG, |
| 63 | CORESIGHT_DEV_SUBTYPE_LINK_SPLIT, |
| 64 | CORESIGHT_DEV_SUBTYPE_LINK_FIFO, |
| 65 | }; |
| 66 | |
| 67 | enum coresight_dev_subtype_source { |
| 68 | CORESIGHT_DEV_SUBTYPE_SOURCE_NONE, |
| 69 | CORESIGHT_DEV_SUBTYPE_SOURCE_PROC, |
| 70 | CORESIGHT_DEV_SUBTYPE_SOURCE_BUS, |
| 71 | CORESIGHT_DEV_SUBTYPE_SOURCE_SOFTWARE, |
| 72 | }; |
| 73 | |
| 74 | struct coresight_dev_subtype { |
| 75 | enum coresight_dev_subtype_sink sink_subtype; |
| 76 | enum coresight_dev_subtype_link link_subtype; |
| 77 | enum coresight_dev_subtype_source source_subtype; |
| 78 | }; |
| 79 | |
| 80 | struct coresight_platform_data { |
| 81 | int id; |
| 82 | const char *name; |
| 83 | int nr_inports; |
| 84 | const int *outports; |
| 85 | const int *child_ids; |
| 86 | const int *child_ports; |
| 87 | int nr_outports; |
| 88 | bool default_sink; |
| 89 | }; |
| 90 | |
| 91 | struct coresight_desc { |
| 92 | enum coresight_dev_type type; |
| 93 | struct coresight_dev_subtype subtype; |
| 94 | const struct coresight_ops *ops; |
| 95 | struct coresight_platform_data *pdata; |
| 96 | struct device *dev; |
| 97 | const struct attribute_group **groups; |
| 98 | struct module *owner; |
Pratik Patel | b84ef9d | 2012-05-24 14:01:43 -0700 | [diff] [blame] | 99 | }; |
| 100 | |
Pratik Patel | 6fb3834 | 2012-06-03 14:51:38 -0700 | [diff] [blame] | 101 | struct coresight_connection { |
Pratik Patel | 0a7edd3 | 2012-06-08 09:31:55 -0700 | [diff] [blame] | 102 | int outport; |
Pratik Patel | b84ef9d | 2012-05-24 14:01:43 -0700 | [diff] [blame] | 103 | int child_id; |
| 104 | int child_port; |
Pratik Patel | 6fb3834 | 2012-06-03 14:51:38 -0700 | [diff] [blame] | 105 | struct coresight_device *child_dev; |
Pratik Patel | b84ef9d | 2012-05-24 14:01:43 -0700 | [diff] [blame] | 106 | struct list_head link; |
| 107 | }; |
| 108 | |
Pratik Patel | 0a7edd3 | 2012-06-08 09:31:55 -0700 | [diff] [blame] | 109 | struct coresight_refcnt { |
| 110 | int sink_refcnt; |
| 111 | int *link_refcnts; |
| 112 | int source_refcnt; |
| 113 | }; |
| 114 | |
Pratik Patel | 6fb3834 | 2012-06-03 14:51:38 -0700 | [diff] [blame] | 115 | struct coresight_device { |
Pratik Patel | b84ef9d | 2012-05-24 14:01:43 -0700 | [diff] [blame] | 116 | int id; |
Pratik Patel | 6fb3834 | 2012-06-03 14:51:38 -0700 | [diff] [blame] | 117 | struct coresight_connection *conns; |
Pratik Patel | b84ef9d | 2012-05-24 14:01:43 -0700 | [diff] [blame] | 118 | int nr_conns; |
Pratik Patel | 0a7edd3 | 2012-06-08 09:31:55 -0700 | [diff] [blame] | 119 | enum coresight_dev_type type; |
| 120 | struct coresight_dev_subtype subtype; |
Pratik Patel | 6fb3834 | 2012-06-03 14:51:38 -0700 | [diff] [blame] | 121 | const struct coresight_ops *ops; |
Pratik Patel | b84ef9d | 2012-05-24 14:01:43 -0700 | [diff] [blame] | 122 | struct device dev; |
Pratik Patel | 0a7edd3 | 2012-06-08 09:31:55 -0700 | [diff] [blame] | 123 | struct coresight_refcnt refcnt; |
| 124 | struct list_head dev_link; |
| 125 | struct list_head path_link; |
Pratik Patel | b84ef9d | 2012-05-24 14:01:43 -0700 | [diff] [blame] | 126 | struct module *owner; |
| 127 | bool enable; |
| 128 | }; |
| 129 | |
Pratik Patel | 6fb3834 | 2012-06-03 14:51:38 -0700 | [diff] [blame] | 130 | #define to_coresight_device(d) container_of(d, struct coresight_device, dev) |
Pratik Patel | b84ef9d | 2012-05-24 14:01:43 -0700 | [diff] [blame] | 131 | |
Pratik Patel | 0a7edd3 | 2012-06-08 09:31:55 -0700 | [diff] [blame] | 132 | struct coresight_ops_sink { |
| 133 | int (*enable)(struct coresight_device *csdev); |
| 134 | void (*disable)(struct coresight_device *csdev); |
Pratik Patel | cf7d045 | 2012-07-02 13:57:20 -0700 | [diff] [blame] | 135 | void (*abort)(struct coresight_device *csdev); |
Pratik Patel | 0a7edd3 | 2012-06-08 09:31:55 -0700 | [diff] [blame] | 136 | }; |
| 137 | |
| 138 | struct coresight_ops_link { |
| 139 | int (*enable)(struct coresight_device *csdev, int iport, int oport); |
| 140 | void (*disable)(struct coresight_device *csdev, int iport, int oport); |
| 141 | }; |
| 142 | |
| 143 | struct coresight_ops_source { |
| 144 | int (*enable)(struct coresight_device *csdev); |
| 145 | void (*disable)(struct coresight_device *csdev); |
| 146 | }; |
| 147 | |
Pratik Patel | 6fb3834 | 2012-06-03 14:51:38 -0700 | [diff] [blame] | 148 | struct coresight_ops { |
Pratik Patel | 0a7edd3 | 2012-06-08 09:31:55 -0700 | [diff] [blame] | 149 | const struct coresight_ops_sink *sink_ops; |
| 150 | const struct coresight_ops_link *link_ops; |
| 151 | const struct coresight_ops_source *source_ops; |
Pratik Patel | b84ef9d | 2012-05-24 14:01:43 -0700 | [diff] [blame] | 152 | }; |
| 153 | |
Pratik Patel | 61e9170 | 2013-01-27 20:30:42 -0800 | [diff] [blame] | 154 | #ifdef CONFIG_CORESIGHT |
Pratik Patel | 0a7edd3 | 2012-06-08 09:31:55 -0700 | [diff] [blame] | 155 | extern struct coresight_device * |
| 156 | coresight_register(struct coresight_desc *desc); |
| 157 | extern void coresight_unregister(struct coresight_device *csdev); |
| 158 | extern int coresight_enable(struct coresight_device *csdev); |
| 159 | extern void coresight_disable(struct coresight_device *csdev); |
Pratik Patel | cf7d045 | 2012-07-02 13:57:20 -0700 | [diff] [blame] | 160 | extern void coresight_abort(void); |
Pratik Patel | bf3e7744 | 2012-03-18 18:30:43 -0700 | [diff] [blame] | 161 | #else |
Pratik Patel | 0a7edd3 | 2012-06-08 09:31:55 -0700 | [diff] [blame] | 162 | static inline struct coresight_device * |
| 163 | coresight_register(struct coresight_desc *desc) { return NULL; } |
| 164 | static inline void coresight_unregister(struct coresight_device *csdev) {} |
| 165 | static inline int |
| 166 | coresight_enable(struct coresight_device *csdev) { return -ENOSYS; } |
| 167 | static inline void coresight_disable(struct coresight_device *csdev) {} |
Pratik Patel | cf7d045 | 2012-07-02 13:57:20 -0700 | [diff] [blame] | 168 | static inline void coresight_abort(void) {} |
Pratik Patel | bf3e7744 | 2012-03-18 18:30:43 -0700 | [diff] [blame] | 169 | #endif |
| 170 | |
Pratik Patel | c35426a | 2012-03-17 12:02:53 -0700 | [diff] [blame] | 171 | #endif |