public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/2] mmc: at91: add multi block read/write support.
@ 2012-09-07 10:39 Josh Wu
  2012-09-07 10:39 ` [U-Boot] [PATCH 2/2] ARM: at91sam9x5: enable MCI0 support for 9x5ek board Josh Wu
  2012-09-13 11:11 ` [U-Boot] [PATCH 1/2] mmc: at91: add multi block read/write support Andreas Bießmann
  0 siblings, 2 replies; 8+ messages in thread
From: Josh Wu @ 2012-09-07 10:39 UTC (permalink / raw)
  To: u-boot

Since the at91sam9263, the mmc hardware support multi blocks read/write. So this driver enable it.
This patch also change delay time to max value, which can avoid the timeout error in rare case.

Signed-off-by: Josh Wu <josh.wu@atmel.com>
---
 drivers/mmc/gen_atmel_mci.c |   16 +++++++++++++---
 include/atmel_mci.h         |    5 ++++-
 2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/drivers/mmc/gen_atmel_mci.c b/drivers/mmc/gen_atmel_mci.c
index 4968c5e..ec075f7 100644
--- a/drivers/mmc/gen_atmel_mci.c
+++ b/drivers/mmc/gen_atmel_mci.c
@@ -24,7 +24,6 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  * MA 02111-1307 USA
  */
-
 #include <common.h>
 #include <mmc.h>
 #include <part.h>
@@ -87,6 +86,11 @@ static void mci_set_mode(struct mmc *mmc, u32 hz, u32 blklen)
 		 | MMCI_BF(BLKLEN, blklen)
 		 | MMCI_BIT(RDPROOF)
 		 | MMCI_BIT(WRPROOF)), &mci->mr);
+	/*
+	 * On some new platforms BLKLEN in mci->mr is ignored.
+	 * Should use the BLKLEN in the block register.
+	 */
+	writel(blklen << MMCI_BLKLEN_OFFSET, &mci->blkr);
 	initialized = 1;
 }
 
@@ -183,6 +187,12 @@ mci_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data)
 	/* Figure out the transfer arguments */
 	cmdr = mci_encode_cmd(cmd, data, &error_flags);
 
+	/* For multi blocks read/write, set the block register */
+	if ((cmd->cmdidx == MMC_CMD_READ_MULTIPLE_BLOCK)
+			|| (cmd->cmdidx == MMC_CMD_WRITE_MULTIPLE_BLOCK))
+		writel(data->blocks | mmc->read_bl_len << MMCI_BLKLEN_OFFSET,
+			&mci->blkr);
+
 	/* Send the command */
 	writel(cmd->cmdarg, &mci->argr);
 	writel(cmdr, &mci->cmdr);
@@ -310,8 +320,8 @@ static int mci_init(struct mmc *mmc)
 	writel(MMCI_BIT(MCIEN), &mci->cr);	/* enable mci */
 	writel(MMCI_BF(SCDSEL, MCI_BUS), &mci->sdcr);	/* select port */
 
-	/* Initial Time-outs */
-	writel(0x5f, &mci->dtor);
+	/* This delay can be optimized, but stick with max value */
+	writel(0x7f, &mci->dtor);
 	/* Disable Interrupts */
 	writel(~0UL, &mci->idr);
 
diff --git a/include/atmel_mci.h b/include/atmel_mci.h
index 3dd5d67..85468d4 100644
--- a/include/atmel_mci.h
+++ b/include/atmel_mci.h
@@ -38,7 +38,7 @@ typedef struct atmel_mci {
 	u32	sdcr;	/* 0x0c */
 	u32	argr;	/* 0x10 */
 	u32	cmdr;	/* 0x14 */
-	u32	_18;	/* 0x18 */
+	u32	blkr;	/* 0x18 */
 	u32	_1c;	/* 0x1c */
 	u32	rspr;	/* 0x20 */
 	u32	rspr1;	/* 0x24 */
@@ -118,6 +118,9 @@ typedef struct atmel_mci {
 #define MMCI_TRTYP_OFFSET			19
 #define MMCI_TRTYP_SIZE				2
 
+/* Bitfields in BLKR */
+#define MMCI_BLKLEN_OFFSET			16
+
 /* Bitfields in RSPRx */
 #define MMCI_RSP_OFFSET				0
 #define MMCI_RSP_SIZE				32
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH 2/2] ARM: at91sam9x5: enable MCI0 support for 9x5ek board.
  2012-09-07 10:39 [U-Boot] [PATCH 1/2] mmc: at91: add multi block read/write support Josh Wu
@ 2012-09-07 10:39 ` Josh Wu
  2012-09-10  8:07   ` Bo Shen
  2012-09-13 11:19   ` Andreas Bießmann
  2012-09-13 11:11 ` [U-Boot] [PATCH 1/2] mmc: at91: add multi block read/write support Andreas Bießmann
  1 sibling, 2 replies; 8+ messages in thread
From: Josh Wu @ 2012-09-07 10:39 UTC (permalink / raw)
  To: u-boot


Signed-off-by: Josh Wu <josh.wu@atmel.com>
---
 arch/arm/cpu/arm926ejs/at91/at91sam9x5_devices.c |   13 +++++++++++++
 board/atmel/at91sam9x5ek/at91sam9x5ek.c          |   16 ++++++++++++++++
 include/configs/at91sam9x5ek.h                   |    8 ++++++++
 3 files changed, 37 insertions(+)

diff --git a/arch/arm/cpu/arm926ejs/at91/at91sam9x5_devices.c b/arch/arm/cpu/arm926ejs/at91/at91sam9x5_devices.c
index 6d77219..3608e7c 100644
--- a/arch/arm/cpu/arm926ejs/at91/at91sam9x5_devices.c
+++ b/arch/arm/cpu/arm926ejs/at91/at91sam9x5_devices.c
@@ -230,3 +230,16 @@ void at91_macb_hw_init(void)
 #endif
 }
 #endif
