]> Git Repo - linux.git/blame - drivers/staging/fsl-mc/bus/dpcon.c
staging: wilc1000: rename _WPARxGtk_end_case_ label to avoid camelCase
[linux.git] / drivers / staging / fsl-mc / bus / dpcon.c
CommitLineData
203e2de3
BP
1// SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
2/*
3 * Copyright 2013-2016 Freescale Semiconductor Inc.
24999f33 4 *
24999f33 5 */
409acdd0 6#include <linux/kernel.h>
fab8ca58 7#include "../include/mc.h"
24999f33
IR
8#include "../include/dpcon.h"
9
10#include "dpcon-cmd.h"
11
12/**
13 * dpcon_open() - Open a control session for the specified object
14 * @mc_io: Pointer to MC portal's I/O object
15 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
16 * @dpcon_id: DPCON unique ID
17 * @token: Returned token; use in subsequent API calls
18 *
19 * This function can be used to open a control session for an
20 * already created object; an object may have been declared in
21 * the DPL or by calling the dpcon_create() function.
22 * This function returns a unique authentication token,
23 * associated with the specific object ID and the specific MC
24 * portal; this token must be used in all subsequent commands for
25 * this specific object.
26 *
27 * Return: '0' on Success; Error code otherwise.
28 */
29int dpcon_open(struct fsl_mc_io *mc_io,
30 u32 cmd_flags,
31 int dpcon_id,
32 u16 *token)
33{
34 struct mc_command cmd = { 0 };
35 struct dpcon_cmd_open *dpcon_cmd;
36 int err;
37
38 /* prepare command */
39 cmd.header = mc_encode_cmd_header(DPCON_CMDID_OPEN,
40 cmd_flags,
41 0);
42 dpcon_cmd = (struct dpcon_cmd_open *)cmd.params;
43 dpcon_cmd->dpcon_id = cpu_to_le32(dpcon_id);
44
45 /* send command to mc*/
46 err = mc_send_command(mc_io, &cmd);
47 if (err)
48 return err;
49
50 /* retrieve response parameters */
51 *token = mc_cmd_hdr_read_token(&cmd);
52
53 return 0;
54}
c9d57ea0 55EXPORT_SYMBOL_GPL(dpcon_open);
24999f33
IR
56
57/**
58 * dpcon_close() - Close the control session of the object
59 * @mc_io: Pointer to MC portal's I/O object
60 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
61 * @token: Token of DPCON object
62 *
63 * After this function is called, no further operations are
64 * allowed on the object without opening a new control session.
65 *
66 * Return: '0' on Success; Error code otherwise.
67 */
68int dpcon_close(struct fsl_mc_io *mc_io,
69 u32 cmd_flags,
70 u16 token)
71{
72 struct mc_command cmd = { 0 };
73
74 /* prepare command */
75 cmd.header = mc_encode_cmd_header(DPCON_CMDID_CLOSE,
76 cmd_flags,
77 token);
78
79 /* send command to mc*/
80 return mc_send_command(mc_io, &cmd);
81}
c9d57ea0 82EXPORT_SYMBOL_GPL(dpcon_close);
24999f33
IR
83
84/**
85 * dpcon_enable() - Enable the DPCON
86 * @mc_io: Pointer to MC portal's I/O object
87 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
88 * @token: Token of DPCON object
89 *
90 * Return: '0' on Success; Error code otherwise
91 */
92int dpcon_enable(struct fsl_mc_io *mc_io,
93 u32 cmd_flags,
94 u16 token)
95{
96 struct mc_command cmd = { 0 };
97
98 /* prepare command */
99 cmd.header = mc_encode_cmd_header(DPCON_CMDID_ENABLE,
100 cmd_flags,
101 token);
102
103 /* send command to mc*/
104 return mc_send_command(mc_io, &cmd);
105}
c9d57ea0 106EXPORT_SYMBOL_GPL(dpcon_enable);
24999f33
IR
107
108/**
109 * dpcon_disable() - Disable the DPCON
110 * @mc_io: Pointer to MC portal's I/O object
111 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
112 * @token: Token of DPCON object
113 *
114 * Return: '0' on Success; Error code otherwise
115 */
116int dpcon_disable(struct fsl_mc_io *mc_io,
117 u32 cmd_flags,
118 u16 token)
119{
120 struct mc_command cmd = { 0 };
121
122 /* prepare command */
123 cmd.header = mc_encode_cmd_header(DPCON_CMDID_DISABLE,
124 cmd_flags,
125 token);
126
127 /* send command to mc*/
128 return mc_send_command(mc_io, &cmd);
129}
c9d57ea0 130EXPORT_SYMBOL_GPL(dpcon_disable);
24999f33 131
24999f33
IR
132/**
133 * dpcon_reset() - Reset the DPCON, returns the object to initial state.
134 * @mc_io: Pointer to MC portal's I/O object
135 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
136 * @token: Token of DPCON object
137 *
138 * Return: '0' on Success; Error code otherwise.
139 */
140int dpcon_reset(struct fsl_mc_io *mc_io,
141 u32 cmd_flags,
142 u16 token)
143{
144 struct mc_command cmd = { 0 };
145
146 /* prepare command */
147 cmd.header = mc_encode_cmd_header(DPCON_CMDID_RESET,
148 cmd_flags, token);
149
150 /* send command to mc*/
151 return mc_send_command(mc_io, &cmd);
152}
c9d57ea0 153EXPORT_SYMBOL_GPL(dpcon_reset);
24999f33
IR
154
155/**
156 * dpcon_get_attributes() - Retrieve DPCON attributes.
157 * @mc_io: Pointer to MC portal's I/O object
158 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
159 * @token: Token of DPCON object
160 * @attr: Object's attributes
161 *
162 * Return: '0' on Success; Error code otherwise.
163 */
164int dpcon_get_attributes(struct fsl_mc_io *mc_io,
165 u32 cmd_flags,
166 u16 token,
167 struct dpcon_attr *attr)
168{
169 struct mc_command cmd = { 0 };
170 struct dpcon_rsp_get_attr *dpcon_rsp;
171 int err;
172
173 /* prepare command */
174 cmd.header = mc_encode_cmd_header(DPCON_CMDID_GET_ATTR,
175 cmd_flags,
176 token);
177
178 /* send command to mc*/
179 err = mc_send_command(mc_io, &cmd);
180 if (err)
181 return err;
182
183 /* retrieve response parameters */
184 dpcon_rsp = (struct dpcon_rsp_get_attr *)cmd.params;
185 attr->id = le32_to_cpu(dpcon_rsp->id);
186 attr->qbman_ch_id = le16_to_cpu(dpcon_rsp->qbman_ch_id);
187 attr->num_priorities = dpcon_rsp->num_priorities;
188
189 return 0;
190}
c9d57ea0 191EXPORT_SYMBOL_GPL(dpcon_get_attributes);
24999f33
IR
192
193/**
194 * dpcon_set_notification() - Set DPCON notification destination
195 * @mc_io: Pointer to MC portal's I/O object
196 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
197 * @token: Token of DPCON object
198 * @cfg: Notification parameters
199 *
200 * Return: '0' on Success; Error code otherwise
201 */
202int dpcon_set_notification(struct fsl_mc_io *mc_io,
203 u32 cmd_flags,
204 u16 token,
205 struct dpcon_notification_cfg *cfg)
206{
207 struct mc_command cmd = { 0 };
208 struct dpcon_cmd_set_notification *dpcon_cmd;
209
210 /* prepare command */
211 cmd.header = mc_encode_cmd_header(DPCON_CMDID_SET_NOTIFICATION,
212 cmd_flags,
213 token);
214 dpcon_cmd = (struct dpcon_cmd_set_notification *)cmd.params;
215 dpcon_cmd->dpio_id = cpu_to_le32(cfg->dpio_id);
216 dpcon_cmd->priority = cfg->priority;
217 dpcon_cmd->user_ctx = cpu_to_le64(cfg->user_ctx);
218
219 /* send command to mc*/
220 return mc_send_command(mc_io, &cmd);
221}
c9d57ea0 222EXPORT_SYMBOL_GPL(dpcon_set_notification);
This page took 0.199386 seconds and 4 git commands to generate.