diff options
Diffstat (limited to 'drivers/of')
-rw-r--r-- | drivers/of/Kconfig | 19 | ||||
-rw-r--r-- | drivers/of/Makefile | 3 | ||||
-rw-r--r-- | drivers/of/base.c | 34 | ||||
-rw-r--r-- | drivers/of/device.c | 12 | ||||
-rw-r--r-- | drivers/of/fdt.c | 41 | ||||
-rw-r--r-- | drivers/of/irq.c | 9 | ||||
-rw-r--r-- | drivers/of/of_mdio.c | 3 | ||||
-rw-r--r-- | drivers/of/overlay.c | 6 | ||||
-rw-r--r-- | drivers/of/platform.c | 1 | ||||
-rw-r--r-- | drivers/of/unittest.c | 3 |
10 files changed, 101 insertions, 30 deletions
diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig index 07bb3c8f1..59bb8556e 100644 --- a/drivers/of/Kconfig +++ b/drivers/of/Kconfig @@ -1,15 +1,20 @@ config DTC bool -config OF - bool +menuconfig OF + bool "Device Tree and Open Firmware support" + help + This option enables the device tree infrastructure. + It is automatically selected by platforms that need it or can + be enabled manually for unittests, overlays or + compile-coverage. -menu "Device Tree and Open Firmware support" - depends on OF +if OF config OF_UNITTEST bool "Device Tree runtime unit tests" - depends on OF_IRQ && OF_EARLY_FLATTREE + depends on OF_IRQ + select OF_EARLY_FLATTREE select OF_RESOLVE help This option builds in test cases for the device tree infrastructure @@ -42,7 +47,7 @@ config OF_DYNAMIC config OF_ADDRESS def_bool y - depends on !SPARC + depends on !SPARC && HAS_IOMEM select OF_ADDRESS_PCI if PCI config OF_ADDRESS_PCI @@ -97,4 +102,4 @@ config OF_OVERLAY While this option is selected automatically when needed, you can enable it manually to improve device tree unit test coverage. -endmenu # OF +endif # OF diff --git a/drivers/of/Makefile b/drivers/of/Makefile index fcacb186a..156c072b3 100644 --- a/drivers/of/Makefile +++ b/drivers/of/Makefile @@ -16,6 +16,3 @@ obj-$(CONFIG_OF_RESOLVE) += resolver.o obj-$(CONFIG_OF_OVERLAY) += overlay.o obj-$(CONFIG_OF_UNITTEST) += unittest-data/ - -CFLAGS_fdt.o = -I$(src)/../../scripts/dtc/libfdt -CFLAGS_fdt_address.o = -I$(src)/../../scripts/dtc/libfdt diff --git a/drivers/of/base.c b/drivers/of/base.c index 5ed97246c..8b5a187a7 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -2231,6 +2231,40 @@ struct device_node *of_graph_get_next_endpoint(const struct device_node *parent, EXPORT_SYMBOL(of_graph_get_next_endpoint); /** + * of_graph_get_endpoint_by_regs() - get endpoint node of specific identifiers + * @parent: pointer to the parent device node + * @port_reg: identifier (value of reg property) of the parent port node + * @reg: identifier (value of reg property) of the endpoint node + * + * Return: An 'endpoint' node pointer which is identified by reg and at the same + * is the child of a port node identified by port_reg. reg and port_reg are + * ignored when they are -1. + */ +struct device_node *of_graph_get_endpoint_by_regs( + const struct device_node *parent, int port_reg, int reg) +{ + struct of_endpoint endpoint; + struct device_node *node, *prev_node = NULL; + + while (1) { + node = of_graph_get_next_endpoint(parent, prev_node); + of_node_put(prev_node); + if (!node) + break; + + of_graph_parse_endpoint(node, &endpoint); + if (((port_reg == -1) || (endpoint.port == port_reg)) && + ((reg == -1) || (endpoint.id == reg))) + return node; + + prev_node = node; + } + + return NULL; +} +EXPORT_SYMBOL(of_graph_get_endpoint_by_regs); + +/** * of_graph_get_remote_port_parent() - get remote port's parent node * @node: pointer to a local endpoint device_node * diff --git a/drivers/of/device.c b/drivers/of/device.c index 20c1332a0..8b91ea241 100644 --- a/drivers/of/device.c +++ b/drivers/of/device.c @@ -163,6 +163,18 @@ void of_device_unregister(struct platform_device *ofdev) } EXPORT_SYMBOL(of_device_unregister); +const void *of_device_get_match_data(const struct device *dev) +{ + const struct of_device_id *match; + + match = of_match_device(dev->driver->of_match_table, dev); + if (!match) + return NULL; + + return match->data; +} +EXPORT_SYMBOL(of_device_get_match_data); + ssize_t of_device_get_modalias(struct device *dev, char *str, ssize_t len) { const char *compat; diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index cde35c5d0..07496560e 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -164,11 +164,14 @@ static void *unflatten_dt_alloc(void **mem, unsigned long size, * unflatten_dt_node - Alloc and populate a device_node from the flat tree * @blob: The parent device tree blob * @mem: Memory chunk to use for allocating device nodes and properties - * @p: pointer to node in flat tree + * @poffset: pointer to node in flat tree * @dad: Parent struct device_node + * @nodepp: The device_node tree created by the call * @fpsize: Size of the node path up at the current depth. + * @dryrun: If true, do not allocate device nodes but still calculate needed + * memory size */ -static void * unflatten_dt_node(void *blob, +static void * unflatten_dt_node(const void *blob, void *mem, int *poffset, struct device_node *dad, @@ -378,7 +381,7 @@ static void * unflatten_dt_node(void *blob, * @dt_alloc: An allocator that provides a virtual address to memory * for the resulting tree */ -static void __unflatten_device_tree(void *blob, +static void __unflatten_device_tree(const void *blob, struct device_node **mynodes, void * (*dt_alloc)(u64 size, u64 align)) { @@ -441,7 +444,7 @@ static void *kernel_tree_alloc(u64 size, u64 align) * pointers of the nodes so the normal device-tree walking functions * can be used. */ -void of_fdt_unflatten_tree(unsigned long *blob, +void of_fdt_unflatten_tree(const unsigned long *blob, struct device_node **mynodes) { __unflatten_device_tree(blob, mynodes, &kernel_tree_alloc); @@ -580,11 +583,6 @@ void __init early_init_fdt_scan_reserved_mem(void) if (!initial_boot_params) return; - /* Reserve the dtb region */ - early_init_dt_reserve_memory_arch(__pa(initial_boot_params), - fdt_totalsize(initial_boot_params), - 0); - /* Process header /memreserve/ fields */ for (n = 0; ; n++) { fdt_get_mem_rsv(initial_boot_params, n, &base, &size); @@ -598,6 +596,20 @@ void __init early_init_fdt_scan_reserved_mem(void) } /** + * early_init_fdt_reserve_self() - reserve the memory used by the FDT blob + */ +void __init early_init_fdt_reserve_self(void) +{ + if (!initial_boot_params) + return; + + /* Reserve the dtb region */ + early_init_dt_reserve_memory_arch(__pa(initial_boot_params), + fdt_totalsize(initial_boot_params), + 0); +} + +/** * of_scan_flat_dt - scan flattened tree blob and call callback on each. * @it: callback function * @data: context data pointer @@ -1015,6 +1027,11 @@ void * __init __weak early_init_dt_alloc_memory_arch(u64 size, u64 align) return __va(memblock_alloc(size, align)); } #else +void __init __weak early_init_dt_add_memory_arch(u64 base, u64 size) +{ + WARN_ON(1); +} + int __init __weak early_init_dt_reserve_memory_arch(phys_addr_t base, phys_addr_t size, bool nomap) { @@ -1022,6 +1039,12 @@ int __init __weak early_init_dt_reserve_memory_arch(phys_addr_t base, &base, &size, nomap ? " (nomap)" : ""); return -ENOSYS; } + +void * __init __weak early_init_dt_alloc_memory_arch(u64 size, u64 align) +{ + WARN_ON(1); + return NULL; +} #endif bool __init early_init_dt_verify(void *params) diff --git a/drivers/of/irq.c b/drivers/of/irq.c index 1a7980692..3cf7a01f5 100644 --- a/drivers/of/irq.c +++ b/drivers/of/irq.c @@ -252,8 +252,6 @@ int of_irq_parse_raw(const __be32 *addr, struct of_phandle_args *out_irq) * Successfully parsed an interrrupt-map translation; copy new * interrupt specifier into the out_irq structure */ - out_irq->np = newpar; - match_array = imap - newaddrsize - newintsize; for (i = 0; i < newintsize; i++) out_irq->args[i] = be32_to_cpup(imap - newintsize + i); @@ -262,6 +260,7 @@ int of_irq_parse_raw(const __be32 *addr, struct of_phandle_args *out_irq) skiplevel: /* Iterate again with new parent */ + out_irq->np = newpar; pr_debug(" -> new parent: %s\n", of_node_full_name(newpar)); of_node_put(ipar); ipar = newpar; @@ -469,7 +468,7 @@ int of_irq_to_resource_table(struct device_node *dev, struct resource *res, } EXPORT_SYMBOL_GPL(of_irq_to_resource_table); -struct intc_desc { +struct of_intc_desc { struct list_head list; struct device_node *dev; struct device_node *interrupt_parent; @@ -485,7 +484,7 @@ struct intc_desc { void __init of_irq_init(const struct of_device_id *matches) { struct device_node *np, *parent = NULL; - struct intc_desc *desc, *temp_desc; + struct of_intc_desc *desc, *temp_desc; struct list_head intc_desc_list, intc_parent_list; INIT_LIST_HEAD(&intc_desc_list); @@ -496,7 +495,7 @@ void __init of_irq_init(const struct of_device_id *matches) !of_device_is_available(np)) continue; /* - * Here, we allocate and populate an intc_desc with the node + * Here, we allocate and populate an of_intc_desc with the node * pointer, interrupt-parent device_node etc. */ desc = kzalloc(sizeof(*desc), GFP_KERNEL); diff --git a/drivers/of/of_mdio.c b/drivers/of/of_mdio.c index 0c064485d..fdc60db60 100644 --- a/drivers/of/of_mdio.c +++ b/drivers/of/of_mdio.c @@ -68,6 +68,9 @@ static int of_mdiobus_register_phy(struct mii_bus *mdio, struct device_node *chi phy->irq = mdio->irq[addr]; } + if (of_property_read_bool(child, "broken-turn-around")) + mdio->phy_ignore_ta_mask |= 1 << addr; + /* Associate the OF node with the device structure so it * can be looked up later */ of_node_get(child); diff --git a/drivers/of/overlay.c b/drivers/of/overlay.c index dee9270ba..24e025f79 100644 --- a/drivers/of/overlay.c +++ b/drivers/of/overlay.c @@ -333,7 +333,7 @@ static DEFINE_IDR(ov_idr); * of the overlay in a list. This list can be used to prevent * illegal overlay removals. * - * Returns the id of the created overlay, or an negative error number + * Returns the id of the created overlay, or a negative error number */ int of_overlay_create(struct device_node *tree) { @@ -481,7 +481,7 @@ static int overlay_removal_is_ok(struct of_overlay *ov) * * Removes an overlay if it is permissible. * - * Returns 0 on success, or an negative error number + * Returns 0 on success, or a negative error number */ int of_overlay_destroy(int id) { @@ -528,7 +528,7 @@ EXPORT_SYMBOL_GPL(of_overlay_destroy); * * Removes all overlays from the system in the correct order. * - * Returns 0 on success, or an negative error number + * Returns 0 on success, or a negative error number */ int of_overlay_destroy_all(void) { diff --git a/drivers/of/platform.c b/drivers/of/platform.c index a01f57c9e..ddf8e42c9 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c @@ -25,6 +25,7 @@ const struct of_device_id of_default_bus_match_table[] = { { .compatible = "simple-bus", }, + { .compatible = "simple-mfd", }, #ifdef CONFIG_ARM_AMBA { .compatible = "arm,amba-bus", }, #endif /* CONFIG_ARM_AMBA */ diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c index 18016341d..9f71770b6 100644 --- a/drivers/of/unittest.c +++ b/drivers/of/unittest.c @@ -979,7 +979,6 @@ static struct platform_driver unittest_driver = { .remove = unittest_remove, .driver = { .name = "unittest", - .owner = THIS_MODULE, .of_match_table = of_match_ptr(unittest_match), }, }; @@ -1666,7 +1665,6 @@ static const struct i2c_device_id unittest_i2c_dev_id[] = { static struct i2c_driver unittest_i2c_dev_driver = { .driver = { .name = "unittest-i2c-dev", - .owner = THIS_MODULE, }, .probe = unittest_i2c_dev_probe, .remove = unittest_i2c_dev_remove, @@ -1761,7 +1759,6 @@ static const struct i2c_device_id unittest_i2c_mux_id[] = { static struct i2c_driver unittest_i2c_mux_driver = { .driver = { .name = "unittest-i2c-mux", - .owner = THIS_MODULE, }, .probe = unittest_i2c_mux_probe, .remove = unittest_i2c_mux_remove, |