From 2d5d1c9e293ac1e29f1e0f067aa381be44e8e844 Mon Sep 17 00:00:00 2001
From: Masahiro Yamada <yamada.m@jp.panasonic.com>
Date: Fri, 7 Nov 2014 21:08:52 +0900
Subject: [PATCH] ARM: UniPhier: add set_pinsel macro for use in assembly code

The function sg_set_pinsel is useful for switching I/O pins
but it can be only used in C code.  This commit adds a simple
macro that is available in asm code.

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
---
 arch/arm/include/asm/arch-uniphier/sg-regs.h | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/arch/arm/include/asm/arch-uniphier/sg-regs.h b/arch/arm/include/asm/arch-uniphier/sg-regs.h
index 79d7ec7148..fa5e6ae0f2 100644
--- a/arch/arm/include/asm/arch-uniphier/sg-regs.h
+++ b/arch/arm/include/asm/arch-uniphier/sg-regs.h
@@ -88,7 +88,18 @@
 #define SG_PINMON0_CLK_MODE_AXOSEL_20480KHZ	(0x2 << 16)
 #define SG_PINMON0_CLK_MODE_AXOSEL_25000KHZ_A	(0x3 << 16)
 
-#ifndef __ASSEMBLY__
+#ifdef __ASSEMBLY__
+
+	.macro	set_pinsel, n, value, ra, rd
+	ldr	\ra, =SG_PINSEL_ADDR(\n)
+	ldr	\rd, [\ra]
+	and	\rd, \rd, #SG_PINSEL_MASK(\n)
+	orr	\rd, \rd, #SG_PINSEL_MODE(\n, \value)
+	str	\rd, [\ra]
+	.endm
+
+#else
+
 #include <linux/types.h>
 #include <asm/io.h>
 
-- 
2.39.5