126bd43a7Sjames qian wang (Arm Technology China) /* SPDX-License-Identifier: GPL-2.0 */
226bd43a7Sjames qian wang (Arm Technology China) /*
326bd43a7Sjames qian wang (Arm Technology China) * (C) COPYRIGHT 2018 ARM Limited. All rights reserved.
426bd43a7Sjames qian wang (Arm Technology China) * Author: James.Qian.Wang <james.qian.wang@arm.com>
526bd43a7Sjames qian wang (Arm Technology China) *
626bd43a7Sjames qian wang (Arm Technology China) */
726bd43a7Sjames qian wang (Arm Technology China) #ifndef _MALIDP_IO_H_
826bd43a7Sjames qian wang (Arm Technology China) #define _MALIDP_IO_H_
926bd43a7Sjames qian wang (Arm Technology China)
1026bd43a7Sjames qian wang (Arm Technology China) #include <linux/io.h>
1126bd43a7Sjames qian wang (Arm Technology China)
1226bd43a7Sjames qian wang (Arm Technology China) static inline u32
malidp_read32(u32 __iomem * base,u32 offset)1326bd43a7Sjames qian wang (Arm Technology China) malidp_read32(u32 __iomem *base, u32 offset)
1426bd43a7Sjames qian wang (Arm Technology China) {
1526bd43a7Sjames qian wang (Arm Technology China) return readl((base + (offset >> 2)));
1626bd43a7Sjames qian wang (Arm Technology China) }
1726bd43a7Sjames qian wang (Arm Technology China)
1826bd43a7Sjames qian wang (Arm Technology China) static inline void
malidp_write32(u32 __iomem * base,u32 offset,u32 v)1926bd43a7Sjames qian wang (Arm Technology China) malidp_write32(u32 __iomem *base, u32 offset, u32 v)
2026bd43a7Sjames qian wang (Arm Technology China) {
2126bd43a7Sjames qian wang (Arm Technology China) writel(v, (base + (offset >> 2)));
2226bd43a7Sjames qian wang (Arm Technology China) }
2326bd43a7Sjames qian wang (Arm Technology China)
2426bd43a7Sjames qian wang (Arm Technology China) static inline void
malidp_write64(u32 __iomem * base,u32 offset,u64 v)25*04e84545Sjames qian wang (Arm Technology China) malidp_write64(u32 __iomem *base, u32 offset, u64 v)
26*04e84545Sjames qian wang (Arm Technology China) {
27*04e84545Sjames qian wang (Arm Technology China) writel(lower_32_bits(v), (base + (offset >> 2)));
28*04e84545Sjames qian wang (Arm Technology China) writel(upper_32_bits(v), (base + (offset >> 2) + 1));
29*04e84545Sjames qian wang (Arm Technology China) }
30*04e84545Sjames qian wang (Arm Technology China)
31*04e84545Sjames qian wang (Arm Technology China) static inline void
malidp_write32_mask(u32 __iomem * base,u32 offset,u32 m,u32 v)3226bd43a7Sjames qian wang (Arm Technology China) malidp_write32_mask(u32 __iomem *base, u32 offset, u32 m, u32 v)
3326bd43a7Sjames qian wang (Arm Technology China) {
3426bd43a7Sjames qian wang (Arm Technology China) u32 tmp = malidp_read32(base, offset);
3526bd43a7Sjames qian wang (Arm Technology China)
3626bd43a7Sjames qian wang (Arm Technology China) tmp &= (~m);
3726bd43a7Sjames qian wang (Arm Technology China) malidp_write32(base, offset, v | tmp);
3826bd43a7Sjames qian wang (Arm Technology China) }
3926bd43a7Sjames qian wang (Arm Technology China)
4026bd43a7Sjames qian wang (Arm Technology China) static inline void
malidp_write_group(u32 __iomem * base,u32 offset,int num,const u32 * values)4126bd43a7Sjames qian wang (Arm Technology China) malidp_write_group(u32 __iomem *base, u32 offset, int num, const u32 *values)
4226bd43a7Sjames qian wang (Arm Technology China) {
4326bd43a7Sjames qian wang (Arm Technology China) int i;
4426bd43a7Sjames qian wang (Arm Technology China)
4526bd43a7Sjames qian wang (Arm Technology China) for (i = 0; i < num; i++)
4626bd43a7Sjames qian wang (Arm Technology China) malidp_write32(base, offset + i * 4, values[i]);
4726bd43a7Sjames qian wang (Arm Technology China) }
4826bd43a7Sjames qian wang (Arm Technology China)
4926bd43a7Sjames qian wang (Arm Technology China) #endif /*_MALIDP_IO_H_*/
50