^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0-or-later */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * (c) Copyright 2006 Benjamin Herrenschmidt, IBM Corp.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * <benh@kernel.crashing.org>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #ifndef _ASM_POWERPC_DCR_MMIO_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #define _ASM_POWERPC_DCR_MMIO_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #ifdef __KERNEL__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <asm/io.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) typedef struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) void __iomem *token;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) unsigned int stride;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) unsigned int base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) } dcr_host_mmio_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) static inline bool dcr_map_ok_mmio(dcr_host_mmio_t host)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) return host.token != NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) extern dcr_host_mmio_t dcr_map_mmio(struct device_node *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) unsigned int dcr_n,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) unsigned int dcr_c);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) extern void dcr_unmap_mmio(dcr_host_mmio_t host, unsigned int dcr_c);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) static inline u32 dcr_read_mmio(dcr_host_mmio_t host, unsigned int dcr_n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) return in_be32(host.token + ((host.base + dcr_n) * host.stride));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) static inline void dcr_write_mmio(dcr_host_mmio_t host,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) unsigned int dcr_n,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) u32 value)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) out_be32(host.token + ((host.base + dcr_n) * host.stride), value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) #endif /* __KERNEL__ */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) #endif /* _ASM_POWERPC_DCR_MMIO_H */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)