blob: be243717e4ae314d780e7b771c1413467e2c8b52 [file] [log] [blame]
Soren Brinkmann76fcae32016-03-06 20:16:27 -08001/*
Rajan Vaja83687612018-01-17 02:39:20 -08002 * Copyright (c) 2013-2018, ARM Limited and Contributors. All rights reserved.
Soren Brinkmann76fcae32016-03-06 20:16:27 -08003 *
dp-armfa3cf0b2017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Soren Brinkmann76fcae32016-03-06 20:16:27 -08005 */
6
7/*
8 * ZynqMP system level PM-API functions and communication with PMU via
9 * IPI interrupts
10 */
11
12#include <arch_helpers.h>
13#include <platform.h>
Rajan Vaja5529a012018-01-17 02:39:23 -080014#include "pm_api_ioctl.h"
Rajan Vaja0ac2be12018-01-17 02:39:21 -080015#include "pm_api_pinctrl.h"
Isla Mitchelle3631462017-07-14 10:46:32 +010016#include "pm_api_sys.h"
Soren Brinkmann76fcae32016-03-06 20:16:27 -080017#include "pm_client.h"
Soren Brinkmann76fcae32016-03-06 20:16:27 -080018#include "pm_common.h"
Isla Mitchelle3631462017-07-14 10:46:32 +010019#include "pm_ipi.h"
Soren Brinkmann76fcae32016-03-06 20:16:27 -080020
21/**
22 * Assigning of argument values into array elements.
23 */
24#define PM_PACK_PAYLOAD1(pl, arg0) { \
25 pl[0] = (uint32_t)(arg0); \
26}
27
28#define PM_PACK_PAYLOAD2(pl, arg0, arg1) { \
29 pl[1] = (uint32_t)(arg1); \
30 PM_PACK_PAYLOAD1(pl, arg0); \
31}
32
33#define PM_PACK_PAYLOAD3(pl, arg0, arg1, arg2) { \
34 pl[2] = (uint32_t)(arg2); \
35 PM_PACK_PAYLOAD2(pl, arg0, arg1); \
36}
37
38#define PM_PACK_PAYLOAD4(pl, arg0, arg1, arg2, arg3) { \
39 pl[3] = (uint32_t)(arg3); \
40 PM_PACK_PAYLOAD3(pl, arg0, arg1, arg2); \
41}
42
43#define PM_PACK_PAYLOAD5(pl, arg0, arg1, arg2, arg3, arg4) { \
44 pl[4] = (uint32_t)(arg4); \
45 PM_PACK_PAYLOAD4(pl, arg0, arg1, arg2, arg3); \
46}
47
48#define PM_PACK_PAYLOAD6(pl, arg0, arg1, arg2, arg3, arg4, arg5) { \
49 pl[5] = (uint32_t)(arg5); \
50 PM_PACK_PAYLOAD5(pl, arg0, arg1, arg2, arg3, arg4); \
51}
52
53/**
54 * pm_self_suspend() - PM call for processor to suspend itself
55 * @nid Node id of the processor or subsystem
56 * @latency Requested maximum wakeup latency (not supported)
Filip Drazic0bd9d0c2016-07-20 17:17:39 +020057 * @state Requested state
Soren Brinkmann76fcae32016-03-06 20:16:27 -080058 * @address Resume address
59 *
60 * This is a blocking call, it will return only once PMU has responded.
61 * On a wakeup, resume address will be automatically set by PMU.
62 *
63 * @return Returns status, either success or error+reason
64 */
65enum pm_ret_status pm_self_suspend(enum pm_node_id nid,
66 unsigned int latency,
67 unsigned int state,
68 uintptr_t address)
69{
70 uint32_t payload[PAYLOAD_ARG_CNT];
71 unsigned int cpuid = plat_my_core_pos();
72 const struct pm_proc *proc = pm_get_proc(cpuid);
73
74 /*
75 * Do client specific suspend operations
76 * (e.g. set powerdown request bit)
77 */
Filip Drazic4c0765a2016-07-26 12:11:33 +020078 pm_client_suspend(proc, state);
Soren Brinkmann76fcae32016-03-06 20:16:27 -080079 /* Send request to the PMU */
80 PM_PACK_PAYLOAD6(payload, PM_SELF_SUSPEND, proc->node_id, latency,
81 state, address, (address >> 32));
Soren Brinkmannd6c9e032016-09-22 11:35:47 -070082 return pm_ipi_send_sync(proc, payload, NULL, 0);
Soren Brinkmann76fcae32016-03-06 20:16:27 -080083}
84
85/**
86 * pm_req_suspend() - PM call to request for another PU or subsystem to
87 * be suspended gracefully.
88 * @target Node id of the targeted PU or subsystem
89 * @ack Flag to specify whether acknowledge is requested
90 * @latency Requested wakeup latency (not supported)
91 * @state Requested state (not supported)
92 *
93 * @return Returns status, either success or error+reason
94 */
95enum pm_ret_status pm_req_suspend(enum pm_node_id target,
96 enum pm_request_ack ack,
97 unsigned int latency, unsigned int state)
98{
99 uint32_t payload[PAYLOAD_ARG_CNT];
100
101 /* Send request to the PMU */
102 PM_PACK_PAYLOAD5(payload, PM_REQ_SUSPEND, target, ack, latency, state);
103 if (ack == REQ_ACK_BLOCKING)
Soren Brinkmannd6c9e032016-09-22 11:35:47 -0700104 return pm_ipi_send_sync(primary_proc, payload, NULL, 0);
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800105 else
106 return pm_ipi_send(primary_proc, payload);
107}
108
109/**
110 * pm_req_wakeup() - PM call for processor to wake up selected processor
111 * or subsystem
112 * @target Node id of the processor or subsystem to wake up
113 * @ack Flag to specify whether acknowledge requested
114 * @set_address Resume address presence indicator
115 * 1 resume address specified, 0 otherwise
116 * @address Resume address
117 *
118 * This API function is either used to power up another APU core for SMP
119 * (by PSCI) or to power up an entirely different PU or subsystem, such
120 * as RPU0, RPU, or PL_CORE_xx. Resume address for the target PU will be
121 * automatically set by PMU.
122 *
123 * @return Returns status, either success or error+reason
124 */
125enum pm_ret_status pm_req_wakeup(enum pm_node_id target,
126 unsigned int set_address,
127 uintptr_t address,
128 enum pm_request_ack ack)
129{
130 uint32_t payload[PAYLOAD_ARG_CNT];
131 uint64_t encoded_address;
132 const struct pm_proc *proc = pm_get_proc_by_node(target);
133
134 /* invoke APU-specific code for waking up another APU core */
135 pm_client_wakeup(proc);
136
137 /* encode set Address into 1st bit of address */
138 encoded_address = address;
139 encoded_address |= !!set_address;
140
141 /* Send request to the PMU to perform the wake of the PU */
142 PM_PACK_PAYLOAD5(payload, PM_REQ_WAKEUP, target, encoded_address,
143 encoded_address >> 32, ack);
144
145 if (ack == REQ_ACK_BLOCKING)
Soren Brinkmannd6c9e032016-09-22 11:35:47 -0700146 return pm_ipi_send_sync(primary_proc, payload, NULL, 0);
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800147 else
148 return pm_ipi_send(primary_proc, payload);
149}
150
151/**
152 * pm_force_powerdown() - PM call to request for another PU or subsystem to
153 * be powered down forcefully
154 * @target Node id of the targeted PU or subsystem
155 * @ack Flag to specify whether acknowledge is requested
156 *
157 * @return Returns status, either success or error+reason
158 */
159enum pm_ret_status pm_force_powerdown(enum pm_node_id target,
160 enum pm_request_ack ack)
161{
162 uint32_t payload[PAYLOAD_ARG_CNT];
163
164 /* Send request to the PMU */
165 PM_PACK_PAYLOAD3(payload, PM_FORCE_POWERDOWN, target, ack);
166
167 if (ack == REQ_ACK_BLOCKING)
Soren Brinkmannd6c9e032016-09-22 11:35:47 -0700168 return pm_ipi_send_sync(primary_proc, payload, NULL, 0);
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800169 else
170 return pm_ipi_send(primary_proc, payload);
171}
172
173/**
174 * pm_abort_suspend() - PM call to announce that a prior suspend request
175 * is to be aborted.
176 * @reason Reason for the abort
177 *
178 * Calling PU expects the PMU to abort the initiated suspend procedure.
179 * This is a non-blocking call without any acknowledge.
180 *
181 * @return Returns status, either success or error+reason
182 */
183enum pm_ret_status pm_abort_suspend(enum pm_abort_reason reason)
184{
185 uint32_t payload[PAYLOAD_ARG_CNT];
186
187 /*
188 * Do client specific abort suspend operations
189 * (e.g. enable interrupts and clear powerdown request bit)
190 */
191 pm_client_abort_suspend();
192 /* Send request to the PMU */
193 /* TODO: allow passing the node ID of the affected CPU */
194 PM_PACK_PAYLOAD3(payload, PM_ABORT_SUSPEND, reason,
195 primary_proc->node_id);
196 return pm_ipi_send(primary_proc, payload);
197}
198
199/**
200 * pm_set_wakeup_source() - PM call to specify the wakeup source while suspended
201 * @target Node id of the targeted PU or subsystem
202 * @wkup_node Node id of the wakeup peripheral
203 * @enable Enable or disable the specified peripheral as wake source
204 *
205 * @return Returns status, either success or error+reason
206 */
207enum pm_ret_status pm_set_wakeup_source(enum pm_node_id target,
208 enum pm_node_id wkup_node,
209 unsigned int enable)
210{
211 uint32_t payload[PAYLOAD_ARG_CNT];
212
213 PM_PACK_PAYLOAD4(payload, PM_SET_WAKEUP_SOURCE, target, wkup_node,
214 enable);
215 return pm_ipi_send(primary_proc, payload);
216}
217
218/**
219 * pm_system_shutdown() - PM call to request a system shutdown or restart
220 * @restart Shutdown or restart? 0 for shutdown, 1 for restart
221 *
222 * @return Returns status, either success or error+reason
223 */
Soren Brinkmann58fbb9b2016-09-02 09:50:54 -0700224enum pm_ret_status pm_system_shutdown(unsigned int type, unsigned int subtype)
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800225{
226 uint32_t payload[PAYLOAD_ARG_CNT];
227
Soren Brinkmann58fbb9b2016-09-02 09:50:54 -0700228 PM_PACK_PAYLOAD3(payload, PM_SYSTEM_SHUTDOWN, type, subtype);
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800229 return pm_ipi_send(primary_proc, payload);
230}
231
232/* APIs for managing PM slaves: */
233
234/**
235 * pm_req_node() - PM call to request a node with specific capabilities
236 * @nid Node id of the slave
237 * @capabilities Requested capabilities of the slave
238 * @qos Quality of service (not supported)
239 * @ack Flag to specify whether acknowledge is requested
240 *
241 * @return Returns status, either success or error+reason
242 */
243enum pm_ret_status pm_req_node(enum pm_node_id nid,
244 unsigned int capabilities,
245 unsigned int qos,
246 enum pm_request_ack ack)
247{
248 uint32_t payload[PAYLOAD_ARG_CNT];
249
250 PM_PACK_PAYLOAD5(payload, PM_REQ_NODE, nid, capabilities, qos, ack);
251
252 if (ack == REQ_ACK_BLOCKING)
Soren Brinkmannd6c9e032016-09-22 11:35:47 -0700253 return pm_ipi_send_sync(primary_proc, payload, NULL, 0);
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800254 else
255 return pm_ipi_send(primary_proc, payload);
256}
257
258/**
259 * pm_set_requirement() - PM call to set requirement for PM slaves
260 * @nid Node id of the slave
261 * @capabilities Requested capabilities of the slave
262 * @qos Quality of service (not supported)
263 * @ack Flag to specify whether acknowledge is requested
264 *
265 * This API function is to be used for slaves a PU already has requested
266 *
267 * @return Returns status, either success or error+reason
268 */
269enum pm_ret_status pm_set_requirement(enum pm_node_id nid,
270 unsigned int capabilities,
271 unsigned int qos,
272 enum pm_request_ack ack)
273{
274 uint32_t payload[PAYLOAD_ARG_CNT];
275
276 PM_PACK_PAYLOAD5(payload, PM_SET_REQUIREMENT, nid, capabilities, qos,
277 ack);
278
279 if (ack == REQ_ACK_BLOCKING)
Soren Brinkmannd6c9e032016-09-22 11:35:47 -0700280 return pm_ipi_send_sync(primary_proc, payload, NULL, 0);
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800281 else
282 return pm_ipi_send(primary_proc, payload);
283}
284
285/**
286 * pm_release_node() - PM call to release a node
287 * @nid Node id of the slave
288 *
289 * @return Returns status, either success or error+reason
290 */
291enum pm_ret_status pm_release_node(enum pm_node_id nid)
292{
293 uint32_t payload[PAYLOAD_ARG_CNT];
294
295 PM_PACK_PAYLOAD2(payload, PM_RELEASE_NODE, nid);
296 return pm_ipi_send(primary_proc, payload);
297}
298
299/**
300 * pm_set_max_latency() - PM call to set wakeup latency requirements
301 * @nid Node id of the slave
302 * @latency Requested maximum wakeup latency
303 *
304 * @return Returns status, either success or error+reason
305 */
306enum pm_ret_status pm_set_max_latency(enum pm_node_id nid,
307 unsigned int latency)
308{
309 uint32_t payload[PAYLOAD_ARG_CNT];
310
311 PM_PACK_PAYLOAD3(payload, PM_SET_MAX_LATENCY, nid, latency);
312 return pm_ipi_send(primary_proc, payload);
313}
314
315/* Miscellaneous API functions */
316
317/**
318 * pm_get_api_version() - Get version number of PMU PM firmware
319 * @version Returns 32-bit version number of PMU Power Management Firmware
320 *
321 * @return Returns status, either success or error+reason
322 */
323enum pm_ret_status pm_get_api_version(unsigned int *version)
324{
325 uint32_t payload[PAYLOAD_ARG_CNT];
326
327 /* Send request to the PMU */
328 PM_PACK_PAYLOAD1(payload, PM_GET_API_VERSION);
Soren Brinkmannd6c9e032016-09-22 11:35:47 -0700329 return pm_ipi_send_sync(primary_proc, payload, version, 1);
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800330}
331
332/**
333 * pm_set_configuration() - PM call to set system configuration
334 * @phys_addr Physical 32-bit address of data structure in memory
335 *
336 * @return Returns status, either success or error+reason
337 */
338enum pm_ret_status pm_set_configuration(unsigned int phys_addr)
339{
340 return PM_RET_ERROR_NOTSUPPORTED;
341}
342
343/**
344 * pm_get_node_status() - PM call to request a node's current power state
345 * @nid Node id of the slave
346 *
347 * @return Returns status, either success or error+reason
348 */
349enum pm_ret_status pm_get_node_status(enum pm_node_id nid)
350{
351 /* TODO: Add power state argument!! */
352 uint32_t payload[PAYLOAD_ARG_CNT];
353
354 PM_PACK_PAYLOAD2(payload, PM_GET_NODE_STATUS, nid);
355 return pm_ipi_send(primary_proc, payload);
356}
357
358/**
359 * pm_register_notifier() - Register the PU to be notified of PM events
360 * @nid Node id of the slave
361 * @event The event to be notified about
362 * @wake Wake up on event
363 * @enable Enable or disable the notifier
364 *
365 * @return Returns status, either success or error+reason
366 */
367enum pm_ret_status pm_register_notifier(enum pm_node_id nid,
368 unsigned int event,
369 unsigned int wake,
370 unsigned int enable)
371{
Anes Hadziahmetagicc95ae092016-05-12 16:17:34 +0200372 uint32_t payload[PAYLOAD_ARG_CNT];
373
374 PM_PACK_PAYLOAD5(payload, PM_REGISTER_NOTIFIER,
375 nid, event, wake, enable);
376
Soren Brinkmanna1b0a902016-09-30 11:30:21 -0700377 return pm_ipi_send_sync(primary_proc, payload, NULL, 0);
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800378}
379
380/**
Anes Hadziahmetagic92aee012016-05-12 16:17:30 +0200381 * pm_get_op_characteristic() - PM call to request operating characteristics
382 * of a node
383 * @nid Node id of the slave
384 * @type Type of the operating characteristic
385 * (power, temperature and latency)
386 * @result Returns the operating characteristic for the requested node,
387 * specified by the type
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800388 *
389 * @return Returns status, either success or error+reason
390 */
391enum pm_ret_status pm_get_op_characteristic(enum pm_node_id nid,
Anes Hadziahmetagic92aee012016-05-12 16:17:30 +0200392 enum pm_opchar_type type,
393 uint32_t *result)
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800394{
Anes Hadziahmetagic92aee012016-05-12 16:17:30 +0200395 uint32_t payload[PAYLOAD_ARG_CNT];
396
397 /* Send request to the PMU */
398 PM_PACK_PAYLOAD3(payload, PM_GET_OP_CHARACTERISTIC, nid, type);
Soren Brinkmannd6c9e032016-09-22 11:35:47 -0700399 return pm_ipi_send_sync(primary_proc, payload, result, 1);
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800400}
401
402/* Direct-Control API functions */
403
404/**
405 * pm_reset_assert() - Assert reset
406 * @reset Reset ID
407 * @assert Assert (1) or de-assert (0)
408 *
409 * @return Returns status, either success or error+reason
410 */
411enum pm_ret_status pm_reset_assert(unsigned int reset,
412 unsigned int assert)
413{
414 uint32_t payload[PAYLOAD_ARG_CNT];
415
416 /* Send request to the PMU */
417 PM_PACK_PAYLOAD3(payload, PM_RESET_ASSERT, reset, assert);
418 return pm_ipi_send(primary_proc, payload);
419}
420
421/**
422 * pm_reset_get_status() - Get current status of a reset line
423 * @reset Reset ID
424 * @reset_status Returns current status of selected reset line
425 *
426 * @return Returns status, either success or error+reason
427 */
428enum pm_ret_status pm_reset_get_status(unsigned int reset,
429 unsigned int *reset_status)
430{
431 uint32_t payload[PAYLOAD_ARG_CNT];
432
433 /* Send request to the PMU */
434 PM_PACK_PAYLOAD2(payload, PM_RESET_GET_STATUS, reset);
Soren Brinkmannd6c9e032016-09-22 11:35:47 -0700435 return pm_ipi_send_sync(primary_proc, payload, reset_status, 1);
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800436}
437
438/**
439 * pm_mmio_write() - Perform write to protected mmio
440 * @address Address to write to
441 * @mask Mask to apply
442 * @value Value to write
443 *
444 * This function provides access to PM-related control registers
445 * that may not be directly accessible by a particular PU.
446 *
447 * @return Returns status, either success or error+reason
448 */
449enum pm_ret_status pm_mmio_write(uintptr_t address,
450 unsigned int mask,
451 unsigned int value)
452{
453 uint32_t payload[PAYLOAD_ARG_CNT];
454
455 /* Send request to the PMU */
456 PM_PACK_PAYLOAD4(payload, PM_MMIO_WRITE, address, mask, value);
Soren Brinkmannd6c9e032016-09-22 11:35:47 -0700457 return pm_ipi_send_sync(primary_proc, payload, NULL, 0);
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800458}
459
460/**
461 * pm_mmio_read() - Read value from protected mmio
462 * @address Address to write to
463 * @value Value to write
464 *
465 * This function provides access to PM-related control registers
466 * that may not be directly accessible by a particular PU.
467 *
468 * @return Returns status, either success or error+reason
469 */
470enum pm_ret_status pm_mmio_read(uintptr_t address, unsigned int *value)
471{
472 uint32_t payload[PAYLOAD_ARG_CNT];
473
474 /* Send request to the PMU */
475 PM_PACK_PAYLOAD2(payload, PM_MMIO_READ, address);
Soren Brinkmannd6c9e032016-09-22 11:35:47 -0700476 return pm_ipi_send_sync(primary_proc, payload, value, 1);
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800477}
Nava kishore Manne68d460c2016-08-20 23:18:09 +0530478
479/**
480 * pm_fpga_load() - Load the bitstream into the PL.
481 *
482 * This function provides access to the xilfpga library to load
483 * the Bit-stream into PL.
484 *
485 * address_low: lower 32-bit Linear memory space address
486 *
487 * address_high: higher 32-bit Linear memory space address
488 *
489 * size: Number of 32bit words
490 *
491 * @return Returns status, either success or error+reason
492 */
493enum pm_ret_status pm_fpga_load(uint32_t address_low,
494 uint32_t address_high,
495 uint32_t size,
496 uint32_t flags)
497{
498 uint32_t payload[PAYLOAD_ARG_CNT];
499
500 /* Send request to the PMU */
501 PM_PACK_PAYLOAD5(payload, PM_FPGA_LOAD, address_high, address_low,
502 size, flags);
503 return pm_ipi_send(primary_proc, payload);
504}
505
506/**
507 * pm_fpga_get_status() - Read value from fpga status register
508 * @value Value to read
509 *
510 * This function provides access to the xilfpga library to get
511 * the fpga status
512 * @return Returns status, either success or error+reason
513 */
514enum pm_ret_status pm_fpga_get_status(unsigned int *value)
515{
516 uint32_t payload[PAYLOAD_ARG_CNT];
517
518 /* Send request to the PMU */
519 PM_PACK_PAYLOAD1(payload, PM_FPGA_GET_STATUS);
Soren Brinkmannd6c9e032016-09-22 11:35:47 -0700520 return pm_ipi_send_sync(primary_proc, payload, value, 1);
Nava kishore Manne68d460c2016-08-20 23:18:09 +0530521}
Soren Brinkmanncb366812016-09-22 12:21:11 -0700522
523/**
524 * pm_get_chipid() - Read silicon ID registers
525 * @value Buffer for return values. Must be large enough
526 * to hold 8 bytes.
527 *
528 * @return Returns silicon ID registers
529 */
530enum pm_ret_status pm_get_chipid(uint32_t *value)
531{
532 uint32_t payload[PAYLOAD_ARG_CNT];
533
534 /* Send request to the PMU */
535 PM_PACK_PAYLOAD1(payload, PM_GET_CHIPID);
536 return pm_ipi_send_sync(primary_proc, payload, value, 2);
537}
Soren Brinkmann84f0af42016-09-30 14:24:25 -0700538
539/**
540 * pm_get_callbackdata() - Read from IPI response buffer
541 * @data - array of PAYLOAD_ARG_CNT elements
542 *
543 * Read value from ipi buffer response buffer.
544 */
545void pm_get_callbackdata(uint32_t *data, size_t count)
546{
Soren Brinkmann84f0af42016-09-30 14:24:25 -0700547 pm_ipi_buff_read_callb(data, count);
Wendy Liang328105c2017-10-03 23:21:11 -0700548 pm_ipi_irq_clear(primary_proc);
Soren Brinkmann84f0af42016-09-30 14:24:25 -0700549}
Rajan Vaja83687612018-01-17 02:39:20 -0800550
551/**
552 * pm_pinctrl_request() - Request Pin from firmware
553 * @pin Pin number to request
554 *
555 * This function requests pin from firmware.
556 *
557 * @return Returns status, either success or error+reason.
558 */
559enum pm_ret_status pm_pinctrl_request(unsigned int pin)
560{
561 return PM_RET_SUCCESS;
562}
563
564/**
565 * pm_pinctrl_release() - Release Pin from firmware
566 * @pin Pin number to release
567 *
568 * This function releases pin from firmware.
569 *
570 * @return Returns status, either success or error+reason.
571 */
572enum pm_ret_status pm_pinctrl_release(unsigned int pin)
573{
574 return PM_RET_SUCCESS;
575}
576
577/**
578 * pm_pinctrl_get_function() - Read function id set for the given pin
579 * @pin Pin number
580 * @nid Node ID of function currently set for given pin
581 *
582 * This function provides the function currently set for the given pin.
583 *
584 * @return Returns status, either success or error+reason
585 */
586enum pm_ret_status pm_pinctrl_get_function(unsigned int pin,
587 enum pm_node_id *nid)
588{
Rajan Vaja0ac2be12018-01-17 02:39:21 -0800589 return pm_api_pinctrl_get_function(pin, nid);
Rajan Vaja83687612018-01-17 02:39:20 -0800590}
591
592/**
593 * pm_pinctrl_set_function() - Set function id set for the given pin
594 * @pin Pin number
595 * @nid Node ID of function to set for given pin
596 *
597 * This function provides the function currently set for the given pin.
598 *
599 * @return Returns status, either success or error+reason
600 */
601enum pm_ret_status pm_pinctrl_set_function(unsigned int pin,
602 enum pm_node_id nid)
603{
Rajan Vaja0ac2be12018-01-17 02:39:21 -0800604 return pm_api_pinctrl_set_function(pin, nid);
Rajan Vaja83687612018-01-17 02:39:20 -0800605}
606
607/**
608 * pm_pinctrl_get_config() - Read value of requested config param for given pin
609 * @pin Pin number
610 * @param Parameter values to be read
611 * @value Buffer for configuration Parameter value
612 *
613 * This function provides the configuration parameter value for the given pin.
614 *
615 * @return Returns status, either success or error+reason
616 */
617enum pm_ret_status pm_pinctrl_get_config(unsigned int pin,
618 unsigned int param,
619 unsigned int *value)
620{
Rajan Vaja5e139e72018-01-17 02:39:22 -0800621 return pm_api_pinctrl_get_config(pin, param, value);
Rajan Vaja83687612018-01-17 02:39:20 -0800622}
623
624/**
625 * pm_pinctrl_set_config() - Read value of requested config param for given pin
626 * @pin Pin number
627 * @param Parameter to set
628 * @value Parameter value to set
629 *
630 * This function provides the configuration parameter value for the given pin.
631 *
632 * @return Returns status, either success or error+reason
633 */
634enum pm_ret_status pm_pinctrl_set_config(unsigned int pin,
635 unsigned int param,
636 unsigned int value)
637{
Rajan Vaja5e139e72018-01-17 02:39:22 -0800638 return pm_api_pinctrl_set_config(pin, param, value);
Rajan Vaja83687612018-01-17 02:39:20 -0800639}
Rajan Vaja5529a012018-01-17 02:39:23 -0800640
641/**
642 * pm_ioctl() - PM IOCTL API for device control and configs
643 * @node_id Node ID of the device
644 * @ioctl_id ID of the requested IOCTL
645 * @arg1 Argument 1 to requested IOCTL call
646 * @arg2 Argument 2 to requested IOCTL call
647 * @out Returned output value
648 *
649 * This function calls IOCTL to firmware for device control and configuration.
650 *
651 * @return Returns status, either success or error+reason
652 */
653enum pm_ret_status pm_ioctl(enum pm_node_id nid,
654 unsigned int ioctl_id,
655 unsigned int arg1,
656 unsigned int arg2,
657 unsigned int *value)
658{
659 return pm_api_ioctl(nid, ioctl_id, arg1, arg2, value);
660}