whci.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /*
  2. * Wireless Host Controller Interface for Ultra-Wide-Band and Wireless USB
  3. *
  4. * Copyright (C) 2005-2006 Intel Corporation
  5. * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License version
  9. * 2 as published by the Free Software Foundation.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  19. * 02110-1301, USA.
  20. *
  21. *
  22. *
  23. * References:
  24. * [WHCI] Wireless Host Controller Interface Specification for
  25. * Certified Wireless Universal Serial Bus, revision 0.95.
  26. */
  27. #ifndef _LINUX_UWB_WHCI_H_
  28. #define _LINUX_UWB_WHCI_H_
  29. #include <linux/pci.h>
  30. /*
  31. * UWB interface capability registers (offsets from UWBBASE)
  32. *
  33. * [WHCI] section 2.2
  34. */
  35. #define UWBCAPINFO 0x00 /* == UWBCAPDATA(0) */
  36. # define UWBCAPINFO_TO_N_CAPS(c) (((c) >> 0) & 0xFull)
  37. #define UWBCAPDATA(n) (8*(n))
  38. # define UWBCAPDATA_TO_VERSION(c) (((c) >> 32) & 0xFFFFull)
  39. # define UWBCAPDATA_TO_OFFSET(c) (((c) >> 18) & 0x3FFFull)
  40. # define UWBCAPDATA_TO_BAR(c) (((c) >> 16) & 0x3ull)
  41. # define UWBCAPDATA_TO_SIZE(c) ((((c) >> 8) & 0xFFull) * sizeof(u32))
  42. # define UWBCAPDATA_TO_CAP_ID(c) (((c) >> 0) & 0xFFull)
  43. /* Size of the WHCI capability data (including the RC capability) for
  44. a device with n capabilities. */
  45. #define UWBCAPDATA_SIZE(n) (8 + 8*(n))
  46. /*
  47. * URC registers (offsets from URCBASE)
  48. *
  49. * [WHCI] section 2.3
  50. */
  51. #define URCCMD 0x00
  52. # define URCCMD_RESET (1 << 31) /* UMC Hardware reset */
  53. # define URCCMD_RS (1 << 30) /* Run/Stop */
  54. # define URCCMD_EARV (1 << 29) /* Event Address Register Valid */
  55. # define URCCMD_ACTIVE (1 << 15) /* Command is active */
  56. # define URCCMD_IWR (1 << 14) /* Interrupt When Ready */
  57. # define URCCMD_SIZE_MASK 0x00000fff /* Command size mask */
  58. #define URCSTS 0x04
  59. # define URCSTS_EPS (1 << 17) /* Event Processing Status */
  60. # define URCSTS_HALTED (1 << 16) /* RC halted */
  61. # define URCSTS_HSE (1 << 10) /* Host System Error...fried */
  62. # define URCSTS_ER (1 << 9) /* Event Ready */
  63. # define URCSTS_RCI (1 << 8) /* Ready for Command Interrupt */
  64. # define URCSTS_INT_MASK 0x00000700 /* URC interrupt sources */
  65. # define URCSTS_ISI 0x000000ff /* Interrupt Source Identification */
  66. #define URCINTR 0x08
  67. # define URCINTR_EN_ALL 0x000007ff /* Enable all interrupt sources */
  68. #define URCCMDADDR 0x10
  69. #define URCEVTADDR 0x18
  70. # define URCEVTADDR_OFFSET_MASK 0xfff /* Event pointer offset mask */
  71. /** Write 32 bit @value to little endian register at @addr */
  72. static inline
  73. void le_writel(u32 value, void __iomem *addr)
  74. {
  75. iowrite32(value, addr);
  76. }
  77. /** Read from 32 bit little endian register at @addr */
  78. static inline
  79. u32 le_readl(void __iomem *addr)
  80. {
  81. return ioread32(addr);
  82. }
  83. /** Write 64 bit @value to little endian register at @addr */
  84. static inline
  85. void le_writeq(u64 value, void __iomem *addr)
  86. {
  87. iowrite32(value, addr);
  88. iowrite32(value >> 32, addr + 4);
  89. }
  90. /** Read from 64 bit little endian register at @addr */
  91. static inline
  92. u64 le_readq(void __iomem *addr)
  93. {
  94. u64 value;
  95. value = ioread32(addr);
  96. value |= (u64)ioread32(addr + 4) << 32;
  97. return value;
  98. }
  99. extern int whci_wait_for(struct device *dev, u32 __iomem *reg,
  100. u32 mask, u32 result,
  101. unsigned long max_ms, const char *tag);
  102. #endif /* #ifndef _LINUX_UWB_WHCI_H_ */