From: Ahmad Fatoum <a.fatoum@barebox.org>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@barebox.org>
Subject: [PATCH 3/4] phy: add phy_configure operation
Date: Mon, 27 Oct 2025 08:00:55 +0100 [thread overview]
Message-ID: <20251027070214.2425834-4-a.fatoum@barebox.org> (raw)
In-Reply-To: <20251027070214.2425834-1-a.fatoum@barebox.org>
This callback will be needed for upcoming Rockchip MIPI-DSI PHY support.
Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
drivers/phy/phy-core.c | 23 +++++++++++++++++++++++
include/linux/phy/phy.h | 32 ++++++++++++++++++++++++++++++++
2 files changed, 55 insertions(+)
diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
index d4c704809cfa..fa404884c924 100644
--- a/drivers/phy/phy-core.c
+++ b/drivers/phy/phy-core.c
@@ -282,6 +282,29 @@ int phy_set_mode_ext(struct phy *phy, enum phy_mode mode, int submode)
}
EXPORT_SYMBOL_GPL(phy_set_mode_ext);
+/**
+ * phy_configure() - Changes the phy parameters
+ * @phy: the phy returned by phy_get()
+ * @opts: New configuration to apply
+ *
+ * Used to change the PHY parameters. phy_init() must have been called
+ * on the phy. The configuration will be applied on the current phy
+ * mode, that can be changed using phy_set_mode().
+ *
+ * Return: %0 if successful, a negative error code otherwise
+ */
+int phy_configure(struct phy *phy, union phy_configure_opts *opts)
+{
+ if (!phy)
+ return -EINVAL;
+
+ if (!phy->ops->configure)
+ return -EOPNOTSUPP;
+
+ return phy->ops->configure(phy, opts);
+}
+EXPORT_SYMBOL_GPL(phy_configure);
+
struct usb_phy *phy_to_usbphy(struct phy *phy)
{
if (!phy)
diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h
index b4a99c9c7037..89e62dee9139 100644
--- a/include/linux/phy/phy.h
+++ b/include/linux/phy/phy.h
@@ -44,6 +44,16 @@ enum phy_mode {
PHY_MODE_DP
};
+/**
+ * union phy_configure_opts - Opaque generic phy configuration
+ *
+ * @mipi_dphy: Configuration set applicable for phys supporting
+ * the MIPI_DPHY phy mode.
+ */
+union phy_configure_opts {
+ struct phy_configure_opts_mipi_dphy mipi_dphy;
+};
+
/**
* struct phy_ops - set of function pointers for performing phy operations
* @init: operation to be performed for initializing phy
@@ -60,6 +70,18 @@ struct phy_ops {
int (*power_off)(struct phy *phy);
int (*set_mode)(struct phy *phy, enum phy_mode mode, int submode);
struct usb_phy *(*to_usbphy)(struct phy *phy);
+
+ /**
+ * @configure:
+ *
+ * Optional.
+ *
+ * Used to change the PHY parameters. phy_init() must have
+ * been called on the phy.
+ *
+ * Returns: 0 if successful, an negative error code otherwise
+ */
+ int (*configure)(struct phy *phy, union phy_configure_opts *opts);
};
/**
@@ -159,6 +181,7 @@ int phy_power_off(struct phy *phy);
int phy_set_mode_ext(struct phy *phy, enum phy_mode mode, int submode);
#define phy_set_mode(phy, mode) \
phy_set_mode_ext(phy, mode, 0)
+int phy_configure(struct phy *phy, union phy_configure_opts *opts);
static inline int phy_get_bus_width(struct phy *phy)
{
return phy->attrs.bus_width;
@@ -222,6 +245,15 @@ static inline int phy_set_mode_ext(struct phy *phy, enum phy_mode mode,
#define phy_set_mode(phy, mode) \
phy_set_mode_ext(phy, mode, 0)
+static inline int phy_configure(struct phy *phy,
+ union phy_configure_opts *opts)
+{
+ if (!phy)
+ return 0;
+
+ return -ENOSYS;
+}
+
static inline int phy_get_bus_width(struct phy *phy)
{
return -ENOSYS;
--
2.47.3
next prev 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 ` [PATCH 2/4] phy: add devinfo callback Ahmad Fatoum
2025-10-27 7:00 ` Ahmad Fatoum [this message]
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-4-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