aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/of
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2015-04-24 11:46:18 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2015-04-24 11:46:18 -0400
commitd56a669ca59c37ed0a7282a251b2f2f22533343a (patch)
treecef7bd4699754057474cc96430864f690f1786e0 /drivers/of
parent836ee4874e201a5907f9658fb2bf3527dd952d30 (diff)
parent04fca0e390e80d88c2f959aef86e0bb7f26fea01 (diff)
Merge tag 'devicetree-for-4.1' of git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux
Pull second batch of devicetree updates from Rob Herring: "As Grant mentioned in the first devicetree pull request, here is the 2nd batch of DT changes for 4.1. The main remaining item here is the endianness bindings and related 8250 driver support. - DT endianness specification bindings - big-endian 8250 serial support - DT overlay unittest updates - various DT doc updates - compile fixes for OF_IRQ=n" * tag 'devicetree-for-4.1' of git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux: frv: add io{read,write}{16,32}be functions mn10300: add io{read,write}{16,32}be functions Documentation: DT bindings: add doc for Altera's SoCFPGA platform of: base: improve of_get_next_child() kernel-doc Doc: dt: arch_timer: discourage clock-frequency use of: unittest: overlay: Keep track of created overlays of/fdt: fix allocation size for device node path serial: of_serial: Support big-endian register accesses serial: 8250: Add support for big-endian MMIO accesses of: Document {little,big,native}-endian bindings of/fdt: Add endianness helper function for early init code of: Add helper function to check MMIO register endianness of/fdt: Remove "reg" data prints from early_init_dt_scan_memory of: add vendor prefix for Artesyn of: Add dummy of_irq_to_resource_table() for IRQ_OF=n of: OF_IRQ should depend on IRQ_DOMAIN
Diffstat (limited to 'drivers/of')
-rw-r--r--drivers/of/Kconfig2
-rw-r--r--drivers/of/base.c28
-rw-r--r--drivers/of/fdt.c24
-rw-r--r--drivers/of/unittest.c62
4 files changed, 110 insertions, 6 deletions
diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig
index 1470b5227834..07bb3c8f191b 100644
--- a/drivers/of/Kconfig
+++ b/drivers/of/Kconfig
@@ -50,7 +50,7 @@ config OF_ADDRESS_PCI
50 50
51config OF_IRQ 51config OF_IRQ
52 def_bool y 52 def_bool y
53 depends on !SPARC 53 depends on !SPARC && IRQ_DOMAIN
54 54
55config OF_NET 55config OF_NET
56 depends on NETDEVICES 56 depends on NETDEVICES
diff --git a/drivers/of/base.c b/drivers/of/base.c
index a1aa0c7dee50..99764db0875a 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -568,6 +568,29 @@ bool of_device_is_available(const struct device_node *device)
568EXPORT_SYMBOL(of_device_is_available); 568EXPORT_SYMBOL(of_device_is_available);
569 569
570/** 570/**
571 * of_device_is_big_endian - check if a device has BE registers
572 *
573 * @device: Node to check for endianness
574 *
575 * Returns true if the device has a "big-endian" property, or if the kernel
576 * was compiled for BE *and* the device has a "native-endian" property.
577 * Returns false otherwise.
578 *
579 * Callers would nominally use ioread32be/iowrite32be if
580 * of_device_is_big_endian() == true, or readl/writel otherwise.
581 */
582bool of_device_is_big_endian(const struct device_node *device)
583{
584 if (of_property_read_bool(device, "big-endian"))
585 return true;
586 if (IS_ENABLED(CONFIG_CPU_BIG_ENDIAN) &&
587 of_property_read_bool(device, "native-endian"))
588 return true;
589 return false;
590}
591EXPORT_SYMBOL(of_device_is_big_endian);
592
593/**
571 * of_get_parent - Get a node's parent if any 594 * of_get_parent - Get a node's parent if any
572 * @node: Node to get parent 595 * @node: Node to get parent
573 * 596 *
@@ -640,8 +663,9 @@ static struct device_node *__of_get_next_child(const struct device_node *node,
640 * @node: parent node 663 * @node: parent node
641 * @prev: previous child of the parent node, or NULL to get first 664 * @prev: previous child of the parent node, or NULL to get first
642 * 665 *
643 * Returns a node pointer with refcount incremented, use 666 * Returns a node pointer with refcount incremented, use of_node_put() on
644 * of_node_put() on it when done. 667 * it when done. Returns NULL when prev is the last child. Decrements the
668 * refcount of prev.
645 */ 669 */
646struct device_node *of_get_next_child(const struct device_node *node, 670struct device_node *of_get_next_child(const struct device_node *node,
647 struct device_node *prev) 671 struct device_node *prev)
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 3a896c9aeb74..cde35c5d0191 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -109,6 +109,25 @@ int of_fdt_is_compatible(const void *blob,
109} 109}
110 110
111/** 111/**
112 * of_fdt_is_big_endian - Return true if given node needs BE MMIO accesses
113 * @blob: A device tree blob
114 * @node: node to test
115 *
116 * Returns true if the node has a "big-endian" property, or if the kernel
117 * was compiled for BE *and* the node has a "native-endian" property.
118 * Returns false otherwise.
119 */
120bool of_fdt_is_big_endian(const void *blob, unsigned long node)
121{
122 if (fdt_getprop(blob, node, "big-endian", NULL))
123 return true;
124 if (IS_ENABLED(CONFIG_CPU_BIG_ENDIAN) &&
125 fdt_getprop(blob, node, "native-endian", NULL))
126 return true;
127 return false;
128}
129
130/**
112 * of_fdt_match - Return true if node matches a list of compatible values 131 * of_fdt_match - Return true if node matches a list of compatible values
113 */ 132 */
114int of_fdt_match(const void *blob, unsigned long node, 133int of_fdt_match(const void *blob, unsigned long node,
@@ -172,7 +191,7 @@ static void * unflatten_dt_node(void *blob,
172 if (!pathp) 191 if (!pathp)
173 return mem; 192 return mem;
174 193
175 allocl = l++; 194 allocl = ++l;
176 195
177 /* version 0x10 has a more compact unit name here instead of the full 196 /* version 0x10 has a more compact unit name here instead of the full
178 * path. we accumulate the full path size using "fpsize", we'll rebuild 197 * path. we accumulate the full path size using "fpsize", we'll rebuild
@@ -879,8 +898,7 @@ int __init early_init_dt_scan_memory(unsigned long node, const char *uname,
879 898
880 endp = reg + (l / sizeof(__be32)); 899 endp = reg + (l / sizeof(__be32));
881 900
882 pr_debug("memory scan node %s, reg size %d, data: %x %x %x %x,\n", 901 pr_debug("memory scan node %s, reg size %d,\n", uname, l);
883 uname, l, reg[0], reg[1], reg[2], reg[3]);
884 902
885 while ((endp - reg) >= (dt_root_addr_cells + dt_root_size_cells)) { 903 while ((endp - reg) >= (dt_root_addr_cells + dt_root_size_cells)) {
886 u64 base, size; 904 u64 base, size;
diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c
index e844907c9efa..18016341d5a9 100644
--- a/drivers/of/unittest.c
+++ b/drivers/of/unittest.c
@@ -23,6 +23,8 @@
23#include <linux/i2c.h> 23#include <linux/i2c.h>
24#include <linux/i2c-mux.h> 24#include <linux/i2c-mux.h>
25 25
26#include <linux/bitops.h>
27
26#include "of_private.h" 28#include "of_private.h"
27 29
28static struct unittest_results { 30static struct unittest_results {
@@ -1109,6 +1111,59 @@ static const char *overlay_path(int nr)
1109 1111
1110static const char *bus_path = "/testcase-data/overlay-node/test-bus"; 1112static const char *bus_path = "/testcase-data/overlay-node/test-bus";
1111 1113
1114/* it is guaranteed that overlay ids are assigned in sequence */
1115#define MAX_UNITTEST_OVERLAYS 256
1116static unsigned long overlay_id_bits[BITS_TO_LONGS(MAX_UNITTEST_OVERLAYS)];
1117static int overlay_first_id = -1;
1118
1119static void of_unittest_track_overlay(int id)
1120{
1121 if (overlay_first_id < 0)
1122 overlay_first_id = id;
1123 id -= overlay_first_id;
1124
1125 /* we shouldn't need that many */
1126 BUG_ON(id >= MAX_UNITTEST_OVERLAYS);
1127 overlay_id_bits[BIT_WORD(id)] |= BIT_MASK(id);
1128}
1129
1130static void of_unittest_untrack_overlay(int id)
1131{
1132 if (overlay_first_id < 0)
1133 return;
1134 id -= overlay_first_id;
1135 BUG_ON(id >= MAX_UNITTEST_OVERLAYS);
1136 overlay_id_bits[BIT_WORD(id)] &= ~BIT_MASK(id);
1137}
1138
1139static void of_unittest_destroy_tracked_overlays(void)
1140{
1141 int id, ret, defers;
1142
1143 if (overlay_first_id < 0)
1144 return;
1145
1146 /* try until no defers */
1147 do {
1148 defers = 0;
1149 /* remove in reverse order */
1150 for (id = MAX_UNITTEST_OVERLAYS - 1; id >= 0; id--) {
1151 if (!(overlay_id_bits[BIT_WORD(id)] & BIT_MASK(id)))
1152 continue;
1153
1154 ret = of_overlay_destroy(id + overlay_first_id);
1155 if (ret != 0) {
1156 defers++;
1157 pr_warn("%s: overlay destroy failed for #%d\n",
1158 __func__, id + overlay_first_id);
1159 continue;
1160 }
1161
1162 overlay_id_bits[BIT_WORD(id)] &= ~BIT_MASK(id);
1163 }
1164 } while (defers > 0);
1165}
1166
1112static int of_unittest_apply_overlay(int unittest_nr, int overlay_nr, 1167static int of_unittest_apply_overlay(int unittest_nr, int overlay_nr,
1113 int *overlay_id) 1168 int *overlay_id)
1114{ 1169{
@@ -1130,6 +1185,7 @@ static int of_unittest_apply_overlay(int unittest_nr, int overlay_nr,
1130 goto out; 1185 goto out;
1131 } 1186 }
1132 id = ret; 1187 id = ret;
1188 of_unittest_track_overlay(id);
1133 1189
1134 ret = 0; 1190 ret = 0;
1135 1191
@@ -1343,6 +1399,7 @@ static void of_unittest_overlay_6(void)
1343 return; 1399 return;
1344 } 1400 }
1345 ov_id[i] = ret; 1401 ov_id[i] = ret;
1402 of_unittest_track_overlay(ov_id[i]);
1346 } 1403 }
1347 1404
1348 for (i = 0; i < 2; i++) { 1405 for (i = 0; i < 2; i++) {
@@ -1367,6 +1424,7 @@ static void of_unittest_overlay_6(void)
1367 PDEV_OVERLAY)); 1424 PDEV_OVERLAY));
1368 return; 1425 return;
1369 } 1426 }
1427 of_unittest_untrack_overlay(ov_id[i]);
1370 } 1428 }
1371 1429
1372 for (i = 0; i < 2; i++) { 1430 for (i = 0; i < 2; i++) {
@@ -1411,6 +1469,7 @@ static void of_unittest_overlay_8(void)
1411 return; 1469 return;
1412 } 1470 }
1413 ov_id[i] = ret; 1471 ov_id[i] = ret;
1472 of_unittest_track_overlay(ov_id[i]);
1414 } 1473 }
1415 1474
1416 /* now try to remove first overlay (it should fail) */ 1475 /* now try to remove first overlay (it should fail) */
@@ -1433,6 +1492,7 @@ static void of_unittest_overlay_8(void)
1433 PDEV_OVERLAY)); 1492 PDEV_OVERLAY));
1434 return; 1493 return;
1435 } 1494 }
1495 of_unittest_untrack_overlay(ov_id[i]);
1436 } 1496 }
1437 1497
1438 unittest(1, "overlay test %d passed\n", 8); 1498 unittest(1, "overlay test %d passed\n", 8);
@@ -1855,6 +1915,8 @@ static void __init of_unittest_overlay(void)
1855 of_unittest_overlay_i2c_cleanup(); 1915 of_unittest_overlay_i2c_cleanup();
1856#endif 1916#endif
1857 1917
1918 of_unittest_destroy_tracked_overlays();
1919
1858out: 1920out:
1859 of_node_put(bus_np); 1921 of_node_put(bus_np);
1860} 1922}