+
+#if defined(CONFIG_GENERIC_ATMEL_MCI)
+void at91_mci_hw_init(void)
+{
+	/* Initialize the MCI0 */
+	at91_set_a_periph(AT91_PIO_PORTA, 17, 1);	/* MCCK */
+	at91_set_a_periph(AT91_PIO_PORTA, 16, 1);	/* MCCDA */
+	at91_set_a_periph(AT91_PIO_PORTA, 15, 1);	/* MCDA0 */
+	at91_set_a_periph(AT91_PIO_PORTA, 18, 1);	/* MCDA1 */
+	at91_set_a_periph(AT91_PIO_PORTA, 19, 1);	/* MCDA2 */
+	at91_set_a_periph(AT91_PIO_PORTA, 20, 1);	/* MCDA3 */
+}
+#endif
diff --git a/board/atmel/at91sam9x5ek/at91sam9x5ek.c b/board/atmel/at91sam9x5ek/at91sam9x5ek.c
index 06028aa..d1f05ef 100644
--- a/board/atmel/at91sam9x5ek/at91sam9x5ek.c
+++ b/board/atmel/at91sam9x5ek/at91sam9x5ek.c
@@ -42,6 +42,9 @@
 #ifdef CONFIG_ATMEL_SPI
 #include <spi.h>
 #endif
+#ifdef CONFIG_GENERIC_ATMEL_MCI
+#include <mmc.h>
+#endif
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -258,6 +261,19 @@ void spi_cs_deactivate(struct spi_slave *slave)
 }
 #endif /* CONFIG_ATMEL_SPI */
 
+#ifdef CONFIG_GENERIC_ATMEL_MCI
+int board_mmc_init(bd_t *bd)
+{
+	/* Enable clock */
+	struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
+	writel(1 << ATMEL_ID_HSMCI0, &pmc->pcer);
+
+	at91_mci_hw_init();
+
+	return atmel_mci_init((void *)ATMEL_BASE_HSMCI0);
+}
+#endif
+
 int board_early_init_f(void)
 {
 	at91_seriald_hw_init();
diff --git a/include/configs/at91sam9x5ek.h b/include/configs/at91sam9x5ek.h
index 1ceb31a..974e08f 100644
--- a/include/configs/at91sam9x5ek.h
+++ b/include/configs/at91sam9x5ek.h
@@ -136,6 +136,14 @@
 #define CONFIG_CMD_UBIFS
 #endif
 
+/* MMC */
+#define CONFIG_MMC
+#define CONFIG_CMD_MMC
+#define CONFIG_CMD_FAT
+#define CONFIG_GENERIC_MMC
+#define CONFIG_GENERIC_ATMEL_MCI
+#define CONFIG_DOS_PARTITION
+
 /* Ethernet */
 #define CONFIG_MACB
 #define CONFIG_RMII
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH 2/2] ARM: at91sam9x5: enable MCI0 support for 9x5ek board.
  2012-09-07 10:39 ` [U-Boot] [PATCH 2/2] ARM: at91sam9x5: enable MCI0 support for 9x5ek board Josh Wu
@ 2012-09-10  8:07   ` Bo Shen
  2012-09-12 10:21     ` Josh Wu
  2012-09-13 11:19   ` Andreas Bießmann
  1 sibling, 1 reply; 8+ messages in thread
From: Bo Shen @ 2012-09-10  8:07 UTC (permalink / raw)
  To: u-boot

Hi Josh,

On 9/7/2012 18:39, Josh Wu wrote:
>
> Signed-off-by: Josh Wu <josh.wu@atmel.com>
> ---
>   arch/arm/cpu/arm926ejs/at91/at91sam9x5_devices.c |   13 +++++++++++++
>   board/atmel/at91sam9x5ek/at91sam9x5ek.c          |   16 ++++++++++++++++
>   include/configs/at91sam9x5ek.h                   |    8 ++++++++
>   3 files changed, 37 insertions(+)
>

I think add MCI1 support at the same time will be better. Otherwise,

Acked-by: voice.shen at atmel.com
Tested-by: voice.shen at atmel.com

