Merge tag 'devicetree-for-5.19' of git://git.kernel.org/pub/scm/linux/kernel/git...
[linux-block.git] / drivers / of / property.c
index 84903dad96a417705cd480e38bb80a27e4bebf56..967f79b59016514a584358f2c9262d819a1a9fb1 100644 (file)
@@ -22,6 +22,7 @@
 #define pr_fmt(fmt)    "OF: " fmt
 
 #include <linux/of.h>
+#include <linux/of_address.h>
 #include <linux/of_device.h>
 #include <linux/of_graph.h>
 #include <linux/of_irq.h>
@@ -875,6 +876,20 @@ static bool of_fwnode_device_is_available(const struct fwnode_handle *fwnode)
        return of_device_is_available(to_of_node(fwnode));
 }
 
+static bool of_fwnode_device_dma_supported(const struct fwnode_handle *fwnode)
+{
+       return true;
+}
+
+static enum dev_dma_attr
+of_fwnode_device_get_dma_attr(const struct fwnode_handle *fwnode)
+{
+       if (of_dma_is_coherent(to_of_node(fwnode)))
+               return DEV_DMA_COHERENT;
+       else
+               return DEV_DMA_NON_COHERENT;
+}
+
 static bool of_fwnode_property_present(const struct fwnode_handle *fwnode,
                                       const char *propname)
 {
@@ -1453,6 +1468,21 @@ static int of_link_property(struct device_node *con_np, const char *prop_name)
        return 0;
 }
 
+static void __iomem *of_fwnode_iomap(struct fwnode_handle *fwnode, int index)
+{
+#ifdef CONFIG_OF_ADDRESS
+       return of_iomap(to_of_node(fwnode), index);
+#else
+       return NULL;
+#endif
+}
+
+static int of_fwnode_irq_get(const struct fwnode_handle *fwnode,
+                            unsigned int index)
+{
+       return of_irq_get(to_of_node(fwnode), index);
+}
+
 static int of_fwnode_add_links(struct fwnode_handle *fwnode)
 {
        struct property *p;
@@ -1475,6 +1505,8 @@ const struct fwnode_operations of_fwnode_ops = {
        .put = of_fwnode_put,
        .device_is_available = of_fwnode_device_is_available,
        .device_get_match_data = of_fwnode_device_get_match_data,
+       .device_dma_supported = of_fwnode_device_dma_supported,
+       .device_get_dma_attr = of_fwnode_device_get_dma_attr,
        .property_present = of_fwnode_property_present,
        .property_read_int_array = of_fwnode_property_read_int_array,
        .property_read_string_array = of_fwnode_property_read_string_array,
@@ -1488,6 +1520,8 @@ const struct fwnode_operations of_fwnode_ops = {
        .graph_get_remote_endpoint = of_fwnode_graph_get_remote_endpoint,
        .graph_get_port_parent = of_fwnode_graph_get_port_parent,
        .graph_parse_endpoint = of_fwnode_graph_parse_endpoint,
+       .iomap = of_fwnode_iomap,
+       .irq_get = of_fwnode_irq_get,
        .add_links = of_fwnode_add_links,
 };
 EXPORT_SYMBOL_GPL(of_fwnode_ops);