ACPI vs. DT - Casing and Other Differences with Named Child Nodes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello All,

Recently, an interesting ACPI vs. DT case arose with a patchset adding DT
bindings and fwnode support (using the firmware-independent device_* api)
for the CP2112, a USB-HID device which provides a GPIO chip and an I2C
controller [1].

The DT binding and driver use the named child nodes - "i2c" and "gpio" -
to be assigned to the child I2C controller and GPIO chip, respectively.
This seems to be a common practice in DT (children named "mdio",
"connector", or "ports", for example), and an ACPIimplementation of the
`get_named_child_node` fwnode operation _does_ exist
(acpi_fwnode_get_named_child_node). However, ACPI node names are always
uppercase, and it seems that these names tend not to carry meaning, and
potentially shouldn't be used to identify a node in a driver. DeviceTree,
in contrast, does allow for uppercase or lowercase node names (if I'm
reading the specification correctly), but
1) It seems that node names are lowercase by convention, from the current
bindings, and
2) node names appear to be technically case-sensitive, per the spec and
[2]

In other words, the patchset in [1] inherently won't work for ACPI in the
current state, since it accesses children by lowercase names, a.e.
`device_get_named_child_node(&hdev->dev,"i2c")`

How can the identification of child nodes within a driver/device be
unified in both languages? Is this a problem that has already been solved?

Some suggestions thus far:

- In the (any) driver, first try to access nodes by name per the DT binding,
then fall-back to accessing nodes by index (a.e. "i2c" is child Zero,
"gpio" is child One). Alternatively, instead of first trying named access,
determine the type of access based on if the passed fw_node is
DT or ACPI (or other). Ideally, this would take the form of a / some new
fwnode/device API functions, so that device drivers wouldn't have to code
for the nuances of each different firmware description language.

- Since ACPI node names are technically "case insensitive" (a.e. iasl
translates them to uppercase if the are specified as lowercase), would it
be valid to do a case insensitive compare in
`acpi_fwnode_get_named_child_node`? Of course, this doesn't address the
issue that ACPI node names shouldn't necessarily be used as identifiers, but
it seems there is _some_ precedence of using named child nodes for ACPI
in mainline kernel code (a.e. drivers/platform/x86/intel accesses the
(uppercase) named child "DD04").


Any additional discussion or suggestions are most welcome!

Thanks,

Danny Kaehn

[1]
https://patchwork.kernel.org/project/linux-input/patch/20230227140758.1575-4-kaehndan@xxxxxxxxx/
[2] https://www.spinics.net/lists/devicetree-spec/msg00328.html



[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux