ssusb_io.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /*
  2. * MUSB OTG driver register I/O
  3. *
  4. * Copyright 2005 Mentor Graphics Corporation
  5. * Copyright (C) 2005-2006 by Texas Instruments
  6. * Copyright (C) 2006-2007 Nokia Corporation
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License
  10. * version 2 as published by the Free Software Foundation.
  11. *
  12. * This program is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * General Public License for more details.
  16. * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
  17. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  18. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
  19. * NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  20. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  21. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  22. * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  23. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  25. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. *
  27. */
  28. #ifndef __MUSB_IOM_H__
  29. #define __MUSB_IOM_H__
  30. #include <linux/io.h>
  31. static inline void mu3d_writeb(void __iomem *base, unsigned int offset, unsigned char data)
  32. {
  33. writeb(data, base + offset);
  34. }
  35. static inline void mu3d_writew(void __iomem *base, unsigned int offset, unsigned short data)
  36. {
  37. writew(data, base + offset);
  38. }
  39. static inline void mu3d_writel(void __iomem *base, unsigned int offset, unsigned int data)
  40. {
  41. writel(data, base + offset);
  42. }
  43. static inline u32 mu3d_readl(void __iomem *base, unsigned int offset)
  44. {
  45. return readl(base + offset);
  46. }
  47. static inline void mu3d_writelmsk(void __iomem *base, unsigned int offset, unsigned int msk,
  48. unsigned int data)
  49. {
  50. void __iomem *addr = base + offset;
  51. unsigned int tmp = readl(addr);
  52. mb();
  53. writel(((tmp & ~(msk)) | ((data) & (msk))), addr);
  54. }
  55. static inline void mu3d_setmsk(void __iomem *base, unsigned int offset, unsigned int msk)
  56. {
  57. void __iomem *addr = base + offset;
  58. unsigned int tmp = readl(addr);
  59. mb();
  60. writel((tmp | (msk)), addr);
  61. }
  62. static inline void mu3d_clrmsk(void __iomem *base, unsigned int offset, unsigned int msk)
  63. {
  64. void __iomem *addr = base + offset;
  65. unsigned int tmp = readl(addr);
  66. mb();
  67. writel((tmp & ~(msk)), addr);
  68. }
  69. /*msk the data first, then umsk with the umsk.*/
  70. #if 0
  71. static inline void mu3d_writelmskumsk(void __iomem *base, unsigned int offset, unsigned int data,
  72. unsigned int msk, unsigned int umsk)
  73. {
  74. void __iomem *addr = /*base + */ (void __iomem *)offset;
  75. unsigned int tmp = readl(addr);
  76. mb();
  77. writel(((tmp & ~(msk)) | ((data) & (msk))) & (umsk), addr);
  78. }
  79. static inline unsigned int mu3d_dir_readl(void __iomem *regs)
  80. {
  81. return readl(regs);
  82. }
  83. static inline void mu3d_dir_writeb(void __iomem *regs, unsigned char val)
  84. {
  85. writeb(val, regs);
  86. }
  87. static inline void mu3d_dir_writew(void __iomem *regs, unsigned short val)
  88. {
  89. writew(val, regs);
  90. }
  91. static inline void mu3d_dir_writel(void __iomem *regs, unsigned int val)
  92. {
  93. writel(val, regs);
  94. }
  95. #endif
  96. /* ep_num should be >1 & < max ep-number */
  97. static inline u32 mu3d_xcsr_readl(void __iomem *base, unsigned int ep1_csrx, unsigned int ep_num)
  98. {
  99. return readl(base + (ep1_csrx + (0x10 * (ep_num - 1))));
  100. }
  101. /* ep_num should be >1 & < max ep-number */
  102. static inline void mu3d_xcsr_writel(void __iomem *base, unsigned int ep1_csrx, unsigned int ep_num,
  103. unsigned int data)
  104. {
  105. writel(data, base + (ep1_csrx + (0x10 * (ep_num - 1))));
  106. }
  107. #endif