Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 693e5e20 authored by Nicolas Ferre's avatar Nicolas Ferre Committed by Chris Ball
Browse files

mmc: atmel-mci: fix burst/chunk size modification



The use of DMA slave config operation requires that the burst size
(aka chunk size) is specified through this interface.
Modify atmel-mci slave driver to use this specification on its side.

Signed-off-by: default avatarNicolas Ferre <nicolas.ferre@atmel.com>
Signed-off-by: default avatarLudovic Desroches <ludovic.desroches@atmel.com>
Signed-off-by: default avatarChris Ball <cjb@laptop.org>
parent b87cc1b5
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -140,4 +140,18 @@
#define atmci_writel(port,reg,value)			\
	__raw_writel((value), (port)->regs + reg)

/*
 * Fix sconfig's burst size according to atmel MCI. We need to convert them as:
 * 1 -> 0, 4 -> 1, 8 -> 2, 16 -> 3.
 *
 * This can be done by finding most significant bit set.
 */
static inline unsigned int atmci_convert_chksize(unsigned int maxburst)
{
	if (maxburst > 1)
		return fls(maxburst) - 2;
	else
		return 0;
}

#endif /* __DRIVERS_MMC_ATMEL_MCI_H__ */
+5 −3
Original line number Diff line number Diff line
@@ -910,6 +910,7 @@ atmci_prepare_data_dma(struct atmel_mci *host, struct mmc_data *data)
	enum dma_data_direction		direction;
	enum dma_transfer_direction	slave_dirn;
	unsigned int			sglen;
	u32				maxburst;
	u32 iflags;

	data->error = -EINPROGRESS;
@@ -943,17 +944,18 @@ atmci_prepare_data_dma(struct atmel_mci *host, struct mmc_data *data)
	if (!chan)
		return -ENODEV;

	if (host->caps.has_dma)
		atmci_writel(host, ATMCI_DMA, ATMCI_DMA_CHKSIZE(3) | ATMCI_DMAEN);

	if (data->flags & MMC_DATA_READ) {
		direction = DMA_FROM_DEVICE;
		host->dma_conf.direction = slave_dirn = DMA_DEV_TO_MEM;
		maxburst = atmci_convert_chksize(host->dma_conf.src_maxburst);
	} else {
		direction = DMA_TO_DEVICE;
		host->dma_conf.direction = slave_dirn = DMA_MEM_TO_DEV;
		maxburst = atmci_convert_chksize(host->dma_conf.dst_maxburst);
	}

	atmci_writel(host, ATMCI_DMA, ATMCI_DMA_CHKSIZE(maxburst) | ATMCI_DMAEN);

	sglen = dma_map_sg(chan->device->dev, data->sg,
			data->sg_len, direction);