Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Stefan Roese | 93e6bf4 | 2014-10-22 12:13:17 +0200 | [diff] [blame] | 2 | /* |
Stefan Roese | c03a213 | 2016-01-07 14:03:11 +0100 | [diff] [blame] | 3 | * Copyright (C) 2014-2016 Stefan Roese <sr@denx.de> |
Stefan Roese | 93e6bf4 | 2014-10-22 12:13:17 +0200 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #include <common.h> |
Stefan Roese | bb1c0bd | 2015-06-29 14:58:13 +0200 | [diff] [blame] | 7 | #include <ahci.h> |
Simon Glass | 1d91ba7 | 2019-11-14 12:57:37 -0700 | [diff] [blame] | 8 | #include <cpu_func.h> |
Simon Glass | 9758973 | 2020-05-10 11:40:02 -0600 | [diff] [blame] | 9 | #include <init.h> |
Simon Glass | 4dcacfc | 2020-05-10 11:40:13 -0600 | [diff] [blame] | 10 | #include <linux/bitops.h> |
Simon Glass | dbd7954 | 2020-05-10 11:40:11 -0600 | [diff] [blame] | 11 | #include <linux/delay.h> |
Stefan Roese | bb1c0bd | 2015-06-29 14:58:13 +0200 | [diff] [blame] | 12 | #include <linux/mbus.h> |
Stefan Roese | 93e6bf4 | 2014-10-22 12:13:17 +0200 | [diff] [blame] | 13 | #include <asm/io.h> |
Stefan Roese | 8aee4d3 | 2015-05-18 16:09:43 +0000 | [diff] [blame] | 14 | #include <asm/pl310.h> |
Stefan Roese | 93e6bf4 | 2014-10-22 12:13:17 +0200 | [diff] [blame] | 15 | #include <asm/arch/cpu.h> |
| 16 | #include <asm/arch/soc.h> |
Marek Behún | ee76b4a | 2021-08-16 15:19:37 +0200 | [diff] [blame] | 17 | #include <asm/spl.h> |
Stefan Roese | d3e3473 | 2015-06-29 14:58:10 +0200 | [diff] [blame] | 18 | #include <sdhci.h> |
Stefan Roese | 93e6bf4 | 2014-10-22 12:13:17 +0200 | [diff] [blame] | 19 | |
| 20 | #define DDR_BASE_CS_OFF(n) (0x0000 + ((n) << 3)) |
| 21 | #define DDR_SIZE_CS_OFF(n) (0x0004 + ((n) << 3)) |
| 22 | |
Pali Rohár | 32301ee | 2022-09-09 14:41:28 +0200 | [diff] [blame] | 23 | static const struct mbus_win windows[] = { |
Stefan Roese | 93e6bf4 | 2014-10-22 12:13:17 +0200 | [diff] [blame] | 24 | /* SPI */ |
Stefan Roese | 13b109f | 2015-07-01 12:55:07 +0200 | [diff] [blame] | 25 | { MBUS_SPI_BASE, MBUS_SPI_SIZE, |
| 26 | CPU_TARGET_DEVICEBUS_BOOTROM_SPI, CPU_ATTR_SPIFLASH }, |
Stefan Roese | 93e6bf4 | 2014-10-22 12:13:17 +0200 | [diff] [blame] | 27 | |
| 28 | /* NOR */ |
Stefan Roese | 13b109f | 2015-07-01 12:55:07 +0200 | [diff] [blame] | 29 | { MBUS_BOOTROM_BASE, MBUS_BOOTROM_SIZE, |
| 30 | CPU_TARGET_DEVICEBUS_BOOTROM_SPI, CPU_ATTR_BOOTROM }, |
Chris Packham | a8f845e | 2019-04-11 22:22:50 +1200 | [diff] [blame] | 31 | |
| 32 | #ifdef CONFIG_ARMADA_MSYS |
| 33 | /* DFX */ |
| 34 | { MBUS_DFX_BASE, MBUS_DFX_SIZE, CPU_TARGET_DFX, 0 }, |
| 35 | #endif |
Stefan Roese | 93e6bf4 | 2014-10-22 12:13:17 +0200 | [diff] [blame] | 36 | }; |
| 37 | |
Stefan Roese | e1b7bfd | 2015-08-25 14:09:12 +0200 | [diff] [blame] | 38 | void lowlevel_init(void) |
| 39 | { |
| 40 | /* |
| 41 | * Dummy implementation, we only need LOWLEVEL_INIT |
| 42 | * on Armada to configure CP15 in start.S / cpu_init_cp15() |
| 43 | */ |
| 44 | } |
| 45 | |
Harald Seiler | 6f14d5f | 2020-12-15 16:47:52 +0100 | [diff] [blame] | 46 | void reset_cpu(void) |
Stefan Roese | 93e6bf4 | 2014-10-22 12:13:17 +0200 | [diff] [blame] | 47 | { |
| 48 | struct mvebu_system_registers *reg = |
| 49 | (struct mvebu_system_registers *)MVEBU_SYSTEM_REG_BASE; |
| 50 | |
| 51 | writel(readl(®->rstoutn_mask) | 1, ®->rstoutn_mask); |
| 52 | writel(readl(®->sys_soft_rst) | 1, ®->sys_soft_rst); |
| 53 | while (1) |
| 54 | ; |
| 55 | } |
| 56 | |
Marek Behún | ee76b4a | 2021-08-16 15:19:37 +0200 | [diff] [blame] | 57 | u32 get_boot_device(void) |
| 58 | { |
| 59 | u32 val; |
| 60 | u32 boot_device; |
| 61 | |
| 62 | /* |
Tom Rini | b056ce40 | 2021-09-01 07:52:08 -0400 | [diff] [blame] | 63 | * First check, if UART boot-mode is active. This can only |
| 64 | * be done, via the bootrom error register. Here the |
| 65 | * MSB marks if the UART mode is active. |
| 66 | */ |
Tom Rini | 3327dd7 | 2022-03-30 18:07:12 -0400 | [diff] [blame] | 67 | val = readl(BOOTROM_ERR_REG); |
Marek Behún | ee76b4a | 2021-08-16 15:19:37 +0200 | [diff] [blame] | 68 | boot_device = (val & BOOTROM_ERR_MODE_MASK) >> BOOTROM_ERR_MODE_OFFS; |
| 69 | debug("BOOTROM_REG=0x%08x boot_device=0x%x\n", val, boot_device); |
| 70 | if (boot_device == BOOTROM_ERR_MODE_UART) |
| 71 | return BOOT_DEVICE_UART; |
| 72 | |
| 73 | #ifdef CONFIG_ARMADA_38X |
| 74 | /* |
Tom Rini | b056ce40 | 2021-09-01 07:52:08 -0400 | [diff] [blame] | 75 | * If the bootrom error code contains any other than zeros it's an |
| 76 | * error condition and the bootROM has fallen back to UART boot |
| 77 | */ |
Marek Behún | ee76b4a | 2021-08-16 15:19:37 +0200 | [diff] [blame] | 78 | boot_device = (val & BOOTROM_ERR_CODE_MASK) >> BOOTROM_ERR_CODE_OFFS; |
| 79 | if (boot_device) |
| 80 | return BOOT_DEVICE_UART; |
| 81 | #endif |
| 82 | |
| 83 | /* |
Tom Rini | b056ce40 | 2021-09-01 07:52:08 -0400 | [diff] [blame] | 84 | * Now check the SAR register for the strapped boot-device |
| 85 | */ |
Marek Behún | ee76b4a | 2021-08-16 15:19:37 +0200 | [diff] [blame] | 86 | val = readl(CONFIG_SAR_REG); /* SAR - Sample At Reset */ |
| 87 | boot_device = (val & BOOT_DEV_SEL_MASK) >> BOOT_DEV_SEL_OFFS; |
| 88 | debug("SAR_REG=0x%08x boot_device=0x%x\n", val, boot_device); |
| 89 | switch (boot_device) { |
| 90 | #ifdef BOOT_FROM_NAND |
| 91 | case BOOT_FROM_NAND: |
| 92 | return BOOT_DEVICE_NAND; |
| 93 | #endif |
| 94 | #ifdef BOOT_FROM_MMC |
| 95 | case BOOT_FROM_MMC: |
| 96 | case BOOT_FROM_MMC_ALT: |
| 97 | return BOOT_DEVICE_MMC1; |
| 98 | #endif |
| 99 | case BOOT_FROM_UART: |
| 100 | #ifdef BOOT_FROM_UART_ALT |
| 101 | case BOOT_FROM_UART_ALT: |
| 102 | #endif |
| 103 | return BOOT_DEVICE_UART; |
| 104 | #ifdef BOOT_FROM_SATA |
| 105 | case BOOT_FROM_SATA: |
| 106 | case BOOT_FROM_SATA_ALT: |
| 107 | return BOOT_DEVICE_SATA; |
| 108 | #endif |
| 109 | case BOOT_FROM_SPI: |
| 110 | return BOOT_DEVICE_SPI; |
| 111 | default: |
| 112 | return BOOT_DEVICE_BOOTROM; |
| 113 | }; |
| 114 | } |
| 115 | |
Stefan Roese | 93e6bf4 | 2014-10-22 12:13:17 +0200 | [diff] [blame] | 116 | #if defined(CONFIG_DISPLAY_CPUINFO) |
Stefan Roese | 2a539c8 | 2015-12-21 12:36:40 +0100 | [diff] [blame] | 117 | |
Stefan Roese | 479f9af | 2016-02-10 07:23:00 +0100 | [diff] [blame] | 118 | #if defined(CONFIG_ARMADA_375) |
| 119 | /* SAR frequency values for Armada 375 */ |
| 120 | static const struct sar_freq_modes sar_freq_tab[] = { |
| 121 | { 0, 0x0, 266, 133, 266 }, |
| 122 | { 1, 0x0, 333, 167, 167 }, |
| 123 | { 2, 0x0, 333, 167, 222 }, |
| 124 | { 3, 0x0, 333, 167, 333 }, |
| 125 | { 4, 0x0, 400, 200, 200 }, |
| 126 | { 5, 0x0, 400, 200, 267 }, |
| 127 | { 6, 0x0, 400, 200, 400 }, |
| 128 | { 7, 0x0, 500, 250, 250 }, |
| 129 | { 8, 0x0, 500, 250, 334 }, |
| 130 | { 9, 0x0, 500, 250, 500 }, |
| 131 | { 10, 0x0, 533, 267, 267 }, |
| 132 | { 11, 0x0, 533, 267, 356 }, |
| 133 | { 12, 0x0, 533, 267, 533 }, |
| 134 | { 13, 0x0, 600, 300, 300 }, |
| 135 | { 14, 0x0, 600, 300, 400 }, |
| 136 | { 15, 0x0, 600, 300, 600 }, |
| 137 | { 16, 0x0, 666, 333, 333 }, |
| 138 | { 17, 0x0, 666, 333, 444 }, |
| 139 | { 18, 0x0, 666, 333, 666 }, |
| 140 | { 19, 0x0, 800, 400, 267 }, |
| 141 | { 20, 0x0, 800, 400, 400 }, |
| 142 | { 21, 0x0, 800, 400, 534 }, |
| 143 | { 22, 0x0, 900, 450, 300 }, |
| 144 | { 23, 0x0, 900, 450, 450 }, |
| 145 | { 24, 0x0, 900, 450, 600 }, |
| 146 | { 25, 0x0, 1000, 500, 500 }, |
| 147 | { 26, 0x0, 1000, 500, 667 }, |
| 148 | { 27, 0x0, 1000, 333, 500 }, |
| 149 | { 28, 0x0, 400, 400, 400 }, |
| 150 | { 29, 0x0, 1100, 550, 550 }, |
| 151 | { 0xff, 0xff, 0, 0, 0 } /* 0xff marks end of array */ |
| 152 | }; |
| 153 | #elif defined(CONFIG_ARMADA_38X) |
Stefan Roese | c03a213 | 2016-01-07 14:03:11 +0100 | [diff] [blame] | 154 | /* SAR frequency values for Armada 38x */ |
Stefan Roese | 32139c3 | 2016-01-07 14:04:51 +0100 | [diff] [blame] | 155 | static const struct sar_freq_modes sar_freq_tab[] = { |
Chris Packham | 5ccd14e | 2017-09-05 17:03:26 +1200 | [diff] [blame] | 156 | { 0x0, 0x0, 666, 333, 333 }, |
| 157 | { 0x2, 0x0, 800, 400, 400 }, |
| 158 | { 0x4, 0x0, 1066, 533, 533 }, |
| 159 | { 0x6, 0x0, 1200, 600, 600 }, |
| 160 | { 0x8, 0x0, 1332, 666, 666 }, |
| 161 | { 0xc, 0x0, 1600, 800, 800 }, |
| 162 | { 0x10, 0x0, 1866, 933, 933 }, |
| 163 | { 0x13, 0x0, 2000, 1000, 933 }, |
| 164 | { 0xff, 0xff, 0, 0, 0 } /* 0xff marks end of array */ |
Stefan Roese | 2a539c8 | 2015-12-21 12:36:40 +0100 | [diff] [blame] | 165 | }; |
Chris Packham | a8f845e | 2019-04-11 22:22:50 +1200 | [diff] [blame] | 166 | #elif defined(CONFIG_ARMADA_MSYS) |
| 167 | static const struct sar_freq_modes sar_freq_tab[] = { |
| 168 | { 0x0, 0x0, 400, 400, 400 }, |
| 169 | { 0x2, 0x0, 667, 333, 667 }, |
| 170 | { 0x3, 0x0, 800, 400, 800 }, |
| 171 | { 0x5, 0x0, 800, 400, 800 }, |
| 172 | { 0xff, 0xff, 0, 0, 0 } /* 0xff marks end of array */ |
| 173 | }; |
Stefan Roese | 2a539c8 | 2015-12-21 12:36:40 +0100 | [diff] [blame] | 174 | #else |
Stefan Roese | c03a213 | 2016-01-07 14:03:11 +0100 | [diff] [blame] | 175 | /* SAR frequency values for Armada XP */ |
Stefan Roese | 32139c3 | 2016-01-07 14:04:51 +0100 | [diff] [blame] | 176 | static const struct sar_freq_modes sar_freq_tab[] = { |
Stefan Roese | 2a539c8 | 2015-12-21 12:36:40 +0100 | [diff] [blame] | 177 | { 0xa, 0x5, 800, 400, 400 }, |
| 178 | { 0x1, 0x5, 1066, 533, 533 }, |
| 179 | { 0x2, 0x5, 1200, 600, 600 }, |
| 180 | { 0x2, 0x9, 1200, 600, 400 }, |
| 181 | { 0x3, 0x5, 1333, 667, 667 }, |
| 182 | { 0x4, 0x5, 1500, 750, 750 }, |
| 183 | { 0x4, 0x9, 1500, 750, 500 }, |
| 184 | { 0xb, 0x9, 1600, 800, 533 }, |
| 185 | { 0xb, 0xa, 1600, 800, 640 }, |
| 186 | { 0xb, 0x5, 1600, 800, 800 }, |
| 187 | { 0xff, 0xff, 0, 0, 0 } /* 0xff marks end of array */ |
| 188 | }; |
| 189 | #endif |
| 190 | |
| 191 | void get_sar_freq(struct sar_freq_modes *sar_freq) |
| 192 | { |
| 193 | u32 val; |
| 194 | u32 freq; |
| 195 | int i; |
| 196 | |
Chris Packham | a8f845e | 2019-04-11 22:22:50 +1200 | [diff] [blame] | 197 | #if defined(CONFIG_ARMADA_375) || defined(CONFIG_ARMADA_MSYS) |
Stefan Roese | 479f9af | 2016-02-10 07:23:00 +0100 | [diff] [blame] | 198 | val = readl(CONFIG_SAR2_REG); /* SAR - Sample At Reset */ |
| 199 | #else |
Stefan Roese | 2a539c8 | 2015-12-21 12:36:40 +0100 | [diff] [blame] | 200 | val = readl(CONFIG_SAR_REG); /* SAR - Sample At Reset */ |
Stefan Roese | 479f9af | 2016-02-10 07:23:00 +0100 | [diff] [blame] | 201 | #endif |
Stefan Roese | 2a539c8 | 2015-12-21 12:36:40 +0100 | [diff] [blame] | 202 | freq = (val & SAR_CPU_FREQ_MASK) >> SAR_CPU_FREQ_OFFS; |
Stefan Roese | 479f9af | 2016-02-10 07:23:00 +0100 | [diff] [blame] | 203 | #if defined(SAR2_CPU_FREQ_MASK) |
Stefan Roese | 2a539c8 | 2015-12-21 12:36:40 +0100 | [diff] [blame] | 204 | /* |
| 205 | * Shift CPU0 clock frequency select bit from SAR2 register |
| 206 | * into correct position |
| 207 | */ |
| 208 | freq |= ((readl(CONFIG_SAR2_REG) & SAR2_CPU_FREQ_MASK) |
| 209 | >> SAR2_CPU_FREQ_OFFS) << 3; |
| 210 | #endif |
| 211 | for (i = 0; sar_freq_tab[i].val != 0xff; i++) { |
| 212 | if (sar_freq_tab[i].val == freq) { |
Chris Packham | a8f845e | 2019-04-11 22:22:50 +1200 | [diff] [blame] | 213 | #if defined(CONFIG_ARMADA_375) || defined(CONFIG_ARMADA_38X) || defined(CONFIG_ARMADA_MSYS) |
Stefan Roese | 2a539c8 | 2015-12-21 12:36:40 +0100 | [diff] [blame] | 214 | *sar_freq = sar_freq_tab[i]; |
| 215 | return; |
| 216 | #else |
| 217 | int k; |
| 218 | u8 ffc; |
| 219 | |
| 220 | ffc = (val & SAR_FFC_FREQ_MASK) >> |
| 221 | SAR_FFC_FREQ_OFFS; |
| 222 | for (k = i; sar_freq_tab[k].ffc != 0xff; k++) { |
| 223 | if (sar_freq_tab[k].ffc == ffc) { |
| 224 | *sar_freq = sar_freq_tab[k]; |
| 225 | return; |
| 226 | } |
| 227 | } |
| 228 | i = k; |
| 229 | #endif |
| 230 | } |
| 231 | } |
| 232 | |
| 233 | /* SAR value not found, return 0 for frequencies */ |
| 234 | *sar_freq = sar_freq_tab[i - 1]; |
| 235 | } |
| 236 | |
Stefan Roese | 93e6bf4 | 2014-10-22 12:13:17 +0200 | [diff] [blame] | 237 | int print_cpuinfo(void) |
| 238 | { |
| 239 | u16 devid = (readl(MVEBU_REG_PCIE_DEVID) >> 16) & 0xffff; |
| 240 | u8 revid = readl(MVEBU_REG_PCIE_REVID) & 0xff; |
Stefan Roese | 2a539c8 | 2015-12-21 12:36:40 +0100 | [diff] [blame] | 241 | struct sar_freq_modes sar_freq; |
Stefan Roese | 93e6bf4 | 2014-10-22 12:13:17 +0200 | [diff] [blame] | 242 | |
| 243 | puts("SoC: "); |
| 244 | |
| 245 | switch (devid) { |
Phil Sutter | 22e553e | 2015-12-25 14:41:24 +0100 | [diff] [blame] | 246 | case SOC_MV78230_ID: |
| 247 | puts("MV78230-"); |
| 248 | break; |
Stefan Roese | b158f37 | 2015-12-09 11:00:51 +0100 | [diff] [blame] | 249 | case SOC_MV78260_ID: |
| 250 | puts("MV78260-"); |
| 251 | break; |
Stefan Roese | 93e6bf4 | 2014-10-22 12:13:17 +0200 | [diff] [blame] | 252 | case SOC_MV78460_ID: |
| 253 | puts("MV78460-"); |
| 254 | break; |
Stefan Roese | 479f9af | 2016-02-10 07:23:00 +0100 | [diff] [blame] | 255 | case SOC_88F6720_ID: |
| 256 | puts("MV88F6720-"); |
| 257 | break; |
Stefan Roese | 174d23e | 2015-04-25 06:29:51 +0200 | [diff] [blame] | 258 | case SOC_88F6810_ID: |
| 259 | puts("MV88F6810-"); |
Stefan Roese | 93e6bf4 | 2014-10-22 12:13:17 +0200 | [diff] [blame] | 260 | break; |
Stefan Roese | 174d23e | 2015-04-25 06:29:51 +0200 | [diff] [blame] | 261 | case SOC_88F6820_ID: |
| 262 | puts("MV88F6820-"); |
Stefan Roese | 93e6bf4 | 2014-10-22 12:13:17 +0200 | [diff] [blame] | 263 | break; |
Stefan Roese | 174d23e | 2015-04-25 06:29:51 +0200 | [diff] [blame] | 264 | case SOC_88F6828_ID: |
| 265 | puts("MV88F6828-"); |
Stefan Roese | 93e6bf4 | 2014-10-22 12:13:17 +0200 | [diff] [blame] | 266 | break; |
Chris Packham | 348109d | 2017-09-04 17:38:31 +1200 | [diff] [blame] | 267 | case SOC_98DX3236_ID: |
| 268 | puts("98DX3236-"); |
| 269 | break; |
| 270 | case SOC_98DX3336_ID: |
| 271 | puts("98DX3336-"); |
| 272 | break; |
| 273 | case SOC_98DX4251_ID: |
| 274 | puts("98DX4251-"); |
| 275 | break; |
Stefan Roese | 93e6bf4 | 2014-10-22 12:13:17 +0200 | [diff] [blame] | 276 | default: |
Stefan Roese | 174d23e | 2015-04-25 06:29:51 +0200 | [diff] [blame] | 277 | puts("Unknown-"); |
Stefan Roese | 93e6bf4 | 2014-10-22 12:13:17 +0200 | [diff] [blame] | 278 | break; |
| 279 | } |
| 280 | |
Pali Rohár | fdf415c | 2022-07-15 10:13:12 +0200 | [diff] [blame] | 281 | switch (devid) { |
| 282 | case SOC_MV78230_ID: |
| 283 | case SOC_MV78260_ID: |
| 284 | case SOC_MV78460_ID: |
Stefan Roese | 174d23e | 2015-04-25 06:29:51 +0200 | [diff] [blame] | 285 | switch (revid) { |
| 286 | case 1: |
Stefan Roese | 2a539c8 | 2015-12-21 12:36:40 +0100 | [diff] [blame] | 287 | puts("A0"); |
Stefan Roese | 174d23e | 2015-04-25 06:29:51 +0200 | [diff] [blame] | 288 | break; |
| 289 | case 2: |
Stefan Roese | 2a539c8 | 2015-12-21 12:36:40 +0100 | [diff] [blame] | 290 | puts("B0"); |
Stefan Roese | 174d23e | 2015-04-25 06:29:51 +0200 | [diff] [blame] | 291 | break; |
| 292 | default: |
Stefan Roese | 2a539c8 | 2015-12-21 12:36:40 +0100 | [diff] [blame] | 293 | printf("?? (%x)", revid); |
Stefan Roese | 174d23e | 2015-04-25 06:29:51 +0200 | [diff] [blame] | 294 | break; |
| 295 | } |
Pali Rohár | fdf415c | 2022-07-15 10:13:12 +0200 | [diff] [blame] | 296 | break; |
Stefan Roese | 174d23e | 2015-04-25 06:29:51 +0200 | [diff] [blame] | 297 | |
Pali Rohár | fdf415c | 2022-07-15 10:13:12 +0200 | [diff] [blame] | 298 | case SOC_88F6720_ID: |
Stefan Roese | 479f9af | 2016-02-10 07:23:00 +0100 | [diff] [blame] | 299 | switch (revid) { |
| 300 | case MV_88F67XX_A0_ID: |
| 301 | puts("A0"); |
| 302 | break; |
| 303 | default: |
| 304 | printf("?? (%x)", revid); |
| 305 | break; |
| 306 | } |
Pali Rohár | fdf415c | 2022-07-15 10:13:12 +0200 | [diff] [blame] | 307 | break; |
Stefan Roese | 479f9af | 2016-02-10 07:23:00 +0100 | [diff] [blame] | 308 | |
Pali Rohár | fdf415c | 2022-07-15 10:13:12 +0200 | [diff] [blame] | 309 | case SOC_88F6810_ID: |
| 310 | case SOC_88F6820_ID: |
| 311 | case SOC_88F6828_ID: |
Stefan Roese | 174d23e | 2015-04-25 06:29:51 +0200 | [diff] [blame] | 312 | switch (revid) { |
| 313 | case MV_88F68XX_Z1_ID: |
Stefan Roese | 2a539c8 | 2015-12-21 12:36:40 +0100 | [diff] [blame] | 314 | puts("Z1"); |
Stefan Roese | 174d23e | 2015-04-25 06:29:51 +0200 | [diff] [blame] | 315 | break; |
| 316 | case MV_88F68XX_A0_ID: |
Stefan Roese | 2a539c8 | 2015-12-21 12:36:40 +0100 | [diff] [blame] | 317 | puts("A0"); |
Stefan Roese | 174d23e | 2015-04-25 06:29:51 +0200 | [diff] [blame] | 318 | break; |
Chris Packham | ec4510b | 2018-11-28 10:32:00 +1300 | [diff] [blame] | 319 | case MV_88F68XX_B0_ID: |
| 320 | puts("B0"); |
| 321 | break; |
Stefan Roese | 174d23e | 2015-04-25 06:29:51 +0200 | [diff] [blame] | 322 | default: |
Stefan Roese | 2a539c8 | 2015-12-21 12:36:40 +0100 | [diff] [blame] | 323 | printf("?? (%x)", revid); |
Stefan Roese | 174d23e | 2015-04-25 06:29:51 +0200 | [diff] [blame] | 324 | break; |
| 325 | } |
Pali Rohár | fdf415c | 2022-07-15 10:13:12 +0200 | [diff] [blame] | 326 | break; |
Stefan Roese | 174d23e | 2015-04-25 06:29:51 +0200 | [diff] [blame] | 327 | |
Pali Rohár | fdf415c | 2022-07-15 10:13:12 +0200 | [diff] [blame] | 328 | case SOC_98DX3236_ID: |
| 329 | case SOC_98DX3336_ID: |
| 330 | case SOC_98DX4251_ID: |
Chris Packham | a8f845e | 2019-04-11 22:22:50 +1200 | [diff] [blame] | 331 | switch (revid) { |
| 332 | case 3: |
| 333 | puts("A0"); |
| 334 | break; |
| 335 | case 4: |
| 336 | puts("A1"); |
| 337 | break; |
| 338 | default: |
| 339 | printf("?? (%x)", revid); |
| 340 | break; |
| 341 | } |
Pali Rohár | fdf415c | 2022-07-15 10:13:12 +0200 | [diff] [blame] | 342 | break; |
| 343 | |
| 344 | default: |
| 345 | printf("?? (%x)", revid); |
| 346 | break; |
Chris Packham | a8f845e | 2019-04-11 22:22:50 +1200 | [diff] [blame] | 347 | } |
| 348 | |
Stefan Roese | 2a539c8 | 2015-12-21 12:36:40 +0100 | [diff] [blame] | 349 | get_sar_freq(&sar_freq); |
| 350 | printf(" at %d MHz\n", sar_freq.p_clk); |
| 351 | |
Stefan Roese | 93e6bf4 | 2014-10-22 12:13:17 +0200 | [diff] [blame] | 352 | return 0; |
| 353 | } |
| 354 | #endif /* CONFIG_DISPLAY_CPUINFO */ |
| 355 | |
| 356 | /* |
| 357 | * This function initialize Controller DRAM Fastpath windows. |
| 358 | * It takes the CS size information from the 0x1500 scratch registers |
| 359 | * and sets the correct windows sizes and base addresses accordingly. |
| 360 | * |
| 361 | * These values are set in the scratch registers by the Marvell |
Chris Packham | 1cd77b0 | 2018-12-14 16:27:57 +1300 | [diff] [blame] | 362 | * DDR3 training code, which is executed by the SPL before the |
| 363 | * main payload (U-Boot) is executed. |
Stefan Roese | 93e6bf4 | 2014-10-22 12:13:17 +0200 | [diff] [blame] | 364 | */ |
| 365 | static void update_sdram_window_sizes(void) |
| 366 | { |
| 367 | u64 base = 0; |
| 368 | u32 size, temp; |
| 369 | int i; |
| 370 | |
| 371 | for (i = 0; i < SDRAM_MAX_CS; i++) { |
| 372 | size = readl((MVEBU_SDRAM_SCRATCH + (i * 8))) & SDRAM_ADDR_MASK; |
| 373 | if (size != 0) { |
| 374 | size |= ~(SDRAM_ADDR_MASK); |
| 375 | |
| 376 | /* Set Base Address */ |
| 377 | temp = (base & 0xFF000000ll) | ((base >> 32) & 0xF); |
| 378 | writel(temp, MVEBU_SDRAM_BASE + DDR_BASE_CS_OFF(i)); |
| 379 | |
| 380 | /* |
| 381 | * Check if out of max window size and resize |
| 382 | * the window |
| 383 | */ |
| 384 | temp = (readl(MVEBU_SDRAM_BASE + DDR_SIZE_CS_OFF(i)) & |
| 385 | ~(SDRAM_ADDR_MASK)) | 1; |
| 386 | temp |= (size & SDRAM_ADDR_MASK); |
| 387 | writel(temp, MVEBU_SDRAM_BASE + DDR_SIZE_CS_OFF(i)); |
| 388 | |
| 389 | base += ((u64)size + 1); |
| 390 | } else { |
| 391 | /* |
| 392 | * Disable window if not used, otherwise this |
| 393 | * leads to overlapping enabled windows with |
| 394 | * pretty strange results |
| 395 | */ |
| 396 | clrbits_le32(MVEBU_SDRAM_BASE + DDR_SIZE_CS_OFF(i), 1); |
| 397 | } |
| 398 | } |
| 399 | } |
| 400 | |
| 401 | #ifdef CONFIG_ARCH_CPU_INIT |
Stefan Roese | f43d323 | 2015-07-22 18:26:13 +0200 | [diff] [blame] | 402 | #define MV_USB_PHY_BASE (MVEBU_AXP_USB_BASE + 0x800) |
| 403 | #define MV_USB_PHY_PLL_REG(reg) (MV_USB_PHY_BASE | (((reg) & 0xF) << 2)) |
| 404 | #define MV_USB_X3_BASE(addr) (MVEBU_AXP_USB_BASE | BIT(11) | \ |
| 405 | (((addr) & 0xF) << 6)) |
| 406 | #define MV_USB_X3_PHY_CHANNEL(dev, reg) (MV_USB_X3_BASE((dev) + 1) | \ |
| 407 | (((reg) & 0xF) << 2)) |
| 408 | |
| 409 | static void setup_usb_phys(void) |
| 410 | { |
| 411 | int dev; |
| 412 | |
| 413 | /* |
| 414 | * USB PLL init |
| 415 | */ |
| 416 | |
| 417 | /* Setup PLL frequency */ |
| 418 | /* USB REF frequency = 25 MHz */ |
| 419 | clrsetbits_le32(MV_USB_PHY_PLL_REG(1), 0x3ff, 0x605); |
| 420 | |
| 421 | /* Power up PLL and PHY channel */ |
Stefan Roese | 0b1d537 | 2015-12-04 13:08:34 +0100 | [diff] [blame] | 422 | setbits_le32(MV_USB_PHY_PLL_REG(2), BIT(9)); |
Stefan Roese | f43d323 | 2015-07-22 18:26:13 +0200 | [diff] [blame] | 423 | |
| 424 | /* Assert VCOCAL_START */ |
Stefan Roese | 0b1d537 | 2015-12-04 13:08:34 +0100 | [diff] [blame] | 425 | setbits_le32(MV_USB_PHY_PLL_REG(1), BIT(21)); |
Stefan Roese | f43d323 | 2015-07-22 18:26:13 +0200 | [diff] [blame] | 426 | |
| 427 | mdelay(1); |
| 428 | |
| 429 | /* |
| 430 | * USB PHY init (change from defaults) specific for 40nm (78X30 78X60) |
| 431 | */ |
| 432 | |
| 433 | for (dev = 0; dev < 3; dev++) { |
Stefan Roese | 0b1d537 | 2015-12-04 13:08:34 +0100 | [diff] [blame] | 434 | setbits_le32(MV_USB_X3_PHY_CHANNEL(dev, 3), BIT(15)); |
Stefan Roese | f43d323 | 2015-07-22 18:26:13 +0200 | [diff] [blame] | 435 | |
| 436 | /* Assert REG_RCAL_START in channel REG 1 */ |
Stefan Roese | 0b1d537 | 2015-12-04 13:08:34 +0100 | [diff] [blame] | 437 | setbits_le32(MV_USB_X3_PHY_CHANNEL(dev, 1), BIT(12)); |
Stefan Roese | f43d323 | 2015-07-22 18:26:13 +0200 | [diff] [blame] | 438 | udelay(40); |
Stefan Roese | 0b1d537 | 2015-12-04 13:08:34 +0100 | [diff] [blame] | 439 | clrbits_le32(MV_USB_X3_PHY_CHANNEL(dev, 1), BIT(12)); |
Stefan Roese | f43d323 | 2015-07-22 18:26:13 +0200 | [diff] [blame] | 440 | } |
| 441 | } |
Kevin Smith | 1ddff02 | 2015-05-18 16:09:44 +0000 | [diff] [blame] | 442 | |
Stefan Roese | e7c7228 | 2015-12-03 12:39:45 +0100 | [diff] [blame] | 443 | /* |
| 444 | * This function is not called from the SPL U-Boot version |
| 445 | */ |
Stefan Roese | 93e6bf4 | 2014-10-22 12:13:17 +0200 | [diff] [blame] | 446 | int arch_cpu_init(void) |
| 447 | { |
Stefan Roese | e1b7bfd | 2015-08-25 14:09:12 +0200 | [diff] [blame] | 448 | struct pl310_regs *const pl310 = |
| 449 | (struct pl310_regs *)CONFIG_SYS_PL310_BASE; |
| 450 | |
Pali Rohár | 6f90ffc | 2022-09-08 16:06:51 +0200 | [diff] [blame] | 451 | if (!IS_ENABLED(CONFIG_ARMADA_XP)) { |
Stefan Roese | caf74c9 | 2015-12-03 12:39:45 +0100 | [diff] [blame] | 452 | /* |
| 453 | * To fully release / unlock this area from cache, we need |
| 454 | * to flush all caches and disable the L2 cache. |
| 455 | */ |
| 456 | icache_disable(); |
| 457 | dcache_disable(); |
| 458 | clrbits_le32(&pl310->pl310_ctrl, L2X0_CTRL_EN); |
| 459 | } |
Stefan Roese | 73acffe | 2015-04-24 10:49:11 +0200 | [diff] [blame] | 460 | |
Stefan Roese | 93e6bf4 | 2014-10-22 12:13:17 +0200 | [diff] [blame] | 461 | /* |
| 462 | * We need to call mvebu_mbus_probe() before calling |
| 463 | * update_sdram_window_sizes() as it disables all previously |
| 464 | * configured mbus windows and then configures them as |
| 465 | * required for U-Boot. Calling update_sdram_window_sizes() |
| 466 | * without this configuration will not work, as the internal |
| 467 | * registers can't be accessed reliably because of potenial |
| 468 | * double mapping. |
| 469 | * After updating the SDRAM access windows we need to call |
| 470 | * mvebu_mbus_probe() again, as this now correctly configures |
| 471 | * the SDRAM areas that are later used by the MVEBU drivers |
| 472 | * (e.g. USB, NETA). |
| 473 | */ |
| 474 | |
| 475 | /* |
| 476 | * First disable all windows |
| 477 | */ |
| 478 | mvebu_mbus_probe(NULL, 0); |
| 479 | |
Pali Rohár | fdf415c | 2022-07-15 10:13:12 +0200 | [diff] [blame] | 480 | if (IS_ENABLED(CONFIG_ARMADA_XP)) { |
Stefan Roese | 174d23e | 2015-04-25 06:29:51 +0200 | [diff] [blame] | 481 | /* |
| 482 | * Now the SDRAM access windows can be reconfigured using |
| 483 | * the information in the SDRAM scratch pad registers |
| 484 | */ |
| 485 | update_sdram_window_sizes(); |
| 486 | } |
Stefan Roese | 93e6bf4 | 2014-10-22 12:13:17 +0200 | [diff] [blame] | 487 | |
| 488 | /* |
| 489 | * Finally the mbus windows can be configured with the |
| 490 | * updated SDRAM sizes |
| 491 | */ |
| 492 | mvebu_mbus_probe(windows, ARRAY_SIZE(windows)); |
| 493 | |
Pali Rohár | fdf415c | 2022-07-15 10:13:12 +0200 | [diff] [blame] | 494 | if (IS_ENABLED(CONFIG_ARMADA_XP)) { |
Stefan Roese | badccc3 | 2015-07-16 10:40:05 +0200 | [diff] [blame] | 495 | /* Enable GBE0, GBE1, LCD and NFC PUP */ |
| 496 | clrsetbits_le32(ARMADA_XP_PUP_ENABLE, 0, |
| 497 | GE0_PUP_EN | GE1_PUP_EN | LCD_PUP_EN | |
| 498 | NAND_PUP_EN | SPI_PUP_EN); |
Stefan Roese | f43d323 | 2015-07-22 18:26:13 +0200 | [diff] [blame] | 499 | |
| 500 | /* Configure USB PLL and PHYs on AXP */ |
| 501 | setup_usb_phys(); |
Stefan Roese | badccc3 | 2015-07-16 10:40:05 +0200 | [diff] [blame] | 502 | } |
| 503 | |
| 504 | /* Enable NAND and NAND arbiter */ |
| 505 | clrsetbits_le32(MVEBU_SOC_DEV_MUX_REG, 0, NAND_EN | NAND_ARBITER_EN); |
| 506 | |
Stefan Roese | 8ac6dab | 2015-07-01 13:28:39 +0200 | [diff] [blame] | 507 | /* Disable MBUS error propagation */ |
| 508 | clrsetbits_le32(SOC_COHERENCY_FABRIC_CTRL_REG, MBUS_ERR_PROP_EN, 0); |
| 509 | |
Stefan Roese | 93e6bf4 | 2014-10-22 12:13:17 +0200 | [diff] [blame] | 510 | return 0; |
| 511 | } |
| 512 | #endif /* CONFIG_ARCH_CPU_INIT */ |
| 513 | |
Stefan Roese | badccc3 | 2015-07-16 10:40:05 +0200 | [diff] [blame] | 514 | u32 mvebu_get_nand_clock(void) |
| 515 | { |
Chris Packham | 460086e | 2016-08-22 12:38:39 +1200 | [diff] [blame] | 516 | u32 reg; |
| 517 | |
Pali Rohár | fdf415c | 2022-07-15 10:13:12 +0200 | [diff] [blame] | 518 | if (IS_ENABLED(CONFIG_ARMADA_38X)) |
Chris Packham | 460086e | 2016-08-22 12:38:39 +1200 | [diff] [blame] | 519 | reg = MVEBU_DFX_DIV_CLK_CTRL(1); |
Pali Rohár | fdf415c | 2022-07-15 10:13:12 +0200 | [diff] [blame] | 520 | else if (IS_ENABLED(CONFIG_ARMADA_MSYS)) |
Chris Packham | 7ce3f8c | 2019-04-11 22:22:51 +1200 | [diff] [blame] | 521 | reg = MVEBU_DFX_DIV_CLK_CTRL(8); |
Chris Packham | 460086e | 2016-08-22 12:38:39 +1200 | [diff] [blame] | 522 | else |
| 523 | reg = MVEBU_CORE_DIV_CLK_CTRL(1); |
| 524 | |
Stefan Roese | badccc3 | 2015-07-16 10:40:05 +0200 | [diff] [blame] | 525 | return CONFIG_SYS_MVEBU_PLL_CLOCK / |
Chris Packham | 460086e | 2016-08-22 12:38:39 +1200 | [diff] [blame] | 526 | ((readl(reg) & |
Stefan Roese | badccc3 | 2015-07-16 10:40:05 +0200 | [diff] [blame] | 527 | NAND_ECC_DIVCKL_RATIO_MASK) >> NAND_ECC_DIVCKL_RATIO_OFFS); |
| 528 | } |
| 529 | |
Stefan Roese | 93e6bf4 | 2014-10-22 12:13:17 +0200 | [diff] [blame] | 530 | /* |
| 531 | * SOC specific misc init |
| 532 | */ |
| 533 | #if defined(CONFIG_ARCH_MISC_INIT) |
| 534 | int arch_misc_init(void) |
| 535 | { |
| 536 | /* Nothing yet, perhaps we need something here later */ |
| 537 | return 0; |
| 538 | } |
| 539 | #endif /* CONFIG_ARCH_MISC_INIT */ |
| 540 | |
Pierre Bourdon | b9af62d | 2019-04-11 04:56:58 +0200 | [diff] [blame] | 541 | #if defined(CONFIG_MMC_SDHCI_MV) && !defined(CONFIG_DM_MMC) |
Masahiro Yamada | f7ed78b | 2020-06-26 15:13:33 +0900 | [diff] [blame] | 542 | int board_mmc_init(struct bd_info *bis) |
Stefan Roese | d3e3473 | 2015-06-29 14:58:10 +0200 | [diff] [blame] | 543 | { |
| 544 | mv_sdh_init(MVEBU_SDIO_BASE, 0, 0, |
| 545 | SDHCI_QUIRK_32BIT_DMA_ADDR | SDHCI_QUIRK_WAIT_SEND_CMD); |
| 546 | |
| 547 | return 0; |
| 548 | } |
| 549 | #endif |
| 550 | |
Stefan Roese | bb1c0bd | 2015-06-29 14:58:13 +0200 | [diff] [blame] | 551 | #define AHCI_VENDOR_SPECIFIC_0_ADDR 0xa0 |
| 552 | #define AHCI_VENDOR_SPECIFIC_0_DATA 0xa4 |
| 553 | |
| 554 | #define AHCI_WINDOW_CTRL(win) (0x60 + ((win) << 4)) |
| 555 | #define AHCI_WINDOW_BASE(win) (0x64 + ((win) << 4)) |
| 556 | #define AHCI_WINDOW_SIZE(win) (0x68 + ((win) << 4)) |
| 557 | |
| 558 | static void ahci_mvebu_mbus_config(void __iomem *base) |
| 559 | { |
| 560 | const struct mbus_dram_target_info *dram; |
| 561 | int i; |
| 562 | |
Baruch Siach | 2179c77 | 2019-05-16 13:03:57 +0300 | [diff] [blame] | 563 | /* mbus is not initialized in SPL; keep the ROM settings */ |
| 564 | if (IS_ENABLED(CONFIG_SPL_BUILD)) |
| 565 | return; |
| 566 | |
Stefan Roese | bb1c0bd | 2015-06-29 14:58:13 +0200 | [diff] [blame] | 567 | dram = mvebu_mbus_dram_info(); |
| 568 | |
| 569 | for (i = 0; i < 4; i++) { |
| 570 | writel(0, base + AHCI_WINDOW_CTRL(i)); |
| 571 | writel(0, base + AHCI_WINDOW_BASE(i)); |
| 572 | writel(0, base + AHCI_WINDOW_SIZE(i)); |
| 573 | } |
| 574 | |
| 575 | for (i = 0; i < dram->num_cs; i++) { |
| 576 | const struct mbus_dram_window *cs = dram->cs + i; |
| 577 | |
| 578 | writel((cs->mbus_attr << 8) | |
| 579 | (dram->mbus_dram_target_id << 4) | 1, |
| 580 | base + AHCI_WINDOW_CTRL(i)); |
| 581 | writel(cs->base >> 16, base + AHCI_WINDOW_BASE(i)); |
| 582 | writel(((cs->size - 1) & 0xffff0000), |
| 583 | base + AHCI_WINDOW_SIZE(i)); |
| 584 | } |
| 585 | } |
| 586 | |
| 587 | static void ahci_mvebu_regret_option(void __iomem *base) |
| 588 | { |
| 589 | /* |
| 590 | * Enable the regret bit to allow the SATA unit to regret a |
| 591 | * request that didn't receive an acknowlegde and avoid a |
| 592 | * deadlock |
| 593 | */ |
| 594 | writel(0x4, base + AHCI_VENDOR_SPECIFIC_0_ADDR); |
| 595 | writel(0x80, base + AHCI_VENDOR_SPECIFIC_0_DATA); |
| 596 | } |
| 597 | |
Baruch Siach | b590a14 | 2019-03-24 13:27:43 +0200 | [diff] [blame] | 598 | int board_ahci_enable(void) |
Stefan Roese | bb1c0bd | 2015-06-29 14:58:13 +0200 | [diff] [blame] | 599 | { |
Stefan Roese | bb1c0bd | 2015-06-29 14:58:13 +0200 | [diff] [blame] | 600 | ahci_mvebu_mbus_config((void __iomem *)MVEBU_SATA0_BASE); |
| 601 | ahci_mvebu_regret_option((void __iomem *)MVEBU_SATA0_BASE); |
Baruch Siach | b590a14 | 2019-03-24 13:27:43 +0200 | [diff] [blame] | 602 | |
| 603 | return 0; |
| 604 | } |
| 605 | |
| 606 | #ifdef CONFIG_SCSI_AHCI_PLAT |
| 607 | void scsi_init(void) |
| 608 | { |
| 609 | printf("MVEBU SATA INIT\n"); |
| 610 | board_ahci_enable(); |
Stefan Roese | bb1c0bd | 2015-06-29 14:58:13 +0200 | [diff] [blame] | 611 | ahci_init((void __iomem *)MVEBU_SATA0_BASE); |
| 612 | } |
| 613 | #endif |
| 614 | |
Jon Nettleton | 8650232 | 2017-11-06 10:33:20 +0200 | [diff] [blame] | 615 | #ifdef CONFIG_USB_XHCI_MVEBU |
| 616 | #define USB3_MAX_WINDOWS 4 |
| 617 | #define USB3_WIN_CTRL(w) (0x0 + ((w) * 8)) |
| 618 | #define USB3_WIN_BASE(w) (0x4 + ((w) * 8)) |
| 619 | |
| 620 | static void xhci_mvebu_mbus_config(void __iomem *base, |
| 621 | const struct mbus_dram_target_info *dram) |
| 622 | { |
| 623 | int i; |
| 624 | |
| 625 | for (i = 0; i < USB3_MAX_WINDOWS; i++) { |
| 626 | writel(0, base + USB3_WIN_CTRL(i)); |
| 627 | writel(0, base + USB3_WIN_BASE(i)); |
| 628 | } |
| 629 | |
| 630 | for (i = 0; i < dram->num_cs; i++) { |
| 631 | const struct mbus_dram_window *cs = dram->cs + i; |
| 632 | |
| 633 | /* Write size, attributes and target id to control register */ |
| 634 | writel(((cs->size - 1) & 0xffff0000) | (cs->mbus_attr << 8) | |
| 635 | (dram->mbus_dram_target_id << 4) | 1, |
| 636 | base + USB3_WIN_CTRL(i)); |
| 637 | |
| 638 | /* Write base address to base register */ |
| 639 | writel((cs->base & 0xffff0000), base + USB3_WIN_BASE(i)); |
| 640 | } |
| 641 | } |
| 642 | |
| 643 | int board_xhci_enable(fdt_addr_t base) |
| 644 | { |
| 645 | const struct mbus_dram_target_info *dram; |
| 646 | |
| 647 | printf("MVEBU XHCI INIT controller @ 0x%lx\n", base); |
| 648 | |
| 649 | dram = mvebu_mbus_dram_info(); |
| 650 | xhci_mvebu_mbus_config((void __iomem *)base, dram); |
| 651 | |
| 652 | return 0; |
| 653 | } |
| 654 | #endif |
| 655 | |
Stefan Roese | 93e6bf4 | 2014-10-22 12:13:17 +0200 | [diff] [blame] | 656 | void enable_caches(void) |
| 657 | { |
Stefan Roese | 7a4a5ba | 2015-04-25 06:29:55 +0200 | [diff] [blame] | 658 | /* Avoid problem with e.g. neta ethernet driver */ |
| 659 | invalidate_dcache_all(); |
| 660 | |
Stefan Roese | dafe60f | 2016-02-10 09:18:46 +0100 | [diff] [blame] | 661 | /* |
| 662 | * Armada 375 still has some problems with d-cache enabled in the |
| 663 | * ethernet driver (mvpp2). So lets keep the d-cache disabled |
| 664 | * until this is solved. |
| 665 | */ |
Pali Rohár | b94cb13 | 2022-09-08 16:06:50 +0200 | [diff] [blame] | 666 | if (!IS_ENABLED(CONFIG_ARMADA_375)) { |
Stefan Roese | dafe60f | 2016-02-10 09:18:46 +0100 | [diff] [blame] | 667 | /* Enable D-cache. I-cache is already enabled in start.S */ |
| 668 | dcache_enable(); |
| 669 | } |
Stefan Roese | 93e6bf4 | 2014-10-22 12:13:17 +0200 | [diff] [blame] | 670 | } |
Stefan Roese | 479a977 | 2015-12-03 12:39:45 +0100 | [diff] [blame] | 671 | |
| 672 | void v7_outer_cache_enable(void) |
| 673 | { |
Pali Rohár | 2100c4d | 2022-09-08 16:06:53 +0200 | [diff] [blame^] | 674 | struct pl310_regs *const pl310 = |
| 675 | (struct pl310_regs *)CONFIG_SYS_PL310_BASE; |
| 676 | |
| 677 | /* The L2 cache is already disabled at this point */ |
| 678 | |
| 679 | /* |
| 680 | * For now L2 cache will be enabled only for Armada XP and Armada 38x. |
| 681 | * It can be enabled also for other SoCs after testing that it works fine. |
| 682 | */ |
| 683 | if (!IS_ENABLED(CONFIG_ARMADA_XP) && !IS_ENABLED(CONFIG_ARMADA_38X)) |
| 684 | return; |
| 685 | |
Pali Rohár | fdf415c | 2022-07-15 10:13:12 +0200 | [diff] [blame] | 686 | if (IS_ENABLED(CONFIG_ARMADA_XP)) { |
Stefan Roese | 479a977 | 2015-12-03 12:39:45 +0100 | [diff] [blame] | 687 | u32 u; |
| 688 | |
| 689 | /* |
| 690 | * For Aurora cache in no outer mode, enable via the CP15 |
| 691 | * coprocessor broadcasting of cache commands to L2. |
| 692 | */ |
| 693 | asm volatile("mrc p15, 1, %0, c15, c2, 0" : "=r" (u)); |
| 694 | u |= BIT(8); /* Set the FW bit */ |
| 695 | asm volatile("mcr p15, 1, %0, c15, c2, 0" : : "r" (u)); |
| 696 | |
| 697 | isb(); |
Stefan Roese | 479a977 | 2015-12-03 12:39:45 +0100 | [diff] [blame] | 698 | } |
Pali Rohár | 2100c4d | 2022-09-08 16:06:53 +0200 | [diff] [blame^] | 699 | |
| 700 | /* Enable the L2 cache */ |
| 701 | setbits_le32(&pl310->pl310_ctrl, L2X0_CTRL_EN); |
Stefan Roese | 479a977 | 2015-12-03 12:39:45 +0100 | [diff] [blame] | 702 | } |
Stefan Roese | 77b299c | 2015-12-14 12:31:48 +0100 | [diff] [blame] | 703 | |
| 704 | void v7_outer_cache_disable(void) |
| 705 | { |
| 706 | struct pl310_regs *const pl310 = |
| 707 | (struct pl310_regs *)CONFIG_SYS_PL310_BASE; |
| 708 | |
| 709 | clrbits_le32(&pl310->pl310_ctrl, L2X0_CTRL_EN); |
| 710 | } |