* [PATCH 1/3] mmc: sunxi-mmc: change idma descriptor to __le32
[not found] <20160721182329.13478-1-michael.weiser@gmx.de>
@ 2016-07-21 18:23 ` Michael Weiser
2016-07-22 8:59 ` Maxime Ripard
0 siblings, 1 reply; 2+ messages in thread
From: Michael Weiser @ 2016-07-21 18:23 UTC (permalink / raw)
To: linux-arm-kernel
Cc: linux-mmc, Ulf Hansson, Chen-Yu Tsai, Michael Weiser,
Maxime Ripard
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@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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 1/3] mmc: sunxi-mmc: change idma descriptor to __le32
2016-07-21 18:23 ` [PATCH 1/3] mmc: sunxi-mmc: change idma descriptor to __le32 Michael Weiser
@ 2016-07-22 8:59 ` Maxime Ripard
0 siblings, 0 replies; 2+ messages in thread
From: Maxime Ripard @ 2016-07-22 8:59 UTC (permalink / raw)
To: Michael Weiser; +Cc: linux-arm-kernel, Ulf Hansson, Chen-Yu Tsai, linux-mmc
[-- Attachment #1: Type: text/plain, Size: 819 bytes --]
On Thu, Jul 21, 2016 at 08:23:27PM +0200, Michael Weiser wrote:
> 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@vger.kernel.org
Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Thanks,
Maxime
--
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-07-22 8:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20160721182329.13478-1-michael.weiser@gmx.de>
2016-07-21 18:23 ` [PATCH 1/3] mmc: sunxi-mmc: change idma descriptor to __le32 Michael Weiser
2016-07-22 8:59 ` Maxime Ripard
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox