1 /*
2 * Copyright (c) 2019-2022, Xilinx, Inc. All rights reserved.
3 * Copyright (c) 2022, Advanced Micro Devices, Inc. All rights reserved.
4 *
5 * SPDX-License-Identifier: BSD-3-Clause
6 */
7
8 /*
9 * Versal system level PM-API functions and communication with PMC via
10 * IPI interrupts
11 */
12
13 #include <pm_common.h>
14 #include <pm_ipi.h>
15 #include <plat/common/platform.h>
16 #include "pm_api_sys.h"
17 #include "pm_client.h"
18 #include "pm_defs.h"
19 #include "pm_svc_main.h"
20
21 /* default shutdown/reboot scope is system(2) */
22 static uint32_t pm_shutdown_scope = XPM_SHUTDOWN_SUBTYPE_RST_SYSTEM;
23
24 /**
25 * pm_get_shutdown_scope() - Get the currently set shutdown scope
26 *
27 * @return Shutdown scope value
28 */
pm_get_shutdown_scope(void)29 uint32_t pm_get_shutdown_scope(void)
30 {
31 return pm_shutdown_scope;
32 }
33
34 /* PM API functions */
35
36 /**
37 * pm_handle_eemi_call() - PM call for processor to send eemi payload
38 * @flag 0 - Call from secure source
39 * 1 - Call from non-secure source
40 * @x0 to x5 Arguments received per SMC64 standard
41 * @result Payload received from firmware
42 *
43 * @return PM_RET_SUCCESS on success or error code
44 */
pm_handle_eemi_call(uint32_t flag,uint32_t x0,uint32_t x1,uint32_t x2,uint32_t x3,uint32_t x4,uint32_t x5,uint64_t * result)45 enum pm_ret_status pm_handle_eemi_call(uint32_t flag, uint32_t x0, uint32_t x1,
46 uint32_t x2, uint32_t x3, uint32_t x4,
47 uint32_t x5, uint64_t *result)
48 {
49 uint32_t payload[PAYLOAD_ARG_CNT] = {0};
50 uint32_t module_id;
51
52 module_id = (x0 & MODULE_ID_MASK) >> 8U;
53
54 //default module id is for LIBPM
55 if (module_id == 0) {
56 module_id = LIBPM_MODULE_ID;
57 }
58
59 PM_PACK_PAYLOAD6(payload, module_id, flag, x0, x1, x2, x3, x4, x5);
60 return pm_ipi_send_sync(primary_proc, payload, (uint32_t *)result, PAYLOAD_ARG_CNT);
61 }
62
63 /**
64 * pm_self_suspend() - PM call for processor to suspend itself
65 * @nid Node id of the processor or subsystem
66 * @latency Requested maximum wakeup latency (not supported)
67 * @state Requested state
68 * @address Resume address
69 * @flag 0 - Call from secure source
70 * 1 - Call from non-secure source
71 *
72 * This is a blocking call, it will return only once PMU has responded.
73 * On a wakeup, resume address will be automatically set by PMU.
74 *
75 * @return Returns status, either success or error+reason
76 */
pm_self_suspend(uint32_t nid,uint32_t latency,uint32_t state,uintptr_t address,uint32_t flag)77 enum pm_ret_status pm_self_suspend(uint32_t nid,
78 uint32_t latency,
79 uint32_t state,
80 uintptr_t address, uint32_t flag)
81 {
82 uint32_t payload[PAYLOAD_ARG_CNT];
83 uint32_t cpuid = plat_my_core_pos();
84 const struct pm_proc *proc = pm_get_proc(cpuid);
85
86 if (proc == NULL) {
87 WARN("Failed to get proc %d\n", cpuid);
88 return PM_RET_ERROR_INTERNAL;
89 }
90
91 /*
92 * Do client specific suspend operations
93 * (e.g. set powerdown request bit)
94 */
95 pm_client_suspend(proc, state);
96
97 /* Send request to the PLM */
98 PM_PACK_PAYLOAD6(payload, LIBPM_MODULE_ID, flag, PM_SELF_SUSPEND,
99 proc->node_id, latency, state, address,
100 (address >> 32));
101 return pm_ipi_send_sync(proc, payload, NULL, 0);
102 }
103
104 /**
105 * pm_abort_suspend() - PM call to announce that a prior suspend request
106 * is to be aborted.
107 * @reason Reason for the abort
108 * @flag 0 - Call from secure source
109 * 1 - Call from non-secure source
110 *
111 * Calling PU expects the PMU to abort the initiated suspend procedure.
112 * This is a non-blocking call without any acknowledge.
113 *
114 * @return Returns status, either success or error+reason
115 */
pm_abort_suspend(enum pm_abort_reason reason,uint32_t flag)116 enum pm_ret_status pm_abort_suspend(enum pm_abort_reason reason, uint32_t flag)
117 {
118 uint32_t payload[PAYLOAD_ARG_CNT];
119
120 /*
121 * Do client specific abort suspend operations
122 * (e.g. enable interrupts and clear powerdown request bit)
123 */
124 pm_client_abort_suspend();
125
126 /* Send request to the PLM */
127 PM_PACK_PAYLOAD3(payload, LIBPM_MODULE_ID, flag, PM_ABORT_SUSPEND,
128 reason, primary_proc->node_id);
129 return pm_ipi_send_sync(primary_proc, payload, NULL, 0);
130 }
131
132 /**
133 * pm_req_suspend() - PM call to request for another PU or subsystem to
134 * be suspended gracefully.
135 * @target Node id of the targeted PU or subsystem
136 * @ack Flag to specify whether acknowledge is requested
137 * @latency Requested wakeup latency (not supported)
138 * @state Requested state (not supported)
139 * @flag 0 - Call from secure source
140 * 1 - Call from non-secure source
141 *
142 * @return Returns status, either success or error+reason
143 */
pm_req_suspend(uint32_t target,uint8_t ack,uint32_t latency,uint32_t state,uint32_t flag)144 enum pm_ret_status pm_req_suspend(uint32_t target, uint8_t ack,
145 uint32_t latency, uint32_t state,
146 uint32_t flag)
147 {
148 uint32_t payload[PAYLOAD_ARG_CNT];
149
150 /* Send request to the PMU */
151 PM_PACK_PAYLOAD4(payload, LIBPM_MODULE_ID, flag, PM_REQ_SUSPEND, target,
152 latency, state);
153 if (ack == IPI_BLOCKING) {
154 return pm_ipi_send_sync(primary_proc, payload, NULL, 0);
155 } else {
156 return pm_ipi_send(primary_proc, payload);
157 }
158 }
159
160 /**
161 * pm_req_wakeup() - PM call for processor to wake up selected processor
162 * or subsystem
163 * @target Device ID of the processor or subsystem to wake up
164 * @set_address Resume address presence indicator
165 * 1 - resume address specified, 0 - otherwise
166 * @address Resume address
167 * @ack Flag to specify whether acknowledge requested
168 * @flag 0 - Call from secure source
169 * 1 - Call from non-secure source
170 *
171 * This API function is either used to power up another APU core for SMP
172 * (by PSCI) or to power up an entirely different PU or subsystem, such
173 * as RPU0, RPU, or PL_CORE_xx. Resume address for the target PU will be
174 * automatically set by PMC.
175 *
176 * @return Returns status, either success or error+reason
177 */
pm_req_wakeup(uint32_t target,uint32_t set_address,uintptr_t address,uint8_t ack,uint32_t flag)178 enum pm_ret_status pm_req_wakeup(uint32_t target, uint32_t set_address,
179 uintptr_t address, uint8_t ack, uint32_t flag)
180 {
181 uint32_t payload[PAYLOAD_ARG_CNT];
182
183 /* Send request to the PMC to perform the wake of the PU */
184 PM_PACK_PAYLOAD5(payload, LIBPM_MODULE_ID, flag, PM_REQ_WAKEUP, target,
185 set_address, address, ack);
186
187 return pm_ipi_send_sync(primary_proc, payload, NULL, 0);
188 }
189
190 /**
191 * pm_get_callbackdata() - Read from IPI response buffer
192 * @data - array of PAYLOAD_ARG_CNT elements
193 * @flag - 0 - Call from secure source
194 * 1 - Call from non-secure source
195 * @ack - 0 - Do not ack IPI after reading payload
196 * 1 - Ack IPI after reading payload
197 *
198 * Read value from ipi buffer response buffer.
199 */
pm_get_callbackdata(uint32_t * data,size_t count,uint32_t flag,uint32_t ack)200 void pm_get_callbackdata(uint32_t *data, size_t count, uint32_t flag, uint32_t ack)
201 {
202 /* Return if interrupt is not from PMU */
203 if (pm_ipi_irq_status(primary_proc) == 0) {
204 return;
205 }
206
207 pm_ipi_buff_read_callb(data, count);
208
209 if (ack != 0U) {
210 pm_ipi_irq_clear(primary_proc);
211 }
212 }
213
214 /**
215 * pm_pll_set_param() - Set PLL parameter
216 *
217 * This API is deprecated and maintained here for backward compatibility.
218 * New use of this API should be avoided for versal platform.
219 * This API and its use cases will be removed for versal platform.
220 *
221 * @clk_id PLL clock ID
222 * @param PLL parameter ID
223 * @value Value to set for PLL parameter
224 * @flag 0 - Call from secure source
225 * 1 - Call from non-secure source
226 *
227 * @return Returns status, either success or error+reason
228 */
pm_pll_set_param(uint32_t clk_id,uint32_t param,uint32_t value,uint32_t flag)229 enum pm_ret_status pm_pll_set_param(uint32_t clk_id, uint32_t param,
230 uint32_t value, uint32_t flag)
231 {
232 uint32_t payload[PAYLOAD_ARG_CNT];
233
234 /* Send request to the PMC */
235 PM_PACK_PAYLOAD4(payload, LIBPM_MODULE_ID, flag, PM_PLL_SET_PARAMETER,
236 clk_id, param, value);
237
238 return pm_ipi_send_sync(primary_proc, payload, NULL, 0);
239 }
240
241 /**
242 * pm_pll_get_param() - Get PLL parameter value
243 *
244 * This API is deprecated and maintained here for backward compatibility.
245 * New use of this API should be avoided for versal platform.
246 * This API and its use cases will be removed for versal platform.
247 *
248 * @clk_id PLL clock ID
249 * @param PLL parameter ID
250 * @value: Buffer to store PLL parameter value
251 * @flag 0 - Call from secure source
252 * 1 - Call from non-secure source
253 *
254 * @return Returns status, either success or error+reason
255 */
pm_pll_get_param(uint32_t clk_id,uint32_t param,uint32_t * value,uint32_t flag)256 enum pm_ret_status pm_pll_get_param(uint32_t clk_id, uint32_t param,
257 uint32_t *value, uint32_t flag)
258 {
259 uint32_t payload[PAYLOAD_ARG_CNT];
260
261 /* Send request to the PMC */
262 PM_PACK_PAYLOAD3(payload, LIBPM_MODULE_ID, flag, PM_PLL_GET_PARAMETER,
263 clk_id, param);
264
265 return pm_ipi_send_sync(primary_proc, payload, value, 1);
266 }
267
268 /**
269 * pm_pll_set_mode() - Set PLL mode
270 *
271 * This API is deprecated and maintained here for backward compatibility.
272 * New use of this API should be avoided for versal platform.
273 * This API and its use cases will be removed for versal platform.
274 *
275 * @clk_id PLL clock ID
276 * @mode PLL mode
277 * @flag 0 - Call from secure source
278 * 1 - Call from non-secure source
279 *
280 * @return Returns status, either success or error+reason
281 */
pm_pll_set_mode(uint32_t clk_id,uint32_t mode,uint32_t flag)282 enum pm_ret_status pm_pll_set_mode(uint32_t clk_id, uint32_t mode,
283 uint32_t flag)
284 {
285 uint32_t payload[PAYLOAD_ARG_CNT];
286
287 /* Send request to the PMC */
288 PM_PACK_PAYLOAD3(payload, LIBPM_MODULE_ID, flag, PM_PLL_SET_MODE,
289 clk_id, mode);
290
291 return pm_ipi_send_sync(primary_proc, payload, NULL, 0);
292 }
293
294 /**
295 * pm_pll_get_mode() - Get PLL mode
296 *
297 * This API is deprecated and maintained here for backward compatibility.
298 * New use of this API should be avoided for versal platform.
299 * This API and its use cases will be removed for versal platform.
300 *
301 * @clk_id PLL clock ID
302 * @mode: Buffer to store PLL mode
303 * @flag 0 - Call from secure source
304 * 1 - Call from non-secure source
305 *
306 * @return Returns status, either success or error+reason
307 */
pm_pll_get_mode(uint32_t clk_id,uint32_t * mode,uint32_t flag)308 enum pm_ret_status pm_pll_get_mode(uint32_t clk_id, uint32_t *mode,
309 uint32_t flag)
310 {
311 uint32_t payload[PAYLOAD_ARG_CNT];
312
313 /* Send request to the PMC */
314 PM_PACK_PAYLOAD2(payload, LIBPM_MODULE_ID, flag, PM_PLL_GET_MODE,
315 clk_id);
316
317 return pm_ipi_send_sync(primary_proc, payload, mode, 1);
318 }
319
320 /**
321 * pm_force_powerdown() - PM call to request for another PU or subsystem to
322 * be powered down forcefully
323 * @target Device ID of the PU node to be forced powered down.
324 * @ack Flag to specify whether acknowledge is requested
325 * @flag 0 - Call from secure source
326 * 1 - Call from non-secure source
327 *
328 * @return Returns status, either success or error+reason
329 */
pm_force_powerdown(uint32_t target,uint8_t ack,uint32_t flag)330 enum pm_ret_status pm_force_powerdown(uint32_t target, uint8_t ack,
331 uint32_t flag)
332 {
333 uint32_t payload[PAYLOAD_ARG_CNT];
334
335 /* Send request to the PMC */
336 PM_PACK_PAYLOAD3(payload, LIBPM_MODULE_ID, flag, PM_FORCE_POWERDOWN,
337 target, ack);
338
339 if (ack == IPI_BLOCKING) {
340 return pm_ipi_send_sync(primary_proc, payload, NULL, 0);
341 } else {
342 return pm_ipi_send(primary_proc, payload);
343 }
344 }
345
346 /**
347 * pm_system_shutdown() - PM call to request a system shutdown or restart
348 * @type Shutdown or restart? 0=shutdown, 1=restart, 2=setscope
349 * @subtype Scope: 0=APU-subsystem, 1=PS, 2=system
350 * @flag 0 - Call from secure source
351 * 1 - Call from non-secure source
352 *
353 * @return Returns status, either success or error+reason
354 */
pm_system_shutdown(uint32_t type,uint32_t subtype,uint32_t flag)355 enum pm_ret_status pm_system_shutdown(uint32_t type, uint32_t subtype,
356 uint32_t flag)
357 {
358 uint32_t payload[PAYLOAD_ARG_CNT];
359
360 if (type == XPM_SHUTDOWN_TYPE_SETSCOPE_ONLY) {
361 /* Setting scope for subsequent PSCI reboot or shutdown */
362 pm_shutdown_scope = subtype;
363 return PM_RET_SUCCESS;
364 }
365
366 /* Send request to the PMC */
367 PM_PACK_PAYLOAD3(payload, LIBPM_MODULE_ID, flag, PM_SYSTEM_SHUTDOWN,
368 type, subtype);
369
370 return pm_ipi_send_non_blocking(primary_proc, payload);
371 }
372
373 /**
374 * pm_query_data() - PM API for querying firmware data
375 *
376 * This API is deprecated and maintained here for backward compatibility.
377 * New use of this API should be avoided for versal platform.
378 * This API and its use cases will be removed for versal platform.
379 *
380 * @qid The type of data to query
381 * @arg1 Argument 1 to requested query data call
382 * @arg2 Argument 2 to requested query data call
383 * @arg3 Argument 3 to requested query data call
384 * @data Returned output data
385 * @flag 0 - Call from secure source
386 * 1 - Call from non-secure source
387 *
388 * @retur - 0 if success else non-zero error code of type
389 * enum pm_ret_status
390 */
pm_query_data(uint32_t qid,uint32_t arg1,uint32_t arg2,uint32_t arg3,uint32_t * data,uint32_t flag)391 enum pm_ret_status pm_query_data(uint32_t qid, uint32_t arg1, uint32_t arg2,
392 uint32_t arg3, uint32_t *data, uint32_t flag)
393 {
394 uint32_t ret;
395 uint32_t version[PAYLOAD_ARG_CNT] = {0};
396 uint32_t payload[PAYLOAD_ARG_CNT];
397 uint32_t fw_api_version;
398
399 /* Send request to the PMC */
400 PM_PACK_PAYLOAD5(payload, LIBPM_MODULE_ID, flag, PM_QUERY_DATA, qid,
401 arg1, arg2, arg3);
402
403 ret = pm_feature_check(PM_QUERY_DATA, &version[0], flag);
404 if (ret == PM_RET_SUCCESS) {
405 fw_api_version = version[0] & 0xFFFFU;
406 if ((fw_api_version == 2U) &&
407 ((qid == XPM_QID_CLOCK_GET_NAME) ||
408 (qid == XPM_QID_PINCTRL_GET_FUNCTION_NAME))) {
409 ret = pm_ipi_send_sync(primary_proc, payload, data, PAYLOAD_ARG_CNT);
410 if (ret == PM_RET_SUCCESS) {
411 ret = data[0];
412 data[0] = data[1];
413 data[1] = data[2];
414 data[2] = data[3];
415 }
416 } else {
417 ret = pm_ipi_send_sync(primary_proc, payload, data, PAYLOAD_ARG_CNT);
418 }
419 }
420 return ret;
421 }
422 /**
423 * pm_api_ioctl() - PM IOCTL API for device control and configs
424 *
425 * This API is deprecated and maintained here for backward compatibility.
426 * New use of this API should be avoided for versal platform.
427 * This API and its use cases will be removed for versal platform.
428 *
429 * @device_id Device ID
430 * @ioctl_id ID of the requested IOCTL
431 * @arg1 Argument 1 to requested IOCTL call
432 * @arg2 Argument 2 to requested IOCTL call
433 * @arg3 Argument 3 to requested IOCTL call
434 * @value Returned output value
435 * @flag 0 - Call from secure source
436 * 1 - Call from non-secure source
437 *
438 * This function calls IOCTL to firmware for device control and configuration.
439 *
440 * @return Returns status, either 0 on success or non-zero error code
441 * of type enum pm_ret_status
442 */
pm_api_ioctl(uint32_t device_id,uint32_t ioctl_id,uint32_t arg1,uint32_t arg2,uint32_t arg3,uint32_t * value,uint32_t flag)443 enum pm_ret_status pm_api_ioctl(uint32_t device_id, uint32_t ioctl_id,
444 uint32_t arg1, uint32_t arg2, uint32_t arg3,
445 uint32_t *value, uint32_t flag)
446 {
447 enum pm_ret_status ret;
448
449 switch (ioctl_id) {
450 case IOCTL_SET_PLL_FRAC_MODE:
451 ret = pm_pll_set_mode(arg1, arg2, flag);
452 break;
453 case IOCTL_GET_PLL_FRAC_MODE:
454 ret = pm_pll_get_mode(arg1, value, flag);
455 break;
456 case IOCTL_SET_PLL_FRAC_DATA:
457 ret = pm_pll_set_param(arg1, PM_PLL_PARAM_DATA, arg2, flag);
458 break;
459 case IOCTL_GET_PLL_FRAC_DATA:
460 ret = pm_pll_get_param(arg1, PM_PLL_PARAM_DATA, value, flag);
461 break;
462 case IOCTL_SET_SGI:
463 /* Get the sgi number */
464 ret = pm_register_sgi(arg1, arg2);
465 if (ret != 0) {
466 return PM_RET_ERROR_ARGS;
467 }
468 ret = PM_RET_SUCCESS;
469 break;
470 default:
471 return PM_RET_ERROR_NOTSUPPORTED;
472 }
473
474 return ret;
475 }
476
477 /**
478 * pm_set_wakeup_source() - PM call to specify the wakeup source while suspended
479 * @target Device id of the targeted PU or subsystem
480 * @wkup_node Device id of the wakeup peripheral
481 * @enable Enable or disable the specified peripheral as wake source
482 * @flag 0 - Call from secure source
483 * 1 - Call from non-secure source
484 *
485 * @return Returns status, either success or error+reason
486 */
pm_set_wakeup_source(uint32_t target,uint32_t wkup_device,uint8_t enable,uint32_t flag)487 enum pm_ret_status pm_set_wakeup_source(uint32_t target, uint32_t wkup_device,
488 uint8_t enable, uint32_t flag)
489 {
490 uint32_t payload[PAYLOAD_ARG_CNT];
491
492 PM_PACK_PAYLOAD4(payload, LIBPM_MODULE_ID, flag, PM_SET_WAKEUP_SOURCE,
493 target, wkup_device, enable);
494 return pm_ipi_send_sync(primary_proc, payload, NULL, 0);
495 }
496
497 /**
498 * pm_feature_check() - Returns the supported API version if supported
499 * @api_id API ID to check
500 * @flag 0 - Call from secure source
501 * 1 - Call from non-secure source
502 * @ret_payload pointer to array of PAYLOAD_ARG_CNT number of
503 * words Returned supported API version and bitmasks
504 * for IOCTL and QUERY ID
505 *
506 * @return Returns status, either success or error+reason
507 */
pm_feature_check(uint32_t api_id,uint32_t * ret_payload,uint32_t flag)508 enum pm_ret_status pm_feature_check(uint32_t api_id, uint32_t *ret_payload,
509 uint32_t flag)
510 {
511 uint32_t payload[PAYLOAD_ARG_CNT];
512 uint32_t module_id;
513
514 /* Return version of API which are implemented in ATF only */
515 switch (api_id) {
516 case PM_GET_CALLBACK_DATA:
517 case PM_GET_TRUSTZONE_VERSION:
518 ret_payload[0] = PM_API_VERSION_2;
519 return PM_RET_SUCCESS;
520 case TF_A_PM_REGISTER_SGI:
521 ret_payload[0] = PM_API_BASE_VERSION;
522 return PM_RET_SUCCESS;
523 default:
524 break;
525 }
526
527 module_id = (api_id & MODULE_ID_MASK) >> 8U;
528
529 /*
530 * feature check should be done only for LIBPM module
531 * If module_id is 0, then we consider it LIBPM module as default id
532 */
533 if ((module_id > 0) && (module_id != LIBPM_MODULE_ID)) {
534 return PM_RET_SUCCESS;
535 }
536
537 PM_PACK_PAYLOAD2(payload, LIBPM_MODULE_ID, flag,
538 PM_FEATURE_CHECK, api_id);
539 return pm_ipi_send_sync(primary_proc, payload, ret_payload, PAYLOAD_ARG_CNT);
540 }
541
542 /**
543 * pm_load_pdi() - Load the PDI
544 *
545 * This function provides support to load PDI from linux
546 *
547 * src: Source device of pdi(DDR, OCM, SD etc)
548 * address_low: lower 32-bit Linear memory space address
549 * address_high: higher 32-bit Linear memory space address
550 * @flag 0 - Call from secure source
551 * 1 - Call from non-secure source
552 *
553 * @return Returns status, either success or error+reason
554 */
pm_load_pdi(uint32_t src,uint32_t address_low,uint32_t address_high,uint32_t flag)555 enum pm_ret_status pm_load_pdi(uint32_t src, uint32_t address_low,
556 uint32_t address_high, uint32_t flag)
557 {
558 uint32_t payload[PAYLOAD_ARG_CNT];
559
560 /* Send request to the PMU */
561 PM_PACK_PAYLOAD4(payload, LOADER_MODULE_ID, flag, PM_LOAD_PDI, src,
562 address_high, address_low);
563 return pm_ipi_send_sync(primary_proc, payload, NULL, 0);
564 }
565
566 /**
567 * pm_register_notifier() - PM call to register a subsystem to be notified
568 * about the device event
569 * @device_id Device ID for the Node to which the event is related
570 * @event Event in question
571 * @wake Wake subsystem upon capturing the event if value 1
572 * @enable Enable the registration for value 1, disable for value 0
573 * @flag 0 - Call from secure source
574 * 1 - Call from non-secure source
575 *
576 * @return Returns status, either success or error+reason
577 */
pm_register_notifier(uint32_t device_id,uint32_t event,uint32_t wake,uint32_t enable,uint32_t flag)578 enum pm_ret_status pm_register_notifier(uint32_t device_id, uint32_t event,
579 uint32_t wake, uint32_t enable,
580 uint32_t flag)
581 {
582 uint32_t payload[PAYLOAD_ARG_CNT];
583
584 /* Send request to the PMC */
585 PM_PACK_PAYLOAD5(payload, LIBPM_MODULE_ID, flag, PM_REGISTER_NOTIFIER,
586 device_id, event, wake, enable);
587
588 return pm_ipi_send_sync(primary_proc, payload, NULL, 0);
589 }
590