sessyargc.jp the answer was sufficient; however, just for completeness, I wanted to offer some C code that I used to print out some basic tree information from inside the driver:
#include <linux/of_device.h> #include <linux/of_platform.h> ... print_device_tree_node(of_find_node_by_path("/"), 0); ... static void print_device_tree_node(struct device_node *node, int depth) { int i = 0; struct device_node *child; struct property *properties; char indent[255] = ""; for(i = 0; i < depth * 3; i++) { indent[i] = ' '; } indent[i] = '\0'; ++depth; for_each_child_of_node(node, child) { printk(KERN_INFO "%s{ name = %s\n", indent, child->name); printk(KERN_INFO "%s type = %s\n", indent, child->type); for (properties = child->properties; properties != NULL; properties = properties->next) { printk(KERN_INFO "%s %s (%d)\n", indent, properties->name, properties->length); } print_device_tree_node(child, depth); printk(KERN_INFO "%s}\n", indent); } }
I would like to know how to define each type of property so that I can format the value and output it correctly. Any suggestions?
Finally, here is the original snippet, slightly modified by oh-so:
char *path = "/ fpga_dt@c0000000 "; struct device_node *dt_node; const u32 *property; int len; dt_node = of_find_node_by_path(path); if (!dt_node) { printk(KERN_ERR "(E) Failed to find device-tree node: %s\n", path); return -ENODEV; } printk(KERN_INFO "(I) Found device-tree node. Now retrieving property.\n"); property = of_get_property(dt_node, "reg", &len); printk(KERN_INFO "(I) len=%d\n", len); printk(KERN_INFO "(I) reg[0]=0x%08lX\n", (unsigned long) property[0]); printk(KERN_INFO "(I) reg[1]=0x%08lX\n", (unsigned long) property[1]); printk(KERN_INFO "(I) reg[2]=0x%08lX\n", (unsigned long) property[2]); printk(KERN_INFO "(I) reg[3]=0x%08lX\n", (unsigned long) property[3]);
A seg error occurred on some bad device tracks. Apparently there was some type error. I eventually fixed the problem by examining the root path and then some other base nodes (e.g. / cpu0, / memory, etc.), and finally I was able to examine my fpga. I'm not sure what really changed, but now I can correctly edit my node FPGA tree of devices using the code above.
Thanks for the help!:)
Trevor
source share