Satyajit Desai | e30e3c5 | 2016-08-22 11:22:51 -0700 | [diff] [blame] | 1 | #ifndef __LINUX_CORESIGHT_STM_H |
| 2 | #define __LINUX_CORESIGHT_STM_H |
Pratik Patel | 237483a | 2016-05-03 11:33:40 -0600 | [diff] [blame] | 3 | |
Satyajit Desai | e30e3c5 | 2016-08-22 11:22:51 -0700 | [diff] [blame] | 4 | #include <asm/local.h> |
| 5 | #include <linux/stm.h> |
| 6 | #include <linux/bitmap.h> |
Pratik Patel | 237483a | 2016-05-03 11:33:40 -0600 | [diff] [blame] | 7 | #include <uapi/linux/coresight-stm.h> |
| 8 | |
Satyajit Desai | e30e3c5 | 2016-08-22 11:22:51 -0700 | [diff] [blame] | 9 | #define BYTES_PER_CHANNEL 256 |
| 10 | |
| 11 | enum stm_pkt_type { |
| 12 | STM_PKT_TYPE_DATA = 0x98, |
| 13 | STM_PKT_TYPE_FLAG = 0xE8, |
| 14 | STM_PKT_TYPE_TRIG = 0xF8, |
| 15 | }; |
| 16 | |
| 17 | #define stm_channel_off(type, opts) (type & ~opts) |
| 18 | |
| 19 | #define stm_channel_addr(drvdata, ch) (drvdata->chs.base + \ |
| 20 | (ch * BYTES_PER_CHANNEL)) |
| 21 | |
| 22 | #define stm_log_inv(entity_id, proto_id, data, size) \ |
| 23 | stm_trace(STM_FLAG_NONE, entity_id, proto_id, data, size) |
| 24 | |
| 25 | #define stm_log_inv_ts(entity_id, proto_id, data, size) \ |
| 26 | stm_trace(STM_FLAG_TIMESTAMPED, entity_id, proto_id, \ |
| 27 | data, size) |
| 28 | |
| 29 | #define stm_log_gtd(entity_id, proto_id, data, size) \ |
| 30 | stm_trace(STM_FLAG_GUARANTEED, entity_id, proto_id, \ |
| 31 | data, size) |
| 32 | |
| 33 | #define stm_log_gtd_ts(entity_id, proto_id, data, size) \ |
| 34 | stm_trace(STM_FLAG_GUARANTEED | STM_OPTION_TIMESTAMPED, \ |
| 35 | entity_id, proto_id, data, size) |
| 36 | |
| 37 | #define stm_log(entity_id, data, size) \ |
| 38 | stm_log_inv_ts(entity_id, 0, data, size) |
| 39 | |
| 40 | /** |
| 41 | * struct channel_space - central management entity for extended ports |
| 42 | * @base: memory mapped base address where channels start. |
Kyle Yan | 65be4a5 | 2016-10-31 15:05:00 -0700 | [diff] [blame] | 43 | * @phys: physical base address of channel region. |
Satyajit Desai | e30e3c5 | 2016-08-22 11:22:51 -0700 | [diff] [blame] | 44 | * @guaraneed: is the channel delivery guaranteed. |
| 45 | * @bitmap: channel info for OST packet |
| 46 | */ |
| 47 | struct channel_space { |
| 48 | void __iomem *base; |
Kyle Yan | 65be4a5 | 2016-10-31 15:05:00 -0700 | [diff] [blame] | 49 | phys_addr_t phys; |
Satyajit Desai | e30e3c5 | 2016-08-22 11:22:51 -0700 | [diff] [blame] | 50 | unsigned long *guaranteed; |
| 51 | unsigned long *bitmap; |
| 52 | }; |
| 53 | |
| 54 | /** |
| 55 | * struct stm_drvdata - specifics associated to an STM component |
| 56 | * @base: memory mapped base address for this component. |
| 57 | * @dev: the device entity associated to this component. |
| 58 | * @atclk: optional clock for the core parts of the STM. |
| 59 | * @csdev: component vitals needed by the framework. |
| 60 | * @spinlock: only one at a time pls. |
| 61 | * @chs: the channels accociated to this STM. |
| 62 | * @entities currently configured OST entities. |
| 63 | * @stm: structure associated to the generic STM interface. |
| 64 | * @mode: this tracer's mode, i.e sysFS, or disabled. |
| 65 | * @traceid: value of the current ID for this component. |
| 66 | * @write_bytes: Maximus bytes this STM can write at a time. |
| 67 | * @stmsper: settings for register STMSPER. |
| 68 | * @stmspscr: settings for register STMSPSCR. |
| 69 | * @numsp: the total number of stimulus port support by this STM. |
| 70 | * @stmheer: settings for register STMHEER. |
| 71 | * @stmheter: settings for register STMHETER. |
| 72 | * @stmhebsr: settings for register STMHEBSR. |
Satyajit Desai | 262e85b | 2017-03-08 17:17:45 -0800 | [diff] [blame] | 73 | * @ch_alloc_fail_count: Number of ch allocation failures over time. |
Satyajit Desai | e30e3c5 | 2016-08-22 11:22:51 -0700 | [diff] [blame] | 74 | */ |
| 75 | struct stm_drvdata { |
| 76 | void __iomem *base; |
| 77 | struct device *dev; |
| 78 | struct clk *atclk; |
| 79 | struct coresight_device *csdev; |
| 80 | spinlock_t spinlock; |
| 81 | struct channel_space chs; |
| 82 | bool enable; |
| 83 | DECLARE_BITMAP(entities, OST_ENTITY_MAX); |
| 84 | struct stm_data stm; |
| 85 | local_t mode; |
| 86 | u8 traceid; |
| 87 | u32 write_bytes; |
| 88 | u32 stmsper; |
| 89 | u32 stmspscr; |
| 90 | u32 numsp; |
| 91 | u32 stmheer; |
| 92 | u32 stmheter; |
| 93 | u32 stmhebsr; |
Satyajit Desai | 262e85b | 2017-03-08 17:17:45 -0800 | [diff] [blame] | 94 | u32 ch_alloc_fail_count; |
Satyajit Desai | e30e3c5 | 2016-08-22 11:22:51 -0700 | [diff] [blame] | 95 | }; |
| 96 | |
| 97 | #ifdef CONFIG_CORESIGHT_STM |
| 98 | extern int stm_trace(uint32_t flags, uint8_t entity_id, uint8_t proto_id, |
| 99 | const void *data, uint32_t size); |
| 100 | |
| 101 | void stm_send(void *addr, const void *data, u32 size, u8 write_bytes); |
| 102 | #else |
| 103 | static inline int stm_trace(uint32_t flags, uint8_t entity_id, |
| 104 | uint8_t proto_id, const void *data, uint32_t size) |
| 105 | { |
| 106 | return 0; |
| 107 | } |
| 108 | static inline void stm_send(void *addr, const void *data, u32 size, |
| 109 | u8 write_bytes) {} |
| 110 | #endif |
Pratik Patel | 237483a | 2016-05-03 11:33:40 -0600 | [diff] [blame] | 111 | #endif |