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