Skip to content

Commit a8b28f1

Browse files
Jaska Uimonenfabiobaltieri
authored andcommitted
soc: intel_adsp: cavs: add simple IMR functionality
Add simple mechanism to load the image from IMR memory. Basically we are only setting a flag in power off for the next boot to jump to existing image in IMR. Signed-off-by: Jaska Uimonen <[email protected]>
1 parent a13157f commit a8b28f1

File tree

4 files changed

+64
-0
lines changed

4 files changed

+64
-0
lines changed

dts/xtensa/intel/intel_adsp_cavs25.dtsi

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,13 @@
9797
wovcro-supported;
9898
};
9999

100+
IMR1: memory@0xb0000000 {
101+
compatible = "intel,adsp-imr";
102+
reg = <0xB0000000 DT_SIZE_M(16)>;
103+
block-size = <0x1000>;
104+
zephyr,memory-region = "IMR1";
105+
};
106+
100107
soc {
101108
shim: shim@71f00 {
102109
compatible = "intel,adsp-shim";
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/* Copyright (c) 2023 Intel Corporation
2+
* SPDX-License-Identifier: Apache-2.0
3+
*/
4+
#ifndef ZEPHYR_SOC_INTEL_ADSP_TGL_IMR_LAYOUT_H_
5+
#define ZEPHYR_SOC_INTEL_ADSP_TGL_IMR_LAYOUT_H_
6+
7+
/* These structs and macros are from the ROM code header
8+
* on cAVS platforms, please keep them immutable.
9+
*
10+
* The ROM structs and code is lifted from:
11+
* https://github.com/thesofproject/sof
12+
* 6c0db22c65 - platform: cavs: configure resume from IMR
13+
*/
14+
15+
/*
16+
* A magic that tells ROM to jump to imr_restore_vector instead of normal boot
17+
*/
18+
#define ADSP_IMR_MAGIC_VALUE 0x02468ACE
19+
20+
struct imr_header {
21+
uint32_t adsp_imr_magic;
22+
uint32_t structure_version;
23+
uint32_t structure_size;
24+
uint32_t imr_state;
25+
uint32_t imr_size;
26+
void (*imr_restore_vector)(void);
27+
};
28+
29+
struct imr_state {
30+
struct imr_header header;
31+
uint8_t reserved[0x1000 - sizeof(struct imr_header)];
32+
};
33+
34+
struct imr_layout {
35+
uint8_t css_reserved[0x1000];
36+
struct imr_state imr_state;
37+
};
38+
39+
#endif /* ZEPHYR_SOC_INTEL_ADSP_TGL_IMR_LAYOUT_H_ */

soc/xtensa/intel_adsp/cavs/include/intel_tgl_adsp/adsp_memory.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
#define HPSRAM_SEGMENTS (HPSRAM_EBB_COUNT + EBB_SEG_SIZE - 1) / EBB_SEG_SIZE
3030
#define HPSRAM_MEMMASK(idx) ((1ULL << (HPSRAM_EBB_COUNT - EBB_SEG_SIZE * idx)) - 1)
3131

32+
/* L3 region (IMR), located in host memory */
33+
#define L3_MEM_BASE_ADDR (DT_REG_ADDR(DT_NODELABEL(imr1)))
34+
3235
/* The rimage tool produces two blob addresses we need to find: one is
3336
* our bootloader code block which starts at its entry point, the
3437
* other is the "manifest" containing the HP-SRAM data to unpack,

soc/xtensa/intel_adsp/cavs/power.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <adsp_memory.h>
1919
#include <adsp_shim.h>
2020
#include <adsp_clk.h>
21+
#include <adsp_imr_layout.h>
2122
#include <cavs-idc.h>
2223
#include "soc.h"
2324

@@ -47,6 +48,11 @@ LOG_MODULE_REGISTER(soc);
4748

4849
#define ALL_USED_INT_LEVELS_MASK (L2_INTERRUPT_MASK | L3_INTERRUPT_MASK)
4950

51+
/*
52+
* @biref FW entry point called by ROM during normal boot flow
53+
*/
54+
extern void rom_entry(void);
55+
5056
struct core_state {
5157
uint32_t intenable;
5258
};
@@ -82,6 +88,15 @@ __weak void pm_state_set(enum pm_state state, uint8_t substate_id)
8288
sys_cache_data_flush_and_invd_all();
8389
if (cpu == 0) {
8490
uint32_t hpsram_mask[HPSRAM_SEGMENTS];
91+
92+
struct imr_header hdr = {
93+
.adsp_imr_magic = ADSP_IMR_MAGIC_VALUE,
94+
.imr_restore_vector = rom_entry,
95+
};
96+
struct imr_layout *imr_layout =
97+
arch_xtensa_uncached_ptr((struct imr_layout *)L3_MEM_BASE_ADDR);
98+
imr_layout->imr_state.header = hdr;
99+
85100
/* turn off all HPSRAM banks - get a full bitmap */
86101
for (int i = 0; i < HPSRAM_SEGMENTS; i++)
87102
hpsram_mask[i] = HPSRAM_MEMMASK(i);

0 commit comments

Comments
 (0)