hc
2024-10-22 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
/*
 *
 * (C) COPYRIGHT 2022 ARM Limited. All rights reserved.
 *
 * This program is free software and is provided to you under the terms of the
 * GNU General Public License version 2 as published by the Free Software
 * Foundation, and any use by you of this program is subject to the terms
 * of such GNU license.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, you can access it online at
 * http://www.gnu.org/licenses/gpl-2.0.html.
 *
 */
 
#ifndef _CORESIGHT_MALI_COMMON_H
#define _CORESIGHT_MALI_COMMON_H
 
#include <linux/types.h>
#include <linux/mali_kbase_debug_coresight_csf.h>
 
/* Macros for CoreSight OP types. */
#define WRITE_IMM_OP(_reg_addr, _val)                                                              \
   {                                                                                          \
       .type = KBASE_DEBUG_CORESIGHT_CSF_OP_TYPE_WRITE_IMM,                               \
       .op.write_imm.reg_addr = _reg_addr, .op.write_imm.val = _val                       \
   }
 
#define WRITE_RANGE_OP(_reg_start, _reg_end, _val)                                                 \
   {                                                                                          \
       .type = KBASE_DEBUG_CORESIGHT_CSF_OP_TYPE_WRITE_IMM_RANGE,                         \
       .op.write_imm_range.reg_start = _reg_start,                                        \
       .op.write_imm_range.reg_end = _reg_end, .op.write_imm_range.val = _val             \
   }
 
#define WRITE_PTR_OP(_reg_addr, _ptr)                                                              \
   {                                                                                          \
       .type = KBASE_DEBUG_CORESIGHT_CSF_OP_TYPE_WRITE, .op.write.reg_addr = _reg_addr,   \
       .op.write.ptr = _ptr                                                               \
   }
 
#define READ_OP(_reg_addr, _ptr)                                                                   \
   {                                                                                          \
       .type = KBASE_DEBUG_CORESIGHT_CSF_OP_TYPE_READ, .op.read.reg_addr = _reg_addr,     \
       .op.read.ptr = _ptr                                                                \
   }
 
#define POLL_OP(_reg_addr, _mask, _val)                                                            \
   {                                                                                          \
       .type = KBASE_DEBUG_CORESIGHT_CSF_OP_TYPE_POLL, .op.poll.reg_addr = _reg_addr,     \
       .op.poll.mask = _mask, .op.poll.val = _val                                         \
   }
 
#define BIT_OR_OP(_ptr, _val)                                                                      \
   {                                                                                          \
       .type = KBASE_DEBUG_CORESIGHT_CSF_OP_TYPE_BIT_OR, .op.bitw.ptr = _ptr,             \
       .op.bitw.val = _val                                                                \
   }
 
#define BIT_XOR_OP(_ptr, _val)                                                                     \
   {                                                                                          \
       .type = KBASE_DEBUG_CORESIGHT_CSF_OP_TYPE_BIT_XOR, .op.bitw.ptr = _ptr,            \
       .op.bitw.val = _val                                                                \
   }
 
#define BIT_AND_OP(_ptr, _val)                                                                     \
   {                                                                                          \
       .type = KBASE_DEBUG_CORESIGHT_CSF_OP_TYPE_BIT_AND, .op.bitw.ptr = _ptr,            \
       .op.bitw.val = _val                                                                \
   }
 
#define BIT_NOT_OP(_ptr)                                                                           \
   {                                                                                          \
       .type = KBASE_DEBUG_CORESIGHT_CSF_OP_TYPE_BIT_NOT, .op.bitw.ptr = _ptr,            \
   }
 
#ifndef CS_MALI_UNLOCK_COMPONENT
/**
 * CS_MALI_UNLOCK_COMPONENT - A write of 0xC5ACCE55 enables write access to the block
 */
#define CS_MALI_UNLOCK_COMPONENT 0xC5ACCE55
#endif
 
/**
 * struct coresight_mali_drvdata - Coresight mali driver data
 *
 * @csdev:        Coresight device pointer
 * @dev:          Device pointer
 * @kbase_client: Pointer to coresight mali client
 * @config:       Pointer to coresight mali config, used for enabling and
 *                disabling the coresight component
 * @enable_seq:   Enable sequence needed to enable coresight block
 * @disable_seq:  Disable sequence needed to enable coresight block
 * @gpu_dev:      Pointer to gpu device structure
 * @mode:         Mode in which the driver operates
 */
struct coresight_mali_drvdata {
   struct coresight_device *csdev;
   struct device *dev;
   void *kbase_client;
   void *config;
   struct kbase_debug_coresight_csf_sequence enable_seq;
   struct kbase_debug_coresight_csf_sequence disable_seq;
   void *gpu_dev;
   u32 mode;
};
 
/**
 * coresight_mali_enable_component - Generic enable for a coresight block
 *
 * @csdev:  Coresight device to be enabled
 * @mode: Mode in which the block should start operating in
 *
 * Return: 0 if success. Error code on failure.
 */
int coresight_mali_enable_component(struct coresight_device *csdev, u32 mode);
 
/**
 * coresight_mali_disable_component - Generic disable for a coresight block
 *
 * @csdev:  Coresight device to be disabled
 *
 * Return: 0 if success. Error code on failure.
 */
int coresight_mali_disable_component(struct coresight_device *csdev);
 
#endif /* _CORESIGHT_MALI_COMMON_H */