]>
Commit | Line | Data |
---|---|---|
77754408 | 1 | /* |
d1c559af | 2 | * Copyright (C) 2012-2017 Altera Corporation <www.altera.com> |
77754408 | 3 | * |
1a459660 | 4 | * SPDX-License-Identifier: GPL-2.0+ |
77754408 DN |
5 | */ |
6 | ||
7 | #include <common.h> | |
8 | #include <asm/io.h> | |
bd48c061 | 9 | #include <errno.h> |
6ab00db2 | 10 | #include <fdtdec.h> |
b08c8c48 | 11 | #include <linux/libfdt.h> |
230fe9b2 | 12 | #include <altera.h> |
99b97106 PM |
13 | #include <miiphy.h> |
14 | #include <netdev.h> | |
d0e932de | 15 | #include <watchdog.h> |
d1c559af | 16 | #include <asm/arch/misc.h> |
de6da925 | 17 | #include <asm/arch/reset_manager.h> |
bd48c061 | 18 | #include <asm/arch/scan_manager.h> |
45d6e677 | 19 | #include <asm/arch/system_manager.h> |
60d804c2 | 20 | #include <asm/arch/nic301.h> |
13e81d45 | 21 | #include <asm/arch/scu.h> |
60d804c2 | 22 | #include <asm/pl310.h> |
77754408 DN |
23 | |
24 | DECLARE_GLOBAL_DATA_PTR; | |
25 | ||
d1c559af | 26 | static const struct pl310_regs *const pl310 = |
60d804c2 | 27 | (struct pl310_regs *)CONFIG_SYS_PL310_BASE; |
d1c559af LFT |
28 | |
29 | struct bsel bsel_str[] = { | |
30 | { "rsvd", "Reserved", }, | |
31 | { "fpga", "FPGA (HPS2FPGA Bridge)", }, | |
32 | { "nand", "NAND Flash (1.8V)", }, | |
33 | { "nand", "NAND Flash (3.0V)", }, | |
34 | { "sd", "SD/MMC External Transceiver (1.8V)", }, | |
35 | { "sd", "SD/MMC Internal Transceiver (3.0V)", }, | |
36 | { "qspi", "QSPI Flash (1.8V)", }, | |
37 | { "qspi", "QSPI Flash (3.0V)", }, | |
38 | }; | |
45d6e677 | 39 | |
77754408 DN |
40 | int dram_init(void) |
41 | { | |
42 | gd->ram_size = get_ram_size((long *)PHYS_SDRAM_1, PHYS_SDRAM_1_SIZE); | |
43 | return 0; | |
44 | } | |
23f23f23 | 45 | |
4ab333b7 MV |
46 | void enable_caches(void) |
47 | { | |
48 | #ifndef CONFIG_SYS_ICACHE_OFF | |
49 | icache_enable(); | |
50 | #endif | |
51 | #ifndef CONFIG_SYS_DCACHE_OFF | |
52 | dcache_enable(); | |
53 | #endif | |
54 | } | |
55 | ||
8d8e13e1 DN |
56 | void v7_outer_cache_enable(void) |
57 | { | |
07806977 MV |
58 | /* Disable the L2 cache */ |
59 | clrbits_le32(&pl310->pl310_ctrl, L2X0_CTRL_EN); | |
8d8e13e1 DN |
60 | |
61 | /* enable BRESP, instruction and data prefetch, full line of zeroes */ | |
62 | setbits_le32(&pl310->pl310_aux_ctrl, | |
63 | L310_AUX_CTRL_DATA_PREFETCH_MASK | | |
64 | L310_AUX_CTRL_INST_PREFETCH_MASK | | |
65 | L310_SHARED_ATT_OVERRIDE_ENABLE); | |
07806977 MV |
66 | |
67 | /* Enable the L2 cache */ | |
68 | setbits_le32(&pl310->pl310_ctrl, L2X0_CTRL_EN); | |
69 | } | |
70 | ||
71 | void v7_outer_cache_disable(void) | |
72 | { | |
73 | /* Disable the L2 cache */ | |
74 | clrbits_le32(&pl310->pl310_ctrl, L2X0_CTRL_EN); | |
8d8e13e1 DN |
75 | } |
76 | ||
23f23f23 CLS |
77 | #if defined(CONFIG_SYS_CONSOLE_IS_IN_ENV) && \ |
78 | defined(CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE) | |
79 | int overwrite_console(void) | |
80 | { | |
81 | return 0; | |
82 | } | |
83 | #endif | |
84 | ||
230fe9b2 PM |
85 | #ifdef CONFIG_FPGA |
86 | /* | |
87 | * FPGA programming support for SoC FPGA Cyclone V | |
88 | */ | |
89 | static Altera_desc altera_fpga[] = { | |
90 | { | |
91 | /* Family */ | |
92 | Altera_SoCFPGA, | |
93 | /* Interface type */ | |
94 | fast_passive_parallel, | |
95 | /* No limitation as additional data will be ignored */ | |
96 | -1, | |
97 | /* No device function table */ | |
98 | NULL, | |
99 | /* Base interface address specified in driver */ | |
100 | NULL, | |
101 | /* No cookie implementation */ | |
102 | 0 | |
103 | }, | |
104 | }; | |
105 | ||
106 | /* add device descriptor to FPGA device table */ | |
d1c559af | 107 | void socfpga_fpga_add(void) |
230fe9b2 PM |
108 | { |
109 | int i; | |
110 | fpga_init(); | |
111 | for (i = 0; i < ARRAY_SIZE(altera_fpga); i++) | |
112 | fpga_add(fpga_altera, &altera_fpga[i]); | |
113 | } | |
230fe9b2 PM |
114 | #endif |
115 | ||
de6da925 PM |
116 | int arch_cpu_init(void) |
117 | { | |
d0e932de SR |
118 | #ifdef CONFIG_HW_WATCHDOG |
119 | /* | |
120 | * In case the watchdog is enabled, make sure to (re-)configure it | |
121 | * so that the defined timeout is valid. Otherwise the SPL (Perloader) | |
122 | * timeout value is still active which might too short for Linux | |
123 | * booting. | |
124 | */ | |
125 | hw_watchdog_init(); | |
126 | #else | |
de6da925 PM |
127 | /* |
128 | * If the HW watchdog is NOT enabled, make sure it is not running, | |
129 | * for example because it was enabled in the preloader. This might | |
130 | * trigger a watchdog-triggered reboot of Linux kernel later. | |
a71df7aa | 131 | * Toggle watchdog reset, so watchdog in not running state. |
de6da925 | 132 | */ |
a71df7aa MV |
133 | socfpga_per_reset(SOCFPGA_RESET(L4WD0), 1); |
134 | socfpga_per_reset(SOCFPGA_RESET(L4WD0), 0); | |
de6da925 | 135 | #endif |
d0e932de | 136 | |
de6da925 PM |
137 | return 0; |
138 | } |