^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /* Copyright 2019 NXP */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) #ifndef __FSL_DPDMAI_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #define __FSL_DPDMAI_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) /* DPDMAI Version */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #define DPDMAI_VER_MAJOR 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #define DPDMAI_VER_MINOR 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #define DPDMAI_CMD_BASE_VERSION 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #define DPDMAI_CMD_ID_OFFSET 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #define DPDMAI_CMDID_FORMAT(x) (((x) << DPDMAI_CMD_ID_OFFSET) | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) DPDMAI_CMD_BASE_VERSION)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) /* Command IDs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #define DPDMAI_CMDID_CLOSE DPDMAI_CMDID_FORMAT(0x800)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #define DPDMAI_CMDID_OPEN DPDMAI_CMDID_FORMAT(0x80E)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #define DPDMAI_CMDID_CREATE DPDMAI_CMDID_FORMAT(0x90E)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #define DPDMAI_CMDID_DESTROY DPDMAI_CMDID_FORMAT(0x900)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #define DPDMAI_CMDID_ENABLE DPDMAI_CMDID_FORMAT(0x002)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #define DPDMAI_CMDID_DISABLE DPDMAI_CMDID_FORMAT(0x003)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #define DPDMAI_CMDID_GET_ATTR DPDMAI_CMDID_FORMAT(0x004)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #define DPDMAI_CMDID_RESET DPDMAI_CMDID_FORMAT(0x005)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #define DPDMAI_CMDID_IS_ENABLED DPDMAI_CMDID_FORMAT(0x006)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #define DPDMAI_CMDID_SET_IRQ DPDMAI_CMDID_FORMAT(0x010)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #define DPDMAI_CMDID_GET_IRQ DPDMAI_CMDID_FORMAT(0x011)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) #define DPDMAI_CMDID_SET_IRQ_ENABLE DPDMAI_CMDID_FORMAT(0x012)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) #define DPDMAI_CMDID_GET_IRQ_ENABLE DPDMAI_CMDID_FORMAT(0x013)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) #define DPDMAI_CMDID_SET_IRQ_MASK DPDMAI_CMDID_FORMAT(0x014)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) #define DPDMAI_CMDID_GET_IRQ_MASK DPDMAI_CMDID_FORMAT(0x015)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) #define DPDMAI_CMDID_GET_IRQ_STATUS DPDMAI_CMDID_FORMAT(0x016)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) #define DPDMAI_CMDID_CLEAR_IRQ_STATUS DPDMAI_CMDID_FORMAT(0x017)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) #define DPDMAI_CMDID_SET_RX_QUEUE DPDMAI_CMDID_FORMAT(0x1A0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) #define DPDMAI_CMDID_GET_RX_QUEUE DPDMAI_CMDID_FORMAT(0x1A1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) #define DPDMAI_CMDID_GET_TX_QUEUE DPDMAI_CMDID_FORMAT(0x1A2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) #define MC_CMD_HDR_TOKEN_O 32 /* Token field offset */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) #define MC_CMD_HDR_TOKEN_S 16 /* Token field size */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) #define MAKE_UMASK64(_width) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) ((u64)((_width) < 64 ? ((u64)1 << (_width)) - 1 : (u64)-1))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) /* Data Path DMA Interface API
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) * Contains initialization APIs and runtime control APIs for DPDMAI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) * Maximum number of Tx/Rx priorities per DPDMAI object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) #define DPDMAI_PRIO_NUM 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) /* DPDMAI queue modification options */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) * Select to modify the user's context associated with the queue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) #define DPDMAI_QUEUE_OPT_USER_CTX 0x1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) * Select to modify the queue's destination
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) #define DPDMAI_QUEUE_OPT_DEST 0x2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) * struct dpdmai_cfg - Structure representing DPDMAI configuration
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) * @priorities: Priorities for the DMA hardware processing; valid priorities are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) * configured with values 1-8; the entry following last valid entry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) * should be configured with 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) struct dpdmai_cfg {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) u8 priorities[DPDMAI_PRIO_NUM];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) * struct dpdmai_attr - Structure representing DPDMAI attributes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) * @id: DPDMAI object ID
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) * @version: DPDMAI version
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) * @num_of_priorities: number of priorities
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) struct dpdmai_attr {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) int id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) * struct version - DPDMAI version
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) * @major: DPDMAI major version
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) * @minor: DPDMAI minor version
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) u16 major;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) u16 minor;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) } version;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) u8 num_of_priorities;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) * enum dpdmai_dest - DPDMAI destination types
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) * @DPDMAI_DEST_NONE: Unassigned destination; The queue is set in parked mode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) * and does not generate FQDAN notifications; user is expected to dequeue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) * from the queue based on polling or other user-defined method
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) * @DPDMAI_DEST_DPIO: The queue is set in schedule mode and generates FQDAN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) * notifications to the specified DPIO; user is expected to dequeue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) * from the queue only after notification is received
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) * @DPDMAI_DEST_DPCON: The queue is set in schedule mode and does not generate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) * FQDAN notifications, but is connected to the specified DPCON object;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) * user is expected to dequeue from the DPCON channel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) enum dpdmai_dest {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) DPDMAI_DEST_NONE = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) DPDMAI_DEST_DPIO = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) DPDMAI_DEST_DPCON = 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) * struct dpdmai_dest_cfg - Structure representing DPDMAI destination parameters
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) * @dest_type: Destination type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) * @dest_id: Either DPIO ID or DPCON ID, depending on the destination type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) * @priority: Priority selection within the DPIO or DPCON channel; valid values
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) * are 0-1 or 0-7, depending on the number of priorities in that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) * channel; not relevant for 'DPDMAI_DEST_NONE' option
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) struct dpdmai_dest_cfg {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) enum dpdmai_dest dest_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) int dest_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) u8 priority;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) * struct dpdmai_rx_queue_cfg - DPDMAI RX queue configuration
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) * @options: Flags representing the suggested modifications to the queue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) * Use any combination of 'DPDMAI_QUEUE_OPT_<X>' flags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) * @user_ctx: User context value provided in the frame descriptor of each
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) * dequeued frame;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) * valid only if 'DPDMAI_QUEUE_OPT_USER_CTX' is contained in 'options'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) * @dest_cfg: Queue destination parameters;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) * valid only if 'DPDMAI_QUEUE_OPT_DEST' is contained in 'options'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) struct dpdmai_rx_queue_cfg {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) struct dpdmai_dest_cfg dest_cfg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) u32 options;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) u64 user_ctx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) * struct dpdmai_rx_queue_attr - Structure representing attributes of Rx queues
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) * @user_ctx: User context value provided in the frame descriptor of each
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) * dequeued frame
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) * @dest_cfg: Queue destination configuration
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) * @fqid: Virtual FQID value to be used for dequeue operations
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) struct dpdmai_rx_queue_attr {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) struct dpdmai_dest_cfg dest_cfg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) u64 user_ctx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) u32 fqid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) int dpdmai_open(struct fsl_mc_io *mc_io, u32 cmd_flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) int dpdmai_id, u16 *token);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) int dpdmai_close(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) int dpdmai_destroy(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) int dpdmai_create(struct fsl_mc_io *mc_io, u32 cmd_flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) const struct dpdmai_cfg *cfg, u16 *token);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) int dpdmai_enable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) int dpdmai_disable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) int dpdmai_reset(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) int dpdmai_get_attributes(struct fsl_mc_io *mc_io, u32 cmd_flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) u16 token, struct dpdmai_attr *attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) int dpdmai_set_rx_queue(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) u8 priority, const struct dpdmai_rx_queue_cfg *cfg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) int dpdmai_get_rx_queue(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) u8 priority, struct dpdmai_rx_queue_attr *attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) int dpdmai_get_tx_queue(struct fsl_mc_io *mc_io, u32 cmd_flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) u16 token, u8 priority, u32 *fqid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) #endif /* __FSL_DPDMAI_H */