mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@barebox.org>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@barebox.org>
Subject: [PATCH 2/4] phy: add devinfo callback
Date: Mon, 27 Oct 2025 08:00:54 +0100	[thread overview]
Message-ID: <20251027070214.2425834-3-a.fatoum@barebox.org> (raw)
In-Reply-To: <20251027070214.2425834-1-a.fatoum@barebox.org>

To make debugging of generic PHYs more convenient, add a devinfo
callback to extract some information from the struct phy.

Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
 drivers/phy/phy-core.c | 61 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 61 insertions(+)

diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
index f876dc2dea0f..d4c704809cfa 100644
--- a/drivers/phy/phy-core.c
+++ b/drivers/phy/phy-core.c
@@ -20,6 +20,65 @@ static int phy_ida;
 
 DEFINE_DEV_CLASS(phy_class, "phy");
 
+static const char *phy_mode_tostr(struct phy *phy)
+{
+	switch (phy->attrs.mode) {
+	case PHY_MODE_INVALID:
+		return "invalid";
+	case PHY_MODE_USB_HOST:
+		return "usb-host";
+	case PHY_MODE_USB_HOST_LS:
+		return "usb-host-ls";
+	case PHY_MODE_USB_HOST_FS:
+		return "usb-host-fs";
+	case PHY_MODE_USB_HOST_HS:
+		return "usb-host-hs";
+	case PHY_MODE_USB_HOST_SS:
+		return "usb-host-ss";
+	case PHY_MODE_USB_DEVICE:
+		return "usb-device";
+	case PHY_MODE_USB_DEVICE_LS:
+		return "usb-device-ls";
+	case PHY_MODE_USB_DEVICE_FS:
+		return "usb-device-fs";
+	case PHY_MODE_USB_DEVICE_HS:
+		return "usb-device-hs";
+	case PHY_MODE_USB_DEVICE_SS:
+		return "usb-device-ss";
+	case PHY_MODE_USB_OTG:
+		return "usb-otg";
+	case PHY_MODE_UFS_HS_A:
+		return "ufs-hs-a";
+	case PHY_MODE_UFS_HS_B:
+		return "ufs-hs-b";
+	case PHY_MODE_PCIE:
+		return "pcie";
+	case PHY_MODE_ETHERNET:
+		return "ethernet";
+	case PHY_MODE_MIPI_DPHY:
+		return "mipi-dphy";
+	case PHY_MODE_SATA:
+		return "sata";
+	case PHY_MODE_LVDS:
+		return "lvds";
+	case PHY_MODE_DP:
+		return "dp";
+	}
+
+	return "unknown";
+}
+
+static void phy_devinfo(struct device *dev)
+{
+	struct phy *phy = container_of(dev, struct phy, dev);
+
+	printf("PHY info:\n");
+	if (phy->attrs.mode != PHY_MODE_INVALID)
+		printf("  mode: %s\n", phy_mode_tostr(phy));
+	printf("  init count: %u\n", phy->init_count);
+	printf("  power count: %u\n", phy->power_count);
+}
+
 /**
  * phy_create() - create a new phy
  * @dev: device that is creating the new phy
@@ -64,6 +123,8 @@ struct phy *phy_create(struct device *dev, struct device_node *node,
 	if (ret)
 		goto free_ida;
 
+	devinfo_add(&phy->dev, phy_devinfo);
+
 	return phy;
 
 free_ida:
-- 
2.47.3




  parent reply	other threads:[~2025-10-27  7:02 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-27  7:00 [PATCH 0/4] phy: rockchip: add MIPI-DSI phy driver Ahmad Fatoum
2025-10-27  7:00 ` [PATCH 1/4] phy: add support for generic MIPI D-PHY Ahmad Fatoum
2025-10-27  7:00 ` Ahmad Fatoum [this message]
2025-10-27  7:00 ` [PATCH 3/4] phy: add phy_configure operation Ahmad Fatoum
2025-10-27  7:00 ` [PATCH 4/4] phy: rockchip: add Innosilicon MIPI/LVDS/TTL PHY driver Ahmad Fatoum
2025-10-28  7:35 ` [PATCH 0/4] phy: rockchip: add MIPI-DSI phy driver Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251027070214.2425834-3-a.fatoum@barebox.org \
    --to=a.fatoum@barebox.org \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox