|
2 | 2 | /* |
3 | 3 | * TI K3 DSP Remote Processor(s) driver |
4 | 4 | * |
5 | | - * Copyright (C) 2018-2020 Texas Instruments Incorporated - https://www.ti.com/ |
| 5 | + * Copyright (C) 2018-2022 Texas Instruments Incorporated - https://www.ti.com/ |
6 | 6 | * Suman Anna <s-anna@ti.com> |
7 | 7 | */ |
8 | 8 |
|
@@ -216,6 +216,43 @@ static int k3_dsp_rproc_release(struct k3_dsp_rproc *kproc) |
216 | 216 | return ret; |
217 | 217 | } |
218 | 218 |
|
| 219 | +static int k3_dsp_rproc_request_mbox(struct rproc *rproc) |
| 220 | +{ |
| 221 | + struct k3_dsp_rproc *kproc = rproc->priv; |
| 222 | + struct mbox_client *client = &kproc->client; |
| 223 | + struct device *dev = kproc->dev; |
| 224 | + int ret; |
| 225 | + |
| 226 | + client->dev = dev; |
| 227 | + client->tx_done = NULL; |
| 228 | + client->rx_callback = k3_dsp_rproc_mbox_callback; |
| 229 | + client->tx_block = false; |
| 230 | + client->knows_txdone = false; |
| 231 | + |
| 232 | + kproc->mbox = mbox_request_channel(client, 0); |
| 233 | + if (IS_ERR(kproc->mbox)) { |
| 234 | + ret = -EBUSY; |
| 235 | + dev_err(dev, "mbox_request_channel failed: %ld\n", |
| 236 | + PTR_ERR(kproc->mbox)); |
| 237 | + return ret; |
| 238 | + } |
| 239 | + |
| 240 | + /* |
| 241 | + * Ping the remote processor, this is only for sanity-sake for now; |
| 242 | + * there is no functional effect whatsoever. |
| 243 | + * |
| 244 | + * Note that the reply will _not_ arrive immediately: this message |
| 245 | + * will wait in the mailbox fifo until the remote processor is booted. |
| 246 | + */ |
| 247 | + ret = mbox_send_message(kproc->mbox, (void *)RP_MBOX_ECHO_REQUEST); |
| 248 | + if (ret < 0) { |
| 249 | + dev_err(dev, "mbox_send_message failed: %d\n", ret); |
| 250 | + mbox_free_channel(kproc->mbox); |
| 251 | + return ret; |
| 252 | + } |
| 253 | + |
| 254 | + return 0; |
| 255 | +} |
219 | 256 | /* |
220 | 257 | * The C66x DSP cores have a local reset that affects only the CPU, and a |
221 | 258 | * generic module reset that powers on the device and allows the DSP internal |
@@ -273,37 +310,13 @@ static int k3_dsp_rproc_unprepare(struct rproc *rproc) |
273 | 310 | static int k3_dsp_rproc_start(struct rproc *rproc) |
274 | 311 | { |
275 | 312 | struct k3_dsp_rproc *kproc = rproc->priv; |
276 | | - struct mbox_client *client = &kproc->client; |
277 | 313 | struct device *dev = kproc->dev; |
278 | 314 | u32 boot_addr; |
279 | 315 | int ret; |
280 | 316 |
|
281 | | - client->dev = dev; |
282 | | - client->tx_done = NULL; |
283 | | - client->rx_callback = k3_dsp_rproc_mbox_callback; |
284 | | - client->tx_block = false; |
285 | | - client->knows_txdone = false; |
286 | | - |
287 | | - kproc->mbox = mbox_request_channel(client, 0); |
288 | | - if (IS_ERR(kproc->mbox)) { |
289 | | - ret = -EBUSY; |
290 | | - dev_err(dev, "mbox_request_channel failed: %ld\n", |
291 | | - PTR_ERR(kproc->mbox)); |
| 317 | + ret = k3_dsp_rproc_request_mbox(rproc); |
| 318 | + if (ret) |
292 | 319 | return ret; |
293 | | - } |
294 | | - |
295 | | - /* |
296 | | - * Ping the remote processor, this is only for sanity-sake for now; |
297 | | - * there is no functional effect whatsoever. |
298 | | - * |
299 | | - * Note that the reply will _not_ arrive immediately: this message |
300 | | - * will wait in the mailbox fifo until the remote processor is booted. |
301 | | - */ |
302 | | - ret = mbox_send_message(kproc->mbox, (void *)RP_MBOX_ECHO_REQUEST); |
303 | | - if (ret < 0) { |
304 | | - dev_err(dev, "mbox_send_message failed: %d\n", ret); |
305 | | - goto put_mbox; |
306 | | - } |
307 | 320 |
|
308 | 321 | boot_addr = rproc->bootaddr; |
309 | 322 | if (boot_addr & (kproc->data->boot_align_addr - 1)) { |
|
0 commit comments