12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- From 03eea243622d85d59653ee076ce43ac0653dc51d Mon Sep 17 00:00:00 2001
- From: Zhao Qiang <B45475@freescale.com>
- Date: Fri, 10 Oct 2014 10:38:48 +0800
- Subject: [PATCH 39/70] arch: arm: add ARM specific fucntions required for
- ehci fsl driver
- Add below functions for ARM platform which are used by ehci fsl driver:
- 1. spin_event_timeout function
- 2. set/clear bits functions
- Signed-off-by: Zhao Qiang <B45475@freescale.com>
- Signed-off-by: Rajesh Bhagat <rajesh.bhagat@nxp.com>
- ---
- arch/arm/include/asm/delay.h | 16 ++++++++++++++++
- arch/arm/include/asm/io.h | 28 ++++++++++++++++++++++++++++
- 2 files changed, 44 insertions(+)
- --- a/arch/arm/include/asm/delay.h
- +++ b/arch/arm/include/asm/delay.h
- @@ -57,6 +57,22 @@ extern void __bad_udelay(void);
- __const_udelay((n) * UDELAY_MULT)) : \
- __udelay(n))
-
- +#define spin_event_timeout(condition, timeout, delay) \
- +({ \
- + typeof(condition) __ret; \
- + int i = 0; \
- + while (!(__ret = (condition)) && (i++ < timeout)) { \
- + if (delay) \
- + udelay(delay); \
- + else \
- + cpu_relax(); \
- + udelay(1); \
- + } \
- + if (!__ret) \
- + __ret = (condition); \
- + __ret; \
- +})
- +
- /* Loop-based definitions for assembly code. */
- extern void __loop_delay(unsigned long loops);
- extern void __loop_udelay(unsigned long usecs);
- --- a/arch/arm/include/asm/io.h
- +++ b/arch/arm/include/asm/io.h
- @@ -221,6 +221,34 @@ extern int pci_ioremap_io(unsigned int o
- #endif
- #endif
-
- +/* access ports */
- +#define setbits32(_addr, _v) iowrite32be(ioread32be(_addr) | (_v), (_addr))
- +#define clrbits32(_addr, _v) iowrite32be(ioread32be(_addr) & ~(_v), (_addr))
- +
- +#define setbits16(_addr, _v) iowrite16be(ioread16be(_addr) | (_v), (_addr))
- +#define clrbits16(_addr, _v) iowrite16be(ioread16be(_addr) & ~(_v), (_addr))
- +
- +#define setbits8(_addr, _v) iowrite8(ioread8(_addr) | (_v), (_addr))
- +#define clrbits8(_addr, _v) iowrite8(ioread8(_addr) & ~(_v), (_addr))
- +
- +/* Clear and set bits in one shot. These macros can be used to clear and
- + * set multiple bits in a register using a single read-modify-write. These
- + * macros can also be used to set a multiple-bit bit pattern using a mask,
- + * by specifying the mask in the 'clear' parameter and the new bit pattern
- + * in the 'set' parameter.
- + */
- +
- +#define clrsetbits_be32(addr, clear, set) \
- + iowrite32be((ioread32be(addr) & ~(clear)) | (set), (addr))
- +#define clrsetbits_le32(addr, clear, set) \
- + iowrite32le((ioread32le(addr) & ~(clear)) | (set), (addr))
- +#define clrsetbits_be16(addr, clear, set) \
- + iowrite16be((ioread16be(addr) & ~(clear)) | (set), (addr))
- +#define clrsetbits_le16(addr, clear, set) \
- + iowrite16le((ioread16le(addr) & ~(clear)) | (set), (addr))
- +#define clrsetbits_8(addr, clear, set) \
- + iowrite8((ioread8(addr) & ~(clear)) | (set), (addr))
- +
- /*
- * IO port access primitives
- * -------------------------
|