Alexander Shishkin | 50352fa | 2018-03-28 18:46:15 +0300 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Alexander Shishkin | ba82664 | 2015-09-22 15:47:18 +0300 | [diff] [blame] | 2 | /* |
| 3 | * Intel(R) Trace Hub Memory Storage Unit (MSU) data structures |
| 4 | * |
| 5 | * Copyright (C) 2014-2015 Intel Corporation. |
Alexander Shishkin | ba82664 | 2015-09-22 15:47:18 +0300 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #ifndef __INTEL_TH_MSU_H__ |
| 9 | #define __INTEL_TH_MSU_H__ |
| 10 | |
| 11 | enum { |
| 12 | REG_MSU_MSUPARAMS = 0x0000, |
| 13 | REG_MSU_MSUSTS = 0x0008, |
| 14 | REG_MSU_MSC0CTL = 0x0100, /* MSC0 control */ |
| 15 | REG_MSU_MSC0STS = 0x0104, /* MSC0 status */ |
| 16 | REG_MSU_MSC0BAR = 0x0108, /* MSC0 output base address */ |
| 17 | REG_MSU_MSC0SIZE = 0x010c, /* MSC0 output size */ |
| 18 | REG_MSU_MSC0MWP = 0x0110, /* MSC0 write pointer */ |
| 19 | REG_MSU_MSC0NWSA = 0x011c, /* MSC0 next window start address */ |
| 20 | |
| 21 | REG_MSU_MSC1CTL = 0x0200, /* MSC1 control */ |
| 22 | REG_MSU_MSC1STS = 0x0204, /* MSC1 status */ |
| 23 | REG_MSU_MSC1BAR = 0x0208, /* MSC1 output base address */ |
| 24 | REG_MSU_MSC1SIZE = 0x020c, /* MSC1 output size */ |
| 25 | REG_MSU_MSC1MWP = 0x0210, /* MSC1 write pointer */ |
| 26 | REG_MSU_MSC1NWSA = 0x021c, /* MSC1 next window start address */ |
| 27 | }; |
| 28 | |
| 29 | /* MSUSTS bits */ |
| 30 | #define MSUSTS_MSU_INT BIT(0) |
| 31 | |
| 32 | /* MSCnCTL bits */ |
| 33 | #define MSC_EN BIT(0) |
| 34 | #define MSC_WRAPEN BIT(1) |
| 35 | #define MSC_RD_HDR_OVRD BIT(2) |
| 36 | #define MSC_MODE (BIT(4) | BIT(5)) |
| 37 | #define MSC_LEN (BIT(8) | BIT(9) | BIT(10)) |
| 38 | |
| 39 | /* MSC operating modes (MSC_MODE) */ |
| 40 | enum { |
| 41 | MSC_MODE_SINGLE = 0, |
| 42 | MSC_MODE_MULTI, |
| 43 | MSC_MODE_EXI, |
| 44 | MSC_MODE_DEBUG, |
| 45 | }; |
| 46 | |
| 47 | /* MSCnSTS bits */ |
| 48 | #define MSCSTS_WRAPSTAT BIT(1) /* Wrap occurred */ |
| 49 | #define MSCSTS_PLE BIT(2) /* Pipeline Empty */ |
| 50 | |
| 51 | /* |
| 52 | * Multiblock/multiwindow block descriptor |
| 53 | */ |
| 54 | struct msc_block_desc { |
| 55 | u32 sw_tag; |
| 56 | u32 block_sz; |
| 57 | u32 next_blk; |
| 58 | u32 next_win; |
| 59 | u32 res0[4]; |
| 60 | u32 hw_tag; |
| 61 | u32 valid_dw; |
| 62 | u32 ts_low; |
| 63 | u32 ts_high; |
| 64 | u32 res1[4]; |
| 65 | } __packed; |
| 66 | |
| 67 | #define MSC_BDESC sizeof(struct msc_block_desc) |
| 68 | #define DATA_IN_PAGE (PAGE_SIZE - MSC_BDESC) |
| 69 | |
| 70 | /* MSC multiblock sw tag bits */ |
| 71 | #define MSC_SW_TAG_LASTBLK BIT(0) |
| 72 | #define MSC_SW_TAG_LASTWIN BIT(1) |
| 73 | |
| 74 | /* MSC multiblock hw tag bits */ |
| 75 | #define MSC_HW_TAG_TRIGGER BIT(0) |
| 76 | #define MSC_HW_TAG_BLOCKWRAP BIT(1) |
| 77 | #define MSC_HW_TAG_WINWRAP BIT(2) |
| 78 | #define MSC_HW_TAG_ENDBIT BIT(3) |
| 79 | |
| 80 | static inline unsigned long msc_data_sz(struct msc_block_desc *bdesc) |
| 81 | { |
| 82 | if (!bdesc->valid_dw) |
| 83 | return 0; |
| 84 | |
| 85 | return bdesc->valid_dw * 4 - MSC_BDESC; |
| 86 | } |
| 87 | |
| 88 | static inline bool msc_block_wrapped(struct msc_block_desc *bdesc) |
| 89 | { |
| 90 | if (bdesc->hw_tag & MSC_HW_TAG_BLOCKWRAP) |
| 91 | return true; |
| 92 | |
| 93 | return false; |
| 94 | } |
| 95 | |
| 96 | static inline bool msc_block_last_written(struct msc_block_desc *bdesc) |
| 97 | { |
| 98 | if ((bdesc->hw_tag & MSC_HW_TAG_ENDBIT) || |
| 99 | (msc_data_sz(bdesc) != DATA_IN_PAGE)) |
| 100 | return true; |
| 101 | |
| 102 | return false; |
| 103 | } |
| 104 | |
| 105 | /* waiting for Pipeline Empty bit(s) to assert for MSC */ |
| 106 | #define MSC_PLE_WAITLOOP_DEPTH 10000 |
| 107 | |
| 108 | #endif /* __INTEL_TH_MSU_H__ */ |