Skip to contentSkip to conversation

mmc: mxs-mmc: add mmc host driver for i.MX23/28

PATCH Superseded Shawn Guo 4 participants 11 messages Feb 21, 2011 – Feb 24, 2011

Subsystems (4)
lore
Share & tools
lore

Shawn Guo

author
#0 lore raw

PATCH v3 1/1 mmc: mxs-mmc: add mmc host driver for i.MX23/28

This adds the mmc host driver for Freescale MXS-based SoC i.MX23/28. The driver calls into mxs-dma via generic dmaengine api for both pio and data transfer.

Thanks Chris Ball for the indentation patch.

---
 arch/arm/mach-mxs/include/mach/mmc.h |   18 +
 drivers/mmc/host/Kconfig             |    9 +
 drivers/mmc/host/Makefile            |    1 +
 drivers/mmc/host/mxs-mmc.c           |  874 ++++++++++++++++++++++++++++++++++
 4 files changed, 902 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-mxs/include/mach/mmc.h
 create mode 100644 drivers/mmc/host/mxs-mmc.c
arch/arm/mach-mxs/include/mach/mmc.h new file +18 -0
new file mode 100644
index 0000000..211547a
@@ -0,0 +1,18 @@
+/*
+ * Copyright 2011 Freescale Semiconductor, Inc. All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __MACH_MXS_MMC_H__
+#define __MACH_MXS_MMC_H__
+
+struct mxs_mmc_platform_data {
+	int wp_gpio;	/* write protect pin */
+	unsigned int flags;
+#define SLOTF_4_BIT_CAPABLE	(1 << 0)
+#define SLOTF_8_BIT_CAPABLE	(1 << 1)
+};
+#endif /* __MACH_MXS_MMC_H__ */
drivers/mmc/host/Kconfig +9 -0
index afe8c6f..47ef75d 100644
@@ -319,6 +319,15 @@ config MMC_MXC
 
 	  If unsure, say N.
 
+config MMC_MXS
+	tristate "Freescale MXS Multimedia Card Interface support"
+	depends on ARCH_MXS && MXS_DMA
+	help
+	  This selects the Freescale SSP MMC controller found on MXS based
+	  platforms like mx23/28.
+
+	  If unsure, say N.
+
 config MMC_TIFM_SD
 	tristate "TI Flash Media MMC/SD Interface support  (EXPERIMENTAL)"
 	depends on EXPERIMENTAL && PCI
drivers/mmc/host/Makefile +1 -0
index e834fb2..30aa686 100644
@@ -6,6 +6,7 @@ obj-$(CONFIG_MMC_ARMMMCI)	+= mmci.o
 obj-$(CONFIG_MMC_PXA)		+= pxamci.o
 obj-$(CONFIG_MMC_IMX)		+= imxmmc.o
 obj-$(CONFIG_MMC_MXC)		+= mxcmmc.o
+obj-$(CONFIG_MMC_MXS)		+= mxs-mmc.o
 obj-$(CONFIG_MMC_SDHCI)		+= sdhci.o
 obj-$(CONFIG_MMC_SDHCI_PCI)	+= sdhci-pci.o
 obj-$(CONFIG_MMC_SDHCI_PXA)	+= sdhci-pxa.o
drivers/mmc/host/mxs-mmc.c new file +874 -0

874 lines not on this page · raw message

Signature · 1 line
1.7.1
#1 lore raw

PATCH v3 1/1 mmc: mxs-mmc: add mmc host driver for i.MX23/28

Shawn,

Quoted 8 lines · Shawn Guo

This adds the mmc host driver for Freescale MXS-based SoC i.MX23/28. The driver calls into mxs-dma via generic dmaengine api for both pio and data transfer.

Thanks Chris Ball for the indentation patch.

What throughput rates do you get on a mx28-regulated slot serving a card at 50Mhz? This is poor here (55kb/s) while it is OK at 25Mhz. Could be a board issue though (or we can fix it later), rest works fine, thus:

Signature · 9 lines
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20110221/8244f36f/attachment.sig>
author
#2 lore raw

PATCH v3 1/1 mmc: mxs-mmc: add mmc host driver for i.MX23/28

Hi Wolfram,

Quoted 7 lines · Wolfram Sang

Shawn,

Quoted 4 lines · Shawn Guo

This adds the mmc host driver for Freescale MXS-based SoC i.MX23/28. The driver calls into mxs-dma via generic dmaengine api for both pio and data transfer.

