]> git.kernelconcepts.de Git - karo-tx-linux.git/blob - drivers/staging/fsl-mc/include/mc-sys.h
staging: fsl-mc: fix a few implicit includes
[karo-tx-linux.git] / drivers / staging / fsl-mc / include / mc-sys.h
1 /*
2  * Copyright 2013-2016 Freescale Semiconductor Inc.
3  *
4  * Interface of the I/O services to send MC commands to the MC hardware
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are met:
8  *     * Redistributions of source code must retain the above copyright
9  *       notice, this list of conditions and the following disclaimer.
10  *     * Redistributions in binary form must reproduce the above copyright
11  *       notice, this list of conditions and the following disclaimer in the
12  *       documentation and/or other materials provided with the distribution.
13  *     * Neither the name of the above-listed copyright holders nor the
14  *       names of any contributors may be used to endorse or promote products
15  *       derived from this software without specific prior written permission.
16  *
17  *
18  * ALTERNATIVELY, this software may be distributed under the terms of the
19  * GNU General Public License ("GPL") as published by the Free Software
20  * Foundation, either version 2 of that License or (at your option) any
21  * later version.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
27  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33  * POSSIBILITY OF SUCH DAMAGE.
34  */
35
36 #ifndef _FSL_MC_SYS_H
37 #define _FSL_MC_SYS_H
38
39 #include <linux/types.h>
40 #include <linux/errno.h>
41 #include <linux/mutex.h>
42 #include <linux/spinlock.h>
43
44 /**
45  * Bit masks for a MC I/O object (struct fsl_mc_io) flags
46  */
47 #define FSL_MC_IO_ATOMIC_CONTEXT_PORTAL 0x0001
48
49 struct mc_command;
50
51 /**
52  * struct fsl_mc_io - MC I/O object to be passed-in to mc_send_command()
53  * @dev: device associated with this Mc I/O object
54  * @flags: flags for mc_send_command()
55  * @portal_size: MC command portal size in bytes
56  * @portal_phys_addr: MC command portal physical address
57  * @portal_virt_addr: MC command portal virtual address
58  * @dpmcp_dev: pointer to the DPMCP device associated with the MC portal.
59  *
60  * Fields are only meaningful if the FSL_MC_IO_ATOMIC_CONTEXT_PORTAL flag is not
61  * set:
62  * @mutex: Mutex to serialize mc_send_command() calls that use the same MC
63  * portal, if the fsl_mc_io object was created with the
64  * FSL_MC_IO_ATOMIC_CONTEXT_PORTAL flag off. mc_send_command() calls for this
65  * fsl_mc_io object must be made only from non-atomic context.
66  *
67  * Fields are only meaningful if the FSL_MC_IO_ATOMIC_CONTEXT_PORTAL flag is
68  * set:
69  * @spinlock: Spinlock to serialize mc_send_command() calls that use the same MC
70  * portal, if the fsl_mc_io object was created with the
71  * FSL_MC_IO_ATOMIC_CONTEXT_PORTAL flag on. mc_send_command() calls for this
72  * fsl_mc_io object can be made from atomic or non-atomic context.
73  */
74 struct fsl_mc_io {
75         struct device *dev;
76         u16 flags;
77         u16 portal_size;
78         phys_addr_t portal_phys_addr;
79         void __iomem *portal_virt_addr;
80         struct fsl_mc_device *dpmcp_dev;
81         union {
82                 /*
83                  * This field is only meaningful if the
84                  * FSL_MC_IO_ATOMIC_CONTEXT_PORTAL flag is not set
85                  */
86                 struct mutex mutex; /* serializes mc_send_command() */
87
88                 /*
89                  * This field is only meaningful if the
90                  * FSL_MC_IO_ATOMIC_CONTEXT_PORTAL flag is set
91                  */
92                 spinlock_t spinlock;    /* serializes mc_send_command() */
93         };
94 };
95
96 int mc_send_command(struct fsl_mc_io *mc_io, struct mc_command *cmd);
97
98 #endif /* _FSL_MC_SYS_H */