devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Anholt <eric-WhKQ6XTQaPysTnJN9+BGXg@public.gmane.org>
To: linux-arm-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: linux-rpi-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	Stephen Warren <swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>,
	Lee Jones <lee-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Jassi Brar
	<jassisinghbrar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Craig McGeachie <slapdau-/E1597aS9LT0CCvOHzKKcA@public.gmane.org>,
	Lubomir Rintel <lkundrak-NGH9Lh4a5iE@public.gmane.org>,
	Eric Anholt <eric-WhKQ6XTQaPysTnJN9+BGXg@public.gmane.org>,
	John Youn <johnyoun-HKixBCOQz3hWk0Htik3J/w@public.gmane.org>
Subject: [PATCH 07/10 v2] usb: Make sure that DWC2 initializes after the power channel mailbox driver.
Date: Tue,  3 Mar 2015 12:32:58 -0800	[thread overview]
Message-ID: <1425414778-30820-1-git-send-email-eric@anholt.net> (raw)
In-Reply-To: <20150303083250.GG6976@x1>

This gets USB working on the Raspberry Pi without relying on U-Boot to
send the power message for us.  Without it, you would get warnings
about fifo sizes and "dwc2_core_reset() HANG! Soft Reset
GRSTCTL=80000001" leading to a failed probe.

v2: Make the export of the has-the-mailbox-driver-loaded bool be
    through a function call defined in include/linux/platform/

Signed-off-by: Eric Anholt <eric-WhKQ6XTQaPysTnJN9+BGXg@public.gmane.org>
Cc: John Youn <johnyoun-HKixBCOQz3hWk0Htik3J/w@public.gmane.org>
---

This would be the first include file in include/linux/platform/.  Is
that the right place?  I see a few
arch/arm/mach-*/include/mach/platform.h files -- would that or
arch/arm/mach-bcm/include/mach/bcm2835-platform.h possibly be the right
place instead?

Also, Lee, since you mostly typed the contents of that header, should
your SoB go on this?

drivers/mailbox/bcm2835-mailbox-power.c | 11 +++++++++++
 drivers/usb/dwc2/platform.c             |  8 ++++++++
 include/linux/platform/bcm2835.h        | 18 ++++++++++++++++++
 3 files changed, 37 insertions(+)
 create mode 100644 include/linux/platform/bcm2835.h

diff --git a/drivers/mailbox/bcm2835-mailbox-power.c b/drivers/mailbox/bcm2835-mailbox-power.c
index f09c855..a3ed773 100644
--- a/drivers/mailbox/bcm2835-mailbox-power.c
+++ b/drivers/mailbox/bcm2835-mailbox-power.c
@@ -19,6 +19,7 @@
 #include <linux/mailbox_client.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
+#include <linux/platform/bcm2835.h>
 
 #define BCM_POWER_USB (1 << 3)
 #define BCM_MBOX_DATA_SHIFT 4
@@ -31,6 +32,14 @@ struct bcm_mbox_power {
 	uint32_t response;
 };
 
+static bool bcm2835_mbox_power_initialized;
+
+bool bcm2835_mbox_is_usb_powered(void)
+{
+	return bcm2835_mbox_power_initialized;
+}
+EXPORT_SYMBOL_GPL(bcm2835_mbox_is_usb_powered);
+
 struct bcm_mbox_power *mbox_power;
 
 static void response_callback(struct mbox_client *cl, void *mssg)
@@ -92,6 +101,7 @@ static int bcm2835_mbox_power_probe(struct platform_device *pdev)
 		bcm_mbox_set_power(BCM_POWER_USB);
 		bcm2835_mbox_power_initialized = true;
 	}
+	bcm2835_mbox_power_initialized = true;
 
 	return ret;
 }
@@ -99,6 +109,7 @@ static int bcm2835_mbox_power_probe(struct platform_device *pdev)
 static int bcm2835_mbox_power_remove(struct platform_device *pdev)
 {
 	bcm_mbox_set_power(0);
+	bcm2835_mbox_power_initialized = false;
 
 	mbox_free_channel(mbox_power->chan);
 
diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
index ae095f0..caca216 100644
--- a/drivers/usb/dwc2/platform.c
+++ b/drivers/usb/dwc2/platform.c
@@ -42,6 +42,7 @@
 #include <linux/of_device.h>
 #include <linux/mutex.h>
 #include <linux/platform_device.h>
+#include <linux/platform/bcm2835.h>
 
 #include <linux/usb/of.h>
 
@@ -175,6 +176,13 @@ static int dwc2_driver_probe(struct platform_device *dev)
 		defparams.dma_desc_enable = 0;
 	}
 