Quoted 7 lines
Quoted 4 lines

Thanks Chris Ball for the indentation patch.

What throughput rates do you get on a mx28-regulated slot serving a card at 50Mhz? This is poor here (55kb/s) while it is OK at 25Mhz. Could be a

To make sure we are on the same page, can you share me the test you ran? And I can give it a try on my board.

Quoted 4 lines

board issue though (or we can fix it later), rest works fine, thus:

Signature · 2 lines
Regards,
Shawn
author
#3 lore raw

PATCH v3 1/1 mmc: mxs-mmc: add mmc host driver for i.MX23/28

Please ignore the message which is the one I sent a few days ago and I thought it did not get through.

Quoted 35 lines · Shawn Guo

Hi Wolfram,

Quoted 7 lines · Wolfram Sang

Shawn,

Quoted 4 lines · Shawn Guo

This adds the mmc host driver for Freescale MXS-based SoC i.MX23/28. The driver calls into mxs-dma via generic dmaengine api for both pio and data transfer.

Quoted 7 lines
Quoted 4 lines

Thanks Chris Ball for the indentation patch.

What throughput rates do you get on a mx28-regulated slot serving a card at 50Mhz? This is poor here (55kb/s) while it is OK at 25Mhz. Could be a

To make sure we are on the same page, can you share me the test you ran? And I can give it a try on my board.

Quoted 4 lines

board issue though (or we can fix it later), rest works fine, thus:

Signature · 7 lines
Regards,
Shawn

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Signature · 2 lines
Regards,
Shawn
author
#4 lore raw

PATCH v3 1/1 mmc: mxs-mmc: add mmc host driver for i.MX23/28

In reply to Wolfram Sang

Hi Wolfram,

Quoted 7 lines · Wolfram Sang

Shawn,

Quoted 4 lines · Shawn Guo

This adds the mmc host driver for Freescale MXS-based SoC i.MX23/28. The driver calls into mxs-dma via generic dmaengine api for both pio and data transfer.

Quoted 7 lines
Quoted 4 lines

Thanks Chris Ball for the indentation patch.

What throughput rates do you get on a mx28-regulated slot serving a card at 50Mhz? This is poor here (55kb/s) while it is OK at 25Mhz. Could be a

To make sure we are on the same test, can you share the test case you ran to get the result? So that I can run it here for the result on my board.

Quoted 4 lines

board issue though (or we can fix it later), rest works fine, thus:

Signature · 2 lines
Regards,
Shawn
#5 lore raw

PATCH v3 1/1 mmc: mxs-mmc: add mmc host driver for i.MX23/28

Quoted 7 lines
Quoted 3 lines

What throughput rates do you get on a mx28-regulated slot serving a card at 50Mhz? This is poor here (55kb/s) while it is OK at 25Mhz. Could be a

To make sure we are on the same test, can you share the test case you ran to get the result? So that I can run it here for the result on my board.

# mount -t vfat /dev/mmcblk0p1 /mnt
# dd if=/mnt/test.dat of=/tmp/a bs=1024
# umount /mnt
# ./dd --version
dd (coreutils) 8.5
...

'test.dat' was a 8MB file of random data on a 4GB SDHC card (extrememory) on a slot powered by the mx28. Operating the card at 50Mhz, dd will report ~55 kb/s. If I add 'rate /= 2;' to the beginning of set_clk_rate, so it will operate at 25Mhz, I have 8mb/s.

Regards,

Wolfram

Signature · 9 lines
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20110222/067cb096/attachment.sig>
author
#6 lore raw

PATCH v3 1/1 mmc: mxs-mmc: add mmc host driver for i.MX23/28

Quoted 15 lines · Wolfram Sang
Quoted 7 lines
Quoted 3 lines

What throughput rates do you get on a mx28-regulated slot serving a card at 50Mhz? This is poor here (55kb/s) while it is OK at 25Mhz. Could be a

To make sure we are on the same test, can you share the test case you ran to get the result? So that I can run it here for the result on my board.

# mount -t vfat /dev/mmcblk0p1 /mnt
# dd if=/mnt/test.dat of=/tmp/a bs=1024
# umount /mnt
# ./dd --version
dd (coreutils) 8.5
...
Quoted 5 lines

