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
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>
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(-)
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);
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);
36 @@ -502,6 +502,7 @@ int dpbp_get_irq_status(struct fsl_mc_io
38 cmd.header = mc_encode_cmd_header(DPBP_CMDID_GET_IRQ_STATUS,
40 + cmd.params[0] |= mc_enc(0, 32, *status);
41 cmd.params[0] |= mc_enc(32, 8, irq_index);
43 /* send command to mc*/
44 @@ -580,3 +581,75 @@ int dpbp_get_attributes(struct fsl_mc_io
47 EXPORT_SYMBOL(dpbp_get_attributes);
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
56 + * Return: '0' on Success; Error code otherwise.
58 +int dpbp_set_notifications(struct fsl_mc_io *mc_io,
61 + struct dpbp_notification_cfg *cfg)
63 + struct mc_command cmd = { 0 };
65 + /* prepare command */
66 + cmd.header = mc_encode_cmd_header(DPBP_CMDID_SET_NOTIFICATIONS,
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);
78 + /* send command to mc*/
79 + return mc_send_command(mc_io, &cmd);
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
89 + * Return: '0' on Success; Error code otherwise.
91 +int dpbp_get_notifications(struct fsl_mc_io *mc_io,
94 + struct dpbp_notification_cfg *cfg)
96 + struct mc_command cmd = { 0 };
99 + /* prepare command */
100 + cmd.header = mc_encode_cmd_header(DPBP_CMDID_GET_NOTIFICATIONS,
104 + /* send command to mc*/
105 + err = mc_send_command(mc_io, &cmd);
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);
120 --- a/drivers/staging/fsl-mc/include/dpbp-cmd.h
121 +++ b/drivers/staging/fsl-mc/include/dpbp-cmd.h
125 #define DPBP_VER_MAJOR 2
126 -#define DPBP_VER_MINOR 1
127 +#define DPBP_VER_MINOR 2
130 #define DPBP_CMDID_CLOSE 0x800
132 #define DPBP_CMDID_GET_IRQ_STATUS 0x016
133 #define DPBP_CMDID_CLEAR_IRQ_STATUS 0x017
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
147 struct dpbp_irq_cfg {
154 int dpbp_set_irq(struct fsl_mc_io *mc_io,
155 @@ -168,6 +168,53 @@ int dpbp_get_attributes(struct fsl_mc_io
157 struct dpbp_attr *attr);
160 + * DPBP notifications options
164 + * BPSCN write will attempt to allocate into a cache (coherent write)
166 +#define DPBP_NOTIF_OPT_COHERENT_WRITE 0x00000001
169 + * struct dpbp_notification_cfg - Structure representing DPBP notifications
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
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
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
186 +struct dpbp_notification_cfg {
187 + u32 depletion_entry;
188 + u32 depletion_exit;
196 +int dpbp_set_notifications(struct fsl_mc_io *mc_io,
199 + struct dpbp_notification_cfg *cfg);
201 +int dpbp_get_notifications(struct fsl_mc_io *mc_io,
204 + struct dpbp_notification_cfg *cfg);
208 #endif /* __FSL_DPBP_H */