• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  *
3  * Copyright(c) 2018 - 2019 Realtek Corporation. All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of version 2 of the GNU General Public License as
7  * published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12  * more details.
13  *
14  ******************************************************************************/
15 #include "halmac_dbg.h"
16 #if HALMAC_DBG_MONITOR_IO
17 static u8
18 monitor_reg_read_8(struct halmac_adapter *adapter, u32 offset,
19 		   const char *func, const u32 line);
20 static u16
21 monitor_reg_read_16(struct halmac_adapter *adapter, u32 offset,
22 		    const char *func, const u32 line);
23 static u32
24 monitor_reg_read_32(struct halmac_adapter *adapter, u32 offset,
25 		    const char *func, const u32 line);
26 static enum halmac_ret_status
27 monitor_reg_sdio_cmd53_read_n(struct halmac_adapter *adapter,
28 			      u32 offset, u32 size, u8 *value,
29 			      const char *func, const u32 line);
30 static enum halmac_ret_status
31 monitor_reg_write_8(struct halmac_adapter *adapter, u32 offset,
32 		    u8 value, const char *func, const u32 line);
33 static enum halmac_ret_status
34 monitor_reg_write_16(struct halmac_adapter *adapter, u32 offset,
35 		     u16 value, const char *func, const u32 line);
36 static enum halmac_ret_status
37 monitor_reg_write_32(struct halmac_adapter *adapter, u32 offset,
38 		     u32 value, const char *func, const u32 line);
39 
40 enum halmac_ret_status
mount_api_dbg(struct halmac_adapter * adapter)41 mount_api_dbg(struct halmac_adapter *adapter)
42 {
43 	struct halmac_api *api = (struct halmac_api *)adapter->halmac_api;
44 
45 	api->halmac_mon_reg_read_8 = monitor_reg_read_8;
46 	api->halmac_mon_reg_read_16 = monitor_reg_read_16;
47 	api->halmac_mon_reg_read_32 = monitor_reg_read_32;
48 	api->halmac_mon_reg_sdio_cmd53_read_n = monitor_reg_sdio_cmd53_read_n;
49 	api->halmac_mon_reg_write_8 = monitor_reg_write_8;
50 	api->halmac_mon_reg_write_16 = monitor_reg_write_16;
51 	api->halmac_mon_reg_write_32 = monitor_reg_write_32;
52 
53 	return HALMAC_RET_SUCCESS;
54 }
55 
56 u8
monitor_reg_read_8(struct halmac_adapter * adapter,u32 offset,const char * func,const u32 line)57 monitor_reg_read_8(struct halmac_adapter *adapter, u32 offset,
58 		   const char *func, const u32 line)
59 {
60 	struct halmac_api *api = (struct halmac_api *)adapter->halmac_api;
61 	u8 val;
62 
63 	val = api->halmac_reg_read_8(adapter, offset);
64 	PLTFM_MONITOR_READ(offset, 1, val, func, line);
65 	return val;
66 }
67 
68 u16
monitor_reg_read_16(struct halmac_adapter * adapter,u32 offset,const char * func,const u32 line)69 monitor_reg_read_16(struct halmac_adapter *adapter, u32 offset,
70 		    const char *func, const u32 line)
71 {
72 	struct halmac_api *api = (struct halmac_api *)adapter->halmac_api;
73 	u16 val;
74 
75 	val = api->halmac_reg_read_16(adapter, offset);
76 	PLTFM_MONITOR_READ(offset, 2, val, func, line);
77 	return val;
78 }
79 
80 u32
monitor_reg_read_32(struct halmac_adapter * adapter,u32 offset,const char * func,const u32 line)81 monitor_reg_read_32(struct halmac_adapter *adapter, u32 offset,
82 		    const char *func, const u32 line)
83 {
84 	struct halmac_api *api = (struct halmac_api *)adapter->halmac_api;
85 	u32 val;
86 
87 	val = api->halmac_reg_read_32(adapter, offset);
88 	PLTFM_MONITOR_READ(offset, 4, val, func, line);
89 	return val;
90 }
91 
92 enum halmac_ret_status
monitor_reg_sdio_cmd53_read_n(struct halmac_adapter * adapter,u32 offset,u32 size,u8 * value,const char * func,const u32 line)93 monitor_reg_sdio_cmd53_read_n(struct halmac_adapter *adapter,
94 			      u32 offset, u32 size, u8 *value,
95 			      const char *func, const u32 line)
96 {
97 	struct halmac_api *api = (struct halmac_api *)adapter->halmac_api;
98 
99 	PLTFM_MONITOR_READ(offset, size, 0, func, line);
100 	return api->halmac_reg_sdio_cmd53_read_n(adapter, offset, size, value);
101 }
102 
103 enum halmac_ret_status
monitor_reg_write_8(struct halmac_adapter * adapter,u32 offset,u8 value,const char * func,const u32 line)104 monitor_reg_write_8(struct halmac_adapter *adapter, u32 offset,
105 		    u8 value, const char *func, const u32 line)
106 {
107 	struct halmac_api *api = (struct halmac_api *)adapter->halmac_api;
108 
109 	PLTFM_MONITOR_WRITE(offset, 1, value, func, line);
110 	return api->halmac_reg_write_8(adapter, offset, value);
111 }
112 
113 enum halmac_ret_status
monitor_reg_write_16(struct halmac_adapter * adapter,u32 offset,u16 value,const char * func,const u32 line)114 monitor_reg_write_16(struct halmac_adapter *adapter, u32 offset,
115 		     u16 value, const char *func, const u32 line)
116 {
117 	struct halmac_api *api = (struct halmac_api *)adapter->halmac_api;
118 
119 	PLTFM_MONITOR_WRITE(offset, 2, value, func, line);
120 	return api->halmac_reg_write_16(adapter, offset, value);
121 }
122 
123 enum halmac_ret_status
monitor_reg_write_32(struct halmac_adapter * adapter,u32 offset,u32 value,const char * func,const u32 line)124 monitor_reg_write_32(struct halmac_adapter *adapter, u32 offset,
125 		     u32 value, const char *func, const u32 line)
126 {
127 	struct halmac_api *api = (struct halmac_api *)adapter->halmac_api;
128 
129 	PLTFM_MONITOR_WRITE(offset, 4, value, func, line);
130 	return api->halmac_reg_write_32(adapter, offset, value);
131 }
132 #endif
133