devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Roger Quadros <rogerq@ti.com>
To: balbi@ti.com
Cc: tony@atomide.com, mark.rutland@arm.com, mkl@pengutronix.de,
	linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org,
	linux-omap@vger.kernel.org, devicetree-discuss@lists.ozlabs.org,
	rogerq@ti.com
Subject: [PATCH 8/8] USB: phy: nop: Defer probe if device needs VCC/RESET
Date: Tue, 12 Mar 2013 13:24:26 +0200	[thread overview]
Message-ID: <1363087466-32444-9-git-send-email-rogerq@ti.com> (raw)
In-Reply-To: <1363087466-32444-1-git-send-email-rogerq@ti.com>

Add 2 flags, needs_vcc and needs_reset to platform data.
If the flag is set and the regulator couldn't be found
then we bail out with -EPROBE_DEFER.

For device tree boot we depend on presensce of vcc-supply/
reset-supply properties to decide if we should bail out
with -EPROBE_DEFER or just continue in case the regulator
can't be found.

This is required for proper functionality in cases where the
regulator is needed but is probed later than the PHY device.

Signed-off-by: Roger Quadros <rogerq@ti.com>
Acked-by: Felipe Balbi <balbi@ti.com>
---
 drivers/usb/otg/nop-usb-xceiv.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/otg/nop-usb-xceiv.c b/drivers/usb/otg/nop-usb-xceiv.c
index b26b1c2..2b10cc9 100644
--- a/drivers/usb/otg/nop-usb-xceiv.c
+++ b/drivers/usb/otg/nop-usb-xceiv.c
@@ -147,6 +147,8 @@ static int nop_usb_xceiv_probe(struct platform_device *pdev)
 	enum usb_phy_type	type = USB_PHY_TYPE_USB2;
 	int err;
 	u32 clk_rate = 0;
+	bool needs_vcc = false;
+	bool needs_reset = false;
 
 	nop = devm_kzalloc(&pdev->dev, sizeof(*nop), GFP_KERNEL);
 	if (!nop)
@@ -163,9 +165,14 @@ static int nop_usb_xceiv_probe(struct platform_device *pdev)
 		if (of_property_read_u32(node, "clock-frequency", &clk_rate))
 			clk_rate = 0;
 
+		needs_vcc = of_property_read_bool(node, "vcc-supply");
+		needs_reset = of_property_read_bool(node, "reset-supply");
+
 	} else if (pdata) {
 		type = pdata->type;
 		clk_rate = pdata->clk_rate;
+		needs_vcc = pdata->needs_vcc;
+		needs_reset = pdata->needs_reset;
 	}
 
 	nop->clk = devm_clk_get(&pdev->dev, "main_clk");
@@ -194,12 +201,16 @@ static int nop_usb_xceiv_probe(struct platform_device *pdev)
 	if (IS_ERR(nop->vcc)) {
 		dev_dbg(&pdev->dev, "Error getting vcc regulator: %ld\n",
 					PTR_ERR(nop->vcc));
+		if (needs_vcc)
+			return -EPROBE_DEFER;
 	}
 
 	nop->reset = devm_regulator_get(&pdev->dev, "reset");
 	if (IS_ERR(nop->reset)) {
 		dev_dbg(&pdev->dev, "Error getting reset regulator: %ld\n",
 					PTR_ERR(nop->reset));
+		if (needs_reset)
+			return -EPROBE_DEFER;
 	}
 
 	nop->dev		= &pdev->dev;
-- 
1.7.4.1

      parent reply	other threads:[~2013-03-12 11:24 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-12 11:24 [PATCH 0/8] USB: PHY: nop: Device tree support for 3.10 Roger Quadros
     [not found] ` <1363087466-32444-1-git-send-email-rogerq-l0cyMroinI0@public.gmane.org>
2013-03-12 11:24   ` [PATCH 1/8] usb: phy: nop: Add some parameters to platform data Roger Quadros
2013-03-12 11:54     ` Marc Kleine-Budde
     [not found]       ` <513F177D.40500-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2013-03-12 14:12         ` Roger Quadros
2013-03-12 14:17           ` Marc Kleine-Budde
     [not found]             ` <513F38DF.5040404-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2013-03-12 14:28               ` Roger Quadros
     [not found]                 ` <513F3B7E.8000002-l0cyMroinI0@public.gmane.org>
2013-03-12 14:42                   ` Marc Kleine-Budde
     [not found]                     ` <513F3EF0.3030609-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2013-03-12 15:20                       ` Roger Quadros
     [not found]                         ` <513F47B4.2060004-l0cyMroinI0@public.gmane.org>
2013-03-12 16:06                           ` Marc Kleine-Budde
2013-03-13 15:17                           ` Peter Ujfalusi
     [not found]                             ` <514098A0.1030809-l0cyMroinI0@public.gmane.org>
2013-03-13 15:46                               ` Roger Quadros
2013-03-13 15:52                               ` Marc Kleine-Budde
2013-03-12 11:24   ` [PATCH 2/8] usb: phy: nop: use devm_kzalloc() Roger Quadros
2013-03-12 11:24   ` [PATCH 3/8] usb: phy: nop: Manage PHY clock Roger Quadros
2013-03-12 11:24   ` [PATCH 4/8] usb: phy: nop: Handle power supply regulator for the PHY Roger Quadros
2013-03-12 11:24   ` [PATCH 5/8] usb: phy: nop: Handle RESET " Roger Quadros
2013-03-12 11:24   ` [PATCH 6/8] usb: phy: nop: use new PHY API to register PHY Roger Quadros
2013-03-12 11:24 ` [PATCH 7/8] usb: phy: nop: Add device tree support and binding information Roger Quadros
2013-03-12 11:24 ` Roger Quadros [this message]

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=1363087466-32444-9-git-send-email-rogerq@ti.com \
    --to=rogerq@ti.com \
    --cc=balbi@ti.com \
    --cc=devicetree-discuss@lists.ozlabs.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mkl@pengutronix.de \
    --cc=tony@atomide.com \
    /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;
as well as URLs for NNTP newsgroup(s).