> diff --git a/arch/arm/cpu/arm926ejs/at91/at91sam9x5_devices.c b/arch/arm/cpu/arm926ejs/at91/at91sam9x5_devices.c
> index 6d77219..3608e7c 100644
> --- a/arch/arm/cpu/arm926ejs/at91/at91sam9x5_devices.c
> +++ b/arch/arm/cpu/arm926ejs/at91/at91sam9x5_devices.c
> @@ -230,3 +230,16 @@ void at91_macb_hw_init(void)
>   #endif
>   }
>   #endif
> +
> +#if defined(CONFIG_GENERIC_ATMEL_MCI)
> +void at91_mci_hw_init(void)
> +{
> +	/* Initialize the MCI0 */
> +	at91_set_a_periph(AT91_PIO_PORTA, 17, 1);	/* MCCK */
> +	at91_set_a_periph(AT91_PIO_PORTA, 16, 1);	/* MCCDA */
> +	at91_set_a_periph(AT91_PIO_PORTA, 15, 1);	/* MCDA0 */
> +	at91_set_a_periph(AT91_PIO_PORTA, 18, 1);	/* MCDA1 */
> +	at91_set_a_periph(AT91_PIO_PORTA, 19, 1);	/* MCDA2 */
> +	at91_set_a_periph(AT91_PIO_PORTA, 20, 1);	/* MCDA3 */
> +}
> +#endif
> diff --git a/board/atmel/at91sam9x5ek/at91sam9x5ek.c b/board/atmel/at91sam9x5ek/at91sam9x5ek.c
> index 06028aa..d1f05ef 100644
> --- a/board/atmel/at91sam9x5ek/at91sam9x5ek.c
> +++ b/board/atmel/at91sam9x5ek/at91sam9x5ek.c
> @@ -42,6 +42,9 @@
>   #ifdef CONFIG_ATMEL_SPI
>   #include <spi.h>
>   #endif
> +#ifdef CONFIG_GENERIC_ATMEL_MCI
> +#include <mmc.h>
> +#endif
>
>   DECLARE_GLOBAL_DATA_PTR;
>
> @@ -258,6 +261,19 @@ void spi_cs_deactivate(struct spi_slave *slave)
>   }
>   #endif /* CONFIG_ATMEL_SPI */
>
> +#ifdef CONFIG_GENERIC_ATMEL_MCI
> +int board_mmc_init(bd_t *bd)
> +{
> +	/* Enable clock */
> +	struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
> +	writel(1 << ATMEL_ID_HSMCI0, &pmc->pcer);
> +
> +	at91_mci_hw_init();
> +
> +	return atmel_mci_init((void *)ATMEL_BASE_HSMCI0);
> +}
> +#endif
> +
>   int board_early_init_f(void)
>   {
>   	at91_seriald_hw_init();
> diff --git a/include/configs/at91sam9x5ek.h b/include/configs/at91sam9x5ek.h
> index 1ceb31a..974e08f 100644
> --- a/include/configs/at91sam9x5ek.h
> +++ b/include/configs/at91sam9x5ek.h
> @@ -136,6 +136,14 @@
>   #define CONFIG_CMD_UBIFS
>   #endif
>
> +/* MMC */
> +#define CONFIG_MMC
> +#define CONFIG_CMD_MMC
> +#define CONFIG_CMD_FAT
> +#define CONFIG_GENERIC_MMC
> +#define CONFIG_GENERIC_ATMEL_MCI
> +#define CONFIG_DOS_PARTITION
> +
>   /* Ethernet */
>   #define CONFIG_MACB
>   #define CONFIG_RMII
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH 2/2] ARM: at91sam9x5: enable MCI0 support for 9x5ek board.
  2012-09-10  8:07   ` Bo Shen
@ 2012-09-12 10:21     ` Josh Wu
  2012-09-14  6:22       ` Josh Wu
  0 siblings, 1 reply; 8+ messages in thread
From: Josh Wu @ 2012-09-12 10:21 UTC (permalink / raw)
  To: u-boot

Hi, Voice

On 9/10/2012 4:07 PM, Bo Shen wrote:
> Hi Josh,
>
> On 9/7/2012 18:39, Josh Wu wrote:
>>
>> Signed-off-by: Josh Wu <josh.wu@atmel.com>
>> ---
>>   arch/arm/cpu/arm926ejs/at91/at91sam9x5_devices.c |   13 +++++++++++++
>>   board/atmel/at91sam9x5ek/at91sam9x5ek.c          |   16 
>> ++++++++++++++++
>>   include/configs/at91sam9x5ek.h                   |    8 ++++++++
>>   3 files changed, 37 insertions(+)
>>
>
> I think add MCI1 support at the same time will be better. Otherwise,
>
> Acked-by: voice.shen at atmel.com
> Tested-by: voice.shen at atmel.com
>

Thanks for the testing. If this patch will be accepted. then I will add 
MCI1 support in later patch.

Best Regards,
Josh Wu

>> diff --git a/arch/arm/cpu/arm926ejs/at91/at91sam9x5_devices.c 
>> b/arch/arm/cpu/arm926ejs/at91/at91sam9x5_devices.c
>> index 6d77219..3608e7c 100644
>> --- a/arch/arm/cpu/arm926ejs/at91/at91sam9x5_devices.c
>> +++ b/arch/arm/cpu/arm926ejs/at91/at91sam9x5_devices.c
>> @@ -230,3 +230,16 @@ void at91_macb_hw_init(void)
>>   #endif
>>   }
>>   #endif
>> +
>> +#if defined(CONFIG_GENERIC_ATMEL_MCI)
>> +void at91_mci_hw_init(void)
>> +{
>> +    /* Initialize the MCI0 */
>> +    at91_set_a_periph(AT91_PIO_PORTA, 17, 1);    /* MCCK */
>> +    at91_set_a_periph(AT91_PIO_PORTA, 16, 1);    /* MCCDA */
>> +    at91_set_a_periph(AT91_PIO_PORTA, 15, 1);    /* MCDA0 */
>> +    at91_set_a_periph(AT91_PIO_PORTA, 18, 1);    /* MCDA1 */
>> +    at91_set_a_periph(AT91_PIO_PORTA, 19, 1);    /* MCDA2 */
>> +    at91_set_a_periph(AT91_PIO_PORTA, 20, 1);    /* MCDA3 */
>> +}
>> +#endif
>> diff --git a/board/atmel/at91sam9x5ek/at91sam9x5ek.c 
>> b/board/atmel/at91sam9x5ek/at91sam9x5ek.c
>> index 06028aa..d1f05ef 100644
>> --- a/board/atmel/at91sam9x5ek/at91sam9x5ek.c
>> +++ b/board/atmel/at91sam9x5ek/at91sam9x5ek.c
>> @@ -42,6 +42,9 @@
>>   #ifdef CONFIG_ATMEL_SPI
>>   #include <spi.h>
>>   #endif
>> +#ifdef CONFIG_GENERIC_ATMEL_MCI
>> +#include <mmc.h>
>> +#endif
>>
>>   DECLARE_GLOBAL_DATA_PTR;
>>
>> @@ -258,6 +261,19 @@ void spi_cs_deactivate(struct spi_slave *slave)
>>   }
>>   #endif /* CONFIG_ATMEL_SPI */
>>
>> +#ifdef CONFIG_GENERIC_ATMEL_MCI
>> +int board_mmc_init(bd_t *bd)
>> +{
>> +    /* Enable clock */
>> +    struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
>> +    writel(1 << ATMEL_ID_HSMCI0, &pmc->pcer);
>> +
>> +    at91_mci_hw_init();
>> +
>> +    return atmel_mci_init((void *)ATMEL_BASE_HSMCI0);
>> +}
>> +#endif
>> +
>>   int board_early_init_f(void)
>>   {
>>       at91_seriald_hw_init();
>> diff --git a/include/configs/at91sam9x5ek.h 
>> b/include/configs/at91sam9x5ek.h
>> index 1ceb31a..974e08f 100644
>> --- a/include/configs/at91sam9x5ek.h
>> +++ b/include/configs/at91sam9x5ek.h
>> @@ -136,6 +136,14 @@
>>   #define CONFIG_CMD_UBIFS
>>   #endif
>>
>> +/* MMC */
>> +#define CONFIG_MMC
>> +#define CONFIG_CMD_MMC
>> +#define CONFIG_CMD_FAT
>> +#define CONFIG_GENERIC_MMC
>> +#define CONFIG_GENERIC_ATMEL_MCI
>> +#define CONFIG_DOS_PARTITION
>> +
>>   /* Ethernet */
>>   #define CONFIG_MACB
>>   #define CONFIG_RMII
>>
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH 1/2] mmc: at91: add multi block read/write support.
  2012-09-07 10:39 [U-Boot] [PATCH 1/2] mmc: at91: add multi block read/write support Josh Wu
  2012-09-07 10:39 ` [U-Boot] [PATCH 2/2] ARM: at91sam9x5: enable MCI0 support for 9x5ek board Josh Wu
