Skip to contentSkip to conversation

phy: Add max_link_rate as a PHY attribute along with get/set APIs

PATCH In review Yuti Amonkar 2 participants 2 messages Apr 25, 2020 – Apr 27, 2020 Generic PHY framework

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 phy: Add max_link_rate as a PHY attribute along with get/set APIs

The patch adds a pair of APIs that allow the generic PHY subsystem to provide information on the maximum value of link rate supported by the PHY. The PHY provider driver may use phy_set_max_link_rate() to set the maximum link rate that the PHY supports. The controller driver may then use phy_get_max_link_rate() to fetch the PHY link rate in order to properly configure the controller.

---
 include/linux/phy/phy.h | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
include/linux/phy/phy.h +21 -0
index bcee8eba62b3..a8b7b4a2b8de 100644
@@ -119,6 +119,7 @@ struct phy_ops {
  */
 struct phy_attrs {
 	u32			bus_width;
+	u32			max_link_rate;
 	enum phy_mode		mode;
 };
 
@@ -231,6 +232,16 @@ static inline void phy_set_bus_width(struct phy *phy, int bus_width)
 {
 	phy->attrs.bus_width = bus_width;
 }
+
+static inline int phy_get_max_link_rate(struct phy *phy)
+{
+	return phy->attrs.max_link_rate;
+}
+
+static inline void phy_set_max_link_rate(struct phy *phy, int link_rate)
+{
+	phy->attrs.max_link_rate = link_rate;
+}
 struct phy *phy_get(struct device *dev, const char *string);
 struct phy *phy_optional_get(struct device *dev, const char *string);
 struct phy *devm_phy_get(struct device *dev, const char *string);
@@ -389,6 +400,16 @@ static inline void phy_set_bus_width(struct phy *phy, int bus_width)
 	return;
 }
 
+static inline int phy_get_max_link_rate(struct phy *phy)
+{
+	return -ENOSYS;
+}
+
+static inline void phy_set_max_link_rate(struct phy *phy, int link_rate)
+{
+	return;
+}
+
 static inline struct phy *phy_get(struct device *dev, const char *string)
 {
 	return ERR_PTR(-ENOSYS);
Signature · 1 line
2.26.1
#1 lore raw

Hi Yuti,

Quoted 8 lines · Yuti Amonkar

The patch adds a pair of APIs that allow the generic PHY subsystem to provide information on the maximum value of link rate supported by the PHY. The PHY provider driver may use phy_set_max_link_rate() to set the maximum link rate that the PHY supports. The controller driver may then use phy_get_max_link_rate() to fetch the PHY link rate in order to properly configure the controller.

This patch should preferably be sent along with the patch that uses these functions (unless you have some specific reason).

Thanks
Kishon

Quoted 51 lines
---
 include/linux/phy/phy.h | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
include/linux/phy/phy.h +21 -0
index bcee8eba62b3..a8b7b4a2b8de 100644
@@ -119,6 +119,7 @@ struct phy_ops {
  */
 struct phy_attrs {
 	u32			bus_width;
+	u32			max_link_rate;
 	enum phy_mode		mode;
 };
 
@@ -231,6 +232,16 @@ static inline void phy_set_bus_width(struct phy *phy, int bus_width)
 {
 	phy->attrs.bus_width = bus_width;
 }
+
+static inline int phy_get_max_link_rate(struct phy *phy)
+{
+	return phy->attrs.max_link_rate;
+}
+
+static inline void phy_set_max_link_rate(struct phy *phy, int link_rate)
+{
+	phy->attrs.max_link_rate = link_rate;
+}
 struct phy *phy_get(struct device *dev, const char *string);
 struct phy *phy_optional_get(struct device *dev, const char *string);
 struct phy *devm_phy_get(struct device *dev, const char *string);
@@ -389,6 +400,16 @@ static inline void phy_set_bus_width(struct phy *phy, int bus_width)
 	return;
 }
 
+static inline int phy_get_max_link_rate(struct phy *phy)
+{
+	return -ENOSYS;
+}
+
+static inline void phy_set_max_link_rate(struct phy *phy, int link_rate)
+{
+	return;
+}
+
 static inline struct phy *phy_get(struct device *dev, const char *string)
 {
 	return ERR_PTR(-ENOSYS);