Skip to contentSkip to conversation

add ARM MMCI support

PATCH In review Jean-Christophe PLAGNIOL-VILLARD 2 participants 5 messages Oct 22, 2013

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v2 cover add ARM MMCI support

Hi,

v2: use max_req_size only if set

to support the ARM AMBA MMCI support we need update the mci support to only request data length that the controler can handle

The following changes since commit 8f23a17f9bac836e4a2f4883ca8f886f535449a8:

Merge branch 'pu/bootloader-spec' (2013-10-14 15:46:10 +0200)

are available in the git repository at:

git://git.jcrosoft.org/barebox.git delivery/vexpress_mmci

for you to fetch changes up to 2d51fd108f2e857b264be86c24ee7130a6b281c7:

vexpress: mmc support (2013-10-18 03:24:33 +0800)

----------------------------------------------------------------
Jean-Christophe PLAGNIOL-VILLARD (3):
mci: add max_req_size support
add: mmci drivers
vexpress: mmc support

 arch/arm/boards/vexpress/init.c               |   9 +-
 arch/arm/mach-vexpress/devices.c              |  12 ++-
 arch/arm/mach-vexpress/include/mach/devices.h |   5 ++
 arch/arm/mach-vexpress/v2m.c                  |   1 +
 drivers/mci/Kconfig                           |   6 ++
 drivers/mci/Makefile                          |   1 +
 drivers/mci/mci-core.c                        |  38 ++++++--
 drivers/mci/mmci.c                            | 690 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 drivers/mci/mmci.h                            | 167 +++++++++++++++++++++++++++++++++++
 include/linux/amba/mmci.h                     |  42 +++++++++
 include/mci.h                                 |   1 +
 11 files changed, 962 insertions(+), 10 deletions(-)
 create mode 100644 drivers/mci/mmci.c
 create mode 100644 drivers/mci/mmci.h
 create mode 100644 include/linux/amba/mmci.h

Best Regards,
J.

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#1 lore raw

PATCH v2 1/3 mci: add max_req_size support

Some controller such as the ARM AMBA pl181 can not handle more than 16bits data length request.

---
 drivers/mci/mci-core.c | 38 ++++++++++++++++++++++++++++++--------
 include/mci.h          |  1 +
 2 files changed, 31 insertions(+), 8 deletions(-)