+	/*
+	 * Make sure the platform driver for enabling the power has
+	 * initialized before we do.
+	 */
+	if (params == &params_bcm2835 && !bcm2835_is_usb_powered())
+		return -EPROBE_DEFER;
+
 	hsotg = devm_kzalloc(&dev->dev, sizeof(*hsotg), GFP_KERNEL);
 	if (!hsotg)
 		return -ENOMEM;
diff --git a/include/linux/platform/bcm2835.h b/include/linux/platform/bcm2835.h
new file mode 100644
index 0000000..a97d938
--- /dev/null
+++ b/include/linux/platform/bcm2835.h
@@ -0,0 +1,18 @@
+#ifdef CONFIG_BCM2835_MBOX
+bool bcm2835_mbox_is_usb_powered(void);
+
+static inline bool bcm2835_is_usb_powered(void)
+{
+	return bcm2835_mbox_is_usb_powered();
+}
+#else
+static inline bool bcm2835_is_usb_powered(void)
+{
+	/*
+	 * If BCM2835 isn't using its Mailbox driver, the bootloader
+	 * is charged with powering up USB.
+	 */
+	return true;
+}
+#endif
+
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2015-03-03 20:32 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-02 20:54 Raspberry Pi mailbox drivers Eric Anholt
2015-03-02 20:54 ` [PATCH 02/10] mailbox: Enable BCM2835 mailbox support Eric Anholt
     [not found]   ` <1425329684-23968-3-git-send-email-eric-WhKQ6XTQaPysTnJN9+BGXg@public.gmane.org>
2015-03-04  3:03     ` Stephen Warren
     [not found]       ` <54F675F1.60205-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2015-03-04  9:48         ` Arnd Bergmann
2015-03-04 18:20         ` Eric Anholt
     [not found]           ` <87a8zs8vzo.fsf-omZaPlIz5HhaEpDpdNBo/KxOck334EZe@public.gmane.org>
2015-03-06  4:54             ` Stephen Warren
     [not found]               ` <54F932FD.5040207-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2015-03-06 20:00                 ` Eric Anholt
     [not found]                   ` <87bnk5lwvt.fsf-omZaPlIz5HhaEpDpdNBo/KxOck334EZe@public.gmane.org>
2015-03-06 20:29                     ` Stephen Warren
     [not found]                       ` <54FA0E2B.30300-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2015-03-06 21:40                         ` Stephen Warren
2015-03-04 18:28         ` Eric Anholt
     [not found] ` <1425329684-23968-1-git-send-email-eric-WhKQ6XTQaPysTnJN9+BGXg@public.gmane.org>
2015-03-02 20:54   ` [PATCH 01/10] dt/bindings: Add binding for BCM2835 mailbox driver Eric Anholt
     [not found]     ` <1425329684-23968-2-git-send-email-eric-WhKQ6XTQaPysTnJN9+BGXg@public.gmane.org>
2015-03-03  8:05       ` Lee Jones
2015-03-03 19:28         ` Eric Anholt
     [not found]           ` <87vbih98za.fsf-omZaPlIz5HhaEpDpdNBo/KxOck334EZe@public.gmane.org>
2015-03-04  2:37             ` Stephen Warren
     [not found]               ` <54F66FDD.2040409-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2015-03-04 17:44                 ` Eric Anholt
2015-03-12 23:23                 ` Eric Anholt
     [not found]                   ` <87egothkaf.fsf-omZaPlIz5HhaEpDpdNBo/KxOck334EZe@public.gmane.org>
2015-03-17  3:08                     ` Stephen Warren
     [not found]                       ` <55079AA0.5090904-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2015-03-17 19:10                         ` Eric Anholt
     [not found]                           ` <87vbhzl9t1.fsf-omZaPlIz5HhaEpDpdNBo/KxOck334EZe@public.gmane.org>
