Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 202e9ebf authored by Xiaocheng Li's avatar Xiaocheng Li
Browse files

of/address: Add new API of_iomap_by_name and of_get_address_by_name



Create new API of_iomap_by_name and of_get_address_by_name, which
would read "reg-names" property and get the reg address by its
name.

Change-Id: I7ce30da5a7cbc29f8349641af97ac7ed16b4f506
Signed-off-by: default avatarXiaocheng Li <lix@codeaurora.org>
parent a65cf5a3
Loading
Loading
Loading
Loading
+32 −0
Original line number Original line Diff line number Diff line
@@ -552,6 +552,22 @@ const __be32 *of_get_address(struct device_node *dev, int index, u64 *size,
}
}
EXPORT_SYMBOL(of_get_address);
EXPORT_SYMBOL(of_get_address);


const __be32 *of_get_address_by_name(struct device_node *dev, const char *name,
		u64 *size, unsigned int *flags)
{
	int index;
	if (!name)
		return NULL;

	/* Try to read "reg-names" property and get the index by name */
	index = of_property_match_string(dev, "reg-names", name);
	if (index < 0)
		return NULL;

	return of_get_address(dev, index, size, flags);
}
EXPORT_SYMBOL(of_get_address_by_name);

static int __of_address_to_resource(struct device_node *dev,
static int __of_address_to_resource(struct device_node *dev,
		const __be32 *addrp, u64 size, unsigned int flags,
		const __be32 *addrp, u64 size, unsigned int flags,
		const char *name, struct resource *r)
		const char *name, struct resource *r)
@@ -644,3 +660,19 @@ void __iomem *of_iomap(struct device_node *np, int index)
	return ioremap(res.start, resource_size(&res));
	return ioremap(res.start, resource_size(&res));
}
}
EXPORT_SYMBOL(of_iomap);
EXPORT_SYMBOL(of_iomap);

void __iomem *of_iomap_by_name(struct device_node *np, const char *name)
{
	int index;

	if (!name)
		return NULL;

	/* Try to read "reg-names" property and get the index by name */
	index = of_property_match_string(np, "reg-names", name);
	if (index < 0)
		return NULL;

	return of_iomap(np, index);
}
EXPORT_SYMBOL(of_iomap_by_name);
+4 −0
Original line number Original line Diff line number Diff line
@@ -14,6 +14,8 @@ extern struct device_node *of_find_matching_node_by_address(
					const struct of_device_id *matches,
					const struct of_device_id *matches,
					u64 base_address);
					u64 base_address);
extern void __iomem *of_iomap(struct device_node *device, int index);
extern void __iomem *of_iomap(struct device_node *device, int index);
extern void __iomem *of_iomap_by_name(struct device_node *device,
					const char *name);


/* Extract an address from a device, returns the region size and
/* Extract an address from a device, returns the region size and
 * the address space flags too. The PCI version uses a BAR number
 * the address space flags too. The PCI version uses a BAR number
@@ -21,6 +23,8 @@ extern void __iomem *of_iomap(struct device_node *device, int index);
 */
 */
extern const __be32 *of_get_address(struct device_node *dev, int index,
extern const __be32 *of_get_address(struct device_node *dev, int index,
			   u64 *size, unsigned int *flags);
			   u64 *size, unsigned int *flags);
extern const __be32 *of_get_address_by_name(struct device_node *dev,
			   const char *name, u64 *size, unsigned int *flags);


#ifndef pci_address_to_pio
#ifndef pci_address_to_pio
static inline unsigned long pci_address_to_pio(phys_addr_t addr) { return -1; }
static inline unsigned long pci_address_to_pio(phys_addr_t addr) { return -1; }