Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Nobuhiro Iwamatsu | c6ccb47 | 2013-11-21 17:06:45 +0900 | [diff] [blame] | 2 | /* |
Marek Vasut | 1f68658 | 2024-02-27 17:05:57 +0100 | [diff] [blame] | 3 | * arch/arm/mach-renesas/lowlevel_init_ca15.S |
Nobuhiro Iwamatsu | c6ccb47 | 2013-11-21 17:06:45 +0900 | [diff] [blame] | 4 | * This file is lager low level initialize. |
| 5 | * |
Nobuhiro Iwamatsu | dbb81f9 | 2014-03-28 09:43:36 +0900 | [diff] [blame] | 6 | * Copyright (C) 2013, 2014 Renesas Electronics Corporation |
Nobuhiro Iwamatsu | c6ccb47 | 2013-11-21 17:06:45 +0900 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #include <config.h> |
| 10 | #include <linux/linkage.h> |
Tom Rini | 4ddbade | 2022-05-25 12:16:03 -0400 | [diff] [blame] | 11 | #include <system-constants.h> |
Nobuhiro Iwamatsu | c6ccb47 | 2013-11-21 17:06:45 +0900 | [diff] [blame] | 12 | |
| 13 | ENTRY(lowlevel_init) |
Marek Vasut | 9da67e3 | 2018-04-13 23:13:00 +0200 | [diff] [blame] | 14 | #ifndef CONFIG_SPL_BUILD |
Nobuhiro Iwamatsu | c6ccb47 | 2013-11-21 17:06:45 +0900 | [diff] [blame] | 15 | mrc p15, 0, r4, c0, c0, 5 /* mpidr */ |
| 16 | orr r4, r4, r4, lsr #6 |
| 17 | and r4, r4, #7 /* id 0-3 = ca15.0,1,2,3 */ |
| 18 | |
| 19 | b do_lowlevel_init |
| 20 | |
| 21 | .pool |
| 22 | |
| 23 | /* |
| 24 | * CPU ID #1-#3 come here |
| 25 | */ |
| 26 | .align 4 |
| 27 | do_cpu_waiting: |
| 28 | ldr r1, =0xe6180000 /* sysc */ |
| 29 | 1: ldr r0, [r1, #0x20] /* sbar */ |
| 30 | tst r0, r0 |
| 31 | beq 1b |
| 32 | bx r0 |
| 33 | |
| 34 | /* |
| 35 | * Only CPU ID #0 comes here |
| 36 | */ |
| 37 | .align 4 |
| 38 | do_lowlevel_init: |
Nobuhiro Iwamatsu | 1985c4b | 2014-08-08 08:44:02 +0900 | [diff] [blame] | 39 | ldr r2, =0xFF000044 /* PRR */ |
| 40 | ldr r1, [r2] |
| 41 | and r1, r1, #0x7F00 |
| 42 | lsrs r1, r1, #8 |
| 43 | cmp r1, #0x4C /* 0x4C is ID of r8a7794 */ |
Nobuhiro Iwamatsu | b507d8b | 2015-01-23 09:31:57 +0900 | [diff] [blame] | 44 | beq _enable_actlr_smp |
Nobuhiro Iwamatsu | 1985c4b | 2014-08-08 08:44:02 +0900 | [diff] [blame] | 45 | |
Nobuhiro Iwamatsu | c6ccb47 | 2013-11-21 17:06:45 +0900 | [diff] [blame] | 46 | /* surpress wfe if ca15 */ |
Nobuhiro Iwamatsu | dbb81f9 | 2014-03-28 09:43:36 +0900 | [diff] [blame] | 47 | tst r4, #4 |
Nobuhiro Iwamatsu | c6ccb47 | 2013-11-21 17:06:45 +0900 | [diff] [blame] | 48 | mrceq p15, 0, r0, c1, c0, 1 /* actlr */ |
| 49 | orreq r0, r0, #(1<<7) |
| 50 | mcreq p15, 0, r0, c1, c0, 1 |
Nobuhiro Iwamatsu | dbb81f9 | 2014-03-28 09:43:36 +0900 | [diff] [blame] | 51 | |
Nobuhiro Iwamatsu | c6ccb47 | 2013-11-21 17:06:45 +0900 | [diff] [blame] | 52 | /* and set l2 latency */ |
Nobuhiro Iwamatsu | dbb81f9 | 2014-03-28 09:43:36 +0900 | [diff] [blame] | 53 | mrc p15, 0, r0, c0, c0, 5 /* r0 = MPIDR */ |
| 54 | and r0, r0, #0xf00 |
| 55 | lsr r0, r0, #8 |
| 56 | tst r0, #1 /* only need for cluster 0 */ |
| 57 | bne _exit_init_l2_a15 |
| 58 | |
| 59 | mrc p15, 1, r0, c9, c0, 2 /* r0 = L2CTLR */ |
| 60 | and r1, r0, #7 |
| 61 | cmp r1, #3 /* has already been set up */ |
| 62 | bicne r0, r0, #0xe7 |
| 63 | orrne r0, r0, #0x83 /* L2CTLR[7:6] + L2CTLR[2:0] */ |
Nobuhiro Iwamatsu | 06c9e17 | 2014-10-31 16:07:16 +0900 | [diff] [blame] | 64 | #if defined(CONFIG_R8A7790) |
Nobuhiro Iwamatsu | ebf4dad | 2014-08-08 08:41:15 +0900 | [diff] [blame] | 65 | orrne r0, r0, #0x20 /* L2CTLR[5] */ |
Nobuhiro Iwamatsu | 06c9e17 | 2014-10-31 16:07:16 +0900 | [diff] [blame] | 66 | #endif |
Nobuhiro Iwamatsu | dbb81f9 | 2014-03-28 09:43:36 +0900 | [diff] [blame] | 67 | mcrne p15, 1, r0, c9, c0, 2 |
Nobuhiro Iwamatsu | b507d8b | 2015-01-23 09:31:57 +0900 | [diff] [blame] | 68 | |
| 69 | b _exit_init_l2_a15 |
| 70 | |
| 71 | _enable_actlr_smp: /* R8A7794 only (CA7) */ |
| 72 | #ifndef CONFIG_DCACHE_OFF |
| 73 | mrc p15, 0, r0, c1, c0, 1 |
| 74 | orr r0, r0, #0x40 |
| 75 | mcr p15, 0, r0, c1, c0, 1 |
| 76 | #endif |
| 77 | |
Nobuhiro Iwamatsu | dbb81f9 | 2014-03-28 09:43:36 +0900 | [diff] [blame] | 78 | _exit_init_l2_a15: |
Tom Rini | 4ddbade | 2022-05-25 12:16:03 -0400 | [diff] [blame] | 79 | ldr r3, =(SYS_INIT_SP_ADDR) |
Nobuhiro Iwamatsu | c6ccb47 | 2013-11-21 17:06:45 +0900 | [diff] [blame] | 80 | sub sp, r3, #4 |
| 81 | str lr, [sp] |
| 82 | |
| 83 | /* initialize system */ |
| 84 | bl s_init |
| 85 | |
| 86 | ldr lr, [sp] |
Marek Vasut | b326be4 | 2018-04-04 23:32:44 +0200 | [diff] [blame] | 87 | #endif |
Nobuhiro Iwamatsu | c6ccb47 | 2013-11-21 17:06:45 +0900 | [diff] [blame] | 88 | mov pc, lr |
| 89 | nop |
| 90 | ENDPROC(lowlevel_init) |
| 91 | .ltorg |