From patchwork Thu Mar 19 12:15:54 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 6048641 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 780FDBF90F for ; Thu, 19 Mar 2015 12:21:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6F42E20529 for ; Thu, 19 Mar 2015 12:21:40 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5E78D20520 for ; Thu, 19 Mar 2015 12:21:39 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YYZOp-00038p-Eb; Thu, 19 Mar 2015 12:18:07 +0000 Received: from mail-lb0-x22b.google.com ([2a00:1450:4010:c04::22b]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YYZOh-00031p-Hf for linux-arm-kernel@lists.infradead.org; Thu, 19 Mar 2015 12:18:01 +0000 Received: by lbcgn8 with SMTP id gn8so51096598lbc.2 for ; Thu, 19 Mar 2015 05:17:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=eebb0RjRfh6bhMNkUVBi/DRv8ESeY88Usjld33tpWmU=; b=d79tkv3fnSEr0SBHlSBLBGbptKMW7QiFzPqxsRBrDEG7UWxhhz+/ez0pAkSjc75fPV v6fAyEJR6yyryv3vNl1cvt+6WDvixnlIsXPSfTzI0bx4qroOzE9AMdmu4vd/SnreNCef NYQPf8vZ03IeMoxWTTyjipEh4HSiHwUJuEsH8vbWgp+CDu5NGYe4zzncleb8dPLSmf6V fyioez9QGwSalHl6EUaU2Dw+PaYTvHwACQ2EtXmbysvPi1umQhAYr+a11U0YTJ5MoQ0o XqRcYeDYzhFQQ6F3UnWSyySVsKiSztrLZXtDVwc0phni3XMYaA9NjLZciYqHygbVYtyt NtJQ== X-Received: by 10.112.199.36 with SMTP id jh4mr33264807lbc.49.1426767457150; Thu, 19 Mar 2015 05:17:37 -0700 (PDT) Received: from localhost.localdomain ([46.138.70.252]) by mx.google.com with ESMTPSA id kk6sm254840lbc.15.2015.03.19.05.17.36 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 19 Mar 2015 05:17:36 -0700 (PDT) From: Dmitry Osipenko To: digetx@gmail.com, Stephen Warren , Thierry Reding , Alexandre Courbot , Peter De Schrijver , Joseph Lo Subject: [PATCH v2] ARM: tegra: Maintain CPU endianness for asm code Date: Thu, 19 Mar 2015 15:15:54 +0300 Message-Id: <1426767359-23212-1-git-send-email-digetx@gmail.com> X-Mailer: git-send-email 2.3.2 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150319_051800_016340_79BF2899 X-CRM114-Status: GOOD ( 12.30 ) X-Spam-Score: -0.8 (/) Cc: linux-tegra@vger.kernel.org, Russell King , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch adds support for big-endian CPU mode to assembler code, which is required for booting secondary CPU's, cpuidle drivers and machine suspend/resume functionality with big-endian kernel. Signed-off-by: Dmitry Osipenko --- Tested on Tegra 2 and 3. Changelog: V2: Cleanup a bit: reordered include header and replaced conditional branching with conditional reg reverse in sleep-tegra20.S arch/arm/mach-tegra/reset-handler.S | 13 +++++++++++++ arch/arm/mach-tegra/sleep-tegra20.S | 12 ++++++++++++ arch/arm/mach-tegra/sleep-tegra30.S | 9 +++++++++ arch/arm/mach-tegra/sleep.S | 1 + arch/arm/mach-tegra/sleep.h | 3 +++ 5 files changed, 38 insertions(+) diff --git a/arch/arm/mach-tegra/reset-handler.S b/arch/arm/mach-tegra/reset-handler.S index e3070fd..a200f4d 100644 --- a/arch/arm/mach-tegra/reset-handler.S +++ b/arch/arm/mach-tegra/reset-handler.S @@ -20,6 +20,7 @@ #include #include +#include #include #include "flowctrl.h" @@ -43,6 +44,9 @@ * r8: CPU part number */ ENTRY(tegra_resume) + +ARM_BE8(setend be) + check_cpu_part_num 0xc09, r8, r9 bleq v7_invalidate_l1 @@ -59,12 +63,14 @@ ENTRY(tegra_resume) cpu_to_csr_reg r1, r0 mov32 r2, TEGRA_FLOW_CTRL_BASE ldr r1, [r2, r1] +ARM_BE8(rev r1, r1) /* Clear event & intr flag */ orr r1, r1, \ #FLOW_CTRL_CSR_INTR_FLAG | FLOW_CTRL_CSR_EVENT_FLAG movw r0, #0x3FFD @ enable, cluster_switch, immed, bitmaps @ & ext flags for CPU power mgnt bic r1, r1, r0 +ARM_BE8(rev r1, r1) str r1, [r2] 1: @@ -75,7 +81,9 @@ ENTRY(tegra_resume) /* enable SCU */ mov32 r0, TEGRA_ARM_PERIF_BASE ldr r1, [r0] +ARM_BE8(rev r1, r1) orr r1, r1, #1 +ARM_BE8(rev r1, r1) str r1, [r0] #endif @@ -118,6 +126,8 @@ ENTRY(__tegra_cpu_reset_handler_start) .align L1_CACHE_SHIFT ENTRY(__tegra_cpu_reset_handler) +ARM_BE8(setend be) + cpsid aif, 0x13 @ SVC mode, interrupts disabled tegra_get_soc_id TEGRA_APB_MISC_BASE, r6 @@ -222,6 +232,9 @@ __no_cpu0_chk: */ __die: + +ARM_BE8(setend le) + sub lr, lr, #4 mov32 r7, TEGRA_PMC_BASE str lr, [r7, #PMC_SCRATCH41] diff --git a/arch/arm/mach-tegra/sleep-tegra20.S b/arch/arm/mach-tegra/sleep-tegra20.S index e6b684e..991c549 100644 --- a/arch/arm/mach-tegra/sleep-tegra20.S +++ b/arch/arm/mach-tegra/sleep-tegra20.S @@ -105,12 +105,14 @@ ENTRY(tegra20_cpu_shutdown) cpu_to_halt_reg r1, r0 ldr r3, =TEGRA_FLOW_CTRL_VIRT mov r2, #FLOW_CTRL_WAITEVENT | FLOW_CTRL_JTAG_RESUME +ARM_BE8(rev r2, r2) str r2, [r3, r1] @ put flow controller in wait event mode ldr r2, [r3, r1] isb dsb movw r1, 0x1011 mov r1, r1, lsl r0 +ARM_BE8(rev r1, r1) ldr r3, =TEGRA_CLK_RESET_VIRT str r1, [r3, #0x340] @ put slave CPU in reset isb @@ -155,13 +157,16 @@ ENTRY(tegra_pen_lock) addne r3, r3, #PMC_SCRATCH38 mov r12, #1 +ARM_BE8(rev r12, r12) str r12, [r2] @ flag[cpu] = 1 dsb str r12, [r1] @ !turn = cpu 1: dsb ldr r12, [r3] +ARM_BE8(rev r12, r12) cmp r12, #1 @ flag[!cpu] == 1? ldreq r12, [r1] +ARM_BE8(reveq r12, r12) cmpeq r12, r0 @ !turn == cpu? beq 1b @ while !turn == cpu && flag[!cpu] == 1 @@ -337,6 +342,9 @@ tegra20_iram_start: * NOTE: THIS *MUST* BE RELOCATED TO TEGRA_IRAM_LPx_RESUME_AREA. */ ENTRY(tegra20_lp1_reset) + +ARM_BE8(setend le) + /* * The CPU and system bus are running at 32KHz and executing from * IRAM when this code is executed; immediately switch to CLKM and @@ -360,8 +368,10 @@ ENTRY(tegra20_lp1_reset) mov r5, #0 ldr r6, tegra20_sdram_pad_size +ARM_BE8(rev r6, r6) padload: ldr r7, [r2, r5] @ r7 is the addr in the pad_address +ARM_BE8(rev r7, r7) ldr r1, [r4, r5] str r1, [r7] @ restore the value in pad_save @@ -521,8 +531,10 @@ emcself: mov r5, #0 ldr r6, tegra20_sdram_pad_size +ARM_BE8(rev r6, r6) padsave: ldr r0, [r2, r5] @ r0 is the addr in the pad_address +ARM_BE8(rev r0, r0) ldr r1, [r0] str r1, [r4, r5] @ save the content of the addr diff --git a/arch/arm/mach-tegra/sleep-tegra30.S b/arch/arm/mach-tegra/sleep-tegra30.S index 5d8d13a..821c6df 100644 --- a/arch/arm/mach-tegra/sleep-tegra30.S +++ b/arch/arm/mach-tegra/sleep-tegra30.S @@ -184,6 +184,7 @@ _no_cpu0_chk: ARM( orr r12, r12, r4, lsl r3 ) THUMB( lsl r4, r4, r3 ) THUMB( orr r12, r12, r4 ) +ARM_BE8(rev r12, r12) str r12, [r1] /* Halt this CPU. */ @@ -210,8 +211,10 @@ flow_ctrl_setting_for_lp2: orrne r3, r3, #FLOW_CTRL_HALT_GIC_FIQ flow_ctrl_done: cmp r10, #TEGRA30 +ARM_BE8(rev r3, r3) str r3, [r2] ldr r0, [r2] +ARM_BE8(rev r0, r0) b wfe_war __cpu_reset_again: @@ -319,6 +322,9 @@ tegra30_iram_start: * NOTE: THIS *MUST* BE RELOCATED TO TEGRA_IRAM_LPx_RESUME_AREA. */ ENTRY(tegra30_lp1_reset) + +ARM_BE8(setend le) + /* * The CPU and system bus are running at 32KHz and executing from * IRAM when this code is executed; immediately switch to CLKM and @@ -722,11 +728,13 @@ tegra30_sdram_self_refresh: cmp r10, #TEGRA124 adreq r2, tegra124_sdram_pad_address ldreq r3, tegra30_sdram_pad_size +ARM_BE8(rev r3, r3) mov r9, #0 padsave: ldr r0, [r2, r9] @ r0 is the addr in the pad_address +ARM_BE8(rev r0, r0) ldr r1, [r0] str r1, [r8, r9] @ save the content of the addr @@ -744,6 +752,7 @@ padsave_done: ldreq r0, =TEGRA_EMC0_BASE cmp r10, #TEGRA124 ldreq r0, =TEGRA124_EMC_BASE +ARM_BE8(rev r0, r0) enter_self_refresh: cmp r10, #TEGRA30 diff --git a/arch/arm/mach-tegra/sleep.S b/arch/arm/mach-tegra/sleep.S index f024a51..1fd201f 100644 --- a/arch/arm/mach-tegra/sleep.S +++ b/arch/arm/mach-tegra/sleep.S @@ -139,6 +139,7 @@ ENTRY(tegra_shut_off_mmu) moveq r3, #0 streq r3, [r2, #L2X0_CTRL] #endif +ARM_BE8(setend le) ret r0 ENDPROC(tegra_shut_off_mmu) .popsection diff --git a/arch/arm/mach-tegra/sleep.h b/arch/arm/mach-tegra/sleep.h index 0d59360..fa7aba4 100644 --- a/arch/arm/mach-tegra/sleep.h +++ b/arch/arm/mach-tegra/sleep.h @@ -118,8 +118,11 @@ /* Macro to check Tegra revision */ #define APB_MISC_GP_HIDREV 0x804 .macro tegra_get_soc_id base, tmp1 +ARM_BE8(mrc p15, 0, \tmp1, c1, c0) +ARM_BE8(tst \tmp1, #(1 << 7)) @ check for little-endian bit mov32 \tmp1, \base ldr \tmp1, [\tmp1, #APB_MISC_GP_HIDREV] +ARM_BE8(revne \tmp1, \tmp1) and \tmp1, \tmp1, #0xff00 mov \tmp1, \tmp1, lsr #8 .endm