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

Merge branch 'devicetree/next' of git://git.secretlab.ca/git/linux-2.6

* 'devicetree/next' of git://git.secretlab.ca/git/linux-2.6:
of_mdio: Don't phy_scan_fixups() twice
Devicetree: Expand on ARM Primecell binding documentation
dt: Add empty of_match_node() macro
dt: add empty dt helpers for non-dt build
devicetree: fix build error on drivers/tty/serial/altera_jtaguart.c
devicetree: Add ARM pl022 spi controller binding doc
devicetree: Add ARM pl061 gpio controller binding doc
of/irq: of_irq_find_parent: check for parent equal to child
MAINTAINERS: update devicetree maintainers
dt: add helper to read 64-bit integers
tty: use of_match_ptr() for of_match_table entry
OF: Add of_match_ptr() macro
dt: add empty for_each_child_of_node, of_find_property
devicetree: Document Qualcomm and Atmel prefixes
serial/imx: add of_alias_get_id() reference back
dt: add of_alias_scan and of_alias_get_id
devicetree: Add a registry of vendor prefixes

+286 -26
+3 -1
Documentation/devicetree/bindings/arm/primecell.txt
··· 6 6 7 7 Required properties: 8 8 9 - - compatible : should be a specific value for peripheral and "arm,primecell" 9 + - compatible : should be a specific name for the peripheral and 10 + "arm,primecell". The specific name will match the ARM 11 + engineering name for the logic block in the form: "arm,pl???" 10 12 11 13 Optional properties: 12 14
+10
Documentation/devicetree/bindings/gpio/pl061-gpio.txt
··· 1 + ARM PL061 GPIO controller 2 + 3 + Required properties: 4 + - compatible : "arm,pl061", "arm,primecell" 5 + - #gpio-cells : Should be two. The first cell is the pin number and the 6 + second cell is used to specify optional parameters: 7 + - bit 0 specifies polarity (0 for normal, 1 for inverted) 8 + - gpio-controller : Marks the device node as a GPIO controller. 9 + - interrupts : Interrupt mapping for GPIO IRQ. 10 +
+12
Documentation/devicetree/bindings/spi/spi_pl022.txt
··· 1 + ARM PL022 SPI controller 2 + 3 + Required properties: 4 + - compatible : "arm,pl022", "arm,primecell" 5 + - reg : Offset and length of the register set for the device 6 + - interrupts : Should contain SPI controller interrupt 7 + 8 + Optional properties: 9 + - cs-gpios : should specify GPIOs used for chipselects. 10 + The gpios will be referred to as reg = <index> in the SPI child nodes. 11 + If unspecified, a single SPI device without a chip select can be used. 12 +
+40
Documentation/devicetree/bindings/vendor-prefixes.txt
··· 1 + Device tree binding vendor prefix registry. Keep list in alphabetical order. 2 + 3 + This isn't an exhaustive list, but you should add new prefixes to it before 4 + using them to avoid name-space collisions. 5 + 6 + adi Analog Devices, Inc. 7 + amcc Applied Micro Circuits Corporation (APM, formally AMCC) 8 + apm Applied Micro Circuits Corporation (APM) 9 + arm ARM Ltd. 10 + atmel Atmel Corporation 11 + chrp Common Hardware Reference Platform 12 + dallas Maxim Integrated Products (formerly Dallas Semiconductor) 13 + denx Denx Software Engineering 14 + epson Seiko Epson Corp. 15 + est ESTeem Wireless Modems 16 + fsl Freescale Semiconductor 17 + GEFanuc GE Fanuc Intelligent Platforms Embedded Systems, Inc. 18 + gef GE Fanuc Intelligent Platforms Embedded Systems, Inc. 19 + hp Hewlett Packard 20 + ibm International Business Machines (IBM) 21 + idt Integrated Device Technologies, Inc. 22 + intercontrol Inter Control Group 23 + linux Linux-specific binding 24 + marvell Marvell Technology Group Ltd. 25 + maxim Maxim Integrated Products 26 + mosaixtech Mosaix Technologies, Inc. 27 + national National Semiconductor 28 + nintendo Nintendo 29 + nvidia NVIDIA 30 + nxp NXP Semiconductors 31 + powervr Imagination Technologies 32 + qcom Qualcomm, Inc. 33 + ramtron Ramtron International 34 + samsung Samsung Semiconductor 35 + schindler Schindler 36 + simtek 37 + sirf SiRF Technology, Inc. 38 + stericsson ST-Ericsson 39 + ti Texas Instruments 40 + xlnx Xilinx
+2
MAINTAINERS
··· 4760 4760 4761 4761 OPEN FIRMWARE AND FLATTENED DEVICE TREE 4762 4762 M: Grant Likely <grant.likely@secretlab.ca> 4763 + M: Rob Herring <rob.herring@calxeda.com> 4763 4764 L: devicetree-discuss@lists.ozlabs.org (moderated for non-subscribers) 4764 4765 W: http://fdt.secretlab.ca 4765 4766 T: git git://git.secretlab.ca/git/linux-2.6.git 4766 4767 S: Maintained 4768 + F: Documentation/devicetree 4767 4769 F: drivers/of 4768 4770 F: include/linux/of*.h 4769 4771 K: of_get_property
+150
drivers/of/base.c
··· 17 17 * as published by the Free Software Foundation; either version 18 18 * 2 of the License, or (at your option) any later version. 19 19 */ 20 + #include <linux/ctype.h> 20 21 #include <linux/module.h> 21 22 #include <linux/of.h> 22 23 #include <linux/spinlock.h> 23 24 #include <linux/slab.h> 24 25 #include <linux/proc_fs.h> 25 26 27 + /** 28 + * struct alias_prop - Alias property in 'aliases' node 29 + * @link: List node to link the structure in aliases_lookup list 30 + * @alias: Alias property name 31 + * @np: Pointer to device_node that the alias stands for 32 + * @id: Index value from end of alias name 33 + * @stem: Alias string without the index 34 + * 35 + * The structure represents one alias property of 'aliases' node as 36 + * an entry in aliases_lookup list. 37 + */ 38 + struct alias_prop { 39 + struct list_head link; 40 + const char *alias; 41 + struct device_node *np; 42 + int id; 43 + char stem[0]; 44 + }; 45 + 46 + static LIST_HEAD(aliases_lookup); 47 + 26 48 struct device_node *allnodes; 27 49 struct device_node *of_chosen; 50 + struct device_node *of_aliases; 51 + 52 + static DEFINE_MUTEX(of_aliases_mutex); 28 53 29 54 /* use when traversing tree through the allnext, child, sibling, 30 55 * or parent members of struct device_node. ··· 657 632 EXPORT_SYMBOL_GPL(of_property_read_u32_array); 658 633 659 634 /** 635 + * of_property_read_u64 - Find and read a 64 bit integer from a property 636 + * @np: device node from which the property value is to be read. 637 + * @propname: name of the property to be searched. 638 + * @out_value: pointer to return value, modified only if return value is 0. 639 + * 640 + * Search for a property in a device node and read a 64-bit value from 641 + * it. Returns 0 on success, -EINVAL if the property does not exist, 642 + * -ENODATA if property does not have a value, and -EOVERFLOW if the 643 + * property data isn't large enough. 644 + * 645 + * The out_value is modified only if a valid u64 value can be decoded. 646 + */ 647 + int of_property_read_u64(const struct device_node *np, const char *propname, 648 + u64 *out_value) 649 + { 650 + struct property *prop = of_find_property(np, propname, NULL); 651 + 652 + if (!prop) 653 + return -EINVAL; 654 + if (!prop->value) 655 + return -ENODATA; 656 + if (sizeof(*out_value) > prop->length) 657 + return -EOVERFLOW; 658 + *out_value = of_read_number(prop->value, 2); 659 + return 0; 660 + } 661 + EXPORT_SYMBOL_GPL(of_property_read_u64); 662 + 663 + /** 660 664 * of_property_read_string - Find and read a string from a property 661 665 * @np: device node from which the property value is to be read. 662 666 * @propname: name of the property to be searched. ··· 1042 988 } 1043 989 #endif /* defined(CONFIG_OF_DYNAMIC) */ 1044 990 991 + static void of_alias_add(struct alias_prop *ap, struct device_node *np, 992 + int id, const char *stem, int stem_len) 993 + { 994 + ap->np = np; 995 + ap->id = id; 996 + strncpy(ap->stem, stem, stem_len); 997 + ap->stem[stem_len] = 0; 998 + list_add_tail(&ap->link, &aliases_lookup); 999 + pr_debug("adding DT alias:%s: stem=%s id=%i node=%s\n", 1000 + ap->alias, ap->stem, ap->id, np ? np->full_name : NULL); 1001 + } 1002 + 1003 + /** 1004 + * of_alias_scan - Scan all properties of 'aliases' node 1005 + * 1006 + * The function scans all the properties of 'aliases' node and populate 1007 + * the the global lookup table with the properties. It returns the 1008 + * number of alias_prop found, or error code in error case. 1009 + * 1010 + * @dt_alloc: An allocator that provides a virtual address to memory 1011 + * for the resulting tree 1012 + */ 1013 + void of_alias_scan(void * (*dt_alloc)(u64 size, u64 align)) 1014 + { 1015 + struct property *pp; 1016 + 1017 + of_chosen = of_find_node_by_path("/chosen"); 1018 + if (of_chosen == NULL) 1019 + of_chosen = of_find_node_by_path("/chosen@0"); 1020 + of_aliases = of_find_node_by_path("/aliases"); 1021 + if (!of_aliases) 1022 + return; 1023 + 1024 + for_each_property(pp, of_aliases->properties) { 1025 + const char *start = pp->name; 1026 + const char *end = start + strlen(start); 1027 + struct device_node *np; 1028 + struct alias_prop *ap; 1029 + int id, len; 1030 + 1031 + /* Skip those we do not want to proceed */ 1032 + if (!strcmp(pp->name, "name") || 1033 + !strcmp(pp->name, "phandle") || 1034 + !strcmp(pp->name, "linux,phandle")) 1035 + continue; 1036 + 1037 + np = of_find_node_by_path(pp->value); 1038 + if (!np) 1039 + continue; 1040 + 1041 + /* walk the alias backwards to extract the id and work out 1042 + * the 'stem' string */ 1043 + while (isdigit(*(end-1)) && end > start) 1044 + end--; 1045 + len = end - start; 1046 + 1047 + if (kstrtoint(end, 10, &id) < 0) 1048 + continue; 1049 + 1050 + /* Allocate an alias_prop with enough space for the stem */ 1051 + ap = dt_alloc(sizeof(*ap) + len + 1, 4); 1052 + if (!ap) 1053 + continue; 1054 + ap->alias = start; 1055 + of_alias_add(ap, np, id, start, len); 1056 + } 1057 + } 1058 + 1059 + /** 1060 + * of_alias_get_id - Get alias id for the given device_node 1061 + * @np: Pointer to the given device_node 1062 + * @stem: Alias stem of the given device_node 1063 + * 1064 + * The function travels the lookup table to get alias id for the given 1065 + * device_node and alias stem. It returns the alias id if find it. 1066 + */ 1067 + int of_alias_get_id(struct device_node *np, const char *stem) 1068 + { 1069 + struct alias_prop *app; 1070 + int id = -ENODEV; 1071 + 1072 + mutex_lock(&of_aliases_mutex); 1073 + list_for_each_entry(app, &aliases_lookup, link) { 1074 + if (strcmp(app->stem, stem) != 0) 1075 + continue; 1076 + 1077 + if (np == app->np) { 1078 + id = app->id; 1079 + break; 1080 + } 1081 + } 1082 + mutex_unlock(&of_aliases_mutex); 1083 + 1084 + return id; 1085 + } 1086 + EXPORT_SYMBOL_GPL(of_alias_get_id);
+2 -4
drivers/of/fdt.c
··· 707 707 __unflatten_device_tree(initial_boot_params, &allnodes, 708 708 early_init_dt_alloc_memory_arch); 709 709 710 - /* Get pointer to OF "/chosen" node for use everywhere */ 711 - of_chosen = of_find_node_by_path("/chosen"); 712 - if (of_chosen == NULL) 713 - of_chosen = of_find_node_by_path("/chosen@0"); 710 + /* Get pointer to "/chosen" and "/aliasas" nodes for use everywhere */ 711 + of_alias_scan(early_init_dt_alloc_memory_arch); 714 712 } 715 713 716 714 #endif /* CONFIG_OF_EARLY_FLATTREE */
+7 -7
drivers/of/irq.c
··· 58 58 */ 59 59 struct device_node *of_irq_find_parent(struct device_node *child) 60 60 { 61 - struct device_node *p; 61 + struct device_node *p, *c = child; 62 62 const __be32 *parp; 63 63 64 - if (!of_node_get(child)) 64 + if (!of_node_get(c)) 65 65 return NULL; 66 66 67 67 do { 68 - parp = of_get_property(child, "interrupt-parent", NULL); 68 + parp = of_get_property(c, "interrupt-parent", NULL); 69 69 if (parp == NULL) 70 - p = of_get_parent(child); 70 + p = of_get_parent(c); 71 71 else { 72 72 if (of_irq_workarounds & OF_IMAP_NO_PHANDLE) 73 73 p = of_node_get(of_irq_dflt_pic); 74 74 else 75 75 p = of_find_node_by_phandle(be32_to_cpup(parp)); 76 76 } 77 - of_node_put(child); 78 - child = p; 77 + of_node_put(c); 78 + c = p; 79 79 } while (p && of_get_property(p, "#interrupt-cells", NULL) == NULL); 80 80 81 - return p; 81 + return (p == child) ? NULL : p; 82 82 } 83 83 84 84 /**
-1
drivers/of/of_mdio.c
··· 83 83 addr); 84 84 continue; 85 85 } 86 - phy_scan_fixups(phy); 87 86 88 87 /* Associate the OF node with the device structure so it 89 88 * can be looked up later */
+8
drivers/of/pdt.c
··· 229 229 return ret; 230 230 } 231 231 232 + static void *kernel_tree_alloc(u64 size, u64 align) 233 + { 234 + return prom_early_alloc(size); 235 + } 236 + 232 237 void __init of_pdt_build_devicetree(phandle root_node, struct of_pdt_ops *ops) 233 238 { 234 239 struct device_node **nextp; ··· 250 245 nextp = &allnodes->allnext; 251 246 allnodes->child = of_pdt_build_tree(allnodes, 252 247 of_pdt_prom_ops->getchild(allnodes->phandle), &nextp); 248 + 249 + /* Get pointer to "/chosen" and "/aliasas" nodes for use everywhere */ 250 + of_alias_scan(kernel_tree_alloc); 253 251 }
+2 -3
drivers/tty/serial/altera_jtaguart.c
··· 18 18 #include <linux/interrupt.h> 19 19 #include <linux/module.h> 20 20 #include <linux/console.h> 21 + #include <linux/of.h> 21 22 #include <linux/tty.h> 22 23 #include <linux/tty_flip.h> 23 24 #include <linux/serial.h> ··· 473 472 {}, 474 473 }; 475 474 MODULE_DEVICE_TABLE(of, altera_jtaguart_match); 476 - #else 477 - #define altera_jtaguart_match NULL 478 475 #endif /* CONFIG_OF */ 479 476 480 477 static struct platform_driver altera_jtaguart_platform_driver = { ··· 481 482 .driver = { 482 483 .name = DRV_NAME, 483 484 .owner = THIS_MODULE, 484 - .of_match_table = altera_jtaguart_match, 485 + .of_match_table = of_match_ptr(altera_jtaguart_match), 485 486 }, 486 487 }; 487 488
+1 -3
drivers/tty/serial/altera_uart.c
··· 616 616 {}, 617 617 }; 618 618 MODULE_DEVICE_TABLE(of, altera_uart_match); 619 - #else 620 - #define altera_uart_match NULL 621 619 #endif /* CONFIG_OF */ 622 620 623 621 static struct platform_driver altera_uart_platform_driver = { ··· 624 626 .driver = { 625 627 .name = DRV_NAME, 626 628 .owner = THIS_MODULE, 627 - .of_match_table = altera_uart_match, 629 + .of_match_table = of_match_ptr(altera_uart_match), 628 630 }, 629 631 }; 630 632
+7 -4
drivers/tty/serial/imx.c
··· 1290 1290 static int serial_imx_probe_dt(struct imx_port *sport, 1291 1291 struct platform_device *pdev) 1292 1292 { 1293 - static int portnum = 0; 1294 1293 struct device_node *np = pdev->dev.of_node; 1295 1294 const struct of_device_id *of_id = 1296 1295 of_match_device(imx_uart_dt_ids, &pdev->dev); 1296 + int ret; 1297 1297 1298 1298 if (!np) 1299 1299 return -ENODEV; 1300 1300 1301 - sport->port.line = portnum++; 1302 - if (sport->port.line >= UART_NR) 1303 - return -EINVAL; 1301 + ret = of_alias_get_id(np, "serial"); 1302 + if (ret < 0) { 1303 + dev_err(&pdev->dev, "failed to get alias id, errno %d\n", ret); 1304 + return -ENODEV; 1305 + } 1306 + sport->port.line = ret; 1304 1307 1305 1308 if (of_get_property(np, "fsl,uart-has-rtscts", NULL)) 1306 1309 sport->have_rtscts = 1;
+1 -3
drivers/tty/serial/uartlite.c
··· 569 569 {} 570 570 }; 571 571 MODULE_DEVICE_TABLE(of, ulite_of_match); 572 - #else /* CONFIG_OF */ 573 - #define ulite_of_match NULL 574 572 #endif /* CONFIG_OF */ 575 573 576 574 static int __devinit ulite_probe(struct platform_device *pdev) ··· 608 610 .driver = { 609 611 .owner = THIS_MODULE, 610 612 .name = "uartlite", 611 - .of_match_table = ulite_of_match, 613 + .of_match_table = of_match_ptr(ulite_of_match), 612 614 }, 613 615 }; 614 616
+41
include/linux/of.h
··· 68 68 /* Pointer for first entry in chain of all nodes. */ 69 69 extern struct device_node *allnodes; 70 70 extern struct device_node *of_chosen; 71 + extern struct device_node *of_aliases; 71 72 extern rwlock_t devtree_lock; 72 73 73 74 static inline bool of_have_populated_dt(void) ··· 200 199 const char *propname, 201 200 u32 *out_values, 202 201 size_t sz); 202 + extern int of_property_read_u64(const struct device_node *np, 203 + const char *propname, u64 *out_value); 203 204 204 205 extern int of_property_read_string(struct device_node *np, 205 206 const char *propname, ··· 212 209 extern const void *of_get_property(const struct device_node *node, 213 210 const char *name, 214 211 int *lenp); 212 + #define for_each_property(pp, properties) \ 213 + for (pp = properties; pp != NULL; pp = pp->next) 214 + 215 215 extern int of_n_addr_cells(struct device_node *np); 216 216 extern int of_n_size_cells(struct device_node *np); 217 217 extern const struct of_device_id *of_match_node( ··· 226 220 extern int of_parse_phandles_with_args(struct device_node *np, 227 221 const char *list_name, const char *cells_name, int index, 228 222 struct device_node **out_node, const void **out_args); 223 + 224 + extern void of_alias_scan(void * (*dt_alloc)(u64 size, u64 align)); 225 + extern int of_alias_get_id(struct device_node *np, const char *stem); 229 226 230 227 extern int of_machine_is_compatible(const char *compat); 231 228 ··· 244 235 extern void of_detach_node(struct device_node *); 245 236 #endif 246 237 238 + #define of_match_ptr(_ptr) (_ptr) 247 239 #else /* CONFIG_OF */ 248 240 249 241 static inline bool of_have_populated_dt(void) 250 242 { 251 243 return false; 244 + } 245 + 246 + #define for_each_child_of_node(parent, child) \ 247 + while (0) 248 + 249 + static inline int of_device_is_compatible(const struct device_node *device, 250 + const char *name) 251 + { 252 + return 0; 253 + } 254 + 255 + static inline struct property *of_find_property(const struct device_node *np, 256 + const char *name, 257 + int *lenp) 258 + { 259 + return NULL; 252 260 } 253 261 254 262 static inline int of_property_read_u32_array(const struct device_node *np, ··· 289 263 return NULL; 290 264 } 291 265 266 + static inline int of_property_read_u64(const struct device_node *np, 267 + const char *propname, u64 *out_value) 268 + { 269 + return -ENOSYS; 270 + } 271 + 272 + static inline struct device_node *of_parse_phandle(struct device_node *np, 273 + const char *phandle_name, 274 + int index) 275 + { 276 + return NULL; 277 + } 278 + 279 + #define of_match_ptr(_ptr) NULL 280 + #define of_match_node(_matches, _node) NULL 292 281 #endif /* CONFIG_OF */ 293 282 294 283 static inline int of_property_read_u32(const struct device_node *np,