|
2 | 2 | /* |
3 | 3 | * TI K3 R5F (MCU) Remote Processor driver |
4 | 4 | * |
5 | | - * Copyright (C) 2017-2020 Texas Instruments Incorporated - https://www.ti.com/ |
| 5 | + * Copyright (C) 2017-2022 Texas Instruments Incorporated - https://www.ti.com/ |
6 | 6 | * Suman Anna <s-anna@ti.com> |
7 | 7 | */ |
8 | 8 |
|
@@ -376,6 +376,44 @@ static inline int k3_r5_core_run(struct k3_r5_core *core) |
376 | 376 | 0, PROC_BOOT_CTRL_FLAG_R5_CORE_HALT); |
377 | 377 | } |
378 | 378 |
|
| 379 | +static int k3_r5_rproc_request_mbox(struct rproc *rproc) |
| 380 | +{ |
| 381 | + struct k3_r5_rproc *kproc = rproc->priv; |
| 382 | + struct mbox_client *client = &kproc->client; |
| 383 | + struct device *dev = kproc->dev; |
| 384 | + int ret; |
| 385 | + |
| 386 | + client->dev = dev; |
| 387 | + client->tx_done = NULL; |
| 388 | + client->rx_callback = k3_r5_rproc_mbox_callback; |
| 389 | + client->tx_block = false; |
| 390 | + client->knows_txdone = false; |
| 391 | + |
| 392 | + kproc->mbox = mbox_request_channel(client, 0); |
| 393 | + if (IS_ERR(kproc->mbox)) { |
| 394 | + ret = -EBUSY; |
| 395 | + dev_err(dev, "mbox_request_channel failed: %ld\n", |
| 396 | + PTR_ERR(kproc->mbox)); |
| 397 | + return ret; |
| 398 | + } |
| 399 | + |
| 400 | + /* |
| 401 | + * Ping the remote processor, this is only for sanity-sake for now; |
| 402 | + * there is no functional effect whatsoever. |
| 403 | + * |
| 404 | + * Note that the reply will _not_ arrive immediately: this message |
| 405 | + * will wait in the mailbox fifo until the remote processor is booted. |
| 406 | + */ |
| 407 | + ret = mbox_send_message(kproc->mbox, (void *)RP_MBOX_ECHO_REQUEST); |
| 408 | + if (ret < 0) { |
| 409 | + dev_err(dev, "mbox_send_message failed: %d\n", ret); |
| 410 | + mbox_free_channel(kproc->mbox); |
| 411 | + return ret; |
| 412 | + } |
| 413 | + |
| 414 | + return 0; |
| 415 | +} |
| 416 | + |
379 | 417 | /* |
380 | 418 | * The R5F cores have controls for both a reset and a halt/run. The code |
381 | 419 | * execution from DDR requires the initial boot-strapping code to be run |
@@ -495,38 +533,14 @@ static int k3_r5_rproc_start(struct rproc *rproc) |
495 | 533 | { |
496 | 534 | struct k3_r5_rproc *kproc = rproc->priv; |
497 | 535 | struct k3_r5_cluster *cluster = kproc->cluster; |
498 | | - struct mbox_client *client = &kproc->client; |
499 | 536 | struct device *dev = kproc->dev; |
500 | 537 | struct k3_r5_core *core; |
501 | 538 | u32 boot_addr; |
502 | 539 | int ret; |
503 | 540 |
|
504 | | - client->dev = dev; |
505 | | - client->tx_done = NULL; |
506 | | - client->rx_callback = k3_r5_rproc_mbox_callback; |
507 | | - client->tx_block = false; |
508 | | - client->knows_txdone = false; |
509 | | - |
510 | | - kproc->mbox = mbox_request_channel(client, 0); |
511 | | - if (IS_ERR(kproc->mbox)) { |
512 | | - ret = -EBUSY; |
513 | | - dev_err(dev, "mbox_request_channel failed: %ld\n", |
514 | | - PTR_ERR(kproc->mbox)); |
| 541 | + ret = k3_r5_rproc_request_mbox(rproc); |
| 542 | + if (ret) |
515 | 543 | return ret; |
516 | | - } |
517 | | - |
518 | | - /* |
519 | | - * Ping the remote processor, this is only for sanity-sake for now; |
520 | | - * there is no functional effect whatsoever. |
521 | | - * |
522 | | - * Note that the reply will _not_ arrive immediately: this message |
523 | | - * will wait in the mailbox fifo until the remote processor is booted. |
524 | | - */ |
525 | | - ret = mbox_send_message(kproc->mbox, (void *)RP_MBOX_ECHO_REQUEST); |
526 | | - if (ret < 0) { |
527 | | - dev_err(dev, "mbox_send_message failed: %d\n", ret); |
528 | | - goto put_mbox; |
529 | | - } |
530 | 544 |
|
531 | 545 | boot_addr = rproc->bootaddr; |
532 | 546 | /* TODO: add boot_addr sanity checking */ |
|
0 commit comments