drivers/mci/mci-core.c +30 -8
index 66ddb5b..cfae91b 100644
@@ -1199,6 +1199,11 @@ static int __maybe_unused mci_sd_write(struct block_device *blk,
 	struct mci *mci = part->mci;
 	struct mci_host *host = mci->host;
 	int rc;
+	unsigned max_req_block = num_blocks;
+	int write_block;
+
+	if (mci->host->max_req_size)
+		max_req_block = mci->host->max_req_size / mci->write_bl_len;
 
 	mci_blk_part_switch(part);
 
@@ -1222,10 +1227,16 @@ static int __maybe_unused mci_sd_write(struct block_device *blk,
 		return -EINVAL;
 	}
 
-	rc = mci_block_write(mci, buffer, block, num_blocks);
-	if (rc != 0) {
-		dev_dbg(&mci->dev, "Writing block %d failed with %d\n", block, rc);
-		return rc;
+	while (num_blocks) {
+		write_block = min_t(int, num_blocks, max_req_block);
+		rc = mci_block_write(mci, buffer, block, write_block);
+		if (rc != 0) {
+			dev_dbg(&mci->dev, "Writing block %d failed with %d\n", block, rc);
+			return rc;
+		}
+		num_blocks -= write_block;
+		block += write_block;
+		buffer += write_block * mci->write_bl_len;
 	}
 
 	return 0;
@@ -1246,8 +1257,13 @@ static int mci_sd_read(struct block_device *blk, void *buffer, int block,
 {
 	struct mci_part *part = container_of(blk, struct mci_part, blk);
 	struct mci *mci = part->mci;
+	unsigned max_req_block = num_blocks;
+	int read_block;
 	int rc;
 
+	if (mci->host->max_req_size)
+		max_req_block = mci->host->max_req_size / mci->read_bl_len;
+
 	mci_blk_part_switch(part);
 
 	dev_dbg(&mci->dev, "%s: Read %d block(s), starting at %d\n",
@@ -1264,10 +1280,16 @@ static int mci_sd_read(struct block_device *blk, void *buffer, int block,
 		return -EINVAL;
 	}
 
-	rc = mci_read_block(mci, buffer, block, num_blocks);
-	if (rc != 0) {
-		dev_dbg(&mci->dev, "Reading block %d failed with %d\n", block, rc);
-		return rc;
+	while (num_blocks) {
+		read_block = min_t(int, num_blocks, max_req_block);
+		rc = mci_read_block(mci, buffer, block, read_block);
+		if (rc != 0) {
+			dev_dbg(&mci->dev, "Reading block %d failed with %d\n", block, rc);
+			return rc;
+		}
+		num_blocks -= read_block;
+		block += read_block;
+		buffer += read_block * mci->read_bl_len;
 	}
 
 	return 0;
include/mci.h +1 -0
index 1ca00c7..07ac273 100644
@@ -293,6 +293,7 @@ struct mci_host {
 	unsigned f_max;		/**< host interface upper limit */
 	unsigned clock;		/**< Current clock used to talk to the card */
 	unsigned bus_width;	/**< used data bus width to the card */
+	unsigned max_req_size;
 
 	/** init the host interface */
 	int (*init)(struct mci_host*, struct device_d*);
Signature · 7 lines
1.8.4.rc3


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#2 lore raw

PATCH v2 2/3 add: mmci drivers

---
 drivers/mci/Kconfig       |   6 +
 drivers/mci/Makefile      |   1 +
 drivers/mci/mmci.c        | 690 ++++++++++++++++++++++++++++++++++++++++++++++
 drivers/mci/mmci.h        | 167 +++++++++++
 include/linux/amba/mmci.h |  42 +++
 5 files changed, 906 insertions(+)
 create mode 100644 drivers/mci/mmci.c
 create mode 100644 drivers/mci/mmci.h
 create mode 100644 include/linux/amba/mmci.h
drivers/mci/Kconfig +6 -0
index f34c119..bd85424 100644
@@ -101,6 +101,12 @@ config MCI_ATMEL
 	  Enable this entry to add support to read and write SD cards on a
 	  Atmel AT91.
 
+config MCI_MMCI
+	bool "ARM PL180 MMCI"
+	help
+	  Enable this entry to add support to read and write SD cards on a
+	  ARM AMBA PL180.
+
 config MCI_SPI
 	bool "MMC/SD over SPI"
 	select CRC7
drivers/mci/Makefile +1 -0
index c13dad3..421ca9f 100644
@@ -9,3 +9,4 @@ obj-$(CONFIG_MCI_PXA)		+= pxamci.o
 obj-$(CONFIG_MCI_S3C)		+= s3c.o
 obj-$(CONFIG_MCI_SPI)		+= mci_spi.o
 obj-$(CONFIG_MCI_DW)		+= dw_mmc.o
+obj-$(CONFIG_MCI_MMCI)		+= mmci.o
drivers/mci/mmci.c new file +690 -0

690 lines not on this page · raw message

drivers/mci/mmci.h new file +167 -0

167 lines not on this page · raw message

include/linux/amba/mmci.h new file +42 -0

42 lines not on this page · raw message

Signature · 7 lines
1.8.4.rc3


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#3 lore raw

PATCH v2 3/3 vexpress: mmc support

In reply to Jean-Christophe PLAGNIOL-VILLARD

qemu-system-arm -m 1024 -smp 1 -M vexpress-a15 -monitor pty -kernel zbarebox -drive if=sd,cache=unsafe,file=sd -nographic -tftp . -net nic -net user

---
 arch/arm/boards/vexpress/init.c               |  9 ++++++++-
 arch/arm/mach-vexpress/devices.c              | 12 +++++++++++-
 arch/arm/mach-vexpress/include/mach/devices.h |  5 +++++
 arch/arm/mach-vexpress/v2m.c                  |  1 +
 4 files changed, 25 insertions(+), 2 deletions(-)
arch/arm/boards/vexpress/init.c +8 -1
index 72a3b08..6196c4e 100644
@@ -16,6 +16,7 @@
 #include <io.h>
 #include <globalvar.h>
 #include <linux/amba/sp804.h>
+#include <mci.h>
 
 struct vexpress_init {
 	void (*core_init)(void);
@@ -24,6 +25,11 @@ struct vexpress_init {
 	void (*devices_init)(void);
 };
 
+struct mmci_platform_data mmci_plat = {
+	.ocr_mask	= MMC_VDD_32_33 | MMC_VDD_33_34,
+	.clkdiv_init	= SDI_CLKCR_CLKDIV_INIT,
+};
+
 struct vexpress_init *v2m_init;
 
 static void vexpress_ax_mem_init(void)
@@ -37,6 +43,7 @@ static void vexpress_ax_devices_init(void)
 {
 	add_cfi_flash_device(0, 0x08000000, SZ_64M, 0);
 	add_cfi_flash_device(1, 0x0c000000, SZ_64M, 0);
+	vexpress_register_mmc(&mmci_plat);
 	add_generic_device("smc911x", DEVICE_ID_DYNAMIC, NULL, 0x1a000000,
 			64 * 1024, IORESOURCE_MEM, NULL);
 	armlinux_set_bootparams((void *)(0x80000100));
@@ -68,7 +75,7 @@ static void vexpress_a9_legacy_devices_init(void)
 	add_cfi_flash_device(1, 0x44000000, SZ_64M, 0);
 	add_generic_device("smc911x", DEVICE_ID_DYNAMIC, NULL, 0x4e000000,
 			64 * 1024, IORESOURCE_MEM, NULL);
-
+	vexpress_a9_legacy_register_mmc(&mmci_plat);
 	armlinux_set_architecture(MACH_TYPE_VEXPRESS);
 	armlinux_set_bootparams((void *)(0x60000100));
 }
arch/arm/mach-vexpress/devices.c +11 -1
index 6ccce52..5b53011 100644
@@ -20,7 +20,6 @@ void vexpress_a9_legacy_add_ddram(u32 ddr0_size, u32 ddr1_size)
 		arm_add_mem_device("ram1", 0x80000000, ddr1_size);
 }
 
-
 void vexpress_a9_legacy_register_uart(unsigned id)
 {
 	resource_size_t start;
@@ -44,6 +43,12 @@ void vexpress_a9_legacy_register_uart(unsigned id)
 	amba_apb_device_add(NULL, "uart-pl011", id, start, 4096, NULL, 0);
 }
 
+void vexpress_a9_legacy_register_mmc(struct mmci_platform_data *plat)
+{
+	amba_apb_device_add(NULL, "mmci-pl18x", DEVICE_ID_SINGLE, 0x10005000,
+	4096, plat, 0);
+}
+
 void vexpress_add_ddram(u32 size)
 {
 	arm_add_mem_device("ram1", 0x80000000, size);
@@ -71,3 +76,8 @@ void vexpress_register_uart(unsigned id)
 	}
 	amba_apb_device_add(NULL, "uart-pl011", id, start, 4096, NULL, 0);
 }
+
+void vexpress_register_mmc(struct mmci_platform_data *plat)
+{
+	amba_apb_device_add(NULL, "mmci-pl18x", DEVICE_ID_SINGLE, 0x1c050000, 4096, plat, 0);
+}
arch/arm/mach-vexpress/include/mach/devices.h +5 -0
index 3146a47..96d1400 100644
@@ -7,6 +7,8 @@
 #ifndef __ASM_ARCH_DEVICES_H__
 #define __ASM_ARCH_DEVICES_H__
 
+#include <linux/amba/mmci.h>
+
 void vexpress_a9_legacy_add_ddram(u32 ddr0_size, u32 ddr1_size);
 void vexpress_add_ddram(u32 size);
 
@@ -16,6 +18,9 @@ void vexpress_register_uart(unsigned id);
 void vexpress_a9_legacy_init(void);
 void vexpress_init(void);
 
+void vexpress_a9_legacy_register_mmc(struct mmci_platform_data *plat);
+void vexpress_register_mmc(struct mmci_platform_data *plat);
+
 extern void *v2m_wdt_base;
 extern void *v2m_sysreg_base;
 
arch/arm/mach-vexpress/v2m.c +1 -0
index d6dde83..025bbb1 100644
@@ -20,6 +20,7 @@
 void __iomem *v2m_sysreg_base;
 
 static const char *v2m_osc2_periphs[] = {
+	"mb:mmci",  "mmci-pl18x",	/* PL180 MMCI */
 	"mb:uart0", "uart-pl0110",	/* PL011 UART0 */
 	"mb:uart1", "uart-pl0111",	/* PL011 UART1 */
 	"mb:uart2", "uart-pl0112",	/* PL011 UART2 */
Signature · 7 lines
1.8.4.rc3


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#4 lore raw
In reply to Jean-Christophe PLAGNIOL-VILLARD
Quoted 8 lines · Jean-Christophe PLAGNIOL-VILLARD

Hi,

v2: use max_req_size only if set

to support the ARM AMBA MMCI support we need update the mci support to only request data length that the controler can handle

Quoted 8 lines

The following changes since commit 8f23a17f9bac836e4a2f4883ca8f886f535449a8:

Merge branch 'pu/bootloader-spec' (2013-10-14 15:46:10 +0200)

are available in the git repository at:

git://git.jcrosoft.org/barebox.git delivery/vexpress_mmci

Switched to this series.

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox