linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matthew Leach <matthew@mattleach.net>
To: Krzysztof Kozlowski <k.kozlowski@samsung.com>,
	Ben Dooks <ben.dooks@codethink.co.uk>
Cc: linux-samsung-soc@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: [RFC PATCH 09/15] ARM: EXYNOS: fixups for big-endian operation
Date: Wed,  8 Jun 2016 19:31:04 +0100	[thread overview]
Message-ID: <20160608183110.13851-10-matthew@mattleach.net> (raw)
In-Reply-To: <20160608183110.13851-1-matthew@mattleach.net>

From: Ben Dooks <ben.dooks@codethink.co.uk>

If the kernel is built big endian, then using the __raw read and write IO
accessors is not going to work as they end up writing big-endian data to
little-endian IO registers. Fix this by using the readl and writel relaxed
versions which ensure little endian IO.

Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
---
 arch/arm/mach-exynos/firmware.c | 16 ++++++++--------
 arch/arm/mach-exynos/headsmp.S  |  3 +++
 arch/arm/mach-exynos/platsmp.c  |  4 ++--
 3 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/arch/arm/mach-exynos/firmware.c b/arch/arm/mach-exynos/firmware.c
index 1bfd1b0..96b5e92 100644
--- a/arch/arm/mach-exynos/firmware.c
+++ b/arch/arm/mach-exynos/firmware.c
@@ -41,9 +41,9 @@ static int exynos_do_idle(unsigned long mode)
 	case FW_DO_IDLE_AFTR:
 		if (read_cpuid_part() == ARM_CPU_PART_CORTEX_A9)
 			exynos_save_cp15();
-		__raw_writel(virt_to_phys(exynos_cpu_resume_ns),
+		writel_relaxed(virt_to_phys(exynos_cpu_resume_ns),
 			     sysram_ns_base_addr + 0x24);
-		__raw_writel(EXYNOS_AFTR_MAGIC, sysram_ns_base_addr + 0x20);
+		writel_relaxed(EXYNOS_AFTR_MAGIC, sysram_ns_base_addr + 0x20);
 		if (soc_is_exynos3250()) {
 			flush_cache_all();
 			exynos_smc(SMC_CMD_SAVE, OP_TYPE_CORE,
@@ -97,7 +97,7 @@ static int exynos_set_cpu_boot_addr(int cpu, unsigned long boot_addr)
 	if (soc_is_exynos4412())
 		boot_reg += 4 * cpu;
 
-	__raw_writel(boot_addr, boot_reg);
+	writel_relaxed(boot_addr, boot_reg);
 	return 0;
 }
 
@@ -113,7 +113,7 @@ static int exynos_get_cpu_boot_addr(int cpu, unsigned long *boot_addr)
 	if (soc_is_exynos4412())
 		boot_reg += 4 * cpu;
 
-	*boot_addr = __raw_readl(boot_reg);
+	*boot_addr = readl_relaxed(boot_reg);
 	return 0;
 }
 
@@ -234,20 +234,20 @@ void exynos_set_boot_flag(unsigned int cpu, unsigned int mode)
 {
 	unsigned int tmp;
 
-	tmp = __raw_readl(REG_CPU_STATE_ADDR + cpu * 4);
+	tmp = readl_relaxed(REG_CPU_STATE_ADDR + cpu * 4);
 
 	if (mode & BOOT_MODE_MASK)
 		tmp &= ~BOOT_MODE_MASK;
 
 	tmp |= mode;
-	__raw_writel(tmp, REG_CPU_STATE_ADDR + cpu * 4);
+	writel_relaxed(tmp, REG_CPU_STATE_ADDR + cpu * 4);
 }
 
 void exynos_clear_boot_flag(unsigned int cpu, unsigned int mode)
 {
 	unsigned int tmp;
 
-	tmp = __raw_readl(REG_CPU_STATE_ADDR + cpu * 4);
+	tmp = readl_relaxed(REG_CPU_STATE_ADDR + cpu * 4);
 	tmp &= ~mode;
-	__raw_writel(tmp, REG_CPU_STATE_ADDR + cpu * 4);
+	writel_relaxed(tmp, REG_CPU_STATE_ADDR + cpu * 4);
 }
diff --git a/arch/arm/mach-exynos/headsmp.S b/arch/arm/mach-exynos/headsmp.S
index b54f970..d3d24ab 100644
--- a/arch/arm/mach-exynos/headsmp.S
+++ b/arch/arm/mach-exynos/headsmp.S
@@ -12,12 +12,15 @@
 #include <linux/linkage.h>
 #include <linux/init.h>
 
+#include <asm/assembler.h>
+
 /*
  * exynos4 specific entry point for secondary CPUs.  This provides
  * a "holding pen" into which all secondary cores are held until we're
  * ready for them to initialise.
  */
 ENTRY(exynos4_secondary_startup)
+ARM_BE8(setend	be)
 	mrc	p15, 0, r0, c0, c0, 5
 	and	r0, r0, #15
 	adr	r4, 1f
diff --git a/arch/arm/mach-exynos/platsmp.c b/arch/arm/mach-exynos/platsmp.c
index 85c3be6..98ffe1e 100644
--- a/arch/arm/mach-exynos/platsmp.c
+++ b/arch/arm/mach-exynos/platsmp.c
@@ -264,7 +264,7 @@ int exynos_set_boot_addr(u32 core_id, unsigned long boot_addr)
 			ret = PTR_ERR(boot_reg);
 			goto fail;
 		}
