/* SPDX-License-Identifier: GPL-2.0 */ /* * reg.h - mmio accessors. ld/st straight to the device, nothing cute. * * Copyright (C) 2026 Bradley Morgan * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ #ifndef __REG_H #define __REG_H #include #include #define REG32(addr) ((volatile uint32_t *)(uintptr_t)(addr)) static inline void writel(uint32_t v, volatile void *addr) { *(volatile uint32_t *)addr = v; } static inline uint32_t readl(const volatile void *addr) { return *(const volatile uint32_t *)addr; } static inline void writew(uint16_t v, volatile void *addr) { *(volatile uint16_t *)addr = v; } static inline uint16_t readw(const volatile void *addr) { return *(const volatile uint16_t *)addr; } static inline void writeb(uint8_t v, volatile void *addr) { *(volatile uint8_t *)addr = v; } static inline uint8_t readb(const volatile void *addr) { return *(const volatile uint8_t *)addr; } #endif