예제 #1
0
static int atmel_qspi_ofdata_to_platdata(struct udevice *dev)
{
	struct atmel_qspi_platdata *plat = dev_get_platdata(dev);
	const void *blob = gd->fdt_blob;
	int node = dev->of_offset;
	u32 data[4];
	int ret, seq;

	ret = fdtdec_get_int_array(blob, node, "reg", data, ARRAY_SIZE(data));
	if (ret) {
		printf("Error: Can't get base addresses (ret=%d)!\n", ret);
		return -ENODEV;
	}
	plat->regbase = (void *)data[0];
	plat->membase = (void *)data[2];

	ret = fdtdec_get_alias_seq(blob, "spi", node, &seq);
	if (ret) {
		printf("Error: Can't get device ID (ret=%d)!\n", ret);
		return -ENODEV;
	}
	plat->dev_id = (unsigned int)seq;

	return 0;
}
예제 #2
0
int dev_read_alias_seq(struct udevice *dev, int *devnump)
{
	ofnode node = dev_ofnode(dev);
	const char *uc_name = dev->uclass->uc_drv->name;
	int ret;

	if (ofnode_is_np(node)) {
		ret = of_alias_get_id(ofnode_to_np(node), uc_name);
		if (ret >= 0)
			*devnump = ret;
	} else {
		ret = fdtdec_get_alias_seq(gd->fdt_blob, uc_name,
					   ofnode_to_offset(node), devnump);
	}

	return ret;
}