How to read child node property in a device tree
Solution 1:
Yes, you can do it. Just write a similar function as below and call it in AA with the path of the child node of BB.
For example, From AA if you need to access BB/child_2 property then pass the absolute path to of_find_node_by_path() function.
Also, check of_* family of function in the kernel that might be useful.
static void access_dt(void)
{
/* device node path - check it from /proc/device-tree/ */
char *path = "/path/to/BB/child_2";
struct device_node *dt_node;
const u8 *prop = NULL;
int ret;
dt_node = of_find_node_by_path(path);
if (!dt_node) {
printk(KERN_ERR "Failed to find node by path: %s.\n");
} else {
printk(KERN_INFO "Found the node for %s.\n", path);
prop = of_get_property(dt_node, "property 2", &ret);
if(!prop) {
//You are still in trouble!
} else {
//You have got property 2 of BB!
}
}
}
Solution 2:
If I understood correctly you have to use something like for_each_child_of_node().
Check for example drivers/input/keyboard/gpio_keys.c and Documentation/devicetree/bindings/input/gpio-keys.txt.