mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 6/9] phy: Introduce to_usbphy conversion function
Date: Thu, 29 Sep 2016 14:38:57 +0200	[thread overview]
Message-ID: <20160929123900.24853-6-s.hauer@pengutronix.de> (raw)
In-Reply-To: <20160929123900.24853-1-s.hauer@pengutronix.de>

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 <s.hauer@pengutronix.de>
---
 drivers/phy/phy-core.c  | 12 ++++++++++++
 include/linux/phy/phy.h |  8 ++++++++
 2 files changed, 20 insertions(+)

diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
index 7c1f3d4..1b6a9f7 100644
--- a/drivers/phy/phy-core.c
+++ b/drivers/phy/phy-core.c
@@ -15,6 +15,7 @@
 #include <common.h>
 #include <malloc.h>
 #include <linux/phy/phy.h>
+#include <usb/phy.h>
 
 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 0d78923..5d96e02 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 */
-- 
2.9.3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2016-09-29 12:39 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-29 12:38 [PATCH 1/9] usb: Use standard debug macro Sascha Hauer
2016-09-29 12:38 ` [PATCH 2/9] usb: Add usb phy to usb host Sascha Hauer
2016-09-29 12:38 ` [PATCH 3/9] usb: ehci: forward phy given in registration data to host Sascha Hauer
2016-09-29 12:38 ` [PATCH 4/9] usb: imx-usb-phy: Drop unnecessary read/modify/write Sascha Hauer
2016-09-29 12:38 ` [PATCH 5/9] phy: Introduce of_phy_get_by_phandle Sascha Hauer
2016-09-29 12:38 ` Sascha Hauer [this message]
2016-09-29 12:38 ` [PATCH 7/9] phy: Add usb-nop-xceiv support Sascha Hauer
2016-09-29 12:38 ` [PATCH 8/9] usb: imx-us-phy: Convert driver to generic phy support Sascha Hauer
2016-09-29 12:39 ` [PATCH 9/9] usb: imx-us-phy: implement notify_(dis)concect 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=20160929123900.24853-6-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --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