upa.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. #ifndef _SPARC64_UPA_H
  2. #define _SPARC64_UPA_H
  3. #include <asm/asi.h>
  4. /* UPA level registers and defines. */
  5. /* UPA Config Register */
  6. #define UPA_CONFIG_RESV 0xffffffffc0000000 /* Reserved. */
  7. #define UPA_CONFIG_PCON 0x000000003fc00000 /* Depth of various sys queues. */
  8. #define UPA_CONFIG_MID 0x00000000003e0000 /* Module ID. */
  9. #define UPA_CONFIG_PCAP 0x000000000001ffff /* Port Capabilities. */
  10. /* UPA Port ID Register */
  11. #define UPA_PORTID_FNP 0xff00000000000000 /* Hardcoded to 0xfc on ultra. */
  12. #define UPA_PORTID_RESV 0x00fffff800000000 /* Reserved. */
  13. #define UPA_PORTID_ECCVALID 0x0000000400000000 /* Zero if mod can generate ECC */
  14. #define UPA_PORTID_ONEREAD 0x0000000200000000 /* Set if mod generates P_RASB */
  15. #define UPA_PORTID_PINTRDQ 0x0000000180000000 /* # outstanding P_INT_REQ's */
  16. #define UPA_PORTID_PREQDQ 0x000000007e000000 /* slave-wr's to mod supported */
  17. #define UPA_PORTID_PREQRD 0x0000000001e00000 /* # incoming P_REQ's supported */
  18. #define UPA_PORTID_UPACAP 0x00000000001f0000 /* UPA capabilities of mod */
  19. #define UPA_PORTID_ID 0x000000000000ffff /* Module Identification bits */
  20. /* UPA I/O space accessors */
  21. #if defined(__KERNEL__) && !defined(__ASSEMBLY__)
  22. static inline unsigned char _upa_readb(unsigned long addr)
  23. {
  24. unsigned char ret;
  25. __asm__ __volatile__("lduba\t[%1] %2, %0\t/* upa_readb */"
  26. : "=r" (ret)
  27. : "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E));
  28. return ret;
  29. }
  30. static inline unsigned short _upa_readw(unsigned long addr)
  31. {
  32. unsigned short ret;
  33. __asm__ __volatile__("lduha\t[%1] %2, %0\t/* upa_readw */"
  34. : "=r" (ret)
  35. : "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E));
  36. return ret;
  37. }
  38. static inline unsigned int _upa_readl(unsigned long addr)
  39. {
  40. unsigned int ret;
  41. __asm__ __volatile__("lduwa\t[%1] %2, %0\t/* upa_readl */"
  42. : "=r" (ret)
  43. : "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E));
  44. return ret;
  45. }
  46. static inline unsigned long _upa_readq(unsigned long addr)
  47. {
  48. unsigned long ret;
  49. __asm__ __volatile__("ldxa\t[%1] %2, %0\t/* upa_readq */"
  50. : "=r" (ret)
  51. : "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E));
  52. return ret;
  53. }
  54. static inline void _upa_writeb(unsigned char b, unsigned long addr)
  55. {
  56. __asm__ __volatile__("stba\t%0, [%1] %2\t/* upa_writeb */"
  57. : /* no outputs */
  58. : "r" (b), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E));
  59. }
  60. static inline void _upa_writew(unsigned short w, unsigned long addr)
  61. {
  62. __asm__ __volatile__("stha\t%0, [%1] %2\t/* upa_writew */"
  63. : /* no outputs */
  64. : "r" (w), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E));
  65. }
  66. static inline void _upa_writel(unsigned int l, unsigned long addr)
  67. {
  68. __asm__ __volatile__("stwa\t%0, [%1] %2\t/* upa_writel */"
  69. : /* no outputs */
  70. : "r" (l), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E));
  71. }
  72. static inline void _upa_writeq(unsigned long q, unsigned long addr)
  73. {
  74. __asm__ __volatile__("stxa\t%0, [%1] %2\t/* upa_writeq */"
  75. : /* no outputs */
  76. : "r" (q), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E));
  77. }
  78. #define upa_readb(__addr) (_upa_readb((unsigned long)(__addr)))
  79. #define upa_readw(__addr) (_upa_readw((unsigned long)(__addr)))
  80. #define upa_readl(__addr) (_upa_readl((unsigned long)(__addr)))
  81. #define upa_readq(__addr) (_upa_readq((unsigned long)(__addr)))
  82. #define upa_writeb(__b, __addr) (_upa_writeb((__b), (unsigned long)(__addr)))
  83. #define upa_writew(__w, __addr) (_upa_writew((__w), (unsigned long)(__addr)))
  84. #define upa_writel(__l, __addr) (_upa_writel((__l), (unsigned long)(__addr)))
  85. #define upa_writeq(__q, __addr) (_upa_writeq((__q), (unsigned long)(__addr)))
  86. #endif /* __KERNEL__ && !__ASSEMBLY__ */
  87. #endif /* !(_SPARC64_UPA_H) */