Пример #1
0
void fdt_fsl_mc_fixup_iommu_map_entry(void *blob)
{
	u32 *prop;
	u32 iommu_map[4];
	int offset;
	int lenp;

	/* find fsl-mc node */
	offset = fdt_path_offset(blob, "/soc/fsl-mc");
	if (offset < 0)
		offset = fdt_path_offset(blob, "/fsl-mc");
	if (offset < 0) {
		printf("%s: fsl-mc: ERR: fsl-mc node not found in DT, err %d\n",
		       __func__, offset);
		return;
	}

	prop = fdt_getprop_w(blob, offset, "iommu-map", &lenp);
	if (!prop) {
		debug("%s: fsl-mc: ERR: missing iommu-map in fsl-mc bus node\n",
		      __func__);
		return;
	}

	iommu_map[0] = cpu_to_fdt32(FSL_DPAA2_STREAM_ID_START);
	iommu_map[1] = *++prop;
	iommu_map[2] = cpu_to_fdt32(FSL_DPAA2_STREAM_ID_START);
	iommu_map[3] = cpu_to_fdt32(FSL_DPAA2_STREAM_ID_END -
		FSL_DPAA2_STREAM_ID_START + 1);

	fdt_setprop_inplace(blob, offset, "iommu-map",
			    iommu_map, sizeof(iommu_map));
}
Пример #2
0
/* Set the value of a property of a package. */
static int
ofw_fdt_setprop(ofw_t ofw, phandle_t package, const char *propname,
    const void *buf, size_t len)
{
	int offset;

	offset = fdt_phandle_offset(package);
	if (offset < 0)
		return (-1);

	return (fdt_setprop_inplace(fdtp, offset, propname, buf, len));
}
Пример #3
0
/**
 * Fix-up the kernel device tree so the bridge pd_n and rst_n gpios accurately
 * reflect the current board rev.
 */
static void ft_board_setup_gpios(void *blob, bd_t *bd)
{
	int ret, rev, np, len;
	const struct fdt_property *prop;

	/* Do nothing for newer boards */
	rev = board_get_revision();
	if (rev < 4 || rev == 6)
		return;

	/*
	 * If this is an older board, replace powerdown-gpio contents with that
	 * of reset-gpio and delete reset-gpio from the dt.
	 */
	np = fdtdec_next_compatible(blob, 0, COMPAT_NXP_PTN3460);
	if (np < 0) {
		debug("%s: Could not find COMPAT_NXP_PTN3460\n", __func__);
		return;
	}

	prop = fdt_get_property(blob, np, "reset-gpio", &len);
	if (!prop) {
		debug("%s: Could not get property err=%d\n", __func__, len);
		return;
	}

	ret = fdt_setprop_inplace(blob, np, "powerdown-gpio", prop->data,
			len);
	if (ret) {
		debug("%s: Could not setprop inplace err=%d\n", __func__, ret);
		return;
	}

	ret = fdt_delprop(blob, np, "reset-gpio");
	if (ret) {
		debug("%s: Could not delprop err=%d\n", __func__, ret);
		return;
	}
}
Пример #4
0
void update_partial_goods_dtb_nodes(void *fdt)
{
	int i;
	int tbl_sz = sizeof(table) / sizeof(struct partial_goods);
	int parent_offset = 0;
	int subnode_offset = 0;
	int ret = 0;
	int prop_len = 0;
	uint32_t reg = readl(QFPROM_PTE_PART_ADDR);
	uint32_t prop_type = 0;
	struct subnode_list *subnode_lst = NULL;
	const struct fdt_property *prop = NULL;
	const char *replace_str = NULL;

	/*
	 * The PTE register bits 23 to 27 have the partial goods
	 * info, extract the partial goods value before using
	 */
	reg = (reg & 0x0f800000) >> 23;

	/* If none of the DTB needs update */
	if (!reg)
		return;

	ret = fdt_open_into(fdt, fdt, fdt_totalsize(fdt));
	if (ret != 0)
	{
		dprintf(CRITICAL, "Failed to move/resize dtb buffer: %d\n", ret);
		ASSERT(0);
	}

	for (i = 0; i < tbl_sz; i++)
	{
		if (reg == table[i].val)
		{
			/* Find the Parent node */
			ret = fdt_path_offset(fdt, table[i].parent_node);
			if (ret < 0)
			{
				dprintf(CRITICAL, "Failed to get parent node: %s\terrno:%d\n", table[i].parent_node, ret);
				ASSERT(0);
			}
			parent_offset = ret;

			/* Find the subnode */
			subnode_lst = table[i].subnode;

			while (subnode_lst->subnode)
			{
				ret = fdt_subnode_offset(fdt, parent_offset, subnode_lst->subnode);
				if (ret < 0)
				{
					dprintf(CRITICAL, "Failed to get subnode: %s\terrno:%d\n", subnode_lst->subnode, ret);
					ASSERT(0);
				}
				subnode_offset = ret;

				/* Find the property node and its length */
				prop = fdt_get_property(fdt, subnode_offset, subnode_lst->property, &prop_len);
				if (!prop)
				{
					dprintf(CRITICAL, "Failed to get property: %s\terrno: %d\n", subnode_lst->property, prop_len);
					ASSERT(0);
				}

				/*
				 * Replace the property value based on the property
				 * length and type
				 */
				if (!(strncmp(subnode_lst->property, "device_type", sizeof(subnode_lst->property))))
					prop_type = DEVICE_TYPE;
				else if ((!strncmp(subnode_lst->property, "status", sizeof(subnode_lst->property))))
					prop_type = STATUS_TYPE;
				else
				{
					dprintf(CRITICAL, "%s: Property type is not supported\n", subnode_lst->property);
					ASSERT(0);
				}

				switch (prop_type)
				{
					case DEVICE_TYPE:
						replace_str = "nak";
						break;
					case STATUS_TYPE:
						if (prop_len == sizeof("ok"))
							replace_str = "no";
						else if (prop_len == sizeof("okay"))
							replace_str = "dsbl";
						else
						{
							dprintf(CRITICAL, "Property value length: %u is invalid for property: %s\n", prop_len, subnode_lst->property);
							ASSERT(0);
						}
						break;
					default:
						/* Control would not come here, as this gets taken care while setting property type */
						break;
				};

				/* Replace the property with new value */
				ret = fdt_setprop_inplace(fdt, subnode_offset, subnode_lst->property, (const void *)replace_str, prop_len);
				if (!ret)
					dprintf(INFO, "Updated device tree property: %s @ %s node\n", subnode_lst->property, subnode_lst->subnode);
				else
				{
					dprintf(CRITICAL, "Failed to update property: %s: error no: %d\n", subnode_lst->property, ret);
					ASSERT(0);
				}

				subnode_lst++;
			}
		}
	}

	fdt_pack(fdt);
}