-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
soc: intel_adsp: cavs: start using zephyr power management
Start using zephyr power management in cavs platform in a similar way that is already done in ace. This commit only addresses the power off/on sequence. Runtime power management is not implemented. Signed-off-by: Jaska Uimonen <jaska.uimonen@linux.intel.com>
- Loading branch information
Showing
7 changed files
with
453 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
/* Copyright (c) 2023 Intel Corporation | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#ifndef __ZEPHYR_CAVS_LIB_ASM_LDO_MANAGEMENT_H__ | ||
#define __ZEPHYR_CAVS_LIB_ASM_LDO_MANAGEMENT_H__ | ||
|
||
#ifdef _ASMLANGUAGE | ||
|
||
#define SHIM_BASE 0x00071F00 | ||
#define SHIM_LDOCTL 0xA4 | ||
#define SHIM_LDOCTL_HPSRAM_MASK (3 << 0 | 3 << 16) | ||
#define SHIM_LDOCTL_LPSRAM_MASK (3 << 2) | ||
#define SHIM_LDOCTL_HPSRAM_LDO_ON (3 << 0 | 3 << 16) | ||
#define SHIM_LDOCTL_LPSRAM_LDO_ON (3 << 2) | ||
#define SHIM_LDOCTL_HPSRAM_LDO_OFF (0 << 0) | ||
#define SHIM_LDOCTL_LPSRAM_LDO_OFF (0 << 2) | ||
#define SHIM_LDOCTL_HPSRAM_LDO_BYPASS (BIT(0) | BIT(16)) | ||
#define SHIM_LDOCTL_LPSRAM_LDO_BYPASS BIT(2) | ||
|
||
.macro m_cavs_set_ldo_state state, ax | ||
movi \ax, (SHIM_BASE + SHIM_LDOCTL) | ||
s32i \state, \ax, 0 | ||
memw | ||
/* wait loop > 300ns (min 100ns required) */ | ||
movi \ax, 128 | ||
1 : | ||
addi \ax, \ax, -1 | ||
nop | ||
bnez \ax, 1b | ||
.endm | ||
|
||
.macro m_cavs_set_hpldo_state state, ax, ay | ||
movi \ax, (SHIM_BASE + SHIM_LDOCTL) | ||
l32i \ay, \ax, 0 | ||
|
||
movi \ax, ~(SHIM_LDOCTL_HPSRAM_MASK) | ||
and \ay, \ax, \ay | ||
or \state, \ay, \state | ||
|
||
m_cavs_set_ldo_state \state, \ax | ||
.endm | ||
|
||
.macro m_cavs_set_lpldo_state state, ax, ay | ||
movi \ax, (SHIM_BASE + SHIM_LDOCTL) | ||
l32i \ay, \ax, 0 | ||
/* LP SRAM mask */ | ||
movi \ax, ~(SHIM_LDOCTL_LPSRAM_MASK) | ||
and \ay, \ax, \ay | ||
or \state, \ay, \state | ||
|
||
m_cavs_set_ldo_state \state, \ax | ||
.endm | ||
|
||
.macro m_cavs_set_ldo_on_state ax, ay, az | ||
movi \ay, (SHIM_BASE + SHIM_LDOCTL) | ||
l32i \az, \ay, 0 | ||
|
||
movi \ax, ~(SHIM_LDOCTL_HPSRAM_MASK | SHIM_LDOCTL_LPSRAM_MASK) | ||
and \az, \ax, \az | ||
movi \ax, (SHIM_LDOCTL_HPSRAM_LDO_ON | SHIM_LDOCTL_LPSRAM_LDO_ON) | ||
or \ax, \az, \ax | ||
|
||
m_cavs_set_ldo_state \ax, \ay | ||
.endm | ||
|
||
.macro m_cavs_set_ldo_off_state ax, ay, az | ||
/* wait loop > 300ns (min 100ns required) */ | ||
movi \ax, 128 | ||
1 : | ||
addi \ax, \ax, -1 | ||
nop | ||
bnez \ax, 1b | ||
movi \ay, (SHIM_BASE + SHIM_LDOCTL) | ||
l32i \az, \ay, 0 | ||
|
||
movi \ax, ~(SHIM_LDOCTL_HPSRAM_MASK | SHIM_LDOCTL_LPSRAM_MASK) | ||
and \az, \az, \ax | ||
|
||
movi \ax, (SHIM_LDOCTL_HPSRAM_LDO_OFF | SHIM_LDOCTL_LPSRAM_LDO_OFF) | ||
or \ax, \ax, \az | ||
|
||
s32i \ax, \ay, 0 | ||
l32i \ax, \ay, 0 | ||
.endm | ||
|
||
.macro m_cavs_set_ldo_bypass_state ax, ay, az | ||
/* wait loop > 300ns (min 100ns required) */ | ||
movi \ax, 128 | ||
1 : | ||
addi \ax, \ax, -1 | ||
nop | ||
bnez \ax, 1b | ||
movi \ay, (SHIM_BASE + SHIM_LDOCTL) | ||
l32i \az, \ay, 0 | ||
|
||
movi \ax, ~(SHIM_LDOCTL_HPSRAM_MASK | SHIM_LDOCTL_LPSRAM_MASK) | ||
and \az, \az, \ax | ||
|
||
movi \ax, (SHIM_LDOCTL_HPSRAM_LDO_BYPASS | SHIM_LDOCTL_LPSRAM_LDO_BYPASS) | ||
or \ax, \ax, \az | ||
|
||
s32i \ax, \ay, 0 | ||
l32i \ax, \ay, 0 | ||
.endm | ||
|
||
#endif | ||
#endif /* __ZEPHYR_CAVS_LIB_ASM_LDO_MANAGEMENT_H__ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* Copyright (c) 2023 Intel Corporation | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#ifndef __ZEPHYR_CAVS_LIB_ASM_MEMORY_MANAGEMENT_H__ | ||
#define __ZEPHYR_CAVS_LIB_ASM_MEMORY_MANAGEMENT_H__ | ||
|
||
#ifdef _ASMLANGUAGE | ||
|
||
#define HSPGCTL0 0x71D10 | ||
#define HSRMCTL0 0x71D14 | ||
#define HSPGISTS0 0x71D18 | ||
|
||
#define LSPGCTL 0x71D50 | ||
#define LSRMCTL 0x71D54 | ||
#define LSPGISTS 0x71D58 | ||
|
||
#define SHIM_HSPGCTL(x) (HSPGCTL0 + 0x10 * (x)) | ||
#define SHIM_HSPGISTS(x) (HSPGISTS0 + 0x10 * (x)) | ||
|
||
#define LPSRAM_MASK 0x1 | ||
/** | ||
* Macro powers down entire HPSRAM. On entry literals and code for section from | ||
* where this code is executed need to be placed in memory which is not | ||
* HPSRAM (in case when this code is located in HPSRAM, lock memory in L1$ or | ||
* L1 SRAM) | ||
*/ | ||
.macro m_cavs_hpsram_power_down_entire ax, ay, az | ||
/* SEGMENT #0 */ | ||
movi \az, SHIM_HSPGCTL(0) | ||
movi \ax, SHIM_HSPGISTS(0) | ||
movi \ay, 0x1FFFFFFF /* HPSRAM_MASK(0) */ | ||
s32i \ay, \ax, 0 | ||
memw | ||
1 : | ||
l32i \ax, \az, 0 | ||
bne \ax, \ay, 1b | ||
|
||
/* SEGMENT #1 */ | ||
movi \az, SHIM_HSPGCTL(1) | ||
movi \ax, SHIM_HSPGISTS(1) | ||
movi \ay, 0x0FFFFFFF /* HPSRAM_MASK(1) */ | ||
s32i \ay, \ax, 0 | ||
memw | ||
1 : | ||
l32i \ax, \az, 0 | ||
bne \ax, \ay, 1b | ||
.endm | ||
|
||
.macro m_cavs_hpsram_power_change segment_index, mask, ax, ay, az | ||
movi \ax, SHIM_HSPGCTL(\segment_index) | ||
movi \ay, SHIM_HSPGISTS(\segment_index) | ||
s32i \mask, \ax, 0 | ||
memw | ||
/* assumed that HDA shared dma buffer will be in LPSRAM */ | ||
1 : | ||
l32i \ax, \ay, 0 | ||
bne \ax, \mask, 1b | ||
.endm | ||
|
||
.macro m_cavs_lpsram_power_down_entire ax, ay, az, loop_cnt_addr | ||
movi \az, LSPGISTS | ||
movi \ax, LSPGCTL | ||
movi \ay, LPSRAM_MASK | ||
s32i \ay, \ax, 0 | ||
memw | ||
/* assumed that HDA shared dma buffer will be in LPSRAM */ | ||
movi \ax, \loop_cnt_addr | ||
l32i \ax, \ax, 0 | ||
1 : | ||
addi \ax, \ax, -1 | ||
bnez \ax, 1b | ||
.endm | ||
|
||
#endif | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.