| 1 |
/* |
| 2 |
* Copyright (c) 2024, Rockchip, Inc. All rights reserved. |
| 3 |
* |
| 4 |
* SPDX-License-Identifier: BSD-3-Clause |
| 5 |
*/ |
| 6 |
|
| 7 |
#ifndef PLAT_PM_HELPERS_H |
| 8 |
#define PLAT_PM_HELPERS_H |
| 9 |
|
| 10 |
#include <stdint.h> |
| 11 |
|
| 12 |
/** |
| 13 |
* Use this macro to define a register region. |
| 14 |
* start: start offset from the base address. |
| 15 |
* end: end offset from the base address. |
| 16 |
* stride: stride of registers in region. |
| 17 |
* base: base address of registers in region. |
| 18 |
* wmsk: write mask of registers in region. |
| 19 |
*/ |
| 20 |
#define REG_REGION(_start, _end, _stride, _base, _wmsk) \ |
| 21 |
{ \ |
| 22 |
.start = (_base) + (_start), \ |
| 23 |
.end = (_base) + (_end), \ |
| 24 |
.stride = _stride, \ |
| 25 |
.wmsk = _wmsk \ |
| 26 |
} |
| 27 |
|
| 28 |
struct reg_region { |
| 29 |
/* Start address of region */ |
| 30 |
uint32_t start; |
| 31 |
/* End address of region */ |
| 32 |
uint32_t end; |
| 33 |
/* Stride of registers in region */ |
| 34 |
uint32_t stride; |
| 35 |
/* Write mask of registers in region */ |
| 36 |
uint32_t wmsk; |
| 37 |
/* Buffer to save/restore registers in region */ |
| 38 |
uint32_t *buf; |
| 39 |
}; |
| 40 |
|
| 41 |
void rockchip_alloc_region_mem(struct reg_region *rgns, uint32_t rgn_num); |
| 42 |
void rockchip_reg_rgn_save(struct reg_region *rgns, uint32_t rgn_num); |
| 43 |
void rockchip_reg_rgn_restore(struct reg_region *rgns, uint32_t rgn_num); |
| 44 |
void rockchip_reg_rgn_restore_reverse(struct reg_region *rgns, uint32_t rgn_num); |
| 45 |
void rockchip_regs_dump(uint32_t base, |
| 46 |
uint32_t start_offset, |
| 47 |
uint32_t end_offset, |
| 48 |
uint32_t stride); |
| 49 |
void rockchip_dump_reg_rgns(struct reg_region *rgns, uint32_t rgn_num); |
| 50 |
|
| 51 |
#endif /* PLAT_PM_HELPERS_H */ |