18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * (c) Copyright 2006 Benjamin Herrenschmidt, IBM Corp. 48c2ecf20Sopenharmony_ci * <benh@kernel.crashing.org> 58c2ecf20Sopenharmony_ci */ 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ci#ifndef _ASM_POWERPC_DCR_MMIO_H 88c2ecf20Sopenharmony_ci#define _ASM_POWERPC_DCR_MMIO_H 98c2ecf20Sopenharmony_ci#ifdef __KERNEL__ 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#include <asm/io.h> 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_citypedef struct { 148c2ecf20Sopenharmony_ci void __iomem *token; 158c2ecf20Sopenharmony_ci unsigned int stride; 168c2ecf20Sopenharmony_ci unsigned int base; 178c2ecf20Sopenharmony_ci} dcr_host_mmio_t; 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_cistatic inline bool dcr_map_ok_mmio(dcr_host_mmio_t host) 208c2ecf20Sopenharmony_ci{ 218c2ecf20Sopenharmony_ci return host.token != NULL; 228c2ecf20Sopenharmony_ci} 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ciextern dcr_host_mmio_t dcr_map_mmio(struct device_node *dev, 258c2ecf20Sopenharmony_ci unsigned int dcr_n, 268c2ecf20Sopenharmony_ci unsigned int dcr_c); 278c2ecf20Sopenharmony_ciextern void dcr_unmap_mmio(dcr_host_mmio_t host, unsigned int dcr_c); 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_cistatic inline u32 dcr_read_mmio(dcr_host_mmio_t host, unsigned int dcr_n) 308c2ecf20Sopenharmony_ci{ 318c2ecf20Sopenharmony_ci return in_be32(host.token + ((host.base + dcr_n) * host.stride)); 328c2ecf20Sopenharmony_ci} 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_cistatic inline void dcr_write_mmio(dcr_host_mmio_t host, 358c2ecf20Sopenharmony_ci unsigned int dcr_n, 368c2ecf20Sopenharmony_ci u32 value) 378c2ecf20Sopenharmony_ci{ 388c2ecf20Sopenharmony_ci out_be32(host.token + ((host.base + dcr_n) * host.stride), value); 398c2ecf20Sopenharmony_ci} 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ci#endif /* __KERNEL__ */ 428c2ecf20Sopenharmony_ci#endif /* _ASM_POWERPC_DCR_MMIO_H */ 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ci 45