drivers/of/property.c

Source file repositories/reference/linux-study-clean/drivers/of/property.c

File Facts

System
Linux kernel
Corpus path
drivers/of/property.c
Extension
.c
Size
50087 bytes
Lines
1705
Domain
Driver Families
Bucket
drivers/of
Inferred role
Driver Families: exported/initcall integration point
Status
integration implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

struct supplier_bindings {
	struct device_node *(*parse_prop)(struct device_node *np,
					  const char *prop_name, int index);
	struct device_node *(*get_con_dev)(struct device_node *np);
	bool optional;
	u8 fwlink_flags;
};

DEFINE_SIMPLE_PROP(clocks, "clocks", "#clock-cells")
DEFINE_SIMPLE_PROP(interconnects, "interconnects", "#interconnect-cells")
DEFINE_SIMPLE_PROP(iommus, "iommus", "#iommu-cells")
DEFINE_SIMPLE_PROP(mboxes, "mboxes", "#mbox-cells")
DEFINE_SIMPLE_PROP(io_channels, "io-channels", "#io-channel-cells")
DEFINE_SIMPLE_PROP(io_backends, "io-backends", "#io-backend-cells")
DEFINE_SIMPLE_PROP(dmas, "dmas", "#dma-cells")
DEFINE_SIMPLE_PROP(power_domains, "power-domains", "#power-domain-cells")
DEFINE_SIMPLE_PROP(hwlocks, "hwlocks", "#hwlock-cells")
DEFINE_SIMPLE_PROP(extcon, "extcon", NULL)
DEFINE_SIMPLE_PROP(nvmem_cells, "nvmem-cells", "#nvmem-cell-cells")
DEFINE_SIMPLE_PROP(phys, "phys", "#phy-cells")
DEFINE_SIMPLE_PROP(wakeup_parent, "wakeup-parent", NULL)
DEFINE_SIMPLE_PROP(pwms, "pwms", "#pwm-cells")
DEFINE_SIMPLE_PROP(resets, "resets", "#reset-cells")
DEFINE_SIMPLE_PROP(leds, "leds", NULL)
DEFINE_SIMPLE_PROP(backlight, "backlight", NULL)
DEFINE_SIMPLE_PROP(panel, "panel", NULL)
DEFINE_SIMPLE_PROP(msi_parent, "msi-parent", "#msi-cells")
DEFINE_SIMPLE_PROP(post_init_providers, "post-init-providers", NULL)
DEFINE_SIMPLE_PROP(access_controllers, "access-controllers", "#access-controller-cells")
DEFINE_SIMPLE_PROP(pses, "pses", "#pse-cells")
DEFINE_SIMPLE_PROP(power_supplies, "power-supplies", NULL)
DEFINE_SIMPLE_PROP(mmc_pwrseq, "mmc-pwrseq", NULL)
DEFINE_SUFFIX_PROP(regulators, "-supply", NULL)
DEFINE_SUFFIX_PROP(gpio, "-gpio", "#gpio-cells")

static struct device_node *parse_pinctrl_n(struct device_node *np,
					   const char *prop_name, int index)
{
	if (!strstarts(prop_name, "pinctrl-"))
		return NULL;

	if (!isdigit(prop_name[strlen("pinctrl-")]))
		return NULL;

	return of_parse_phandle(np, prop_name, index);
}

static struct device_node *parse_gpios(struct device_node *np,
				       const char *prop_name, int index)
{
	if (strends(prop_name, ",nr-gpios"))
		return NULL;

	return parse_suffix_prop_cells(np, prop_name, index, "-gpios",
				       "#gpio-cells");
}

static struct device_node *parse_iommu_maps(struct device_node *np,
					    const char *prop_name, int index)
{
	if (strcmp(prop_name, "iommu-map"))
		return NULL;

	return of_parse_phandle(np, prop_name, (index * 4) + 1);
}

static struct device_node *parse_gpio_compat(struct device_node *np,
					     const char *prop_name, int index)
{
	struct of_phandle_args sup_args;

	if (strcmp(prop_name, "gpio") && strcmp(prop_name, "gpios"))
		return NULL;

	/*
	 * Ignore node with gpio-hog property since its gpios are all provided
	 * by its parent.
	 */
	if (of_property_read_bool(np, "gpio-hog"))
		return NULL;

	if (of_parse_phandle_with_args(np, prop_name, "#gpio-cells", index,
				       &sup_args))
		return NULL;

	return sup_args.np;
}

static struct device_node *parse_interrupts(struct device_node *np,
					    const char *prop_name, int index)

Annotation

Implementation Notes