From 3ce5e03e398334c41642dcd85c19807e8cbb8fce Mon Sep 17 00:00:00 2001 From: dlg Date: Mon, 3 Apr 2023 01:40:32 +0000 Subject: [PATCH] add phy_enable_prop_idx() to work with phys under props other than "phy". eg, the snps,dwc3 device tree bindings say that it uses a usb2 and usb3 phy, and they can be listed either "usb2-phy" and "usb3-phy" under the standard "phys" and "phy-names" properties supported by phy_enable(), or as slots 0 and 1 under a "usb-phy" properties. the latter would be supported by phy_enable_idx(), but it hardcodes "phys" as the property it looks at. phy_enable_prop_idx() is the same as phy_enable_prop_idx, but it lets you specify which property you're indexing into. ok kettenis@ --- sys/dev/ofw/ofw_misc.c | 12 +++++++++--- sys/dev/ofw/ofw_misc.h | 3 ++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/sys/dev/ofw/ofw_misc.c b/sys/dev/ofw/ofw_misc.c index 5f3a21486de..9bfa7979a38 100644 --- a/sys/dev/ofw/ofw_misc.c +++ b/sys/dev/ofw/ofw_misc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ofw_misc.c,v 1.40 2023/04/03 01:34:06 dlg Exp $ */ +/* $OpenBSD: ofw_misc.c,v 1.41 2023/04/03 01:40:32 dlg Exp $ */ /* * Copyright (c) 2017-2021 Mark Kettenis * @@ -250,7 +250,7 @@ phy_next_phy(uint32_t *cells) } int -phy_enable_idx(int node, int idx) +phy_enable_prop_idx(int node, char *prop, int idx) { uint32_t *phys; uint32_t *phy; @@ -262,7 +262,7 @@ phy_enable_idx(int node, int idx) return -1; phys = malloc(len, M_TEMP, M_WAITOK); - OF_getpropintarray(node, "phys", phys, len); + OF_getpropintarray(node, prop, phys, len); phy = phys; while (phy && phy < phys + (len / sizeof(uint32_t))) { @@ -278,6 +278,12 @@ phy_enable_idx(int node, int idx) return rv; } +int +phy_enable_idx(int node, int idx) +{ + return (phy_enable_prop_idx(node, "phys", idx)); +} + int phy_enable(int node, const char *name) { diff --git a/sys/dev/ofw/ofw_misc.h b/sys/dev/ofw/ofw_misc.h index 43847cf1f7a..6a21576b477 100644 --- a/sys/dev/ofw/ofw_misc.h +++ b/sys/dev/ofw/ofw_misc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ofw_misc.h,v 1.28 2023/04/03 01:30:33 dlg Exp $ */ +/* $OpenBSD: ofw_misc.h,v 1.29 2023/04/03 01:40:32 dlg Exp $ */ /* * Copyright (c) 2017-2021 Mark Kettenis * @@ -68,6 +68,7 @@ struct phy_device { void phy_register(struct phy_device *); +int phy_enable_prop_idx(int, char *, int); int phy_enable_idx(int, int); int phy_enable(int, const char *); -- 2.20.1