Patchwork [U-Boot,2/2] ARM: at91sam9x5: enable MCI0 support for 9x5ek board.

login
register
mail settings
Submitter Wu, Josh
Date Sept. 7, 2012, 10:39 a.m.
Message ID <1347014373-4598-2-git-send-email-josh.wu@atmel.com>
Download mbox | patch
Permalink /patch/182355/
State Changes Requested
Delegated to: Andreas Bießmann
Headers show

Comments

Wu, Josh - Sept. 7, 2012, 10:39 a.m.
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(+)
Bo Shen - Sept. 10, 2012, 8:07 a.m.
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@atmel.com
Tested-by: voice.shen@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
>
Wu, Josh - Sept. 12, 2012, 10:21 a.m.
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@atmel.com
> Tested-by: voice.shen@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
>>
>
Andreas Bießmann - Sept. 13, 2012, 11:19 a.m.
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
>
Wu, Josh - Sept. 14, 2012, 6:22 a.m.
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@atmel.com
>> Tested-by: voice.shen@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
>>>
>>
>

Patch

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