Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

phy: add phy_get_bus_width()/phy_set_bus_width() calls

This adds a pair of APIs that allows the generic PHY subsystem to
provide information on the PHY bus width. The PHY provider driver may
use phy_set_bus_width() to set the bus width that the PHY supports.
The controller driver may then use phy_get_bus_width() to fetch the
PHY bus width in order to properly configure the controller.

Signed-off-by: Matt Porter <mporter@linaro.org>
Acked-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>

authored by

Matt Porter and committed by
Felipe Balbi
8feed347 e90b8417

+28
+28
include/linux/phy/phy.h
··· 38 38 }; 39 39 40 40 /** 41 + * struct phy_attrs - represents phy attributes 42 + * @bus_width: Data path width implemented by PHY 43 + */ 44 + struct phy_attrs { 45 + u32 bus_width; 46 + }; 47 + 48 + /** 41 49 * struct phy - represents the phy device 42 50 * @dev: phy device 43 51 * @id: id of the phy device ··· 54 46 * @mutex: mutex to protect phy_ops 55 47 * @init_count: used to protect when the PHY is used by multiple consumers 56 48 * @power_count: used to protect when the PHY is used by multiple consumers 49 + * @phy_attrs: used to specify PHY specific attributes 57 50 */ 58 51 struct phy { 59 52 struct device dev; ··· 64 55 struct mutex mutex; 65 56 int init_count; 66 57 int power_count; 58 + struct phy_attrs attrs; 67 59 }; 68 60 69 61 /** ··· 137 127 int phy_exit(struct phy *phy); 138 128 int phy_power_on(struct phy *phy); 139 129 int phy_power_off(struct phy *phy); 130 + static inline int phy_get_bus_width(struct phy *phy) 131 + { 132 + return phy->attrs.bus_width; 133 + } 134 + static inline void phy_set_bus_width(struct phy *phy, int bus_width) 135 + { 136 + phy->attrs.bus_width = bus_width; 137 + } 140 138 struct phy *phy_get(struct device *dev, const char *string); 141 139 struct phy *devm_phy_get(struct device *dev, const char *string); 142 140 void phy_put(struct phy *phy); ··· 215 197 static inline int phy_power_off(struct phy *phy) 216 198 { 217 199 return -ENOSYS; 200 + } 201 + 202 + static inline int phy_get_bus_width(struct phy *phy) 203 + { 204 + return -ENOSYS; 205 + } 206 + 207 + static inline void phy_set_bus_width(struct phy *phy, int bus_width) 208 + { 209 + return; 218 210 } 219 211 220 212 static inline struct phy *phy_get(struct device *dev, const char *string)