コード例 #1
0
ファイル: syscon-uclass.c プロジェクト: Noltari/u-boot
struct regmap *syscon_regmap_lookup_by_phandle(struct udevice *dev,
					       const char *name)
{
	struct udevice *syscon;
	struct regmap *r;
	u32 phandle;
	ofnode node;
	int err;

	err = uclass_get_device_by_phandle(UCLASS_SYSCON, dev,
					   name, &syscon);
	if (err) {
		/* found node with "syscon" compatible, not bounded to SYSCON */
		err = ofnode_read_u32(dev_ofnode(dev), name, &phandle);
		if (err)
			return ERR_PTR(err);

		node = ofnode_get_by_phandle(phandle);
		if (!ofnode_valid(node)) {
			dev_dbg(dev, "unable to find syscon device\n");
			return ERR_PTR(-EINVAL);
		}
		err = syscon_probe_by_ofnode(node, &syscon);
		if (err)
			return ERR_PTR(-ENODEV);
	}

	r = syscon_get_regmap(syscon);
	if (!r) {
		dev_dbg(dev, "unable to find regmap\n");
		return ERR_PTR(-ENODEV);
	}

	return r;
}
コード例 #2
0
ファイル: i2c-uclass.c プロジェクト: Noltari/u-boot
static int i2c_pre_probe(struct udevice *dev)
{
#if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)
	struct dm_i2c_bus *i2c = dev_get_uclass_priv(dev);
	unsigned int max = 0;
	ofnode node;
	int ret;

	i2c->max_transaction_bytes = 0;
	dev_for_each_subnode(node, dev) {
		ret = ofnode_read_u32(node,
				      "u-boot,i2c-transaction-bytes",
				      &max);
		if (!ret && max > i2c->max_transaction_bytes)
			i2c->max_transaction_bytes = max;
	}
コード例 #3
0
int dev_read_u32(struct udevice *dev, const char *propname, u32 *outp)
{
	return ofnode_read_u32(dev_ofnode(dev), propname, outp);
}