@ 2012-09-13 11:11 ` Andreas Bießmann
  2012-09-14  8:31   ` Josh Wu
  1 sibling, 1 reply; 8+ messages in thread
From: Andreas Bießmann @ 2012-09-13 11:11 UTC (permalink / raw)
  To: u-boot

Dear Josh Wu,

sorry for beeing late. Bu2013.01 release.t this submission was way after
merge window close so it will anyhow end up in 2013.01 release.

On 07.09.2012 12:39, Josh Wu wrote:
> Since the at91sam9263, the mmc hardware support multi blocks read/write. So this driver enable it.
> This patch also change delay time to max value, which can avoid the timeout error in rare case.
> 
> Signed-off-by: Josh Wu <josh.wu@atmel.com>
> ---
>  drivers/mmc/gen_atmel_mci.c |   16 +++++++++++++---
>  include/atmel_mci.h         |    5 ++++-
>  2 files changed, 17 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/mmc/gen_atmel_mci.c b/drivers/mmc/gen_atmel_mci.c
> index 4968c5e..ec075f7 100644
> --- a/drivers/mmc/gen_atmel_mci.c
> +++ b/drivers/mmc/gen_atmel_mci.c
> @@ -24,7 +24,6 @@
>   * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
>   * MA 02111-1307 USA
>   */
> -

