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_H
88c2ecf20Sopenharmony_ci#define _ASM_POWERPC_DCR_H
98c2ecf20Sopenharmony_ci#ifdef __KERNEL__
108c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__
118c2ecf20Sopenharmony_ci#ifdef CONFIG_PPC_DCR
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci#ifdef CONFIG_PPC_DCR_NATIVE
148c2ecf20Sopenharmony_ci#include <asm/dcr-native.h>
158c2ecf20Sopenharmony_ci#endif
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci#ifdef CONFIG_PPC_DCR_MMIO
188c2ecf20Sopenharmony_ci#include <asm/dcr-mmio.h>
198c2ecf20Sopenharmony_ci#endif
208c2ecf20Sopenharmony_ci
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_ci/* Indirection layer for providing both NATIVE and MMIO support. */
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ci#if defined(CONFIG_PPC_DCR_NATIVE) && defined(CONFIG_PPC_DCR_MMIO)
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ci#include <asm/dcr-generic.h>
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci#define DCR_MAP_OK(host)	dcr_map_ok_generic(host)
298c2ecf20Sopenharmony_ci#define dcr_map(dev, dcr_n, dcr_c) dcr_map_generic(dev, dcr_n, dcr_c)
308c2ecf20Sopenharmony_ci#define dcr_unmap(host, dcr_c) dcr_unmap_generic(host, dcr_c)
318c2ecf20Sopenharmony_ci#define dcr_read(host, dcr_n) dcr_read_generic(host, dcr_n)
328c2ecf20Sopenharmony_ci#define dcr_write(host, dcr_n, value) dcr_write_generic(host, dcr_n, value)
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_ci#else
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_ci#ifdef CONFIG_PPC_DCR_NATIVE
378c2ecf20Sopenharmony_citypedef dcr_host_native_t dcr_host_t;
388c2ecf20Sopenharmony_ci#define DCR_MAP_OK(host)	dcr_map_ok_native(host)
398c2ecf20Sopenharmony_ci#define dcr_map(dev, dcr_n, dcr_c) dcr_map_native(dev, dcr_n, dcr_c)
408c2ecf20Sopenharmony_ci#define dcr_unmap(host, dcr_c) dcr_unmap_native(host, dcr_c)
418c2ecf20Sopenharmony_ci#define dcr_read(host, dcr_n) dcr_read_native(host, dcr_n)
428c2ecf20Sopenharmony_ci#define dcr_write(host, dcr_n, value) dcr_write_native(host, dcr_n, value)
438c2ecf20Sopenharmony_ci#else
448c2ecf20Sopenharmony_citypedef dcr_host_mmio_t dcr_host_t;
458c2ecf20Sopenharmony_ci#define DCR_MAP_OK(host)	dcr_map_ok_mmio(host)
468c2ecf20Sopenharmony_ci#define dcr_map(dev, dcr_n, dcr_c) dcr_map_mmio(dev, dcr_n, dcr_c)
478c2ecf20Sopenharmony_ci#define dcr_unmap(host, dcr_c) dcr_unmap_mmio(host, dcr_c)
488c2ecf20Sopenharmony_ci#define dcr_read(host, dcr_n) dcr_read_mmio(host, dcr_n)
498c2ecf20Sopenharmony_ci#define dcr_write(host, dcr_n, value) dcr_write_mmio(host, dcr_n, value)
508c2ecf20Sopenharmony_ci#endif
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_ci#endif /* defined(CONFIG_PPC_DCR_NATIVE) && defined(CONFIG_PPC_DCR_MMIO) */
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_ci/*
558c2ecf20Sopenharmony_ci * additional helpers to read the DCR * base from the device-tree
568c2ecf20Sopenharmony_ci */
578c2ecf20Sopenharmony_cistruct device_node;
588c2ecf20Sopenharmony_ciextern unsigned int dcr_resource_start(const struct device_node *np,
598c2ecf20Sopenharmony_ci				       unsigned int index);
608c2ecf20Sopenharmony_ciextern unsigned int dcr_resource_len(const struct device_node *np,
618c2ecf20Sopenharmony_ci				     unsigned int index);
628c2ecf20Sopenharmony_ci#endif /* CONFIG_PPC_DCR */
638c2ecf20Sopenharmony_ci#endif /* __ASSEMBLY__ */
648c2ecf20Sopenharmony_ci#endif /* __KERNEL__ */
658c2ecf20Sopenharmony_ci#endif /* _ASM_POWERPC_DCR_H */
66