Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 2 | /* |
Yogesh Gaur | a6f2a6e | 2018-05-09 10:52:17 +0530 | [diff] [blame] | 3 | * Copyright 2013-2016 Freescale Semiconductor, Inc. |
Ioana Ciornei | 0aebee7 | 2023-05-31 19:04:35 +0300 | [diff] [blame] | 4 | * Copyright 2017, 2023 NXP |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #ifndef _FSL_DPIO_H |
| 8 | #define _FSL_DPIO_H |
| 9 | |
| 10 | /* DPIO Version */ |
Yogesh Gaur | 2557c5a | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 11 | #define DPIO_VER_MAJOR 4 |
Prabhakar Kushwaha | 53e353f | 2015-12-24 15:32:49 +0530 | [diff] [blame] | 12 | #define DPIO_VER_MINOR 2 |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 13 | |
| 14 | /* Command IDs */ |
Yogesh Gaur | 2557c5a | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 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 |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 20 | |
Yogesh Gaur | 2557c5a | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 21 | #define DPIO_CMDID_ENABLE 0x0021 |
| 22 | #define DPIO_CMDID_DISABLE 0x0031 |
| 23 | #define DPIO_CMDID_GET_ATTR 0x0041 |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 24 | |
Ioana Ciornei | 0aebee7 | 2023-05-31 19:04:35 +0300 | [diff] [blame] | 25 | /* Macros for accessing command fields smaller than 1byte */ |
| 26 | #define DPIO_MASK(field) \ |
| 27 | GENMASK(DPIO_##field##_SHIFT + DPIO_##field##_SIZE - 1, \ |
| 28 | DPIO_##field##_SHIFT) |
| 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) |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 33 | |
Ioana Ciornei | 0aebee7 | 2023-05-31 19:04:35 +0300 | [diff] [blame] | 34 | #pragma pack(push, 1) |
| 35 | struct dpio_cmd_open { |
| 36 | __le32 dpio_id; |
| 37 | }; |
Prabhakar Kushwaha | 1ebbe4f | 2015-11-04 12:25:53 +0530 | [diff] [blame] | 38 | |
Ioana Ciornei | 0aebee7 | 2023-05-31 19:04:35 +0300 | [diff] [blame] | 39 | #define DPIO_CHANNEL_MODE_SHIFT 0 |
| 40 | #define DPIO_CHANNEL_MODE_SIZE 2 |
| 41 | |
| 42 | struct dpio_cmd_create { |
| 43 | __le16 pad1; |
| 44 | /* from LSB: channel_mode:2 */ |
| 45 | u8 channel_mode; |
| 46 | u8 pad2; |
| 47 | u8 num_priorities; |
| 48 | }; |
| 49 | |
| 50 | struct dpio_cmd_destroy { |
| 51 | __le32 dpio_id; |
| 52 | }; |
| 53 | |
| 54 | #define DPIO_ATTR_CHANNEL_MODE_SHIFT 0 |
| 55 | #define DPIO_ATTR_CHANNEL_MODE_SIZE 4 |
| 56 | |
| 57 | struct dpio_rsp_get_attr { |
| 58 | __le32 id; |
| 59 | __le16 qbman_portal_id; |
| 60 | u8 num_priorities; |
| 61 | /* from LSB: channel_mode:4 */ |
| 62 | u8 channel_mode; |
| 63 | __le64 qbman_portal_ce_offset; |
| 64 | __le64 qbman_portal_ci_offset; |
| 65 | __le32 qbman_version; |
| 66 | __le32 pad; |
| 67 | __le32 clk; |
| 68 | }; |
| 69 | |
| 70 | #pragma pack(pop) |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 71 | |
| 72 | /* Data Path I/O Portal API |
| 73 | * Contains initialization APIs and runtime control APIs for DPIO |
| 74 | */ |
| 75 | |
| 76 | struct fsl_mc_io; |
Prabhakar Kushwaha | 1f1c25c | 2015-07-02 11:28:59 +0530 | [diff] [blame] | 77 | |
Ioana Ciornei | 0aebee7 | 2023-05-31 19:04:35 +0300 | [diff] [blame] | 78 | int dpio_open(struct fsl_mc_io *mc_io, u32 cmd_flags, int dpio_id, |
| 79 | u16 *token); |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 80 | |
Ioana Ciornei | 0aebee7 | 2023-05-31 19:04:35 +0300 | [diff] [blame] | 81 | int dpio_close(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token); |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 82 | |
| 83 | /** |
| 84 | * enum dpio_channel_mode - DPIO notification channel mode |
Ioana Ciornei | 0aebee7 | 2023-05-31 19:04:35 +0300 | [diff] [blame] | 85 | * @DPIO_NO_CHANNEL: No support for notification channel |
| 86 | * @DPIO_LOCAL_CHANNEL: Notifications on data availability can be received by a |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 87 | * dedicated channel in the DPIO; user should point the queue's |
| 88 | * destination in the relevant interface to this DPIO |
| 89 | */ |
| 90 | enum dpio_channel_mode { |
| 91 | DPIO_NO_CHANNEL = 0, |
| 92 | DPIO_LOCAL_CHANNEL = 1, |
| 93 | }; |
| 94 | |
| 95 | /** |
Prabhakar Kushwaha | 1ebbe4f | 2015-11-04 12:25:53 +0530 | [diff] [blame] | 96 | * struct dpio_cfg - Structure representing DPIO configuration |
Ioana Ciornei | 0aebee7 | 2023-05-31 19:04:35 +0300 | [diff] [blame] | 97 | * @channel_mode: Notification channel mode |
| 98 | * @num_priorities: Number of priorities for the notification channel (1-8); |
Prabhakar Kushwaha | 1ebbe4f | 2015-11-04 12:25:53 +0530 | [diff] [blame] | 99 | * relevant only if 'channel_mode = DPIO_LOCAL_CHANNEL' |
| 100 | */ |
| 101 | struct dpio_cfg { |
Ioana Ciornei | 0aebee7 | 2023-05-31 19:04:35 +0300 | [diff] [blame] | 102 | enum dpio_channel_mode channel_mode; |
| 103 | u8 num_priorities; |
Prabhakar Kushwaha | 1ebbe4f | 2015-11-04 12:25:53 +0530 | [diff] [blame] | 104 | }; |
| 105 | |
Ioana Ciornei | 0aebee7 | 2023-05-31 19:04:35 +0300 | [diff] [blame] | 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); |
Prabhakar Kushwaha | 1ebbe4f | 2015-11-04 12:25:53 +0530 | [diff] [blame] | 108 | |
Ioana Ciornei | 0aebee7 | 2023-05-31 19:04:35 +0300 | [diff] [blame] | 109 | int dpio_destroy(struct fsl_mc_io *mc_io, u16 dprc_token, u32 cmd_flags, |
| 110 | u32 object_id); |
Prabhakar Kushwaha | 1ebbe4f | 2015-11-04 12:25:53 +0530 | [diff] [blame] | 111 | |
Ioana Ciornei | 0aebee7 | 2023-05-31 19:04:35 +0300 | [diff] [blame] | 112 | int dpio_enable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token); |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 113 | |
Ioana Ciornei | 0aebee7 | 2023-05-31 19:04:35 +0300 | [diff] [blame] | 114 | int dpio_disable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token); |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 115 | |
| 116 | /** |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 117 | * struct dpio_attr - Structure representing DPIO attributes |
Ioana Ciornei | 0aebee7 | 2023-05-31 19:04:35 +0300 | [diff] [blame] | 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 |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 128 | */ |
| 129 | struct dpio_attr { |
Ioana Ciornei | 0aebee7 | 2023-05-31 19:04:35 +0300 | [diff] [blame] | 130 | int id; |
| 131 | u64 qbman_portal_ce_offset; |
| 132 | u64 qbman_portal_ci_offset; |
| 133 | u16 qbman_portal_id; |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 134 | enum dpio_channel_mode channel_mode; |
Ioana Ciornei | 0aebee7 | 2023-05-31 19:04:35 +0300 | [diff] [blame] | 135 | u8 num_priorities; |
| 136 | u32 qbman_version; |
| 137 | u32 clk; |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 138 | }; |
| 139 | |
Ioana Ciornei | 0aebee7 | 2023-05-31 19:04:35 +0300 | [diff] [blame] | 140 | int dpio_get_attributes(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, |
| 141 | struct dpio_attr *attr); |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 142 | |
Ioana Ciornei | 0aebee7 | 2023-05-31 19:04:35 +0300 | [diff] [blame] | 143 | int dpio_get_api_version(struct fsl_mc_io *mc_io, u32 cmd_flags, |
| 144 | u16 *major_ver, u16 *minor_ver); |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 145 | #endif /* _FSL_DPIO_H */ |