layerscape: add ls1088ardb device support
[openwrt/staging/lynxis/omap.git] / target / linux / layerscape / patches-4.4 / 7168-staging-fsl-mc-update-dpbp-binary-interface-to-v2.2.patch
1 From de0fa9842d52e4e80576d378f32aa9ca76a4270b Mon Sep 17 00:00:00 2001
2 From: Stuart Yoder <stuart.yoder@nxp.com>
3 Date: Mon, 11 Apr 2016 11:48:54 -0500
4 Subject: [PATCH 168/226] staging: fsl-mc: update dpbp binary interface to
5 v2.2
6
7 Signed-off-by: Stuart Yoder <stuart.yoder@nxp.com>
8 Acked-by: German Rivera <german.rivera@nxp.com>
9 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
10 ---
11 drivers/staging/fsl-mc/bus/dpbp.c | 77 ++++++++++++++++++++++++++++-
12 drivers/staging/fsl-mc/include/dpbp-cmd.h | 4 +-
13 drivers/staging/fsl-mc/include/dpbp.h | 51 ++++++++++++++++++-
14 3 files changed, 127 insertions(+), 5 deletions(-)
15
16 --- a/drivers/staging/fsl-mc/bus/dpbp.c
17 +++ b/drivers/staging/fsl-mc/bus/dpbp.c
18 @@ -293,7 +293,7 @@ int dpbp_set_irq(struct fsl_mc_io *mc_io
19 cmd.params[0] |= mc_enc(0, 8, irq_index);
20 cmd.params[0] |= mc_enc(32, 32, irq_cfg->val);
21 cmd.params[1] |= mc_enc(0, 64, irq_cfg->addr);
22 - cmd.params[2] |= mc_enc(0, 32, irq_cfg->user_irq_id);
23 + cmd.params[2] |= mc_enc(0, 32, irq_cfg->irq_num);
24
25 /* send command to mc*/
26 return mc_send_command(mc_io, &cmd);
27 @@ -334,7 +334,7 @@ int dpbp_get_irq(struct fsl_mc_io *mc_io
28 /* retrieve response parameters */
29 irq_cfg->val = (u32)mc_dec(cmd.params[0], 0, 32);
30 irq_cfg->addr = (u64)mc_dec(cmd.params[1], 0, 64);
31 - irq_cfg->user_irq_id = (int)mc_dec(cmd.params[2], 0, 32);
32 + irq_cfg->irq_num = (int)mc_dec(cmd.params[2], 0, 32);
33 *type = (int)mc_dec(cmd.params[2], 32, 32);
34 return 0;
35 }
36 @@ -502,6 +502,7 @@ int dpbp_get_irq_status(struct fsl_mc_io
37 /* prepare command */
38 cmd.header = mc_encode_cmd_header(DPBP_CMDID_GET_IRQ_STATUS,
39 cmd_flags, token);
40 + cmd.params[0] |= mc_enc(0, 32, *status);
41 cmd.params[0] |= mc_enc(32, 8, irq_index);
42
43 /* send command to mc*/
44 @@ -580,3 +581,75 @@ int dpbp_get_attributes(struct fsl_mc_io
45 return 0;
46 }
47 EXPORT_SYMBOL(dpbp_get_attributes);
48 +
49 +/**
50 + * dpbp_set_notifications() - Set notifications towards software
51 + * @mc_io: Pointer to MC portal's I/O object
52 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
53 + * @token: Token of DPBP object
54 + * @cfg: notifications configuration
55 + *
56 + * Return: '0' on Success; Error code otherwise.
57 + */
58 +int dpbp_set_notifications(struct fsl_mc_io *mc_io,
59 + u32 cmd_flags,
60 + u16 token,
61 + struct dpbp_notification_cfg *cfg)
62 +{
63 + struct mc_command cmd = { 0 };
64 +
65 + /* prepare command */
66 + cmd.header = mc_encode_cmd_header(DPBP_CMDID_SET_NOTIFICATIONS,
67 + cmd_flags,
68 + token);
69 +
70 + cmd.params[0] |= mc_enc(0, 32, cfg->depletion_entry);
71 + cmd.params[0] |= mc_enc(32, 32, cfg->depletion_exit);
72 + cmd.params[1] |= mc_enc(0, 32, cfg->surplus_entry);
73 + cmd.params[1] |= mc_enc(32, 32, cfg->surplus_exit);
74 + cmd.params[2] |= mc_enc(0, 16, cfg->options);
75 + cmd.params[3] |= mc_enc(0, 64, cfg->message_ctx);
76 + cmd.params[4] |= mc_enc(0, 64, cfg->message_iova);
77 +
78 + /* send command to mc*/
79 + return mc_send_command(mc_io, &cmd);
80 +}
81 +
82 +/**
83 + * dpbp_get_notifications() - Get the notifications configuration
84 + * @mc_io: Pointer to MC portal's I/O object
85 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
86 + * @token: Token of DPBP object
87 + * @cfg: notifications configuration
88 + *
89 + * Return: '0' on Success; Error code otherwise.
90 + */
91 +int dpbp_get_notifications(struct fsl_mc_io *mc_io,
92 + u32 cmd_flags,
93 + u16 token,
94 + struct dpbp_notification_cfg *cfg)
95 +{
96 + struct mc_command cmd = { 0 };
97 + int err;
98 +
99 + /* prepare command */
100 + cmd.header = mc_encode_cmd_header(DPBP_CMDID_GET_NOTIFICATIONS,
101 + cmd_flags,
102 + token);
103 +
104 + /* send command to mc*/
105 + err = mc_send_command(mc_io, &cmd);
106 + if (err)
107 + return err;
108 +
109 + /* retrieve response parameters */
110 + cfg->depletion_entry = (u32)mc_dec(cmd.params[0], 0, 32);
111 + cfg->depletion_exit = (u32)mc_dec(cmd.params[0], 32, 32);
112 + cfg->surplus_entry = (u32)mc_dec(cmd.params[1], 0, 32);
113 + cfg->surplus_exit = (u32)mc_dec(cmd.params[1], 32, 32);
114 + cfg->options = (u16)mc_dec(cmd.params[2], 0, 16);
115 + cfg->message_ctx = (u64)mc_dec(cmd.params[3], 0, 64);
116 + cfg->message_iova = (u64)mc_dec(cmd.params[4], 0, 64);
117 +
118 + return 0;
119 +}
120 --- a/drivers/staging/fsl-mc/include/dpbp-cmd.h
121 +++ b/drivers/staging/fsl-mc/include/dpbp-cmd.h
122 @@ -34,7 +34,7 @@
123
124 /* DPBP Version */
125 #define DPBP_VER_MAJOR 2
126 -#define DPBP_VER_MINOR 1
127 +#define DPBP_VER_MINOR 2
128
129 /* Command IDs */
130 #define DPBP_CMDID_CLOSE 0x800
131 @@ -57,4 +57,6 @@
132 #define DPBP_CMDID_GET_IRQ_STATUS 0x016
133 #define DPBP_CMDID_CLEAR_IRQ_STATUS 0x017
134
135 +#define DPBP_CMDID_SET_NOTIFICATIONS 0x01b0
136 +#define DPBP_CMDID_GET_NOTIFICATIONS 0x01b1
137 #endif /* _FSL_DPBP_CMD_H */
138 --- a/drivers/staging/fsl-mc/include/dpbp.h
139 +++ b/drivers/staging/fsl-mc/include/dpbp.h
140 @@ -85,12 +85,12 @@ int dpbp_reset(struct fsl_mc_io *mc_io,
141 * struct dpbp_irq_cfg - IRQ configuration
142 * @addr: Address that must be written to signal a message-based interrupt
143 * @val: Value to write into irq_addr address
144 - * @user_irq_id: A user defined number associated with this IRQ
145 + * @irq_num: A user defined number associated with this IRQ
146 */
147 struct dpbp_irq_cfg {
148 u64 addr;
149 u32 val;
150 - int user_irq_id;
151 + int irq_num;
152 };
153
154 int dpbp_set_irq(struct fsl_mc_io *mc_io,
155 @@ -168,6 +168,53 @@ int dpbp_get_attributes(struct fsl_mc_io
156 u16 token,
157 struct dpbp_attr *attr);
158
159 +/**
160 + * DPBP notifications options
161 + */
162 +
163 +/**
164 + * BPSCN write will attempt to allocate into a cache (coherent write)
165 + */
166 +#define DPBP_NOTIF_OPT_COHERENT_WRITE 0x00000001
167 +
168 +/**
169 + * struct dpbp_notification_cfg - Structure representing DPBP notifications
170 + * towards software
171 + * @depletion_entry: below this threshold the pool is "depleted";
172 + * set it to '0' to disable it
173 + * @depletion_exit: greater than or equal to this threshold the pool exit its
174 + * "depleted" state
175 + * @surplus_entry: above this threshold the pool is in "surplus" state;
176 + * set it to '0' to disable it
177 + * @surplus_exit: less than or equal to this threshold the pool exit its
178 + * "surplus" state
179 + * @message_iova: MUST be given if either 'depletion_entry' or 'surplus_entry'
180 + * is not '0' (enable); I/O virtual address (must be in DMA-able memory),
181 + * must be 16B aligned.
182 + * @message_ctx: The context that will be part of the BPSCN message and will
183 + * be written to 'message_iova'
184 + * @options: Mask of available options; use 'DPBP_NOTIF_OPT_<X>' values
185 + */
186 +struct dpbp_notification_cfg {
187 + u32 depletion_entry;
188 + u32 depletion_exit;
189 + u32 surplus_entry;
190 + u32 surplus_exit;
191 + u64 message_iova;
192 + u64 message_ctx;
193 + u16 options;
194 +};
195 +
196 +int dpbp_set_notifications(struct fsl_mc_io *mc_io,
197 + u32 cmd_flags,
198 + u16 token,
199 + struct dpbp_notification_cfg *cfg);
200 +
201 +int dpbp_get_notifications(struct fsl_mc_io *mc_io,
202 + u32 cmd_flags,
203 + u16 token,
204 + struct dpbp_notification_cfg *cfg);
205 +
206 /** @} */
207
208 #endif /* __FSL_DPBP_H */