设备树中,有status属性,其作用是禁止或者启用设备。默认不写status的情况下,是启用设备的。下面看一下设备书描述文件中,对status属性的描述:
Property name: status
Value type: <string>
Description:
The status property indicates the operational status of a device. The lack of a status property should be treated as if the property existed with the value of “okay”. Valid values are listed and defined in Table 2.4.
Table 2.4: Values for status property
Value Description
“okay”: Indicates the device is operational.
“disabled”: Indicates that the device is not presently operational, but it might become operational in the future(for example, something is not plugged in, or switched off).Refer to the device binding for details on what disabled means for a given device.
“reserved” : Indicates that the device is operational, but should not be used. Typically this is used for devices that are controlled by another software component, such as platform firmware.
“fail”: Indicates that the device is not operational. A serious error was detected in the device, and it isunlikely to become operational without repair.
“fail-sss”: Indicates that the device is not operational. A serious error was detected in the device and it is unlikely to become operational without repair. The sss portion of the value is specific to the device and indicates the error condition detected.
文档截图如下:

一般默认情况下不设置status
下面看几个例子:
例1:
rwdt: watchdog@e6020000 {
compatible = “renesas,r8a77965-wdt”,
“renesas,rcar-gen3-wdt”;
reg = <0 0xe6020000 0 0x0c>;
clocks = <&cpg CPG_MOD 402>;
power-domains = <&sysc R8A77965_PD_ALWAYS_ON>;
resets = <&cpg 402>;
status = “disabled”;
};
status设置为disabled表明,不启用。
例2:
CPU_SLEEP_0: cpu-sleep-0 {
compatible = “arm,idle-state”;
arm,psci-suspend-param = <0x0010000>;
local-timer-stop;
entry-latency-us = <400>;
exit-latency-us = <500>;
min-residency-us = <4000>;
status = “okay”;
};
status设置为okay表明,启用
例3:
gpio0: gpio@e6050000 {
compatible = “renesas,gpio-r8a77965”,
“renesas,rcar-gen3-gpio”;
reg = <0 0xe6050000 0 0x50>;
interrupts = <GIC_SPI 4 IRQ_TYPE_LEVEL_HIGH>;
#gpio-cells = <2>;
gpio-controller;
gpio-ranges = <&pfc 0 0 16>;
#interrupt-cells = <2>;
interrupt-controller;
clocks = <&cpg CPG_MOD 912>;
power-domains = <&sysc R8A77965_PD_ALWAYS_ON>;
resets = <&cpg 912>;
};
该节点,没有设置status属性,默认是启用的。
下面我看一下,内核代码中对设备树的status属性的处理代码,代码路径为:drivers/of/base.c
/**
* __of_device_is_available – check if a device is available for use
*
* @device: Node to check for availability, with locks already held
*
* Returns true if the status property is absent or set to “okay” or “ok”,
* false otherwise
*/
static bool __of_device_is_available(const struct device_node *device)
{
const char *status;
int statlen;
if (!device)
return false;
status = __of_get_property(device, “status”, &statlen);
if (status == NULL)
return true;
if (statlen > 0) {
if (!strcmp(status, “okay”) || !strcmp(status, “ok”))
return true;
}
return false;
}
看代码中,可以知道,不写status属性,设置status属性为“okay”或“ok”,这三种情况都是启动设备。
