dcr-native.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * (c) Copyright 2006 Benjamin Herrenschmidt, IBM Corp.
  3. * <benh@kernel.crashing.org>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
  13. * the GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18. */
  19. #ifndef _ASM_POWERPC_DCR_NATIVE_H
  20. #define _ASM_POWERPC_DCR_NATIVE_H
  21. #ifdef __KERNEL__
  22. #ifndef __ASSEMBLY__
  23. typedef struct {
  24. unsigned int base;
  25. } dcr_host_t;
  26. #define DCR_MAP_OK(host) (1)
  27. #define dcr_map(dev, dcr_n, dcr_c) ((dcr_host_t){ .base = (dcr_n) })
  28. #define dcr_unmap(host, dcr_n, dcr_c) do {} while (0)
  29. #define dcr_read(host, dcr_n) mfdcr(dcr_n)
  30. #define dcr_write(host, dcr_n, value) mtdcr(dcr_n, value)
  31. /* Device Control Registers */
  32. void __mtdcr(int reg, unsigned int val);
  33. unsigned int __mfdcr(int reg);
  34. #define mfdcr(rn) \
  35. ({unsigned int rval; \
  36. if (__builtin_constant_p(rn)) \
  37. asm volatile("mfdcr %0," __stringify(rn) \
  38. : "=r" (rval)); \
  39. else \
  40. rval = __mfdcr(rn); \
  41. rval;})
  42. #define mtdcr(rn, v) \
  43. do { \
  44. if (__builtin_constant_p(rn)) \
  45. asm volatile("mtdcr " __stringify(rn) ",%0" \
  46. : : "r" (v)); \
  47. else \
  48. __mtdcr(rn, v); \
  49. } while (0)
  50. /* R/W of indirect DCRs make use of standard naming conventions for DCRs */
  51. #define mfdcri(base, reg) \
  52. ({ \
  53. mtdcr(base ## _CFGADDR, base ## _ ## reg); \
  54. mfdcr(base ## _CFGDATA); \
  55. })
  56. #define mtdcri(base, reg, data) \
  57. do { \
  58. mtdcr(base ## _CFGADDR, base ## _ ## reg); \
  59. mtdcr(base ## _CFGDATA, data); \
  60. } while (0)
  61. #endif /* __ASSEMBLY__ */
  62. #endif /* __KERNEL__ */
  63. #endif /* _ASM_POWERPC_DCR_NATIVE_H */