2015-03-18  1:52                             ` Stephen Warren
2015-03-02 20:54   ` [PATCH 03/10] ARM: bcm2835: Add the mailbox to the device tree Eric Anholt
     [not found]     ` <1425329684-23968-4-git-send-email-eric-WhKQ6XTQaPysTnJN9+BGXg@public.gmane.org>
2015-03-03  8:34       ` Lee Jones
2015-03-02 20:54   ` [PATCH 04/10] dt/bindings: Add binding for BCM2835 mailbox power channel driver Eric Anholt
     [not found]     ` <1425329684-23968-5-git-send-email-eric-WhKQ6XTQaPysTnJN9+BGXg@public.gmane.org>
2015-03-04  3:07       ` Stephen Warren
2015-03-02 20:54   ` [PATCH 05/10] ARM: bcm2835: Add the " Eric Anholt
     [not found]     ` <1425329684-23968-6-git-send-email-eric-WhKQ6XTQaPysTnJN9+BGXg@public.gmane.org>
2015-03-02 21:09       ` Arnd Bergmann
2015-03-02 22:02         ` Eric Anholt
2015-03-04  3:15       ` Stephen Warren
2015-03-02 20:54   ` [PATCH 06/10] ARM: bcm2835: Add the mailbox power channel to the device tree Eric Anholt
2015-03-02 20:54   ` [PATCH 07/10] usb: Make sure that DWC2 initializes after the power channel mailbox driver Eric Anholt
     [not found]     ` <1425329684-23968-8-git-send-email-eric-WhKQ6XTQaPysTnJN9+BGXg@public.gmane.org>
2015-03-03  8:32       ` Lee Jones
2015-03-03 20:32         ` Eric Anholt [this message]
     [not found]           ` <1425414778-30820-1-git-send-email-eric-WhKQ6XTQaPysTnJN9+BGXg@public.gmane.org>
2015-03-04  3:24             ` [PATCH 07/10 v2] " Stephen Warren
2015-03-04  3:17         ` [PATCH 07/10] " Stephen Warren
     [not found]           ` <54F67944.1030501-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2015-03-04  9:50             ` Arnd Bergmann
2015-03-02 20:54   ` [PATCH 08/10] dt/bindings: Add binding for BCM2835 mailbox property channel driver Eric Anholt
     [not found]     ` <1425329684-23968-9-git-send-email-eric-WhKQ6XTQaPysTnJN9+BGXg@public.gmane.org>
2015-03-04  3:53       ` Stephen Warren
     [not found]         ` <54F681CE.2070801-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2015-03-05 19:50           ` Eric Anholt
     [not found]             ` <87wq2v6x69.fsf-omZaPlIz5HhaEpDpdNBo/KxOck334EZe@public.gmane.org>
2015-03-06  5:15               ` Stephen Warren
     [not found]                 ` <54F937DF.3020001-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2015-03-06  6:05                   ` Jassi Brar
2015-03-02 20:54   ` [PATCH 09/10] ARM: bcm2835: Add the " Eric Anholt
     [not found]     ` <1425329684-23968-10-git-send-email-eric-WhKQ6XTQaPysTnJN9+BGXg@public.gmane.org>
2015-03-04  4:00       ` Stephen Warren
     [not found]         ` <54F68352.5080108-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2015-03-05 19:54           ` Eric Anholt
     [not found]             ` <87vbif6wzi.fsf-omZaPlIz5HhaEpDpdNBo/KxOck334EZe@public.gmane.org>
2015-03-06  5:05               ` Stephen Warren
2015-03-02 20:54   ` [PATCH 10/10] ARM: bcm2835: Add the mailbox property channel to the device tree Eric Anholt

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=1425414778-30820-1-git-send-email-eric@anholt.net \
    --to=eric-whkq6xtqapystnjn9+bgxg@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=jassisinghbrar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=johnyoun-HKixBCOQz3hWk0Htik3J/w@public.gmane.org \
    --cc=lee-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=linux-arm-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-rpi-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=lkundrak-NGH9Lh4a5iE@public.gmane.org \
    --cc=slapdau-/E1597aS9LT0CCvOHzKKcA@public.gmane.org \
    --cc=swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.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;
as well as URLs for NNTP newsgroup(s).