blob: af78127dde93131a9bde02bb104b7a3fc613250f [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Alexey Brodkin511ab042014-02-04 12:56:19 +04002/*
3 * Copyright (C) 2013-2014 Synopsys, Inc. All rights reserved.
Alexey Brodkin511ab042014-02-04 12:56:19 +04004 */
5
6#include <common.h>
7#include <dwmmc.h>
8#include <malloc.h>
Alexey Brodkin323dad42017-03-31 11:14:35 +03009#include <asm/arcregs.h>
Alexey Brodkinf8f13b12015-04-09 19:50:58 +030010#include "axs10x.h"
Alexey Brodkin511ab042014-02-04 12:56:19 +040011
12DECLARE_GLOBAL_DATA_PTR;
13
14int board_mmc_init(bd_t *bis)
15{
16 struct dwmci_host *host = NULL;
17
18 host = malloc(sizeof(struct dwmci_host));
19 if (!host) {
20 printf("dwmci_host malloc fail!\n");
21 return 1;
22 }
23
24 memset(host, 0, sizeof(struct dwmci_host));
25 host->name = "Synopsys Mobile storage";
26 host->ioaddr = (void *)ARC_DWMMC_BASE;
27 host->buswidth = 4;
28 host->dev_index = 0;
Alexey Brodkin95417cf2015-04-02 10:19:12 +030029 host->bus_hz = 50000000;
Alexey Brodkin511ab042014-02-04 12:56:19 +040030
Alexey Brodkinade110a2015-10-04 16:10:26 +030031 add_dwmci(host, host->bus_hz / 2, 400000);
Alexey Brodkin511ab042014-02-04 12:56:19 +040032
33 return 0;
34}
35
Alexey Brodkinf8f13b12015-04-09 19:50:58 +030036#define AXS_MB_CREG 0xE0011000
37
38int board_early_init_f(void)
39{
40 if (readl((void __iomem *)AXS_MB_CREG + 0x234) & (1 << 28))
41 gd->board_type = AXS_MB_V3;
42 else
43 gd->board_type = AXS_MB_V2;
44
45 return 0;
46}
Alexey Brodkincf9cafd2015-04-13 13:37:05 +030047
48#ifdef CONFIG_ISA_ARCV2
Eugeniy Paltsev01f45cc2018-03-23 15:35:03 +030049
50void board_jump_and_run(ulong entry, int zero, int arch, uint params)
51{
52 void (*kernel_entry)(int zero, int arch, uint params);
53
54 kernel_entry = (void (*)(int, int, uint))entry;
55
56 smp_set_core_boot_addr(entry, -1);
57 smp_kick_all_cpus();
58 kernel_entry(zero, arch, params);
59}
60
Alexey Brodkincf9cafd2015-04-13 13:37:05 +030061#define RESET_VECTOR_ADDR 0x0
62
63void smp_set_core_boot_addr(unsigned long addr, int corenr)
64{
65 /* All cores have reset vector pointing to 0 */
66 writel(addr, (void __iomem *)RESET_VECTOR_ADDR);
67
68 /* Make sure other cores see written value in memory */
Alexey Brodkin0fda9642016-06-08 08:19:33 +030069 flush_dcache_all();
Alexey Brodkincf9cafd2015-04-13 13:37:05 +030070}
71
72void smp_kick_all_cpus(void)
73{
74/* CPU start CREG */
75#define AXC003_CREG_CPU_START 0xF0001400
Alexey Brodkincf9cafd2015-04-13 13:37:05 +030076/* Bits positions in CPU start CREG */
77#define BITS_START 0
Alexey Brodkinef5b5172017-03-30 19:18:30 +030078#define BITS_START_MODE 4
Alexey Brodkincf9cafd2015-04-13 13:37:05 +030079#define BITS_CORE_SEL 9
Alexey Brodkincf9cafd2015-04-13 13:37:05 +030080
Alexey Brodkin323dad42017-03-31 11:14:35 +030081/*
82 * In axs103 v1.1 START bits semantics has changed quite a bit.
83 * We used to have a generic START bit for all cores selected by CORE_SEL mask.
84 * But now we don't touch CORE_SEL at all because we have a dedicated START bit
85 * for each core:
86 * bit 0: Core 0 (master)
87 * bit 1: Core 1 (slave)
88 */
89#define BITS_START_CORE1 1
90
91#define ARCVER_HS38_3_0 0x53
92
93 int core_family = read_aux_reg(ARC_AUX_IDENTITY) & 0xff;
Alexey Brodkinef5b5172017-03-30 19:18:30 +030094 int cmd = readl((void __iomem *)AXC003_CREG_CPU_START);
Alexey Brodkin323dad42017-03-31 11:14:35 +030095
96 if (core_family < ARCVER_HS38_3_0) {
97 cmd |= (1 << BITS_CORE_SEL) | (1 << BITS_START);
98 cmd &= ~(1 << BITS_START_MODE);
99 } else {
100 cmd |= (1 << BITS_START_CORE1);
101 }
Alexey Brodkinef5b5172017-03-30 19:18:30 +0300102 writel(cmd, (void __iomem *)AXC003_CREG_CPU_START);
Alexey Brodkincf9cafd2015-04-13 13:37:05 +0300103}
104#endif