dcr.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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_H
  7. #define _ASM_POWERPC_DCR_H
  8. #ifdef __KERNEL__
  9. #ifndef __ASSEMBLY__
  10. #ifdef CONFIG_PPC_DCR
  11. #ifdef CONFIG_PPC_DCR_NATIVE
  12. #include <asm/dcr-native.h>
  13. #endif
  14. #ifdef CONFIG_PPC_DCR_MMIO
  15. #include <asm/dcr-mmio.h>
  16. #endif
  17. /* Indirection layer for providing both NATIVE and MMIO support. */
  18. #if defined(CONFIG_PPC_DCR_NATIVE) && defined(CONFIG_PPC_DCR_MMIO)
  19. #include <asm/dcr-generic.h>
  20. #define DCR_MAP_OK(host) dcr_map_ok_generic(host)
  21. #define dcr_map(dev, dcr_n, dcr_c) dcr_map_generic(dev, dcr_n, dcr_c)
  22. #define dcr_unmap(host, dcr_c) dcr_unmap_generic(host, dcr_c)
  23. #define dcr_read(host, dcr_n) dcr_read_generic(host, dcr_n)
  24. #define dcr_write(host, dcr_n, value) dcr_write_generic(host, dcr_n, value)
  25. #else
  26. #ifdef CONFIG_PPC_DCR_NATIVE
  27. typedef dcr_host_native_t dcr_host_t;
  28. #define DCR_MAP_OK(host) dcr_map_ok_native(host)
  29. #define dcr_map(dev, dcr_n, dcr_c) dcr_map_native(dev, dcr_n, dcr_c)
  30. #define dcr_unmap(host, dcr_c) dcr_unmap_native(host, dcr_c)
  31. #define dcr_read(host, dcr_n) dcr_read_native(host, dcr_n)
  32. #define dcr_write(host, dcr_n, value) dcr_write_native(host, dcr_n, value)
  33. #else
  34. typedef dcr_host_mmio_t dcr_host_t;
  35. #define DCR_MAP_OK(host) dcr_map_ok_mmio(host)
  36. #define dcr_map(dev, dcr_n, dcr_c) dcr_map_mmio(dev, dcr_n, dcr_c)
  37. #define dcr_unmap(host, dcr_c) dcr_unmap_mmio(host, dcr_c)
  38. #define dcr_read(host, dcr_n) dcr_read_mmio(host, dcr_n)
  39. #define dcr_write(host, dcr_n, value) dcr_write_mmio(host, dcr_n, value)
  40. #endif
  41. #endif /* defined(CONFIG_PPC_DCR_NATIVE) && defined(CONFIG_PPC_DCR_MMIO) */
  42. /*
  43. * additional helpers to read the DCR * base from the device-tree
  44. */
  45. struct device_node;
  46. extern unsigned int dcr_resource_start(const struct device_node *np,
  47. unsigned int index);
  48. extern unsigned int dcr_resource_len(const struct device_node *np,
  49. unsigned int index);
  50. #endif /* CONFIG_PPC_DCR */
  51. #endif /* __ASSEMBLY__ */
  52. #endif /* __KERNEL__ */
  53. #endif /* _ASM_POWERPC_DCR_H */