162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * (c) Copyright 2006 Benjamin Herrenschmidt, IBM Corp. 462306a36Sopenharmony_ci * <benh@kernel.crashing.org> 562306a36Sopenharmony_ci */ 662306a36Sopenharmony_ci 762306a36Sopenharmony_ci#ifndef _ASM_POWERPC_DCR_H 862306a36Sopenharmony_ci#define _ASM_POWERPC_DCR_H 962306a36Sopenharmony_ci#ifdef __KERNEL__ 1062306a36Sopenharmony_ci#ifndef __ASSEMBLY__ 1162306a36Sopenharmony_ci#ifdef CONFIG_PPC_DCR 1262306a36Sopenharmony_ci 1362306a36Sopenharmony_ci#ifdef CONFIG_PPC_DCR_NATIVE 1462306a36Sopenharmony_ci#include <asm/dcr-native.h> 1562306a36Sopenharmony_ci#endif 1662306a36Sopenharmony_ci 1762306a36Sopenharmony_ci#ifdef CONFIG_PPC_DCR_MMIO 1862306a36Sopenharmony_ci#include <asm/dcr-mmio.h> 1962306a36Sopenharmony_ci#endif 2062306a36Sopenharmony_ci 2162306a36Sopenharmony_ci 2262306a36Sopenharmony_ci/* Indirection layer for providing both NATIVE and MMIO support. */ 2362306a36Sopenharmony_ci 2462306a36Sopenharmony_ci#if defined(CONFIG_PPC_DCR_NATIVE) && defined(CONFIG_PPC_DCR_MMIO) 2562306a36Sopenharmony_ci 2662306a36Sopenharmony_ci#include <asm/dcr-generic.h> 2762306a36Sopenharmony_ci 2862306a36Sopenharmony_ci#define DCR_MAP_OK(host) dcr_map_ok_generic(host) 2962306a36Sopenharmony_ci#define dcr_map(dev, dcr_n, dcr_c) dcr_map_generic(dev, dcr_n, dcr_c) 3062306a36Sopenharmony_ci#define dcr_unmap(host, dcr_c) dcr_unmap_generic(host, dcr_c) 3162306a36Sopenharmony_ci#define dcr_read(host, dcr_n) dcr_read_generic(host, dcr_n) 3262306a36Sopenharmony_ci#define dcr_write(host, dcr_n, value) dcr_write_generic(host, dcr_n, value) 3362306a36Sopenharmony_ci 3462306a36Sopenharmony_ci#else 3562306a36Sopenharmony_ci 3662306a36Sopenharmony_ci#ifdef CONFIG_PPC_DCR_NATIVE 3762306a36Sopenharmony_citypedef dcr_host_native_t dcr_host_t; 3862306a36Sopenharmony_ci#define DCR_MAP_OK(host) dcr_map_ok_native(host) 3962306a36Sopenharmony_ci#define dcr_map(dev, dcr_n, dcr_c) dcr_map_native(dev, dcr_n, dcr_c) 4062306a36Sopenharmony_ci#define dcr_unmap(host, dcr_c) dcr_unmap_native(host, dcr_c) 4162306a36Sopenharmony_ci#define dcr_read(host, dcr_n) dcr_read_native(host, dcr_n) 4262306a36Sopenharmony_ci#define dcr_write(host, dcr_n, value) dcr_write_native(host, dcr_n, value) 4362306a36Sopenharmony_ci#else 4462306a36Sopenharmony_citypedef dcr_host_mmio_t dcr_host_t; 4562306a36Sopenharmony_ci#define DCR_MAP_OK(host) dcr_map_ok_mmio(host) 4662306a36Sopenharmony_ci#define dcr_map(dev, dcr_n, dcr_c) dcr_map_mmio(dev, dcr_n, dcr_c) 4762306a36Sopenharmony_ci#define dcr_unmap(host, dcr_c) dcr_unmap_mmio(host, dcr_c) 4862306a36Sopenharmony_ci#define dcr_read(host, dcr_n) dcr_read_mmio(host, dcr_n) 4962306a36Sopenharmony_ci#define dcr_write(host, dcr_n, value) dcr_write_mmio(host, dcr_n, value) 5062306a36Sopenharmony_ci#endif 5162306a36Sopenharmony_ci 5262306a36Sopenharmony_ci#endif /* defined(CONFIG_PPC_DCR_NATIVE) && defined(CONFIG_PPC_DCR_MMIO) */ 5362306a36Sopenharmony_ci 5462306a36Sopenharmony_ci/* 5562306a36Sopenharmony_ci * additional helpers to read the DCR * base from the device-tree 5662306a36Sopenharmony_ci */ 5762306a36Sopenharmony_cistruct device_node; 5862306a36Sopenharmony_ciextern unsigned int dcr_resource_start(const struct device_node *np, 5962306a36Sopenharmony_ci unsigned int index); 6062306a36Sopenharmony_ciextern unsigned int dcr_resource_len(const struct device_node *np, 6162306a36Sopenharmony_ci unsigned int index); 6262306a36Sopenharmony_ci#endif /* CONFIG_PPC_DCR */ 6362306a36Sopenharmony_ci#endif /* __ASSEMBLY__ */ 6462306a36Sopenharmony_ci#endif /* __KERNEL__ */ 6562306a36Sopenharmony_ci#endif /* _ASM_POWERPC_DCR_H */ 66