mirror of
https://github.com/torvalds/linux.git
synced 2026-06-01 02:53:36 +02:00
kselftest: devices: Add of-fullname-regex property
Introduce a new 'of-fullname-regex' property that takes a regular
expression and matches against the OF_FULLNAME property. It allows
matching controllers that don't have a unique DT address across sibling
controllers, and thus dt-mmio can't be used.
One particular example of where this is needed is on MT8195 which has
multiple USB controllers described by two level deep nodes and using the
ranges property:
ssusb2: usb@112a1000 {
reg = <0 0x112a1000 0 0x2dff>, <0 0x112a3e00 0 0x0100>;
ranges = <0 0 0 0x112a0000 0 0x3f00>;
xhci2: usb@0 {
Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
Link: https://lore.kernel.org/r/20240613-kselftest-discoverable-probe-mt8195-kci-v1-2-7b396a9b032d@collabora.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
f871f9bacd
commit
819984a0dd
|
|
@ -11,6 +11,10 @@
|
|||
# this, several optional keys can be used:
|
||||
# - dt-mmio: identify the MMIO address of the controller as defined in the
|
||||
# Devicetree.
|
||||
# - of-fullname-regex: regular expression to match against the OF_FULLNAME
|
||||
# property. Useful when the controller's address is not unique across other
|
||||
# sibling controllers. In this case, dt-mmio can't be used, and this property
|
||||
# allows the matching to include parent nodes as well to make it unique.
|
||||
# - usb-version: for USB controllers to differentiate between USB3 and USB2
|
||||
# buses sharing the same controller.
|
||||
# - acpi-uid: _UID property of the controller as supplied by the ACPI. Useful to
|
||||
|
|
|
|||
|
|
@ -64,6 +64,22 @@ def get_dt_mmio(sysfs_dev_dir):
|
|||
sysfs_dev_dir = os.path.dirname(sysfs_dev_dir)
|
||||
|
||||
|
||||
def get_of_fullname(sysfs_dev_dir):
|
||||
re_of_fullname = re.compile("OF_FULLNAME=(.*)")
|
||||
of_full_name = None
|
||||
|
||||
# PCI controllers' sysfs don't have an of_node, so have to read it from the
|
||||
# parent
|
||||
while not of_full_name:
|
||||
try:
|
||||
with open(os.path.join(sysfs_dev_dir, "uevent")) as f:
|
||||
of_fullname = re_of_fullname.search(f.read()).group(1)
|
||||
return of_fullname
|
||||
except:
|
||||
pass
|
||||
sysfs_dev_dir = os.path.dirname(sysfs_dev_dir)
|
||||
|
||||
|
||||
def get_acpi_uid(sysfs_dev_dir):
|
||||
with open(os.path.join(sysfs_dev_dir, "firmware_node", "uid")) as f:
|
||||
return f.read()
|
||||
|
|
@ -97,6 +113,11 @@ def find_controller_in_sysfs(controller, parent_sysfs=None):
|
|||
if str(controller["dt-mmio"]) != get_dt_mmio(c):
|
||||
continue
|
||||
|
||||
if controller.get("of-fullname-regex"):
|
||||
re_of_fullname = re.compile(str(controller["of-fullname-regex"]))
|
||||
if not re_of_fullname.match(get_of_fullname(c)):
|
||||
continue
|
||||
|
||||
if controller.get("usb-version"):
|
||||
if controller["usb-version"] != get_usb_version(c):
|
||||
continue
|
||||
|
|
@ -195,6 +216,9 @@ def generate_pathname(device):
|
|||
if device.get("dt-mmio"):
|
||||
pathname += "@" + str(device["dt-mmio"])
|
||||
|
||||
if device.get("of-fullname-regex"):
|
||||
pathname += "-" + str(device["of-fullname-regex"])
|
||||
|
||||
if device.get("name"):
|
||||
pathname = pathname + "/" + device["name"]
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user