Skip to content

Commit 848f2bb

Browse files
ronakj89michalsimek
authored andcommitted
firmware: xilinx: Add missing debug firmware interfaces
Add missing PM EEMI APIs interface in debug firmware driver. The debugfs firmware driver interface is intended for testing and debugging the EEMI APIs only. This interface does not contain any checking regarding improper usage, and the number, type and valid ranges of the arguments. This interface must be used with a lot of care. In fact, accessing this interface during normal PM operation will very likely cause unexpected problems. The debugfs interface shouldn't be used in the production system and hence it is disabled by default in defconfig. Signed-off-by: Ronak Jain <[email protected]> Signed-off-by: Radhey Shyam Pandey <[email protected]> Signed-off-by: Michal Simek <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 44ed4f9 commit 848f2bb

File tree

2 files changed

+165
-1
lines changed

2 files changed

+165
-1
lines changed

drivers/firmware/xilinx/zynqmp-debug.c

Lines changed: 161 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,50 @@ static char debugfs_buf[PAGE_SIZE];
3131

3232
#define PM_API(id) {id, #id, strlen(#id)}
3333
static struct pm_api_info pm_api_list[] = {
34+
PM_API(PM_FORCE_POWERDOWN),
35+
PM_API(PM_REQUEST_WAKEUP),
36+
PM_API(PM_SYSTEM_SHUTDOWN),
37+
PM_API(PM_REQUEST_NODE),
38+
PM_API(PM_RELEASE_NODE),
39+
PM_API(PM_SET_REQUIREMENT),
3440
PM_API(PM_GET_API_VERSION),
41+
PM_API(PM_REGISTER_NOTIFIER),
42+
PM_API(PM_RESET_ASSERT),
43+
PM_API(PM_RESET_GET_STATUS),
44+
PM_API(PM_GET_CHIPID),
45+
PM_API(PM_PINCTRL_SET_FUNCTION),
46+
PM_API(PM_PINCTRL_CONFIG_PARAM_GET),
47+
PM_API(PM_PINCTRL_CONFIG_PARAM_SET),
48+
PM_API(PM_IOCTL),
49+
PM_API(PM_CLOCK_ENABLE),
50+
PM_API(PM_CLOCK_DISABLE),
51+
PM_API(PM_CLOCK_GETSTATE),
52+
PM_API(PM_CLOCK_SETDIVIDER),
53+
PM_API(PM_CLOCK_GETDIVIDER),
54+
PM_API(PM_CLOCK_SETPARENT),
55+
PM_API(PM_CLOCK_GETPARENT),
3556
PM_API(PM_QUERY_DATA),
3657
};
3758

3859
static struct dentry *firmware_debugfs_root;
3960

