Lokesh Vutla | 5d83fd2 | 2018-11-02 19:51:05 +0530 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * K3: Common Architecture initialization |
| 4 | * |
| 5 | * Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/ |
| 6 | * Lokesh Vutla <lokeshvutla@ti.com> |
| 7 | */ |
| 8 | |
| 9 | #include <common.h> |
| 10 | #include <spl.h> |
| 11 | #include "common.h" |
| 12 | #include <dm.h> |
| 13 | #include <remoteproc.h> |
Lokesh Vutla | 28cd824 | 2019-03-08 11:47:33 +0530 | [diff] [blame^] | 14 | #include <linux/soc/ti/ti_sci_protocol.h> |
| 15 | |
| 16 | struct ti_sci_handle *get_ti_sci_handle(void) |
| 17 | { |
| 18 | struct udevice *dev; |
| 19 | int ret; |
| 20 | |
| 21 | ret = uclass_get_device_by_name(UCLASS_FIRMWARE, "dmsc", &dev); |
| 22 | if (ret) |
| 23 | panic("Failed to get SYSFW (%d)\n", ret); |
| 24 | |
| 25 | return (struct ti_sci_handle *)ti_sci_get_handle_from_sysfw(dev); |
| 26 | } |
Lokesh Vutla | 5d83fd2 | 2018-11-02 19:51:05 +0530 | [diff] [blame] | 27 | |
| 28 | #ifdef CONFIG_SYS_K3_SPL_ATF |
| 29 | void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image) |
| 30 | { |
| 31 | int ret; |
| 32 | |
| 33 | /* |
| 34 | * It is assumed that remoteproc device 1 is the corresponding |
Andreas Dannenberg | 376c0fe | 2019-02-04 12:58:47 -0600 | [diff] [blame] | 35 | * Cortex-A core which runs ATF. Make sure DT reflects the same. |
Lokesh Vutla | 5d83fd2 | 2018-11-02 19:51:05 +0530 | [diff] [blame] | 36 | */ |
| 37 | ret = rproc_dev_init(1); |
Andreas Dannenberg | 376c0fe | 2019-02-04 12:58:47 -0600 | [diff] [blame] | 38 | if (ret) |
| 39 | panic("%s: ATF failed to initialize on rproc (%d)\n", __func__, |
| 40 | ret); |
Lokesh Vutla | 5d83fd2 | 2018-11-02 19:51:05 +0530 | [diff] [blame] | 41 | |
| 42 | ret = rproc_load(1, spl_image->entry_point, 0x200); |
Andreas Dannenberg | 376c0fe | 2019-02-04 12:58:47 -0600 | [diff] [blame] | 43 | if (ret) |
| 44 | panic("%s: ATF failed to load on rproc (%d)\n", __func__, ret); |
Lokesh Vutla | 5d83fd2 | 2018-11-02 19:51:05 +0530 | [diff] [blame] | 45 | |
Andreas Dannenberg | 376c0fe | 2019-02-04 12:58:47 -0600 | [diff] [blame] | 46 | /* Add an extra newline to differentiate the ATF logs from SPL */ |
Lokesh Vutla | 5d83fd2 | 2018-11-02 19:51:05 +0530 | [diff] [blame] | 47 | printf("Starting ATF on ARM64 core...\n\n"); |
| 48 | |
| 49 | ret = rproc_start(1); |
Andreas Dannenberg | 376c0fe | 2019-02-04 12:58:47 -0600 | [diff] [blame] | 50 | if (ret) |
| 51 | panic("%s: ATF failed to start on rproc (%d)\n", __func__, ret); |
Lokesh Vutla | 5d83fd2 | 2018-11-02 19:51:05 +0530 | [diff] [blame] | 52 | |
Andreas Dannenberg | 376c0fe | 2019-02-04 12:58:47 -0600 | [diff] [blame] | 53 | debug("ATF started. Waiting indefinitely...\n"); |
Lokesh Vutla | 5d83fd2 | 2018-11-02 19:51:05 +0530 | [diff] [blame] | 54 | while (1) |
| 55 | asm volatile("wfe"); |
| 56 | } |
| 57 | #endif |