I'm writing a UBoot driver for bitbanged NAND and need to add it to the device tree.
Because this device is not on any bus and only references GPIO pins, I want to put it directly at the device tree root (like it's done for gpio-leds
):
/ {
nand {
status = "ok";
compatible = "onfi,bitbang-nand";
pinctrl-0 = <&nand_pins>;
pinctrl-names = "default";
nand-bus-width = <8>;
data-gpios = <&gpio 40 0>,
<&gpio 41 0>,
<&gpio 42 0>,
<&gpio 43 0>,
<&gpio 44 0>,
<&gpio 45 0>,
<&gpio 46 0>,
<&gpio 47 0>;
ale-gpios = <&gpio 38 0>;
cle-gpios = <&gpio 39 0>;
nre-gpios = <&gpio 36 0>;
nwe-gpios = <&gpio 35 0>;
nce-gpios = <&gpio 44 0>;
nwp-gpios = <&gpio 44 0>;
rdy-gpios = <&gpio 47 0>;
};
};
When the device is declared as such, UBoot does not recognize the device, and it's not even present in device tree node binding log. When I add a subnode to the device, UBoot recognizes nand
as a device:
/ {
nand {
compatible = "onfi,bitbang-nand";
#address-cells = <1>;
#size-cells = <1>;
pinctrl-0 = <&nand_pins>;
pinctrl-names = "default";
nand@0 {
status = "ok";
nand-bus-width = <8>;
data-gpios = <&gpio 40 0>,
<&gpio 41 0>,
<&gpio 42 0>,
<&gpio 43 0>,
<&gpio 44 0>,
<&gpio 45 0>,
<&gpio 46 0>,
<&gpio 47 0>;
ale-gpios = <&gpio 38 0>;
cle-gpios = <&gpio 39 0>;
nre-gpios = <&gpio 36 0>;
nwe-gpios = <&gpio 35 0>;
nce-gpios = <&gpio 44 0>;
nwp-gpios = <&gpio 44 0>;
rdy-gpios = <&gpio 47 0>;
};
};
};
Why the first example is not considered a device and the second one is? I couldn't find anything relevant in the specification.
This was a silly mistake. According to the specification, the right status
value is okay
, not ok
. So, the node nand
was read by dm_scan_fdt_node
in drivers/core/root.c
and discarded as disabled. Second version was found because absent status
field is equivalent to the enabled device.