xref: /rk3399_ARM-atf/plat/intel/soc/common/lib/utils/alignment_utils.c (revision cbf956ad0b4d62f7f93fd33d975a4d961009d83f)
1 /*
2  * Copyright (c) 2025, Altera Corporation. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 
8 #include <arch_helpers.h>
9 #include <common/debug.h>
10 #include <lib/mmio.h>
11 
12 #include "alignment_utils.h"
13 #include "socfpga_mailbox.h"
14 
15 bool is_size_4_bytes_aligned(uint32_t size)
16 {
17 	if ((size % MBOX_WORD_BYTE) != 0U) {
18 		return false;
19 	} else {
20 		return true;
21 	}
22 }
23 
24 bool is_8_bytes_aligned(uint32_t data)
25 {
26 	if ((data % (MBOX_WORD_BYTE * 2U)) != 0U) {
27 		return false;
28 	} else {
29 		return true;
30 	}
31 }
32 
33 /* As of now used on only Agilex5 platform. */
34 bool is_16_bytes_aligned(uint32_t data)
35 {
36 	if ((data % (MBOX_WORD_BYTE * 4U)) != 0U)
37 		return false;
38 	else
39 		return true;
40 }
41 
42 bool is_32_bytes_aligned(uint32_t data)
43 {
44 	if ((data % (8U * MBOX_WORD_BYTE)) != 0U) {
45 		return false;
46 	} else {
47 		return true;
48 	}
49 }
50