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. |
Poonam Aggrwal | 4ca72ae | 2009-09-02 19:40:36 +0530 | [diff] [blame] | 7 | * See file CREDITS for list of people who contributed to this |
| 8 | * project. |
| 9 | * |
| 10 | * This program is free software; you can redistribute it and/or |
| 11 | * modify it under the terms of the GNU General Public License as |
| 12 | * published by the Free Software Foundation; either version 2 of |
| 13 | * the License, or (at your option) any later version. |
| 14 | * |
| 15 | * This program is distributed in the hope that it will be useful, |
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | * GNU General Public License for more details. |
| 19 | * |
| 20 | * You should have received a copy of the GNU General Public License |
| 21 | * along with this program; if not, write to the Free Software |
| 22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 23 | * MA 02111-1307 USA |
| 24 | */ |
| 25 | |
| 26 | #include <common.h> |
| 27 | #include <libfdt.h> |
| 28 | #include <fdt_support.h> |
Kumar Gala | 819a479 | 2010-06-09 22:33:53 -0500 | [diff] [blame] | 29 | #include <asm/mp.h> |
Kumar Gala | 8975d7a | 2010-12-30 12:09:53 -0600 | [diff] [blame] | 30 | #include <asm/fsl_serdes.h> |
Andy Fleming | 7832a46 | 2011-04-13 00:37:12 -0500 | [diff] [blame] | 31 | #include <phy.h> |
Ramneek Mehresh | 7f548e0 | 2011-06-08 17:14:20 +0530 | [diff] [blame] | 32 | #include <hwconfig.h> |
Kumar Gala | 3725f55 | 2011-07-29 08:51:26 -0500 | [diff] [blame] | 33 | |
| 34 | #define FSL_MAX_NUM_USB_CTRLS 2 |
Poonam Aggrwal | 4ca72ae | 2009-09-02 19:40:36 +0530 | [diff] [blame] | 35 | |
Kumar Gala | 819a479 | 2010-06-09 22:33:53 -0500 | [diff] [blame] | 36 | #if defined(CONFIG_MP) && (defined(CONFIG_MPC85xx) || defined(CONFIG_MPC86xx)) |
Kumar Gala | a24926d | 2010-06-09 13:14:28 -0500 | [diff] [blame] | 37 | static int ft_del_cpuhandle(void *blob, int cpuhandle) |
| 38 | { |
| 39 | int off, ret = -FDT_ERR_NOTFOUND; |
| 40 | |
| 41 | /* if we find a match, we'll delete at it which point the offsets are |
| 42 | * invalid so we start over from the beginning |
| 43 | */ |
| 44 | off = fdt_node_offset_by_prop_value(blob, -1, "cpu-handle", |
| 45 | &cpuhandle, 4); |
| 46 | while (off != -FDT_ERR_NOTFOUND) { |
| 47 | fdt_delprop(blob, off, "cpu-handle"); |
| 48 | ret = 1; |
| 49 | off = fdt_node_offset_by_prop_value(blob, -1, "cpu-handle", |
| 50 | &cpuhandle, 4); |
| 51 | } |
| 52 | |
| 53 | return ret; |
| 54 | } |
| 55 | |
Poonam Aggrwal | 4ca72ae | 2009-09-02 19:40:36 +0530 | [diff] [blame] | 56 | void ft_fixup_num_cores(void *blob) { |
| 57 | int off, num_cores, del_cores; |
| 58 | |
| 59 | del_cores = 0; |
| 60 | num_cores = cpu_numcores(); |
| 61 | |
| 62 | off = fdt_node_offset_by_prop_value(blob, -1, "device_type", "cpu", 4); |
| 63 | while (off != -FDT_ERR_NOTFOUND) { |
| 64 | u32 *reg = (u32 *)fdt_getprop(blob, off, "reg", 0); |
| 65 | |
Timur Tabi | 4728942 | 2011-08-05 16:15:24 -0500 | [diff] [blame] | 66 | if (!is_core_valid(*reg) || is_core_disabled(*reg)) { |
Kumar Gala | a24926d | 2010-06-09 13:14:28 -0500 | [diff] [blame] | 67 | int ph = fdt_get_phandle(blob, off); |
| 68 | |
| 69 | /* Delete the cpu node once there are no cpu handles */ |
| 70 | if (-FDT_ERR_NOTFOUND == ft_del_cpuhandle(blob, ph)) { |
| 71 | fdt_del_node(blob, off); |
| 72 | del_cores++; |
| 73 | } |
| 74 | /* either we deleted some cpu handles or the cpu node |
| 75 | * so we reset the offset back to the start since we |
| 76 | * can't trust the offsets anymore |
| 77 | */ |
Poonam Aggrwal | 4ca72ae | 2009-09-02 19:40:36 +0530 | [diff] [blame] | 78 | off = -1; |
| 79 | } |
| 80 | off = fdt_node_offset_by_prop_value(blob, off, |
| 81 | "device_type", "cpu", 4); |
| 82 | } |
| 83 | debug ("%x core system found\n", num_cores); |
| 84 | debug ("deleted %d extra core entry entries from device tree\n", |
| 85 | del_cores); |
| 86 | } |
Kim Phillips | 6578bae | 2010-05-28 08:00:14 +0000 | [diff] [blame] | 87 | #endif /* defined(CONFIG_MPC85xx) || defined(CONFIG_MPC86xx) */ |
| 88 | |
ramneek mehresh | 800c206 | 2012-02-10 00:36:43 +0000 | [diff] [blame] | 89 | #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] | 90 | static int fdt_fixup_usb_mode_phy_type(void *blob, const char *mode, |
| 91 | const char *phy_type, int start_offset) |
Kim Phillips | 6578bae | 2010-05-28 08:00:14 +0000 | [diff] [blame] | 92 | { |
ramneek mehresh | 800c206 | 2012-02-10 00:36:43 +0000 | [diff] [blame] | 93 | const char *compat_dr = "fsl-usb2-dr"; |
| 94 | const char *compat_mph = "fsl-usb2-mph"; |
Kim Phillips | 6578bae | 2010-05-28 08:00:14 +0000 | [diff] [blame] | 95 | const char *prop_mode = "dr_mode"; |
| 96 | const char *prop_type = "phy_type"; |
ramneek mehresh | 800c206 | 2012-02-10 00:36:43 +0000 | [diff] [blame] | 97 | const char *node_type = NULL; |
Kim Phillips | 6578bae | 2010-05-28 08:00:14 +0000 | [diff] [blame] | 98 | int node_offset; |
| 99 | int err; |
| 100 | |
Ramneek Mehresh | 7f548e0 | 2011-06-08 17:14:20 +0530 | [diff] [blame] | 101 | node_offset = fdt_node_offset_by_compatible(blob, |
ramneek mehresh | 800c206 | 2012-02-10 00:36:43 +0000 | [diff] [blame] | 102 | start_offset, compat_mph); |
Kim Phillips | 6578bae | 2010-05-28 08:00:14 +0000 | [diff] [blame] | 103 | if (node_offset < 0) { |
ramneek mehresh | 800c206 | 2012-02-10 00:36:43 +0000 | [diff] [blame] | 104 | node_offset = fdt_node_offset_by_compatible(blob, |
| 105 | start_offset, compat_dr); |
| 106 | if (node_offset < 0) { |
| 107 | printf("WARNING: could not find compatible" |
| 108 | " node %s or %s: %s.\n", compat_mph, |
| 109 | compat_dr, fdt_strerror(node_offset)); |
| 110 | return -1; |
| 111 | } else |
| 112 | node_type = compat_dr; |
| 113 | } else |
| 114 | node_type = compat_mph; |
Kim Phillips | 6578bae | 2010-05-28 08:00:14 +0000 | [diff] [blame] | 115 | |
| 116 | if (mode) { |
| 117 | err = fdt_setprop(blob, node_offset, prop_mode, mode, |
| 118 | strlen(mode) + 1); |
| 119 | if (err < 0) |
| 120 | printf("WARNING: could not set %s for %s: %s.\n", |
ramneek mehresh | 800c206 | 2012-02-10 00:36:43 +0000 | [diff] [blame] | 121 | prop_mode, node_type, fdt_strerror(err)); |
Kim Phillips | 6578bae | 2010-05-28 08:00:14 +0000 | [diff] [blame] | 122 | } |
| 123 | |
Ramneek Mehresh | 7f548e0 | 2011-06-08 17:14:20 +0530 | [diff] [blame] | 124 | if (phy_type) { |
| 125 | err = fdt_setprop(blob, node_offset, prop_type, phy_type, |
| 126 | strlen(phy_type) + 1); |
Kim Phillips | 6578bae | 2010-05-28 08:00:14 +0000 | [diff] [blame] | 127 | if (err < 0) |
| 128 | printf("WARNING: could not set %s for %s: %s.\n", |
ramneek mehresh | 800c206 | 2012-02-10 00:36:43 +0000 | [diff] [blame] | 129 | prop_type, node_type, fdt_strerror(err)); |
Kim Phillips | 6578bae | 2010-05-28 08:00:14 +0000 | [diff] [blame] | 130 | } |
Ramneek Mehresh | 7f548e0 | 2011-06-08 17:14:20 +0530 | [diff] [blame] | 131 | |
Ramneek Mehresh | 8cab6eb | 2011-11-08 13:09:20 +0530 | [diff] [blame] | 132 | return node_offset; |
Ramneek Mehresh | 7f548e0 | 2011-06-08 17:14:20 +0530 | [diff] [blame] | 133 | } |
| 134 | |
| 135 | void fdt_fixup_dr_usb(void *blob, bd_t *bd) |
| 136 | { |
| 137 | const char *modes[] = { "host", "peripheral", "otg" }; |
Ramneek Mehresh | 8cab6eb | 2011-11-08 13:09:20 +0530 | [diff] [blame] | 138 | const char *phys[] = { "ulpi", "utmi" }; |
Ramneek Mehresh | 7f548e0 | 2011-06-08 17:14:20 +0530 | [diff] [blame] | 139 | const char *mode = NULL; |
| 140 | const char *phy_type = NULL; |
| 141 | char usb1_defined = 0; |
Ramneek Mehresh | 8cab6eb | 2011-11-08 13:09:20 +0530 | [diff] [blame] | 142 | int usb_mode_off = -1; |
| 143 | int usb_phy_off = -1; |
Ramneek Mehresh | 7f548e0 | 2011-06-08 17:14:20 +0530 | [diff] [blame] | 144 | char str[5]; |
| 145 | int i, j; |
| 146 | |
Kumar Gala | 3725f55 | 2011-07-29 08:51:26 -0500 | [diff] [blame] | 147 | for (i = 1; i <= FSL_MAX_NUM_USB_CTRLS; i++) { |
Ramneek Mehresh | 7f548e0 | 2011-06-08 17:14:20 +0530 | [diff] [blame] | 148 | int mode_idx = -1, phy_idx = -1; |
ramneek mehresh | 6bce611 | 2012-02-06 19:17:29 +0000 | [diff] [blame] | 149 | snprintf(str, 5, "%s%d", "usb", i); |
Ramneek Mehresh | 7f548e0 | 2011-06-08 17:14:20 +0530 | [diff] [blame] | 150 | if (hwconfig(str)) { |
ramneek mehresh | 6bce611 | 2012-02-06 19:17:29 +0000 | [diff] [blame] | 151 | for (j = 0; j < ARRAY_SIZE(modes); j++) { |
Ramneek Mehresh | 7f548e0 | 2011-06-08 17:14:20 +0530 | [diff] [blame] | 152 | if (hwconfig_subarg_cmp(str, "dr_mode", |
| 153 | modes[j])) { |
| 154 | mode_idx = j; |
| 155 | break; |
| 156 | } |
| 157 | } |
ramneek mehresh | 6bce611 | 2012-02-06 19:17:29 +0000 | [diff] [blame] | 158 | for (j = 0; j < ARRAY_SIZE(phys); j++) { |
Ramneek Mehresh | 7f548e0 | 2011-06-08 17:14:20 +0530 | [diff] [blame] | 159 | if (hwconfig_subarg_cmp(str, "phy_type", |
| 160 | phys[j])) { |
| 161 | phy_idx = j; |
| 162 | break; |
| 163 | } |
| 164 | } |
ramneek mehresh | 6bce611 | 2012-02-06 19:17:29 +0000 | [diff] [blame] | 165 | if (mode_idx >= 0) { |
Ramneek Mehresh | 8cab6eb | 2011-11-08 13:09:20 +0530 | [diff] [blame] | 166 | usb_mode_off = fdt_fixup_usb_mode_phy_type(blob, |
| 167 | modes[mode_idx], NULL, usb_mode_off); |
ramneek mehresh | 6bce611 | 2012-02-06 19:17:29 +0000 | [diff] [blame] | 168 | if (usb_mode_off < 0) |
| 169 | return; |
| 170 | } |
| 171 | if (phy_idx >= 0) { |
Ramneek Mehresh | 8cab6eb | 2011-11-08 13:09:20 +0530 | [diff] [blame] | 172 | usb_phy_off = fdt_fixup_usb_mode_phy_type(blob, |
| 173 | NULL, phys[phy_idx], usb_phy_off); |
ramneek mehresh | 6bce611 | 2012-02-06 19:17:29 +0000 | [diff] [blame] | 174 | if (usb_phy_off < 0) |
| 175 | return; |
| 176 | } |
Ramneek Mehresh | 7f548e0 | 2011-06-08 17:14:20 +0530 | [diff] [blame] | 177 | if (!strcmp(str, "usb1")) |
| 178 | usb1_defined = 1; |
| 179 | if (mode_idx < 0 && phy_idx < 0) |
| 180 | printf("WARNING: invalid phy or mode\n"); |
Ramneek Mehresh | 7f548e0 | 2011-06-08 17:14:20 +0530 | [diff] [blame] | 181 | } |
| 182 | } |
| 183 | if (!usb1_defined) { |
Ramneek Mehresh | 8cab6eb | 2011-11-08 13:09:20 +0530 | [diff] [blame] | 184 | int usb_off = -1; |
Ramneek Mehresh | 7f548e0 | 2011-06-08 17:14:20 +0530 | [diff] [blame] | 185 | mode = getenv("usb_dr_mode"); |
| 186 | phy_type = getenv("usb_phy_type"); |
| 187 | if (!mode && !phy_type) |
| 188 | return; |
Ramneek Mehresh | 8cab6eb | 2011-11-08 13:09:20 +0530 | [diff] [blame] | 189 | fdt_fixup_usb_mode_phy_type(blob, mode, phy_type, usb_off); |
Ramneek Mehresh | 7f548e0 | 2011-06-08 17:14:20 +0530 | [diff] [blame] | 190 | } |
Kim Phillips | 6578bae | 2010-05-28 08:00:14 +0000 | [diff] [blame] | 191 | } |
ramneek mehresh | 800c206 | 2012-02-10 00:36:43 +0000 | [diff] [blame] | 192 | #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] | 193 | |
Kim Phillips | 6578bae | 2010-05-28 08:00:14 +0000 | [diff] [blame] | 194 | /* |
| 195 | * update crypto node properties to a specified revision of the SEC |
Kim Phillips | def125f | 2010-06-01 12:24:27 -0500 | [diff] [blame] | 196 | * called with sec_rev == 0 if not on an E processor |
Kim Phillips | 6578bae | 2010-05-28 08:00:14 +0000 | [diff] [blame] | 197 | */ |
Kim Phillips | def125f | 2010-06-01 12:24:27 -0500 | [diff] [blame] | 198 | #if CONFIG_SYS_FSL_SEC_COMPAT == 2 /* SEC 2.x/3.x */ |
Kim Phillips | 6578bae | 2010-05-28 08:00:14 +0000 | [diff] [blame] | 199 | void fdt_fixup_crypto_node(void *blob, int sec_rev) |
| 200 | { |
| 201 | const struct sec_rev_prop { |
| 202 | u32 sec_rev; |
| 203 | u32 num_channels; |
| 204 | u32 channel_fifo_len; |
| 205 | u32 exec_units_mask; |
| 206 | u32 descriptor_types_mask; |
| 207 | } sec_rev_prop_list [] = { |
| 208 | { 0x0200, 4, 24, 0x07e, 0x01010ebf }, /* SEC 2.0 */ |
| 209 | { 0x0201, 4, 24, 0x0fe, 0x012b0ebf }, /* SEC 2.1 */ |
| 210 | { 0x0202, 1, 24, 0x04c, 0x0122003f }, /* SEC 2.2 */ |
| 211 | { 0x0204, 4, 24, 0x07e, 0x012b0ebf }, /* SEC 2.4 */ |
| 212 | { 0x0300, 4, 24, 0x9fe, 0x03ab0ebf }, /* SEC 3.0 */ |
| 213 | { 0x0301, 4, 24, 0xbfe, 0x03ab0ebf }, /* SEC 3.1 */ |
| 214 | { 0x0303, 4, 24, 0x97c, 0x03a30abf }, /* SEC 3.3 */ |
| 215 | }; |
| 216 | char compat_strlist[ARRAY_SIZE(sec_rev_prop_list) * |
| 217 | sizeof("fsl,secX.Y")]; |
| 218 | int crypto_node, sec_idx, err; |
| 219 | char *p; |
| 220 | u32 val; |
| 221 | |
| 222 | /* locate crypto node based on lowest common compatible */ |
| 223 | crypto_node = fdt_node_offset_by_compatible(blob, -1, "fsl,sec2.0"); |
| 224 | if (crypto_node == -FDT_ERR_NOTFOUND) |
| 225 | return; |
| 226 | |
| 227 | /* delete it if not on an E-processor */ |
| 228 | if (crypto_node > 0 && !sec_rev) { |
| 229 | fdt_del_node(blob, crypto_node); |
| 230 | return; |
| 231 | } |
| 232 | |
| 233 | /* else we got called for possible uprev */ |
| 234 | for (sec_idx = 0; sec_idx < ARRAY_SIZE(sec_rev_prop_list); sec_idx++) |
| 235 | if (sec_rev_prop_list[sec_idx].sec_rev == sec_rev) |
| 236 | break; |
| 237 | |
| 238 | if (sec_idx == ARRAY_SIZE(sec_rev_prop_list)) { |
| 239 | puts("warning: unknown SEC revision number\n"); |
| 240 | return; |
| 241 | } |
| 242 | |
| 243 | val = cpu_to_fdt32(sec_rev_prop_list[sec_idx].num_channels); |
| 244 | err = fdt_setprop(blob, crypto_node, "fsl,num-channels", &val, 4); |
| 245 | if (err < 0) |
| 246 | printf("WARNING: could not set crypto property: %s\n", |
| 247 | fdt_strerror(err)); |
| 248 | |
| 249 | val = cpu_to_fdt32(sec_rev_prop_list[sec_idx].descriptor_types_mask); |
| 250 | err = fdt_setprop(blob, crypto_node, "fsl,descriptor-types-mask", &val, 4); |
| 251 | if (err < 0) |
| 252 | printf("WARNING: could not set crypto property: %s\n", |
| 253 | fdt_strerror(err)); |
| 254 | |
| 255 | val = cpu_to_fdt32(sec_rev_prop_list[sec_idx].exec_units_mask); |
| 256 | err = fdt_setprop(blob, crypto_node, "fsl,exec-units-mask", &val, 4); |
| 257 | if (err < 0) |
| 258 | printf("WARNING: could not set crypto property: %s\n", |
| 259 | fdt_strerror(err)); |
| 260 | |
| 261 | val = cpu_to_fdt32(sec_rev_prop_list[sec_idx].channel_fifo_len); |
| 262 | err = fdt_setprop(blob, crypto_node, "fsl,channel-fifo-len", &val, 4); |
| 263 | if (err < 0) |
| 264 | printf("WARNING: could not set crypto property: %s\n", |
| 265 | fdt_strerror(err)); |
| 266 | |
| 267 | val = 0; |
| 268 | while (sec_idx >= 0) { |
| 269 | p = compat_strlist + val; |
| 270 | val += sprintf(p, "fsl,sec%d.%d", |
| 271 | (sec_rev_prop_list[sec_idx].sec_rev & 0xff00) >> 8, |
| 272 | sec_rev_prop_list[sec_idx].sec_rev & 0x00ff) + 1; |
| 273 | sec_idx--; |
| 274 | } |
| 275 | err = fdt_setprop(blob, crypto_node, "compatible", &compat_strlist, val); |
| 276 | if (err < 0) |
| 277 | printf("WARNING: could not set crypto property: %s\n", |
| 278 | fdt_strerror(err)); |
| 279 | } |
Kim Phillips | 1b62549 | 2010-06-01 12:24:34 -0500 | [diff] [blame] | 280 | #elif CONFIG_SYS_FSL_SEC_COMPAT >= 4 /* SEC4 */ |
| 281 | void fdt_fixup_crypto_node(void *blob, int sec_rev) |
| 282 | { |
| 283 | if (!sec_rev) |
| 284 | fdt_del_node_and_alias(blob, "crypto"); |
| 285 | } |
Kim Phillips | def125f | 2010-06-01 12:24:27 -0500 | [diff] [blame] | 286 | #endif |
Kumar Gala | 6bc9fd5 | 2010-09-30 09:15:03 -0500 | [diff] [blame] | 287 | |
Andy Fleming | 7832a46 | 2011-04-13 00:37:12 -0500 | [diff] [blame] | 288 | 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] | 289 | { |
Kumar Gala | 6bc9fd5 | 2010-09-30 09:15:03 -0500 | [diff] [blame] | 290 | return fdt_setprop_string(blob, offset, "phy-connection-type", |
Andy Fleming | 7832a46 | 2011-04-13 00:37:12 -0500 | [diff] [blame] | 291 | phy_string_for_interface(phyc)); |
Kumar Gala | 6bc9fd5 | 2010-09-30 09:15:03 -0500 | [diff] [blame] | 292 | } |
Kumar Gala | 8975d7a | 2010-12-30 12:09:53 -0600 | [diff] [blame] | 293 | |
| 294 | #ifdef CONFIG_SYS_SRIO |
Kumar Gala | 0e7ccae | 2011-10-14 00:03:58 -0500 | [diff] [blame] | 295 | static inline void ft_disable_srio_port(void *blob, int srio_off, int port) |
| 296 | { |
| 297 | int off = fdt_node_offset_by_prop_value(blob, srio_off, |
| 298 | "cell-index", &port, 4); |
| 299 | if (off >= 0) { |
| 300 | off = fdt_setprop_string(blob, off, "status", "disabled"); |
| 301 | if (off > 0) |
| 302 | printf("WARNING unable to set status for fsl,srio " |
| 303 | "port %d: %s\n", port, fdt_strerror(off)); |
| 304 | } |
| 305 | } |
| 306 | |
| 307 | static inline void ft_disable_rman(void *blob) |
| 308 | { |
| 309 | int off = fdt_node_offset_by_compatible(blob, -1, "fsl,rman"); |
| 310 | if (off >= 0) { |
| 311 | off = fdt_setprop_string(blob, off, "status", "disabled"); |
| 312 | if (off > 0) |
| 313 | printf("WARNING unable to set status for fsl,rman %s\n", |
| 314 | fdt_strerror(off)); |
| 315 | } |
| 316 | } |
| 317 | |
| 318 | static inline void ft_disable_rmu(void *blob) |
| 319 | { |
| 320 | int off = fdt_node_offset_by_compatible(blob, -1, "fsl,srio-rmu"); |
| 321 | if (off >= 0) { |
| 322 | off = fdt_setprop_string(blob, off, "status", "disabled"); |
| 323 | if (off > 0) |
| 324 | printf("WARNING unable to set status for " |
| 325 | "fsl,srio-rmu %s\n", fdt_strerror(off)); |
| 326 | } |
| 327 | } |
| 328 | |
Kumar Gala | 8975d7a | 2010-12-30 12:09:53 -0600 | [diff] [blame] | 329 | void ft_srio_setup(void *blob) |
| 330 | { |
Kumar Gala | 0e7ccae | 2011-10-14 00:03:58 -0500 | [diff] [blame] | 331 | int srio1_used = 0, srio2_used = 0; |
| 332 | int srio_off; |
| 333 | |
| 334 | /* search for srio node, if doesn't exist just return - nothing todo */ |
| 335 | srio_off = fdt_node_offset_by_compatible(blob, -1, "fsl,srio"); |
| 336 | if (srio_off < 0) |
| 337 | return ; |
| 338 | |
Kumar Gala | 8975d7a | 2010-12-30 12:09:53 -0600 | [diff] [blame] | 339 | #ifdef CONFIG_SRIO1 |
Kumar Gala | 0e7ccae | 2011-10-14 00:03:58 -0500 | [diff] [blame] | 340 | if (is_serdes_configured(SRIO1)) |
| 341 | srio1_used = 1; |
Kumar Gala | 8975d7a | 2010-12-30 12:09:53 -0600 | [diff] [blame] | 342 | #endif |
| 343 | #ifdef CONFIG_SRIO2 |
Kumar Gala | 0e7ccae | 2011-10-14 00:03:58 -0500 | [diff] [blame] | 344 | if (is_serdes_configured(SRIO2)) |
| 345 | srio2_used = 1; |
Kumar Gala | 8975d7a | 2010-12-30 12:09:53 -0600 | [diff] [blame] | 346 | #endif |
Kumar Gala | 0e7ccae | 2011-10-14 00:03:58 -0500 | [diff] [blame] | 347 | |
| 348 | /* mark port1 disabled */ |
| 349 | if (!srio1_used) |
| 350 | ft_disable_srio_port(blob, srio_off, 1); |
| 351 | |
| 352 | /* mark port2 disabled */ |
| 353 | if (!srio2_used) |
| 354 | ft_disable_srio_port(blob, srio_off, 2); |
| 355 | |
| 356 | /* if both ports not used, disable controller, rmu and rman */ |
| 357 | if (!srio1_used && !srio2_used) { |
| 358 | fdt_setprop_string(blob, srio_off, "status", "disabled"); |
| 359 | |
| 360 | ft_disable_rman(blob); |
| 361 | ft_disable_rmu(blob); |
| 362 | } |
Kumar Gala | 8975d7a | 2010-12-30 12:09:53 -0600 | [diff] [blame] | 363 | } |
| 364 | #endif |