Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Alexey Brodkin | 511ab04 | 2014-02-04 12:56:19 +0400 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2013-2014 Synopsys, Inc. All rights reserved. |
Alexey Brodkin | 511ab04 | 2014-02-04 12:56:19 +0400 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #include <common.h> |
| 7 | #include <dwmmc.h> |
| 8 | #include <malloc.h> |
Alexey Brodkin | 323dad4 | 2017-03-31 11:14:35 +0300 | [diff] [blame] | 9 | #include <asm/arcregs.h> |
Alexey Brodkin | f8f13b1 | 2015-04-09 19:50:58 +0300 | [diff] [blame] | 10 | #include "axs10x.h" |
Alexey Brodkin | 511ab04 | 2014-02-04 12:56:19 +0400 | [diff] [blame] | 11 | |
| 12 | DECLARE_GLOBAL_DATA_PTR; |
| 13 | |
Alexey Brodkin | f8f13b1 | 2015-04-09 19:50:58 +0300 | [diff] [blame] | 14 | #define AXS_MB_CREG 0xE0011000 |
| 15 | |
| 16 | int board_early_init_f(void) |
| 17 | { |
| 18 | if (readl((void __iomem *)AXS_MB_CREG + 0x234) & (1 << 28)) |
| 19 | gd->board_type = AXS_MB_V3; |
| 20 | else |
| 21 | gd->board_type = AXS_MB_V2; |
| 22 | |
| 23 | return 0; |
| 24 | } |
Alexey Brodkin | cf9cafd | 2015-04-13 13:37:05 +0300 | [diff] [blame] | 25 | |
| 26 | #ifdef CONFIG_ISA_ARCV2 |
Eugeniy Paltsev | 01f45cc | 2018-03-23 15:35:03 +0300 | [diff] [blame] | 27 | |
| 28 | void board_jump_and_run(ulong entry, int zero, int arch, uint params) |
| 29 | { |
| 30 | void (*kernel_entry)(int zero, int arch, uint params); |
| 31 | |
| 32 | kernel_entry = (void (*)(int, int, uint))entry; |
| 33 | |
| 34 | smp_set_core_boot_addr(entry, -1); |
| 35 | smp_kick_all_cpus(); |
| 36 | kernel_entry(zero, arch, params); |
| 37 | } |
| 38 | |
Alexey Brodkin | cf9cafd | 2015-04-13 13:37:05 +0300 | [diff] [blame] | 39 | #define RESET_VECTOR_ADDR 0x0 |
| 40 | |
| 41 | void smp_set_core_boot_addr(unsigned long addr, int corenr) |
| 42 | { |
| 43 | /* All cores have reset vector pointing to 0 */ |
| 44 | writel(addr, (void __iomem *)RESET_VECTOR_ADDR); |
| 45 | |
| 46 | /* Make sure other cores see written value in memory */ |
Alexey Brodkin | 0fda964 | 2016-06-08 08:19:33 +0300 | [diff] [blame] | 47 | flush_dcache_all(); |
Alexey Brodkin | cf9cafd | 2015-04-13 13:37:05 +0300 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | void smp_kick_all_cpus(void) |
| 51 | { |
| 52 | /* CPU start CREG */ |
| 53 | #define AXC003_CREG_CPU_START 0xF0001400 |
Alexey Brodkin | cf9cafd | 2015-04-13 13:37:05 +0300 | [diff] [blame] | 54 | /* Bits positions in CPU start CREG */ |
| 55 | #define BITS_START 0 |
Alexey Brodkin | ef5b517 | 2017-03-30 19:18:30 +0300 | [diff] [blame] | 56 | #define BITS_START_MODE 4 |
Alexey Brodkin | cf9cafd | 2015-04-13 13:37:05 +0300 | [diff] [blame] | 57 | #define BITS_CORE_SEL 9 |
Alexey Brodkin | cf9cafd | 2015-04-13 13:37:05 +0300 | [diff] [blame] | 58 | |
Alexey Brodkin | 323dad4 | 2017-03-31 11:14:35 +0300 | [diff] [blame] | 59 | /* |
| 60 | * In axs103 v1.1 START bits semantics has changed quite a bit. |
| 61 | * We used to have a generic START bit for all cores selected by CORE_SEL mask. |
| 62 | * But now we don't touch CORE_SEL at all because we have a dedicated START bit |
| 63 | * for each core: |
| 64 | * bit 0: Core 0 (master) |
| 65 | * bit 1: Core 1 (slave) |
| 66 | */ |
| 67 | #define BITS_START_CORE1 1 |
| 68 | |
| 69 | #define ARCVER_HS38_3_0 0x53 |
| 70 | |
| 71 | int core_family = read_aux_reg(ARC_AUX_IDENTITY) & 0xff; |
Alexey Brodkin | ef5b517 | 2017-03-30 19:18:30 +0300 | [diff] [blame] | 72 | int cmd = readl((void __iomem *)AXC003_CREG_CPU_START); |
Alexey Brodkin | 323dad4 | 2017-03-31 11:14:35 +0300 | [diff] [blame] | 73 | |
| 74 | if (core_family < ARCVER_HS38_3_0) { |
| 75 | cmd |= (1 << BITS_CORE_SEL) | (1 << BITS_START); |
| 76 | cmd &= ~(1 << BITS_START_MODE); |
| 77 | } else { |
| 78 | cmd |= (1 << BITS_START_CORE1); |
| 79 | } |
Alexey Brodkin | ef5b517 | 2017-03-30 19:18:30 +0300 | [diff] [blame] | 80 | writel(cmd, (void __iomem *)AXC003_CREG_CPU_START); |
Alexey Brodkin | cf9cafd | 2015-04-13 13:37:05 +0300 | [diff] [blame] | 81 | } |
| 82 | #endif |
Alexey Brodkin | dbf9fa2 | 2018-11-27 09:47:01 +0300 | [diff] [blame] | 83 | |
| 84 | int checkboard(void) |
| 85 | { |
| 86 | printf("Board: ARC Software Development Platform AXS%s\n", |
| 87 | is_isa_arcv2() ? "103" : "101"); |
| 88 | |
| 89 | return 0; |
| 90 | }; |