coresight-tpdm: Add node to set dsb programming mode
[linux-2.6-microblaze.git] / drivers / hwtracing / coresight / coresight-tpdm.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
4  */
5
6 #ifndef _CORESIGHT_CORESIGHT_TPDM_H
7 #define _CORESIGHT_CORESIGHT_TPDM_H
8
9 /* The max number of the datasets that TPDM supports */
10 #define TPDM_DATASETS       7
11
12 /* DSB Subunit Registers */
13 #define TPDM_DSB_CR             (0x780)
14 #define TPDM_DSB_TIER           (0x784)
15
16 /* Enable bit for DSB subunit */
17 #define TPDM_DSB_CR_ENA         BIT(0)
18 /* Enable bit for DSB subunit perfmance mode */
19 #define TPDM_DSB_CR_MODE                BIT(1)
20 /* Enable bit for DSB subunit trigger type */
21 #define TPDM_DSB_CR_TRIG_TYPE           BIT(12)
22 /* Data bits for DSB high performace mode */
23 #define TPDM_DSB_CR_HPSEL               GENMASK(6, 2)
24 /* Data bits for DSB test mode */
25 #define TPDM_DSB_CR_TEST_MODE           GENMASK(10, 9)
26
27 /* Enable bit for DSB subunit trigger timestamp */
28 #define TPDM_DSB_TIER_XTRIG_TSENAB              BIT(1)
29
30 /* DSB programming modes */
31 /* DSB mode bits mask */
32 #define TPDM_DSB_MODE_MASK                      GENMASK(8, 0)
33 /* Test mode control bit*/
34 #define TPDM_DSB_MODE_TEST(val) (val & GENMASK(1, 0))
35 /* Performance mode */
36 #define TPDM_DSB_MODE_PERF              BIT(3)
37 /* High performance mode */
38 #define TPDM_DSB_MODE_HPBYTESEL(val)    (val & GENMASK(8, 4))
39
40 /* TPDM integration test registers */
41 #define TPDM_ITATBCNTRL         (0xEF0)
42 #define TPDM_ITCNTRL            (0xF00)
43
44 /* Register value for integration test */
45 #define ATBCNTRL_VAL_32         0xC00F1409
46 #define ATBCNTRL_VAL_64         0xC01F1409
47
48 /*
49  * Number of cycles to write value when
50  * integration test.
51  */
52 #define INTEGRATION_TEST_CYCLE  10
53
54 /**
55  * The bits of PERIPHIDR0 register.
56  * The fields [6:0] of PERIPHIDR0 are used to determine what
57  * interfaces and subunits are present on a given TPDM.
58  *
59  * PERIPHIDR0[0] : Fix to 1 if ImplDef subunit present, else 0
60  * PERIPHIDR0[1] : Fix to 1 if DSB subunit present, else 0
61  */
62
63 #define TPDM_PIDR0_DS_IMPDEF    BIT(0)
64 #define TPDM_PIDR0_DS_DSB       BIT(1)
65
66 /**
67  * struct dsb_dataset - specifics associated to dsb dataset
68  * @mode:             DSB programming mode
69  * @trig_ts:          Enable/Disable trigger timestamp.
70  * @trig_type:        Enable/Disable trigger type.
71  */
72 struct dsb_dataset {
73         u32                     mode;
74         bool                    trig_ts;
75         bool                    trig_type;
76 };
77
78 /**
79  * struct tpdm_drvdata - specifics associated to an TPDM component
80  * @base:       memory mapped base address for this component.
81  * @dev:        The device entity associated to this component.
82  * @csdev:      component vitals needed by the framework.
83  * @spinlock:   lock for the drvdata value.
84  * @enable:     enable status of the component.
85  * @datasets:   The datasets types present of the TPDM.
86  * @dsb         Specifics associated to TPDM DSB.
87  */
88
89 struct tpdm_drvdata {
90         void __iomem            *base;
91         struct device           *dev;
92         struct coresight_device *csdev;
93         spinlock_t              spinlock;
94         bool                    enable;
95         unsigned long           datasets;
96         struct dsb_dataset      *dsb;
97 };
98
99 #endif  /* _CORESIGHT_CORESIGHT_TPDM_H */