blob: ba9536d405087014ca21eab03e806e4e1622e98f [file] [log] [blame]
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -07001/*
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#include <fsl-mc/fsl_mc_sys.h>
10#include <fsl-mc/fsl_mc_cmd.h>
11#include <fsl-mc/fsl_dpbp.h>
12
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +053013int dpbp_open(struct fsl_mc_io *mc_io,
14 uint32_t cmd_flags,
15 int dpbp_id,
16 uint16_t *token)
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -070017{
18 struct mc_command cmd = { 0 };
19 int err;
20
21 /* prepare command */
22 cmd.header = mc_encode_cmd_header(DPBP_CMDID_OPEN,
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +053023 cmd_flags,
24 0);
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -070025 DPBP_CMD_OPEN(cmd, dpbp_id);
26
27 /* send command to mc*/
28 err = mc_send_command(mc_io, &cmd);
29 if (err)
30 return err;
31
32 /* retrieve response parameters */
33 *token = MC_CMD_HDR_READ_TOKEN(cmd.header);
34
35 return err;
36}
37
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +053038int dpbp_close(struct fsl_mc_io *mc_io,
39 uint32_t cmd_flags,
40 uint16_t token)
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -070041{
42 struct mc_command cmd = { 0 };
43
44 /* prepare command */
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +053045 cmd.header = mc_encode_cmd_header(DPBP_CMDID_CLOSE, cmd_flags,
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -070046 token);
47
48 /* send command to mc*/
49 return mc_send_command(mc_io, &cmd);
50}
51
Prabhakar Kushwahacf0c8cf2015-11-04 12:25:53 +053052int dpbp_create(struct fsl_mc_io *mc_io,
53 uint32_t cmd_flags,
54 const struct dpbp_cfg *cfg,
55 uint16_t *token)
56{
57 struct mc_command cmd = { 0 };
58 int err;
59
60 (void)(cfg); /* unused */
61
62 /* prepare command */
63 cmd.header = mc_encode_cmd_header(DPBP_CMDID_CREATE,
64 cmd_flags,
65 0);
66
67 /* send command to mc*/
68 err = mc_send_command(mc_io, &cmd);
69 if (err)
70 return err;
71
72 /* retrieve response parameters */
73 *token = MC_CMD_HDR_READ_TOKEN(cmd.header);
74
75 return 0;
76}
77
78int dpbp_destroy(struct fsl_mc_io *mc_io,
79 uint32_t cmd_flags,
80 uint16_t token)
81{
82 struct mc_command cmd = { 0 };
83
84 /* prepare command */
85 cmd.header = mc_encode_cmd_header(DPBP_CMDID_DESTROY,
86 cmd_flags,
87 token);
88
89 /* send command to mc*/
90 return mc_send_command(mc_io, &cmd);
91}
92
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +053093int dpbp_enable(struct fsl_mc_io *mc_io,
94 uint32_t cmd_flags,
95 uint16_t token)
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -070096{
97 struct mc_command cmd = { 0 };
98
99 /* prepare command */
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +0530100 cmd.header = mc_encode_cmd_header(DPBP_CMDID_ENABLE, cmd_flags,
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700101 token);
102
103 /* send command to mc*/
104 return mc_send_command(mc_io, &cmd);
105}
106
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +0530107int dpbp_disable(struct fsl_mc_io *mc_io,
108 uint32_t cmd_flags,
109 uint16_t token)
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700110{
111 struct mc_command cmd = { 0 };
112
113 /* prepare command */
114 cmd.header = mc_encode_cmd_header(DPBP_CMDID_DISABLE,
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +0530115 cmd_flags,
116 token);
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700117
118 /* send command to mc*/
119 return mc_send_command(mc_io, &cmd);
120}
121
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +0530122int dpbp_reset(struct fsl_mc_io *mc_io,
123 uint32_t cmd_flags,
124 uint16_t token)
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700125{
126 struct mc_command cmd = { 0 };
127
128 /* prepare command */
129 cmd.header = mc_encode_cmd_header(DPBP_CMDID_RESET,
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +0530130 cmd_flags,
131 token);
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700132
133 /* send command to mc*/
134 return mc_send_command(mc_io, &cmd);
135}
136
137int dpbp_get_attributes(struct fsl_mc_io *mc_io,
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +0530138 uint32_t cmd_flags,
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700139 uint16_t token,
140 struct dpbp_attr *attr)
141{
142 struct mc_command cmd = { 0 };
143 int err;
144
145 /* prepare command */
146 cmd.header = mc_encode_cmd_header(DPBP_CMDID_GET_ATTR,
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +0530147 cmd_flags,
148 token);
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700149
150 /* send command to mc*/
151 err = mc_send_command(mc_io, &cmd);
152 if (err)
153 return err;
154
155 /* retrieve response parameters */
156 DPBP_RSP_GET_ATTRIBUTES(cmd, attr);
157
158 return 0;
159}