'test.dat' was a 8MB file of random data on a 4GB SDHC card (extrememory) on a slot powered by the mx28. Operating the card at 50Mhz, dd will report ~55 kb/s. If I add 'rate /= 2;' to the beginning of set_clk_rate, so it will operate at 25Mhz, I have 8mb/s.

My busybox version of dd does not report the speed. But I tried to dd 8MB data and saw it's done in 1~2 seconds.

Also here is mmc host driver test performance related result on my board if you are interested.

mmc0: Test case 23. Best-case read performance...
mmc0: Transfer of 6630 sectors (3315 KiB) took 0.101999209 seconds (33280 kB/s, 32500 KiB/s)
mmc0: Result: OK
mmc0: Test case 24. Best-case write performance...
mmc0: Transfer of 6630 sectors (3315 KiB) took 0.388688317 seconds (8733 kB/s, 8 528 KiB/s)
mmc0: Result: OK
mmc0: Test case 25. Best-case read performance into scattered pages...
mmc0: Transfer of 416 sectors (208 KiB) took 0.006997933 seconds (30436 kB/s, 29 723 KiB/s)
mmc0: Result: OK
mmc0: Test case 26. Best-case write performance from scattered pages...
mmc0: Transfer of 416 sectors (208 KiB) took 0.020431605 seconds (10424 kB/s, 10 180 KiB/s)
mmc0: Result: OK
mmc0: Test case 27. Single read performance by transfer size...
mmc0: Transfer of 1 sectors (0.5 KiB) took 0.000906524 seconds (564 kB/s, 551 Ki B/s)
mmc0: Transfer of 2 sectors (1 KiB) took 0.000625190 seconds (1637 kB/s, 1599 Ki B/s)
mmc0: Transfer of 4 sectors (2 KiB) took 0.000687706 seconds (2978 kB/s, 2908 Ki B/s)
mmc0: Transfer of 8 sectors (4 KiB) took 0.000718959 seconds (5697 kB/s, 5563 Ki B/s)
mmc0: Transfer of 16 sectors (8 KiB) took 0.000812729 seconds (10079 kB/s, 9843 KiB/s)
mmc0: Transfer of 32 sectors (16 KiB) took 0.001094051 seconds (14975 kB/s, 1462 4 KiB/s)
mmc0: Transfer of 64 sectors (32 KiB) took 0.001625434 seconds (20159 kB/s, 1968 7 KiB/s)
mmc0: Transfer of 128 sectors (64 KiB) took 0.002594421 seconds (25260 kB/s, 246 68 KiB/s)
mmc0: Transfer of 256 sectors (128 KiB) took 0.004563644 seconds (28720 kB/s, 28 047 KiB/s)
mmc0: Transfer of 512 sectors (256 KiB) took 0.008439521 seconds (31061 kB/s, 30 333 KiB/s)
mmc0: Transfer of 1024 sectors (512 KiB) took 0.016253622 seconds (32256 kB/s, 3 1500 KiB/s)
mmc0: Transfer of 2048 sectors (1024 KiB) took 0.031886943 seconds (32884 kB/s, 32113 KiB/s)
mmc0: Transfer of 4096 sectors (2048 KiB) took 0.063176177 seconds (33195 kB/s, 32417 KiB/s)
mmc0: Transfer of 6630 sectors (3315 KiB) took 0.101735514 seconds (33366 kB/s, 32584 KiB/s)
mmc0: Result: OK
mmc0: Test case 28. Single write performance by transfer size...
mmc0: Transfer of 1 sectors (0.5 KiB) took 0.001781476 seconds (287 kB/s, 280 Ki B/s)
mmc0: Transfer of 2 sectors (1 KiB) took 0.002250249 seconds (455 kB/s, 444 KiB/
s)
mmc0: Transfer of 4 sectors (2 KiB) took 0.002312719 seconds (885 kB/s, 864 KiB/
s)
mmc0: Transfer of 8 sectors (4 KiB) took 0.003437771 seconds (1191 kB/s, 1163 Ki B/s)
mmc0: Transfer of 16 sectors (8 KiB) took 0.002718920 seconds (3012 kB/s, 2942 K iB/s)
mmc0: Transfer of 32 sectors (16 KiB) took 0.001500142 seconds (10921 kB/s, 1066 5 KiB/s)
mmc0: Transfer of 64 sectors (32 KiB) took 0.003875336 seconds (8455 kB/s, 8257 KiB/s)
mmc0: Transfer of 128 sectors (64 KiB) took 0.006250472 seconds (10484 kB/s, 102 39 KiB/s)
mmc0: Transfer of 256 sectors (128 KiB) took 0.011563288 seconds (11335 kB/s, 11 069 KiB/s)
mmc0: Transfer of 512 sectors (256 KiB) took 0.022187432 seconds (11814 kB/s, 11 538 KiB/s)
mmc0: Transfer of 1024 sectors (512 KiB) took 0.049155884 seconds (10665 kB/s, 1 0415 KiB/s)
mmc0: Transfer of 2048 sectors (1024 KiB) took 0.085375335 seconds (12281 kB/s, 11994 KiB/s)
mmc0: Transfer of 4096 sectors (2048 KiB) took 0.262563987 seconds (7987 kB/s, 7 800 KiB/s)
mmc0: Transfer of 6630 sectors (3315 KiB) took 0.284787038 seconds (11919 kB/s, 11640 KiB/s)
mmc0: Result: OK
mmc0: Test case 29. Single trim performance by transfer size...
mmc0: Result: UNSUPPORTED (by card)
mmc0: Test case 30. Consecutive read performance by transfer size...
mmc0: Transfer of 8192 x 1 sectors (8192 x 0.5 KiB) took 4.091141441 seconds (10 25 kB/s, 1001 KiB/s)
mmc0: Transfer of 4096 x 2 sectors (4096 x 1 KiB) took 2.490875000 seconds (1683
kB/s, 1644 KiB/s)
mmc0: Transfer of 2048 x 4 sectors (2048 x 2 KiB) took 1.316531250 seconds (3185
kB/s, 3111 KiB/s)
mmc0: Transfer of 1024 x 8 sectors (1024 x 4 KiB) took 0.727437500 seconds (5765
kB/s, 5630 KiB/s)
mmc0: Transfer of 512 x 16 sectors (512 x 8 KiB) took 0.437000000 seconds (9597 kB/s, 9372 KiB/s)
mmc0: Transfer of 256 x 32 sectors (256 x 16 KiB) took 0.283156250 seconds (1481 2 kB/s, 14465 KiB/s)
mmc0: Transfer of 128 x 64 sectors (128 x 32 KiB) took 0.205812500 seconds (2037 9 kB/s, 19901 KiB/s)
mmc0: Transfer of 64 x 128 sectors (64 x 64 KiB) took 0.165750000 seconds (25305
kB/s, 24711 KiB/s)
mmc0: Transfer of 32 x 256 sectors (32 x 128 KiB) took 0.145343750 seconds (2885 7 kB/s, 28181 KiB/s)
mmc0: Transfer of 16 x 512 sectors (16 x 256 KiB) took 0.134968750 seconds (3107 6 kB/s, 30347 KiB/s)
mmc0: Transfer of 8 x 1024 sectors (8 x 512 KiB) took 0.130125000 seconds (32232
kB/s, 31477 KiB/s)
mmc0: Transfer of 4 x 2048 sectors (4 x 1024 KiB) took 0.127531249 seconds (3288 8 kB/s, 32117 KiB/s)
mmc0: Transfer of 2 x 4096 sectors (2 x 2048 KiB) took 0.126343751 seconds (3319 7 kB/s, 32419 KiB/s)
mmc0: Transfer of 1 x 6630 sectors (1 x 3315 KiB) took 0.101687494 seconds (3338 2 kB/s, 32599 KiB/s)
mmc0: Result: OK
mmc0: Test case 31. Consecutive write performance by transfer size...
mmc0: Transfer of 8192 x 1 sectors (8192 x 0.5 KiB) took 14.309562500 seconds (2 93 kB/s, 286 KiB/s)
mmc0: Transfer of 4096 x 2 sectors (4096 x 1 KiB) took 9.871062499 seconds (424 kB/s, 414 KiB/s)
mmc0: Transfer of 2048 x 4 sectors (2048 x 2 KiB) took 4.814593750 seconds (871 kB/s, 850 KiB/s)
mmc0: Transfer of 1024 x 8 sectors (1024 x 4 KiB) took 2.296875000 seconds (1826
kB/s, 1783 KiB/s)
mmc0: Transfer of 512 x 16 sectors (512 x 8 KiB) took 1.072843750 seconds (3909 kB/s, 3817 KiB/s)
mmc0: Transfer of 256 x 32 sectors (256 x 16 KiB) took 0.596312500 seconds (7033
kB/s, 6868 KiB/s)
mmc0: Transfer of 128 x 64 sectors (128 x 32 KiB) took 0.455375000 seconds (9210
kB/s, 8994 KiB/s)
mmc0: Transfer of 64 x 128 sectors (64 x 64 KiB) took 0.402875000 seconds (10410
kB/s, 10166 KiB/s)
mmc0: Transfer of 32 x 256 sectors (32 x 128 KiB) took 0.375531250 seconds (1116 8 kB/s, 10907 KiB/s)
mmc0: Transfer of 16 x 512 sectors (16 x 256 KiB) took 0.362562500 seconds (1156 8 kB/s, 11297 KiB/s)
mmc0: Transfer of 8 x 1024 sectors (8 x 512 KiB) took 0.350500000 seconds (11966
kB/s, 11686 KiB/s)
mmc0: Transfer of 4 x 2048 sectors (4 x 1024 KiB) took 0.351593796 seconds (1192 9 kB/s, 11649 KiB/s)
mmc0: Transfer of 2 x 4096 sectors (2 x 2048 KiB) took 0.346812955 seconds (1209 3 kB/s, 11810 KiB/s)
mmc0: Transfer of 1 x 6630 sectors (1 x 3315 KiB) took 0.280838757 seconds (1208 7 kB/s, 11803 KiB/s)
mmc0: Result: OK
mmc0: Test case 32. Consecutive trim performance by transfer size...
mmc0: Result: UNSUPPORTED (by card)
mmc0: Tests completed.

