1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3 * (C) COPYRIGHT 2018 ARM Limited. All rights reserved.
4 * Author: James.Qian.Wang <james.qian.wang@arm.com>
5 *
6 */
7 #ifndef _MALIDP_IO_H_
8 #define _MALIDP_IO_H_
9
10 #include <linux/io.h>
11
12 static inline u32
malidp_read32(u32 __iomem * base,u32 offset)13 malidp_read32(u32 __iomem *base, u32 offset)
14 {
15 return readl((base + (offset >> 2)));
16 }
17
18 static inline void
malidp_write32(u32 __iomem * base,u32 offset,u32 v)19 malidp_write32(u32 __iomem *base, u32 offset, u32 v)
20 {
21 writel(v, (base + (offset >> 2)));
22 }
23
24 static inline void
malidp_write64(u32 __iomem * base,u32 offset,u64 v)25 malidp_write64(u32 __iomem *base, u32 offset, u64 v)
26 {
27 writel(lower_32_bits(v), (base + (offset >> 2)));
28 writel(upper_32_bits(v), (base + (offset >> 2) + 1));
29 }
30
31 static inline void
malidp_write32_mask(u32 __iomem * base,u32 offset,u32 m,u32 v)32 malidp_write32_mask(u32 __iomem *base, u32 offset, u32 m, u32 v)
33 {
34 u32 tmp = malidp_read32(base, offset);
35
36 tmp &= (~m);
37 malidp_write32(base, offset, v | tmp);
38 }
39
40 static inline void
malidp_write_group(u32 __iomem * base,u32 offset,int num,const u32 * values)41 malidp_write_group(u32 __iomem *base, u32 offset, int num, const u32 *values)
42 {
43 int i;
44
45 for (i = 0; i < num; i++)
46 malidp_write32(base, offset + i * 4, values[i]);
47 }
48
49 #endif /*_MALIDP_IO_H_*/
50