drivers/wifi: Remove unnecessary data structure copy
[coreboot2.git] / src / soc / mediatek / common / mcu.c
blobca2bdbbd966ba54d93eb8eda79c8128126f3d3b6
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <arch/barrier.h>
4 #include <cbfs.h>
5 #include <console/console.h>
6 #include <soc/mcu_common.h>
7 #include <soc/symbols.h>
8 #include <timer.h>
10 enum cb_err mtk_init_mcu(struct mtk_mcu *mcu)
12 struct stopwatch sw;
14 if (!mcu)
15 return CB_ERR_ARG;
17 stopwatch_init(&sw);
19 mcu->run_size = cbfs_load(mcu->firmware_name, mcu->load_buffer, mcu->buffer_size);
20 if (mcu->run_size == 0) {
21 printk(BIOS_ERR, "%s: Failed to load %s\n", __func__, mcu->firmware_name);
22 return CB_ERR;
25 if (mcu->run_address) {
26 memcpy(mcu->run_address, mcu->load_buffer, mcu->run_size);
27 /* Memory barrier to ensure data is flushed before resetting MCU. */
28 mb();
31 if (mcu->reset)
32 mcu->reset(mcu);
34 printk(BIOS_DEBUG, "%s: Loaded (and reset) %s in %lld msecs (%zd bytes)\n",
35 __func__, mcu->firmware_name, stopwatch_duration_msecs(&sw), mcu->run_size);
37 return CB_SUCCESS;