please leave this line untouched.

>  #include <common.h>
>  #include <mmc.h>
>  #include <part.h>
> @@ -87,6 +86,11 @@ static void mci_set_mode(struct mmc *mmc, u32 hz, u32 blklen)
>  		 | MMCI_BF(BLKLEN, blklen)
>  		 | MMCI_BIT(RDPROOF)
>  		 | MMCI_BIT(WRPROOF)), &mci->mr);
> +	/*
> +	 * On some new platforms BLKLEN in mci->mr is ignored.
> +	 * Should use the BLKLEN in the block register.
> +	 */
> +	writel(blklen << MMCI_BLKLEN_OFFSET, &mci->blkr);

please use the MMCI_BF macro here

>  	initialized = 1;
>  }
>  
> @@ -183,6 +187,12 @@ mci_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data)
>  	/* Figure out the transfer arguments */
>  	cmdr = mci_encode_cmd(cmd, data, &error_flags);
>  
> +	/* For multi blocks read/write, set the block register */
> +	if ((cmd->cmdidx == MMC_CMD_READ_MULTIPLE_BLOCK)
> +			|| (cmd->cmdidx == MMC_CMD_WRITE_MULTIPLE_BLOCK))
> +		writel(data->blocks | mmc->read_bl_len << MMCI_BLKLEN_OFFSET,
> +			&mci->blkr);

please use the MMCI_BF macros here.

> +
>  	/* Send the command */
>  	writel(cmd->cmdarg, &mci->argr);
>  	writel(cmdr, &mci->cmdr);
> @@ -310,8 +320,8 @@ static int mci_init(struct mmc *mmc)
>  	writel(MMCI_BIT(MCIEN), &mci->cr);	/* enable mci */
>  	writel(MMCI_BF(SCDSEL, MCI_BUS), &mci->sdcr);	/* select port */
>  
> -	/* Initial Time-outs */
> -	writel(0x5f, &mci->dtor);
> +	/* This delay can be optimized, but stick with max value */
> +	writel(0x7f, &mci->dtor);

can we split this in a separate patch?

