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. |
| 73 | */ |
| 74 | struct stm_drvdata { |
| 75 | void __iomem *base; |
| 76 | struct device *dev; |
| 77 | struct clk *atclk; |
| 78 | struct coresight_device *csdev; |
| 79 | spinlock_t spinlock; |
| 80 | struct channel_space chs; |
| 81 | bool enable; |
| 82 | DECLARE_BITMAP(entities, OST_ENTITY_MAX); |
| 83 | struct stm_data stm; |
| 84 | local_t mode; |
| 85 | u8 traceid; |
| 86 | u32 write_bytes; |
| 87 | u32 stmsper; |
| 88 | u32 stmspscr; |
| 89 | u32 numsp; |
| 90 | u32 stmheer; |
| 91 | u32 stmheter; |
| 92 | u32 stmhebsr; |
| 93 | }; |
| 94 | |
| 95 | #ifdef CONFIG_CORESIGHT_STM |
| 96 | extern int stm_trace(uint32_t flags, uint8_t entity_id, uint8_t proto_id, |
| 97 | const void *data, uint32_t size); |
| 98 | |
| 99 | void stm_send(void *addr, const void *data, u32 size, u8 write_bytes); |
| 100 | #else |
| 101 | static inline int stm_trace(uint32_t flags, uint8_t entity_id, |
| 102 | uint8_t proto_id, const void *data, uint32_t size) |
| 103 | { |
| 104 | return 0; |
| 105 | } |
| 106 | static inline void stm_send(void *addr, const void *data, u32 size, |
| 107 | u8 write_bytes) {} |
| 108 | #endif |
Pratik Patel | 237483a | 2016-05-03 11:33:40 -0600 | [diff] [blame] | 109 | #endif |