]>
Commit | Line | Data |
---|---|---|
a2a55e51 | 1 | /* |
2557c5a9 YG |
2 | * Copyright (C) 2013-2016 Freescale Semiconductor |
3 | * Copyright 2017 NXP | |
a2a55e51 PK |
4 | * |
5 | * SPDX-License-Identifier: GPL-2.0+ | |
6 | */ | |
7 | ||
8 | #include <fsl-mc/fsl_mc_sys.h> | |
9 | #include <fsl-mc/fsl_mc_cmd.h> | |
10 | #include <fsl-mc/fsl_dpio.h> | |
11 | ||
87457d11 PK |
12 | int dpio_open(struct fsl_mc_io *mc_io, |
13 | uint32_t cmd_flags, | |
2557c5a9 | 14 | uint32_t dpio_id, |
87457d11 | 15 | uint16_t *token) |
a2a55e51 PK |
16 | { |
17 | struct mc_command cmd = { 0 }; | |
18 | int err; | |
19 | ||
20 | /* prepare command */ | |
21 | cmd.header = mc_encode_cmd_header(DPIO_CMDID_OPEN, | |
87457d11 PK |
22 | cmd_flags, |
23 | 0); | |
a2a55e51 PK |
24 | DPIO_CMD_OPEN(cmd, dpio_id); |
25 | ||
26 | /* send command to mc*/ | |
27 | err = mc_send_command(mc_io, &cmd); | |
28 | if (err) | |
29 | return err; | |
30 | ||
31 | /* retrieve response parameters */ | |
32 | *token = MC_CMD_HDR_READ_TOKEN(cmd.header); | |
33 | ||
34 | return 0; | |
35 | } | |
36 | ||
87457d11 PK |
37 | int dpio_close(struct fsl_mc_io *mc_io, |
38 | uint32_t cmd_flags, | |
39 | uint16_t token) | |
a2a55e51 PK |
40 | { |
41 | struct mc_command cmd = { 0 }; | |
42 | ||
43 | /* prepare command */ | |
44 | cmd.header = mc_encode_cmd_header(DPIO_CMDID_CLOSE, | |
87457d11 PK |
45 | cmd_flags, |
46 | token); | |
a2a55e51 PK |
47 | |
48 | /* send command to mc*/ | |
49 | return mc_send_command(mc_io, &cmd); | |
50 | } | |
51 | ||
1ebbe4fc | 52 | int dpio_create(struct fsl_mc_io *mc_io, |
2557c5a9 | 53 | uint16_t dprc_token, |
1ebbe4fc PK |
54 | uint32_t cmd_flags, |
55 | const struct dpio_cfg *cfg, | |
2557c5a9 | 56 | uint32_t *obj_id) |
1ebbe4fc PK |
57 | { |
58 | struct mc_command cmd = { 0 }; | |
59 | int err; | |
60 | ||
61 | /* prepare command */ | |
62 | cmd.header = mc_encode_cmd_header(DPIO_CMDID_CREATE, | |
63 | cmd_flags, | |
2557c5a9 | 64 | dprc_token); |
1ebbe4fc PK |
65 | DPIO_CMD_CREATE(cmd, cfg); |
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 */ | |
2557c5a9 | 73 | MC_CMD_READ_OBJ_ID(cmd, *obj_id); |
1ebbe4fc PK |
74 | |
75 | return 0; | |
76 | } | |
77 | ||
78 | int dpio_destroy(struct fsl_mc_io *mc_io, | |
2557c5a9 | 79 | uint16_t dprc_token, |
1ebbe4fc | 80 | uint32_t cmd_flags, |
2557c5a9 | 81 | uint32_t obj_id) |
1ebbe4fc PK |
82 | { |
83 | struct mc_command cmd = { 0 }; | |
84 | ||
85 | /* prepare command */ | |
86 | cmd.header = mc_encode_cmd_header(DPIO_CMDID_DESTROY, | |
87 | cmd_flags, | |
2557c5a9 YG |
88 | dprc_token); |
89 | ||
90 | /* set object id to destroy */ | |
91 | CMD_DESTROY_SET_OBJ_ID_PARAM0(cmd, obj_id); | |
1ebbe4fc PK |
92 | |
93 | /* send command to mc*/ | |
94 | return mc_send_command(mc_io, &cmd); | |
95 | } | |
96 | ||
87457d11 PK |
97 | int dpio_enable(struct fsl_mc_io *mc_io, |
98 | uint32_t cmd_flags, | |
99 | uint16_t token) | |
a2a55e51 PK |
100 | { |
101 | struct mc_command cmd = { 0 }; | |
102 | ||
103 | /* prepare command */ | |
104 | cmd.header = mc_encode_cmd_header(DPIO_CMDID_ENABLE, | |
87457d11 PK |
105 | cmd_flags, |
106 | token); | |
a2a55e51 PK |
107 | |
108 | /* send command to mc*/ | |
109 | return mc_send_command(mc_io, &cmd); | |
110 | } | |
111 | ||
87457d11 PK |
112 | int dpio_disable(struct fsl_mc_io *mc_io, |
113 | uint32_t cmd_flags, | |
114 | uint16_t token) | |
a2a55e51 PK |
115 | { |
116 | struct mc_command cmd = { 0 }; | |
117 | ||
118 | /* prepare command */ | |
119 | cmd.header = mc_encode_cmd_header(DPIO_CMDID_DISABLE, | |
87457d11 | 120 | cmd_flags, |
a2a55e51 PK |
121 | token); |
122 | ||
123 | /* send command to mc*/ | |
124 | return mc_send_command(mc_io, &cmd); | |
125 | } | |
126 | ||
87457d11 PK |
127 | int dpio_reset(struct fsl_mc_io *mc_io, |
128 | uint32_t cmd_flags, | |
129 | uint16_t token) | |
a2a55e51 PK |
130 | { |
131 | struct mc_command cmd = { 0 }; | |
132 | ||
133 | /* prepare command */ | |
134 | cmd.header = mc_encode_cmd_header(DPIO_CMDID_RESET, | |
87457d11 PK |
135 | cmd_flags, |
136 | token); | |
a2a55e51 PK |
137 | |
138 | /* send command to mc*/ | |
139 | return mc_send_command(mc_io, &cmd); | |
140 | } | |
141 | ||
142 | int dpio_get_attributes(struct fsl_mc_io *mc_io, | |
87457d11 | 143 | uint32_t cmd_flags, |
a2a55e51 PK |
144 | uint16_t token, |
145 | struct dpio_attr *attr) | |
146 | { | |
147 | struct mc_command cmd = { 0 }; | |
148 | int err; | |
149 | ||
150 | /* prepare command */ | |
151 | cmd.header = mc_encode_cmd_header(DPIO_CMDID_GET_ATTR, | |
87457d11 | 152 | cmd_flags, |
a2a55e51 PK |
153 | token); |
154 | ||
155 | /* send command to mc*/ | |
156 | err = mc_send_command(mc_io, &cmd); | |
157 | if (err) | |
158 | return err; | |
159 | ||
160 | /* retrieve response parameters */ | |
161 | DPIO_RSP_GET_ATTR(cmd, attr); | |
162 | ||
163 | return 0; | |
164 | } | |
2557c5a9 YG |
165 | |
166 | int dpio_get_api_version(struct fsl_mc_io *mc_io, | |
167 | u32 cmd_flags, | |
168 | u16 *major_ver, | |
169 | u16 *minor_ver) | |
170 | { | |
171 | struct mc_command cmd = { 0 }; | |
172 | int err; | |
173 | ||
174 | /* prepare command */ | |
175 | cmd.header = mc_encode_cmd_header(DPIO_CMDID_GET_API_VERSION, | |
176 | cmd_flags, 0); | |
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 | mc_cmd_read_api_version(&cmd, major_ver, minor_ver); | |
185 | ||
186 | return 0; | |
187 | } |