3039-arch-arm-add-ARM-specific-fucntions-required-for-ehc.patch 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. From 03eea243622d85d59653ee076ce43ac0653dc51d Mon Sep 17 00:00:00 2001
  2. From: Zhao Qiang <B45475@freescale.com>
  3. Date: Fri, 10 Oct 2014 10:38:48 +0800
  4. Subject: [PATCH 39/70] arch: arm: add ARM specific fucntions required for
  5. ehci fsl driver
  6. Add below functions for ARM platform which are used by ehci fsl driver:
  7. 1. spin_event_timeout function
  8. 2. set/clear bits functions
  9. Signed-off-by: Zhao Qiang <B45475@freescale.com>
  10. Signed-off-by: Rajesh Bhagat <rajesh.bhagat@nxp.com>
  11. ---
  12. arch/arm/include/asm/delay.h | 16 ++++++++++++++++
  13. arch/arm/include/asm/io.h | 28 ++++++++++++++++++++++++++++
  14. 2 files changed, 44 insertions(+)
  15. --- a/arch/arm/include/asm/delay.h
  16. +++ b/arch/arm/include/asm/delay.h
  17. @@ -57,6 +57,22 @@ extern void __bad_udelay(void);
  18. __const_udelay((n) * UDELAY_MULT)) : \
  19. __udelay(n))
  20. +#define spin_event_timeout(condition, timeout, delay) \
  21. +({ \
  22. + typeof(condition) __ret; \
  23. + int i = 0; \
  24. + while (!(__ret = (condition)) && (i++ < timeout)) { \
  25. + if (delay) \
  26. + udelay(delay); \
  27. + else \
  28. + cpu_relax(); \
  29. + udelay(1); \
  30. + } \
  31. + if (!__ret) \
  32. + __ret = (condition); \
  33. + __ret; \
  34. +})
  35. +
  36. /* Loop-based definitions for assembly code. */
  37. extern void __loop_delay(unsigned long loops);
  38. extern void __loop_udelay(unsigned long usecs);
  39. --- a/arch/arm/include/asm/io.h
  40. +++ b/arch/arm/include/asm/io.h
  41. @@ -221,6 +221,34 @@ extern int pci_ioremap_io(unsigned int o
  42. #endif
  43. #endif
  44. +/* access ports */
  45. +#define setbits32(_addr, _v) iowrite32be(ioread32be(_addr) | (_v), (_addr))
  46. +#define clrbits32(_addr, _v) iowrite32be(ioread32be(_addr) & ~(_v), (_addr))
  47. +
  48. +#define setbits16(_addr, _v) iowrite16be(ioread16be(_addr) | (_v), (_addr))
  49. +#define clrbits16(_addr, _v) iowrite16be(ioread16be(_addr) & ~(_v), (_addr))
  50. +
  51. +#define setbits8(_addr, _v) iowrite8(ioread8(_addr) | (_v), (_addr))
  52. +#define clrbits8(_addr, _v) iowrite8(ioread8(_addr) & ~(_v), (_addr))
  53. +
  54. +/* Clear and set bits in one shot. These macros can be used to clear and
  55. + * set multiple bits in a register using a single read-modify-write. These
  56. + * macros can also be used to set a multiple-bit bit pattern using a mask,
  57. + * by specifying the mask in the 'clear' parameter and the new bit pattern
  58. + * in the 'set' parameter.
  59. + */
  60. +
  61. +#define clrsetbits_be32(addr, clear, set) \
  62. + iowrite32be((ioread32be(addr) & ~(clear)) | (set), (addr))
  63. +#define clrsetbits_le32(addr, clear, set) \
  64. + iowrite32le((ioread32le(addr) & ~(clear)) | (set), (addr))
  65. +#define clrsetbits_be16(addr, clear, set) \
  66. + iowrite16be((ioread16be(addr) & ~(clear)) | (set), (addr))
  67. +#define clrsetbits_le16(addr, clear, set) \
  68. + iowrite16le((ioread16le(addr) & ~(clear)) | (set), (addr))
  69. +#define clrsetbits_8(addr, clear, set) \
  70. + iowrite8((ioread8(addr) & ~(clear)) | (set), (addr))
  71. +
  72. /*
  73. * IO port access primitives
  74. * -------------------------