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