Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

+243 -11
+14
Documentation/devicetree/bindings/arm/altera.txt
··· 1 + Altera's SoCFPGA platform device tree bindings 2 + --------------------------------------------- 3 + 4 + Boards with Cyclone 5 SoC: 5 + Required root node properties: 6 + compatible = "altr,socfpga-cyclone5", "altr,socfpga"; 7 + 8 + Boards with Arria 5 SoC: 9 + Required root node properties: 10 + compatible = "altr,socfpga-arria5", "altr,socfpga"; 11 + 12 + Boards with Arria 10 SoC: 13 + Required root node properties: 14 + compatible = "altr,socfpga-arria10", "altr,socfpga";
+6 -2
Documentation/devicetree/bindings/arm/arch_timer.txt
··· 17 17 - interrupts : Interrupt list for secure, non-secure, virtual and 18 18 hypervisor timers, in that order. 19 19 20 - - clock-frequency : The frequency of the main counter, in Hz. Optional. 20 + - clock-frequency : The frequency of the main counter, in Hz. Should be present 21 + only where necessary to work around broken firmware which does not configure 22 + CNTFRQ on all CPUs to a uniform correct value. Use of this property is 23 + strongly discouraged; fix your firmware unless absolutely impossible. 21 24 22 25 - always-on : a boolean property. If present, the timer is powered through an 23 26 always-on power domain, therefore it never loses context. ··· 49 46 50 47 - compatible : Should at least contain "arm,armv7-timer-mem". 51 48 52 - - clock-frequency : The frequency of the main counter, in Hz. Optional. 49 + - clock-frequency : The frequency of the main counter, in Hz. Should be present 50 + only when firmware has not configured the MMIO CNTFRQ registers. 53 51 54 52 - reg : The control frame base address. 55 53
+60
Documentation/devicetree/bindings/common-properties.txt
··· 1 + Common properties 2 + 3 + The ePAPR specification does not define any properties related to hardware 4 + byteswapping, but endianness issues show up frequently in porting Linux to 5 + different machine types. This document attempts to provide a consistent 6 + way of handling byteswapping across drivers. 7 + 8 + Optional properties: 9 + - big-endian: Boolean; force big endian register accesses 10 + unconditionally (e.g. ioread32be/iowrite32be). Use this if you 11 + know the peripheral always needs to be accessed in BE mode. 12 + - little-endian: Boolean; force little endian register accesses 13 + unconditionally (e.g. readl/writel). Use this if you know the 14 + peripheral always needs to be accessed in LE mode. 15 + - native-endian: Boolean; always use register accesses matched to the 16 + endianness of the kernel binary (e.g. LE vmlinux -> readl/writel, 17 + BE vmlinux -> ioread32be/iowrite32be). In this case no byteswaps 18 + will ever be performed. Use this if the hardware "self-adjusts" 19 + register endianness based on the CPU's configured endianness. 20 + 21 + If a binding supports these properties, then the binding should also 22 + specify the default behavior if none of these properties are present. 23 + In such cases, little-endian is the preferred default, but it is not 24 + a requirement. The of_device_is_big_endian() and of_fdt_is_big_endian() 25 + helper functions do assume that little-endian is the default, because 26 + most existing (PCI-based) drivers implicitly default to LE by using 27 + readl/writel for MMIO accesses. 28 + 29 + Examples: 30 + Scenario 1 : CPU in LE mode & device in LE mode. 31 + dev: dev@40031000 { 32 + compatible = "name"; 33 + reg = <0x40031000 0x1000>; 34 + ... 35 + native-endian; 36 + }; 37 + 38 + Scenario 2 : CPU in LE mode & device in BE mode. 39 + dev: dev@40031000 { 40 + compatible = "name"; 41 + reg = <0x40031000 0x1000>; 42 + ... 43 + big-endian; 44 + }; 45 + 46 + Scenario 3 : CPU in BE mode & device in BE mode. 47 + dev: dev@40031000 { 48 + compatible = "name"; 49 + reg = <0x40031000 0x1000>; 50 + ... 51 + native-endian; 52 + }; 53 + 54 + Scenario 4 : CPU in BE mode & device in LE mode. 55 + dev: dev@40031000 { 56 + compatible = "name"; 57 + reg = <0x40031000 0x1000>; 58 + ... 59 + little-endian; 60 + };
+1
Documentation/devicetree/bindings/vendor-prefixes.txt
··· 26 26 arasan Arasan Chip Systems 27 27 arm ARM Ltd. 28 28 armadeus ARMadeus Systems SARL 29 + artesyn Artesyn Embedded Technologies Inc. 29 30 asahi-kasei Asahi Kasei Corp. 30 31 atmel Atmel Corporation 31 32 auo AU Optronics Corporation
+5
arch/frv/include/asm/io.h
··· 342 342 __flush_PCI_writes(); 343 343 } 344 344 345 + #define ioread16be(addr) be16_to_cpu(ioread16(addr)) 346 + #define ioread32be(addr) be32_to_cpu(ioread32(addr)) 347 + #define iowrite16be(v, addr) iowrite16(cpu_to_be16(v), (addr)) 348 + #define iowrite32be(v, addr) iowrite32(cpu_to_be32(v), (addr)) 349 + 345 350 static inline void ioread8_rep(void __iomem *p, void *dst, unsigned long count) 346 351 { 347 352 io_insb((unsigned long) p, dst, count);
+5
arch/mn10300/include/asm/io.h
··· 197 197 #define iowrite16(v, addr) writew((v), (addr)) 198 198 #define iowrite32(v, addr) writel((v), (addr)) 199 199 200 + #define ioread16be(addr) be16_to_cpu(readw(addr)) 201 + #define ioread32be(addr) be32_to_cpu(readl(addr)) 202 + #define iowrite16be(v, addr) writew(cpu_to_be16(v), (addr)) 203 + #define iowrite32be(v, addr) writel(cpu_to_be32(v), (addr)) 204 + 200 205 #define ioread8_rep(p, dst, count) \ 201 206 insb((unsigned long) (p), (dst), (count)) 202 207 #define ioread16_rep(p, dst, count) \
+1 -1
drivers/of/Kconfig
··· 50 50 51 51 config OF_IRQ 52 52 def_bool y 53 - depends on !SPARC 53 + depends on !SPARC && IRQ_DOMAIN 54 54 55 55 config OF_NET 56 56 depends on NETDEVICES
+26 -2
drivers/of/base.c
··· 568 568 EXPORT_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 + */ 582 + bool 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 + } 591 + EXPORT_SYMBOL(of_device_is_big_endian); 592 + 593 + /** 571 594 * of_get_parent - Get a node's parent if any 572 595 * @node: Node to get parent 573 596 * ··· 663 640 * @node: parent node 664 641 * @prev: previous child of the parent node, or NULL to get first 665 642 * 666 - * Returns a node pointer with refcount incremented, use 667 - * of_node_put() on it when done. 643 + * Returns a node pointer with refcount incremented, use of_node_put() on 644 + * it when done. Returns NULL when prev is the last child. Decrements the 645 + * refcount of prev. 668 646 */ 669 647 struct device_node *of_get_next_child(const struct device_node *node, 670 648 struct device_node *prev)
+21 -3
drivers/of/fdt.c
··· 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 + */ 120 + bool 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 131 * of_fdt_match - Return true if node matches a list of compatible values 113 132 */ 114 133 int of_fdt_match(const void *blob, unsigned long node, ··· 191 172 if (!pathp) 192 173 return mem; 193 174 194 - allocl = l++; 175 + allocl = ++l; 195 176 196 177 /* version 0x10 has a more compact unit name here instead of the full 197 178 * path. we accumulate the full path size using "fpsize", we'll rebuild ··· 898 879 899 880 endp = reg + (l / sizeof(__be32)); 900 881 901 - pr_debug("memory scan node %s, reg size %d, data: %x %x %x %x,\n", 902 - uname, l, reg[0], reg[1], reg[2], reg[3]); 882 + pr_debug("memory scan node %s, reg size %d,\n", uname, l); 903 883 904 884 while ((endp - reg) >= (dt_root_addr_cells + dt_root_size_cells)) { 905 885 u64 base, size;
+62
drivers/of/unittest.c
··· 23 23 #include <linux/i2c.h> 24 24 #include <linux/i2c-mux.h> 25 25 26 + #include <linux/bitops.h> 27 + 26 28 #include "of_private.h" 27 29 28 30 static struct unittest_results { ··· 1111 1109 1112 1110 static const char *bus_path = "/testcase-data/overlay-node/test-bus"; 1113 1111 1112 + /* it is guaranteed that overlay ids are assigned in sequence */ 1113 + #define MAX_UNITTEST_OVERLAYS 256 1114 + static unsigned long overlay_id_bits[BITS_TO_LONGS(MAX_UNITTEST_OVERLAYS)]; 1115 + static int overlay_first_id = -1; 1116 + 1117 + static void of_unittest_track_overlay(int id) 1118 + { 1119 + if (overlay_first_id < 0) 1120 + overlay_first_id = id; 1121 + id -= overlay_first_id; 1122 + 1123 + /* we shouldn't need that many */ 1124 + BUG_ON(id >= MAX_UNITTEST_OVERLAYS); 1125 + overlay_id_bits[BIT_WORD(id)] |= BIT_MASK(id); 1126 + } 1127 + 1128 + static void of_unittest_untrack_overlay(int id) 1129 + { 1130 + if (overlay_first_id < 0) 1131 + return; 1132 + id -= overlay_first_id; 1133 + BUG_ON(id >= MAX_UNITTEST_OVERLAYS); 1134 + overlay_id_bits[BIT_WORD(id)] &= ~BIT_MASK(id); 1135 + } 1136 + 1137 + static void of_unittest_destroy_tracked_overlays(void) 1138 + { 1139 + int id, ret, defers; 1140 + 1141 + if (overlay_first_id < 0) 1142 + return; 1143 + 1144 + /* try until no defers */ 1145 + do { 1146 + defers = 0; 1147 + /* remove in reverse order */ 1148 + for (id = MAX_UNITTEST_OVERLAYS - 1; id >= 0; id--) { 1149 + if (!(overlay_id_bits[BIT_WORD(id)] & BIT_MASK(id))) 1150 + continue; 1151 + 1152 + ret = of_overlay_destroy(id + overlay_first_id); 1153 + if (ret != 0) { 1154 + defers++; 1155 + pr_warn("%s: overlay destroy failed for #%d\n", 1156 + __func__, id + overlay_first_id); 1157 + continue; 1158 + } 1159 + 1160 + overlay_id_bits[BIT_WORD(id)] &= ~BIT_MASK(id); 1161 + } 1162 + } while (defers > 0); 1163 + } 1164 + 1114 1165 static int of_unittest_apply_overlay(int unittest_nr, int overlay_nr, 1115 1166 int *overlay_id) 1116 1167 { ··· 1185 1130 goto out; 1186 1131 } 1187 1132 id = ret; 1133 + of_unittest_track_overlay(id); 1188 1134 1189 1135 ret = 0; 1190 1136 ··· 1399 1343 return; 1400 1344 } 1401 1345 ov_id[i] = ret; 1346 + of_unittest_track_overlay(ov_id[i]); 1402 1347 } 1403 1348 1404 1349 for (i = 0; i < 2; i++) { ··· 1424 1367 PDEV_OVERLAY)); 1425 1368 return; 1426 1369 } 1370 + of_unittest_untrack_overlay(ov_id[i]); 1427 1371 } 1428 1372 1429 1373 for (i = 0; i < 2; i++) { ··· 1469 1411 return; 1470 1412 } 1471 1413 ov_id[i] = ret; 1414 + of_unittest_track_overlay(ov_id[i]); 1472 1415 } 1473 1416 1474 1417 /* now try to remove first overlay (it should fail) */ ··· 1492 1433 PDEV_OVERLAY)); 1493 1434 return; 1494 1435 } 1436 + of_unittest_untrack_overlay(ov_id[i]); 1495 1437 } 1496 1438 1497 1439 unittest(1, "overlay test %d passed\n", 8); ··· 1914 1854 1915 1855 of_unittest_overlay_i2c_cleanup(); 1916 1856 #endif 1857 + 1858 + of_unittest_destroy_tracked_overlays(); 1917 1859 1918 1860 out: 1919 1861 of_node_put(bus_np);
+20
drivers/tty/serial/8250/8250_core.c
··· 450 450 return readl(p->membase + offset); 451 451 } 452 452 453 + static void mem32be_serial_out(struct uart_port *p, int offset, int value) 454 + { 455 + offset = offset << p->regshift; 456 + iowrite32be(value, p->membase + offset); 457 + } 458 + 459 + static unsigned int mem32be_serial_in(struct uart_port *p, int offset) 460 + { 461 + offset = offset << p->regshift; 462 + return ioread32be(p->membase + offset); 463 + } 464 + 453 465 static unsigned int io_serial_in(struct uart_port *p, int offset) 454 466 { 455 467 offset = offset << p->regshift; ··· 500 488 p->serial_out = mem32_serial_out; 501 489 break; 502 490 491 + case UPIO_MEM32BE: 492 + p->serial_in = mem32be_serial_in; 493 + p->serial_out = mem32be_serial_out; 494 + break; 495 + 503 496 #if defined(CONFIG_MIPS_ALCHEMY) || defined(CONFIG_SERIAL_8250_RT288X) 504 497 case UPIO_AU: 505 498 p->serial_in = au_serial_in; ··· 530 513 switch (p->iotype) { 531 514 case UPIO_MEM: 532 515 case UPIO_MEM32: 516 + case UPIO_MEM32BE: 533 517 case UPIO_AU: 534 518 p->serial_out(p, offset, value); 535 519 p->serial_in(p, UART_LCR); /* safe, no side-effects */ ··· 2766 2748 case UPIO_AU: 2767 2749 case UPIO_TSI: 2768 2750 case UPIO_MEM32: 2751 + case UPIO_MEM32BE: 2769 2752 case UPIO_MEM: 2770 2753 if (!port->mapbase) 2771 2754 break; ··· 2803 2784 case UPIO_AU: 2804 2785 case UPIO_TSI: 2805 2786 case UPIO_MEM32: 2787 + case UPIO_MEM32BE: 2806 2788 case UPIO_MEM: 2807 2789 if (!port->mapbase) 2808 2790 break;
+5
drivers/tty/serial/8250/8250_early.c
··· 42 42 return readb(port->membase + offset); 43 43 case UPIO_MEM32: 44 44 return readl(port->membase + (offset << 2)); 45 + case UPIO_MEM32BE: 46 + return ioread32be(port->membase + (offset << 2)); 45 47 case UPIO_PORT: 46 48 return inb(port->iobase + offset); 47 49 default: ··· 59 57 break; 60 58 case UPIO_MEM32: 61 59 writel(value, port->membase + (offset << 2)); 60 + break; 61 + case UPIO_MEM32BE: 62 + iowrite32be(value, port->membase + (offset << 2)); 62 63 break; 63 64 case UPIO_PORT: 64 65 outb(value, port->iobase + offset);
+2 -1
drivers/tty/serial/of_serial.c
··· 116 116 port->iotype = UPIO_MEM; 117 117 break; 118 118 case 4: 119 - port->iotype = UPIO_MEM32; 119 + port->iotype = of_device_is_big_endian(np) ? 120 + UPIO_MEM32BE : UPIO_MEM32; 120 121 break; 121 122 default: 122 123 dev_warn(&ofdev->dev, "unsupported reg-io-width (%d)\n",
+6
include/linux/of.h
··· 305 305 extern int of_device_is_compatible(const struct device_node *device, 306 306 const char *); 307 307 extern bool of_device_is_available(const struct device_node *device); 308 + extern bool of_device_is_big_endian(const struct device_node *device); 308 309 extern const void *of_get_property(const struct device_node *node, 309 310 const char *name, 310 311 int *lenp); ··· 464 463 } 465 464 466 465 static inline bool of_device_is_available(const struct device_node *device) 466 + { 467 + return false; 468 + } 469 + 470 + static inline bool of_device_is_big_endian(const struct device_node *device) 467 471 { 468 472 return false; 469 473 }
+2
include/linux/of_fdt.h
··· 33 33 extern int of_fdt_is_compatible(const void *blob, 34 34 unsigned long node, 35 35 const char *compat); 36 + extern bool of_fdt_is_big_endian(const void *blob, 37 + unsigned long node); 36 38 extern int of_fdt_match(const void *blob, unsigned long node, 37 39 const char *const *compat); 38 40 extern void of_fdt_unflatten_tree(unsigned long *blob,
+7 -2
include/linux/of_irq.h
··· 37 37 extern unsigned int irq_create_of_mapping(struct of_phandle_args *irq_data); 38 38 extern int of_irq_to_resource(struct device_node *dev, int index, 39 39 struct resource *r); 40 - extern int of_irq_to_resource_table(struct device_node *dev, 41 - struct resource *res, int nr_irqs); 42 40 43 41 extern void of_irq_init(const struct of_device_id *matches); 44 42 ··· 44 46 extern int of_irq_count(struct device_node *dev); 45 47 extern int of_irq_get(struct device_node *dev, int index); 46 48 extern int of_irq_get_byname(struct device_node *dev, const char *name); 49 + extern int of_irq_to_resource_table(struct device_node *dev, 50 + struct resource *res, int nr_irqs); 47 51 #else 48 52 static inline int of_irq_count(struct device_node *dev) 49 53 { ··· 56 56 return 0; 57 57 } 58 58 static inline int of_irq_get_byname(struct device_node *dev, const char *name) 59 + { 60 + return 0; 61 + } 62 + static inline int of_irq_to_resource_table(struct device_node *dev, 63 + struct resource *res, int nr_irqs) 59 64 { 60 65 return 0; 61 66 }