mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-29 08:05:39 -04:00
Cortex-M[7,33] processors use a fixed reset vector table format:
0x00 Initial SP value
0x04 Reset vector
0x08 NMI
0x0C ...
...
IRQ[n]
In ELF images, the corresponding layout is:
reset_vectors: --> hardware reset address
.word __stack_end__
.word Reset_Handler
.word NMI_Handler
.word HardFault_Handler
...
.word UART_IRQHandler
.word SPI_IRQHandler
...
Reset_Handler: --> ELF entry point address
...
The hardware fetches the first two words from reset_vectors and populates
SP with __stack_end__ and PC with Reset_Handler. Execution proceeds from
Reset_Handler.
However, the ELF entry point does not always match the hardware reset
address. For example, on i.MX94 CM33S:
ELF entry point: 0x0ffc211d
hardware reset base: 0x0ffc0000 (default reset value, sw programmable)
Current driver always programs the reset vector as 0. But i.MX94 CM33S's
default reset base is 0x0ffc0000, so the correct reset vector must be
passed to the SM API; otherwise the M33 Sync core cannot boot successfully.
rproc_elf_get_boot_addr() returns the ELF entry point, which is not the
hardware reset vector address. Fix the issue by deriving the hardware reset
vector locally using a SoC-specific mask:
reset_vector = rproc->bootaddr & reset_vector_mask
The ELF entry point semantics remain unchanged. The masking is applied only
at the point where the SM reset vector is programmed.
Add reset_vector_mask = GENMASK_U32(31, 16) to the i.MX95 M7 configuration
so the hardware reset vector is derived correctly. Without this mask, the
SM reset vector would be programmed with an unaligned ELF entry point and
the M7 core would fail to boot.
Reviewed-by: Daniel Baluta <daniel.baluta@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
Link: https://lore.kernel.org/r/20260427-imx943-rproc-v4-2-68d7c7253acd@nxp.com
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
49 lines
1.2 KiB
C
49 lines
1.2 KiB
C
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
/*
|
|
* Copyright (c) 2017 Pengutronix, Oleksij Rempel <kernel@pengutronix.de>
|
|
* Copyright 2021 NXP
|
|
*/
|
|
|
|
#ifndef _IMX_RPROC_H
|
|
#define _IMX_RPROC_H
|
|
|
|
/* address translation table */
|
|
struct imx_rproc_att {
|
|
u32 da; /* device address (From Cortex M4 view)*/
|
|
u32 sa; /* system bus address */
|
|
u32 size; /* size of reg range */
|
|
int flags;
|
|
};
|
|
|
|
/* dcfg flags */
|
|
#define IMX_RPROC_NEED_SYSTEM_OFF BIT(0)
|
|
#define IMX_RPROC_NEED_CLKS BIT(1)
|
|
|
|
struct imx_rproc_plat_ops {
|
|
int (*start)(struct rproc *rproc);
|
|
int (*stop)(struct rproc *rproc);
|
|
int (*detach)(struct rproc *rproc);
|
|
int (*detect_mode)(struct rproc *rproc);
|
|
int (*prepare)(struct rproc *rproc);
|
|
};
|
|
|
|
struct imx_rproc_dcfg {
|
|
u32 src_reg;
|
|
u32 src_mask;
|
|
u32 src_start;
|
|
u32 src_stop;
|
|
u32 gpr_reg;
|
|
u32 gpr_wait;
|
|
const struct imx_rproc_att *att;
|
|
size_t att_size;
|
|
u32 flags;
|
|
const struct imx_rproc_plat_ops *ops;
|
|
/* For System Manager(SM) based SoCs */
|
|
u32 cpuid; /* ID of the remote core */
|
|
u32 lmid; /* ID of the Logcial Machine */
|
|
/* reset_vector = elf_entry_addr & reset_vector_mask */
|
|
u32 reset_vector_mask;
|
|
};
|
|
|
|
#endif /* _IMX_RPROC_H */
|