| 1 |
|
| 2 |
|
| 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> |
| 9 |
|
| 10 |
enum cb_err mtk_init_mcu(struct mtk_mcu *mcu) |
| 11 |
{ |
| 12 |
struct stopwatch sw; |
| 13 |
|
| 14 |
if (!mcu) |
| 15 |
return CB_ERR_ARG; |
| 16 |
|
| 17 |
stopwatch_init(&sw); |
| 18 |
|
| 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; |
| 23 |
} |
| 24 |
|
| 25 |
if (mcu->run_address) { |
| 26 |
memcpy(mcu->run_address, mcu->load_buffer, mcu->run_size); |
| 27 |
|
| 28 |
mb(); |
| 29 |
} |
| 30 |
|
| 31 |
if (mcu->reset) |
| 32 |
mcu->reset(mcu); |
| 33 |
|
| 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); |
| 36 |
|
| 37 |
return CB_SUCCESS; |
| 38 |
} |