summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorLucien.Jheng <[email protected]>2026-04-25 16:06:47 +0800
committerJerome Forissier <[email protected]>2026-05-06 11:07:22 +0200
commit9eca7fd0d3902e30563f54b0e95d8d4c5f23b70c (patch)
tree1d8cb5a51f2aaf4f2f2e5e4320bc6ce28fee0031 /include/linux
parent5bb7ae8921eea48e3fa1a810dc5668123ceacb38 (diff)
phy: add common PHY properties support
Add a new PHY_COMMON_PROPS library that provides helper functions for PHY drivers to read standardized polarity properties from the device tree node: - phy_get_rx_polarity() / phy_get_tx_polarity() - phy_get_manual_rx_polarity() / phy_get_manual_tx_polarity() The dt-bindings/phy/phy.h header with PHY_POL_NORMAL, PHY_POL_INVERT, and PHY_POL_AUTO constants is provided via dts/upstream/include, which is already in the build include path. Ported from Merge tag 'phy-for-7.0': git://git.kernel.org/pub/scm/linux/kernel/git/phy/linux-phy Link: https://git.kernel.org/linus/e7556b59ba65179612bce3fa56bb53d1b4fb20db Signed-off-by: Lucien.Jheng <[email protected]>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/phy/phy-common-props.h69
1 files changed, 69 insertions, 0 deletions
diff --git a/include/linux/phy/phy-common-props.h b/include/linux/phy/phy-common-props.h
new file mode 100644
index 00000000000..9158851f2e1
--- /dev/null
+++ b/include/linux/phy/phy-common-props.h
@@ -0,0 +1,69 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * phy-common-props.h -- Common properties for generic PHYs
+ *
+ * Copyright 2025-2026 NXP
+ */
+
+#ifndef __PHY_COMMON_PROPS_H
+#define __PHY_COMMON_PROPS_H
+
+#include <dt-bindings/phy/phy.h>
+#include <dm/ofnode.h>
+
+/**
+ * phy_get_rx_polarity - Get RX polarity for PHY differential lane
+ * @node: Pointer to the PHY's device tree node.
+ * @mode_name: The name of the PHY mode to look up.
+ * @supported: Bit mask of PHY_POL_NORMAL, PHY_POL_INVERT and PHY_POL_AUTO
+ * @default_val: Default polarity value if property is missing
+ * @val: Pointer to returned polarity.
+ *
+ * Return: zero on success, negative error on failure.
+ */
+int phy_get_rx_polarity(ofnode node, const char *mode_name,
+ unsigned int supported, unsigned int default_val,
+ unsigned int *val);
+
+/**
+ * phy_get_tx_polarity - Get TX polarity for PHY differential lane
+ * @node: Pointer to the PHY's device tree node.
+ * @mode_name: The name of the PHY mode to look up.
+ * @supported: Bit mask of PHY_POL_NORMAL, PHY_POL_INVERT and PHY_POL_AUTO
+ * @default_val: Default polarity value if property is missing
+ * @val: Pointer to returned polarity.
+ *
+ * Return: zero on success, negative error on failure.
+ */
+int phy_get_tx_polarity(ofnode node, const char *mode_name,
+ unsigned int supported, unsigned int default_val,
+ unsigned int *val);
+
+/**
+ * phy_get_manual_rx_polarity - Get manual RX polarity for PHY differential lane
+ * @node: Pointer to the PHY's device tree node.
+ * @mode_name: The name of the PHY mode to look up.
+ * @val: Pointer to returned polarity.
+ *
+ * Helper for PHYs which do not support protocols with automatic RX polarity
+ * detection and correction.
+ *
+ * Return: zero on success, negative error on failure.
+ */
+int phy_get_manual_rx_polarity(ofnode node, const char *mode_name,
+ unsigned int *val);
+
+/**
+ * phy_get_manual_tx_polarity - Get manual TX polarity for PHY differential lane
+ * @node: Pointer to the PHY's device tree node.
+ * @mode_name: The name of the PHY mode to look up.
+ * @val: Pointer to returned polarity.
+ *
+ * Helper for PHYs without any custom default value for the TX polarity.
+ *
+ * Return: zero on success, negative error on failure.
+ */
+int phy_get_manual_tx_polarity(ofnode node, const char *mode_name,
+ unsigned int *val);
+
+#endif /* __PHY_COMMON_PROPS_H */