aux.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * Copyright (C) 2016-2017 Synopsys, Inc. (www.synopsys.com)
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 as
  6. * published by the Free Software Foundation.
  7. *
  8. */
  9. #ifndef __SOC_ARC_AUX_H__
  10. #define __SOC_ARC_AUX_H__
  11. #ifdef CONFIG_ARC
  12. #define read_aux_reg(r) __builtin_arc_lr(r)
  13. /* gcc builtin sr needs reg param to be long immediate */
  14. #define write_aux_reg(r, v) __builtin_arc_sr((unsigned int)(v), r)
  15. #else /* !CONFIG_ARC */
  16. static inline int read_aux_reg(u32 r)
  17. {
  18. return 0;
  19. }
  20. /*
  21. * function helps elide unused variable warning
  22. * see: http://lists.infradead.org/pipermail/linux-snps-arc/2016-November/001748.html
  23. */
  24. static inline void write_aux_reg(u32 r, u32 v)
  25. {
  26. ;
  27. }
  28. #endif
  29. #define READ_BCR(reg, into) \
  30. { \
  31. unsigned int tmp; \
  32. tmp = read_aux_reg(reg); \
  33. if (sizeof(tmp) == sizeof(into)) { \
  34. into = *((typeof(into) *)&tmp); \
  35. } else { \
  36. extern void bogus_undefined(void); \
  37. bogus_undefined(); \
  38. } \
  39. }
  40. #define WRITE_AUX(reg, into) \
  41. { \
  42. unsigned int tmp; \
  43. if (sizeof(tmp) == sizeof(into)) { \
  44. tmp = (*(unsigned int *)&(into)); \
  45. write_aux_reg(reg, tmp); \
  46. } else { \
  47. extern void bogus_undefined(void); \
  48. bogus_undefined(); \
  49. } \
  50. }
  51. #endif