blob: 375590fd9751cc1614cbcf6a392d0f70ca87e94d [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -07002/*
Yogesh Gaura6f2a6e2018-05-09 10:52:17 +05303 * Copyright 2013-2016 Freescale Semiconductor, Inc.
Ioana Ciornei0aebee72023-05-31 19:04:35 +03004 * Copyright 2017, 2023 NXP
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -07005 */
6
7#ifndef _FSL_DPIO_H
8#define _FSL_DPIO_H
9
10/* DPIO Version */
Yogesh Gaur2557c5a2017-11-15 11:59:31 +053011#define DPIO_VER_MAJOR 4
Prabhakar Kushwaha53e353f2015-12-24 15:32:49 +053012#define DPIO_VER_MINOR 2
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -070013
14/* Command IDs */
Yogesh Gaur2557c5a2017-11-15 11:59:31 +053015#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 Kushwahaa2a55e52015-03-19 09:20:45 -070020
Yogesh Gaur2557c5a2017-11-15 11:59:31 +053021#define DPIO_CMDID_ENABLE 0x0021
22#define DPIO_CMDID_DISABLE 0x0031
23#define DPIO_CMDID_GET_ATTR 0x0041
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -070024
Ioana Ciornei0aebee72023-05-31 19:04:35 +030025/* 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 Kushwahaa2a55e52015-03-19 09:20:45 -070033
Ioana Ciornei0aebee72023-05-31 19:04:35 +030034#pragma pack(push, 1)
35struct dpio_cmd_open {
36 __le32 dpio_id;
37};
Prabhakar Kushwaha1ebbe4f2015-11-04 12:25:53 +053038
Ioana Ciornei0aebee72023-05-31 19:04:35 +030039#define DPIO_CHANNEL_MODE_SHIFT 0
40#define DPIO_CHANNEL_MODE_SIZE 2
41
42struct 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
50struct 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
57struct 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 Kushwahaa2a55e52015-03-19 09:20:45 -070071
72/* Data Path I/O Portal API
73 * Contains initialization APIs and runtime control APIs for DPIO
74 */
75
76struct fsl_mc_io;
Prabhakar Kushwaha1f1c25c2015-07-02 11:28:59 +053077
Ioana Ciornei0aebee72023-05-31 19:04:35 +030078int dpio_open(struct fsl_mc_io *mc_io, u32 cmd_flags, int dpio_id,
79 u16 *token);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -070080
Ioana Ciornei0aebee72023-05-31 19:04:35 +030081int dpio_close(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -070082
83/**
84 * enum dpio_channel_mode - DPIO notification channel mode
Ioana Ciornei0aebee72023-05-31 19:04:35 +030085 * @DPIO_NO_CHANNEL: No support for notification channel
86 * @DPIO_LOCAL_CHANNEL: Notifications on data availability can be received by a
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -070087 * dedicated channel in the DPIO; user should point the queue's
88 * destination in the relevant interface to this DPIO
89 */
90enum dpio_channel_mode {
91 DPIO_NO_CHANNEL = 0,
92 DPIO_LOCAL_CHANNEL = 1,
93};
94
95/**
Prabhakar Kushwaha1ebbe4f2015-11-04 12:25:53 +053096 * struct dpio_cfg - Structure representing DPIO configuration
Ioana Ciornei0aebee72023-05-31 19:04:35 +030097 * @channel_mode: Notification channel mode
98 * @num_priorities: Number of priorities for the notification channel (1-8);
Prabhakar Kushwaha1ebbe4f2015-11-04 12:25:53 +053099 * relevant only if 'channel_mode = DPIO_LOCAL_CHANNEL'
100 */
101struct dpio_cfg {
Ioana Ciornei0aebee72023-05-31 19:04:35 +0300102 enum dpio_channel_mode channel_mode;
103 u8 num_priorities;
Prabhakar Kushwaha1ebbe4f2015-11-04 12:25:53 +0530104};
105
Ioana Ciornei0aebee72023-05-31 19:04:35 +0300106int dpio_create(struct fsl_mc_io *mc_io, u16 dprc_token, u32 cmd_flags,
107 const struct dpio_cfg *cfg, u32 *obj_id);
Prabhakar Kushwaha1ebbe4f2015-11-04 12:25:53 +0530108
Ioana Ciornei0aebee72023-05-31 19:04:35 +0300109int dpio_destroy(struct fsl_mc_io *mc_io, u16 dprc_token, u32 cmd_flags,
110 u32 object_id);
Prabhakar Kushwaha1ebbe4f2015-11-04 12:25:53 +0530111
Ioana Ciornei0aebee72023-05-31 19:04:35 +0300112int dpio_enable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700113
Ioana Ciornei0aebee72023-05-31 19:04:35 +0300114int dpio_disable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700115
116/**
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700117 * struct dpio_attr - Structure representing DPIO attributes
Ioana Ciornei0aebee72023-05-31 19:04:35 +0300118 * @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 Kushwahaa2a55e52015-03-19 09:20:45 -0700128 */
129struct dpio_attr {
Ioana Ciornei0aebee72023-05-31 19:04:35 +0300130 int id;
131 u64 qbman_portal_ce_offset;
132 u64 qbman_portal_ci_offset;
133 u16 qbman_portal_id;
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700134 enum dpio_channel_mode channel_mode;
Ioana Ciornei0aebee72023-05-31 19:04:35 +0300135 u8 num_priorities;
136 u32 qbman_version;
137 u32 clk;
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700138};
139
Ioana Ciornei0aebee72023-05-31 19:04:35 +0300140int dpio_get_attributes(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
141 struct dpio_attr *attr);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700142
Ioana Ciornei0aebee72023-05-31 19:04:35 +0300143int dpio_get_api_version(struct fsl_mc_io *mc_io, u32 cmd_flags,
144 u16 *major_ver, u16 *minor_ver);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700145#endif /* _FSL_DPIO_H */