add ARM MMCI support
Subsystems (4)
cover add ARM MMCI support
Hi,
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 5de3f3e9a857c7c06322cac70ab5d452267f74ca:
vexpress: mmc support (2013-10-16 13:28:45 +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 | 32 ++++-- drivers/mci/mmci.c | 690 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ drivers/mci/mmci.h | 167 ++++++++++++++++++++++++++++++ include/linux/amba/mmci.h | 42 ++++++++ include/mci.h | 1 + 11 files changed, 956 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
PATCH 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 | 32 ++++++++++++++++++++++++-------- include/mci.h | 1 + 2 files changed, 25 insertions(+), 8 deletions(-)
drivers/mci/mci-core.c +24 -8
@@ -1199,6 +1199,8 @@ 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 = mci->host->max_req_size / mci->read_bl_len; +int write_block;mci_blk_part_switch (part);
@@ -1222,10 +1224,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,6 +1254,8 @@ 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 = mci->host->max_req_size / mci->read_bl_len; +int read_block;int rc;mci_blk_part_switch (part);
@@ -1264,10 +1274,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
@@ -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
PATCH 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
@@ -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
@@ -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
PATCH 3/3 vexpress: mmc support
In reply to Jean-Christophe PLAGNIOL-VILLARDqemu-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
@@ -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
@@ -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
@@ -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
@@ -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
Quoted 11 lines · Jean-Christophe PLAGNIOL-VILLARD
Hi,
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:
I forget there is a bug on qemu that I send this patch to fix
hw/sd/pl181.c +5 -1
@@ -344,7 +344,11 @@ static uint64_t pl181_read(void *opaque, hwaddr offset,data engine. DataCnt is decremented after each byte is transferred between the serial engine and the card. We don't emulate this level of detail, so both can be the same. */ - tmp = (s->datacnt +3 ) >>2 ; +if (s->datactrl &PL181_DATA_DIRECTION ) + tmp = s->fifo_len; +else + tmp = s->datacnt; + tmp = (tmp +3 ) >>2 ;if (s->linux_hack) { s->linux_hack =0 ;pl181_fifo_run (s);
with this the mci support work
Best Regards,
J.
Quoted 29 lines
git://git.jcrosoft.org/barebox.gitdelivery/vexpress_mmcifor you to fetch changes up to
5de3f3e9a857c7c06322cac70ab5d452267f74ca:vexpress: mmc support (2013-10-16 13:28:45 +0800)
----------------------------------------------------------------
Jean-Christophe PLAGNIOL-VILLARD (3):
mci: addmax_req_sizesupport
add: mmci drivers
vexpress: mmc supportarch/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 | 32 ++++-- drivers/mci/mmci.c | 690 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ drivers/mci/mmci.h | 167 ++++++++++++++++++++++++++++++ include/linux/amba/mmci.h | 42 ++++++++ include/mci.h | 1 + 11 files changed, 956 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
Quoted 7 lines
Best Regards,
J._______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Sascha Hauer
AppliedQuoted 8 lines · Jean-Christophe PLAGNIOL-VILLARD
Hi,
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)
Applied, thanks
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
Quoted 11 lines · Sascha Hauer
Quoted 8 lines · Jean-Christophe PLAGNIOL-VILLARD
Hi,
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)
Applied, thanks
I found a bug if max_req_size is 0 we read 0 block
I send a v2
Best Regards,
J.
Quoted 8 lines
Sascha
Signature · 4 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 Best | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox