xref: /openbmc/u-boot/include/fsl-mc/fsl_dpbp.h (revision 722e000c)
1 /*
2  * Freescale Layerscape MC I/O wrapper
3  *
4  * Copyright (C) 2013-2015 Freescale Semiconductor, Inc.
5  * Author: German Rivera <German.Rivera@freescale.com>
6  *
7  * SPDX-License-Identifier:	GPL-2.0+
8  */
9 /*!
10  *  @file    fsl_dpbp.h
11  *  @brief   Data Path Buffer Pool API
12  */
13 #ifndef __FSL_DPBP_H
14 #define __FSL_DPBP_H
15 
16 /* DPBP Version */
17 #define DPBP_VER_MAJOR				2
18 #define DPBP_VER_MINOR				1
19 
20 /* Command IDs */
21 #define DPBP_CMDID_CLOSE				0x800
22 #define DPBP_CMDID_OPEN					0x804
23 
24 #define DPBP_CMDID_ENABLE				0x002
25 #define DPBP_CMDID_DISABLE				0x003
26 #define DPBP_CMDID_GET_ATTR				0x004
27 #define DPBP_CMDID_RESET				0x005
28 
29 /*                cmd, param, offset, width, type, arg_name */
30 #define DPBP_CMD_OPEN(cmd, dpbp_id) \
31 	MC_CMD_OP(cmd, 0, 0,  32, int,	    dpbp_id)
32 
33 /*                cmd, param, offset, width, type, arg_name */
34 #define DPBP_RSP_GET_ATTRIBUTES(cmd, attr) \
35 do { \
36 	MC_RSP_OP(cmd, 0, 16, 16, uint16_t, attr->bpid); \
37 	MC_RSP_OP(cmd, 0, 32, 32, int,	    attr->id);\
38 	MC_RSP_OP(cmd, 1, 0,  16, uint16_t, attr->version.major);\
39 	MC_RSP_OP(cmd, 1, 16, 16, uint16_t, attr->version.minor);\
40 } while (0)
41 
42 /* Data Path Buffer Pool API
43  * Contains initialization APIs and runtime control APIs for DPBP
44  */
45 
46 struct fsl_mc_io;
47 
48 /**
49  * dpbp_open() - Open a control session for the specified object.
50  * @mc_io:	Pointer to MC portal's I/O object
51  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
52  * @dpbp_id:	DPBP unique ID
53  * @token:	Returned token; use in subsequent API calls
54  *
55  * This function can be used to open a control session for an
56  * already created object; an object may have been declared in
57  * the DPL or by calling the dpbp_create function.
58  * This function returns a unique authentication token,
59  * associated with the specific object ID and the specific MC
60  * portal; this token must be used in all subsequent commands for
61  * this specific object
62  *
63  * Return:	'0' on Success; Error code otherwise.
64  */
65 int dpbp_open(struct fsl_mc_io	*mc_io,
66 	      uint32_t		cmd_flags,
67 	      int		dpbp_id,
68 	      uint16_t		*token);
69 
70 /**
71  * dpbp_close() - Close the control session of the object
72  * @mc_io:	Pointer to MC portal's I/O object
73  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
74  * @token:	Token of DPBP object
75  *
76  * After this function is called, no further operations are
77  * allowed on the object without opening a new control session.
78  *
79  * Return:	'0' on Success; Error code otherwise.
80  */
81 int dpbp_close(struct fsl_mc_io	*mc_io,
82 	       uint32_t		cmd_flags,
83 	       uint16_t	token);
84 
85 /**
86  * dpbp_enable() - Enable the DPBP.
87  * @mc_io:	Pointer to MC portal's I/O object
88  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
89  * @token:	Token of DPBP object
90  *
91  * Return:	'0' on Success; Error code otherwise.
92  */
93 int dpbp_enable(struct fsl_mc_io	*mc_io,
94 		uint32_t		cmd_flags,
95 		uint16_t		token);
96 
97 /**
98  * dpbp_disable() - Disable the DPBP.
99  * @mc_io:	Pointer to MC portal's I/O object
100  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
101  * @token:	Token of DPBP object
102  *
103  * Return:	'0' on Success; Error code otherwise.
104  */
105 int dpbp_disable(struct fsl_mc_io	*mc_io,
106 		 uint32_t		cmd_flags,
107 		 uint16_t		token);
108 
109 /**
110  * dpbp_is_enabled() - Check if the DPBP is enabled.
111  * @mc_io:	Pointer to MC portal's I/O object
112  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
113  * @token:	Token of DPBP object
114  * @en:		Returns '1' if object is enabled; '0' otherwise
115  *
116  * Return:	'0' on Success; Error code otherwise.
117  */
118 int dpbp_is_enabled(struct fsl_mc_io	*mc_io,
119 		    uint32_t		cmd_flags,
120 		    uint16_t		token,
121 		    int		*en);
122 
123 /**
124  * dpbp_reset() - Reset the DPBP, returns the object to initial state.
125  * @mc_io:	Pointer to MC portal's I/O object
126  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
127  * @token:	Token of DPBP object
128  *
129  * Return:	'0' on Success; Error code otherwise.
130  */
131 int dpbp_reset(struct fsl_mc_io	*mc_io,
132 	       uint32_t		cmd_flags,
133 	       uint16_t	token);
134 
135 
136 /**
137  * struct dpbp_attr - Structure representing DPBP attributes
138  * @id:		DPBP object ID
139  * @version:	DPBP version
140  * @bpid:	Hardware buffer pool ID; should be used as an argument in
141  *		acquire/release operations on buffers
142  */
143 struct dpbp_attr {
144 	int id;
145 	/**
146 	 * struct version - Structure representing DPBP version
147 	 * @major:	DPBP major version
148 	 * @minor:	DPBP minor version
149 	 */
150 	struct {
151 		uint16_t major;
152 		uint16_t minor;
153 	} version;
154 	uint16_t bpid;
155 };
156 
157 /**
158  * dpbp_get_attributes - Retrieve DPBP attributes.
159  *
160  * @mc_io:	Pointer to MC portal's I/O object
161  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
162  * @token:	Token of DPBP object
163  * @attr:	Returned object's attributes
164  *
165  * Return:	'0' on Success; Error code otherwise.
166  */
167 int dpbp_get_attributes(struct fsl_mc_io	*mc_io,
168 			uint32_t	cmd_flags,
169 			uint16_t		token,
170 			struct dpbp_attr	*attr);
171 
172 /** @} */
173 
174 #endif /* __FSL_DPBP_H */
175