GNU Linux-libre 4.14.295-gnu1
[releases.git] / drivers / staging / fsl-mc / include / dpcon.h
1 /* Copyright 2013-2016 Freescale Semiconductor Inc.
2  *
3  * Redistribution and use in source and binary forms, with or without
4  * modification, are permitted provided that the following conditions are met:
5  * * Redistributions of source code must retain the above copyright
6  * notice, this list of conditions and the following disclaimer.
7  * * Redistributions in binary form must reproduce the above copyright
8  * notice, this list of conditions and the following disclaimer in the
9  * documentation and/or other materials provided with the distribution.
10  * * Neither the name of the above-listed copyright holders nor the
11  * names of any contributors may be used to endorse or promote products
12  * derived from this software without specific prior written permission.
13  *
14  *
15  * ALTERNATIVELY, this software may be distributed under the terms of the
16  * GNU General Public License ("GPL") as published by the Free Software
17  * Foundation, either version 2 of that License or (at your option) any
18  * later version.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
24  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30  * POSSIBILITY OF SUCH DAMAGE.
31  */
32 #ifndef __FSL_DPCON_H
33 #define __FSL_DPCON_H
34
35 /* Data Path Concentrator API
36  * Contains initialization APIs and runtime control APIs for DPCON
37  */
38
39 struct fsl_mc_io;
40
41 /** General DPCON macros */
42
43 /**
44  * Use it to disable notifications; see dpcon_set_notification()
45  */
46 #define DPCON_INVALID_DPIO_ID           (int)(-1)
47
48 int dpcon_open(struct fsl_mc_io *mc_io,
49                u32 cmd_flags,
50                int dpcon_id,
51                u16 *token);
52
53 int dpcon_close(struct fsl_mc_io *mc_io,
54                 u32 cmd_flags,
55                 u16 token);
56
57 int dpcon_enable(struct fsl_mc_io *mc_io,
58                  u32 cmd_flags,
59                  u16 token);
60
61 int dpcon_disable(struct fsl_mc_io *mc_io,
62                   u32 cmd_flags,
63                   u16 token);
64
65 int dpcon_is_enabled(struct fsl_mc_io *mc_io,
66                      u32 cmd_flags,
67                      u16 token,
68                      int *en);
69
70 int dpcon_reset(struct fsl_mc_io *mc_io,
71                 u32 cmd_flags,
72                 u16 token);
73
74 /**
75  * struct dpcon_attr - Structure representing DPCON attributes
76  * @id: DPCON object ID
77  * @qbman_ch_id: Channel ID to be used by dequeue operation
78  * @num_priorities: Number of priorities for the DPCON channel (1-8)
79  */
80 struct dpcon_attr {
81         int id;
82         u16 qbman_ch_id;
83         u8 num_priorities;
84 };
85
86 int dpcon_get_attributes(struct fsl_mc_io *mc_io,
87                          u32 cmd_flags,
88                          u16 token,
89                          struct dpcon_attr *attr);
90
91 /**
92  * struct dpcon_notification_cfg - Structure representing notification params
93  * @dpio_id:    DPIO object ID; must be configured with a notification channel;
94  *      to disable notifications set it to 'DPCON_INVALID_DPIO_ID';
95  * @priority:   Priority selection within the DPIO channel; valid values
96  *              are 0-7, depending on the number of priorities in that channel
97  * @user_ctx:   User context value provided with each CDAN message
98  */
99 struct dpcon_notification_cfg {
100         int dpio_id;
101         u8 priority;
102         u64 user_ctx;
103 };
104
105 int dpcon_set_notification(struct fsl_mc_io *mc_io,
106                            u32 cmd_flags,
107                            u16 token,
108                            struct dpcon_notification_cfg *cfg);
109
110 int dpcon_get_api_version(struct fsl_mc_io *mc_io,
111                           u32 cmd_flags,
112                           u16 *major_ver,
113                           u16 *minor_ver);
114
115 #endif /* __FSL_DPCON_H */