GNU Linux-libre 4.14.251-gnu1
[releases.git] / drivers / staging / fsl-mc / bus / dpio / dpio.h
1 /*
2  * Copyright 2013-2016 Freescale Semiconductor Inc.
3  * Copyright 2016 NXP
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  * * Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * * Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  * * Neither the name of the above-listed copyright holders nor the
13  * names of any contributors may be used to endorse or promote products
14  * derived from this software without specific prior written permission.
15  *
16  * ALTERNATIVELY, this software may be distributed under the terms of the
17  * GNU General Public License ("GPL") as published by the Free Software
18  * Foundation, either version 2 of that License or (at your option) any
19  * later version.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
25  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31  * POSSIBILITY OF SUCH DAMAGE.
32  */
33 #ifndef __FSL_DPIO_H
34 #define __FSL_DPIO_H
35
36 struct fsl_mc_io;
37
38 int dpio_open(struct fsl_mc_io  *mc_io,
39               u32               cmd_flags,
40               int               dpio_id,
41               u16               *token);
42
43 int dpio_close(struct fsl_mc_io *mc_io,
44                u32              cmd_flags,
45                u16              token);
46
47 /**
48  * enum dpio_channel_mode - DPIO notification channel mode
49  * @DPIO_NO_CHANNEL: No support for notification channel
50  * @DPIO_LOCAL_CHANNEL: Notifications on data availability can be received by a
51  *      dedicated channel in the DPIO; user should point the queue's
52  *      destination in the relevant interface to this DPIO
53  */
54 enum dpio_channel_mode {
55         DPIO_NO_CHANNEL = 0,
56         DPIO_LOCAL_CHANNEL = 1,
57 };
58
59 /**
60  * struct dpio_cfg - Structure representing DPIO configuration
61  * @channel_mode: Notification channel mode
62  * @num_priorities: Number of priorities for the notification channel (1-8);
63  *                      relevant only if 'channel_mode = DPIO_LOCAL_CHANNEL'
64  */
65 struct dpio_cfg {
66         enum dpio_channel_mode  channel_mode;
67         u8              num_priorities;
68 };
69
70 int dpio_enable(struct fsl_mc_io        *mc_io,
71                 u32             cmd_flags,
72                 u16             token);
73
74 int dpio_disable(struct fsl_mc_io       *mc_io,
75                  u32            cmd_flags,
76                  u16            token);
77
78 /**
79  * struct dpio_attr - Structure representing DPIO attributes
80  * @id: DPIO object ID
81  * @qbman_portal_ce_offset: offset of the software portal cache-enabled area
82  * @qbman_portal_ci_offset: offset of the software portal cache-inhibited area
83  * @qbman_portal_id: Software portal ID
84  * @channel_mode: Notification channel mode
85  * @num_priorities: Number of priorities for the notification channel (1-8);
86  *                      relevant only if 'channel_mode = DPIO_LOCAL_CHANNEL'
87  * @qbman_version: QBMAN version
88  */
89 struct dpio_attr {
90         int                     id;
91         u64             qbman_portal_ce_offset;
92         u64             qbman_portal_ci_offset;
93         u16             qbman_portal_id;
94         enum dpio_channel_mode  channel_mode;
95         u8                      num_priorities;
96         u32             qbman_version;
97 };
98
99 int dpio_get_attributes(struct fsl_mc_io        *mc_io,
100                         u32             cmd_flags,
101                         u16             token,
102                         struct dpio_attr        *attr);
103
104 int dpio_get_api_version(struct fsl_mc_io *mc_io,
105                          u32 cmd_flags,
106                          u16 *major_ver,
107                          u16 *minor_ver);
108
109 #endif /* __FSL_DPIO_H */