Signature · 2 lines
Regards,
Shawn
#7 lore raw

PATCH v3 1/1 mmc: mxs-mmc: add mmc host driver for i.MX23/28

Quoted 6 lines

My busybox version of dd does not report the speed. But I tried to dd 8MB data and saw it's done in 1~2 seconds.

Also here is mmc host driver test performance related result on my board if you are interested.

OK, looks good. Let's merge the driver then and I will check my board.

Thanks!

Wolfram

Signature · 9 lines
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20110222/1d31de3a/attachment.sig>
#8 lore raw

PATCH v3 1/1 mmc: mxs-mmc: add mmc host driver for i.MX23/28

In reply to Wolfram Sang
Quoted 5 lines · Wolfram Sang
# mount -t vfat /dev/mmcblk0p1 /mnt
# dd if=/mnt/test.dat of=/tmp/a bs=1024
# umount /mnt
# ./dd --version
dd (coreutils) 8.5

In general, you should try to rule out file system, garbage collection, partitioning and cache effects.

With coreutils dd, a good command is

dd if=/dev/zero of=/dev/mmcblk0 bs=64K count=64 seek=256 oflag=direct

* Always write multiples of 4 MB to avoid garbage collection
* smaller block sizes may be faster, so writing 64 times 64K may be better than writing 4 MB once, depending on the card
* don't write to the FAT area, so start writing at 16 MB into the device.
* use direct I/O to bypass the page cache.
* read from /dev/zero instead of a disk file to avoid measuring the wrong thing

