1 /* SPDX-License-Identifier: BSD-2-Clause */ 2 /* 3 * Copyright 2018-2019 NXP 4 * 5 * Brief CAAM driver common include file. 6 * Definition of the structure type to save and restore 7 * HW registers configuration 8 */ 9 #ifndef __CAAM_PWR_H__ 10 #define __CAAM_PWR_H__ 11 12 #include <sys/queue.h> 13 14 /* 15 * Definition of the structure type used to list HW registers 16 * to be saved and restored. 17 */ 18 struct reglist { 19 uint32_t offset; /* Register offset */ 20 uint32_t nbregs; /* Number of consecutive registers */ 21 uint32_t mask_clr; /* Clear mask of bit to exclude in restore value */ 22 uint32_t mask_set; /* Set mask of bit to force in restore value */ 23 }; 24 25 #define BACKUP_REG(_offset, _nbregs, _mask_clr, _mask_set) \ 26 { \ 27 .offset = _offset, .nbregs = _nbregs, .mask_clr = _mask_clr, \ 28 .mask_set = _mask_set, \ 29 } 30 /* 31 * Definition of the structure type used to store registers to backup 32 */ 33 struct backup_data { 34 vaddr_t baseaddr; /* Register virtual base address */ 35 size_t nbentries; /* Number of entries in the list */ 36 const struct reglist *regs; /* Register list */ 37 uint32_t *val; /* Register value */ 38 39 SLIST_ENTRY(backup_data) next; /* Link to next data */ 40 }; 41 42 /* 43 * Add definition of the backup data in the list 44 * 45 * @baseaddr Register base address 46 * @regs Register list 47 * @nbentries Number of entries in the list 48 */ 49 void caam_pwr_add_backup(vaddr_t baseaddr, const struct reglist *regs, 50 size_t nbentries); 51 52 /* 53 * Power Initialization function called when all CAAM modules are 54 * initialized correctly. 55 * Register the PM callback in the system. 56 */ 57 void caam_pwr_init(void); 58 59 #endif /* __CAAM_PWR_H__ */ 60