dcr-mmio.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * (c) Copyright 2006 Benjamin Herrenschmidt, IBM Corp.
  4. * <[email protected]>
  5. */
  6. #ifndef _ASM_POWERPC_DCR_MMIO_H
  7. #define _ASM_POWERPC_DCR_MMIO_H
  8. #ifdef __KERNEL__
  9. #include <asm/io.h>
  10. typedef struct {
  11. void __iomem *token;
  12. unsigned int stride;
  13. unsigned int base;
  14. } dcr_host_mmio_t;
  15. static inline bool dcr_map_ok_mmio(dcr_host_mmio_t host)
  16. {
  17. return host.token != NULL;
  18. }
  19. extern dcr_host_mmio_t dcr_map_mmio(struct device_node *dev,
  20. unsigned int dcr_n,
  21. unsigned int dcr_c);
  22. extern void dcr_unmap_mmio(dcr_host_mmio_t host, unsigned int dcr_c);
  23. static inline u32 dcr_read_mmio(dcr_host_mmio_t host, unsigned int dcr_n)
  24. {
  25. return in_be32(host.token + ((host.base + dcr_n) * host.stride));
  26. }
  27. static inline void dcr_write_mmio(dcr_host_mmio_t host,
  28. unsigned int dcr_n,
  29. u32 value)
  30. {
  31. out_be32(host.token + ((host.base + dcr_n) * host.stride), value);
  32. }
  33. #endif /* __KERNEL__ */
  34. #endif /* _ASM_POWERPC_DCR_MMIO_H */