diff options
Diffstat (limited to 'kernel/ethosu_device.c')
-rw-r--r-- | kernel/ethosu_device.c | 101 |
1 files changed, 3 insertions, 98 deletions
diff --git a/kernel/ethosu_device.c b/kernel/ethosu_device.c index 0f1a284..36b776f 100644 --- a/kernel/ethosu_device.c +++ b/kernel/ethosu_device.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2022 Arm Limited. + * Copyright 2020-2023 Arm Limited and/or its affiliates * * This program is free software and is provided to you under the terms of the * GNU General Public License version 2 as published by the Free Software @@ -39,7 +39,6 @@ #include <linux/interrupt.h> #include <linux/io.h> #include <linux/of_reserved_mem.h> -#include <linux/reset.h> #include <linux/slab.h> #include <linux/uaccess.h> @@ -204,85 +203,6 @@ static int ethosu_handle_msg(struct ethosu_device *edev) return ret; } -int ethosu_firmware_reset(struct ethosu_device *edev) -{ - int ret; - - /* No reset control for this device */ - if (IS_ERR(edev->reset)) - return PTR_ERR(edev->reset); - - dev_info(edev->dev, "Resetting firmware."); - - ret = reset_control_assert(edev->reset); - if (ret) { - dev_err(edev->dev, "Failed to reset assert firmware. ret=%d", - ret); - - return ret; - } - - /* Initialize mailbox header with illegal values */ - ethosu_mailbox_wait_prepare(&edev->mailbox); - - /* If this call fails we have a problem. We managed halt the firmware, - * but not to release the reset. - */ - ret = reset_control_deassert(edev->reset); - if (ret) { - dev_err(edev->dev, "Failed to reset deassert firmware. ret=%d", - ret); - goto fail; - } - - /* Wait for firmware to boot up and initialize mailbox */ - ret = ethosu_mailbox_wait_firmware(&edev->mailbox); - if (ret) { - dev_err(edev->dev, "Wait on firmware boot timed out. ret=%d", - ret); - goto fail; - } - - edev->mailbox.ping_count = 0; - ethosu_watchdog_reset(&edev->watchdog); - - ret = ethosu_mailbox_ping(&edev->mailbox); - if (ret) { - dev_warn(edev->dev, - "Failed to send ping after firmware reset. ret=%d", - ret); - goto fail; - } - - /* Resend messages */ - ethosu_mailbox_resend(&edev->mailbox); - - return ret; - -fail: - ethosu_mailbox_fail(&edev->mailbox); - - return ret; -} - -static void ethosu_watchdog_callback(struct ethosu_watchdog *wdog) -{ - struct ethosu_device *edev = - container_of(wdog, struct ethosu_device, watchdog); - - mutex_lock(&edev->mutex); - - dev_warn(edev->dev, "Device watchdog timeout. ping_count=%u", - edev->mailbox.ping_count); - - if (edev->mailbox.ping_count < 1) - ethosu_mailbox_ping(&edev->mailbox); - else - ethosu_firmware_reset(edev); - - mutex_unlock(&edev->mutex); -} - static int ethosu_open(struct inode *inode, struct file *file) { @@ -414,25 +334,16 @@ int ethosu_dev_init(struct ethosu_device *edev, edev->devt = devt; mutex_init(&edev->mutex); - edev->reset = devm_reset_control_get_by_index(edev->dev, 0); - if (IS_ERR(edev->reset)) - dev_warn(edev->dev, "No reset control found for this device."); - ret = of_reserved_mem_device_init(edev->dev); if (ret) return ret; dma_set_mask_and_coherent(edev->dev, DMA_BIT_MASK(DMA_ADDR_BITS)); - ret = ethosu_watchdog_init(&edev->watchdog, dev, - ethosu_watchdog_callback); - if (ret) - goto release_reserved_mem; - ret = ethosu_mailbox_init(&edev->mailbox, dev, in_queue, out_queue, - ethosu_mbox_rx, edev, &edev->watchdog); + ethosu_mbox_rx, edev); if (ret) - goto deinit_watchdog; + goto release_reserved_mem; cdev_init(&edev->cdev, &fops); edev->cdev.owner = THIS_MODULE; @@ -451,8 +362,6 @@ int ethosu_dev_init(struct ethosu_device *edev, goto del_cdev; } - ethosu_firmware_reset(edev); - dev_info(edev->dev, "Created Arm Ethos-U device. name=%s, major=%d, minor=%d\n", dev_name(sysdev), MAJOR(edev->devt), MINOR(edev->devt)); @@ -465,9 +374,6 @@ del_cdev: deinit_mailbox: ethosu_mailbox_deinit(&edev->mailbox); -deinit_watchdog: - ethosu_watchdog_deinit(&edev->watchdog); - release_reserved_mem: of_reserved_mem_device_release(edev->dev); @@ -477,7 +383,6 @@ release_reserved_mem: void ethosu_dev_deinit(struct ethosu_device *edev) { ethosu_mailbox_deinit(&edev->mailbox); - ethosu_watchdog_deinit(&edev->watchdog); device_destroy(edev->class, edev->cdev.dev); cdev_del(&edev->cdev); of_reserved_mem_device_release(edev->dev); |