Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
J. German Rivera | 8ff14b7 | 2014-06-23 15:15:55 -0700 | [diff] [blame] | 2 | /* |
Yogesh Gaur | 1a0c4ae | 2018-05-09 10:52:17 +0530 | [diff] [blame] | 3 | * Copyright 2014 Freescale Semiconductor, Inc. |
Razvan Ionut Cirjan | a3bbc3b | 2020-04-28 16:09:59 +0300 | [diff] [blame] | 4 | * Copyright 2017-2018, 2020 NXP |
J. German Rivera | 8ff14b7 | 2014-06-23 15:15:55 -0700 | [diff] [blame] | 5 | */ |
Stuart Yoder | a2bdb77 | 2015-07-02 11:29:03 +0530 | [diff] [blame] | 6 | #include <common.h> |
Simon Glass | adaaa48 | 2019-11-14 12:57:43 -0700 | [diff] [blame] | 7 | #include <command.h> |
Simon Glass | 6333448 | 2019-11-14 12:57:39 -0700 | [diff] [blame] | 8 | #include <cpu_func.h> |
Simon Glass | 0af6e2d | 2019-08-01 09:46:52 -0600 | [diff] [blame] | 9 | #include <env.h> |
J. German Rivera | 8ff14b7 | 2014-06-23 15:15:55 -0700 | [diff] [blame] | 10 | #include <errno.h> |
Simon Glass | 2dc9c34 | 2020-05-10 11:40:01 -0600 | [diff] [blame] | 11 | #include <image.h> |
Simon Glass | 0f2af88 | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 12 | #include <log.h> |
Simon Glass | 9bc1564 | 2020-02-03 07:36:16 -0700 | [diff] [blame] | 13 | #include <malloc.h> |
Masahiro Yamada | 78eeb91 | 2016-01-24 23:27:48 +0900 | [diff] [blame] | 14 | #include <linux/bug.h> |
J. German Rivera | 8ff14b7 | 2014-06-23 15:15:55 -0700 | [diff] [blame] | 15 | #include <asm/io.h> |
Simon Glass | dbd7954 | 2020-05-10 11:40:11 -0600 | [diff] [blame] | 16 | #include <linux/delay.h> |
Masahiro Yamada | 75f82d0 | 2018-03-05 01:20:11 +0900 | [diff] [blame] | 17 | #include <linux/libfdt.h> |
Bogdan Purcareata | bea8abd | 2017-01-11 15:58:36 +0000 | [diff] [blame] | 18 | #include <net.h> |
Stuart Yoder | a2bdb77 | 2015-07-02 11:29:03 +0530 | [diff] [blame] | 19 | #include <fdt_support.h> |
J. German Rivera | 43e4ae3 | 2015-01-06 13:19:02 -0800 | [diff] [blame] | 20 | #include <fsl-mc/fsl_mc.h> |
| 21 | #include <fsl-mc/fsl_mc_sys.h> |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 22 | #include <fsl-mc/fsl_mc_private.h> |
J. German Rivera | 43e4ae3 | 2015-01-06 13:19:02 -0800 | [diff] [blame] | 23 | #include <fsl-mc/fsl_dpmng.h> |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 24 | #include <fsl-mc/fsl_dprc.h> |
| 25 | #include <fsl-mc/fsl_dpio.h> |
Prabhakar Kushwaha | 29a63e4 | 2015-11-04 12:25:58 +0530 | [diff] [blame] | 26 | #include <fsl-mc/fsl_dpni.h> |
Florinel Iordache | ae6d852 | 2019-11-19 10:28:17 +0000 | [diff] [blame] | 27 | #include <fsl-mc/fsl_dpsparser.h> |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 28 | #include <fsl-mc/fsl_qbman_portal.h> |
Prabhakar Kushwaha | 29a63e4 | 2015-11-04 12:25:58 +0530 | [diff] [blame] | 29 | #include <fsl-mc/ldpaa_wriop.h> |
J. German Rivera | 8ff14b7 | 2014-06-23 15:15:55 -0700 | [diff] [blame] | 30 | |
J. German Rivera | f4fed4b | 2015-03-20 19:28:18 -0700 | [diff] [blame] | 31 | #define MC_RAM_BASE_ADDR_ALIGNMENT (512UL * 1024 * 1024) |
| 32 | #define MC_RAM_BASE_ADDR_ALIGNMENT_MASK (~(MC_RAM_BASE_ADDR_ALIGNMENT - 1)) |
| 33 | #define MC_RAM_SIZE_ALIGNMENT (256UL * 1024 * 1024) |
| 34 | |
| 35 | #define MC_MEM_SIZE_ENV_VAR "mcmemsize" |
| 36 | #define MC_BOOT_TIMEOUT_ENV_VAR "mcboottimeout" |
Bogdan Purcareata | 08bc014 | 2017-05-24 16:40:21 +0000 | [diff] [blame] | 37 | #define MC_BOOT_ENV_VAR "mcinitcmd" |
Meenakshi Aggarwal | 67f195c | 2019-02-27 14:41:02 +0530 | [diff] [blame] | 38 | #define MC_DRAM_BLOCK_DEFAULT_SIZE (512UL * 1024 * 1024) |
J. German Rivera | f4fed4b | 2015-03-20 19:28:18 -0700 | [diff] [blame] | 39 | |
J. German Rivera | 8ff14b7 | 2014-06-23 15:15:55 -0700 | [diff] [blame] | 40 | DECLARE_GLOBAL_DATA_PTR; |
Prabhakar Kushwaha | 145e4cd | 2018-08-27 12:58:52 +0530 | [diff] [blame] | 41 | static int mc_memset_resv_ram; |
Florinel Iordache | ae6d852 | 2019-11-19 10:28:17 +0000 | [diff] [blame] | 42 | static struct mc_version mc_ver_info; |
Prabhakar Kushwaha | 29a63e4 | 2015-11-04 12:25:58 +0530 | [diff] [blame] | 43 | static int mc_boot_status = -1; |
| 44 | static int mc_dpl_applied = -1; |
| 45 | #ifdef CONFIG_SYS_LS_MC_DRAM_AIOP_IMG_OFFSET |
| 46 | static int mc_aiop_applied = -1; |
| 47 | #endif |
Prabhakar Kushwaha | 316b71c | 2015-11-04 12:25:59 +0530 | [diff] [blame] | 48 | struct fsl_mc_io *root_mc_io = NULL; |
| 49 | struct fsl_mc_io *dflt_mc_io = NULL; /* child container */ |
| 50 | uint16_t root_dprc_handle = 0; |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 51 | uint16_t dflt_dprc_handle = 0; |
Prabhakar Kushwaha | 316b71c | 2015-11-04 12:25:59 +0530 | [diff] [blame] | 52 | int child_dprc_id; |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 53 | struct fsl_dpbp_obj *dflt_dpbp = NULL; |
| 54 | struct fsl_dpio_obj *dflt_dpio = NULL; |
Prabhakar Kushwaha | 316b71c | 2015-11-04 12:25:59 +0530 | [diff] [blame] | 55 | struct fsl_dpni_obj *dflt_dpni = NULL; |
Alexander Graf | 2ebeb44 | 2016-11-17 01:02:57 +0100 | [diff] [blame] | 56 | static u64 mc_lazy_dpl_addr; |
Florinel Iordache | ae6d852 | 2019-11-19 10:28:17 +0000 | [diff] [blame] | 57 | static u32 dpsparser_obj_id; |
| 58 | static u16 dpsparser_handle; |
| 59 | static char *mc_err_msg_apply_spb[] = MC_ERROR_MSG_APPLY_SPB; |
J. German Rivera | f4fed4b | 2015-03-20 19:28:18 -0700 | [diff] [blame] | 60 | |
| 61 | #ifdef DEBUG |
| 62 | void dump_ram_words(const char *title, void *addr) |
| 63 | { |
| 64 | int i; |
| 65 | uint32_t *words = addr; |
| 66 | |
| 67 | printf("Dumping beginning of %s (%p):\n", title, addr); |
| 68 | for (i = 0; i < 16; i++) |
| 69 | printf("%#x ", words[i]); |
| 70 | |
| 71 | printf("\n"); |
| 72 | } |
J. German Rivera | 8ff14b7 | 2014-06-23 15:15:55 -0700 | [diff] [blame] | 73 | |
J. German Rivera | f4fed4b | 2015-03-20 19:28:18 -0700 | [diff] [blame] | 74 | void dump_mc_ccsr_regs(struct mc_ccsr_registers __iomem *mc_ccsr_regs) |
| 75 | { |
| 76 | printf("MC CCSR registers:\n" |
| 77 | "reg_gcr1 %#x\n" |
| 78 | "reg_gsr %#x\n" |
| 79 | "reg_sicbalr %#x\n" |
| 80 | "reg_sicbahr %#x\n" |
| 81 | "reg_sicapr %#x\n" |
| 82 | "reg_mcfbalr %#x\n" |
| 83 | "reg_mcfbahr %#x\n" |
| 84 | "reg_mcfapr %#x\n" |
| 85 | "reg_psr %#x\n", |
| 86 | mc_ccsr_regs->reg_gcr1, |
| 87 | mc_ccsr_regs->reg_gsr, |
| 88 | mc_ccsr_regs->reg_sicbalr, |
| 89 | mc_ccsr_regs->reg_sicbahr, |
| 90 | mc_ccsr_regs->reg_sicapr, |
| 91 | mc_ccsr_regs->reg_mcfbalr, |
| 92 | mc_ccsr_regs->reg_mcfbahr, |
| 93 | mc_ccsr_regs->reg_mcfapr, |
| 94 | mc_ccsr_regs->reg_psr); |
| 95 | } |
| 96 | #else |
| 97 | |
| 98 | #define dump_ram_words(title, addr) |
| 99 | #define dump_mc_ccsr_regs(mc_ccsr_regs) |
| 100 | |
| 101 | #endif /* DEBUG */ |
| 102 | |
J. German Rivera | 8ff14b7 | 2014-06-23 15:15:55 -0700 | [diff] [blame] | 103 | /** |
| 104 | * Copying MC firmware or DPL image to DDR |
| 105 | */ |
| 106 | static int mc_copy_image(const char *title, |
J. German Rivera | 43e4ae3 | 2015-01-06 13:19:02 -0800 | [diff] [blame] | 107 | u64 image_addr, u32 image_size, u64 mc_ram_addr) |
J. German Rivera | 8ff14b7 | 2014-06-23 15:15:55 -0700 | [diff] [blame] | 108 | { |
| 109 | debug("%s copied to address %p\n", title, (void *)mc_ram_addr); |
| 110 | memcpy((void *)mc_ram_addr, (void *)image_addr, image_size); |
J. German Rivera | f4fed4b | 2015-03-20 19:28:18 -0700 | [diff] [blame] | 111 | flush_dcache_range(mc_ram_addr, mc_ram_addr + image_size); |
J. German Rivera | 8ff14b7 | 2014-06-23 15:15:55 -0700 | [diff] [blame] | 112 | return 0; |
| 113 | } |
| 114 | |
Florinel Iordache | ae6d852 | 2019-11-19 10:28:17 +0000 | [diff] [blame] | 115 | #ifndef CONFIG_SYS_LS_MC_FW_IN_DDR |
J. German Rivera | 8ff14b7 | 2014-06-23 15:15:55 -0700 | [diff] [blame] | 116 | /** |
| 117 | * MC firmware FIT image parser checks if the image is in FIT |
| 118 | * format, verifies integrity of the image and calculates |
| 119 | * raw image address and size values. |
J. German Rivera | 43e4ae3 | 2015-01-06 13:19:02 -0800 | [diff] [blame] | 120 | * Returns 0 on success and a negative errno on error. |
J. German Rivera | 8ff14b7 | 2014-06-23 15:15:55 -0700 | [diff] [blame] | 121 | * task fail. |
| 122 | **/ |
Prabhakar Kushwaha | 29a63e4 | 2015-11-04 12:25:58 +0530 | [diff] [blame] | 123 | int parse_mc_firmware_fit_image(u64 mc_fw_addr, |
| 124 | const void **raw_image_addr, |
J. German Rivera | 8ff14b7 | 2014-06-23 15:15:55 -0700 | [diff] [blame] | 125 | size_t *raw_image_size) |
| 126 | { |
| 127 | int format; |
| 128 | void *fit_hdr; |
| 129 | int node_offset; |
| 130 | const void *data; |
| 131 | size_t size; |
| 132 | const char *uname = "firmware"; |
| 133 | |
Prabhakar Kushwaha | 29a63e4 | 2015-11-04 12:25:58 +0530 | [diff] [blame] | 134 | fit_hdr = (void *)mc_fw_addr; |
J. German Rivera | 8ff14b7 | 2014-06-23 15:15:55 -0700 | [diff] [blame] | 135 | |
| 136 | /* Check if Image is in FIT format */ |
| 137 | format = genimg_get_format(fit_hdr); |
| 138 | |
| 139 | if (format != IMAGE_FORMAT_FIT) { |
Prabhakar Kushwaha | 29a63e4 | 2015-11-04 12:25:58 +0530 | [diff] [blame] | 140 | printf("fsl-mc: ERR: Bad firmware image (not a FIT image)\n"); |
J. German Rivera | 43e4ae3 | 2015-01-06 13:19:02 -0800 | [diff] [blame] | 141 | return -EINVAL; |
J. German Rivera | 8ff14b7 | 2014-06-23 15:15:55 -0700 | [diff] [blame] | 142 | } |
| 143 | |
| 144 | if (!fit_check_format(fit_hdr)) { |
Prabhakar Kushwaha | 29a63e4 | 2015-11-04 12:25:58 +0530 | [diff] [blame] | 145 | printf("fsl-mc: ERR: Bad firmware image (bad FIT header)\n"); |
J. German Rivera | 43e4ae3 | 2015-01-06 13:19:02 -0800 | [diff] [blame] | 146 | return -EINVAL; |
J. German Rivera | 8ff14b7 | 2014-06-23 15:15:55 -0700 | [diff] [blame] | 147 | } |
| 148 | |
| 149 | node_offset = fit_image_get_node(fit_hdr, uname); |
| 150 | |
| 151 | if (node_offset < 0) { |
Prabhakar Kushwaha | 29a63e4 | 2015-11-04 12:25:58 +0530 | [diff] [blame] | 152 | printf("fsl-mc: ERR: Bad firmware image (missing subimage)\n"); |
J. German Rivera | 43e4ae3 | 2015-01-06 13:19:02 -0800 | [diff] [blame] | 153 | return -ENOENT; |
J. German Rivera | 8ff14b7 | 2014-06-23 15:15:55 -0700 | [diff] [blame] | 154 | } |
| 155 | |
| 156 | /* Verify MC firmware image */ |
| 157 | if (!(fit_image_verify(fit_hdr, node_offset))) { |
Prabhakar Kushwaha | 29a63e4 | 2015-11-04 12:25:58 +0530 | [diff] [blame] | 158 | printf("fsl-mc: ERR: Bad firmware image (bad CRC)\n"); |
J. German Rivera | 43e4ae3 | 2015-01-06 13:19:02 -0800 | [diff] [blame] | 159 | return -EINVAL; |
J. German Rivera | 8ff14b7 | 2014-06-23 15:15:55 -0700 | [diff] [blame] | 160 | } |
| 161 | |
| 162 | /* Get address and size of raw image */ |
| 163 | fit_image_get_data(fit_hdr, node_offset, &data, &size); |
| 164 | |
| 165 | *raw_image_addr = data; |
| 166 | *raw_image_size = size; |
| 167 | |
| 168 | return 0; |
| 169 | } |
J. German Rivera | f4fed4b | 2015-03-20 19:28:18 -0700 | [diff] [blame] | 170 | #endif |
| 171 | |
Bogdan Purcareata | 7266914 | 2017-05-24 16:40:22 +0000 | [diff] [blame] | 172 | #define MC_DT_INCREASE_SIZE 64 |
| 173 | |
| 174 | enum mc_fixup_type { |
| 175 | MC_FIXUP_DPL, |
| 176 | MC_FIXUP_DPC |
| 177 | }; |
| 178 | |
| 179 | static int mc_fixup_mac_addr(void *blob, int nodeoffset, |
Ioana Ciornei | 25f7cf7 | 2020-03-18 16:47:38 +0200 | [diff] [blame] | 180 | #ifdef CONFIG_DM_ETH |
| 181 | const char *propname, struct udevice *eth_dev, |
| 182 | #else |
Bogdan Purcareata | 7266914 | 2017-05-24 16:40:22 +0000 | [diff] [blame] | 183 | const char *propname, struct eth_device *eth_dev, |
Ioana Ciornei | 25f7cf7 | 2020-03-18 16:47:38 +0200 | [diff] [blame] | 184 | #endif |
Bogdan Purcareata | 7266914 | 2017-05-24 16:40:22 +0000 | [diff] [blame] | 185 | enum mc_fixup_type type) |
Bogdan Purcareata | bea8abd | 2017-01-11 15:58:36 +0000 | [diff] [blame] | 186 | { |
Ioana Ciornei | 25f7cf7 | 2020-03-18 16:47:38 +0200 | [diff] [blame] | 187 | #ifdef CONFIG_DM_ETH |
Simon Glass | fa20e93 | 2020-12-03 16:55:20 -0700 | [diff] [blame] | 188 | struct eth_pdata *plat = dev_get_plat(eth_dev); |
Ioana Ciornei | 25f7cf7 | 2020-03-18 16:47:38 +0200 | [diff] [blame] | 189 | unsigned char *enetaddr = plat->enetaddr; |
Simon Glass | 75e534b | 2020-12-16 21:20:07 -0700 | [diff] [blame] | 190 | int eth_index = dev_seq(eth_dev); |
Ioana Ciornei | 25f7cf7 | 2020-03-18 16:47:38 +0200 | [diff] [blame] | 191 | #else |
| 192 | unsigned char *enetaddr = eth_dev->enetaddr; |
| 193 | int eth_index = eth_dev->index; |
| 194 | #endif |
Bogdan Purcareata | 7266914 | 2017-05-24 16:40:22 +0000 | [diff] [blame] | 195 | int err = 0, len = 0, size, i; |
| 196 | unsigned char env_enetaddr[ARP_HLEN]; |
| 197 | unsigned int enetaddr_32[ARP_HLEN]; |
| 198 | void *val = NULL; |
| 199 | |
| 200 | switch (type) { |
| 201 | case MC_FIXUP_DPL: |
Ioana Ciornei | 25f7cf7 | 2020-03-18 16:47:38 +0200 | [diff] [blame] | 202 | /* DPL likes its addresses on 32 * ARP_HLEN bits */ |
| 203 | for (i = 0; i < ARP_HLEN; i++) |
| 204 | enetaddr_32[i] = cpu_to_fdt32(enetaddr[i]); |
| 205 | val = enetaddr_32; |
| 206 | len = sizeof(enetaddr_32); |
| 207 | break; |
Bogdan Purcareata | 7266914 | 2017-05-24 16:40:22 +0000 | [diff] [blame] | 208 | case MC_FIXUP_DPC: |
Ioana Ciornei | 25f7cf7 | 2020-03-18 16:47:38 +0200 | [diff] [blame] | 209 | val = enetaddr; |
| 210 | len = ARP_HLEN; |
| 211 | break; |
Bogdan Purcareata | 7266914 | 2017-05-24 16:40:22 +0000 | [diff] [blame] | 212 | } |
| 213 | |
| 214 | /* MAC address property present */ |
| 215 | if (fdt_get_property(blob, nodeoffset, propname, NULL)) { |
| 216 | /* u-boot MAC addr randomly assigned - leave the present one */ |
Ioana Ciornei | 25f7cf7 | 2020-03-18 16:47:38 +0200 | [diff] [blame] | 217 | if (!eth_env_get_enetaddr_by_index("eth", eth_index, |
Simon Glass | 399a9ce | 2017-08-03 12:22:14 -0600 | [diff] [blame] | 218 | env_enetaddr)) |
Bogdan Purcareata | 7266914 | 2017-05-24 16:40:22 +0000 | [diff] [blame] | 219 | return err; |
| 220 | } else { |
| 221 | size = MC_DT_INCREASE_SIZE + strlen(propname) + len; |
| 222 | /* make room for mac address property */ |
| 223 | err = fdt_increase_size(blob, size); |
| 224 | if (err) { |
| 225 | printf("fdt_increase_size: err=%s\n", |
| 226 | fdt_strerror(err)); |
| 227 | return err; |
| 228 | } |
| 229 | } |
| 230 | |
| 231 | err = fdt_setprop(blob, nodeoffset, propname, val, len); |
| 232 | if (err) { |
| 233 | printf("fdt_setprop: err=%s\n", fdt_strerror(err)); |
| 234 | return err; |
| 235 | } |
| 236 | |
| 237 | return err; |
| 238 | } |
| 239 | |
| 240 | #define is_dpni(s) (s != NULL ? !strncmp(s, "dpni@", 5) : 0) |
| 241 | |
| 242 | const char *dpl_get_connection_endpoint(void *blob, char *endpoint) |
| 243 | { |
| 244 | int connoffset = fdt_path_offset(blob, "/connections"), off; |
| 245 | const char *s1, *s2; |
| 246 | |
| 247 | for (off = fdt_first_subnode(blob, connoffset); |
| 248 | off >= 0; |
| 249 | off = fdt_next_subnode(blob, off)) { |
| 250 | s1 = fdt_stringlist_get(blob, off, "endpoint1", 0, NULL); |
| 251 | s2 = fdt_stringlist_get(blob, off, "endpoint2", 0, NULL); |
| 252 | |
| 253 | if (!s1 || !s2) |
| 254 | continue; |
| 255 | |
| 256 | if (strcmp(endpoint, s1) == 0) |
| 257 | return s2; |
| 258 | |
| 259 | if (strcmp(endpoint, s2) == 0) |
| 260 | return s1; |
| 261 | } |
| 262 | |
| 263 | return NULL; |
| 264 | } |
| 265 | |
| 266 | static int mc_fixup_dpl_mac_addr(void *blob, int dpmac_id, |
Ioana Ciornei | 25f7cf7 | 2020-03-18 16:47:38 +0200 | [diff] [blame] | 267 | #ifdef CONFIG_DM_ETH |
| 268 | struct udevice *eth_dev) |
| 269 | #else |
Bogdan Purcareata | 7266914 | 2017-05-24 16:40:22 +0000 | [diff] [blame] | 270 | struct eth_device *eth_dev) |
Ioana Ciornei | 25f7cf7 | 2020-03-18 16:47:38 +0200 | [diff] [blame] | 271 | #endif |
Bogdan Purcareata | 7266914 | 2017-05-24 16:40:22 +0000 | [diff] [blame] | 272 | { |
| 273 | int objoff = fdt_path_offset(blob, "/objects"); |
| 274 | int dpmacoff = -1, dpnioff = -1; |
| 275 | const char *endpoint; |
| 276 | char mac_name[10]; |
| 277 | int err; |
| 278 | |
| 279 | sprintf(mac_name, "dpmac@%d", dpmac_id); |
| 280 | dpmacoff = fdt_subnode_offset(blob, objoff, mac_name); |
| 281 | if (dpmacoff < 0) |
| 282 | /* dpmac not defined in DPL, so skip it. */ |
| 283 | return 0; |
| 284 | |
| 285 | err = mc_fixup_mac_addr(blob, dpmacoff, "mac_addr", eth_dev, |
| 286 | MC_FIXUP_DPL); |
| 287 | if (err) { |
| 288 | printf("Error fixing up dpmac mac_addr in DPL\n"); |
| 289 | return err; |
| 290 | } |
| 291 | |
| 292 | /* now we need to figure out if there is any |
| 293 | * DPNI connected to this MAC, so we walk the |
| 294 | * connection list |
| 295 | */ |
| 296 | endpoint = dpl_get_connection_endpoint(blob, mac_name); |
| 297 | if (!is_dpni(endpoint)) |
| 298 | return 0; |
| 299 | |
| 300 | /* let's see if we can fixup the DPNI as well */ |
| 301 | dpnioff = fdt_subnode_offset(blob, objoff, endpoint); |
| 302 | if (dpnioff < 0) |
| 303 | /* DPNI not defined in DPL in the objects area */ |
| 304 | return 0; |
| 305 | |
| 306 | return mc_fixup_mac_addr(blob, dpnioff, "mac_addr", eth_dev, |
| 307 | MC_FIXUP_DPL); |
| 308 | } |
| 309 | |
Meenakshi Aggarwal | d67ae48 | 2019-05-23 15:13:43 +0530 | [diff] [blame] | 310 | void fdt_fixup_mc_ddr(u64 *base, u64 *size) |
| 311 | { |
| 312 | u64 mc_size = mc_get_dram_block_size(); |
| 313 | |
| 314 | if (mc_size < MC_DRAM_BLOCK_DEFAULT_SIZE) { |
| 315 | *base = mc_get_dram_addr() + mc_size; |
| 316 | *size = MC_DRAM_BLOCK_DEFAULT_SIZE - mc_size; |
| 317 | } |
| 318 | } |
| 319 | |
Nipun Gupta | d691264 | 2018-08-20 16:01:14 +0530 | [diff] [blame] | 320 | void fdt_fsl_mc_fixup_iommu_map_entry(void *blob) |
| 321 | { |
| 322 | u32 *prop; |
Laurentiu Tudor | 9e35259 | 2020-05-04 14:47:11 +0300 | [diff] [blame] | 323 | u32 iommu_map[4], phandle; |
Nipun Gupta | d691264 | 2018-08-20 16:01:14 +0530 | [diff] [blame] | 324 | int offset; |
| 325 | int lenp; |
| 326 | |
| 327 | /* find fsl-mc node */ |
| 328 | offset = fdt_path_offset(blob, "/soc/fsl-mc"); |
| 329 | if (offset < 0) |
| 330 | offset = fdt_path_offset(blob, "/fsl-mc"); |
| 331 | if (offset < 0) { |
| 332 | printf("%s: fsl-mc: ERR: fsl-mc node not found in DT, err %d\n", |
| 333 | __func__, offset); |
| 334 | return; |
| 335 | } |
| 336 | |
| 337 | prop = fdt_getprop_w(blob, offset, "iommu-map", &lenp); |
| 338 | if (!prop) { |
| 339 | debug("%s: fsl-mc: ERR: missing iommu-map in fsl-mc bus node\n", |
| 340 | __func__); |
| 341 | return; |
| 342 | } |
| 343 | |
| 344 | iommu_map[0] = cpu_to_fdt32(FSL_DPAA2_STREAM_ID_START); |
| 345 | iommu_map[1] = *++prop; |
| 346 | iommu_map[2] = cpu_to_fdt32(FSL_DPAA2_STREAM_ID_START); |
| 347 | iommu_map[3] = cpu_to_fdt32(FSL_DPAA2_STREAM_ID_END - |
| 348 | FSL_DPAA2_STREAM_ID_START + 1); |
| 349 | |
| 350 | fdt_setprop_inplace(blob, offset, "iommu-map", |
| 351 | iommu_map, sizeof(iommu_map)); |
Laurentiu Tudor | 9e35259 | 2020-05-04 14:47:11 +0300 | [diff] [blame] | 352 | |
| 353 | /* get phandle to MSI controller */ |
| 354 | prop = (u32 *)fdt_getprop(blob, offset, "msi-parent", 0); |
| 355 | if (!prop) { |
| 356 | debug("\n%s: ERROR: missing msi-parent\n", __func__); |
| 357 | return; |
| 358 | } |
| 359 | phandle = fdt32_to_cpu(*prop); |
| 360 | |
| 361 | /* also set msi-map property */ |
| 362 | fdt_appendprop_u32(blob, offset, "msi-map", FSL_DPAA2_STREAM_ID_START); |
| 363 | fdt_appendprop_u32(blob, offset, "msi-map", phandle); |
| 364 | fdt_appendprop_u32(blob, offset, "msi-map", FSL_DPAA2_STREAM_ID_START); |
| 365 | fdt_appendprop_u32(blob, offset, "msi-map", FSL_DPAA2_STREAM_ID_END - |
| 366 | FSL_DPAA2_STREAM_ID_START + 1); |
Nipun Gupta | d691264 | 2018-08-20 16:01:14 +0530 | [diff] [blame] | 367 | } |
| 368 | |
Bogdan Purcareata | 7266914 | 2017-05-24 16:40:22 +0000 | [diff] [blame] | 369 | static int mc_fixup_dpc_mac_addr(void *blob, int dpmac_id, |
Ioana Ciornei | 25f7cf7 | 2020-03-18 16:47:38 +0200 | [diff] [blame] | 370 | #ifdef CONFIG_DM_ETH |
| 371 | struct udevice *eth_dev) |
| 372 | #else |
Bogdan Purcareata | 7266914 | 2017-05-24 16:40:22 +0000 | [diff] [blame] | 373 | struct eth_device *eth_dev) |
Ioana Ciornei | 25f7cf7 | 2020-03-18 16:47:38 +0200 | [diff] [blame] | 374 | #endif |
Bogdan Purcareata | 7266914 | 2017-05-24 16:40:22 +0000 | [diff] [blame] | 375 | { |
| 376 | int nodeoffset = fdt_path_offset(blob, "/board_info/ports"), noff; |
| 377 | int err = 0; |
Bogdan Purcareata | bea8abd | 2017-01-11 15:58:36 +0000 | [diff] [blame] | 378 | char mac_name[10]; |
Bogdan Purcareata | 7266914 | 2017-05-24 16:40:22 +0000 | [diff] [blame] | 379 | const char link_type_mode[] = "MAC_LINK_TYPE_FIXED"; |
Bogdan Purcareata | bea8abd | 2017-01-11 15:58:36 +0000 | [diff] [blame] | 380 | |
| 381 | sprintf(mac_name, "mac@%d", dpmac_id); |
| 382 | |
| 383 | /* node not found - create it */ |
Bogdan Purcareata | 7266914 | 2017-05-24 16:40:22 +0000 | [diff] [blame] | 384 | noff = fdt_subnode_offset(blob, nodeoffset, (const char *)mac_name); |
| 385 | if (noff < 0) { |
Bogdan Purcareata | bea8abd | 2017-01-11 15:58:36 +0000 | [diff] [blame] | 386 | err = fdt_increase_size(blob, 200); |
| 387 | if (err) { |
| 388 | printf("fdt_increase_size: err=%s\n", |
| 389 | fdt_strerror(err)); |
| 390 | return err; |
| 391 | } |
| 392 | |
Bogdan Purcareata | 7266914 | 2017-05-24 16:40:22 +0000 | [diff] [blame] | 393 | noff = fdt_add_subnode(blob, nodeoffset, mac_name); |
| 394 | if (noff < 0) { |
| 395 | printf("fdt_add_subnode: err=%s\n", |
| 396 | fdt_strerror(err)); |
| 397 | return err; |
| 398 | } |
Bogdan Purcareata | bea8abd | 2017-01-11 15:58:36 +0000 | [diff] [blame] | 399 | |
| 400 | /* add default property of fixed link */ |
Bogdan Purcareata | 7266914 | 2017-05-24 16:40:22 +0000 | [diff] [blame] | 401 | err = fdt_appendprop_string(blob, noff, |
Bogdan Purcareata | bea8abd | 2017-01-11 15:58:36 +0000 | [diff] [blame] | 402 | "link_type", link_type_mode); |
| 403 | if (err) { |
| 404 | printf("fdt_appendprop_string: err=%s\n", |
| 405 | fdt_strerror(err)); |
| 406 | return err; |
| 407 | } |
| 408 | } |
| 409 | |
Bogdan Purcareata | 7266914 | 2017-05-24 16:40:22 +0000 | [diff] [blame] | 410 | return mc_fixup_mac_addr(blob, noff, "port_mac_address", eth_dev, |
| 411 | MC_FIXUP_DPC); |
| 412 | } |
Bogdan Purcareata | bea8abd | 2017-01-11 15:58:36 +0000 | [diff] [blame] | 413 | |
Bogdan Purcareata | 7266914 | 2017-05-24 16:40:22 +0000 | [diff] [blame] | 414 | static int mc_fixup_mac_addrs(void *blob, enum mc_fixup_type type) |
| 415 | { |
| 416 | int i, err = 0, ret = 0; |
Ioana Ciornei | 25f7cf7 | 2020-03-18 16:47:38 +0200 | [diff] [blame] | 417 | #ifdef CONFIG_DM_ETH |
| 418 | #define ETH_NAME_LEN 20 |
| 419 | struct udevice *eth_dev; |
| 420 | #else |
Bogdan Purcareata | 7266914 | 2017-05-24 16:40:22 +0000 | [diff] [blame] | 421 | struct eth_device *eth_dev; |
Ioana Ciornei | 25f7cf7 | 2020-03-18 16:47:38 +0200 | [diff] [blame] | 422 | #endif |
| 423 | char ethname[ETH_NAME_LEN]; |
Bogdan Purcareata | bea8abd | 2017-01-11 15:58:36 +0000 | [diff] [blame] | 424 | |
Bogdan Purcareata | 7266914 | 2017-05-24 16:40:22 +0000 | [diff] [blame] | 425 | for (i = WRIOP1_DPMAC1; i < NUM_WRIOP_PORTS; i++) { |
| 426 | /* port not enabled */ |
Pankaj Bansal | 7987ab7 | 2018-10-10 14:08:33 +0530 | [diff] [blame] | 427 | if (wriop_is_enabled_dpmac(i) != 1) |
Bogdan Purcareata | 7266914 | 2017-05-24 16:40:22 +0000 | [diff] [blame] | 428 | continue; |
Bogdan Purcareata | bea8abd | 2017-01-11 15:58:36 +0000 | [diff] [blame] | 429 | |
Pankaj Bansal | 8a92170 | 2018-08-02 16:31:28 +0530 | [diff] [blame] | 430 | snprintf(ethname, ETH_NAME_LEN, "DPMAC%d@%s", i, |
| 431 | phy_interface_strings[wriop_get_enet_if(i)]); |
Bogdan Purcareata | bea8abd | 2017-01-11 15:58:36 +0000 | [diff] [blame] | 432 | |
Bogdan Purcareata | 7266914 | 2017-05-24 16:40:22 +0000 | [diff] [blame] | 433 | eth_dev = eth_get_dev_by_name(ethname); |
| 434 | if (eth_dev == NULL) |
| 435 | continue; |
| 436 | |
| 437 | switch (type) { |
| 438 | case MC_FIXUP_DPL: |
| 439 | err = mc_fixup_dpl_mac_addr(blob, i, eth_dev); |
| 440 | break; |
| 441 | case MC_FIXUP_DPC: |
| 442 | err = mc_fixup_dpc_mac_addr(blob, i, eth_dev); |
| 443 | break; |
| 444 | default: |
| 445 | break; |
| 446 | } |
| 447 | |
| 448 | if (err) |
| 449 | printf("fsl-mc: ERROR fixing mac address for %s\n", |
| 450 | ethname); |
| 451 | ret |= err; |
Bogdan Purcareata | bea8abd | 2017-01-11 15:58:36 +0000 | [diff] [blame] | 452 | } |
| 453 | |
Bogdan Purcareata | 7266914 | 2017-05-24 16:40:22 +0000 | [diff] [blame] | 454 | return ret; |
Bogdan Purcareata | bea8abd | 2017-01-11 15:58:36 +0000 | [diff] [blame] | 455 | } |
| 456 | |
Stuart Yoder | a2bdb77 | 2015-07-02 11:29:03 +0530 | [diff] [blame] | 457 | static int mc_fixup_dpc(u64 dpc_addr) |
| 458 | { |
| 459 | void *blob = (void *)dpc_addr; |
Bogdan Purcareata | bea8abd | 2017-01-11 15:58:36 +0000 | [diff] [blame] | 460 | int nodeoffset, err = 0; |
Stuart Yoder | a2bdb77 | 2015-07-02 11:29:03 +0530 | [diff] [blame] | 461 | |
| 462 | /* delete any existing ICID pools */ |
| 463 | nodeoffset = fdt_path_offset(blob, "/resources/icid_pools"); |
| 464 | if (fdt_del_node(blob, nodeoffset) < 0) |
| 465 | printf("\nfsl-mc: WARNING: could not delete ICID pool\n"); |
| 466 | |
| 467 | /* add a new pool */ |
| 468 | nodeoffset = fdt_path_offset(blob, "/resources"); |
| 469 | if (nodeoffset < 0) { |
| 470 | printf("\nfsl-mc: ERROR: DPC is missing /resources\n"); |
| 471 | return -EINVAL; |
| 472 | } |
| 473 | nodeoffset = fdt_add_subnode(blob, nodeoffset, "icid_pools"); |
| 474 | nodeoffset = fdt_add_subnode(blob, nodeoffset, "icid_pool@0"); |
| 475 | do_fixup_by_path_u32(blob, "/resources/icid_pools/icid_pool@0", |
| 476 | "base_icid", FSL_DPAA2_STREAM_ID_START, 1); |
| 477 | do_fixup_by_path_u32(blob, "/resources/icid_pools/icid_pool@0", |
| 478 | "num", |
| 479 | FSL_DPAA2_STREAM_ID_END - |
| 480 | FSL_DPAA2_STREAM_ID_START + 1, 1); |
| 481 | |
Bogdan Purcareata | bea8abd | 2017-01-11 15:58:36 +0000 | [diff] [blame] | 482 | /* fixup MAC addresses for dpmac ports */ |
| 483 | nodeoffset = fdt_path_offset(blob, "/board_info/ports"); |
Razvan Ionut Cirjan | a3bbc3b | 2020-04-28 16:09:59 +0300 | [diff] [blame] | 484 | if (nodeoffset < 0) { |
| 485 | err = fdt_increase_size(blob, 512); |
| 486 | if (err) { |
| 487 | printf("fdt_increase_size: err=%s\n", |
| 488 | fdt_strerror(err)); |
| 489 | goto out; |
| 490 | } |
| 491 | nodeoffset = fdt_path_offset(blob, "/board_info"); |
| 492 | if (nodeoffset < 0) |
| 493 | nodeoffset = fdt_add_subnode(blob, 0, "board_info"); |
| 494 | |
| 495 | nodeoffset = fdt_add_subnode(blob, nodeoffset, "ports"); |
| 496 | } |
Bogdan Purcareata | bea8abd | 2017-01-11 15:58:36 +0000 | [diff] [blame] | 497 | |
Bogdan Purcareata | 7266914 | 2017-05-24 16:40:22 +0000 | [diff] [blame] | 498 | err = mc_fixup_mac_addrs(blob, MC_FIXUP_DPC); |
Ioana Ciocoi Radulescu | d7697f4 | 2019-02-26 15:50:07 +0000 | [diff] [blame] | 499 | |
| 500 | out: |
Stuart Yoder | a2bdb77 | 2015-07-02 11:29:03 +0530 | [diff] [blame] | 501 | flush_dcache_range(dpc_addr, dpc_addr + fdt_totalsize(blob)); |
| 502 | |
Bogdan Purcareata | bea8abd | 2017-01-11 15:58:36 +0000 | [diff] [blame] | 503 | return err; |
Stuart Yoder | a2bdb77 | 2015-07-02 11:29:03 +0530 | [diff] [blame] | 504 | } |
| 505 | |
Prabhakar Kushwaha | 29a63e4 | 2015-11-04 12:25:58 +0530 | [diff] [blame] | 506 | static int load_mc_dpc(u64 mc_ram_addr, size_t mc_ram_size, u64 mc_dpc_addr) |
J. German Rivera | f4fed4b | 2015-03-20 19:28:18 -0700 | [diff] [blame] | 507 | { |
| 508 | u64 mc_dpc_offset; |
| 509 | #ifndef CONFIG_SYS_LS_MC_DPC_IN_DDR |
| 510 | int error; |
| 511 | void *dpc_fdt_hdr; |
| 512 | int dpc_size; |
| 513 | #endif |
| 514 | |
| 515 | #ifdef CONFIG_SYS_LS_MC_DRAM_DPC_OFFSET |
| 516 | BUILD_BUG_ON((CONFIG_SYS_LS_MC_DRAM_DPC_OFFSET & 0x3) != 0 || |
| 517 | CONFIG_SYS_LS_MC_DRAM_DPC_OFFSET > 0xffffffff); |
| 518 | |
| 519 | mc_dpc_offset = CONFIG_SYS_LS_MC_DRAM_DPC_OFFSET; |
| 520 | #else |
| 521 | #error "CONFIG_SYS_LS_MC_DRAM_DPC_OFFSET not defined" |
| 522 | #endif |
| 523 | |
| 524 | /* |
| 525 | * Load the MC DPC blob in the MC private DRAM block: |
| 526 | */ |
| 527 | #ifdef CONFIG_SYS_LS_MC_DPC_IN_DDR |
| 528 | printf("MC DPC is preloaded to %#llx\n", mc_ram_addr + mc_dpc_offset); |
| 529 | #else |
| 530 | /* |
| 531 | * Get address and size of the DPC blob stored in flash: |
| 532 | */ |
Prabhakar Kushwaha | 29a63e4 | 2015-11-04 12:25:58 +0530 | [diff] [blame] | 533 | dpc_fdt_hdr = (void *)mc_dpc_addr; |
J. German Rivera | f4fed4b | 2015-03-20 19:28:18 -0700 | [diff] [blame] | 534 | |
| 535 | error = fdt_check_header(dpc_fdt_hdr); |
| 536 | if (error != 0) { |
| 537 | /* |
| 538 | * Don't return with error here, since the MC firmware can |
| 539 | * still boot without a DPC |
| 540 | */ |
J. German Rivera | 75d7ace | 2015-07-02 11:28:56 +0530 | [diff] [blame] | 541 | printf("\nfsl-mc: WARNING: No DPC image found"); |
J. German Rivera | f4fed4b | 2015-03-20 19:28:18 -0700 | [diff] [blame] | 542 | return 0; |
| 543 | } |
| 544 | |
| 545 | dpc_size = fdt_totalsize(dpc_fdt_hdr); |
| 546 | if (dpc_size > CONFIG_SYS_LS_MC_DPC_MAX_LENGTH) { |
J. German Rivera | 75d7ace | 2015-07-02 11:28:56 +0530 | [diff] [blame] | 547 | printf("\nfsl-mc: ERROR: Bad DPC image (too large: %d)\n", |
J. German Rivera | f4fed4b | 2015-03-20 19:28:18 -0700 | [diff] [blame] | 548 | dpc_size); |
| 549 | return -EINVAL; |
| 550 | } |
| 551 | |
| 552 | mc_copy_image("MC DPC blob", |
| 553 | (u64)dpc_fdt_hdr, dpc_size, mc_ram_addr + mc_dpc_offset); |
| 554 | #endif /* not defined CONFIG_SYS_LS_MC_DPC_IN_DDR */ |
| 555 | |
Stuart Yoder | a2bdb77 | 2015-07-02 11:29:03 +0530 | [diff] [blame] | 556 | if (mc_fixup_dpc(mc_ram_addr + mc_dpc_offset)) |
| 557 | return -EINVAL; |
| 558 | |
J. German Rivera | f4fed4b | 2015-03-20 19:28:18 -0700 | [diff] [blame] | 559 | dump_ram_words("DPC", (void *)(mc_ram_addr + mc_dpc_offset)); |
| 560 | return 0; |
| 561 | } |
| 562 | |
Bogdan Purcareata | 7266914 | 2017-05-24 16:40:22 +0000 | [diff] [blame] | 563 | |
| 564 | static int mc_fixup_dpl(u64 dpl_addr) |
| 565 | { |
| 566 | void *blob = (void *)dpl_addr; |
| 567 | u32 ver = fdt_getprop_u32_default(blob, "/", "dpl-version", 0); |
| 568 | int err = 0; |
| 569 | |
| 570 | /* The DPL fixup for mac addresses is only relevant |
| 571 | * for old-style DPLs |
| 572 | */ |
| 573 | if (ver >= 10) |
| 574 | return 0; |
| 575 | |
| 576 | err = mc_fixup_mac_addrs(blob, MC_FIXUP_DPL); |
| 577 | flush_dcache_range(dpl_addr, dpl_addr + fdt_totalsize(blob)); |
| 578 | |
| 579 | return err; |
| 580 | } |
| 581 | |
Prabhakar Kushwaha | 29a63e4 | 2015-11-04 12:25:58 +0530 | [diff] [blame] | 582 | static int load_mc_dpl(u64 mc_ram_addr, size_t mc_ram_size, u64 mc_dpl_addr) |
J. German Rivera | f4fed4b | 2015-03-20 19:28:18 -0700 | [diff] [blame] | 583 | { |
| 584 | u64 mc_dpl_offset; |
| 585 | #ifndef CONFIG_SYS_LS_MC_DPL_IN_DDR |
| 586 | int error; |
| 587 | void *dpl_fdt_hdr; |
| 588 | int dpl_size; |
| 589 | #endif |
| 590 | |
| 591 | #ifdef CONFIG_SYS_LS_MC_DRAM_DPL_OFFSET |
| 592 | BUILD_BUG_ON((CONFIG_SYS_LS_MC_DRAM_DPL_OFFSET & 0x3) != 0 || |
| 593 | CONFIG_SYS_LS_MC_DRAM_DPL_OFFSET > 0xffffffff); |
| 594 | |
| 595 | mc_dpl_offset = CONFIG_SYS_LS_MC_DRAM_DPL_OFFSET; |
| 596 | #else |
| 597 | #error "CONFIG_SYS_LS_MC_DRAM_DPL_OFFSET not defined" |
| 598 | #endif |
| 599 | |
| 600 | /* |
| 601 | * Load the MC DPL blob in the MC private DRAM block: |
| 602 | */ |
| 603 | #ifdef CONFIG_SYS_LS_MC_DPL_IN_DDR |
| 604 | printf("MC DPL is preloaded to %#llx\n", mc_ram_addr + mc_dpl_offset); |
| 605 | #else |
| 606 | /* |
| 607 | * Get address and size of the DPL blob stored in flash: |
| 608 | */ |
Prabhakar Kushwaha | 29a63e4 | 2015-11-04 12:25:58 +0530 | [diff] [blame] | 609 | dpl_fdt_hdr = (void *)mc_dpl_addr; |
J. German Rivera | f4fed4b | 2015-03-20 19:28:18 -0700 | [diff] [blame] | 610 | |
| 611 | error = fdt_check_header(dpl_fdt_hdr); |
| 612 | if (error != 0) { |
J. German Rivera | 75d7ace | 2015-07-02 11:28:56 +0530 | [diff] [blame] | 613 | printf("\nfsl-mc: ERROR: Bad DPL image (bad header)\n"); |
J. German Rivera | f4fed4b | 2015-03-20 19:28:18 -0700 | [diff] [blame] | 614 | return error; |
| 615 | } |
| 616 | |
| 617 | dpl_size = fdt_totalsize(dpl_fdt_hdr); |
| 618 | if (dpl_size > CONFIG_SYS_LS_MC_DPL_MAX_LENGTH) { |
J. German Rivera | 75d7ace | 2015-07-02 11:28:56 +0530 | [diff] [blame] | 619 | printf("\nfsl-mc: ERROR: Bad DPL image (too large: %d)\n", |
J. German Rivera | f4fed4b | 2015-03-20 19:28:18 -0700 | [diff] [blame] | 620 | dpl_size); |
| 621 | return -EINVAL; |
| 622 | } |
| 623 | |
| 624 | mc_copy_image("MC DPL blob", |
| 625 | (u64)dpl_fdt_hdr, dpl_size, mc_ram_addr + mc_dpl_offset); |
| 626 | #endif /* not defined CONFIG_SYS_LS_MC_DPL_IN_DDR */ |
| 627 | |
Bogdan Purcareata | 7266914 | 2017-05-24 16:40:22 +0000 | [diff] [blame] | 628 | if (mc_fixup_dpl(mc_ram_addr + mc_dpl_offset)) |
| 629 | return -EINVAL; |
J. German Rivera | f4fed4b | 2015-03-20 19:28:18 -0700 | [diff] [blame] | 630 | dump_ram_words("DPL", (void *)(mc_ram_addr + mc_dpl_offset)); |
| 631 | return 0; |
| 632 | } |
| 633 | |
| 634 | /** |
| 635 | * Return the MC boot timeout value in milliseconds |
| 636 | */ |
| 637 | static unsigned long get_mc_boot_timeout_ms(void) |
| 638 | { |
| 639 | unsigned long timeout_ms = CONFIG_SYS_LS_MC_BOOT_TIMEOUT_MS; |
| 640 | |
Simon Glass | 64b723f | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 641 | char *timeout_ms_env_var = env_get(MC_BOOT_TIMEOUT_ENV_VAR); |
J. German Rivera | f4fed4b | 2015-03-20 19:28:18 -0700 | [diff] [blame] | 642 | |
| 643 | if (timeout_ms_env_var) { |
| 644 | timeout_ms = simple_strtoul(timeout_ms_env_var, NULL, 10); |
| 645 | if (timeout_ms == 0) { |
| 646 | printf("fsl-mc: WARNING: Invalid value for \'" |
| 647 | MC_BOOT_TIMEOUT_ENV_VAR |
| 648 | "\' environment variable: %lu\n", |
| 649 | timeout_ms); |
| 650 | |
| 651 | timeout_ms = CONFIG_SYS_LS_MC_BOOT_TIMEOUT_MS; |
| 652 | } |
| 653 | } |
| 654 | |
| 655 | return timeout_ms; |
| 656 | } |
| 657 | |
Prabhakar Kushwaha | 29a63e4 | 2015-11-04 12:25:58 +0530 | [diff] [blame] | 658 | #ifdef CONFIG_SYS_LS_MC_DRAM_AIOP_IMG_OFFSET |
York Sun | cbe8e1c | 2016-04-04 11:41:26 -0700 | [diff] [blame] | 659 | |
| 660 | __weak bool soc_has_aiop(void) |
| 661 | { |
| 662 | return false; |
| 663 | } |
| 664 | |
Prabhakar Kushwaha | 29a63e4 | 2015-11-04 12:25:58 +0530 | [diff] [blame] | 665 | static int load_mc_aiop_img(u64 aiop_fw_addr) |
J. German Rivera | c3b505f | 2015-07-02 11:28:58 +0530 | [diff] [blame] | 666 | { |
Prabhakar Kushwaha | 29a63e4 | 2015-11-04 12:25:58 +0530 | [diff] [blame] | 667 | u64 mc_ram_addr = mc_get_dram_addr(); |
| 668 | #ifndef CONFIG_SYS_LS_MC_DPC_IN_DDR |
J. German Rivera | c3b505f | 2015-07-02 11:28:58 +0530 | [diff] [blame] | 669 | void *aiop_img; |
Prabhakar Kushwaha | 29a63e4 | 2015-11-04 12:25:58 +0530 | [diff] [blame] | 670 | #endif |
J. German Rivera | c3b505f | 2015-07-02 11:28:58 +0530 | [diff] [blame] | 671 | |
York Sun | cbe8e1c | 2016-04-04 11:41:26 -0700 | [diff] [blame] | 672 | /* Check if AIOP is available */ |
| 673 | if (!soc_has_aiop()) |
| 674 | return -ENODEV; |
J. German Rivera | c3b505f | 2015-07-02 11:28:58 +0530 | [diff] [blame] | 675 | /* |
| 676 | * Load the MC AIOP image in the MC private DRAM block: |
| 677 | */ |
| 678 | |
Prabhakar Kushwaha | 29a63e4 | 2015-11-04 12:25:58 +0530 | [diff] [blame] | 679 | #ifdef CONFIG_SYS_LS_MC_DPC_IN_DDR |
| 680 | printf("MC AIOP is preloaded to %#llx\n", mc_ram_addr + |
| 681 | CONFIG_SYS_LS_MC_DRAM_AIOP_IMG_OFFSET); |
| 682 | #else |
| 683 | aiop_img = (void *)aiop_fw_addr; |
J. German Rivera | c3b505f | 2015-07-02 11:28:58 +0530 | [diff] [blame] | 684 | mc_copy_image("MC AIOP image", |
| 685 | (u64)aiop_img, CONFIG_SYS_LS_MC_AIOP_IMG_MAX_LENGTH, |
| 686 | mc_ram_addr + CONFIG_SYS_LS_MC_DRAM_AIOP_IMG_OFFSET); |
Prabhakar Kushwaha | 29a63e4 | 2015-11-04 12:25:58 +0530 | [diff] [blame] | 687 | #endif |
| 688 | mc_aiop_applied = 0; |
J. German Rivera | c3b505f | 2015-07-02 11:28:58 +0530 | [diff] [blame] | 689 | |
| 690 | return 0; |
| 691 | } |
| 692 | #endif |
Prabhakar Kushwaha | 29a63e4 | 2015-11-04 12:25:58 +0530 | [diff] [blame] | 693 | |
J. German Rivera | f4fed4b | 2015-03-20 19:28:18 -0700 | [diff] [blame] | 694 | static int wait_for_mc(bool booting_mc, u32 *final_reg_gsr) |
| 695 | { |
| 696 | u32 reg_gsr; |
| 697 | u32 mc_fw_boot_status; |
| 698 | unsigned long timeout_ms = get_mc_boot_timeout_ms(); |
| 699 | struct mc_ccsr_registers __iomem *mc_ccsr_regs = MC_CCSR_BASE_ADDR; |
| 700 | |
| 701 | dmb(); |
J. German Rivera | f4fed4b | 2015-03-20 19:28:18 -0700 | [diff] [blame] | 702 | assert(timeout_ms > 0); |
| 703 | for (;;) { |
| 704 | udelay(1000); /* throttle polling */ |
| 705 | reg_gsr = in_le32(&mc_ccsr_regs->reg_gsr); |
| 706 | mc_fw_boot_status = (reg_gsr & GSR_FS_MASK); |
| 707 | if (mc_fw_boot_status & 0x1) |
| 708 | break; |
| 709 | |
| 710 | timeout_ms--; |
| 711 | if (timeout_ms == 0) |
| 712 | break; |
| 713 | } |
| 714 | |
| 715 | if (timeout_ms == 0) { |
J. German Rivera | 75d7ace | 2015-07-02 11:28:56 +0530 | [diff] [blame] | 716 | printf("ERROR: timeout\n"); |
J. German Rivera | f4fed4b | 2015-03-20 19:28:18 -0700 | [diff] [blame] | 717 | |
| 718 | /* TODO: Get an error status from an MC CCSR register */ |
| 719 | return -ETIMEDOUT; |
| 720 | } |
| 721 | |
| 722 | if (mc_fw_boot_status != 0x1) { |
| 723 | /* |
| 724 | * TODO: Identify critical errors from the GSR register's FS |
| 725 | * field and for those errors, set error to -ENODEV or other |
| 726 | * appropriate errno, so that the status property is set to |
| 727 | * failure in the fsl,dprc device tree node. |
| 728 | */ |
J. German Rivera | 75d7ace | 2015-07-02 11:28:56 +0530 | [diff] [blame] | 729 | printf("WARNING: Firmware returned an error (GSR: %#x)\n", |
| 730 | reg_gsr); |
| 731 | } else { |
| 732 | printf("SUCCESS\n"); |
J. German Rivera | f4fed4b | 2015-03-20 19:28:18 -0700 | [diff] [blame] | 733 | } |
| 734 | |
J. German Rivera | 75d7ace | 2015-07-02 11:28:56 +0530 | [diff] [blame] | 735 | |
J. German Rivera | f4fed4b | 2015-03-20 19:28:18 -0700 | [diff] [blame] | 736 | *final_reg_gsr = reg_gsr; |
| 737 | return 0; |
| 738 | } |
J. German Rivera | 8ff14b7 | 2014-06-23 15:15:55 -0700 | [diff] [blame] | 739 | |
Prabhakar Kushwaha | 29a63e4 | 2015-11-04 12:25:58 +0530 | [diff] [blame] | 740 | int mc_init(u64 mc_fw_addr, u64 mc_dpc_addr) |
J. German Rivera | 8ff14b7 | 2014-06-23 15:15:55 -0700 | [diff] [blame] | 741 | { |
| 742 | int error = 0; |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 743 | int portal_id = 0; |
J. German Rivera | 8ff14b7 | 2014-06-23 15:15:55 -0700 | [diff] [blame] | 744 | struct mc_ccsr_registers __iomem *mc_ccsr_regs = MC_CCSR_BASE_ADDR; |
Prabhakar Kushwaha | 29a63e4 | 2015-11-04 12:25:58 +0530 | [diff] [blame] | 745 | u64 mc_ram_addr = mc_get_dram_addr(); |
J. German Rivera | 8ff14b7 | 2014-06-23 15:15:55 -0700 | [diff] [blame] | 746 | u32 reg_gsr; |
J. German Rivera | f4fed4b | 2015-03-20 19:28:18 -0700 | [diff] [blame] | 747 | u32 reg_mcfbalr; |
| 748 | #ifndef CONFIG_SYS_LS_MC_FW_IN_DDR |
J. German Rivera | 8ff14b7 | 2014-06-23 15:15:55 -0700 | [diff] [blame] | 749 | const void *raw_image_addr; |
| 750 | size_t raw_image_size = 0; |
J. German Rivera | f4fed4b | 2015-03-20 19:28:18 -0700 | [diff] [blame] | 751 | #endif |
J. German Rivera | f4fed4b | 2015-03-20 19:28:18 -0700 | [diff] [blame] | 752 | u8 mc_ram_num_256mb_blocks; |
| 753 | size_t mc_ram_size = mc_get_dram_block_size(); |
J. German Rivera | 8ff14b7 | 2014-06-23 15:15:55 -0700 | [diff] [blame] | 754 | |
York Sun | c55d731 | 2017-03-06 09:02:29 -0800 | [diff] [blame] | 755 | mc_ram_num_256mb_blocks = mc_ram_size / MC_RAM_SIZE_ALIGNMENT; |
Meenakshi Aggarwal | 67f195c | 2019-02-27 14:41:02 +0530 | [diff] [blame] | 756 | |
| 757 | if (mc_ram_num_256mb_blocks >= 0xff) { |
York Sun | c55d731 | 2017-03-06 09:02:29 -0800 | [diff] [blame] | 758 | error = -EINVAL; |
| 759 | printf("fsl-mc: ERROR: invalid MC private RAM size (%lu)\n", |
| 760 | mc_ram_size); |
J. German Rivera | f4fed4b | 2015-03-20 19:28:18 -0700 | [diff] [blame] | 761 | goto out; |
York Sun | c55d731 | 2017-03-06 09:02:29 -0800 | [diff] [blame] | 762 | } |
J. German Rivera | f4fed4b | 2015-03-20 19:28:18 -0700 | [diff] [blame] | 763 | |
J. German Rivera | 8ff14b7 | 2014-06-23 15:15:55 -0700 | [diff] [blame] | 764 | /* |
Meenakshi Aggarwal | 67f195c | 2019-02-27 14:41:02 +0530 | [diff] [blame] | 765 | * To support 128 MB DDR Size for MC |
| 766 | */ |
| 767 | if (mc_ram_num_256mb_blocks == 0) |
| 768 | mc_ram_num_256mb_blocks = 0xFF; |
| 769 | |
| 770 | /* |
J. German Rivera | 8ff14b7 | 2014-06-23 15:15:55 -0700 | [diff] [blame] | 771 | * Management Complex cores should be held at reset out of POR. |
Bin Meng | 7557405 | 2016-02-05 19:30:11 -0800 | [diff] [blame] | 772 | * U-Boot should be the first software to touch MC. To be safe, |
J. German Rivera | 8ff14b7 | 2014-06-23 15:15:55 -0700 | [diff] [blame] | 773 | * we reset all cores again by setting GCR1 to 0. It doesn't do |
| 774 | * anything if they are held at reset. After we setup the firmware |
| 775 | * we kick off MC by deasserting the reset bit for core 0, and |
| 776 | * deasserting the reset bits for Command Portal Managers. |
| 777 | * The stop bits are not touched here. They are used to stop the |
| 778 | * cores when they are active. Setting stop bits doesn't stop the |
| 779 | * cores from fetching instructions when they are released from |
| 780 | * reset. |
| 781 | */ |
| 782 | out_le32(&mc_ccsr_regs->reg_gcr1, 0); |
| 783 | dmb(); |
| 784 | |
J. German Rivera | f4fed4b | 2015-03-20 19:28:18 -0700 | [diff] [blame] | 785 | #ifdef CONFIG_SYS_LS_MC_FW_IN_DDR |
| 786 | printf("MC firmware is preloaded to %#llx\n", mc_ram_addr); |
| 787 | #else |
Prabhakar Kushwaha | 29a63e4 | 2015-11-04 12:25:58 +0530 | [diff] [blame] | 788 | error = parse_mc_firmware_fit_image(mc_fw_addr, &raw_image_addr, |
| 789 | &raw_image_size); |
J. German Rivera | 8ff14b7 | 2014-06-23 15:15:55 -0700 | [diff] [blame] | 790 | if (error != 0) |
| 791 | goto out; |
| 792 | /* |
| 793 | * Load the MC FW at the beginning of the MC private DRAM block: |
| 794 | */ |
J. German Rivera | 43e4ae3 | 2015-01-06 13:19:02 -0800 | [diff] [blame] | 795 | mc_copy_image("MC Firmware", |
| 796 | (u64)raw_image_addr, raw_image_size, mc_ram_addr); |
J. German Rivera | 43e4ae3 | 2015-01-06 13:19:02 -0800 | [diff] [blame] | 797 | #endif |
J. German Rivera | f4fed4b | 2015-03-20 19:28:18 -0700 | [diff] [blame] | 798 | dump_ram_words("firmware", (void *)mc_ram_addr); |
J. German Rivera | 43e4ae3 | 2015-01-06 13:19:02 -0800 | [diff] [blame] | 799 | |
Prabhakar Kushwaha | 29a63e4 | 2015-11-04 12:25:58 +0530 | [diff] [blame] | 800 | error = load_mc_dpc(mc_ram_addr, mc_ram_size, mc_dpc_addr); |
J. German Rivera | f4fed4b | 2015-03-20 19:28:18 -0700 | [diff] [blame] | 801 | if (error != 0) |
J. German Rivera | 8ff14b7 | 2014-06-23 15:15:55 -0700 | [diff] [blame] | 802 | goto out; |
J. German Rivera | c3b505f | 2015-07-02 11:28:58 +0530 | [diff] [blame] | 803 | |
J. German Rivera | 8ff14b7 | 2014-06-23 15:15:55 -0700 | [diff] [blame] | 804 | debug("mc_ccsr_regs %p\n", mc_ccsr_regs); |
J. German Rivera | f4fed4b | 2015-03-20 19:28:18 -0700 | [diff] [blame] | 805 | dump_mc_ccsr_regs(mc_ccsr_regs); |
J. German Rivera | 8ff14b7 | 2014-06-23 15:15:55 -0700 | [diff] [blame] | 806 | |
| 807 | /* |
J. German Rivera | f4fed4b | 2015-03-20 19:28:18 -0700 | [diff] [blame] | 808 | * Tell MC what is the address range of the DRAM block assigned to it: |
J. German Rivera | 8ff14b7 | 2014-06-23 15:15:55 -0700 | [diff] [blame] | 809 | */ |
Meenakshi Aggarwal | 67f195c | 2019-02-27 14:41:02 +0530 | [diff] [blame] | 810 | if (mc_ram_num_256mb_blocks < 0xFF) { |
| 811 | reg_mcfbalr = (u32)mc_ram_addr | |
| 812 | (mc_ram_num_256mb_blocks - 1); |
| 813 | } else { |
| 814 | reg_mcfbalr = (u32)mc_ram_addr | |
| 815 | (mc_ram_num_256mb_blocks); |
| 816 | } |
| 817 | |
J. German Rivera | f4fed4b | 2015-03-20 19:28:18 -0700 | [diff] [blame] | 818 | out_le32(&mc_ccsr_regs->reg_mcfbalr, reg_mcfbalr); |
| 819 | out_le32(&mc_ccsr_regs->reg_mcfbahr, |
York Sun | c55d731 | 2017-03-06 09:02:29 -0800 | [diff] [blame] | 820 | (u32)(mc_ram_addr >> 32)); |
Stuart Yoder | d197035 | 2015-07-02 11:29:02 +0530 | [diff] [blame] | 821 | out_le32(&mc_ccsr_regs->reg_mcfapr, FSL_BYPASS_AMQ); |
J. German Rivera | 8ff14b7 | 2014-06-23 15:15:55 -0700 | [diff] [blame] | 822 | |
| 823 | /* |
J. German Rivera | f4fed4b | 2015-03-20 19:28:18 -0700 | [diff] [blame] | 824 | * Tell the MC that we want delayed DPL deployment. |
J. German Rivera | 8ff14b7 | 2014-06-23 15:15:55 -0700 | [diff] [blame] | 825 | */ |
J. German Rivera | f4fed4b | 2015-03-20 19:28:18 -0700 | [diff] [blame] | 826 | out_le32(&mc_ccsr_regs->reg_gsr, 0xDD00); |
J. German Rivera | 8ff14b7 | 2014-06-23 15:15:55 -0700 | [diff] [blame] | 827 | |
J. German Rivera | 75d7ace | 2015-07-02 11:28:56 +0530 | [diff] [blame] | 828 | printf("\nfsl-mc: Booting Management Complex ... "); |
J. German Rivera | 43e4ae3 | 2015-01-06 13:19:02 -0800 | [diff] [blame] | 829 | |
J. German Rivera | 8ff14b7 | 2014-06-23 15:15:55 -0700 | [diff] [blame] | 830 | /* |
| 831 | * Deassert reset and release MC core 0 to run |
| 832 | */ |
| 833 | out_le32(&mc_ccsr_regs->reg_gcr1, GCR1_P1_DE_RST | GCR1_M_ALL_DE_RST); |
J. German Rivera | f4fed4b | 2015-03-20 19:28:18 -0700 | [diff] [blame] | 834 | error = wait_for_mc(true, ®_gsr); |
| 835 | if (error != 0) |
J. German Rivera | 8ff14b7 | 2014-06-23 15:15:55 -0700 | [diff] [blame] | 836 | goto out; |
J. German Rivera | 8ff14b7 | 2014-06-23 15:15:55 -0700 | [diff] [blame] | 837 | |
J. German Rivera | 43e4ae3 | 2015-01-06 13:19:02 -0800 | [diff] [blame] | 838 | /* |
| 839 | * TODO: need to obtain the portal_id for the root container from the |
| 840 | * DPL |
| 841 | */ |
| 842 | portal_id = 0; |
| 843 | |
| 844 | /* |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 845 | * Initialize the global default MC portal |
| 846 | * And check that the MC firmware is responding portal commands: |
J. German Rivera | 43e4ae3 | 2015-01-06 13:19:02 -0800 | [diff] [blame] | 847 | */ |
Prabhakar Kushwaha | 790c1a4 | 2017-10-11 08:51:18 +0530 | [diff] [blame] | 848 | root_mc_io = (struct fsl_mc_io *)calloc(sizeof(struct fsl_mc_io), 1); |
Prabhakar Kushwaha | 316b71c | 2015-11-04 12:25:59 +0530 | [diff] [blame] | 849 | if (!root_mc_io) { |
Prabhakar Kushwaha | 790c1a4 | 2017-10-11 08:51:18 +0530 | [diff] [blame] | 850 | printf(" No memory: calloc() failed\n"); |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 851 | return -ENOMEM; |
| 852 | } |
| 853 | |
Prabhakar Kushwaha | 316b71c | 2015-11-04 12:25:59 +0530 | [diff] [blame] | 854 | root_mc_io->mmio_regs = SOC_MC_PORTAL_ADDR(portal_id); |
J. German Rivera | 43e4ae3 | 2015-01-06 13:19:02 -0800 | [diff] [blame] | 855 | debug("Checking access to MC portal of root DPRC container (portal_id %d, portal physical addr %p)\n", |
Prabhakar Kushwaha | 316b71c | 2015-11-04 12:25:59 +0530 | [diff] [blame] | 856 | portal_id, root_mc_io->mmio_regs); |
J. German Rivera | 43e4ae3 | 2015-01-06 13:19:02 -0800 | [diff] [blame] | 857 | |
Prabhakar Kushwaha | 316b71c | 2015-11-04 12:25:59 +0530 | [diff] [blame] | 858 | error = mc_get_version(root_mc_io, MC_CMD_NO_FLAGS, &mc_ver_info); |
J. German Rivera | 43e4ae3 | 2015-01-06 13:19:02 -0800 | [diff] [blame] | 859 | if (error != 0) { |
| 860 | printf("fsl-mc: ERROR: Firmware version check failed (error: %d)\n", |
| 861 | error); |
| 862 | goto out; |
| 863 | } |
| 864 | |
J. German Rivera | 43e4ae3 | 2015-01-06 13:19:02 -0800 | [diff] [blame] | 865 | printf("fsl-mc: Management Complex booted (version: %d.%d.%d, boot status: %#x)\n", |
| 866 | mc_ver_info.major, mc_ver_info.minor, mc_ver_info.revision, |
J. German Rivera | f4fed4b | 2015-03-20 19:28:18 -0700 | [diff] [blame] | 867 | reg_gsr & GSR_FS_MASK); |
| 868 | |
Prabhakar Kushwaha | 29a63e4 | 2015-11-04 12:25:58 +0530 | [diff] [blame] | 869 | out: |
| 870 | if (error != 0) |
| 871 | mc_boot_status = error; |
| 872 | else |
| 873 | mc_boot_status = 0; |
| 874 | |
| 875 | return error; |
| 876 | } |
| 877 | |
| 878 | int mc_apply_dpl(u64 mc_dpl_addr) |
| 879 | { |
| 880 | struct mc_ccsr_registers __iomem *mc_ccsr_regs = MC_CCSR_BASE_ADDR; |
| 881 | int error = 0; |
| 882 | u32 reg_gsr; |
| 883 | u64 mc_ram_addr = mc_get_dram_addr(); |
| 884 | size_t mc_ram_size = mc_get_dram_block_size(); |
| 885 | |
Alexander Graf | 2ebeb44 | 2016-11-17 01:02:57 +0100 | [diff] [blame] | 886 | if (!mc_dpl_addr) |
| 887 | return -1; |
| 888 | |
Prabhakar Kushwaha | 29a63e4 | 2015-11-04 12:25:58 +0530 | [diff] [blame] | 889 | error = load_mc_dpl(mc_ram_addr, mc_ram_size, mc_dpl_addr); |
| 890 | if (error != 0) |
| 891 | return error; |
| 892 | |
J. German Rivera | f4fed4b | 2015-03-20 19:28:18 -0700 | [diff] [blame] | 893 | /* |
| 894 | * Tell the MC to deploy the DPL: |
| 895 | */ |
| 896 | out_le32(&mc_ccsr_regs->reg_gsr, 0x0); |
J. German Rivera | 75d7ace | 2015-07-02 11:28:56 +0530 | [diff] [blame] | 897 | printf("fsl-mc: Deploying data path layout ... "); |
J. German Rivera | f4fed4b | 2015-03-20 19:28:18 -0700 | [diff] [blame] | 898 | error = wait_for_mc(false, ®_gsr); |
J. German Rivera | 75d7ace | 2015-07-02 11:28:56 +0530 | [diff] [blame] | 899 | |
Prabhakar Kushwaha | 29a63e4 | 2015-11-04 12:25:58 +0530 | [diff] [blame] | 900 | if (!error) |
| 901 | mc_dpl_applied = 0; |
J. German Rivera | 8ff14b7 | 2014-06-23 15:15:55 -0700 | [diff] [blame] | 902 | |
| 903 | return error; |
| 904 | } |
| 905 | |
| 906 | int get_mc_boot_status(void) |
| 907 | { |
| 908 | return mc_boot_status; |
| 909 | } |
| 910 | |
Prabhakar Kushwaha | 29a63e4 | 2015-11-04 12:25:58 +0530 | [diff] [blame] | 911 | #ifdef CONFIG_SYS_LS_MC_DRAM_AIOP_IMG_OFFSET |
| 912 | int get_aiop_apply_status(void) |
| 913 | { |
| 914 | return mc_aiop_applied; |
| 915 | } |
| 916 | #endif |
| 917 | |
| 918 | int get_dpl_apply_status(void) |
| 919 | { |
| 920 | return mc_dpl_applied; |
| 921 | } |
| 922 | |
Mian Yousaf Kaukab | 9712465 | 2018-12-18 14:01:17 +0100 | [diff] [blame] | 923 | int is_lazy_dpl_addr_valid(void) |
| 924 | { |
| 925 | return !!mc_lazy_dpl_addr; |
| 926 | } |
| 927 | |
Priyanka Jain | e0e0be5 | 2017-08-24 16:42:43 +0530 | [diff] [blame] | 928 | /* |
Prabhakar Kushwaha | 29a63e4 | 2015-11-04 12:25:58 +0530 | [diff] [blame] | 929 | * Return the MC address of private DRAM block. |
Priyanka Jain | e0e0be5 | 2017-08-24 16:42:43 +0530 | [diff] [blame] | 930 | * As per MC design document, MC initial base address |
| 931 | * should be least significant 512MB address of MC private |
| 932 | * memory, i.e. address should point to end address masked |
| 933 | * with 512MB offset in private DRAM block. |
Prabhakar Kushwaha | 29a63e4 | 2015-11-04 12:25:58 +0530 | [diff] [blame] | 934 | */ |
| 935 | u64 mc_get_dram_addr(void) |
| 936 | { |
Priyanka Jain | e0e0be5 | 2017-08-24 16:42:43 +0530 | [diff] [blame] | 937 | size_t mc_ram_size = mc_get_dram_block_size(); |
| 938 | |
Prabhakar Kushwaha | 145e4cd | 2018-08-27 12:58:52 +0530 | [diff] [blame] | 939 | if (!mc_memset_resv_ram || (get_mc_boot_status() < 0)) { |
| 940 | mc_memset_resv_ram = 1; |
| 941 | memset((void *)gd->arch.resv_ram, 0, mc_ram_size); |
| 942 | } |
| 943 | |
Priyanka Jain | e0e0be5 | 2017-08-24 16:42:43 +0530 | [diff] [blame] | 944 | return (gd->arch.resv_ram + mc_ram_size - 1) & |
| 945 | MC_RAM_BASE_ADDR_ALIGNMENT_MASK; |
Prabhakar Kushwaha | 29a63e4 | 2015-11-04 12:25:58 +0530 | [diff] [blame] | 946 | } |
| 947 | |
| 948 | /** |
J. German Rivera | 8ff14b7 | 2014-06-23 15:15:55 -0700 | [diff] [blame] | 949 | * Return the actual size of the MC private DRAM block. |
J. German Rivera | 8ff14b7 | 2014-06-23 15:15:55 -0700 | [diff] [blame] | 950 | */ |
| 951 | unsigned long mc_get_dram_block_size(void) |
| 952 | { |
J. German Rivera | f4fed4b | 2015-03-20 19:28:18 -0700 | [diff] [blame] | 953 | unsigned long dram_block_size = CONFIG_SYS_LS_MC_DRAM_BLOCK_MIN_SIZE; |
| 954 | |
Simon Glass | 64b723f | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 955 | char *dram_block_size_env_var = env_get(MC_MEM_SIZE_ENV_VAR); |
J. German Rivera | f4fed4b | 2015-03-20 19:28:18 -0700 | [diff] [blame] | 956 | |
| 957 | if (dram_block_size_env_var) { |
| 958 | dram_block_size = simple_strtoul(dram_block_size_env_var, NULL, |
Prabhakar Kushwaha | b166d6a | 2017-11-09 14:45:41 +0530 | [diff] [blame] | 959 | 16); |
J. German Rivera | f4fed4b | 2015-03-20 19:28:18 -0700 | [diff] [blame] | 960 | |
| 961 | if (dram_block_size < CONFIG_SYS_LS_MC_DRAM_BLOCK_MIN_SIZE) { |
| 962 | printf("fsl-mc: WARNING: Invalid value for \'" |
| 963 | MC_MEM_SIZE_ENV_VAR |
| 964 | "\' environment variable: %lu\n", |
| 965 | dram_block_size); |
| 966 | |
Meenakshi Aggarwal | 67f195c | 2019-02-27 14:41:02 +0530 | [diff] [blame] | 967 | dram_block_size = MC_DRAM_BLOCK_DEFAULT_SIZE; |
J. German Rivera | f4fed4b | 2015-03-20 19:28:18 -0700 | [diff] [blame] | 968 | } |
| 969 | } |
| 970 | |
| 971 | return dram_block_size; |
J. German Rivera | 8ff14b7 | 2014-06-23 15:15:55 -0700 | [diff] [blame] | 972 | } |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 973 | |
Masahiro Yamada | f7ed78b | 2020-06-26 15:13:33 +0900 | [diff] [blame] | 974 | int fsl_mc_ldpaa_init(struct bd_info *bis) |
Prabhakar Kushwaha | 316b71c | 2015-11-04 12:25:59 +0530 | [diff] [blame] | 975 | { |
Prabhakar Kushwaha | 52d2e2c | 2015-11-04 12:26:00 +0530 | [diff] [blame] | 976 | int i; |
| 977 | |
| 978 | for (i = WRIOP1_DPMAC1; i < NUM_WRIOP_PORTS; i++) |
Pankaj Bansal | 7987ab7 | 2018-10-10 14:08:33 +0530 | [diff] [blame] | 979 | if (wriop_is_enabled_dpmac(i) == 1) |
Prabhakar Kushwaha | 52d2e2c | 2015-11-04 12:26:00 +0530 | [diff] [blame] | 980 | ldpaa_eth_init(i, wriop_get_enet_if(i)); |
Prabhakar Kushwaha | 316b71c | 2015-11-04 12:25:59 +0530 | [diff] [blame] | 981 | return 0; |
| 982 | } |
| 983 | |
Prabhakar Kushwaha | 0a4156c | 2015-12-24 15:32:37 +0530 | [diff] [blame] | 984 | static int dprc_version_check(struct fsl_mc_io *mc_io, uint16_t handle) |
| 985 | { |
Prabhakar Kushwaha | 0a4156c | 2015-12-24 15:32:37 +0530 | [diff] [blame] | 986 | int error; |
Yogesh Gaur | 318c32f | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 987 | uint16_t major_ver, minor_ver; |
Prabhakar Kushwaha | 0a4156c | 2015-12-24 15:32:37 +0530 | [diff] [blame] | 988 | |
Yogesh Gaur | 318c32f | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 989 | error = dprc_get_api_version(mc_io, 0, |
| 990 | &major_ver, |
| 991 | &minor_ver); |
| 992 | if (error < 0) { |
| 993 | printf("dprc_get_api_version() failed: %d\n", error); |
| 994 | return error; |
Prabhakar Kushwaha | 0a4156c | 2015-12-24 15:32:37 +0530 | [diff] [blame] | 995 | } |
Yogesh Gaur | 318c32f | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 996 | |
| 997 | if (major_ver < DPRC_VER_MAJOR || (major_ver == DPRC_VER_MAJOR && |
| 998 | minor_ver < DPRC_VER_MINOR)) { |
| 999 | printf("DPRC version mismatch found %u.%u,", |
| 1000 | major_ver, minor_ver); |
| 1001 | printf("supported version is %u.%u\n", |
| 1002 | DPRC_VER_MAJOR, DPRC_VER_MINOR); |
| 1003 | } |
| 1004 | |
Prabhakar Kushwaha | 0a4156c | 2015-12-24 15:32:37 +0530 | [diff] [blame] | 1005 | return error; |
| 1006 | } |
| 1007 | |
Prabhakar Kushwaha | 316b71c | 2015-11-04 12:25:59 +0530 | [diff] [blame] | 1008 | static int dpio_init(void) |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 1009 | { |
| 1010 | struct qbman_swp_desc p_des; |
| 1011 | struct dpio_attr attr; |
Prabhakar Kushwaha | 316b71c | 2015-11-04 12:25:59 +0530 | [diff] [blame] | 1012 | struct dpio_cfg dpio_cfg; |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 1013 | int err = 0; |
Yogesh Gaur | 318c32f | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 1014 | uint16_t major_ver, minor_ver; |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 1015 | |
Prabhakar Kushwaha | 790c1a4 | 2017-10-11 08:51:18 +0530 | [diff] [blame] | 1016 | dflt_dpio = (struct fsl_dpio_obj *)calloc( |
| 1017 | sizeof(struct fsl_dpio_obj), 1); |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 1018 | if (!dflt_dpio) { |
Prabhakar Kushwaha | 790c1a4 | 2017-10-11 08:51:18 +0530 | [diff] [blame] | 1019 | printf("No memory: calloc() failed\n"); |
Prabhakar Kushwaha | 316b71c | 2015-11-04 12:25:59 +0530 | [diff] [blame] | 1020 | err = -ENOMEM; |
Prabhakar Kushwaha | 790c1a4 | 2017-10-11 08:51:18 +0530 | [diff] [blame] | 1021 | goto err_calloc; |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 1022 | } |
Prabhakar Kushwaha | 316b71c | 2015-11-04 12:25:59 +0530 | [diff] [blame] | 1023 | dpio_cfg.channel_mode = DPIO_LOCAL_CHANNEL; |
| 1024 | dpio_cfg.num_priorities = 8; |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 1025 | |
Yogesh Gaur | 318c32f | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 1026 | err = dpio_create(dflt_mc_io, |
| 1027 | dflt_dprc_handle, |
| 1028 | MC_CMD_NO_FLAGS, |
| 1029 | &dpio_cfg, |
| 1030 | &dflt_dpio->dpio_id); |
Prabhakar Kushwaha | 316b71c | 2015-11-04 12:25:59 +0530 | [diff] [blame] | 1031 | if (err < 0) { |
| 1032 | printf("dpio_create() failed: %d\n", err); |
| 1033 | err = -ENODEV; |
| 1034 | goto err_create; |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 1035 | } |
| 1036 | |
Yogesh Gaur | 318c32f | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 1037 | err = dpio_get_api_version(dflt_mc_io, 0, |
| 1038 | &major_ver, |
| 1039 | &minor_ver); |
| 1040 | if (err < 0) { |
| 1041 | printf("dpio_get_api_version() failed: %d\n", err); |
| 1042 | goto err_get_api_ver; |
| 1043 | } |
| 1044 | |
| 1045 | if (major_ver < DPIO_VER_MAJOR || (major_ver == DPIO_VER_MAJOR && |
| 1046 | minor_ver < DPIO_VER_MINOR)) { |
| 1047 | printf("DPRC version mismatch found %u.%u,", |
| 1048 | major_ver, |
| 1049 | minor_ver); |
| 1050 | } |
| 1051 | |
| 1052 | err = dpio_open(dflt_mc_io, |
| 1053 | MC_CMD_NO_FLAGS, |
| 1054 | dflt_dpio->dpio_id, |
| 1055 | &dflt_dpio->dpio_handle); |
| 1056 | if (err) { |
| 1057 | printf("dpio_open() failed\n"); |
| 1058 | goto err_open; |
| 1059 | } |
| 1060 | |
Prabhakar Kushwaha | 316b71c | 2015-11-04 12:25:59 +0530 | [diff] [blame] | 1061 | memset(&attr, 0, sizeof(struct dpio_attr)); |
Prabhakar Kushwaha | 9564df6 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 1062 | err = dpio_get_attributes(dflt_mc_io, MC_CMD_NO_FLAGS, |
Prabhakar Kushwaha | 316b71c | 2015-11-04 12:25:59 +0530 | [diff] [blame] | 1063 | dflt_dpio->dpio_handle, &attr); |
| 1064 | if (err < 0) { |
| 1065 | printf("dpio_get_attributes() failed: %d\n", err); |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 1066 | goto err_get_attr; |
| 1067 | } |
| 1068 | |
Yogesh Gaur | 318c32f | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 1069 | if (dflt_dpio->dpio_id != attr.id) { |
| 1070 | printf("dnpi object id and attribute id are not same\n"); |
| 1071 | goto err_attr_not_same; |
Prabhakar Kushwaha | 0a4156c | 2015-12-24 15:32:37 +0530 | [diff] [blame] | 1072 | } |
| 1073 | |
Prabhakar Kushwaha | 316b71c | 2015-11-04 12:25:59 +0530 | [diff] [blame] | 1074 | #ifdef DEBUG |
| 1075 | printf("Init: DPIO id=0x%d\n", dflt_dpio->dpio_id); |
| 1076 | #endif |
Prabhakar Kushwaha | 316b71c | 2015-11-04 12:25:59 +0530 | [diff] [blame] | 1077 | err = dpio_enable(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpio->dpio_handle); |
| 1078 | if (err < 0) { |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 1079 | printf("dpio_enable() failed %d\n", err); |
| 1080 | goto err_get_enable; |
| 1081 | } |
Prabhakar Kushwaha | fd5d127 | 2015-07-02 11:28:59 +0530 | [diff] [blame] | 1082 | debug("ce_offset=0x%llx, ci_offset=0x%llx, portalid=%d, prios=%d\n", |
| 1083 | attr.qbman_portal_ce_offset, |
| 1084 | attr.qbman_portal_ci_offset, |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 1085 | attr.qbman_portal_id, |
| 1086 | attr.num_priorities); |
| 1087 | |
Prabhakar Kushwaha | fd5d127 | 2015-07-02 11:28:59 +0530 | [diff] [blame] | 1088 | p_des.cena_bar = (void *)(SOC_QBMAN_PORTALS_BASE_ADDR |
| 1089 | + attr.qbman_portal_ce_offset); |
| 1090 | p_des.cinh_bar = (void *)(SOC_QBMAN_PORTALS_BASE_ADDR |
| 1091 | + attr.qbman_portal_ci_offset); |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 1092 | |
| 1093 | dflt_dpio->sw_portal = qbman_swp_init(&p_des); |
| 1094 | if (dflt_dpio->sw_portal == NULL) { |
| 1095 | printf("qbman_swp_init() failed\n"); |
| 1096 | goto err_get_swp_init; |
| 1097 | } |
| 1098 | return 0; |
| 1099 | |
| 1100 | err_get_swp_init: |
Prabhakar Kushwaha | 316b71c | 2015-11-04 12:25:59 +0530 | [diff] [blame] | 1101 | dpio_disable(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpio->dpio_handle); |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 1102 | err_get_enable: |
Prabhakar Kushwaha | 316b71c | 2015-11-04 12:25:59 +0530 | [diff] [blame] | 1103 | err_get_attr: |
Yogesh Gaur | 318c32f | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 1104 | err_attr_not_same: |
Prabhakar Kushwaha | 316b71c | 2015-11-04 12:25:59 +0530 | [diff] [blame] | 1105 | dpio_close(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpio->dpio_handle); |
Yogesh Gaur | 318c32f | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 1106 | err_open: |
| 1107 | err_get_api_ver: |
| 1108 | dpio_destroy(dflt_mc_io, |
| 1109 | dflt_dprc_handle, |
| 1110 | MC_CMD_NO_FLAGS, |
| 1111 | dflt_dpio->dpio_id); |
Prabhakar Kushwaha | 316b71c | 2015-11-04 12:25:59 +0530 | [diff] [blame] | 1112 | err_create: |
Prabhakar Kushwaha | c6018bd | 2016-03-18 16:15:29 +0530 | [diff] [blame] | 1113 | free(dflt_dpio); |
Prabhakar Kushwaha | 790c1a4 | 2017-10-11 08:51:18 +0530 | [diff] [blame] | 1114 | err_calloc: |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 1115 | return err; |
| 1116 | } |
| 1117 | |
Prabhakar Kushwaha | 316b71c | 2015-11-04 12:25:59 +0530 | [diff] [blame] | 1118 | static int dpio_exit(void) |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 1119 | { |
Prabhakar Kushwaha | 316b71c | 2015-11-04 12:25:59 +0530 | [diff] [blame] | 1120 | int err; |
| 1121 | |
| 1122 | err = dpio_disable(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpio->dpio_handle); |
| 1123 | if (err < 0) { |
| 1124 | printf("dpio_disable() failed: %d\n", err); |
| 1125 | goto err; |
| 1126 | } |
| 1127 | |
Yogesh Gaur | 318c32f | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 1128 | dpio_close(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpio->dpio_handle); |
| 1129 | if (err < 0) { |
| 1130 | printf("dpio_close() failed: %d\n", err); |
| 1131 | goto err; |
| 1132 | } |
| 1133 | |
| 1134 | err = dpio_destroy(dflt_mc_io, |
| 1135 | dflt_dprc_handle, |
| 1136 | MC_CMD_NO_FLAGS, |
| 1137 | dflt_dpio->dpio_id); |
Prabhakar Kushwaha | 316b71c | 2015-11-04 12:25:59 +0530 | [diff] [blame] | 1138 | if (err < 0) { |
| 1139 | printf("dpio_destroy() failed: %d\n", err); |
| 1140 | goto err; |
| 1141 | } |
| 1142 | |
| 1143 | #ifdef DEBUG |
| 1144 | printf("Exit: DPIO id=0x%d\n", dflt_dpio->dpio_id); |
| 1145 | #endif |
| 1146 | |
| 1147 | if (dflt_dpio) |
| 1148 | free(dflt_dpio); |
| 1149 | |
| 1150 | return 0; |
| 1151 | err: |
| 1152 | return err; |
| 1153 | } |
| 1154 | |
| 1155 | static int dprc_init(void) |
| 1156 | { |
| 1157 | int err, child_portal_id, container_id; |
| 1158 | struct dprc_cfg cfg; |
| 1159 | uint64_t mc_portal_offset; |
| 1160 | |
| 1161 | /* Open root container */ |
| 1162 | err = dprc_get_container_id(root_mc_io, MC_CMD_NO_FLAGS, &container_id); |
| 1163 | if (err < 0) { |
| 1164 | printf("dprc_get_container_id(): Root failed: %d\n", err); |
| 1165 | goto err_root_container_id; |
| 1166 | } |
| 1167 | |
| 1168 | #ifdef DEBUG |
| 1169 | printf("Root container id = %d\n", container_id); |
| 1170 | #endif |
| 1171 | err = dprc_open(root_mc_io, MC_CMD_NO_FLAGS, container_id, |
| 1172 | &root_dprc_handle); |
| 1173 | if (err < 0) { |
| 1174 | printf("dprc_open(): Root Container failed: %d\n", err); |
| 1175 | goto err_root_open; |
| 1176 | } |
| 1177 | |
| 1178 | if (!root_dprc_handle) { |
| 1179 | printf("dprc_open(): Root Container Handle is not valid\n"); |
| 1180 | goto err_root_open; |
| 1181 | } |
| 1182 | |
Prabhakar Kushwaha | 0a4156c | 2015-12-24 15:32:37 +0530 | [diff] [blame] | 1183 | err = dprc_version_check(root_mc_io, root_dprc_handle); |
| 1184 | if (err < 0) { |
| 1185 | printf("dprc_version_check() failed: %d\n", err); |
| 1186 | goto err_root_open; |
| 1187 | } |
| 1188 | |
Prabhakar Kushwaha | 901a88e | 2016-01-20 12:04:19 +0530 | [diff] [blame] | 1189 | memset(&cfg, 0, sizeof(struct dprc_cfg)); |
Prabhakar Kushwaha | 316b71c | 2015-11-04 12:25:59 +0530 | [diff] [blame] | 1190 | cfg.options = DPRC_CFG_OPT_TOPOLOGY_CHANGES_ALLOWED | |
| 1191 | DPRC_CFG_OPT_OBJ_CREATE_ALLOWED | |
| 1192 | DPRC_CFG_OPT_ALLOC_ALLOWED; |
| 1193 | cfg.icid = DPRC_GET_ICID_FROM_POOL; |
Prabhakar Kushwaha | 7fd59d9 | 2015-12-24 15:33:49 +0530 | [diff] [blame] | 1194 | cfg.portal_id = DPRC_GET_PORTAL_ID_FROM_POOL; |
Prabhakar Kushwaha | 316b71c | 2015-11-04 12:25:59 +0530 | [diff] [blame] | 1195 | err = dprc_create_container(root_mc_io, MC_CMD_NO_FLAGS, |
| 1196 | root_dprc_handle, |
| 1197 | &cfg, |
| 1198 | &child_dprc_id, |
| 1199 | &mc_portal_offset); |
| 1200 | if (err < 0) { |
| 1201 | printf("dprc_create_container() failed: %d\n", err); |
| 1202 | goto err_create; |
| 1203 | } |
| 1204 | |
Prabhakar Kushwaha | 790c1a4 | 2017-10-11 08:51:18 +0530 | [diff] [blame] | 1205 | dflt_mc_io = (struct fsl_mc_io *)calloc(sizeof(struct fsl_mc_io), 1); |
Prabhakar Kushwaha | 316b71c | 2015-11-04 12:25:59 +0530 | [diff] [blame] | 1206 | if (!dflt_mc_io) { |
| 1207 | err = -ENOMEM; |
Prabhakar Kushwaha | 790c1a4 | 2017-10-11 08:51:18 +0530 | [diff] [blame] | 1208 | printf(" No memory: calloc() failed\n"); |
| 1209 | goto err_calloc; |
Prabhakar Kushwaha | 316b71c | 2015-11-04 12:25:59 +0530 | [diff] [blame] | 1210 | } |
| 1211 | |
| 1212 | child_portal_id = MC_PORTAL_OFFSET_TO_PORTAL_ID(mc_portal_offset); |
| 1213 | dflt_mc_io->mmio_regs = SOC_MC_PORTAL_ADDR(child_portal_id); |
Yogesh Gaur | 318c32f | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 1214 | |
Prabhakar Kushwaha | 316b71c | 2015-11-04 12:25:59 +0530 | [diff] [blame] | 1215 | #ifdef DEBUG |
| 1216 | printf("MC portal of child DPRC container: %d, physical addr %p)\n", |
| 1217 | child_dprc_id, dflt_mc_io->mmio_regs); |
| 1218 | #endif |
| 1219 | |
| 1220 | err = dprc_open(dflt_mc_io, MC_CMD_NO_FLAGS, child_dprc_id, |
| 1221 | &dflt_dprc_handle); |
| 1222 | if (err < 0) { |
| 1223 | printf("dprc_open(): Child container failed: %d\n", err); |
| 1224 | goto err_child_open; |
| 1225 | } |
| 1226 | |
| 1227 | if (!dflt_dprc_handle) { |
| 1228 | printf("dprc_open(): Child container Handle is not valid\n"); |
| 1229 | goto err_child_open; |
| 1230 | } |
| 1231 | |
| 1232 | return 0; |
| 1233 | err_child_open: |
| 1234 | free(dflt_mc_io); |
Prabhakar Kushwaha | 790c1a4 | 2017-10-11 08:51:18 +0530 | [diff] [blame] | 1235 | err_calloc: |
Prabhakar Kushwaha | 316b71c | 2015-11-04 12:25:59 +0530 | [diff] [blame] | 1236 | dprc_destroy_container(root_mc_io, MC_CMD_NO_FLAGS, |
| 1237 | root_dprc_handle, child_dprc_id); |
| 1238 | err_create: |
| 1239 | dprc_close(root_mc_io, MC_CMD_NO_FLAGS, root_dprc_handle); |
| 1240 | err_root_open: |
| 1241 | err_root_container_id: |
| 1242 | return err; |
| 1243 | } |
| 1244 | |
| 1245 | static int dprc_exit(void) |
| 1246 | { |
| 1247 | int err; |
| 1248 | |
| 1249 | err = dprc_close(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dprc_handle); |
| 1250 | if (err < 0) { |
| 1251 | printf("dprc_close(): Child failed: %d\n", err); |
| 1252 | goto err; |
| 1253 | } |
| 1254 | |
| 1255 | err = dprc_destroy_container(root_mc_io, MC_CMD_NO_FLAGS, |
| 1256 | root_dprc_handle, child_dprc_id); |
| 1257 | if (err < 0) { |
| 1258 | printf("dprc_destroy_container() failed: %d\n", err); |
| 1259 | goto err; |
| 1260 | } |
| 1261 | |
| 1262 | err = dprc_close(root_mc_io, MC_CMD_NO_FLAGS, root_dprc_handle); |
| 1263 | if (err < 0) { |
| 1264 | printf("dprc_close(): Root failed: %d\n", err); |
| 1265 | goto err; |
| 1266 | } |
| 1267 | |
| 1268 | if (dflt_mc_io) |
| 1269 | free(dflt_mc_io); |
| 1270 | |
| 1271 | if (root_mc_io) |
| 1272 | free(root_mc_io); |
| 1273 | |
| 1274 | return 0; |
| 1275 | |
| 1276 | err: |
| 1277 | return err; |
| 1278 | } |
| 1279 | |
| 1280 | static int dpbp_init(void) |
| 1281 | { |
| 1282 | int err; |
| 1283 | struct dpbp_attr dpbp_attr; |
| 1284 | struct dpbp_cfg dpbp_cfg; |
Yogesh Gaur | 318c32f | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 1285 | uint16_t major_ver, minor_ver; |
Prabhakar Kushwaha | 316b71c | 2015-11-04 12:25:59 +0530 | [diff] [blame] | 1286 | |
Prabhakar Kushwaha | 790c1a4 | 2017-10-11 08:51:18 +0530 | [diff] [blame] | 1287 | dflt_dpbp = (struct fsl_dpbp_obj *)calloc( |
| 1288 | sizeof(struct fsl_dpbp_obj), 1); |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 1289 | if (!dflt_dpbp) { |
Prabhakar Kushwaha | 790c1a4 | 2017-10-11 08:51:18 +0530 | [diff] [blame] | 1290 | printf("No memory: calloc() failed\n"); |
Prabhakar Kushwaha | 316b71c | 2015-11-04 12:25:59 +0530 | [diff] [blame] | 1291 | err = -ENOMEM; |
Prabhakar Kushwaha | 790c1a4 | 2017-10-11 08:51:18 +0530 | [diff] [blame] | 1292 | goto err_calloc; |
Prabhakar Kushwaha | 316b71c | 2015-11-04 12:25:59 +0530 | [diff] [blame] | 1293 | } |
| 1294 | |
| 1295 | dpbp_cfg.options = 512; |
| 1296 | |
Yogesh Gaur | 318c32f | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 1297 | err = dpbp_create(dflt_mc_io, |
| 1298 | dflt_dprc_handle, |
| 1299 | MC_CMD_NO_FLAGS, |
| 1300 | &dpbp_cfg, |
| 1301 | &dflt_dpbp->dpbp_id); |
Prabhakar Kushwaha | 316b71c | 2015-11-04 12:25:59 +0530 | [diff] [blame] | 1302 | |
| 1303 | if (err < 0) { |
| 1304 | err = -ENODEV; |
| 1305 | printf("dpbp_create() failed: %d\n", err); |
| 1306 | goto err_create; |
| 1307 | } |
| 1308 | |
Yogesh Gaur | 318c32f | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 1309 | err = dpbp_get_api_version(dflt_mc_io, 0, |
| 1310 | &major_ver, |
| 1311 | &minor_ver); |
| 1312 | if (err < 0) { |
| 1313 | printf("dpbp_get_api_version() failed: %d\n", err); |
| 1314 | goto err_get_api_ver; |
| 1315 | } |
| 1316 | |
| 1317 | if (major_ver < DPBP_VER_MAJOR || (major_ver == DPBP_VER_MAJOR && |
| 1318 | minor_ver < DPBP_VER_MINOR)) { |
| 1319 | printf("DPBP version mismatch found %u.%u,", |
| 1320 | major_ver, minor_ver); |
| 1321 | printf("supported version is %u.%u\n", |
| 1322 | DPBP_VER_MAJOR, DPBP_VER_MINOR); |
| 1323 | } |
| 1324 | |
| 1325 | err = dpbp_open(dflt_mc_io, |
| 1326 | MC_CMD_NO_FLAGS, |
| 1327 | dflt_dpbp->dpbp_id, |
| 1328 | &dflt_dpbp->dpbp_handle); |
| 1329 | if (err) { |
| 1330 | printf("dpbp_open() failed\n"); |
| 1331 | goto err_open; |
| 1332 | } |
| 1333 | |
Prabhakar Kushwaha | 316b71c | 2015-11-04 12:25:59 +0530 | [diff] [blame] | 1334 | memset(&dpbp_attr, 0, sizeof(struct dpbp_attr)); |
| 1335 | err = dpbp_get_attributes(dflt_mc_io, MC_CMD_NO_FLAGS, |
| 1336 | dflt_dpbp->dpbp_handle, |
| 1337 | &dpbp_attr); |
| 1338 | if (err < 0) { |
| 1339 | printf("dpbp_get_attributes() failed: %d\n", err); |
| 1340 | goto err_get_attr; |
| 1341 | } |
| 1342 | |
Yogesh Gaur | 318c32f | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 1343 | if (dflt_dpbp->dpbp_id != dpbp_attr.id) { |
| 1344 | printf("dpbp object id and attribute id are not same\n"); |
| 1345 | goto err_attr_not_same; |
Prabhakar Kushwaha | 0a4156c | 2015-12-24 15:32:37 +0530 | [diff] [blame] | 1346 | } |
| 1347 | |
Prabhakar Kushwaha | 316b71c | 2015-11-04 12:25:59 +0530 | [diff] [blame] | 1348 | #ifdef DEBUG |
Yogesh Gaur | 318c32f | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 1349 | printf("Init: DPBP id=0x%x\n", dflt_dpbp->dpbp_attr.id); |
Prabhakar Kushwaha | 316b71c | 2015-11-04 12:25:59 +0530 | [diff] [blame] | 1350 | #endif |
| 1351 | |
| 1352 | err = dpbp_close(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpbp->dpbp_handle); |
| 1353 | if (err < 0) { |
| 1354 | printf("dpbp_close() failed: %d\n", err); |
| 1355 | goto err_close; |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 1356 | } |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 1357 | |
| 1358 | return 0; |
Prabhakar Kushwaha | 316b71c | 2015-11-04 12:25:59 +0530 | [diff] [blame] | 1359 | |
Prabhakar Kushwaha | 316b71c | 2015-11-04 12:25:59 +0530 | [diff] [blame] | 1360 | err_get_attr: |
Yogesh Gaur | 318c32f | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 1361 | err_attr_not_same: |
Prabhakar Kushwaha | 316b71c | 2015-11-04 12:25:59 +0530 | [diff] [blame] | 1362 | dpbp_close(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpbp->dpbp_handle); |
Yogesh Gaur | 318c32f | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 1363 | dpbp_destroy(dflt_mc_io, |
| 1364 | dflt_dprc_handle, |
| 1365 | MC_CMD_NO_FLAGS, |
| 1366 | dflt_dpbp->dpbp_id); |
| 1367 | err_get_api_ver: |
| 1368 | err_close: |
| 1369 | err_open: |
Prabhakar Kushwaha | 316b71c | 2015-11-04 12:25:59 +0530 | [diff] [blame] | 1370 | err_create: |
Yogesh Gaur | 318c32f | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 1371 | free(dflt_dpbp); |
Prabhakar Kushwaha | 790c1a4 | 2017-10-11 08:51:18 +0530 | [diff] [blame] | 1372 | err_calloc: |
Prabhakar Kushwaha | 316b71c | 2015-11-04 12:25:59 +0530 | [diff] [blame] | 1373 | return err; |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 1374 | } |
| 1375 | |
Prabhakar Kushwaha | 316b71c | 2015-11-04 12:25:59 +0530 | [diff] [blame] | 1376 | static int dpbp_exit(void) |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 1377 | { |
Prabhakar Kushwaha | 316b71c | 2015-11-04 12:25:59 +0530 | [diff] [blame] | 1378 | int err; |
| 1379 | |
Yogesh Gaur | 318c32f | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 1380 | err = dpbp_destroy(dflt_mc_io, dflt_dprc_handle, MC_CMD_NO_FLAGS, |
| 1381 | dflt_dpbp->dpbp_id); |
Prabhakar Kushwaha | 316b71c | 2015-11-04 12:25:59 +0530 | [diff] [blame] | 1382 | if (err < 0) { |
| 1383 | printf("dpbp_destroy() failed: %d\n", err); |
| 1384 | goto err; |
| 1385 | } |
| 1386 | |
| 1387 | #ifdef DEBUG |
| 1388 | printf("Exit: DPBP id=0x%d\n", dflt_dpbp->dpbp_attr.id); |
| 1389 | #endif |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 1390 | |
Prabhakar Kushwaha | 316b71c | 2015-11-04 12:25:59 +0530 | [diff] [blame] | 1391 | if (dflt_dpbp) |
| 1392 | free(dflt_dpbp); |
Prabhakar Kushwaha | 29a63e4 | 2015-11-04 12:25:58 +0530 | [diff] [blame] | 1393 | return 0; |
Prabhakar Kushwaha | 316b71c | 2015-11-04 12:25:59 +0530 | [diff] [blame] | 1394 | |
| 1395 | err: |
| 1396 | return err; |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 1397 | } |
| 1398 | |
Prabhakar Kushwaha | 316b71c | 2015-11-04 12:25:59 +0530 | [diff] [blame] | 1399 | static int dpni_init(void) |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 1400 | { |
Prabhakar Kushwaha | 316b71c | 2015-11-04 12:25:59 +0530 | [diff] [blame] | 1401 | int err; |
Yogesh Gaur | 318c32f | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 1402 | uint8_t cfg_buf[256] = {0}; |
Prabhakar Kushwaha | 316b71c | 2015-11-04 12:25:59 +0530 | [diff] [blame] | 1403 | struct dpni_cfg dpni_cfg; |
Yogesh Gaur | 318c32f | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 1404 | uint16_t major_ver, minor_ver; |
Prabhakar Kushwaha | 316b71c | 2015-11-04 12:25:59 +0530 | [diff] [blame] | 1405 | |
Prabhakar Kushwaha | 790c1a4 | 2017-10-11 08:51:18 +0530 | [diff] [blame] | 1406 | dflt_dpni = (struct fsl_dpni_obj *)calloc( |
| 1407 | sizeof(struct fsl_dpni_obj), 1); |
Prabhakar Kushwaha | 316b71c | 2015-11-04 12:25:59 +0530 | [diff] [blame] | 1408 | if (!dflt_dpni) { |
Prabhakar Kushwaha | 790c1a4 | 2017-10-11 08:51:18 +0530 | [diff] [blame] | 1409 | printf("No memory: calloc() failed\n"); |
Prabhakar Kushwaha | 316b71c | 2015-11-04 12:25:59 +0530 | [diff] [blame] | 1410 | err = -ENOMEM; |
Prabhakar Kushwaha | 790c1a4 | 2017-10-11 08:51:18 +0530 | [diff] [blame] | 1411 | goto err_calloc; |
Prabhakar Kushwaha | 316b71c | 2015-11-04 12:25:59 +0530 | [diff] [blame] | 1412 | } |
| 1413 | |
Yogesh Gaur | 318c32f | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 1414 | memset(&dpni_cfg, 0, sizeof(dpni_cfg)); |
| 1415 | err = dpni_prepare_cfg(&dpni_cfg, &cfg_buf[0]); |
Prabhakar Kushwaha | e26e285 | 2015-12-24 15:33:01 +0530 | [diff] [blame] | 1416 | if (err < 0) { |
| 1417 | err = -ENODEV; |
Yogesh Gaur | 318c32f | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 1418 | printf("dpni_prepare_cfg() failed: %d\n", err); |
| 1419 | goto err_prepare_cfg; |
Prabhakar Kushwaha | e26e285 | 2015-12-24 15:33:01 +0530 | [diff] [blame] | 1420 | } |
| 1421 | |
Yogesh Gaur | 318c32f | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 1422 | err = dpni_create(dflt_mc_io, |
| 1423 | dflt_dprc_handle, |
| 1424 | MC_CMD_NO_FLAGS, |
| 1425 | &dpni_cfg, |
| 1426 | &dflt_dpni->dpni_id); |
Prabhakar Kushwaha | 316b71c | 2015-11-04 12:25:59 +0530 | [diff] [blame] | 1427 | if (err < 0) { |
| 1428 | err = -ENODEV; |
Yogesh Gaur | 318c32f | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 1429 | printf("dpni create() failed: %d\n", err); |
Prabhakar Kushwaha | 316b71c | 2015-11-04 12:25:59 +0530 | [diff] [blame] | 1430 | goto err_create; |
| 1431 | } |
| 1432 | |
Yogesh Gaur | 318c32f | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 1433 | err = dpni_get_api_version(dflt_mc_io, 0, |
| 1434 | &major_ver, |
| 1435 | &minor_ver); |
Prabhakar Kushwaha | 316b71c | 2015-11-04 12:25:59 +0530 | [diff] [blame] | 1436 | if (err < 0) { |
Yogesh Gaur | 318c32f | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 1437 | printf("dpni_get_api_version() failed: %d\n", err); |
| 1438 | goto err_get_version; |
Prabhakar Kushwaha | 316b71c | 2015-11-04 12:25:59 +0530 | [diff] [blame] | 1439 | } |
| 1440 | |
Yogesh Gaur | 318c32f | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 1441 | if (major_ver < DPNI_VER_MAJOR || (major_ver == DPNI_VER_MAJOR && |
| 1442 | minor_ver < DPNI_VER_MINOR)) { |
Prabhakar Kushwaha | 0a4156c | 2015-12-24 15:32:37 +0530 | [diff] [blame] | 1443 | printf("DPNI version mismatch found %u.%u,", |
Yogesh Gaur | 318c32f | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 1444 | major_ver, minor_ver); |
Prabhakar Kushwaha | 0a4156c | 2015-12-24 15:32:37 +0530 | [diff] [blame] | 1445 | printf("supported version is %u.%u\n", |
| 1446 | DPNI_VER_MAJOR, DPNI_VER_MINOR); |
| 1447 | } |
| 1448 | |
Yogesh Gaur | 318c32f | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 1449 | err = dpni_open(dflt_mc_io, |
| 1450 | MC_CMD_NO_FLAGS, |
| 1451 | dflt_dpni->dpni_id, |
| 1452 | &dflt_dpni->dpni_handle); |
| 1453 | if (err) { |
| 1454 | printf("dpni_open() failed\n"); |
| 1455 | goto err_open; |
| 1456 | } |
| 1457 | |
Prabhakar Kushwaha | 316b71c | 2015-11-04 12:25:59 +0530 | [diff] [blame] | 1458 | #ifdef DEBUG |
| 1459 | printf("Init: DPNI id=0x%d\n", dflt_dpni->dpni_id); |
| 1460 | #endif |
Prabhakar Kushwaha | 316b71c | 2015-11-04 12:25:59 +0530 | [diff] [blame] | 1461 | err = dpni_close(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpni->dpni_handle); |
| 1462 | if (err < 0) { |
| 1463 | printf("dpni_close() failed: %d\n", err); |
| 1464 | goto err_close; |
| 1465 | } |
| 1466 | |
| 1467 | return 0; |
| 1468 | |
| 1469 | err_close: |
Prabhakar Kushwaha | 316b71c | 2015-11-04 12:25:59 +0530 | [diff] [blame] | 1470 | dpni_close(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpni->dpni_handle); |
Yogesh Gaur | 318c32f | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 1471 | err_open: |
| 1472 | err_get_version: |
| 1473 | dpni_destroy(dflt_mc_io, |
| 1474 | dflt_dprc_handle, |
| 1475 | MC_CMD_NO_FLAGS, |
| 1476 | dflt_dpni->dpni_id); |
Prabhakar Kushwaha | 316b71c | 2015-11-04 12:25:59 +0530 | [diff] [blame] | 1477 | err_create: |
Yogesh Gaur | 318c32f | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 1478 | err_prepare_cfg: |
Prabhakar Kushwaha | e26e285 | 2015-12-24 15:33:01 +0530 | [diff] [blame] | 1479 | free(dflt_dpni); |
Prabhakar Kushwaha | 790c1a4 | 2017-10-11 08:51:18 +0530 | [diff] [blame] | 1480 | err_calloc: |
Prabhakar Kushwaha | 316b71c | 2015-11-04 12:25:59 +0530 | [diff] [blame] | 1481 | return err; |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 1482 | } |
| 1483 | |
Prabhakar Kushwaha | 316b71c | 2015-11-04 12:25:59 +0530 | [diff] [blame] | 1484 | static int dpni_exit(void) |
| 1485 | { |
| 1486 | int err; |
| 1487 | |
Yogesh Gaur | 318c32f | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 1488 | err = dpni_destroy(dflt_mc_io, dflt_dprc_handle, MC_CMD_NO_FLAGS, |
| 1489 | dflt_dpni->dpni_id); |
Prabhakar Kushwaha | 316b71c | 2015-11-04 12:25:59 +0530 | [diff] [blame] | 1490 | if (err < 0) { |
| 1491 | printf("dpni_destroy() failed: %d\n", err); |
| 1492 | goto err; |
| 1493 | } |
| 1494 | |
| 1495 | #ifdef DEBUG |
| 1496 | printf("Exit: DPNI id=0x%d\n", dflt_dpni->dpni_id); |
| 1497 | #endif |
| 1498 | |
| 1499 | if (dflt_dpni) |
| 1500 | free(dflt_dpni); |
| 1501 | return 0; |
| 1502 | |
| 1503 | err: |
| 1504 | return err; |
| 1505 | } |
Florinel Iordache | ae6d852 | 2019-11-19 10:28:17 +0000 | [diff] [blame] | 1506 | |
| 1507 | static bool is_dpsparser_supported(void) |
| 1508 | { |
| 1509 | /* dpsparser support was first introduced in MC version: 10.12.0 */ |
| 1510 | if (mc_ver_info.major < 10) |
| 1511 | return false; |
| 1512 | if (mc_ver_info.major == 10) |
| 1513 | return (mc_ver_info.minor >= 12); |
| 1514 | return true; |
| 1515 | } |
| 1516 | |
| 1517 | static int dpsparser_version_check(struct fsl_mc_io *mc_io) |
| 1518 | { |
| 1519 | int error; |
| 1520 | u16 major_ver, minor_ver; |
| 1521 | |
| 1522 | if (!is_dpsparser_supported()) |
| 1523 | return 0; |
| 1524 | |
| 1525 | error = dpsparser_get_api_version(mc_io, 0, |
| 1526 | &major_ver, |
| 1527 | &minor_ver); |
| 1528 | if (error < 0) { |
| 1529 | printf("dpsparser_get_api_version() failed: %d\n", error); |
| 1530 | return error; |
| 1531 | } |
| 1532 | |
| 1533 | if (major_ver < DPSPARSER_VER_MAJOR || (major_ver == |
| 1534 | DPSPARSER_VER_MAJOR && minor_ver < DPSPARSER_VER_MINOR)) { |
| 1535 | printf("DPSPARSER version mismatch found %u.%u,", |
| 1536 | major_ver, minor_ver); |
| 1537 | printf("supported version is %u.%u\n", |
| 1538 | DPSPARSER_VER_MAJOR, DPSPARSER_VER_MINOR); |
| 1539 | } |
| 1540 | |
| 1541 | return error; |
| 1542 | } |
| 1543 | |
| 1544 | static int dpsparser_init(void) |
| 1545 | { |
| 1546 | int err = 0; |
| 1547 | |
| 1548 | if (!is_dpsparser_supported()) |
| 1549 | return 0; |
| 1550 | |
| 1551 | err = dpsparser_create(dflt_mc_io, |
| 1552 | dflt_dprc_handle, |
| 1553 | MC_CMD_NO_FLAGS, |
| 1554 | &dpsparser_obj_id); |
| 1555 | if (err) |
| 1556 | printf("dpsparser_create() failed\n"); |
| 1557 | |
| 1558 | err = dpsparser_version_check(dflt_mc_io); |
| 1559 | if (err < 0) { |
| 1560 | printf("dpsparser_version_check() failed: %d\n", err); |
| 1561 | goto err_version_check; |
| 1562 | } |
| 1563 | |
| 1564 | err = dpsparser_open(dflt_mc_io, |
| 1565 | MC_CMD_NO_FLAGS, |
| 1566 | &dpsparser_handle); |
| 1567 | if (err < 0) { |
| 1568 | printf("dpsparser_open() failed: %d\n", err); |
| 1569 | goto err_open; |
| 1570 | } |
| 1571 | |
| 1572 | return err; |
| 1573 | |
| 1574 | err_open: |
| 1575 | err_version_check: |
| 1576 | dpsparser_destroy(dflt_mc_io, |
| 1577 | dflt_dprc_handle, |
| 1578 | MC_CMD_NO_FLAGS, dpsparser_obj_id); |
| 1579 | |
| 1580 | return err; |
| 1581 | } |
| 1582 | |
| 1583 | #ifdef DPSPARSER_DESTROY |
| 1584 | /* TODO: refactoring needed in the future to allow DPSPARSER object destroy |
| 1585 | * Workaround: DO NOT destroy DPSPARSER object because it needs to be available |
| 1586 | * on Apply DPL |
| 1587 | */ |
| 1588 | static int dpsparser_exit(void) |
| 1589 | { |
| 1590 | int err; |
| 1591 | |
| 1592 | if (!is_dpsparser_supported()) |
| 1593 | return 0; |
| 1594 | |
| 1595 | dpsparser_close(dflt_mc_io, MC_CMD_NO_FLAGS, dpsparser_handle); |
| 1596 | if (err < 0) { |
| 1597 | printf("dpsparser_close() failed: %d\n", err); |
| 1598 | goto err; |
| 1599 | } |
| 1600 | |
| 1601 | err = dpsparser_destroy(dflt_mc_io, dflt_dprc_handle, |
| 1602 | MC_CMD_NO_FLAGS, dpsparser_obj_id); |
| 1603 | if (err < 0) { |
| 1604 | printf("dpsparser_destroy() failed: %d\n", err); |
| 1605 | goto err; |
| 1606 | } |
| 1607 | return 0; |
| 1608 | |
| 1609 | err: |
| 1610 | return err; |
| 1611 | } |
| 1612 | #endif |
| 1613 | |
| 1614 | int mc_apply_spb(u64 mc_spb_addr) |
| 1615 | { |
| 1616 | int err = 0; |
| 1617 | u16 error, err_arr_size; |
| 1618 | u64 mc_spb_offset; |
| 1619 | u32 spb_size; |
| 1620 | struct sp_blob_header *sp_blob; |
| 1621 | u64 mc_ram_addr = mc_get_dram_addr(); |
| 1622 | |
| 1623 | if (!is_dpsparser_supported()) |
| 1624 | return 0; |
| 1625 | |
| 1626 | if (!mc_spb_addr) { |
| 1627 | printf("fsl-mc: Invalid Blob address\n"); |
| 1628 | return -1; |
| 1629 | } |
| 1630 | |
| 1631 | #ifdef CONFIG_MC_DRAM_SPB_OFFSET |
| 1632 | mc_spb_offset = CONFIG_MC_DRAM_SPB_OFFSET; |
| 1633 | #else |
| 1634 | #error "CONFIG_MC_DRAM_SPB_OFFSET not defined" |
| 1635 | #endif |
| 1636 | |
| 1637 | // Read blob header and get size of SPB blob |
| 1638 | sp_blob = (struct sp_blob_header *)mc_spb_addr; |
| 1639 | spb_size = le32_to_cpu(sp_blob->length); |
| 1640 | if (spb_size > CONFIG_MC_SPB_MAX_SIZE) { |
| 1641 | printf("\nfsl-mc: ERROR: Bad SPB image (too large: %d)\n", |
| 1642 | spb_size); |
| 1643 | return -EINVAL; |
| 1644 | } |
| 1645 | |
| 1646 | mc_copy_image("MC SP Blob", mc_spb_addr, spb_size, |
| 1647 | mc_ram_addr + mc_spb_offset); |
| 1648 | |
| 1649 | //Invoke MC command to apply SPB blob |
| 1650 | printf("fsl-mc: Applying soft parser blob... "); |
| 1651 | err = dpsparser_apply_spb(dflt_mc_io, MC_CMD_NO_FLAGS, dpsparser_handle, |
| 1652 | mc_spb_offset, &error); |
| 1653 | if (err) |
| 1654 | return err; |
| 1655 | |
| 1656 | if (error == 0) { |
| 1657 | printf("SUCCESS\n"); |
| 1658 | } else { |
| 1659 | printf("FAILED with error code = %d:\n", error); |
| 1660 | err_arr_size = (u16)ARRAY_SIZE(mc_err_msg_apply_spb); |
| 1661 | |
| 1662 | if (error > 0 && error < err_arr_size) |
| 1663 | printf(mc_err_msg_apply_spb[error]); |
| 1664 | else |
| 1665 | printf(MC_ERROR_MSG_SPB_UNKNOWN); |
| 1666 | } |
| 1667 | |
| 1668 | return err; |
| 1669 | } |
Prabhakar Kushwaha | 316b71c | 2015-11-04 12:25:59 +0530 | [diff] [blame] | 1670 | |
| 1671 | static int mc_init_object(void) |
| 1672 | { |
| 1673 | int err = 0; |
| 1674 | |
| 1675 | err = dprc_init(); |
| 1676 | if (err < 0) { |
| 1677 | printf("dprc_init() failed: %d\n", err); |
| 1678 | goto err; |
| 1679 | } |
| 1680 | |
| 1681 | err = dpbp_init(); |
| 1682 | if (err < 0) { |
| 1683 | printf("dpbp_init() failed: %d\n", err); |
| 1684 | goto err; |
| 1685 | } |
| 1686 | |
| 1687 | err = dpio_init(); |
| 1688 | if (err < 0) { |
| 1689 | printf("dpio_init() failed: %d\n", err); |
| 1690 | goto err; |
| 1691 | } |
| 1692 | |
| 1693 | err = dpni_init(); |
| 1694 | if (err < 0) { |
| 1695 | printf("dpni_init() failed: %d\n", err); |
| 1696 | goto err; |
| 1697 | } |
| 1698 | |
Florinel Iordache | ae6d852 | 2019-11-19 10:28:17 +0000 | [diff] [blame] | 1699 | err = dpsparser_init(); |
| 1700 | if (err < 0) { |
| 1701 | printf("dpsparser_init() failed: %d\n", err); |
| 1702 | goto err; |
| 1703 | } |
| 1704 | |
Prabhakar Kushwaha | 316b71c | 2015-11-04 12:25:59 +0530 | [diff] [blame] | 1705 | return 0; |
| 1706 | err: |
| 1707 | return err; |
| 1708 | } |
| 1709 | |
Masahiro Yamada | f7ed78b | 2020-06-26 15:13:33 +0900 | [diff] [blame] | 1710 | int fsl_mc_ldpaa_exit(struct bd_info *bd) |
Prabhakar Kushwaha | 316b71c | 2015-11-04 12:25:59 +0530 | [diff] [blame] | 1711 | { |
| 1712 | int err = 0; |
Yogesh Gaur | 4a81bbe | 2017-04-27 10:14:16 +0530 | [diff] [blame] | 1713 | bool is_dpl_apply_status = false; |
Santan Kumar | 0a6e5ba | 2017-06-29 11:19:34 +0530 | [diff] [blame] | 1714 | bool mc_boot_status = false; |
Prabhakar Kushwaha | 316b71c | 2015-11-04 12:25:59 +0530 | [diff] [blame] | 1715 | |
Alexander Graf | 2ebeb44 | 2016-11-17 01:02:57 +0100 | [diff] [blame] | 1716 | if (bd && mc_lazy_dpl_addr && !fsl_mc_ldpaa_exit(NULL)) { |
Yogesh Gaur | 8dadfb4 | 2018-01-16 10:08:24 +0530 | [diff] [blame] | 1717 | err = mc_apply_dpl(mc_lazy_dpl_addr); |
| 1718 | if (!err) |
| 1719 | fdt_fixup_board_enet(working_fdt); |
Alexander Graf | 2ebeb44 | 2016-11-17 01:02:57 +0100 | [diff] [blame] | 1720 | mc_lazy_dpl_addr = 0; |
| 1721 | } |
| 1722 | |
Santan Kumar | 0a6e5ba | 2017-06-29 11:19:34 +0530 | [diff] [blame] | 1723 | if (!get_mc_boot_status()) |
| 1724 | mc_boot_status = true; |
| 1725 | |
Prabhakar Kushwaha | 878d3ec | 2016-03-21 14:19:39 +0530 | [diff] [blame] | 1726 | /* MC is not loaded intentionally, So return success. */ |
Santan Kumar | 0a6e5ba | 2017-06-29 11:19:34 +0530 | [diff] [blame] | 1727 | if (bd && !mc_boot_status) |
Prabhakar Kushwaha | 316b71c | 2015-11-04 12:25:59 +0530 | [diff] [blame] | 1728 | return 0; |
| 1729 | |
Yogesh Gaur | 4a81bbe | 2017-04-27 10:14:16 +0530 | [diff] [blame] | 1730 | /* If DPL is deployed, set is_dpl_apply_status as TRUE. */ |
| 1731 | if (!get_dpl_apply_status()) |
| 1732 | is_dpl_apply_status = true; |
Prabhakar Kushwaha | 316b71c | 2015-11-04 12:25:59 +0530 | [diff] [blame] | 1733 | |
Yogesh Gaur | 4a81bbe | 2017-04-27 10:14:16 +0530 | [diff] [blame] | 1734 | /* |
| 1735 | * For case MC is loaded but DPL is not deployed, return success and |
| 1736 | * print message on console. Else FDT fix-up code execution hanged. |
| 1737 | */ |
Santan Kumar | 0a6e5ba | 2017-06-29 11:19:34 +0530 | [diff] [blame] | 1738 | if (bd && mc_boot_status && !is_dpl_apply_status) { |
Yogesh Gaur | 4a81bbe | 2017-04-27 10:14:16 +0530 | [diff] [blame] | 1739 | printf("fsl-mc: DPL not deployed, DPAA2 ethernet not work\n"); |
Yogesh Gaur | 82709e5 | 2017-11-28 10:11:14 +0530 | [diff] [blame] | 1740 | goto mc_obj_cleanup; |
Yogesh Gaur | 4a81bbe | 2017-04-27 10:14:16 +0530 | [diff] [blame] | 1741 | } |
Prabhakar Kushwaha | 316b71c | 2015-11-04 12:25:59 +0530 | [diff] [blame] | 1742 | |
Santan Kumar | 0a6e5ba | 2017-06-29 11:19:34 +0530 | [diff] [blame] | 1743 | if (bd && mc_boot_status && is_dpl_apply_status) |
| 1744 | return 0; |
| 1745 | |
Yogesh Gaur | 82709e5 | 2017-11-28 10:11:14 +0530 | [diff] [blame] | 1746 | mc_obj_cleanup: |
Prabhakar Kushwaha | 316b71c | 2015-11-04 12:25:59 +0530 | [diff] [blame] | 1747 | err = dpbp_exit(); |
| 1748 | if (err < 0) { |
Prabhakar Kushwaha | 88ba4d6 | 2016-01-20 12:04:37 +0530 | [diff] [blame] | 1749 | printf("dpbp_exit() failed: %d\n", err); |
Prabhakar Kushwaha | 316b71c | 2015-11-04 12:25:59 +0530 | [diff] [blame] | 1750 | goto err; |
| 1751 | } |
| 1752 | |
| 1753 | err = dpio_exit(); |
| 1754 | if (err < 0) { |
| 1755 | printf("dpio_exit() failed: %d\n", err); |
| 1756 | goto err; |
| 1757 | } |
| 1758 | |
| 1759 | err = dpni_exit(); |
| 1760 | if (err < 0) { |
| 1761 | printf("dpni_exit() failed: %d\n", err); |
| 1762 | goto err; |
| 1763 | } |
| 1764 | |
| 1765 | err = dprc_exit(); |
| 1766 | if (err < 0) { |
| 1767 | printf("dprc_exit() failed: %d\n", err); |
| 1768 | goto err; |
| 1769 | } |
| 1770 | |
| 1771 | return 0; |
| 1772 | err: |
| 1773 | return err; |
| 1774 | } |
| 1775 | |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 1776 | static int do_fsl_mc(struct cmd_tbl *cmdtp, int flag, int argc, |
| 1777 | char *const argv[]) |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 1778 | { |
Prabhakar Kushwaha | 29a63e4 | 2015-11-04 12:25:58 +0530 | [diff] [blame] | 1779 | int err = 0; |
| 1780 | if (argc < 3) |
| 1781 | goto usage; |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 1782 | |
Prabhakar Kushwaha | 29a63e4 | 2015-11-04 12:25:58 +0530 | [diff] [blame] | 1783 | switch (argv[1][0]) { |
| 1784 | case 's': { |
| 1785 | char sub_cmd; |
Prabhakar Kushwaha | 122bcfd | 2015-11-09 16:42:07 +0530 | [diff] [blame] | 1786 | u64 mc_fw_addr, mc_dpc_addr; |
| 1787 | #ifdef CONFIG_SYS_LS_MC_DRAM_AIOP_IMG_OFFSET |
| 1788 | u64 aiop_fw_addr; |
| 1789 | #endif |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 1790 | |
Prabhakar Kushwaha | 29a63e4 | 2015-11-04 12:25:58 +0530 | [diff] [blame] | 1791 | sub_cmd = argv[2][0]; |
Yogesh Gaur | 318c32f | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 1792 | |
Prabhakar Kushwaha | 29a63e4 | 2015-11-04 12:25:58 +0530 | [diff] [blame] | 1793 | switch (sub_cmd) { |
| 1794 | case 'm': |
| 1795 | if (argc < 5) |
| 1796 | goto usage; |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 1797 | |
Prabhakar Kushwaha | 29a63e4 | 2015-11-04 12:25:58 +0530 | [diff] [blame] | 1798 | if (get_mc_boot_status() == 0) { |
| 1799 | printf("fsl-mc: MC is already booted"); |
| 1800 | printf("\n"); |
| 1801 | return err; |
| 1802 | } |
| 1803 | mc_fw_addr = simple_strtoull(argv[3], NULL, 16); |
| 1804 | mc_dpc_addr = simple_strtoull(argv[4], NULL, |
| 1805 | 16); |
Prabhakar Kushwaha | 316b71c | 2015-11-04 12:25:59 +0530 | [diff] [blame] | 1806 | |
| 1807 | if (!mc_init(mc_fw_addr, mc_dpc_addr)) |
| 1808 | err = mc_init_object(); |
Prabhakar Kushwaha | 29a63e4 | 2015-11-04 12:25:58 +0530 | [diff] [blame] | 1809 | break; |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 1810 | |
Prabhakar Kushwaha | 29a63e4 | 2015-11-04 12:25:58 +0530 | [diff] [blame] | 1811 | #ifdef CONFIG_SYS_LS_MC_DRAM_AIOP_IMG_OFFSET |
| 1812 | case 'a': |
| 1813 | if (argc < 4) |
| 1814 | goto usage; |
| 1815 | if (get_aiop_apply_status() == 0) { |
| 1816 | printf("fsl-mc: AIOP FW is already"); |
| 1817 | printf(" applied\n"); |
| 1818 | return err; |
| 1819 | } |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 1820 | |
Prabhakar Kushwaha | 29a63e4 | 2015-11-04 12:25:58 +0530 | [diff] [blame] | 1821 | aiop_fw_addr = simple_strtoull(argv[3], NULL, |
| 1822 | 16); |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 1823 | |
York Sun | cbe8e1c | 2016-04-04 11:41:26 -0700 | [diff] [blame] | 1824 | /* if SoC doesn't have AIOP, err = -ENODEV */ |
Prabhakar Kushwaha | 29a63e4 | 2015-11-04 12:25:58 +0530 | [diff] [blame] | 1825 | err = load_mc_aiop_img(aiop_fw_addr); |
| 1826 | if (!err) |
| 1827 | printf("fsl-mc: AIOP FW applied\n"); |
| 1828 | break; |
| 1829 | #endif |
| 1830 | default: |
| 1831 | printf("Invalid option: %s\n", argv[2]); |
| 1832 | goto usage; |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 1833 | |
Prabhakar Kushwaha | 29a63e4 | 2015-11-04 12:25:58 +0530 | [diff] [blame] | 1834 | break; |
| 1835 | } |
| 1836 | } |
Florinel Iordache | ae6d852 | 2019-11-19 10:28:17 +0000 | [diff] [blame] | 1837 | break; |
| 1838 | |
| 1839 | case 'l': { |
| 1840 | /* lazyapply */ |
| 1841 | u64 mc_dpl_addr; |
| 1842 | |
| 1843 | if (argc < 4) |
| 1844 | goto usage; |
| 1845 | |
| 1846 | if (get_dpl_apply_status() == 0) { |
| 1847 | printf("fsl-mc: DPL already applied\n"); |
| 1848 | return err; |
| 1849 | } |
| 1850 | |
| 1851 | mc_dpl_addr = simple_strtoull(argv[3], NULL, 16); |
| 1852 | |
| 1853 | if (get_mc_boot_status() != 0) { |
| 1854 | printf("fsl-mc: Deploying data path layout .."); |
| 1855 | printf("ERROR (MC is not booted)\n"); |
| 1856 | return -ENODEV; |
| 1857 | } |
| 1858 | |
| 1859 | /* |
| 1860 | * We will do the actual dpaa exit and dpl apply |
| 1861 | * later from announce_and_cleanup(). |
| 1862 | */ |
| 1863 | mc_lazy_dpl_addr = mc_dpl_addr; |
Prabhakar Kushwaha | 29a63e4 | 2015-11-04 12:25:58 +0530 | [diff] [blame] | 1864 | break; |
Florinel Iordache | ae6d852 | 2019-11-19 10:28:17 +0000 | [diff] [blame] | 1865 | } |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 1866 | |
Prabhakar Kushwaha | 29a63e4 | 2015-11-04 12:25:58 +0530 | [diff] [blame] | 1867 | case 'a': { |
Florinel Iordache | ae6d852 | 2019-11-19 10:28:17 +0000 | [diff] [blame] | 1868 | /* apply */ |
| 1869 | char sub_cmd; |
| 1870 | u64 mc_apply_addr; |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 1871 | |
Florinel Iordache | ae6d852 | 2019-11-19 10:28:17 +0000 | [diff] [blame] | 1872 | if (argc < 4) |
| 1873 | goto usage; |
| 1874 | |
| 1875 | sub_cmd = argv[2][0]; |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 1876 | |
Florinel Iordache | ae6d852 | 2019-11-19 10:28:17 +0000 | [diff] [blame] | 1877 | switch (sub_cmd) { |
| 1878 | case 'd': |
| 1879 | case 'D': |
Prabhakar Kushwaha | 29a63e4 | 2015-11-04 12:25:58 +0530 | [diff] [blame] | 1880 | if (get_dpl_apply_status() == 0) { |
| 1881 | printf("fsl-mc: DPL already applied\n"); |
| 1882 | return err; |
| 1883 | } |
Prabhakar Kushwaha | 29a63e4 | 2015-11-04 12:25:58 +0530 | [diff] [blame] | 1884 | if (get_mc_boot_status() != 0) { |
| 1885 | printf("fsl-mc: Deploying data path layout .."); |
| 1886 | printf("ERROR (MC is not booted)\n"); |
| 1887 | return -ENODEV; |
| 1888 | } |
Prabhakar Kushwaha | 316b71c | 2015-11-04 12:25:59 +0530 | [diff] [blame] | 1889 | |
Florinel Iordache | ae6d852 | 2019-11-19 10:28:17 +0000 | [diff] [blame] | 1890 | mc_apply_addr = simple_strtoull(argv[3], NULL, 16); |
| 1891 | |
| 1892 | /* The user wants DPL applied now */ |
| 1893 | if (!fsl_mc_ldpaa_exit(NULL)) |
| 1894 | err = mc_apply_dpl(mc_apply_addr); |
| 1895 | break; |
| 1896 | |
| 1897 | case 's': |
| 1898 | if (!is_dpsparser_supported()) { |
| 1899 | printf("fsl-mc: apply spb command .. "); |
| 1900 | printf("ERROR: requires at least MC 10.12.0\n"); |
| 1901 | return err; |
Alexander Graf | 2ebeb44 | 2016-11-17 01:02:57 +0100 | [diff] [blame] | 1902 | } |
Florinel Iordache | ae6d852 | 2019-11-19 10:28:17 +0000 | [diff] [blame] | 1903 | if (get_mc_boot_status() != 0) { |
| 1904 | printf("fsl-mc: Deploying Soft Parser Blob..."); |
| 1905 | printf("ERROR (MC is not booted)\n"); |
| 1906 | return err; |
| 1907 | } |
| 1908 | |
| 1909 | mc_apply_addr = simple_strtoull(argv[3], NULL, 16); |
| 1910 | |
| 1911 | /* Apply spb (Soft Parser Blob) */ |
| 1912 | err = mc_apply_spb(mc_apply_addr); |
Prabhakar Kushwaha | 29a63e4 | 2015-11-04 12:25:58 +0530 | [diff] [blame] | 1913 | break; |
Florinel Iordache | ae6d852 | 2019-11-19 10:28:17 +0000 | [diff] [blame] | 1914 | |
| 1915 | default: |
| 1916 | printf("Invalid option: %s\n", argv[2]); |
| 1917 | goto usage; |
| 1918 | } |
| 1919 | break; |
J. German Rivera | f4fed4b | 2015-03-20 19:28:18 -0700 | [diff] [blame] | 1920 | } |
Prabhakar Kushwaha | 29a63e4 | 2015-11-04 12:25:58 +0530 | [diff] [blame] | 1921 | default: |
| 1922 | printf("Invalid option: %s\n", argv[1]); |
| 1923 | goto usage; |
| 1924 | break; |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 1925 | } |
Prabhakar Kushwaha | 29a63e4 | 2015-11-04 12:25:58 +0530 | [diff] [blame] | 1926 | return err; |
| 1927 | usage: |
| 1928 | return CMD_RET_USAGE; |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 1929 | } |
Prabhakar Kushwaha | 29a63e4 | 2015-11-04 12:25:58 +0530 | [diff] [blame] | 1930 | |
| 1931 | U_BOOT_CMD( |
| 1932 | fsl_mc, CONFIG_SYS_MAXARGS, 1, do_fsl_mc, |
| 1933 | "DPAA2 command to manage Management Complex (MC)", |
| 1934 | "start mc [FW_addr] [DPC_addr] - Start Management Complex\n" |
| 1935 | "fsl_mc apply DPL [DPL_addr] - Apply DPL file\n" |
Alexander Graf | 2ebeb44 | 2016-11-17 01:02:57 +0100 | [diff] [blame] | 1936 | "fsl_mc lazyapply DPL [DPL_addr] - Apply DPL file on exit\n" |
Florinel Iordache | ae6d852 | 2019-11-19 10:28:17 +0000 | [diff] [blame] | 1937 | "fsl_mc apply spb [spb_addr] - Apply SPB Soft Parser Blob\n" |
Prabhakar Kushwaha | 29a63e4 | 2015-11-04 12:25:58 +0530 | [diff] [blame] | 1938 | "fsl_mc start aiop [FW_addr] - Start AIOP\n" |
| 1939 | ); |
Bogdan Purcareata | 08bc014 | 2017-05-24 16:40:21 +0000 | [diff] [blame] | 1940 | |
| 1941 | void mc_env_boot(void) |
| 1942 | { |
| 1943 | #if defined(CONFIG_FSL_MC_ENET) |
| 1944 | char *mc_boot_env_var; |
| 1945 | /* The MC may only be initialized in the reset PHY function |
| 1946 | * because otherwise U-Boot has not yet set up all the MAC |
| 1947 | * address info properly. Without MAC addresses, the MC code |
| 1948 | * can not properly initialize the DPC. |
| 1949 | */ |
Simon Glass | 64b723f | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 1950 | mc_boot_env_var = env_get(MC_BOOT_ENV_VAR); |
Bogdan Purcareata | 08bc014 | 2017-05-24 16:40:21 +0000 | [diff] [blame] | 1951 | if (mc_boot_env_var) |
| 1952 | run_command_list(mc_boot_env_var, -1, 0); |
| 1953 | #endif /* CONFIG_FSL_MC_ENET */ |
| 1954 | } |