2 * Copyright (c) 2017-2018, ARM Limited and Contributors. All rights reserved.
4 * SPDX-License-Identifier: BSD-3-Clause
10 #include <drivers/arm/smmu_v3.h>
13 static inline uint32_t __init
smmuv3_read_s_idr1(uintptr_t base
)
15 return mmio_read_32(base
+ SMMU_S_IDR1
);
18 static inline uint32_t __init
smmuv3_read_s_init(uintptr_t base
)
20 return mmio_read_32(base
+ SMMU_S_INIT
);
23 static inline void __init
smmuv3_write_s_init(uintptr_t base
, uint32_t value
)
25 mmio_write_32(base
+ SMMU_S_INIT
, value
);
28 /* Test for pending invalidate */
29 static inline bool smmuv3_inval_pending(uintptr_t base
)
31 return (smmuv3_read_s_init(base
) & SMMU_S_INIT_INV_ALL_MASK
) != 0U;
35 * Initialize the SMMU by invalidating all secure caches and TLBs.
37 * Returns 0 on success, and -1 on failure.
39 int __init
smmuv3_init(uintptr_t smmu_base
)
44 * Invalidation of secure caches and TLBs is required only if the SMMU
45 * supports secure state. If not, it's implementation defined as to how
46 * SMMU_S_INIT register is accessed.
48 idr1_reg
= smmuv3_read_s_idr1(smmu_base
);
49 if (((idr1_reg
>> SMMU_S_IDR1_SECURE_IMPL_SHIFT
) &
50 SMMU_S_IDR1_SECURE_IMPL_MASK
) == 0U) {
54 /* Initiate invalidation, and wait for it to finish */
55 smmuv3_write_s_init(smmu_base
, SMMU_S_INIT_INV_ALL_MASK
);
56 while (smmuv3_inval_pending(smmu_base
))