Arnd

#9 lore raw

PATCH v3 1/1 mmc: mxs-mmc: add mmc host driver for i.MX23/28

Quoted 9 lines · Arnd Bergmann
Quoted 5 lines · Wolfram Sang
# mount -t vfat /dev/mmcblk0p1 /mnt
# dd if=/mnt/test.dat of=/tmp/a bs=1024
# umount /mnt
# ./dd --version
dd (coreutils) 8.5

In general, you should try to rule out file system, garbage collection, partitioning and cache effects.

Yes, right, I am aware of that (well, most of it ;)). I simplified my testcase here, because I was sure by previous tests it was only dependent on the frequency requested by the card. Remember, I wasn't after maximum values but chasing a difference in read performance of two magnitudes.

Thanks,

Wolfram

Signature · 9 lines
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20110222/e97edfa7/attachment.sig>
#10 lore raw

PATCH v3 1/1 mmc: mxs-mmc: add mmc host driver for i.MX23/28

In reply to Shawn Guo

Hi Shawn,

Quoted 3 lines · Shawn Guo

This adds the mmc host driver for Freescale MXS-based SoC i.MX23/28. The driver calls into mxs-dma via generic dmaengine api for both pio and data transfer.

Thanks very much, pushed to mmc-next for .39.

Signature · 2 lines
Chris Ball   <[email protected]>   <http://printf.net/>
One Laptop Per Child