diff mbox series

[U-Boot] ARM: bcm283x mbox: Fix send status register

Message ID 20190716110947.32603-1-matthias.bgg@kernel.org
State Accepted
Commit 49822442edd910efdf12eb8070a9c9cc7c48037d
Delegated to: Matthias Brugger
Headers show
Series [U-Boot] ARM: bcm283x mbox: Fix send status register | expand

Commit Message

Matthias Brugger July 16, 2019, 11:09 a.m. UTC
From: Fabian Vogt <fvogt@suse.com>

Before we can send a message to the mailbox we have to check that there
is space to do so. Therefore we poll the status register. But up to now
the wrong status register, the one of mailbox 0, was checked. Fix this
by polling the status regiser of mailbox 1.

Signed-off-by: Fabian Vogt <fvogt@suse.com>
[mb: rename registers and update commit message]
Signed-off-by: Matthias Brugger <mbrugger@suse.com>
---
 arch/arm/mach-bcm283x/include/mach/mbox.h | 7 +++++--
 arch/arm/mach-bcm283x/mbox.c              | 6 +++---
 2 files changed, 8 insertions(+), 5 deletions(-)

Comments

Stephen Warren July 16, 2019, 3:03 p.m. UTC | #1
On 7/16/19 5:09 AM, matthias.bgg@kernel.org wrote:
> From: Fabian Vogt <fvogt@suse.com>
> 
> Before we can send a message to the mailbox we have to check that there
> is space to do so. Therefore we poll the status register. But up to now
> the wrong status register, the one of mailbox 0, was checked. Fix this
> by polling the status regiser of mailbox 1.

This sounds plausible at least (I didn't check which of mbox 0/1 was 
TX/RX), so,
Acked-by: Stephen Warren <swarren@wwwdotorg.org>
diff mbox series

Patch

diff --git a/arch/arm/mach-bcm283x/include/mach/mbox.h b/arch/arm/mach-bcm283x/include/mach/mbox.h
index e3a893e49c..f892803558 100644
--- a/arch/arm/mach-bcm283x/include/mach/mbox.h
+++ b/arch/arm/mach-bcm283x/include/mach/mbox.h
@@ -46,9 +46,12 @@ 
 struct bcm2835_mbox_regs {
 	u32 read;
 	u32 rsvd0[5];
-	u32 status;
-	u32 config;
+	u32 mail0_status;
+	u32 mail0_config;
 	u32 write;
+	u32 rsvd1[5];
+	u32 mail1_status;
+	u32 mail1_config;
 };
 
 #define BCM2835_MBOX_STATUS_WR_FULL	0x80000000
diff --git a/arch/arm/mach-bcm283x/mbox.c b/arch/arm/mach-bcm283x/mbox.c
index 1642ebd103..3c67f68c17 100644
--- a/arch/arm/mach-bcm283x/mbox.c
+++ b/arch/arm/mach-bcm283x/mbox.c
@@ -27,7 +27,7 @@  int bcm2835_mbox_call_raw(u32 chan, u32 send, u32 *recv)
 	/* Drain any stale responses */
 
 	for (;;) {
-		val = readl(&regs->status);
+		val = readl(&regs->mail0_status);
 		if (val & BCM2835_MBOX_STATUS_RD_EMPTY)
 			break;
 		if (get_timer(0) >= endtime) {
@@ -40,7 +40,7 @@  int bcm2835_mbox_call_raw(u32 chan, u32 send, u32 *recv)
 	/* Wait for space to send */
 
 	for (;;) {
-		val = readl(&regs->status);
+		val = readl(&regs->mail1_status);
 		if (!(val & BCM2835_MBOX_STATUS_WR_FULL))
 			break;
 		if (get_timer(0) >= endtime) {
@@ -58,7 +58,7 @@  int bcm2835_mbox_call_raw(u32 chan, u32 send, u32 *recv)
 	/* Wait for the response */
 
 	for (;;) {
-		val = readl(&regs->status);
+		val = readl(&regs->mail0_status);
 		if (!(val & BCM2835_MBOX_STATUS_RD_EMPTY))
 			break;
 		if (get_timer(0) >= endtime) {