Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 53 additions & 1 deletion soc/nordic/nrf54h/pm_s2ram.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,26 @@
uint32_t CTRL;
} _mpu_context_t;

typedef struct {
uint32_t ICSR;

Check warning on line 44 in soc/nordic/nrf54h/pm_s2ram.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

LEADING_SPACE

soc/nordic/nrf54h/pm_s2ram.c:44 please, no spaces at the start of a line
uint32_t VTOR;

Check warning on line 45 in soc/nordic/nrf54h/pm_s2ram.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

LEADING_SPACE

soc/nordic/nrf54h/pm_s2ram.c:45 please, no spaces at the start of a line
uint32_t AIRCR;

Check warning on line 46 in soc/nordic/nrf54h/pm_s2ram.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

LEADING_SPACE

soc/nordic/nrf54h/pm_s2ram.c:46 please, no spaces at the start of a line
uint32_t SCR;

Check warning on line 47 in soc/nordic/nrf54h/pm_s2ram.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

LEADING_SPACE

soc/nordic/nrf54h/pm_s2ram.c:47 please, no spaces at the start of a line
uint32_t CCR;

Check warning on line 48 in soc/nordic/nrf54h/pm_s2ram.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

LEADING_SPACE

soc/nordic/nrf54h/pm_s2ram.c:48 please, no spaces at the start of a line
uint32_t SHPR[12U];

Check warning on line 49 in soc/nordic/nrf54h/pm_s2ram.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

LEADING_SPACE

soc/nordic/nrf54h/pm_s2ram.c:49 please, no spaces at the start of a line
uint32_t SHCSR;

Check warning on line 50 in soc/nordic/nrf54h/pm_s2ram.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

LEADING_SPACE

soc/nordic/nrf54h/pm_s2ram.c:50 please, no spaces at the start of a line
uint32_t CFSR;

Check warning on line 51 in soc/nordic/nrf54h/pm_s2ram.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

LEADING_SPACE

soc/nordic/nrf54h/pm_s2ram.c:51 please, no spaces at the start of a line
uint32_t HFSR;

Check warning on line 52 in soc/nordic/nrf54h/pm_s2ram.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

LEADING_SPACE

soc/nordic/nrf54h/pm_s2ram.c:52 please, no spaces at the start of a line
uint32_t DFSR;

Check warning on line 53 in soc/nordic/nrf54h/pm_s2ram.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

LEADING_SPACE

soc/nordic/nrf54h/pm_s2ram.c:53 please, no spaces at the start of a line
uint32_t MMFAR;
uint32_t BFAR;
uint32_t AFSR;
} _scb_context_t;

struct backup {
_nvic_context_t nvic_context;
_mpu_context_t mpu_context;
_scb_context_t scb_context;
};

static __noinit struct backup backup_data;
Expand Down Expand Up @@ -107,10 +124,45 @@
memcpy((uint32_t *)NVIC->IPR, backup->IPR, sizeof(NVIC->IPR));
}

static void scb_suspend(_scb_context_t *backup)
{
backup->ICSR = SCB->ICSR;
backup->VTOR = SCB->VTOR;
backup->AIRCR = SCB->AIRCR;
backup->SCR = SCB->SCR;
backup->CCR = SCB->CCR;
memcpy(backup->SHPR, (uint32_t *)SCB->SHPR, sizeof(SCB->SHPR));
backup->SHCSR = SCB->SHCSR;
backup->CFSR = SCB->CFSR;
backup->HFSR = SCB->HFSR;
backup->DFSR = SCB->DFSR;
backup->MMFAR = SCB->MMFAR;
backup->BFAR = SCB->BFAR;
backup->AFSR = SCB->AFSR;
}

static void scb_resume(_scb_context_t *backup)
{
SCB->ICSR = backup->ICSR;
SCB->VTOR = backup->VTOR;
SCB->AIRCR = backup->AIRCR;
SCB->SCR = backup->SCR;
SCB->CCR = backup->CCR;
memcpy((uint32_t *)SCB->SHPR, backup->SHPR, sizeof(SCB->SHPR));
SCB->SHCSR = backup->SHCSR;
SCB->CFSR = backup->CFSR;
SCB->HFSR = backup->HFSR;
SCB->DFSR = backup->DFSR;
SCB->MMFAR = backup->MMFAR;
SCB->BFAR = backup->BFAR;
SCB->AFSR = backup->AFSR;
}

int soc_s2ram_suspend(pm_s2ram_system_off_fn_t system_off)
{
int ret;

scb_suspend(&backup_data.scb_context);
nvic_suspend(&backup_data.nvic_context);
mpu_suspend(&backup_data.mpu_context);
ret = arch_pm_s2ram_suspend(system_off);
Expand All @@ -120,7 +172,7 @@

mpu_resume(&backup_data.mpu_context);
nvic_resume(&backup_data.nvic_context);

scb_resume(&backup_data.scb_context);
return ret;
}

Expand Down
Loading