From 850557842f01ecb47b00ecb43b3bc3c8f1bb826f Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Thu, 29 Sep 2016 11:41:14 +0200 Subject: phy: Introduce of_phy_get_by_phandle Currently generic phy support assumes that the standard phy binding from dts/Bindings/phy/phy-bindings.txt is used. This adds a helper function which can be used to retrieve a phy when this standard binding is not used. Signed-off-by: Sascha Hauer --- include/linux/phy/phy.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'include/linux') diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h index 94f0044036..0d78923358 100644 --- a/include/linux/phy/phy.h +++ b/include/linux/phy/phy.h @@ -136,6 +136,8 @@ static inline void phy_set_bus_width(struct phy *phy, int bus_width) } struct phy *phy_get(struct device_d *dev, const char *string); struct phy *phy_optional_get(struct device_d *dev, const char *string); +struct phy *of_phy_get_by_phandle(struct device_d *dev, const char *phandle, + u8 index); void phy_put(struct phy *phy); struct phy *of_phy_get(struct device_node *np, const char *con_id); struct phy *of_phy_simple_xlate(struct device_d *dev, @@ -198,6 +200,12 @@ static inline struct phy *phy_optional_get(struct device_d *dev, return ERR_PTR(-ENOSYS); } +static inline struct phy *of_phy_get_by_phandle(struct device_d *dev, + const char *phandle, u8 index) +{ + return ERR_PTR(-ENOSYS); +} + static inline void phy_put(struct phy *phy) { } -- cgit v1.2.3 From 081554dca90cdc59d6ca64f83125e741078ea0d9 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Thu, 29 Sep 2016 11:40:30 +0200 Subject: phy: Introduce to_usbphy conversion function The generic phy support layer has the necessary list handling and phy retrieval functions, so we should reuse them for usb phys. This adds a phy_to_usbphy() conversion function which drivers can implement which attach to the generic phy layer and are really usb phys. Signed-off-by: Sascha Hauer --- drivers/phy/phy-core.c | 12 ++++++++++++ include/linux/phy/phy.h | 8 ++++++++ 2 files changed, 20 insertions(+) (limited to 'include/linux') diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index 7c1f3d440b..1b6a9f7b1d 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -15,6 +15,7 @@ #include #include #include +#include static LIST_HEAD(phy_provider_list); static int phy_ida; @@ -201,6 +202,17 @@ int phy_power_off(struct phy *phy) return 0; } +struct usb_phy *phy_to_usbphy(struct phy *phy) +{ + if (!phy) + return NULL; + + if (!phy->ops->to_usbphy) + return ERR_PTR(-EINVAL); + + return phy->ops->to_usbphy(phy); +} + static struct phy_provider *of_phy_provider_lookup(struct device_node *node) { struct phy_provider *phy_provider; diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h index 0d78923358..5d96e02df4 100644 --- a/include/linux/phy/phy.h +++ b/include/linux/phy/phy.h @@ -33,6 +33,7 @@ struct phy_ops { int (*exit)(struct phy *phy); int (*power_on)(struct phy *phy); int (*power_off)(struct phy *phy); + struct usb_phy *(*to_usbphy)(struct phy *phy); }; /** @@ -150,6 +151,7 @@ struct phy_provider *__of_phy_provider_register(struct device_d *dev, struct phy * (*of_xlate)(struct device_d *dev, struct of_phandle_args *args)); void of_phy_provider_unregister(struct phy_provider *phy_provider); +struct usb_phy *phy_to_usbphy(struct phy *phy); #else static inline int phy_init(struct phy *phy) { @@ -243,6 +245,12 @@ static inline struct phy_provider *__of_phy_provider_register( static inline void of_phy_provider_unregister(struct phy_provider *phy_provider) { } + +static inline struct usb_phy *phy_to_usbphy(struct phy *phy) +{ + return NULL; +} + #endif #endif /* __DRIVERS_PHY_H */ -- cgit v1.2.3