1 From 95c8565453e068db2664b5ee9cb0b7eced9a8d24 Mon Sep 17 00:00:00 2001
2 From: Ioana Radulescu <ruxandra.radulescu@freescale.com>
3 Date: Fri, 3 Jul 2015 19:02:45 +0300
4 Subject: [PATCH 189/226] staging: fsl-mc: update dpcon binary interface to
7 -this includes adding the command building/parsing
10 Signed-off-by: Stuart Yoder <stuart.yoder@freescale.com>
12 drivers/staging/fsl-mc/bus/Makefile | 3 +-
13 drivers/staging/fsl-mc/bus/dpcon.c | 407 ++++++++++++++++++++++++++++
14 drivers/staging/fsl-mc/include/dpcon-cmd.h | 102 ++++++-
15 drivers/staging/fsl-mc/include/dpcon.h | 407 ++++++++++++++++++++++++++++
16 4 files changed, 917 insertions(+), 2 deletions(-)
17 create mode 100644 drivers/staging/fsl-mc/bus/dpcon.c
18 create mode 100644 drivers/staging/fsl-mc/include/dpcon.h
20 --- a/drivers/staging/fsl-mc/bus/Makefile
21 +++ b/drivers/staging/fsl-mc/bus/Makefile
22 @@ -16,4 +16,5 @@ mc-bus-driver-objs := mc-bus.o \
24 irq-gic-v3-its-fsl-mc-msi.o \
30 +++ b/drivers/staging/fsl-mc/bus/dpcon.c
32 +/* Copyright 2013-2015 Freescale Semiconductor Inc.
34 + * Redistribution and use in source and binary forms, with or without
35 + * modification, are permitted provided that the following conditions are met:
36 + * * Redistributions of source code must retain the above copyright
37 + * notice, this list of conditions and the following disclaimer.
38 + * * Redistributions in binary form must reproduce the above copyright
39 + * notice, this list of conditions and the following disclaimer in the
40 + * documentation and/or other materials provided with the distribution.
41 + * * Neither the name of the above-listed copyright holders nor the
42 + * names of any contributors may be used to endorse or promote products
43 + * derived from this software without specific prior written permission.
46 + * ALTERNATIVELY, this software may be distributed under the terms of the
47 + * GNU General Public License ("GPL") as published by the Free Software
48 + * Foundation, either version 2 of that License or (at your option) any
51 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
52 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
53 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
54 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
55 + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
56 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
57 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
58 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
59 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
60 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
61 + * POSSIBILITY OF SUCH DAMAGE.
63 +#include "../include/mc-sys.h"
64 +#include "../include/mc-cmd.h"
65 +#include "../include/dpcon.h"
66 +#include "../include/dpcon-cmd.h"
68 +int dpcon_open(struct fsl_mc_io *mc_io,
73 + struct mc_command cmd = { 0 };
76 + /* prepare command */
77 + cmd.header = mc_encode_cmd_header(DPCON_CMDID_OPEN,
80 + DPCON_CMD_OPEN(cmd, dpcon_id);
82 + /* send command to mc*/
83 + err = mc_send_command(mc_io, &cmd);
87 + /* retrieve response parameters */
88 + *token = MC_CMD_HDR_READ_TOKEN(cmd.header);
92 +EXPORT_SYMBOL(dpcon_open);
94 +int dpcon_close(struct fsl_mc_io *mc_io,
98 + struct mc_command cmd = { 0 };
100 + /* prepare command */
101 + cmd.header = mc_encode_cmd_header(DPCON_CMDID_CLOSE,
105 + /* send command to mc*/
106 + return mc_send_command(mc_io, &cmd);
108 +EXPORT_SYMBOL(dpcon_close);
110 +int dpcon_create(struct fsl_mc_io *mc_io,
111 + uint32_t cmd_flags,
112 + const struct dpcon_cfg *cfg,
115 + struct mc_command cmd = { 0 };
118 + /* prepare command */
119 + cmd.header = mc_encode_cmd_header(DPCON_CMDID_CREATE,
122 + DPCON_CMD_CREATE(cmd, cfg);
124 + /* send command to mc*/
125 + err = mc_send_command(mc_io, &cmd);
129 + /* retrieve response parameters */
130 + *token = MC_CMD_HDR_READ_TOKEN(cmd.header);
135 +int dpcon_destroy(struct fsl_mc_io *mc_io,
136 + uint32_t cmd_flags,
139 + struct mc_command cmd = { 0 };
141 + /* prepare command */
142 + cmd.header = mc_encode_cmd_header(DPCON_CMDID_DESTROY,
146 + /* send command to mc*/
147 + return mc_send_command(mc_io, &cmd);
150 +int dpcon_enable(struct fsl_mc_io *mc_io,
151 + uint32_t cmd_flags,
154 + struct mc_command cmd = { 0 };
156 + /* prepare command */
157 + cmd.header = mc_encode_cmd_header(DPCON_CMDID_ENABLE,
161 + /* send command to mc*/
162 + return mc_send_command(mc_io, &cmd);
164 +EXPORT_SYMBOL(dpcon_enable);
166 +int dpcon_disable(struct fsl_mc_io *mc_io,
167 + uint32_t cmd_flags,
170 + struct mc_command cmd = { 0 };
172 + /* prepare command */
173 + cmd.header = mc_encode_cmd_header(DPCON_CMDID_DISABLE,
177 + /* send command to mc*/
178 + return mc_send_command(mc_io, &cmd);
180 +EXPORT_SYMBOL(dpcon_disable);
182 +int dpcon_is_enabled(struct fsl_mc_io *mc_io,
183 + uint32_t cmd_flags,
187 + struct mc_command cmd = { 0 };
189 + /* prepare command */
190 + cmd.header = mc_encode_cmd_header(DPCON_CMDID_IS_ENABLED,
194 + /* send command to mc*/
195 + err = mc_send_command(mc_io, &cmd);
199 + /* retrieve response parameters */
200 + DPCON_RSP_IS_ENABLED(cmd, *en);
205 +int dpcon_reset(struct fsl_mc_io *mc_io,
206 + uint32_t cmd_flags,
209 + struct mc_command cmd = { 0 };
211 + /* prepare command */
212 + cmd.header = mc_encode_cmd_header(DPCON_CMDID_RESET,
215 + /* send command to mc*/
216 + return mc_send_command(mc_io, &cmd);
219 +int dpcon_set_irq(struct fsl_mc_io *mc_io,
220 + uint32_t cmd_flags,
223 + struct dpcon_irq_cfg *irq_cfg)
225 + struct mc_command cmd = { 0 };
227 + /* prepare command */
228 + cmd.header = mc_encode_cmd_header(DPCON_CMDID_SET_IRQ,
231 + DPCON_CMD_SET_IRQ(cmd, irq_index, irq_cfg);
233 + /* send command to mc*/
234 + return mc_send_command(mc_io, &cmd);
237 +int dpcon_get_irq(struct fsl_mc_io *mc_io,
238 + uint32_t cmd_flags,
242 + struct dpcon_irq_cfg *irq_cfg)
244 + struct mc_command cmd = { 0 };
247 + /* prepare command */
248 + cmd.header = mc_encode_cmd_header(DPCON_CMDID_GET_IRQ,
251 + DPCON_CMD_GET_IRQ(cmd, irq_index);
253 + /* send command to mc*/
254 + err = mc_send_command(mc_io, &cmd);
258 + /* retrieve response parameters */
259 + DPCON_RSP_GET_IRQ(cmd, *type, irq_cfg);
264 +int dpcon_set_irq_enable(struct fsl_mc_io *mc_io,
265 + uint32_t cmd_flags,
270 + struct mc_command cmd = { 0 };
272 + /* prepare command */
273 + cmd.header = mc_encode_cmd_header(DPCON_CMDID_SET_IRQ_ENABLE,
276 + DPCON_CMD_SET_IRQ_ENABLE(cmd, irq_index, en);
278 + /* send command to mc*/
279 + return mc_send_command(mc_io, &cmd);
282 +int dpcon_get_irq_enable(struct fsl_mc_io *mc_io,
283 + uint32_t cmd_flags,
288 + struct mc_command cmd = { 0 };
291 + /* prepare command */
292 + cmd.header = mc_encode_cmd_header(DPCON_CMDID_GET_IRQ_ENABLE,
295 + DPCON_CMD_GET_IRQ_ENABLE(cmd, irq_index);
297 + /* send command to mc*/
298 + err = mc_send_command(mc_io, &cmd);
302 + /* retrieve response parameters */
303 + DPCON_RSP_GET_IRQ_ENABLE(cmd, *en);
308 +int dpcon_set_irq_mask(struct fsl_mc_io *mc_io,
309 + uint32_t cmd_flags,
314 + struct mc_command cmd = { 0 };
316 + /* prepare command */
317 + cmd.header = mc_encode_cmd_header(DPCON_CMDID_SET_IRQ_MASK,
320 + DPCON_CMD_SET_IRQ_MASK(cmd, irq_index, mask);
322 + /* send command to mc*/
323 + return mc_send_command(mc_io, &cmd);
326 +int dpcon_get_irq_mask(struct fsl_mc_io *mc_io,
327 + uint32_t cmd_flags,
332 + struct mc_command cmd = { 0 };
335 + /* prepare command */
336 + cmd.header = mc_encode_cmd_header(DPCON_CMDID_GET_IRQ_MASK,
339 + DPCON_CMD_GET_IRQ_MASK(cmd, irq_index);
341 + /* send command to mc*/
342 + err = mc_send_command(mc_io, &cmd);
346 + /* retrieve response parameters */
347 + DPCON_RSP_GET_IRQ_MASK(cmd, *mask);
352 +int dpcon_get_irq_status(struct fsl_mc_io *mc_io,
353 + uint32_t cmd_flags,
358 + struct mc_command cmd = { 0 };
361 + /* prepare command */
362 + cmd.header = mc_encode_cmd_header(DPCON_CMDID_GET_IRQ_STATUS,
365 + DPCON_CMD_GET_IRQ_STATUS(cmd, irq_index, *status);
367 + /* send command to mc*/
368 + err = mc_send_command(mc_io, &cmd);
372 + /* retrieve response parameters */
373 + DPCON_RSP_GET_IRQ_STATUS(cmd, *status);
378 +int dpcon_clear_irq_status(struct fsl_mc_io *mc_io,
379 + uint32_t cmd_flags,
384 + struct mc_command cmd = { 0 };
386 + /* prepare command */
387 + cmd.header = mc_encode_cmd_header(DPCON_CMDID_CLEAR_IRQ_STATUS,
390 + DPCON_CMD_CLEAR_IRQ_STATUS(cmd, irq_index, status);
392 + /* send command to mc*/
393 + return mc_send_command(mc_io, &cmd);
396 +int dpcon_get_attributes(struct fsl_mc_io *mc_io,
397 + uint32_t cmd_flags,
399 + struct dpcon_attr *attr)
401 + struct mc_command cmd = { 0 };
404 + /* prepare command */
405 + cmd.header = mc_encode_cmd_header(DPCON_CMDID_GET_ATTR,
409 + /* send command to mc*/
410 + err = mc_send_command(mc_io, &cmd);
414 + /* retrieve response parameters */
415 + DPCON_RSP_GET_ATTR(cmd, attr);
419 +EXPORT_SYMBOL(dpcon_get_attributes);
421 +int dpcon_set_notification(struct fsl_mc_io *mc_io,
422 + uint32_t cmd_flags,
424 + struct dpcon_notification_cfg *cfg)
426 + struct mc_command cmd = { 0 };
428 + /* prepare command */
429 + cmd.header = mc_encode_cmd_header(DPCON_CMDID_SET_NOTIFICATION,
432 + DPCON_CMD_SET_NOTIFICATION(cmd, cfg);
434 + /* send command to mc*/
435 + return mc_send_command(mc_io, &cmd);
437 +EXPORT_SYMBOL(dpcon_set_notification);
439 --- a/drivers/staging/fsl-mc/include/dpcon-cmd.h
440 +++ b/drivers/staging/fsl-mc/include/dpcon-cmd.h
444 #define DPCON_VER_MAJOR 2
445 -#define DPCON_VER_MINOR 1
446 +#define DPCON_VER_MINOR 2
449 #define DPCON_CMDID_CLOSE 0x800
452 #define DPCON_CMDID_SET_NOTIFICATION 0x100
454 +/* cmd, param, offset, width, type, arg_name */
455 +#define DPCON_CMD_OPEN(cmd, dpcon_id) \
456 + MC_CMD_OP(cmd, 0, 0, 32, int, dpcon_id)
458 +/* cmd, param, offset, width, type, arg_name */
459 +#define DPCON_CMD_CREATE(cmd, cfg) \
460 + MC_CMD_OP(cmd, 0, 0, 8, uint8_t, cfg->num_priorities)
462 +/* cmd, param, offset, width, type, arg_name */
463 +#define DPCON_RSP_IS_ENABLED(cmd, en) \
464 + MC_RSP_OP(cmd, 0, 0, 1, int, en)
466 +/* cmd, param, offset, width, type, arg_name */
467 +#define DPCON_CMD_SET_IRQ(cmd, irq_index, irq_cfg) \
469 + MC_CMD_OP(cmd, 0, 0, 8, uint8_t, irq_index);\
470 + MC_CMD_OP(cmd, 0, 32, 32, uint32_t, irq_cfg->val);\
471 + MC_CMD_OP(cmd, 1, 0, 64, uint64_t, irq_cfg->addr);\
472 + MC_CMD_OP(cmd, 2, 0, 32, int, irq_cfg->irq_num); \
475 +/* cmd, param, offset, width, type, arg_name */
476 +#define DPCON_CMD_GET_IRQ(cmd, irq_index) \
477 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index)
479 +/* cmd, param, offset, width, type, arg_name */
480 +#define DPCON_RSP_GET_IRQ(cmd, type, irq_cfg) \
482 + MC_RSP_OP(cmd, 0, 0, 32, uint32_t, irq_cfg->val);\
483 + MC_RSP_OP(cmd, 1, 0, 64, uint64_t, irq_cfg->addr);\
484 + MC_RSP_OP(cmd, 2, 0, 32, int, irq_cfg->irq_num); \
485 + MC_RSP_OP(cmd, 2, 32, 32, int, type);\
488 +/* cmd, param, offset, width, type, arg_name */
489 +#define DPCON_CMD_SET_IRQ_ENABLE(cmd, irq_index, en) \
491 + MC_CMD_OP(cmd, 0, 0, 8, uint8_t, en); \
492 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index);\
495 +/* cmd, param, offset, width, type, arg_name */
496 +#define DPCON_CMD_GET_IRQ_ENABLE(cmd, irq_index) \
497 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index)
499 +/* cmd, param, offset, width, type, arg_name */
500 +#define DPCON_RSP_GET_IRQ_ENABLE(cmd, en) \
501 + MC_RSP_OP(cmd, 0, 0, 8, uint8_t, en)
503 +/* cmd, param, offset, width, type, arg_name */
504 +#define DPCON_CMD_SET_IRQ_MASK(cmd, irq_index, mask) \
506 + MC_CMD_OP(cmd, 0, 0, 32, uint32_t, mask); \
507 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index);\
510 +/* cmd, param, offset, width, type, arg_name */
511 +#define DPCON_CMD_GET_IRQ_MASK(cmd, irq_index) \
512 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index)
514 +/* cmd, param, offset, width, type, arg_name */
515 +#define DPCON_RSP_GET_IRQ_MASK(cmd, mask) \
516 + MC_RSP_OP(cmd, 0, 0, 32, uint32_t, mask)
518 +/* cmd, param, offset, width, type, arg_name */
519 +#define DPCON_CMD_GET_IRQ_STATUS(cmd, irq_index, status) \
521 + MC_CMD_OP(cmd, 0, 0, 32, uint32_t, status);\
522 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index);\
525 +/* cmd, param, offset, width, type, arg_name */
526 +#define DPCON_RSP_GET_IRQ_STATUS(cmd, status) \
527 + MC_RSP_OP(cmd, 0, 0, 32, uint32_t, status)
529 +/* cmd, param, offset, width, type, arg_name */
530 +#define DPCON_CMD_CLEAR_IRQ_STATUS(cmd, irq_index, status) \
532 + MC_CMD_OP(cmd, 0, 0, 32, uint32_t, status); \
533 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index);\
536 +/* cmd, param, offset, width, type, arg_name */
537 +#define DPCON_RSP_GET_ATTR(cmd, attr) \
539 + MC_RSP_OP(cmd, 0, 0, 32, int, attr->id);\
540 + MC_RSP_OP(cmd, 0, 32, 16, uint16_t, attr->qbman_ch_id);\
541 + MC_RSP_OP(cmd, 0, 48, 8, uint8_t, attr->num_priorities);\
542 + MC_RSP_OP(cmd, 1, 0, 16, uint16_t, attr->version.major);\
543 + MC_RSP_OP(cmd, 1, 16, 16, uint16_t, attr->version.minor);\
546 +/* cmd, param, offset, width, type, arg_name */
547 +#define DPCON_CMD_SET_NOTIFICATION(cmd, cfg) \
549 + MC_CMD_OP(cmd, 0, 0, 32, int, cfg->dpio_id);\
550 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, cfg->priority);\
551 + MC_CMD_OP(cmd, 1, 0, 64, uint64_t, cfg->user_ctx);\
554 #endif /* _FSL_DPCON_CMD_H */
556 +++ b/drivers/staging/fsl-mc/include/dpcon.h
558 +/* Copyright 2013-2015 Freescale Semiconductor Inc.
560 + * Redistribution and use in source and binary forms, with or without
561 + * modification, are permitted provided that the following conditions are met:
562 + * * Redistributions of source code must retain the above copyright
563 + * notice, this list of conditions and the following disclaimer.
564 + * * Redistributions in binary form must reproduce the above copyright
565 + * notice, this list of conditions and the following disclaimer in the
566 + * documentation and/or other materials provided with the distribution.
567 + * * Neither the name of the above-listed copyright holders nor the
568 + * names of any contributors may be used to endorse or promote products
569 + * derived from this software without specific prior written permission.
572 + * ALTERNATIVELY, this software may be distributed under the terms of the
573 + * GNU General Public License ("GPL") as published by the Free Software
574 + * Foundation, either version 2 of that License or (at your option) any
577 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
578 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
579 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
580 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
581 + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
582 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
583 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
584 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
585 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
586 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
587 + * POSSIBILITY OF SUCH DAMAGE.
589 +#ifndef __FSL_DPCON_H
590 +#define __FSL_DPCON_H
592 +/* Data Path Concentrator API
593 + * Contains initialization APIs and runtime control APIs for DPCON
598 +/** General DPCON macros */
601 + * Use it to disable notifications; see dpcon_set_notification()
603 +#define DPCON_INVALID_DPIO_ID (int)(-1)
606 + * dpcon_open() - Open a control session for the specified object
607 + * @mc_io: Pointer to MC portal's I/O object
608 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
609 + * @dpcon_id: DPCON unique ID
610 + * @token: Returned token; use in subsequent API calls
612 + * This function can be used to open a control session for an
613 + * already created object; an object may have been declared in
614 + * the DPL or by calling the dpcon_create() function.
615 + * This function returns a unique authentication token,
616 + * associated with the specific object ID and the specific MC
617 + * portal; this token must be used in all subsequent commands for
618 + * this specific object.
620 + * Return: '0' on Success; Error code otherwise.
622 +int dpcon_open(struct fsl_mc_io *mc_io,
623 + uint32_t cmd_flags,
628 + * dpcon_close() - Close the control session of the object
629 + * @mc_io: Pointer to MC portal's I/O object
630 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
631 + * @token: Token of DPCON object
633 + * After this function is called, no further operations are
634 + * allowed on the object without opening a new control session.
636 + * Return: '0' on Success; Error code otherwise.
638 +int dpcon_close(struct fsl_mc_io *mc_io,
639 + uint32_t cmd_flags,
643 + * struct dpcon_cfg - Structure representing DPCON configuration
644 + * @num_priorities: Number of priorities for the DPCON channel (1-8)
647 + uint8_t num_priorities;
651 + * dpcon_create() - Create the DPCON object.
652 + * @mc_io: Pointer to MC portal's I/O object
653 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
654 + * @cfg: Configuration structure
655 + * @token: Returned token; use in subsequent API calls
657 + * Create the DPCON object, allocate required resources and
658 + * perform required initialization.
660 + * The object can be created either by declaring it in the
661 + * DPL file, or by calling this function.
663 + * This function returns a unique authentication token,
664 + * associated with the specific object ID and the specific MC
665 + * portal; this token must be used in all subsequent calls to
666 + * this specific object. For objects that are created using the
667 + * DPL file, call dpcon_open() function to get an authentication
670 + * Return: '0' on Success; Error code otherwise.
672 +int dpcon_create(struct fsl_mc_io *mc_io,
673 + uint32_t cmd_flags,
674 + const struct dpcon_cfg *cfg,
678 + * dpcon_destroy() - Destroy the DPCON object and release all its resources.
679 + * @mc_io: Pointer to MC portal's I/O object
680 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
681 + * @token: Token of DPCON object
683 + * Return: '0' on Success; error code otherwise.
685 +int dpcon_destroy(struct fsl_mc_io *mc_io,
686 + uint32_t cmd_flags,
690 + * dpcon_enable() - Enable the DPCON
691 + * @mc_io: Pointer to MC portal's I/O object
692 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
693 + * @token: Token of DPCON object
695 + * Return: '0' on Success; Error code otherwise
697 +int dpcon_enable(struct fsl_mc_io *mc_io,
698 + uint32_t cmd_flags,
702 + * dpcon_disable() - Disable the DPCON
703 + * @mc_io: Pointer to MC portal's I/O object
704 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
705 + * @token: Token of DPCON object
707 + * Return: '0' on Success; Error code otherwise
709 +int dpcon_disable(struct fsl_mc_io *mc_io,
710 + uint32_t cmd_flags,
714 + * dpcon_is_enabled() - Check if the DPCON is enabled.
715 + * @mc_io: Pointer to MC portal's I/O object
716 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
717 + * @token: Token of DPCON object
718 + * @en: Returns '1' if object is enabled; '0' otherwise
720 + * Return: '0' on Success; Error code otherwise.
722 +int dpcon_is_enabled(struct fsl_mc_io *mc_io,
723 + uint32_t cmd_flags,
728 + * dpcon_reset() - Reset the DPCON, returns the object to initial state.
729 + * @mc_io: Pointer to MC portal's I/O object
730 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
731 + * @token: Token of DPCON object
733 + * Return: '0' on Success; Error code otherwise.
735 +int dpcon_reset(struct fsl_mc_io *mc_io,
736 + uint32_t cmd_flags,
740 + * struct dpcon_irq_cfg - IRQ configuration
741 + * @addr: Address that must be written to signal a message-based interrupt
742 + * @val: Value to write into irq_addr address
743 + * @irq_num: A user defined number associated with this IRQ
745 +struct dpcon_irq_cfg {
752 + * dpcon_set_irq() - Set IRQ information for the DPCON to trigger an interrupt.
753 + * @mc_io: Pointer to MC portal's I/O object
754 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
755 + * @token: Token of DPCON object
756 + * @irq_index: Identifies the interrupt index to configure
757 + * @irq_cfg: IRQ configuration
758 + * Return: '0' on Success; Error code otherwise.
760 +int dpcon_set_irq(struct fsl_mc_io *mc_io,
761 + uint32_t cmd_flags,
764 + struct dpcon_irq_cfg *irq_cfg);
767 + * dpcon_get_irq() - Get IRQ information from the DPCON.
769 + * @mc_io: Pointer to MC portal's I/O object
770 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
771 + * @token: Token of DPCON object
772 + * @irq_index: The interrupt index to configure
773 + * @type: Interrupt type: 0 represents message interrupt
774 + * type (both irq_addr and irq_val are valid)
775 + * @irq_cfg: IRQ attributes
777 + * Return: '0' on Success; Error code otherwise.
779 +int dpcon_get_irq(struct fsl_mc_io *mc_io,
780 + uint32_t cmd_flags,
784 + struct dpcon_irq_cfg *irq_cfg);
787 + * dpcon_set_irq_enable() - Set overall interrupt state.
788 + * @mc_io: Pointer to MC portal's I/O object
789 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
790 + * @token: Token of DPCON object
791 + * @irq_index: The interrupt index to configure
792 + * @en: Interrupt state - enable = 1, disable = 0
794 + * Allows GPP software to control when interrupts are generated.
795 + * Each interrupt can have up to 32 causes. The enable/disable control's the
796 + * overall interrupt state. if the interrupt is disabled no causes will cause
799 + * Return: '0' on Success; Error code otherwise.
801 +int dpcon_set_irq_enable(struct fsl_mc_io *mc_io,
802 + uint32_t cmd_flags,
808 + * dpcon_get_irq_enable() - Get overall interrupt state.
809 + * @mc_io: Pointer to MC portal's I/O object
810 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
811 + * @token: Token of DPCON object
812 + * @irq_index: The interrupt index to configure
813 + * @en: Returned interrupt state - enable = 1, disable = 0
815 + * Return: '0' on Success; Error code otherwise.
817 +int dpcon_get_irq_enable(struct fsl_mc_io *mc_io,
818 + uint32_t cmd_flags,
824 + * dpcon_set_irq_mask() - Set interrupt mask.
825 + * @mc_io: Pointer to MC portal's I/O object
826 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
827 + * @token: Token of DPCON object
828 + * @irq_index: The interrupt index to configure
829 + * @mask: Event mask to trigger interrupt;
832 + * 1 = consider event for asserting IRQ
834 + * Every interrupt can have up to 32 causes and the interrupt model supports
835 + * masking/unmasking each cause independently
837 + * Return: '0' on Success; Error code otherwise.
839 +int dpcon_set_irq_mask(struct fsl_mc_io *mc_io,
840 + uint32_t cmd_flags,
846 + * dpcon_get_irq_mask() - Get interrupt mask.
847 + * @mc_io: Pointer to MC portal's I/O object
848 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
849 + * @token: Token of DPCON object
850 + * @irq_index: The interrupt index to configure
851 + * @mask: Returned event mask to trigger interrupt
853 + * Every interrupt can have up to 32 causes and the interrupt model supports
854 + * masking/unmasking each cause independently
856 + * Return: '0' on Success; Error code otherwise.
858 +int dpcon_get_irq_mask(struct fsl_mc_io *mc_io,
859 + uint32_t cmd_flags,
865 + * dpcon_get_irq_status() - Get the current status of any pending interrupts.
866 + * @mc_io: Pointer to MC portal's I/O object
867 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
868 + * @token: Token of DPCON object
869 + * @irq_index: The interrupt index to configure
870 + * @status: interrupts status - one bit per cause:
871 + * 0 = no interrupt pending
872 + * 1 = interrupt pending
874 + * Return: '0' on Success; Error code otherwise.
876 +int dpcon_get_irq_status(struct fsl_mc_io *mc_io,
877 + uint32_t cmd_flags,
883 + * dpcon_clear_irq_status() - Clear a pending interrupt's status
884 + * @mc_io: Pointer to MC portal's I/O object
885 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
886 + * @token: Token of DPCON object
887 + * @irq_index: The interrupt index to configure
888 + * @status: bits to clear (W1C) - one bit per cause:
890 + * 1 = clear status bit
892 + * Return: '0' on Success; Error code otherwise.
894 +int dpcon_clear_irq_status(struct fsl_mc_io *mc_io,
895 + uint32_t cmd_flags,
901 + * struct dpcon_attr - Structure representing DPCON attributes
902 + * @id: DPCON object ID
903 + * @version: DPCON version
904 + * @qbman_ch_id: Channel ID to be used by dequeue operation
905 + * @num_priorities: Number of priorities for the DPCON channel (1-8)
910 + * struct version - DPCON version
911 + * @major: DPCON major version
912 + * @minor: DPCON minor version
918 + uint16_t qbman_ch_id;
919 + uint8_t num_priorities;
923 + * dpcon_get_attributes() - Retrieve DPCON attributes.
924 + * @mc_io: Pointer to MC portal's I/O object
925 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
926 + * @token: Token of DPCON object
927 + * @attr: Object's attributes
929 + * Return: '0' on Success; Error code otherwise.
931 +int dpcon_get_attributes(struct fsl_mc_io *mc_io,
932 + uint32_t cmd_flags,
934 + struct dpcon_attr *attr);
937 + * struct dpcon_notification_cfg - Structure representing notification parameters
938 + * @dpio_id: DPIO object ID; must be configured with a notification channel;
939 + * to disable notifications set it to 'DPCON_INVALID_DPIO_ID';
940 + * @priority: Priority selection within the DPIO channel; valid values
941 + * are 0-7, depending on the number of priorities in that channel
942 + * @user_ctx: User context value provided with each CDAN message
944 +struct dpcon_notification_cfg {
951 + * dpcon_set_notification() - Set DPCON notification destination
952 + * @mc_io: Pointer to MC portal's I/O object
953 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
954 + * @token: Token of DPCON object
955 + * @cfg: Notification parameters
957 + * Return: '0' on Success; Error code otherwise
959 +int dpcon_set_notification(struct fsl_mc_io *mc_io,
960 + uint32_t cmd_flags,
962 + struct dpcon_notification_cfg *cfg);
964 +#endif /* __FSL_DPCON_H */