>  	/* Disable Interrupts */
>  	writel(~0UL, &mci->idr);
>  
> diff --git a/include/atmel_mci.h b/include/atmel_mci.h
> index 3dd5d67..85468d4 100644
> --- a/include/atmel_mci.h
> +++ b/include/atmel_mci.h
> @@ -38,7 +38,7 @@ typedef struct atmel_mci {
>  	u32	sdcr;	/* 0x0c */
>  	u32	argr;	/* 0x10 */
>  	u32	cmdr;	/* 0x14 */
> -	u32	_18;	/* 0x18 */
> +	u32	blkr;	/* 0x18 */
>  	u32	_1c;	/* 0x1c */
>  	u32	rspr;	/* 0x20 */
>  	u32	rspr1;	/* 0x24 */
> @@ -118,6 +118,9 @@ typedef struct atmel_mci {
>  #define MMCI_TRTYP_OFFSET			19
>  #define MMCI_TRTYP_SIZE				2
>  
> +/* Bitfields in BLKR */
> +#define MMCI_BLKLEN_OFFSET			16

NAK, this is defined some lines up (under MR), please add an reminder
here that it is defined under MR. I wonder if this will produce 'defined
previously' warnings.

> +
>  /* Bitfields in RSPRx */
>  #define MMCI_RSP_OFFSET				0
>  #define MMCI_RSP_SIZE				32
> 

Best regards

Andreas Bie?mann

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH 2/2] ARM: at91sam9x5: enable MCI0 support for 9x5ek board.
  2012-09-07 10:39 ` [U-Boot] [PATCH 2/2] ARM: at91sam9x5: enable MCI0 support for 9x5ek board Josh Wu
  2012-09-10  8:07   ` Bo Shen
@ 2012-09-13 11:19   ` Andreas Bießmann
  1 sibling, 0 replies; 8+ messages in thread
From: Andreas Bießmann @ 2012-09-13 11:19 UTC (permalink / raw)
  To: u-boot

Dear Josh Wu,

On 07.09.2012 12:39, Josh Wu wrote:
> Signed-off-by: Josh Wu <josh.wu@atmel.com>
> ---
>  arch/arm/cpu/arm926ejs/at91/at91sam9x5_devices.c |   13 +++++++++++++
>  board/atmel/at91sam9x5ek/at91sam9x5ek.c          |   16 ++++++++++++++++
>  include/configs/at91sam9x5ek.h                   |    8 ++++++++
>  3 files changed, 37 insertions(+)
> 
> diff --git a/arch/arm/cpu/arm926ejs/at91/at91sam9x5_devices.c b/arch/arm/cpu/arm926ejs/at91/at91sam9x5_devices.c
> index 6d77219..3608e7c 100644
> --- a/arch/arm/cpu/arm926ejs/at91/at91sam9x5_devices.c
> +++ b/arch/arm/cpu/arm926ejs/at91/at91sam9x5_devices.c
> @@ -230,3 +230,16 @@ void at91_macb_hw_init(void)
>  #endif
>  }
>  #endif
> +
> +#if defined(CONFIG_GENERIC_ATMEL_MCI)

This define is not necessary, we have -ffunction-sections and --gc-sections.

> +void at91_mci_hw_init(void)
> +{

I favor initializing the required clocks here.

> +	/* Initialize the MCI0 */
> +	at91_set_a_periph(AT91_PIO_PORTA, 17, 1);	/* MCCK */
> +	at91_set_a_periph(AT91_PIO_PORTA, 16, 1);	/* MCCDA */
> +	at91_set_a_periph(AT91_PIO_PORTA, 15, 1);	/* MCDA0 */
> +	at91_set_a_periph(AT91_PIO_PORTA, 18, 1);	/* MCDA1 */
> +	at91_set_a_periph(AT91_PIO_PORTA, 19, 1);	/* MCDA2 */
> +	at91_set_a_periph(AT91_PIO_PORTA, 20, 1);	/* MCDA3 */
> +}
> +#endif
> diff --git a/board/atmel/at91sam9x5ek/at91sam9x5ek.c b/board/atmel/at91sam9x5ek/at91sam9x5ek.c
> index 06028aa..d1f05ef 100644
> --- a/board/atmel/at91sam9x5ek/at91sam9x5ek.c
> +++ b/board/atmel/at91sam9x5ek/at91sam9x5ek.c
> @@ -42,6 +42,9 @@
>  #ifdef CONFIG_ATMEL_SPI
>  #include <spi.h>
>  #endif
> +#ifdef CONFIG_GENERIC_ATMEL_MCI

This define is not necessary at all, we should be able to include header
without any impact if their functionality is not required.

> +#include <mmc.h>
> +#endif
>  
>  DECLARE_GLOBAL_DATA_PTR;
>  
> @@ -258,6 +261,19 @@ void spi_cs_deactivate(struct spi_slave *slave)
>  }
>  #endif /* CONFIG_ATMEL_SPI */
>  
> +#ifdef CONFIG_GENERIC_ATMEL_MCI
> +int board_mmc_init(bd_t *bd)
> +{
> +	/* Enable clock */
> +	struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
> +	writel(1 << ATMEL_ID_HSMCI0, &pmc->pcer);

I favor moving the clock enable to at91_mci_hw_init()

> +
> +	at91_mci_hw_init();
> +
> +	return atmel_mci_init((void *)ATMEL_BASE_HSMCI0);
> +}
> +#endif
> +
>  int board_early_init_f(void)
>  {
>  	at91_seriald_hw_init();
> diff --git a/include/configs/at91sam9x5ek.h b/include/configs/at91sam9x5ek.h
> index 1ceb31a..974e08f 100644
> --- a/include/configs/at91sam9x5ek.h
> +++ b/include/configs/at91sam9x5ek.h
> @@ -136,6 +136,14 @@
>  #define CONFIG_CMD_UBIFS
>  #endif
>  
> +/* MMC */
> +#define CONFIG_MMC
> +#define CONFIG_CMD_MMC
> +#define CONFIG_CMD_FAT
> +#define CONFIG_GENERIC_MMC
> +#define CONFIG_GENERIC_ATMEL_MCI
> +#define CONFIG_DOS_PARTITION
> +
>  /* Ethernet */
>  #define CONFIG_MACB
>  #define CONFIG_RMII
> 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH 2/2] ARM: at91sam9x5: enable MCI0 support for 9x5ek board.
  2012-09-12 10:21     ` Josh Wu
@ 2012-09-14  6:22       ` Josh Wu
  0 siblings, 0 replies; 8+ messages in thread
From: Josh Wu @ 2012-09-14  6:22 UTC (permalink / raw)
  To: u-boot

Hi, Voice

On 9/12/2012 6:21 PM, Josh Wu wrote:
> Hi, Voice
>
> On 9/10/2012 4:07 PM, Bo Shen wrote:
>> Hi Josh,
>>
>> On 9/7/2012 18:39, Josh Wu wrote:
>>>
>>> Signed-off-by: Josh Wu <josh.wu@atmel.com>
>>> ---
>>>   arch/arm/cpu/arm926ejs/at91/at91sam9x5_devices.c |   13 +++++++++++++
>>>   board/atmel/at91sam9x5ek/at91sam9x5ek.c          |   16 
>>> ++++++++++++++++
>>>   include/configs/at91sam9x5ek.h                   |    8 ++++++++
>>>   3 files changed, 37 insertions(+)
>>>
>>
>> I think add MCI1 support at the same time will be better. Otherwise,

After checking the datasheet, The SPI0 has conflict with MCI1 in pin 
PA11, PA12, PA13.
So I decide NOT enable MCI1 in 9x5ek u-boot since SPI0 is maybe most 
used for common cases.

>>
>> Acked-by: voice.shen at atmel.com
>> Tested-by: voice.shen at atmel.com
>>
>
> Thanks for the testing. If this patch will be accepted. then I will 
> add MCI1 support in later patch.
>
> Best Regards,
> Josh Wu
>
>>> diff --git a/arch/arm/cpu/arm926ejs/at91/at91sam9x5_devices.c 
>>> b/arch/arm/cpu/arm926ejs/at91/at91sam9x5_devices.c
>>> index 6d77219..3608e7c 100644
>>> --- a/arch/arm/cpu/arm926ejs/at91/at91sam9x5_devices.c
>>> +++ b/arch/arm/cpu/arm926ejs/at91/at91sam9x5_devices.c
>>> @@ -230,3 +230,16 @@ void at91_macb_hw_init(void)
>>>   #endif
>>>   }
>>>   #endif
>>> +
>>> +#if defined(CONFIG_GENERIC_ATMEL_MCI)
>>> +void at91_mci_hw_init(void)
>>> +{
>>> +    /* Initialize the MCI0 */
>>> +    at91_set_a_periph(AT91_PIO_PORTA, 17, 1);    /* MCCK */
>>> +    at91_set_a_periph(AT91_PIO_PORTA, 16, 1);    /* MCCDA */
>>> +    at91_set_a_periph(AT91_PIO_PORTA, 15, 1);    /* MCDA0 */
>>> +    at91_set_a_periph(AT91_PIO_PORTA, 18, 1);    /* MCDA1 */
>>> +    at91_set_a_periph(AT91_PIO_PORTA, 19, 1);    /* MCDA2 */
>>> +    at91_set_a_periph(AT91_PIO_PORTA, 20, 1);    /* MCDA3 */
>>> +}
>>> +#endif
>>> diff --git a/board/atmel/at91sam9x5ek/at91sam9x5ek.c 
>>> b/board/atmel/at91sam9x5ek/at91sam9x5ek.c
>>> index 06028aa..d1f05ef 100644
>>> --- a/board/atmel/at91sam9x5ek/at91sam9x5ek.c
>>> +++ b/board/atmel/at91sam9x5ek/at91sam9x5ek.c
>>> @@ -42,6 +42,9 @@
>>>   #ifdef CONFIG_ATMEL_SPI
>>>   #include <spi.h>
>>>   #endif
>>> +#ifdef CONFIG_GENERIC_ATMEL_MCI
>>> +#include <mmc.h>
>>> +#endif
>>>
>>>   DECLARE_GLOBAL_DATA_PTR;
>>>
>>> @@ -258,6 +261,19 @@ void spi_cs_deactivate(struct spi_slave *slave)
>>>   }
>>>   #endif /* CONFIG_ATMEL_SPI */
>>>
>>> +#ifdef CONFIG_GENERIC_ATMEL_MCI
>>> +int board_mmc_init(bd_t *bd)
>>> +{
>>> +    /* Enable clock */
>>> +    struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
>>> +    writel(1 << ATMEL_ID_HSMCI0, &pmc->pcer);
>>> +
>>> +    at91_mci_hw_init();
>>> +
>>> +    return atmel_mci_init((void *)ATMEL_BASE_HSMCI0);
>>> +}
>>> +#endif
>>> +
>>>   int board_early_init_f(void)
>>>   {
>>>       at91_seriald_hw_init();
>>> diff --git a/include/configs/at91sam9x5ek.h 
>>> b/include/configs/at91sam9x5ek.h
>>> index 1ceb31a..974e08f 100644
>>> --- a/include/configs/at91sam9x5ek.h
>>> +++ b/include/configs/at91sam9x5ek.h
>>> @@ -136,6 +136,14 @@
>>>   #define CONFIG_CMD_UBIFS
>>>   #endif
>>>
>>> +/* MMC */
>>> +#define CONFIG_MMC
>>> +#define CONFIG_CMD_MMC
>>> +#define CONFIG_CMD_FAT
>>> +#define CONFIG_GENERIC_MMC
>>> +#define CONFIG_GENERIC_ATMEL_MCI
>>> +#define CONFIG_DOS_PARTITION
>>> +
>>>   /* Ethernet */
>>>   #define CONFIG_MACB
>>>   #define CONFIG_RMII
>>>
>>
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH 1/2] mmc: at91: add multi block read/write support.
  2012-09-13 11:11 ` [U-Boot] [PATCH 1/2] mmc: at91: add multi block read/write support Andreas Bießmann
@ 2012-09-14  8:31   ` Josh Wu
  0 siblings, 0 replies; 8+ messages in thread
From: Josh Wu @ 2012-09-14  8:31 UTC (permalink / raw)
  To: u-boot

On 9/13/2012 7:11 PM, Andreas Bie?mann wrote:
> Dear Josh Wu,
>
> sorry for beeing late. Bu2013.01 release.t this submission was way after
> merge window close so it will anyhow end up in 2013.01 release.

OK, no problem.

According to your comments I made the v2 patch and already sent it out. 
Thank you.

Best Regards,
Josh Wu
>
> On 07.09.2012 12:39, Josh Wu wrote:
>> Since the at91sam9263, the mmc hardware support multi blocks read/write. So this driver enable it.
>> This patch also change delay time to max value, which can avoid the timeout error in rare case.
>>
>> Signed-off-by: Josh Wu <josh.wu@atmel.com>
>> ---
>>   drivers/mmc/gen_atmel_mci.c |   16 +++++++++++++---
>>   include/atmel_mci.h         |    5 ++++-
>>   2 files changed, 17 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/mmc/gen_atmel_mci.c b/drivers/mmc/gen_atmel_mci.c
>> index 4968c5e..ec075f7 100644
>> --- a/drivers/mmc/gen_atmel_mci.c
>> +++ b/drivers/mmc/gen_atmel_mci.c
>> @@ -24,7 +24,6 @@
>>    * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
>>    * MA 02111-1307 USA
>>    */
>> -
> please leave this line untouched.
>
>>   #include <common.h>
>>   #include <mmc.h>
>>   #include <part.h>
>> @@ -87,6 +86,11 @@ static void mci_set_mode(struct mmc *mmc, u32 hz, u32 blklen)
>>   		 | MMCI_BF(BLKLEN, blklen)
>>   		 | MMCI_BIT(RDPROOF)
>>   		 | MMCI_BIT(WRPROOF)), &mci->mr);
>> +	/*
>> +	 * On some new platforms BLKLEN in mci->mr is ignored.
>> +	 * Should use the BLKLEN in the block register.
>> +	 */
>> +	writel(blklen << MMCI_BLKLEN_OFFSET, &mci->blkr);
> please use the MMCI_BF macro here
>
>>   	initialized = 1;
>>   }
>>   
>> @@ -183,6 +187,12 @@ mci_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data)
>>   	/* Figure out the transfer arguments */
>>   	cmdr = mci_encode_cmd(cmd, data, &error_flags);
>>   
>> +	/* For multi blocks read/write, set the block register */
>> +	if ((cmd->cmdidx == MMC_CMD_READ_MULTIPLE_BLOCK)
>> +			|| (cmd->cmdidx == MMC_CMD_WRITE_MULTIPLE_BLOCK))
>> +		writel(data->blocks | mmc->read_bl_len << MMCI_BLKLEN_OFFSET,
>> +			&mci->blkr);
> please use the MMCI_BF macros here.
>
>> +
>>   	/* Send the command */
>>   	writel(cmd->cmdarg, &mci->argr);
>>   	writel(cmdr, &mci->cmdr);
>> @@ -310,8 +320,8 @@ static int mci_init(struct mmc *mmc)
>>   	writel(MMCI_BIT(MCIEN), &mci->cr);	/* enable mci */
>>   	writel(MMCI_BF(SCDSEL, MCI_BUS), &mci->sdcr);	/* select port */
>>   
>> -	/* Initial Time-outs */
>> -	writel(0x5f, &mci->dtor);
>> +	/* This delay can be optimized, but stick with max value */
>> +	writel(0x7f, &mci->dtor);
> can we split this in a separate patch?
>
>>   	/* Disable Interrupts */
>>   	writel(~0UL, &mci->idr);
>>   
>> diff --git a/include/atmel_mci.h b/include/atmel_mci.h
>> index 3dd5d67..85468d4 100644
>> --- a/include/atmel_mci.h
>> +++ b/include/atmel_mci.h
>> @@ -38,7 +38,7 @@ typedef struct atmel_mci {
>>   	u32	sdcr;	/* 0x0c */
>>   	u32	argr;	/* 0x10 */
>>   	u32	cmdr;	/* 0x14 */
>> -	u32	_18;	/* 0x18 */
>> +	u32	blkr;	/* 0x18 */
>>   	u32	_1c;	/* 0x1c */
>>   	u32	rspr;	/* 0x20 */
>>   	u32	rspr1;	/* 0x24 */
>> @@ -118,6 +118,9 @@ typedef struct atmel_mci {
>>   #define MMCI_TRTYP_OFFSET			19
>>   #define MMCI_TRTYP_SIZE				2
>>   
>> +/* Bitfields in BLKR */
>> +#define MMCI_BLKLEN_OFFSET			16
> NAK, this is defined some lines up (under MR), please add an reminder
> here that it is defined under MR. I wonder if this will produce 'defined
> previously' warnings.
>
>> +
>>   /* Bitfields in RSPRx */
>>   #define MMCI_RSP_OFFSET				0
>>   #define MMCI_RSP_SIZE				32
>>
> Best regards
>
> Andreas Bie?mann

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2012-09-14  8:31 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-07 10:39 [U-Boot] [PATCH 1/2] mmc: at91: add multi block read/write support Josh Wu
2012-09-07 10:39 ` [U-Boot] [PATCH 2/2] ARM: at91sam9x5: enable MCI0 support for 9x5ek board Josh Wu
2012-09-10  8:07   ` Bo Shen
2012-09-12 10:21     ` Josh Wu
2012-09-14  6:22       ` Josh Wu
2012-09-13 11:19   ` Andreas Bießmann
2012-09-13 11:11 ` [U-Boot] [PATCH 1/2] mmc: at91: add multi block read/write support Andreas Bießmann
2012-09-14  8:31   ` Josh Wu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox