]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - include/fsl-mc/fsl_dpio.h
driver/fsl-mc: Add support of MC Flibs
[karo-tx-uboot.git] / include / fsl-mc / fsl_dpio.h
1 /*
2  * Copyright (C) 2013-2015 Freescale Semiconductor
3  *
4  * SPDX-License-Identifier:     GPL-2.0+
5  */
6
7 #ifndef _FSL_DPIO_H
8 #define _FSL_DPIO_H
9
10 /* DPIO Version */
11 #define DPIO_VER_MAJOR                          2
12 #define DPIO_VER_MINOR                          1
13
14 /* Command IDs */
15 #define DPIO_CMDID_CLOSE                                        0x800
16 #define DPIO_CMDID_OPEN                                         0x803
17
18 #define DPIO_CMDID_ENABLE                                       0x002
19 #define DPIO_CMDID_DISABLE                                      0x003
20 #define DPIO_CMDID_GET_ATTR                                     0x004
21 #define DPIO_CMDID_RESET                                        0x005
22
23 /*                cmd, param, offset, width, type, arg_name */
24 #define DPIO_CMD_OPEN(cmd, dpio_id) \
25         MC_CMD_OP(cmd, 0, 0,  32, int,     dpio_id)
26
27 /*                cmd, param, offset, width, type, arg_name */
28 #define DPIO_RSP_GET_ATTR(cmd, attr) \
29 do { \
30         MC_RSP_OP(cmd, 0, 0,  32, int,      attr->id);\
31         MC_RSP_OP(cmd, 0, 32, 16, uint16_t, attr->qbman_portal_id);\
32         MC_RSP_OP(cmd, 0, 48, 8,  uint8_t,  attr->num_priorities);\
33         MC_RSP_OP(cmd, 0, 56, 4,  enum dpio_channel_mode, attr->channel_mode);\
34         MC_RSP_OP(cmd, 1, 0,  64, uint64_t, attr->qbman_portal_ce_paddr);\
35         MC_RSP_OP(cmd, 2, 0,  64, uint64_t, attr->qbman_portal_ci_paddr);\
36         MC_RSP_OP(cmd, 3, 0,  16, uint16_t, attr->version.major);\
37         MC_RSP_OP(cmd, 3, 16, 16, uint16_t, attr->version.minor);\
38 } while (0)
39
40 /* Data Path I/O Portal API
41  * Contains initialization APIs and runtime control APIs for DPIO
42  */
43
44 struct fsl_mc_io;
45 /**
46  * dpio_open() - Open a control session for the specified object
47  * @mc_io:      Pointer to MC portal's I/O object
48  * @dpio_id:    DPIO unique ID
49  * @token:      Returned token; use in subsequent API calls
50  *
51  * This function can be used to open a control session for an
52  * already created object; an object may have been declared in
53  * the DPL or by calling the dpio_create() function.
54  * This function returns a unique authentication token,
55  * associated with the specific object ID and the specific MC
56  * portal; this token must be used in all subsequent commands for
57  * this specific object.
58  *
59  * Return:      '0' on Success; Error code otherwise.
60  */
61 int dpio_open(struct fsl_mc_io *mc_io, int dpio_id, uint16_t *token);
62
63 /**
64  * dpio_open() - Open a control session for the specified object
65  * @mc_io:      Pointer to MC portal's I/O object
66  * @dpio_id:    DPIO unique ID
67  * @token:      Returned token; use in subsequent API calls
68  *
69  * This function can be used to open a control session for an
70  * already created object; an object may have been declared in
71  * the DPL or by calling the dpio_create() function.
72  * This function returns a unique authentication token,
73  * associated with the specific object ID and the specific MC
74  * portal; this token must be used in all subsequent commands for
75  * this specific object.
76  *
77  * Return:      '0' on Success; Error code otherwise.
78  */
79 int dpio_close(struct fsl_mc_io *mc_io, uint16_t token);
80
81 /**
82  * enum dpio_channel_mode - DPIO notification channel mode
83  * @DPIO_NO_CHANNEL: No support for notification channel
84  * @DPIO_LOCAL_CHANNEL: Notifications on data availability can be received by a
85  *      dedicated channel in the DPIO; user should point the queue's
86  *      destination in the relevant interface to this DPIO
87  */
88 enum dpio_channel_mode {
89         DPIO_NO_CHANNEL = 0,
90         DPIO_LOCAL_CHANNEL = 1,
91 };
92
93 /**
94  * dpio_enable() - Enable the DPIO, allow I/O portal operations.
95  * @mc_io:      Pointer to MC portal's I/O object
96  * @token:      Token of DPIO object
97  *
98  * Return:      '0' on Success; Error code otherwise
99  */
100 int dpio_enable(struct fsl_mc_io *mc_io, uint16_t token);
101
102 /**
103  * dpio_disable() - Disable the DPIO, stop any I/O portal operation.
104  * @mc_io:      Pointer to MC portal's I/O object
105  * @token:      Token of DPIO object
106  *
107  * Return:      '0' on Success; Error code otherwise
108  */
109 int dpio_disable(struct fsl_mc_io *mc_io, uint16_t token);
110
111 /**
112  * dpio_reset() - Reset the DPIO, returns the object to initial state.
113  * @mc_io:      Pointer to MC portal's I/O object
114  * @token:      Token of DPIO object
115  *
116  * Return:      '0' on Success; Error code otherwise.
117  */
118 int dpio_reset(struct fsl_mc_io *mc_io, uint16_t token);
119
120 /**
121  * struct dpio_attr - Structure representing DPIO attributes
122  * @id: DPIO object ID
123  * @version: DPIO version
124  * @qbman_portal_ce_paddr: Physical address of the software portal
125  *                              cache-enabled area
126  * @qbman_portal_ci_paddr: Physical address of the software portal
127  *                              cache-inhibited area
128  * @qbman_portal_id: Software portal ID
129  * @channel_mode: Notification channel mode
130  * @num_priorities: Number of priorities for the notification channel (1-8);
131  *                      relevant only if 'channel_mode = DPIO_LOCAL_CHANNEL'
132  */
133 struct dpio_attr {
134         int id;
135         /**
136          * struct version - DPIO version
137          * @major: DPIO major version
138          * @minor: DPIO minor version
139          */
140         struct {
141                 uint16_t major;
142                 uint16_t minor;
143         } version;
144         uint64_t qbman_portal_ce_paddr;
145         uint64_t qbman_portal_ci_paddr;
146         uint16_t qbman_portal_id;
147         enum dpio_channel_mode channel_mode;
148         uint8_t num_priorities;
149 };
150
151 /**
152  * dpio_get_attributes() - Retrieve DPIO attributes
153  * @mc_io:      Pointer to MC portal's I/O object
154  * @token:      Token of DPIO object
155  * @attr:       Returned object's attributes
156  *
157  * Return:      '0' on Success; Error code otherwise
158  */
159 int dpio_get_attributes(struct fsl_mc_io        *mc_io,
160                         uint16_t                token,
161                         struct dpio_attr        *attr);
162
163 #endif /* _FSL_DPIO_H */