-		__raw_writel(boot_addr, boot_reg);
+		writel_relaxed(boot_addr, boot_reg);
 		ret = 0;
 	}
 fail:
@@ -289,7 +289,7 @@ int exynos_get_boot_addr(u32 core_id, unsigned long *boot_addr)
 			ret = PTR_ERR(boot_reg);
 			goto fail;
 		}
-		*boot_addr = __raw_readl(boot_reg);
+		*boot_addr = readl_relaxed(boot_reg);
 		ret = 0;
 	}
 fail:
-- 
2.8.3

  parent reply	other threads:[~2016-06-08 18:34 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-08 18:30 [RFC PATCH 00/15] Exynos big-endian fixes Matthew Leach
2016-06-08 18:30 ` [RFC PATCH 01/15] clock: exynos: fixup endian in pll clk Matthew Leach
2016-06-10  9:51   ` Sylwester Nawrocki
2016-06-08 18:30 ` [RFC PATCH 02/15] clocksource: samsung_pwm_timer: fix endian accessors Matthew Leach
2016-06-10 11:43   ` Krzysztof Kozlowski
2016-06-16 13:23   ` Daniel Lezcano
2016-06-08 18:30 ` [RFC PATCH 03/15] clk: samsung: exynos4: fixup reg access on be Matthew Leach
2016-06-10  9:51   ` Sylwester Nawrocki
2016-06-08 18:30 ` [RFC PATCH 04/15] irqchip: exynos_combiner: " Matthew Leach
2016-06-10 11:44   ` Krzysztof Kozlowski
2016-06-08 18:31 ` [RFC PATCH 05/15] tty: serial: samsung: fixup accessors for endian Matthew Leach
2016-06-09  8:12   ` Ben Dooks
2016-06-10 10:13   ` Ben Dooks
2016-06-10 11:47     ` Krzysztof Kozlowski
2016-06-08 18:31 ` [RFC PATCH 06/15] tty: serial: samsung: add byte-order aware bit functions Matthew Leach
2016-06-10 12:17   ` Krzysztof Kozlowski
2016-06-08 18:31 ` [RFC PATCH 07/15] ARM: exynos: fixup debug macros for big-endian Matthew Leach
2016-06-10 11:12   ` Ben Dooks
2016-06-10 11:16     ` Krzysztof Kozlowski
2016-06-10 12:44       ` Ben Dooks
2016-06-10 13:02       ` Ben Dooks
2016-06-10 13:04         ` Krzysztof Kozlowski
2016-06-08 18:31 ` [RFC PATCH 08/15] ARM: samsung: fixup endian issues in cpu detection Matthew Leach
2016-06-08 18:31 ` Matthew Leach [this message]
2016-06-08 18:31 ` [RFC PATCH 10/15] ARM: EXYNOS: fixup endian in pm/pmu Matthew Leach
2016-06-08 18:31 ` [RFC PATCH 11/15] ARM: EXYNOS: Enable ARCH_SUPPORTS_BIG_ENDIAN explicitly Matthew Leach
2016-06-08 18:31 ` [RFC PATCH 12/15] irqchip/s3c24xx: fixup IO accessors for big endian Matthew Leach
2016-06-17  8:56   ` Krzysztof Kozlowski
2016-06-08 18:31 ` [RFC PATCH 13/15] memory: samsung: endian fixes for IO Matthew Leach
2016-06-17  8:59   ` Krzysztof Kozlowski
2016-06-08 18:31 ` [RFC PATCH 14/15] hwrng: exynos - fixup IO accesors Matthew Leach
2016-06-08 18:31 ` [RFC PATCH 15/15] iommu/exynos: update to use iommu big-endian Matthew Leach
2016-06-09  6:51   ` Marek Szyprowski
2016-06-09  8:14     ` Ben Dooks
2016-06-21  9:59   ` Joerg Roedel
2016-06-09  8:09 ` [RFC PATCH 00/15] Exynos big-endian fixes Ben Dooks

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160608183110.13851-10-matthew@mattleach.net \
    --to=matthew@mattleach.net \
    --cc=ben.dooks@codethink.co.uk \
    --cc=k.kozlowski@samsung.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).