linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: michael.weiser@gmx.de (Michael Weiser)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/3] mmc: sunxi-mmc: change idma descriptor to __le32
Date: Thu, 21 Jul 2016 20:23:27 +0200	[thread overview]
Message-ID: <20160721182329.13478-2-michael.weiser@gmx.de> (raw)
In-Reply-To: <20160721182329.13478-1-michael.weiser@gmx.de>

The sunxi-mmc driver does not take into account the processor may be big
endian when writing the DMA descriptors. This causes cards not to be
detected when running a big-endian kernel. Change the descriptors for
IDMA to use __le32 and ensure they are suitably swapped before writing.
Tested successfully on the Cubieboard2.

Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
Cc: Ulf Hansson <ulf.hansson@linaro.org>
Cc: Maxime Ripard <maxime.ripard@free-electrons.com>
Cc: Chen-Yu Tsai <wens@csie.org>
Cc: linux-mmc at vger.kernel.org
---
 drivers/mmc/host/sunxi-mmc.c | 27 +++++++++++++++------------
 1 file changed, 15 insertions(+), 12 deletions(-)

diff --git a/drivers/mmc/host/sunxi-mmc.c b/drivers/mmc/host/sunxi-mmc.c
index 2ee4c21..1e6df8a 100644
--- a/drivers/mmc/host/sunxi-mmc.c
+++ b/drivers/mmc/host/sunxi-mmc.c
@@ -223,10 +223,10 @@ struct sunxi_mmc_clk_delay {
 };
 
 struct sunxi_idma_des {
-	u32	config;
-	u32	buf_size;
-	u32	buf_addr_ptr1;
-	u32	buf_addr_ptr2;
+	__le32 config;
+	__le32 buf_size;
+	__le32 buf_addr_ptr1;
+	__le32 buf_addr_ptr2;
 };
 
 struct sunxi_mmc_host {
@@ -325,22 +325,25 @@ static void sunxi_mmc_init_idma_des(struct sunxi_mmc_host *host,
 	int i, max_len = (1 << host->idma_des_size_bits);
 
 	for (i = 0; i < data->sg_len; i++) {
-		pdes[i].config = SDXC_IDMAC_DES0_CH | SDXC_IDMAC_DES0_OWN |
-				 SDXC_IDMAC_DES0_DIC;
+		pdes[i].config = cpu_to_le32(SDXC_IDMAC_DES0_CH |
+					     SDXC_IDMAC_DES0_OWN |
+					     SDXC_IDMAC_DES0_DIC);
 
 		if (data->sg[i].length == max_len)
 			pdes[i].buf_size = 0; /* 0 == max_len */
 		else
-			pdes[i].buf_size = data->sg[i].length;
+			pdes[i].buf_size = cpu_to_le32(data->sg[i].length);
 
 		next_desc += sizeof(struct sunxi_idma_des);
-		pdes[i].buf_addr_ptr1 = sg_dma_address(&data->sg[i]);
-		pdes[i].buf_addr_ptr2 = (u32)next_desc;
+		pdes[i].buf_addr_ptr1 =
+			cpu_to_le32(sg_dma_address(&data->sg[i]));
+		pdes[i].buf_addr_ptr2 = cpu_to_le32((u32)next_desc);
 	}
 
-	pdes[0].config |= SDXC_IDMAC_DES0_FD;
-	pdes[i - 1].config |= SDXC_IDMAC_DES0_LD | SDXC_IDMAC_DES0_ER;
-	pdes[i - 1].config &= ~SDXC_IDMAC_DES0_DIC;
+	pdes[0].config |= cpu_to_le32(SDXC_IDMAC_DES0_FD);
+	pdes[i - 1].config |= cpu_to_le32(SDXC_IDMAC_DES0_LD |
+					  SDXC_IDMAC_DES0_ER);
+	pdes[i - 1].config &= cpu_to_le32(~SDXC_IDMAC_DES0_DIC);
 	pdes[i - 1].buf_addr_ptr2 = 0;
 
 	/*
-- 
2.9.0

  reply	other threads:[~2016-07-21 18:23 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-21 18:23 [PATCH 0/3 v2] Fixes for running a big-endian kernel on Cubieboard2 Michael Weiser
2016-07-21 18:23 ` Michael Weiser [this message]
2016-07-22  8:59   ` [PATCH 1/3] mmc: sunxi-mmc: change idma descriptor to __le32 Maxime Ripard
2016-07-21 18:23 ` [PATCH 2/3] stmmac: change dma descriptors " Michael Weiser
2016-07-26 12:13   ` Giuseppe CAVALLARO
2016-07-29  7:53     ` Michael Weiser
2016-07-29  8:26       ` Giuseppe CAVALLARO
2016-07-21 18:23 ` [PATCH 3/3] ARM: sunxi: enable big-endian Michael Weiser
2016-07-22  9:01   ` Maxime Ripard
2016-07-22 13:56     ` Michael Weiser
2016-07-25 12:25       ` Maxime Ripard
2016-07-26 19:26         ` Michael Weiser
2016-07-27  1:55           ` Chen-Yu Tsai
2016-07-29  7:59             ` Michael Weiser
2016-07-29 16:39               ` Maxime Ripard
2016-07-29 18:55                 ` Michael Weiser
  -- strict thread matches above, loose matches on Subject: below --
2016-07-18 16:23 [PATCH 0/3] Fixes for running a big-endian kernel on Cubieboard2 Michael Weiser
2016-07-18 16:23 ` [PATCH 1/3] mmc: sunxi-mmc: change idma descriptor to __le32 Michael Weiser

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=20160721182329.13478-2-michael.weiser@gmx.de \
    --to=michael.weiser@gmx.de \
    --cc=linux-arm-kernel@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;
as well as URLs for NNTP newsgroup(s).