2 * Copyright 2008-2011 Freescale Semiconductor, Inc.
4 * See file CREDITS for list of people who contributed to this
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of
10 * the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
25 #include <fdt_support.h>
27 #include <asm/processor.h>
30 #include <asm/fsl_portals.h>
31 #include <asm/fsl_liodn.h>
33 static ccsr_qman_t *qman = (void *)CONFIG_SYS_FSL_QMAN_ADDR;
35 void setup_portals(void)
37 #ifdef CONFIG_FSL_CORENET
40 for (i = 0; i < CONFIG_SYS_QMAN_NUM_PORTALS; i++) {
41 u8 sdest = qp_info[i].sdest;
42 u16 fliodn = qp_info[i].fliodn;
43 u16 dliodn = qp_info[i].dliodn;
44 u16 liodn_off = qp_info[i].liodn_offset;
46 out_be32(&qman->qcsp[i].qcsp_lio_cfg, (liodn_off << 16) |
49 out_be32(&qman->qcsp[i].qcsp_io_cfg, (sdest << 16) | fliodn);
53 /* Set the Qman initiator BAR to match the LAW (for DQRR stashing) */
54 #ifdef CONFIG_PHYS_64BIT
55 out_be32(&qman->qcsp_bare, (u32)(CONFIG_SYS_QMAN_MEM_PHYS >> 32));
57 out_be32(&qman->qcsp_bar, (u32)CONFIG_SYS_QMAN_MEM_PHYS);
60 /* Update portal containter to match LAW setup of portal in phy map */
61 void fdt_portal(void *blob, const char *compat, const char *container,
66 off = fdt_node_offset_by_compatible(blob, -1, compat);
70 off = fdt_parent_offset(blob, off);
71 /* if non-zero assume we have a container */
79 range = fdt_getprop_w(blob, off, "ranges", &len);
81 printf("ERROR: container for %s has no ranges", compat);
87 range[1] = addr >> 32;
88 range[2] = addr & 0xffffffff;
91 range[1] = addr & 0xffffffff;
94 fdt_setprop_inplace(blob, off, "ranges", range, len);
97 name = fdt_get_name(blob, off, &len);
98 p = memchr(name, '@', len);
103 /* if we are given a container name check it
104 * against what we found, if it doesnt match exit out */
105 if (container && (memcmp(container, name, len))) {
106 printf("WARNING: container names didn't match %s %s\n",
111 memcpy(&buf, name, len);
112 len += sprintf(&buf[len], "@%llx", addr);
113 fdt_set_name(blob, off, buf);
117 printf("ERROR: %s isn't in a container. Not supported\n", compat);
120 static int fdt_qportal(void *blob, int off, int id, char *name,
121 enum fsl_dpaa_dev dev, int create)
123 int childoff, dev_off, ret = 0;
125 #ifdef CONFIG_FSL_CORENET
130 childoff = fdt_subnode_offset(blob, off, name);
133 childoff = fdt_add_subnode(blob, off, name);
138 strncpy(handle, name, sizeof(handle));
139 p = strchr(handle, '@');
140 if (!strncmp(name, "fman", 4)) {
146 dev_off = fdt_path_offset(blob, handle);
150 dev_handle = fdt_get_phandle(blob, dev_off);
151 if (dev_handle <= 0) {
152 dev_handle = fdt_alloc_phandle(blob);
153 fdt_setprop_cell(blob, dev_off,
154 "linux,phandle", dev_handle);
157 ret = fdt_setprop(blob, childoff, "dev-handle",
158 &dev_handle, sizeof(dev_handle));
162 #ifdef CONFIG_FSL_CORENET
163 num = get_dpaa_liodn(dev, &liodns[0], id);
164 ret = fdt_setprop(blob, childoff, "fsl,liodn",
165 &liodns[0], sizeof(u32) * num);
172 ret = fdt_del_node(blob, childoff);
178 void fdt_fixup_qportals(void *blob)
181 unsigned int maj, min;
182 u32 rev_1 = in_be32(&qman->ip_rev_1);
186 maj = (rev_1 >> 8) & 0xff;
189 compat_len = sprintf(compat, "fsl,qman-portal-%u.%u", maj, min) + 1;
190 compat_len += sprintf(compat + compat_len, "fsl,qman-portal") + 1;
192 off = fdt_node_offset_by_compatible(blob, -1, "fsl,qman-portal");
193 while (off != -FDT_ERR_NOTFOUND) {
194 #ifdef CONFIG_FSL_CORENET
197 const int *ci = fdt_getprop(blob, off, "cell-index", NULL);
200 err = fdt_setprop(blob, off, "compatible", compat, compat_len);
204 #ifdef CONFIG_FSL_CORENET
205 liodns[0] = qp_info[i].dliodn;
206 liodns[1] = qp_info[i].fliodn;
208 err = fdt_setprop(blob, off, "fsl,liodn",
209 &liodns, sizeof(u32) * 2);
216 err = fdt_qportal(blob, off, i, "crypto@0", FSL_HW_PORTAL_SEC,
217 IS_E_PROCESSOR(get_svr()));
221 #ifdef CONFIG_FSL_CORENET
222 #ifdef CONFIG_SYS_DPAA_PME
223 err = fdt_qportal(blob, off, i, "pme@0", FSL_HW_PORTAL_PME, 1);
227 fdt_qportal(blob, off, i, "pme@0", FSL_HW_PORTAL_PME, 0);
231 #ifdef CONFIG_SYS_DPAA_FMAN
232 for (j = 0; j < CONFIG_SYS_NUM_FMAN; j++) {
233 char name[] = "fman@0";
235 name[sizeof(name) - 2] = '0' + j;
236 err = fdt_qportal(blob, off, i, name,
237 FSL_HW_PORTAL_FMAN1 + j, 1);
245 printf("ERROR: unable to create props for %s: %s\n",
246 fdt_get_name(blob, off, NULL), fdt_strerror(err));
250 off = fdt_node_offset_by_compatible(blob, off, "fsl,qman-portal");