Poonam Aggrwal | 4ca72ae | 2009-09-02 19:40:36 +0530 | [diff] [blame] | 1 | /* |
ramneek mehresh | 6bce611 | 2012-02-06 19:17:29 +0000 | [diff] [blame] | 2 | * Copyright 2009-2012 Freescale Semiconductor, Inc. |
Poonam Aggrwal | 4ca72ae | 2009-09-02 19:40:36 +0530 | [diff] [blame] | 3 | * |
Stefan Roese | 88fbf93 | 2010-04-15 16:07:28 +0200 | [diff] [blame] | 4 | * This file is derived from arch/powerpc/cpu/mpc85xx/cpu.c and |
| 5 | * arch/powerpc/cpu/mpc86xx/cpu.c. Basically this file contains |
Peter Tyser | 29514c7 | 2010-04-12 22:28:09 -0500 | [diff] [blame] | 6 | * cpu specific common code for 85xx/86xx processors. |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame^] | 7 | * SPDX-License-Identifier: GPL-2.0+ |
Poonam Aggrwal | 4ca72ae | 2009-09-02 19:40:36 +0530 | [diff] [blame] | 8 | */ |
| 9 | |
| 10 | #include <common.h> |
| 11 | #include <libfdt.h> |
| 12 | #include <fdt_support.h> |
Kumar Gala | 819a479 | 2010-06-09 22:33:53 -0500 | [diff] [blame] | 13 | #include <asm/mp.h> |
Kumar Gala | 8975d7a | 2010-12-30 12:09:53 -0600 | [diff] [blame] | 14 | #include <asm/fsl_serdes.h> |
Andy Fleming | 7832a46 | 2011-04-13 00:37:12 -0500 | [diff] [blame] | 15 | #include <phy.h> |
Ramneek Mehresh | 7f548e0 | 2011-06-08 17:14:20 +0530 | [diff] [blame] | 16 | #include <hwconfig.h> |
Kumar Gala | 3725f55 | 2011-07-29 08:51:26 -0500 | [diff] [blame] | 17 | |
| 18 | #define FSL_MAX_NUM_USB_CTRLS 2 |
Poonam Aggrwal | 4ca72ae | 2009-09-02 19:40:36 +0530 | [diff] [blame] | 19 | |
Kumar Gala | 819a479 | 2010-06-09 22:33:53 -0500 | [diff] [blame] | 20 | #if defined(CONFIG_MP) && (defined(CONFIG_MPC85xx) || defined(CONFIG_MPC86xx)) |
Kumar Gala | a24926d | 2010-06-09 13:14:28 -0500 | [diff] [blame] | 21 | static int ft_del_cpuhandle(void *blob, int cpuhandle) |
| 22 | { |
| 23 | int off, ret = -FDT_ERR_NOTFOUND; |
| 24 | |
| 25 | /* if we find a match, we'll delete at it which point the offsets are |
| 26 | * invalid so we start over from the beginning |
| 27 | */ |
| 28 | off = fdt_node_offset_by_prop_value(blob, -1, "cpu-handle", |
| 29 | &cpuhandle, 4); |
| 30 | while (off != -FDT_ERR_NOTFOUND) { |
| 31 | fdt_delprop(blob, off, "cpu-handle"); |
| 32 | ret = 1; |
| 33 | off = fdt_node_offset_by_prop_value(blob, -1, "cpu-handle", |
| 34 | &cpuhandle, 4); |
| 35 | } |
| 36 | |
| 37 | return ret; |
| 38 | } |
| 39 | |
Poonam Aggrwal | 4ca72ae | 2009-09-02 19:40:36 +0530 | [diff] [blame] | 40 | void ft_fixup_num_cores(void *blob) { |
| 41 | int off, num_cores, del_cores; |
| 42 | |
| 43 | del_cores = 0; |
| 44 | num_cores = cpu_numcores(); |
| 45 | |
| 46 | off = fdt_node_offset_by_prop_value(blob, -1, "device_type", "cpu", 4); |
| 47 | while (off != -FDT_ERR_NOTFOUND) { |
| 48 | u32 *reg = (u32 *)fdt_getprop(blob, off, "reg", 0); |
York Sun | 2adf2ce | 2012-08-17 08:20:26 +0000 | [diff] [blame] | 49 | u32 phys_cpu_id = thread_to_core(*reg); |
Poonam Aggrwal | 4ca72ae | 2009-09-02 19:40:36 +0530 | [diff] [blame] | 50 | |
York Sun | 2adf2ce | 2012-08-17 08:20:26 +0000 | [diff] [blame] | 51 | if (!is_core_valid(phys_cpu_id) || is_core_disabled(phys_cpu_id)) { |
Kumar Gala | a24926d | 2010-06-09 13:14:28 -0500 | [diff] [blame] | 52 | int ph = fdt_get_phandle(blob, off); |
| 53 | |
| 54 | /* Delete the cpu node once there are no cpu handles */ |
| 55 | if (-FDT_ERR_NOTFOUND == ft_del_cpuhandle(blob, ph)) { |
| 56 | fdt_del_node(blob, off); |
| 57 | del_cores++; |
| 58 | } |
| 59 | /* either we deleted some cpu handles or the cpu node |
| 60 | * so we reset the offset back to the start since we |
| 61 | * can't trust the offsets anymore |
| 62 | */ |
Poonam Aggrwal | 4ca72ae | 2009-09-02 19:40:36 +0530 | [diff] [blame] | 63 | off = -1; |
| 64 | } |
| 65 | off = fdt_node_offset_by_prop_value(blob, off, |
| 66 | "device_type", "cpu", 4); |
| 67 | } |
| 68 | debug ("%x core system found\n", num_cores); |
| 69 | debug ("deleted %d extra core entry entries from device tree\n", |
| 70 | del_cores); |
| 71 | } |
Kim Phillips | 6578bae | 2010-05-28 08:00:14 +0000 | [diff] [blame] | 72 | #endif /* defined(CONFIG_MPC85xx) || defined(CONFIG_MPC86xx) */ |
| 73 | |
ramneek mehresh | 800c206 | 2012-02-10 00:36:43 +0000 | [diff] [blame] | 74 | #if defined(CONFIG_HAS_FSL_DR_USB) || defined(CONFIG_HAS_FSL_MPH_USB) |
Ramneek Mehresh | 8cab6eb | 2011-11-08 13:09:20 +0530 | [diff] [blame] | 75 | static int fdt_fixup_usb_mode_phy_type(void *blob, const char *mode, |
| 76 | const char *phy_type, int start_offset) |
Kim Phillips | 6578bae | 2010-05-28 08:00:14 +0000 | [diff] [blame] | 77 | { |
ramneek mehresh | 800c206 | 2012-02-10 00:36:43 +0000 | [diff] [blame] | 78 | const char *compat_dr = "fsl-usb2-dr"; |
| 79 | const char *compat_mph = "fsl-usb2-mph"; |
Kim Phillips | 6578bae | 2010-05-28 08:00:14 +0000 | [diff] [blame] | 80 | const char *prop_mode = "dr_mode"; |
| 81 | const char *prop_type = "phy_type"; |
ramneek mehresh | 800c206 | 2012-02-10 00:36:43 +0000 | [diff] [blame] | 82 | const char *node_type = NULL; |
Kim Phillips | 6578bae | 2010-05-28 08:00:14 +0000 | [diff] [blame] | 83 | int node_offset; |
| 84 | int err; |
| 85 | |
Ramneek Mehresh | 7f548e0 | 2011-06-08 17:14:20 +0530 | [diff] [blame] | 86 | node_offset = fdt_node_offset_by_compatible(blob, |
ramneek mehresh | 800c206 | 2012-02-10 00:36:43 +0000 | [diff] [blame] | 87 | start_offset, compat_mph); |
Kim Phillips | 6578bae | 2010-05-28 08:00:14 +0000 | [diff] [blame] | 88 | if (node_offset < 0) { |
ramneek mehresh | 800c206 | 2012-02-10 00:36:43 +0000 | [diff] [blame] | 89 | node_offset = fdt_node_offset_by_compatible(blob, |
| 90 | start_offset, compat_dr); |
| 91 | if (node_offset < 0) { |
| 92 | printf("WARNING: could not find compatible" |
| 93 | " node %s or %s: %s.\n", compat_mph, |
| 94 | compat_dr, fdt_strerror(node_offset)); |
| 95 | return -1; |
| 96 | } else |
| 97 | node_type = compat_dr; |
| 98 | } else |
| 99 | node_type = compat_mph; |
Kim Phillips | 6578bae | 2010-05-28 08:00:14 +0000 | [diff] [blame] | 100 | |
| 101 | if (mode) { |
| 102 | err = fdt_setprop(blob, node_offset, prop_mode, mode, |
| 103 | strlen(mode) + 1); |
| 104 | if (err < 0) |
| 105 | printf("WARNING: could not set %s for %s: %s.\n", |
ramneek mehresh | 800c206 | 2012-02-10 00:36:43 +0000 | [diff] [blame] | 106 | prop_mode, node_type, fdt_strerror(err)); |
Kim Phillips | 6578bae | 2010-05-28 08:00:14 +0000 | [diff] [blame] | 107 | } |
| 108 | |
Ramneek Mehresh | 7f548e0 | 2011-06-08 17:14:20 +0530 | [diff] [blame] | 109 | if (phy_type) { |
| 110 | err = fdt_setprop(blob, node_offset, prop_type, phy_type, |
| 111 | strlen(phy_type) + 1); |
Kim Phillips | 6578bae | 2010-05-28 08:00:14 +0000 | [diff] [blame] | 112 | if (err < 0) |
| 113 | printf("WARNING: could not set %s for %s: %s.\n", |
ramneek mehresh | 800c206 | 2012-02-10 00:36:43 +0000 | [diff] [blame] | 114 | prop_type, node_type, fdt_strerror(err)); |
Kim Phillips | 6578bae | 2010-05-28 08:00:14 +0000 | [diff] [blame] | 115 | } |
Ramneek Mehresh | 7f548e0 | 2011-06-08 17:14:20 +0530 | [diff] [blame] | 116 | |
Ramneek Mehresh | 8cab6eb | 2011-11-08 13:09:20 +0530 | [diff] [blame] | 117 | return node_offset; |
Ramneek Mehresh | 7f548e0 | 2011-06-08 17:14:20 +0530 | [diff] [blame] | 118 | } |
| 119 | |
| 120 | void fdt_fixup_dr_usb(void *blob, bd_t *bd) |
| 121 | { |
| 122 | const char *modes[] = { "host", "peripheral", "otg" }; |
Ramneek Mehresh | 8cab6eb | 2011-11-08 13:09:20 +0530 | [diff] [blame] | 123 | const char *phys[] = { "ulpi", "utmi" }; |
Ramneek Mehresh | 7f548e0 | 2011-06-08 17:14:20 +0530 | [diff] [blame] | 124 | const char *mode = NULL; |
| 125 | const char *phy_type = NULL; |
ramneek mehresh | ff6a024 | 2012-09-18 22:28:51 +0000 | [diff] [blame] | 126 | const char *dr_mode_type = NULL; |
| 127 | const char *dr_phy_type = NULL; |
Ramneek Mehresh | 7f548e0 | 2011-06-08 17:14:20 +0530 | [diff] [blame] | 128 | char usb1_defined = 0; |
Ramneek Mehresh | 8cab6eb | 2011-11-08 13:09:20 +0530 | [diff] [blame] | 129 | int usb_mode_off = -1; |
| 130 | int usb_phy_off = -1; |
Ramneek Mehresh | 7f548e0 | 2011-06-08 17:14:20 +0530 | [diff] [blame] | 131 | char str[5]; |
| 132 | int i, j; |
| 133 | |
Kumar Gala | 3725f55 | 2011-07-29 08:51:26 -0500 | [diff] [blame] | 134 | for (i = 1; i <= FSL_MAX_NUM_USB_CTRLS; i++) { |
Ramneek Mehresh | 7f548e0 | 2011-06-08 17:14:20 +0530 | [diff] [blame] | 135 | int mode_idx = -1, phy_idx = -1; |
ramneek mehresh | 6bce611 | 2012-02-06 19:17:29 +0000 | [diff] [blame] | 136 | snprintf(str, 5, "%s%d", "usb", i); |
Ramneek Mehresh | 7f548e0 | 2011-06-08 17:14:20 +0530 | [diff] [blame] | 137 | if (hwconfig(str)) { |
ramneek mehresh | 6bce611 | 2012-02-06 19:17:29 +0000 | [diff] [blame] | 138 | for (j = 0; j < ARRAY_SIZE(modes); j++) { |
Ramneek Mehresh | 7f548e0 | 2011-06-08 17:14:20 +0530 | [diff] [blame] | 139 | if (hwconfig_subarg_cmp(str, "dr_mode", |
| 140 | modes[j])) { |
| 141 | mode_idx = j; |
| 142 | break; |
| 143 | } |
| 144 | } |
ramneek mehresh | ff6a024 | 2012-09-18 22:28:51 +0000 | [diff] [blame] | 145 | |
ramneek mehresh | 6bce611 | 2012-02-06 19:17:29 +0000 | [diff] [blame] | 146 | for (j = 0; j < ARRAY_SIZE(phys); j++) { |
Ramneek Mehresh | 7f548e0 | 2011-06-08 17:14:20 +0530 | [diff] [blame] | 147 | if (hwconfig_subarg_cmp(str, "phy_type", |
| 148 | phys[j])) { |
| 149 | phy_idx = j; |
| 150 | break; |
| 151 | } |
| 152 | } |
ramneek mehresh | ff6a024 | 2012-09-18 22:28:51 +0000 | [diff] [blame] | 153 | |
ramneek mehresh | b2553f5 | 2013-02-17 18:23:32 +0000 | [diff] [blame] | 154 | if (mode_idx < 0 || phy_idx < 0) { |
| 155 | puts("ERROR: wrong usb mode/phy defined!!\n"); |
| 156 | return; |
| 157 | } |
| 158 | |
ramneek mehresh | ff6a024 | 2012-09-18 22:28:51 +0000 | [diff] [blame] | 159 | dr_mode_type = modes[mode_idx]; |
| 160 | dr_phy_type = phys[phy_idx]; |
| 161 | |
| 162 | /* use usb_dr_mode and usb_phy_type if |
| 163 | usb1_defined = 0; these variables are to |
| 164 | be deprecated */ |
Ramneek Mehresh | 7f548e0 | 2011-06-08 17:14:20 +0530 | [diff] [blame] | 165 | if (!strcmp(str, "usb1")) |
| 166 | usb1_defined = 1; |
ramneek mehresh | ff6a024 | 2012-09-18 22:28:51 +0000 | [diff] [blame] | 167 | |
| 168 | if (mode_idx < 0 && phy_idx < 0) { |
Ramneek Mehresh | 7f548e0 | 2011-06-08 17:14:20 +0530 | [diff] [blame] | 169 | printf("WARNING: invalid phy or mode\n"); |
ramneek mehresh | ff6a024 | 2012-09-18 22:28:51 +0000 | [diff] [blame] | 170 | return; |
| 171 | } |
Ramneek Mehresh | 7f548e0 | 2011-06-08 17:14:20 +0530 | [diff] [blame] | 172 | } |
ramneek mehresh | ff6a024 | 2012-09-18 22:28:51 +0000 | [diff] [blame] | 173 | |
| 174 | usb_mode_off = fdt_fixup_usb_mode_phy_type(blob, |
| 175 | dr_mode_type, NULL, usb_mode_off); |
| 176 | |
| 177 | if (usb_mode_off < 0) |
| 178 | return; |
| 179 | |
| 180 | usb_phy_off = fdt_fixup_usb_mode_phy_type(blob, |
| 181 | NULL, dr_phy_type, usb_phy_off); |
| 182 | |
| 183 | if (usb_phy_off < 0) |
| 184 | return; |
Ramneek Mehresh | 7f548e0 | 2011-06-08 17:14:20 +0530 | [diff] [blame] | 185 | } |
ramneek mehresh | ff6a024 | 2012-09-18 22:28:51 +0000 | [diff] [blame] | 186 | |
Ramneek Mehresh | 7f548e0 | 2011-06-08 17:14:20 +0530 | [diff] [blame] | 187 | if (!usb1_defined) { |
Ramneek Mehresh | 8cab6eb | 2011-11-08 13:09:20 +0530 | [diff] [blame] | 188 | int usb_off = -1; |
Ramneek Mehresh | 7f548e0 | 2011-06-08 17:14:20 +0530 | [diff] [blame] | 189 | mode = getenv("usb_dr_mode"); |
| 190 | phy_type = getenv("usb_phy_type"); |
ramneek mehresh | ff6a024 | 2012-09-18 22:28:51 +0000 | [diff] [blame] | 191 | if (mode || phy_type) { |
| 192 | printf("WARNING: usb_dr_mode and usb_phy_type " |
| 193 | "are to be deprecated soon. Use " |
| 194 | "hwconfig to set these values instead!!\n"); |
| 195 | fdt_fixup_usb_mode_phy_type(blob, mode, |
| 196 | phy_type, usb_off); |
| 197 | } |
Ramneek Mehresh | 7f548e0 | 2011-06-08 17:14:20 +0530 | [diff] [blame] | 198 | } |
Kim Phillips | 6578bae | 2010-05-28 08:00:14 +0000 | [diff] [blame] | 199 | } |
ramneek mehresh | 800c206 | 2012-02-10 00:36:43 +0000 | [diff] [blame] | 200 | #endif /* defined(CONFIG_HAS_FSL_DR_USB) || defined(CONFIG_HAS_FSL_MPH_USB) */ |
Kim Phillips | 6578bae | 2010-05-28 08:00:14 +0000 | [diff] [blame] | 201 | |
Kim Phillips | 6578bae | 2010-05-28 08:00:14 +0000 | [diff] [blame] | 202 | /* |
| 203 | * update crypto node properties to a specified revision of the SEC |
Kim Phillips | def125f | 2010-06-01 12:24:27 -0500 | [diff] [blame] | 204 | * called with sec_rev == 0 if not on an E processor |
Kim Phillips | 6578bae | 2010-05-28 08:00:14 +0000 | [diff] [blame] | 205 | */ |
Kim Phillips | def125f | 2010-06-01 12:24:27 -0500 | [diff] [blame] | 206 | #if CONFIG_SYS_FSL_SEC_COMPAT == 2 /* SEC 2.x/3.x */ |
Kim Phillips | 6578bae | 2010-05-28 08:00:14 +0000 | [diff] [blame] | 207 | void fdt_fixup_crypto_node(void *blob, int sec_rev) |
| 208 | { |
Kim Phillips | 82eac67 | 2012-10-31 11:09:26 +0000 | [diff] [blame] | 209 | static const struct sec_rev_prop { |
Kim Phillips | 6578bae | 2010-05-28 08:00:14 +0000 | [diff] [blame] | 210 | u32 sec_rev; |
| 211 | u32 num_channels; |
| 212 | u32 channel_fifo_len; |
| 213 | u32 exec_units_mask; |
| 214 | u32 descriptor_types_mask; |
| 215 | } sec_rev_prop_list [] = { |
| 216 | { 0x0200, 4, 24, 0x07e, 0x01010ebf }, /* SEC 2.0 */ |
| 217 | { 0x0201, 4, 24, 0x0fe, 0x012b0ebf }, /* SEC 2.1 */ |
| 218 | { 0x0202, 1, 24, 0x04c, 0x0122003f }, /* SEC 2.2 */ |
| 219 | { 0x0204, 4, 24, 0x07e, 0x012b0ebf }, /* SEC 2.4 */ |
| 220 | { 0x0300, 4, 24, 0x9fe, 0x03ab0ebf }, /* SEC 3.0 */ |
| 221 | { 0x0301, 4, 24, 0xbfe, 0x03ab0ebf }, /* SEC 3.1 */ |
| 222 | { 0x0303, 4, 24, 0x97c, 0x03a30abf }, /* SEC 3.3 */ |
| 223 | }; |
Kim Phillips | 82eac67 | 2012-10-31 11:09:26 +0000 | [diff] [blame] | 224 | static char compat_strlist[ARRAY_SIZE(sec_rev_prop_list) * |
| 225 | sizeof("fsl,secX.Y")]; |
Kim Phillips | 6578bae | 2010-05-28 08:00:14 +0000 | [diff] [blame] | 226 | int crypto_node, sec_idx, err; |
| 227 | char *p; |
| 228 | u32 val; |
| 229 | |
| 230 | /* locate crypto node based on lowest common compatible */ |
| 231 | crypto_node = fdt_node_offset_by_compatible(blob, -1, "fsl,sec2.0"); |
| 232 | if (crypto_node == -FDT_ERR_NOTFOUND) |
| 233 | return; |
| 234 | |
| 235 | /* delete it if not on an E-processor */ |
| 236 | if (crypto_node > 0 && !sec_rev) { |
| 237 | fdt_del_node(blob, crypto_node); |
| 238 | return; |
| 239 | } |
| 240 | |
| 241 | /* else we got called for possible uprev */ |
| 242 | for (sec_idx = 0; sec_idx < ARRAY_SIZE(sec_rev_prop_list); sec_idx++) |
| 243 | if (sec_rev_prop_list[sec_idx].sec_rev == sec_rev) |
| 244 | break; |
| 245 | |
| 246 | if (sec_idx == ARRAY_SIZE(sec_rev_prop_list)) { |
| 247 | puts("warning: unknown SEC revision number\n"); |
| 248 | return; |
| 249 | } |
| 250 | |
| 251 | val = cpu_to_fdt32(sec_rev_prop_list[sec_idx].num_channels); |
| 252 | err = fdt_setprop(blob, crypto_node, "fsl,num-channels", &val, 4); |
| 253 | if (err < 0) |
| 254 | printf("WARNING: could not set crypto property: %s\n", |
| 255 | fdt_strerror(err)); |
| 256 | |
| 257 | val = cpu_to_fdt32(sec_rev_prop_list[sec_idx].descriptor_types_mask); |
| 258 | err = fdt_setprop(blob, crypto_node, "fsl,descriptor-types-mask", &val, 4); |
| 259 | if (err < 0) |
| 260 | printf("WARNING: could not set crypto property: %s\n", |
| 261 | fdt_strerror(err)); |
| 262 | |
| 263 | val = cpu_to_fdt32(sec_rev_prop_list[sec_idx].exec_units_mask); |
| 264 | err = fdt_setprop(blob, crypto_node, "fsl,exec-units-mask", &val, 4); |
| 265 | if (err < 0) |
| 266 | printf("WARNING: could not set crypto property: %s\n", |
| 267 | fdt_strerror(err)); |
| 268 | |
| 269 | val = cpu_to_fdt32(sec_rev_prop_list[sec_idx].channel_fifo_len); |
| 270 | err = fdt_setprop(blob, crypto_node, "fsl,channel-fifo-len", &val, 4); |
| 271 | if (err < 0) |
| 272 | printf("WARNING: could not set crypto property: %s\n", |
| 273 | fdt_strerror(err)); |
| 274 | |
| 275 | val = 0; |
| 276 | while (sec_idx >= 0) { |
| 277 | p = compat_strlist + val; |
| 278 | val += sprintf(p, "fsl,sec%d.%d", |
| 279 | (sec_rev_prop_list[sec_idx].sec_rev & 0xff00) >> 8, |
| 280 | sec_rev_prop_list[sec_idx].sec_rev & 0x00ff) + 1; |
| 281 | sec_idx--; |
| 282 | } |
| 283 | err = fdt_setprop(blob, crypto_node, "compatible", &compat_strlist, val); |
| 284 | if (err < 0) |
| 285 | printf("WARNING: could not set crypto property: %s\n", |
| 286 | fdt_strerror(err)); |
| 287 | } |
Kim Phillips | 1b62549 | 2010-06-01 12:24:34 -0500 | [diff] [blame] | 288 | #elif CONFIG_SYS_FSL_SEC_COMPAT >= 4 /* SEC4 */ |
Vakul Garg | 90a7f9f | 2013-01-23 22:52:31 +0000 | [diff] [blame] | 289 | static u8 caam_get_era(void) |
| 290 | { |
| 291 | static const struct { |
| 292 | u16 ip_id; |
| 293 | u8 maj_rev; |
| 294 | u8 era; |
| 295 | } caam_eras[] = { |
| 296 | {0x0A10, 1, 1}, |
| 297 | {0x0A10, 2, 2}, |
| 298 | {0x0A12, 1, 3}, |
| 299 | {0x0A14, 1, 3}, |
| 300 | {0x0A14, 2, 4}, |
| 301 | {0x0A16, 1, 4}, |
| 302 | {0x0A10, 3, 4}, |
| 303 | {0x0A11, 1, 4}, |
| 304 | {0x0A18, 1, 4}, |
| 305 | {0x0A11, 2, 5}, |
| 306 | {0x0A12, 2, 5}, |
| 307 | {0x0A13, 1, 5}, |
| 308 | {0x0A1C, 1, 5} |
| 309 | }; |
| 310 | |
| 311 | ccsr_sec_t __iomem *sec = (void __iomem *)CONFIG_SYS_FSL_SEC_ADDR; |
| 312 | u32 secvid_ms = in_be32(&sec->secvid_ms); |
| 313 | u32 ccbvid = in_be32(&sec->ccbvid); |
| 314 | u16 ip_id = (secvid_ms & SEC_SECVID_MS_IPID_MASK) >> |
| 315 | SEC_SECVID_MS_IPID_SHIFT; |
| 316 | u8 maj_rev = (secvid_ms & SEC_SECVID_MS_MAJ_REV_MASK) >> |
| 317 | SEC_SECVID_MS_MAJ_REV_SHIFT; |
| 318 | u8 era = (ccbvid & SEC_CCBVID_ERA_MASK) >> SEC_CCBVID_ERA_SHIFT; |
| 319 | |
| 320 | int i; |
| 321 | |
| 322 | if (era) /* This is '0' prior to CAAM ERA-6 */ |
| 323 | return era; |
| 324 | |
| 325 | for (i = 0; i < ARRAY_SIZE(caam_eras); i++) |
| 326 | if (caam_eras[i].ip_id == ip_id && |
| 327 | caam_eras[i].maj_rev == maj_rev) |
| 328 | return caam_eras[i].era; |
| 329 | |
| 330 | return 0; |
| 331 | } |
| 332 | |
| 333 | static void fdt_fixup_crypto_era(void *blob, u32 era) |
| 334 | { |
| 335 | int err; |
| 336 | int crypto_node; |
| 337 | |
| 338 | crypto_node = fdt_path_offset(blob, "crypto"); |
| 339 | if (crypto_node < 0) { |
| 340 | printf("WARNING: Missing crypto node\n"); |
| 341 | return; |
| 342 | } |
| 343 | |
| 344 | err = fdt_setprop(blob, crypto_node, "fsl,sec-era", &era, |
| 345 | sizeof(era)); |
| 346 | if (err < 0) { |
| 347 | printf("ERROR: could not set fsl,sec-era property: %s\n", |
| 348 | fdt_strerror(err)); |
| 349 | } |
| 350 | } |
| 351 | |
Kim Phillips | 1b62549 | 2010-06-01 12:24:34 -0500 | [diff] [blame] | 352 | void fdt_fixup_crypto_node(void *blob, int sec_rev) |
| 353 | { |
Vakul Garg | 90a7f9f | 2013-01-23 22:52:31 +0000 | [diff] [blame] | 354 | u8 era; |
| 355 | |
| 356 | if (!sec_rev) { |
Kim Phillips | 1b62549 | 2010-06-01 12:24:34 -0500 | [diff] [blame] | 357 | fdt_del_node_and_alias(blob, "crypto"); |
Vakul Garg | 90a7f9f | 2013-01-23 22:52:31 +0000 | [diff] [blame] | 358 | return; |
| 359 | } |
| 360 | |
| 361 | /* Add SEC ERA information in compatible */ |
| 362 | era = caam_get_era(); |
| 363 | if (era) { |
| 364 | fdt_fixup_crypto_era(blob, era); |
| 365 | } else { |
| 366 | printf("WARNING: Unable to get ERA for CAAM rev: %d\n", |
| 367 | sec_rev); |
| 368 | } |
Kim Phillips | 1b62549 | 2010-06-01 12:24:34 -0500 | [diff] [blame] | 369 | } |
Kim Phillips | def125f | 2010-06-01 12:24:27 -0500 | [diff] [blame] | 370 | #endif |
Kumar Gala | 6bc9fd5 | 2010-09-30 09:15:03 -0500 | [diff] [blame] | 371 | |
Andy Fleming | 7832a46 | 2011-04-13 00:37:12 -0500 | [diff] [blame] | 372 | int fdt_fixup_phy_connection(void *blob, int offset, phy_interface_t phyc) |
Kumar Gala | 6bc9fd5 | 2010-09-30 09:15:03 -0500 | [diff] [blame] | 373 | { |
Kumar Gala | 6bc9fd5 | 2010-09-30 09:15:03 -0500 | [diff] [blame] | 374 | return fdt_setprop_string(blob, offset, "phy-connection-type", |
Andy Fleming | 7832a46 | 2011-04-13 00:37:12 -0500 | [diff] [blame] | 375 | phy_string_for_interface(phyc)); |
Kumar Gala | 6bc9fd5 | 2010-09-30 09:15:03 -0500 | [diff] [blame] | 376 | } |
Kumar Gala | 8975d7a | 2010-12-30 12:09:53 -0600 | [diff] [blame] | 377 | |
| 378 | #ifdef CONFIG_SYS_SRIO |
Kumar Gala | 0e7ccae | 2011-10-14 00:03:58 -0500 | [diff] [blame] | 379 | static inline void ft_disable_srio_port(void *blob, int srio_off, int port) |
| 380 | { |
| 381 | int off = fdt_node_offset_by_prop_value(blob, srio_off, |
| 382 | "cell-index", &port, 4); |
| 383 | if (off >= 0) { |
| 384 | off = fdt_setprop_string(blob, off, "status", "disabled"); |
| 385 | if (off > 0) |
| 386 | printf("WARNING unable to set status for fsl,srio " |
| 387 | "port %d: %s\n", port, fdt_strerror(off)); |
| 388 | } |
| 389 | } |
| 390 | |
| 391 | static inline void ft_disable_rman(void *blob) |
| 392 | { |
| 393 | int off = fdt_node_offset_by_compatible(blob, -1, "fsl,rman"); |
| 394 | if (off >= 0) { |
| 395 | off = fdt_setprop_string(blob, off, "status", "disabled"); |
| 396 | if (off > 0) |
| 397 | printf("WARNING unable to set status for fsl,rman %s\n", |
| 398 | fdt_strerror(off)); |
| 399 | } |
| 400 | } |
| 401 | |
| 402 | static inline void ft_disable_rmu(void *blob) |
| 403 | { |
| 404 | int off = fdt_node_offset_by_compatible(blob, -1, "fsl,srio-rmu"); |
| 405 | if (off >= 0) { |
| 406 | off = fdt_setprop_string(blob, off, "status", "disabled"); |
| 407 | if (off > 0) |
| 408 | printf("WARNING unable to set status for " |
| 409 | "fsl,srio-rmu %s\n", fdt_strerror(off)); |
| 410 | } |
| 411 | } |
| 412 | |
Kumar Gala | 8975d7a | 2010-12-30 12:09:53 -0600 | [diff] [blame] | 413 | void ft_srio_setup(void *blob) |
| 414 | { |
Kumar Gala | 0e7ccae | 2011-10-14 00:03:58 -0500 | [diff] [blame] | 415 | int srio1_used = 0, srio2_used = 0; |
| 416 | int srio_off; |
| 417 | |
| 418 | /* search for srio node, if doesn't exist just return - nothing todo */ |
| 419 | srio_off = fdt_node_offset_by_compatible(blob, -1, "fsl,srio"); |
| 420 | if (srio_off < 0) |
| 421 | return ; |
| 422 | |
Kumar Gala | 8975d7a | 2010-12-30 12:09:53 -0600 | [diff] [blame] | 423 | #ifdef CONFIG_SRIO1 |
Kumar Gala | 0e7ccae | 2011-10-14 00:03:58 -0500 | [diff] [blame] | 424 | if (is_serdes_configured(SRIO1)) |
| 425 | srio1_used = 1; |
Kumar Gala | 8975d7a | 2010-12-30 12:09:53 -0600 | [diff] [blame] | 426 | #endif |
| 427 | #ifdef CONFIG_SRIO2 |
Kumar Gala | 0e7ccae | 2011-10-14 00:03:58 -0500 | [diff] [blame] | 428 | if (is_serdes_configured(SRIO2)) |
| 429 | srio2_used = 1; |
Kumar Gala | 8975d7a | 2010-12-30 12:09:53 -0600 | [diff] [blame] | 430 | #endif |
Kumar Gala | 0e7ccae | 2011-10-14 00:03:58 -0500 | [diff] [blame] | 431 | |
| 432 | /* mark port1 disabled */ |
| 433 | if (!srio1_used) |
| 434 | ft_disable_srio_port(blob, srio_off, 1); |
| 435 | |
| 436 | /* mark port2 disabled */ |
| 437 | if (!srio2_used) |
| 438 | ft_disable_srio_port(blob, srio_off, 2); |
| 439 | |
| 440 | /* if both ports not used, disable controller, rmu and rman */ |
| 441 | if (!srio1_used && !srio2_used) { |
| 442 | fdt_setprop_string(blob, srio_off, "status", "disabled"); |
| 443 | |
| 444 | ft_disable_rman(blob); |
| 445 | ft_disable_rmu(blob); |
| 446 | } |
Kumar Gala | 8975d7a | 2010-12-30 12:09:53 -0600 | [diff] [blame] | 447 | } |
| 448 | #endif |