1/* 2 * Copyright 2014, General Dynamics C4 Systems 3 * 4 * SPDX-License-Identifier: GPL-2.0-only 5 */ 6 7#pragma once 8 9static inline void wfi(void) 10{ 11 /* 12 * The wait-for-interrupt doesn't work on the KZM board, although, 13 * according to the arm infocenter, it should. With the KZM currently 14 * being the only supported ARMv6 platform, it is unclear at this 15 * time wether it works for other SoCs (e.g. BCM2835), so we explicitly 16 * disable only the KZM here. 17 * 18 * See: http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.faqs/ka13332.html 19 */ 20#ifndef CONFIG_PLAT_KZM 21 asm volatile("mcr p15, 0, %0, c7, c0, 4" : : "r"(0) : "memory"); 22#endif 23} 24 25static inline void dsb(void) 26{ 27 asm volatile("mcr p15, 0, %0, c7, c10, 4" : : "r"(0) : "memory"); 28} 29 30static inline void dmb(void) 31{ 32 asm volatile("mcr p15, 0, %0, c7, c10, 5" : : "r"(0) : "memory"); 33} 34 35static inline void isb(void) 36{ 37 asm volatile("mcr p15, 0, %0, c7, c5, 4" : : "r"(0) : "memory"); 38} 39 40#define MRC(cpreg, v) asm volatile("mrc " cpreg : "=r"(v)) 41#define MRRC(cpreg, v) asm volatile("mrrc " cpreg : "=r"(v)) 42#define MCR(cpreg, v) \ 43 do { \ 44 word_t _v = v; \ 45 asm volatile("mcr " cpreg :: "r" (_v)); \ 46 }while(0) 47#define MCRR(cpreg, v) \ 48 do { \ 49 uint64_t _v = v; \ 50 asm volatile("mcrr " cpreg :: "r" (_v)); \ 51 }while(0) 52 53#define SYSTEM_WRITE_WORD(reg, v) MCR(reg, v) 54#define SYSTEM_READ_WORD(reg, v) MRC(reg, v) 55#define SYSTEM_WRITE_64(reg, v) MCRR(reg, v) 56#define SYSTEM_READ_64(reg, v) MRRC(reg, v) 57 58