1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * Copyright 2013-2016 Freescale Semiconductor, Inc.
4 * Copyright 2017, 2023 NXP
11 #define DPIO_VER_MAJOR 4
12 #define DPIO_VER_MINOR 2
15 #define DPIO_CMDID_CLOSE 0x8001
16 #define DPIO_CMDID_OPEN 0x8031
17 #define DPIO_CMDID_CREATE 0x9031
18 #define DPIO_CMDID_DESTROY 0x9831
19 #define DPIO_CMDID_GET_API_VERSION 0xa031
21 #define DPIO_CMDID_ENABLE 0x0021
22 #define DPIO_CMDID_DISABLE 0x0031
23 #define DPIO_CMDID_GET_ATTR 0x0041
25 /* Macros for accessing command fields smaller than 1byte */
26 #define DPIO_MASK(field) \
27 GENMASK(DPIO_##field##_SHIFT + DPIO_##field##_SIZE - 1, \
29 #define dpio_set_field(var, field, val) \
30 ((var) |= (((val) << DPIO_##field##_SHIFT) & DPIO_MASK(field)))
31 #define dpio_get_field(var, field) \
32 (((var) & DPIO_MASK(field)) >> DPIO_##field##_SHIFT)
35 struct dpio_cmd_open
{
39 #define DPIO_CHANNEL_MODE_SHIFT 0
40 #define DPIO_CHANNEL_MODE_SIZE 2
42 struct dpio_cmd_create
{
44 /* from LSB: channel_mode:2 */
50 struct dpio_cmd_destroy
{
54 #define DPIO_ATTR_CHANNEL_MODE_SHIFT 0
55 #define DPIO_ATTR_CHANNEL_MODE_SIZE 4
57 struct dpio_rsp_get_attr
{
59 __le16 qbman_portal_id
;
61 /* from LSB: channel_mode:4 */
63 __le64 qbman_portal_ce_offset
;
64 __le64 qbman_portal_ci_offset
;
72 /* Data Path I/O Portal API
73 * Contains initialization APIs and runtime control APIs for DPIO
78 int dpio_open(struct fsl_mc_io
*mc_io
, u32 cmd_flags
, int dpio_id
,
81 int dpio_close(struct fsl_mc_io
*mc_io
, u32 cmd_flags
, u16 token
);
84 * enum dpio_channel_mode - DPIO notification channel mode
85 * @DPIO_NO_CHANNEL: No support for notification channel
86 * @DPIO_LOCAL_CHANNEL: Notifications on data availability can be received by a
87 * dedicated channel in the DPIO; user should point the queue's
88 * destination in the relevant interface to this DPIO
90 enum dpio_channel_mode
{
92 DPIO_LOCAL_CHANNEL
= 1,
96 * struct dpio_cfg - Structure representing DPIO configuration
97 * @channel_mode: Notification channel mode
98 * @num_priorities: Number of priorities for the notification channel (1-8);
99 * relevant only if 'channel_mode = DPIO_LOCAL_CHANNEL'
102 enum dpio_channel_mode channel_mode
;
106 int dpio_create(struct fsl_mc_io
*mc_io
, u16 dprc_token
, u32 cmd_flags
,
107 const struct dpio_cfg
*cfg
, u32
*obj_id
);
109 int dpio_destroy(struct fsl_mc_io
*mc_io
, u16 dprc_token
, u32 cmd_flags
,
112 int dpio_enable(struct fsl_mc_io
*mc_io
, u32 cmd_flags
, u16 token
);
114 int dpio_disable(struct fsl_mc_io
*mc_io
, u32 cmd_flags
, u16 token
);
117 * struct dpio_attr - Structure representing DPIO attributes
118 * @id: DPIO object ID
119 * @qbman_portal_ce_offset: Offset of the software portal cache-enabled area
120 * @qbman_portal_ci_offset: Offset of the software portal
121 * cache-inhibited area
122 * @qbman_portal_id: Software portal ID
123 * @channel_mode: Notification channel mode
124 * @num_priorities: Number of priorities for the notification
125 * channel (1-8); relevant only if
126 * 'channel_mode = DPIO_LOCAL_CHANNEL'
127 * @qbman_version: QBMAN version
131 u64 qbman_portal_ce_offset
;
132 u64 qbman_portal_ci_offset
;
134 enum dpio_channel_mode channel_mode
;
140 int dpio_get_attributes(struct fsl_mc_io
*mc_io
, u32 cmd_flags
, u16 token
,
141 struct dpio_attr
*attr
);
143 int dpio_get_api_version(struct fsl_mc_io
*mc_io
, u32 cmd_flags
,
144 u16
*major_ver
, u16
*minor_ver
);
145 #endif /* _FSL_DPIO_H */