blob: fc6d93ef4a1370ecf2e797697c1c0b94982886d2 [file] [log] [blame]
Thomas Gleixner1a59d1b82019-05-27 08:55:05 +02001/* SPDX-License-Identifier: GPL-2.0-or-later */
Benjamin Herrenschmidt4c75a6f2006-11-11 17:24:53 +11002/*
3 * (c) Copyright 2006 Benjamin Herrenschmidt, IBM Corp.
4 * <benh@kernel.crashing.org>
Benjamin Herrenschmidt4c75a6f2006-11-11 17:24:53 +11005 */
6
7#ifndef _ASM_POWERPC_DCR_MMIO_H
8#define _ASM_POWERPC_DCR_MMIO_H
9#ifdef __KERNEL__
10
11#include <asm/io.h>
12
Michael Ellerman0b94a1e2007-09-17 16:05:00 +100013typedef struct {
14 void __iomem *token;
15 unsigned int stride;
16 unsigned int base;
Stephen Neuendorfferb786af112008-05-07 04:29:17 +100017} dcr_host_mmio_t;
Benjamin Herrenschmidt4c75a6f2006-11-11 17:24:53 +110018
Stephen Neuendorfferb786af112008-05-07 04:29:17 +100019static inline bool dcr_map_ok_mmio(dcr_host_mmio_t host)
20{
21 return host.token != NULL;
22}
Benjamin Herrenschmidt4c75a6f2006-11-11 17:24:53 +110023
Stephen Neuendorfferb786af112008-05-07 04:29:17 +100024extern dcr_host_mmio_t dcr_map_mmio(struct device_node *dev,
25 unsigned int dcr_n,
26 unsigned int dcr_c);
27extern void dcr_unmap_mmio(dcr_host_mmio_t host, unsigned int dcr_c);
Benjamin Herrenschmidt4c75a6f2006-11-11 17:24:53 +110028
Stephen Neuendorfferb786af112008-05-07 04:29:17 +100029static inline u32 dcr_read_mmio(dcr_host_mmio_t host, unsigned int dcr_n)
Benjamin Herrenschmidt4c75a6f2006-11-11 17:24:53 +110030{
Michael Ellerman83f34df2007-10-15 19:34:36 +100031 return in_be32(host.token + ((host.base + dcr_n) * host.stride));
Benjamin Herrenschmidt4c75a6f2006-11-11 17:24:53 +110032}
33
Stephen Neuendorfferb786af112008-05-07 04:29:17 +100034static inline void dcr_write_mmio(dcr_host_mmio_t host,
35 unsigned int dcr_n,
36 u32 value)
Benjamin Herrenschmidt4c75a6f2006-11-11 17:24:53 +110037{
Michael Ellerman83f34df2007-10-15 19:34:36 +100038 out_be32(host.token + ((host.base + dcr_n) * host.stride), value);
Benjamin Herrenschmidt4c75a6f2006-11-11 17:24:53 +110039}
40
Benjamin Herrenschmidt4c75a6f2006-11-11 17:24:53 +110041#endif /* __KERNEL__ */
42#endif /* _ASM_POWERPC_DCR_MMIO_H */
43
44