61+
/**
62+
* zynqmp_pm_ioctl - PM IOCTL for device control and configs
63+
* @node: Node ID of the device
64+
* @ioctl: ID of the requested IOCTL
65+
* @arg1: Argument 1 of requested IOCTL call
66+
* @arg2: Argument 2 of requested IOCTL call
67+
* @arg3: Argument 3 of requested IOCTL call
68+
* @out: Returned output value
69+
*
70+
* Return: Returns status, either success or error+reason
71+
*/
72+
static int zynqmp_pm_ioctl(const u32 node, const u32 ioctl, const u32 arg1,
73+
const u32 arg2, const u32 arg3, u32 *out)
74+
{
75+
return zynqmp_pm_invoke_fn(PM_IOCTL, out, 5, node, ioctl, arg1, arg2, arg3);
76+
}
77+
4078
/**
4179
* zynqmp_pm_argument_value() - Extract argument value from a PM-API request
4280
* @arg: Entered PM-API argument in string format
@@ -95,6 +133,128 @@ static int process_api_request(u32 pm_id, u64 *pm_api_arg, u32 *pm_api_ret)
95133
sprintf(debugfs_buf, "PM-API Version = %d.%d\n",
96134
pm_api_version >> 16, pm_api_version & 0xffff);
97135
break;
136+
case PM_FORCE_POWERDOWN:
137+
ret = zynqmp_pm_force_pwrdwn(pm_api_arg[0],
138+
pm_api_arg[1] ? pm_api_arg[1] :
139+
ZYNQMP_PM_REQUEST_ACK_NO);
140+
break;
141+
case PM_REQUEST_WAKEUP:
142+
ret = zynqmp_pm_request_wake(pm_api_arg[0],
143+
pm_api_arg[1], pm_api_arg[2],
144+
pm_api_arg[3] ? pm_api_arg[3] :
145+
ZYNQMP_PM_REQUEST_ACK_NO);
146+
break;
147+
case PM_SYSTEM_SHUTDOWN:
148+
ret = zynqmp_pm_system_shutdown(pm_api_arg[0], pm_api_arg[1]);
149+
break;
150+
case PM_REQUEST_NODE:
151+
ret = zynqmp_pm_request_node(pm_api_arg[0],
152+
pm_api_arg[1] ? pm_api_arg[1] :
153+
ZYNQMP_PM_CAPABILITY_ACCESS,
154+
pm_api_arg[2] ? pm_api_arg[2] : 0,
155+
pm_api_arg[3] ? pm_api_arg[3] :
156+
ZYNQMP_PM_REQUEST_ACK_BLOCKING);
157+
break;
158+
case PM_RELEASE_NODE:
159+
ret = zynqmp_pm_release_node(pm_api_arg[0]);
160+
break;
161+
case PM_SET_REQUIREMENT:
162+
ret = zynqmp_pm_set_requirement(pm_api_arg[0],
163+
pm_api_arg[1] ? pm_api_arg[1] :
164+
ZYNQMP_PM_CAPABILITY_CONTEXT,
165+
pm_api_arg[2] ?
166+
pm_api_arg[2] : 0,
167+
pm_api_arg[3] ? pm_api_arg[3] :
168+
ZYNQMP_PM_REQUEST_ACK_BLOCKING);
169+
break;
170+
case PM_REGISTER_NOTIFIER:
171+
ret = zynqmp_pm_register_notifier(pm_api_arg[0],
172+
pm_api_arg[1] ?
173+
pm_api_arg[1] : 0,
174+
pm_api_arg[2] ?
175+
pm_api_arg[2] : 0,
176+
pm_api_arg[3] ?
177+
pm_api_arg[3] : 0);
178+
break;
179+
case PM_RESET_ASSERT:
180+
ret = zynqmp_pm_reset_assert(pm_api_arg[0], pm_api_arg[1]);
181+
break;
182+
case PM_RESET_GET_STATUS:
183+
ret = zynqmp_pm_reset_get_status(pm_api_arg[0], &pm_api_ret[0]);
184+
if (!ret)
185+
sprintf(debugfs_buf, "Reset status: %u\n",
186+
pm_api_ret[0]);
187+
break;
188+
case PM_GET_CHIPID:
189+
ret = zynqmp_pm_get_chipid(&pm_api_ret[0], &pm_api_ret[1]);
190+
if (!ret)
191+
sprintf(debugfs_buf, "Idcode: %#x, Version:%#x\n",
192+
pm_api_ret[0], pm_api_ret[1]);
193+
break;
194+
case PM_PINCTRL_SET_FUNCTION:
195+
ret = zynqmp_pm_pinctrl_set_function(pm_api_arg[0],
196+
pm_api_arg[1]);
197+
break;
198+
case PM_PINCTRL_CONFIG_PARAM_GET:
199+
ret = zynqmp_pm_pinctrl_get_config(pm_api_arg[0], pm_api_arg[1],
200+
&pm_api_ret[0]);
201+
if (!ret)
202+
sprintf(debugfs_buf,
203+
"Pin: %llu, Param: %llu, Value: %u\n",
204+
pm_api_arg[0], pm_api_arg[1],
205+
pm_api_ret[0]);
206+
break;
207+
case PM_PINCTRL_CONFIG_PARAM_SET:
208+
ret = zynqmp_pm_pinctrl_set_config(pm_api_arg[0],
209+
pm_api_arg[1],
210+
pm_api_arg[2]);
211+
break;
212+
case PM_IOCTL:
213+
ret = zynqmp_pm_ioctl(pm_api_arg[0], pm_api_arg[1],
214+
pm_api_arg[2], pm_api_arg[3],
215+
pm_api_arg[4], &pm_api_ret[0]);
216+
if (!ret && (pm_api_arg[1] == IOCTL_GET_RPU_OPER_MODE ||
217+
pm_api_arg[1] == IOCTL_GET_PLL_FRAC_MODE ||
218+
pm_api_arg[1] == IOCTL_GET_PLL_FRAC_DATA ||
219+
pm_api_arg[1] == IOCTL_READ_GGS ||
220+
pm_api_arg[1] == IOCTL_READ_PGGS ||
221+
pm_api_arg[1] == IOCTL_READ_REG))
222+
sprintf(debugfs_buf, "IOCTL return value: %u\n",
223+
pm_api_ret[1]);
224+
if (!ret && pm_api_arg[1] == IOCTL_GET_QOS)
225+
sprintf(debugfs_buf, "Default QoS: %u\nCurrent QoS: %u\n",
226+
pm_api_ret[1], pm_api_ret[2]);
227+
break;
228+
case PM_CLOCK_ENABLE:
229+
ret = zynqmp_pm_clock_enable(pm_api_arg[0]);
230+
break;
231+
case PM_CLOCK_DISABLE:
232+
ret = zynqmp_pm_clock_disable(pm_api_arg[0]);
233+
break;
234+
case PM_CLOCK_GETSTATE:
235+
ret = zynqmp_pm_clock_getstate(pm_api_arg[0], &pm_api_ret[0]);
236+
if (!ret)
237+
sprintf(debugfs_buf, "Clock state: %u\n",
238+
pm_api_ret[0]);
239+
break;
240+
case PM_CLOCK_SETDIVIDER:
241+
ret = zynqmp_pm_clock_setdivider(pm_api_arg[0], pm_api_arg[1]);
242+
break;
243+
case PM_CLOCK_GETDIVIDER:
244+
ret = zynqmp_pm_clock_getdivider(pm_api_arg[0], &pm_api_ret[0]);
245+
if (!ret)
246+
sprintf(debugfs_buf, "Divider Value: %d\n",
247+
pm_api_ret[0]);
248+
break;
249+
case PM_CLOCK_SETPARENT:
250+
ret = zynqmp_pm_clock_setparent(pm_api_arg[0], pm_api_arg[1]);
251+
break;
252+
case PM_CLOCK_GETPARENT:
253+
ret = zynqmp_pm_clock_getparent(pm_api_arg[0], &pm_api_ret[0]);
254+
if (!ret)
255+
sprintf(debugfs_buf,
256+
"Clock parent Index: %u\n", pm_api_ret[0]);
257+
break;
98258
case PM_QUERY_DATA:
99259
qdata.qid = pm_api_arg[0];
100260
qdata.arg1 = pm_api_arg[1];
@@ -150,7 +310,7 @@ static ssize_t zynqmp_pm_debugfs_api_write(struct file *file,
150310
char *kern_buff, *tmp_buff;
151311
char *pm_api_req;
152312
u32 pm_id = 0;
153-
u64 pm_api_arg[4] = {0, 0, 0, 0};
313+
u64 pm_api_arg[5] = {0, 0, 0, 0, 0};
154314
/* Return values from PM APIs calls */
155315
u32 pm_api_ret[4] = {0, 0, 0, 0};
156316

include/linux/firmware/xlnx-zynqmp.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,13 @@ enum pm_ioctl_id {
218218
/* Runtime feature configuration */
219219
IOCTL_SET_FEATURE_CONFIG = 26,
220220
IOCTL_GET_FEATURE_CONFIG = 27,
221+
/* IOCTL for Secure Read/Write Interface */
222+
IOCTL_READ_REG = 28,
221223
/* Dynamic SD/GEM configuration */
222224
IOCTL_SET_SD_CONFIG = 30,
223225
IOCTL_SET_GEM_CONFIG = 31,
226+
/* IOCTL to get default/current QoS */
227+
IOCTL_GET_QOS = 34,
224228
};
225229

226230
enum pm_query_id {

0 commit comments

Comments
 (0)