Repository navigation
Expand file tree
/
Copy pathplatform.c
More file actions
643 lines (558 loc) · 16.6 KB
/
Copy pathplatform.c
File metadata and controls
643 lines (558 loc) · 16.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
// SPDX-License-Identifier: BSD-3-Clause
//
// Copyright(c) 2018 Intel Corporation. All rights reserved.
//
// Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
// Keyon Jie <yang.jie@linux.intel.com>
// Rander Wang <rander.wang@intel.com>
// Janusz Jankowski <janusz.jankowski@linux.intel.com>
#include <cavs/version.h>
#if (CONFIG_CAVS_LPS)
#include <cavs/lps_wait.h>
#endif
#include <cavs/mem_window.h>
#include <sof/common.h>
#include <sof/compiler_info.h>
#include <sof/debug/debug.h>
#include <sof/drivers/dw-dma.h>
#include <sof/drivers/idc.h>
#include <sof/drivers/interrupt.h>
#include <sof/ipc/common.h>
#include <sof/drivers/timer.h>
#include <sof/fw-ready-metadata.h>
#include <sof/lib/agent.h>
#include <sof/lib/cache.h>
#include <sof/lib/clk.h>
#include <sof/lib/cpu.h>
#include <sof/lib/dai.h>
#include <sof/lib/dma.h>
#include <sof/lib/io.h>
#include <sof/lib/mailbox.h>
#include <sof/lib/memory.h>
#include <sof/lib/mm_heap.h>
#include <sof/lib/notifier.h>
#include <sof/lib/pm_runtime.h>
#include <sof/lib/wait.h>
#include <sof/platform.h>
#include <sof/schedule/edf_schedule.h>
#include <sof/schedule/ll_schedule.h>
#include <sof/schedule/ll_schedule_domain.h>
#include <sof/trace/dma-trace.h>
#include <sof/trace/trace.h>
#include <ipc/header.h>
#include <ipc/info.h>
#include <kernel/abi.h>
#include <kernel/ext_manifest.h>
#include <sof_versions.h>
#include <errno.h>
#include <stdint.h>
static const struct sof_ipc_fw_ready ready
__section(".fw_ready") = {
.hdr = {
.cmd = SOF_IPC_FW_READY,
.size = sizeof(struct sof_ipc_fw_ready),
},
.version = {
.hdr.size = sizeof(struct sof_ipc_fw_version),
.micro = SOF_MICRO,
.minor = SOF_MINOR,
.major = SOF_MAJOR,
/* opt-in; reproducible build by default */
#if BLD_COUNTERS
.build = SOF_BUILD, /* See version-build-counter.cmake */
.date = __DATE__,
.time = __TIME__,
#else
.build = -1,
.date = "dtermin.\0",
.time = "fwready.\0",
#endif
.tag = SOF_TAG,
.abi_version = SOF_ABI_VERSION,
.src_hash = SOF_SRC_HASH,
},
#if CONFIG_CAVS_IMR_D3_PERSISTENT
.flags = DEBUG_SET_FW_READY_FLAGS | SOF_IPC_INFO_D3_PERSISTENT,
#else
.flags = DEBUG_SET_FW_READY_FLAGS,
#endif
};
#if CONFIG_MEM_WND
#define SRAM_WINDOW_HOST_OFFSET(x) (0x80000 + x * 0x20000)
#define NUM_WINDOWS 7
const struct ext_man_windows xsram_window
__aligned(EXT_MAN_ALIGN) __section(".fw_metadata") __unused = {
.hdr = {
.type = EXT_MAN_ELEM_WINDOW,
.elem_size = ALIGN_UP_COMPILE(sizeof(struct ext_man_windows), EXT_MAN_ALIGN),
},
.window = {
.ext_hdr = {
.hdr.cmd = SOF_IPC_FW_READY,
.hdr.size = sizeof(struct sof_ipc_window),
.type = SOF_IPC_EXT_WINDOW,
},
.num_windows = NUM_WINDOWS,
.window = {
{
.type = SOF_IPC_REGION_REGS,
.id = 0, /* map to host window 0 */
.flags = 0, // TODO: set later
.size = MAILBOX_SW_REG_SIZE,
.offset = 0,
},
{
.type = SOF_IPC_REGION_UPBOX,
.id = 0, /* map to host window 0 */
.flags = 0, // TODO: set later
.size = MAILBOX_DSPBOX_SIZE,
.offset = MAILBOX_SW_REG_SIZE,
},
{
.type = SOF_IPC_REGION_DOWNBOX,
.id = 1, /* map to host window 1 */
.flags = 0, // TODO: set later
.size = MAILBOX_HOSTBOX_SIZE,
.offset = 0,
},
{
.type = SOF_IPC_REGION_DEBUG,
.id = 2, /* map to host window 2 */
.flags = 0, // TODO: set later
.size = MAILBOX_DEBUG_SIZE,
.offset = 0,
},
{
.type = SOF_IPC_REGION_EXCEPTION,
.id = 2, /* map to host window 2 */
.flags = 0, // TODO: set later
.size = MAILBOX_EXCEPTION_SIZE,
.offset = MAILBOX_EXCEPTION_OFFSET,
},
{
.type = SOF_IPC_REGION_STREAM,
.id = 2, /* map to host window 2 */
.flags = 0, // TODO: set later
.size = MAILBOX_STREAM_SIZE,
.offset = MAILBOX_STREAM_OFFSET,
},
{
.type = SOF_IPC_REGION_TRACE,
.id = 3, /* map to host window 3 */
.flags = 0, // TODO: set later
.size = MAILBOX_TRACE_SIZE,
.offset = 0,
},
},
},
};
#endif
#if CONFIG_CANNONLAKE || CONFIG_ICELAKE || CONFIG_TIGERLAKE
#if CONFIG_CAVS_LPRO_ONLY
#define CAVS_DEFAULT_RO SHIM_CLKCTL_RLROSCC
#define CAVS_DEFAULT_RO_FOR_MEM SHIM_CLKCTL_OCS_LP_RING
#else
#define CAVS_DEFAULT_RO SHIM_CLKCTL_RHROSCC
#define CAVS_DEFAULT_RO_FOR_MEM SHIM_CLKCTL_OCS_HP_RING
#endif
#endif
#if CONFIG_DW_GPIO
#include <sof/drivers/gpio.h>
const struct gpio_pin_config gpio_data[] = {
{ /* GPIO0 */
.mux_id = 1,
.mux_config = {.bit = 0, .mask = 3, .fn = 1},
}, { /* GPIO1 */
.mux_id = 1,
.mux_config = {.bit = 2, .mask = 3, .fn = 1},
}, { /* GPIO2 */
.mux_id = 1,
.mux_config = {.bit = 4, .mask = 3, .fn = 1},
}, { /* GPIO3 */
.mux_id = 1,
.mux_config = {.bit = 6, .mask = 3, .fn = 1},
}, { /* GPIO4 */
.mux_id = 1,
.mux_config = {.bit = 8, .mask = 3, .fn = 1},
}, { /* GPIO5 */
.mux_id = 1,
.mux_config = {.bit = 10, .mask = 3, .fn = 1},
}, { /* GPIO6 */
.mux_id = 1,
.mux_config = {.bit = 12, .mask = 3, .fn = 1},
}, { /* GPIO7 */
.mux_id = 1,
.mux_config = {.bit = 14, .mask = 3, .fn = 1},
}, { /* GPIO8 */
.mux_id = 1,
.mux_config = {.bit = 16, .mask = 1, .fn = 1},
}, { /* GPIO9 */
.mux_id = 0,
.mux_config = {.bit = 11, .mask = 1, .fn = 1},
}, { /* GPIO10 */
.mux_id = 0,
.mux_config = {.bit = 11, .mask = 1, .fn = 1},
}, { /* GPIO11 */
.mux_id = 0,
.mux_config = {.bit = 11, .mask = 1, .fn = 1},
}, { /* GPIO12 */
.mux_id = 0,
.mux_config = {.bit = 11, .mask = 1, .fn = 1},
}, { /* GPIO13 */
.mux_id = 0,
.mux_config = {.bit = 0, .mask = 1, .fn = 1},
}, { /* GPIO14 */
.mux_id = 0,
.mux_config = {.bit = 1, .mask = 1, .fn = 1},
}, { /* GPIO15 */
.mux_id = 0,
.mux_config = {.bit = 9, .mask = 1, .fn = 1},
}, { /* GPIO16 */
.mux_id = 0,
.mux_config = {.bit = 9, .mask = 1, .fn = 1},
}, { /* GPIO17 */
.mux_id = 0,
.mux_config = {.bit = 9, .mask = 1, .fn = 1},
}, { /* GPIO18 */
.mux_id = 0,
.mux_config = {.bit = 9, .mask = 1, .fn = 1},
}, { /* GPIO19 */
.mux_id = 0,
.mux_config = {.bit = 10, .mask = 1, .fn = 1},
}, { /* GPIO20 */
.mux_id = 0,
.mux_config = {.bit = 10, .mask = 1, .fn = 1},
}, { /* GPIO21 */
.mux_id = 0,
.mux_config = {.bit = 10, .mask = 1, .fn = 1},
}, { /* GPIO22 */
.mux_id = 0,
.mux_config = {.bit = 10, .mask = 1, .fn = 1},
}, { /* GPIO23 */
.mux_id = 0,
.mux_config = {.bit = 16, .mask = 1, .fn = 1},
}, { /* GPIO24 */
.mux_id = 0,
.mux_config = {.bit = 16, .mask = 1, .fn = 1},
}, { /* GPIO25 */
.mux_id = 0,
.mux_config = {.bit = 26, .mask = 1, .fn = 1},
},
};
const int n_gpios = ARRAY_SIZE(gpio_data);
#if CONFIG_INTEL_IOMUX
#include <sof/drivers/iomux.h>
struct iomux iomux_data[] = {
{.base = EXT_CTRL_BASE + 0x30,},
{.base = EXT_CTRL_BASE + 0x34,},
{.base = EXT_CTRL_BASE + 0x38,},
};
const int n_iomux = ARRAY_SIZE(iomux_data);
#endif
#endif
#ifndef __ZEPHYR__
static SHARED_DATA struct timer platform_timer = {
.id = TIMER3, /* external timer */
.irq = IRQ_EXT_TSTAMP0_LVL2,
.irq_name = irq_name_level2,
};
static SHARED_DATA struct timer arch_timers[CONFIG_CORE_COUNT];
#endif
#if CONFIG_DW_SPI
#include <sof/drivers/spi.h>
static struct spi_platform_data spi = {
.base = DW_SPI_SLAVE_BASE,
.type = SOF_SPI_INTEL_SLAVE,
.fifo[SPI_DIR_RX] = {
.handshake = DMA_HANDSHAKE_SSI_RX,
},
.fifo[SPI_DIR_TX] = {
.handshake = DMA_HANDSHAKE_SSI_TX,
}
};
int platform_boot_complete(uint32_t boot_message)
{
return spi_push(spi_get(SOF_SPI_INTEL_SLAVE), &ready, sizeof(ready));
}
#else
int platform_boot_complete(uint32_t boot_message)
{
struct ipc_cmd_hdr header;
#if CONFIG_TIGERLAKE && !CONFIG_CAVS_LPRO_ONLY
/* TGL specific HW recommended flow */
pm_runtime_get(PM_RUNTIME_DSP, PWRD_BY_HPRO | (CONFIG_CORE_COUNT - 1));
#endif
mailbox_dspbox_write(0, &ready, sizeof(ready));
/* get any IPC specific boot message and optional data */
ipc_boot_complete_msg(&header, SRAM_WINDOW_HOST_OFFSET(0) >> 12);
/* tell host we are ready */
#if CONFIG_IPC_MAJOR_3
#if CAVS_VERSION == CAVS_VERSION_1_5
ipc_write(IPC_DIPCIE, header.dat[1]);
ipc_write(IPC_DIPCI, IPC_DIPCI_BUSY | header.dat[0]);
#else
ipc_write(IPC_DIPCIDD, header.dat[1]);
ipc_write(IPC_DIPCIDR, IPC_DIPCIDR_BUSY | header.dat[0]);
#endif
#elif CONFIG_IPC_MAJOR_4
#if CAVS_VERSION == CAVS_VERSION_1_5
ipc_write(IPC_DIPCIE, header.ext);
ipc_write(IPC_DIPCI, IPC_DIPCI_BUSY | header.pri);
#else
ipc_write(IPC_DIPCIDD, header.ext);
ipc_write(IPC_DIPCIDR, IPC_DIPCIDR_BUSY | header.pri);
#endif
#endif
return 0;
}
#endif
#if CAVS_VERSION >= CAVS_VERSION_1_8
/* init HW */
static void platform_init_hw(void)
{
io_reg_write(DSP_INIT_GENO,
GENO_MDIVOSEL | GENO_DIOPTOSEL);
io_reg_write(DSP_INIT_IOPO,
IOPO_DMIC_FLAG | IOPO_I2S_FLAG);
io_reg_write(DSP_INIT_ALHO,
ALHO_ASO_FLAG | ALHO_CSO_FLAG);
io_reg_write(DSP_INIT_LPGPDMA(0),
LPGPDMA_CHOSEL_FLAG | LPGPDMA_CTLOSEL_FLAG);
io_reg_write(DSP_INIT_LPGPDMA(1),
LPGPDMA_CHOSEL_FLAG | LPGPDMA_CTLOSEL_FLAG);
}
#endif
/* Runs on the primary core only */
int platform_init(struct sof *sof)
{
#if CONFIG_DW_SPI
struct spi *spi_dev;
#endif
int ret;
int i;
#ifndef __ZEPHYR__
sof->platform_timer = platform_shared_get(&platform_timer, sizeof(platform_timer));
sof->cpu_timers = platform_shared_get(arch_timers, sizeof(arch_timers));
for (i = 0; i < CONFIG_CORE_COUNT; i++)
sof->cpu_timers[i] = (struct timer) {
.id = TIMER1, /* internal timer */
.irq = IRQ_NUM_TIMER2,
};
#endif
/* Turn off memory for all unused cores */
for (i = 0; i < CONFIG_CORE_COUNT; i++)
if (i != PLATFORM_PRIMARY_CORE_ID)
pm_runtime_put(CORE_MEMORY_POW, i);
/* pm runtime already initialized, request the DSP to stay in D0
* until we are allowed to do full power gating (by the IPC req).
*/
pm_runtime_disable(PM_RUNTIME_DSP, 0);
#if CAVS_VERSION >= CAVS_VERSION_1_8
trace_point(TRACE_BOOT_PLATFORM_ENTRY);
platform_init_hw();
#endif
trace_point(TRACE_BOOT_PLATFORM_IRQ);
platform_interrupt_init();
#if CONFIG_MEM_WND
trace_point(TRACE_BOOT_PLATFORM_MBOX);
platform_memory_windows_init(MEM_WND_INIT_CLEAR);
#endif
#ifndef __ZEPHYR__
/* init timers, clocks and schedulers */
trace_point(TRACE_BOOT_PLATFORM_TIMER);
platform_timer_start(sof->platform_timer);
#endif
trace_point(TRACE_BOOT_PLATFORM_CLOCK);
platform_clock_init(sof);
trace_point(TRACE_BOOT_PLATFORM_SCHED);
scheduler_init_edf();
/* init low latency timer domain and scheduler */
sof->platform_timer_domain = timer_domain_init(sof->platform_timer, PLATFORM_DEFAULT_CLOCK);
scheduler_init_ll(sof->platform_timer_domain);
/* init the system agent */
trace_point(TRACE_BOOT_PLATFORM_AGENT);
sa_init(sof, CONFIG_SYSTICK_PERIOD);
/* Set CPU to max frequency for booting (single shim_write below) */
trace_point(TRACE_BOOT_PLATFORM_CPU_FREQ);
#if CONFIG_APOLLOLAKE
/* initialize PM for boot */
/* TODO: there are two clk freqs CRO & CRO/4
* Running on CRO all the time atm
*/
shim_write(SHIM_CLKCTL,
SHIM_CLKCTL_HDCS_PLL | /* HP domain clocked by PLL */
SHIM_CLKCTL_LDCS_PLL | /* LP domain clocked by PLL */
SHIM_CLKCTL_DPCS_DIV1(0) | /* Core 0 clk not divided */
SHIM_CLKCTL_DPCS_DIV1(1) | /* Core 1 clk not divided */
SHIM_CLKCTL_HPMPCS_DIV2 | /* HP mem clock div by 2 */
SHIM_CLKCTL_LPMPCS_DIV4 | /* LP mem clock div by 4 */
SHIM_CLKCTL_TCPAPLLS_DIS |
SHIM_CLKCTL_TCPLCG_DIS(0) | SHIM_CLKCTL_TCPLCG_DIS(1));
shim_write(SHIM_LPSCTL, shim_read(SHIM_LPSCTL));
#elif CONFIG_CANNONLAKE || CONFIG_ICELAKE || CONFIG_TIGERLAKE
/* initialize PM for boot */
/* request configured ring oscillator and wait for status ready */
shim_write(SHIM_CLKCTL, shim_read(SHIM_CLKCTL) | CAVS_DEFAULT_RO);
while (!(shim_read(SHIM_CLKSTS) & CAVS_DEFAULT_RO))
idelay(16);
shim_write(SHIM_CLKCTL,
CAVS_DEFAULT_RO | /* Request configured RING Osc */
CAVS_DEFAULT_RO_FOR_MEM | /* Select configured
* RING Oscillator Clk for memory
*/
SHIM_CLKCTL_HMCS_DIV2 | /* HP mem clock div by 2 */
SHIM_CLKCTL_LMCS_DIV4 | /* LP mem clock div by 4 */
SHIM_CLKCTL_TCPLCG_DIS_ALL); /* Allow Local Clk Gating */
/* prevent LP GPDMA 0&1 clock gating */
shim_write(SHIM_GPDMA_CLKCTL(0), SHIM_CLKCTL_LPGPDMAFDCGB);
shim_write(SHIM_GPDMA_CLKCTL(1), SHIM_CLKCTL_LPGPDMAFDCGB);
/* prevent DSP Common power gating */
pm_runtime_get(PM_RUNTIME_DSP, PLATFORM_PRIMARY_CORE_ID);
#if CONFIG_DSP_RESIDENCY_COUNTERS
#if CONFIG_CAVS_LPRO_ONLY
init_dsp_r_state(r1_r_state);
#else
init_dsp_r_state(r0_r_state);
#endif
#endif
#elif CONFIG_SUECREEK
/* TODO: need to merge as for APL */
clock_set_freq(CLK_CPU(cpu_get_id()), CLK_MAX_CPU_HZ);
/* prevent Core0 clock gating. */
shim_write(SHIM_CLKCTL, shim_read(SHIM_CLKCTL) |
SHIM_CLKCTL_TCPLCG(0));
/* prevent LP GPDMA 0&1 clock gating */
shim_write(SHIM_GPDMA_CLKCTL(0), SHIM_CLKCTL_LPGPDMAFDCGB);
shim_write(SHIM_GPDMA_CLKCTL(1), SHIM_CLKCTL_LPGPDMAFDCGB);
/* prevent DSP Common power gating */
pm_runtime_get(PM_RUNTIME_DSP, PLATFORM_PRIMARY_CORE_ID);
#endif
/* init DMACs */
trace_point(TRACE_BOOT_PLATFORM_DMA);
ret = dmac_init(sof);
if (ret < 0)
return ret;
/* init low latency single channel DW-DMA domain and scheduler */
sof->platform_dma_domain =
dma_single_chan_domain_init
(&sof->dma_info->dma_array[PLATFORM_DW_DMA_INDEX],
PLATFORM_NUM_DW_DMACS,
PLATFORM_DEFAULT_CLOCK);
scheduler_init_ll(sof->platform_dma_domain);
/* initialize the host IPC mechanisms */
trace_point(TRACE_BOOT_PLATFORM_IPC);
ipc_init(sof);
/* initialize IDC mechanism */
trace_point(TRACE_BOOT_PLATFORM_IDC);
ret = idc_init();
if (ret < 0)
return ret;
/* init DAIs */
trace_point(TRACE_BOOT_PLATFORM_DAI);
ret = dai_init(sof);
if (ret < 0)
return ret;
#if CONFIG_DW_SPI
/* initialize the SPI slave */
trace_point(TRACE_BOOT_PLATFORM_SPI);
spi_init();
ret = spi_install(&spi, 1);
if (ret < 0)
return ret;
spi_dev = spi_get(SOF_SPI_INTEL_SLAVE);
if (!spi_dev)
return -ENODEV;
/* initialize the SPI-SLave module */
ret = spi_probe(spi_dev);
if (ret < 0)
return ret;
#elif CONFIG_TRACE
/* Initialize DMA for Trace*/
trace_point(TRACE_BOOT_PLATFORM_DMA_TRACE);
dma_trace_init_complete(sof->dmat);
#endif
/* show heap status */
heap_trace_all(1);
return 0;
}
#ifndef __ZEPHYR__
void platform_wait_for_interrupt(int level)
{
platform_clock_on_waiti();
#ifdef CONFIG_MULTICORE
int cpu_id = cpu_get_id();
/* for secondary cores, if prepare_d0ix_core_mask flag is set for
* specific core, we should prepare for power down before going to wait
* - it is required by D0->D0ix flow.
*/
if (cpu_id != PLATFORM_PRIMARY_CORE_ID &&
platform_pm_runtime_prepare_d0ix_is_req(cpu_id))
cpu_power_down_core(CPU_POWER_DOWN_MEMORY_ON);
#endif
#if (CONFIG_CAVS_LPS)
if (pm_runtime_is_active(PM_RUNTIME_DSP, PLATFORM_PRIMARY_CORE_ID) ||
cpu_get_id() != PLATFORM_PRIMARY_CORE_ID)
arch_wait_for_interrupt(level);
else
lps_wait_for_interrupt(level);
#else
arch_wait_for_interrupt(level);
#endif
}
#endif
#if CONFIG_CAVS_IMR_D3_PERSISTENT
/* These structs and macros are from from the ROM code header
* on cAVS platforms, please keep them immutable
*/
#define ADSP_IMR_MAGIC_VALUE 0x02468ACE
#define IMR_L1_CACHE_ADDRESS 0xB0000000
struct imr_header {
uint32_t adsp_imr_magic;
uint32_t structure_version;
uint32_t structure_size;
uint32_t imr_state;
uint32_t imr_size;
void *imr_restore_vector;
};
struct imr_state {
struct imr_header header;
uint8_t reserved[0x1000 - sizeof(struct imr_header)];
};
struct imr_layout {
uint8_t css_reserved[0x1000];
struct imr_state imr_state;
};
/* cAVS ROM structs and macros end */
static void imr_layout_update(void *vector)
{
struct imr_layout *imr_layout = (struct imr_layout *)(IMR_L1_CACHE_ADDRESS);
/* update the IMR layout and write it back to uncache memory
* for ROM code usage. The ROM code will read this from IMR
* at the subsequent run and decide (e.g. combine with checking
* if FW_PURGE IPC from host got) if it can use the previous
* IMR FW directly. So this here is only a host->FW->ROM one way
* configuration, no symmetric task need to done in any
* platform_resume() to clear the configuration.
*/
dcache_invalidate_region((__sparse_force void __sparse_cache *)imr_layout,
sizeof(*imr_layout));
imr_layout->imr_state.header.adsp_imr_magic = ADSP_IMR_MAGIC_VALUE;
imr_layout->imr_state.header.imr_restore_vector = vector;
dcache_writeback_region((__sparse_force void __sparse_cache *)imr_layout,
sizeof(*imr_layout));
}
#endif
int platform_context_save(struct sof *sof)
{
#if CONFIG_CAVS_IMR_D3_PERSISTENT
/*
* Both runtime PM and S2Idle suspend works on APL, while S3 ([deep])
* doesn't. Only support IMR restoring on cAVS 1.8 and onward at the
* moment.
* TODO: Root cause of why IMR restore doesn't work on APL during S3
* cycle.
*/
imr_layout_update((void *)IMR_BOOT_LDR_TEXT_ENTRY_BASE);
#endif
return 0;
}