[U-Boot] [PATCH] nds32: mmc: Support ftsdc010 DM.

2017-05-23 Thread Andes
From: rick 

Support Andestech ftsdc010 SD/MMC device tree flow
on AG101P/AE3XX platforms.
Verification : boot linux kernel from sd card

NDS32 # mmc rescan
NDS32 # fatls mmc 0:1
13938796   boomimage-310y-ag101p.bin

1 file(s)

NDS32 # fatload mmc 0:1 0x60 boomimage-310y-ag101p.bin
reading boomimage-310y-ag101p.bin
13938796 bytes read in 17358 ms (784.2 KiB/s)
NDS32 # bootm 0x60
 Image Name:
 Created:  2017-05-23   1:58:24 UTC
 Image Type:   NDS32 Linux Kernel Image (uncompressed)
 Data Size:13938732 Bytes = 13.3 MiB
 Load Address: c000
 Entry Point:  c000
 Verifying Checksum ... OK
 Loading Kernel Image ... OK
Linux version 3.10.102-20420-g301b0f6 (rick@app09) (gcc version 4.9.3
(2016-07-06_nds32le-linux-glibc-v3_experimental) )#798
PREEMPT Tue May 23 09:57:59 CST 2017
CPU: NDS32 N13, AndesCore ID(wb), CPU_VER 0x0d0c003f(id 13, rev 12, cfg 63)
...
...
Signed-off-by: rick 
---
 arch/nds32/dts/ae3xx.dts|8 ++
 arch/nds32/dts/ag101p.dts   |8 ++
 board/AndesTech/adp-ae3xx/adp-ae3xx.c   |4 +-
 board/AndesTech/adp-ag101p/adp-ag101p.c |7 +-
 configs/adp-ae3xx_defconfig |5 ++
 configs/adp-ag101p_defconfig|5 ++
 drivers/mmc/Kconfig |   12 +++
 drivers/mmc/Makefile|1 +
 drivers/mmc/ftsdc010_mci.c  |  140 ---
 drivers/mmc/ftsdc010_mci.h  |   54 
 drivers/mmc/nds32_mmc.c |  139 ++
 include/configs/adp-ae3xx.h |1 -
 include/configs/adp-ag101p.h|1 -
 13 files changed, 344 insertions(+), 41 deletions(-)
 create mode 100644 drivers/mmc/ftsdc010_mci.h
 create mode 100644 drivers/mmc/nds32_mmc.c

diff --git a/arch/nds32/dts/ae3xx.dts b/arch/nds32/dts/ae3xx.dts
index 4221e4b..781eabc 100644
--- a/arch/nds32/dts/ae3xx.dts
+++ b/arch/nds32/dts/ae3xx.dts
@@ -62,6 +62,14 @@
interrupts = <25 4>;
};
 
+   mmc0: mmc@f0e0 {
+   compatible = "andestech,atsdc010";
+   clock-freq-min-max = <40 1>;
+   fifo-depth = <0x10>;
+   reg = <0xf0e0 0x1000>;
+   interrupts = <17 4>;
+   };
+
nor@0,0 {
compatible = "cfi-flash";
reg = <0x8800 0x1000>;
diff --git a/arch/nds32/dts/ag101p.dts b/arch/nds32/dts/ag101p.dts
index 99cde2f..dd2bf8f 100644
--- a/arch/nds32/dts/ag101p.dts
+++ b/arch/nds32/dts/ag101p.dts
@@ -60,4 +60,12 @@
reg = <0x9090 0x1000>;
interrupts = <25 4>;
};
+
+   mmc0: mmc@98e0 {
+   compatible = "andestech,atsdc010";
+   clock-freq-min-max = <40 3000>;
+   fifo-depth = <0x10>;
+   reg = <0x98e0 0x1000>;
+   interrupts = <5 4>;
+   };
 };
diff --git a/board/AndesTech/adp-ae3xx/adp-ae3xx.c 
b/board/AndesTech/adp-ae3xx/adp-ae3xx.c
index 98ed4d9..3903427 100644
--- a/board/AndesTech/adp-ae3xx/adp-ae3xx.c
+++ b/board/AndesTech/adp-ae3xx/adp-ae3xx.c
@@ -77,10 +77,8 @@ ulong board_flash_get_legacy(ulong base, int banknum, 
flash_info_t *info)
 
 int board_mmc_init(bd_t *bis)
 {
-#ifndef CONFIG_DM_MMC
-#ifdef CONFIG_FTSDC010
+#if defined(CONFIG_FTSDC010) && !defined(CONFIG_DM_MMC)
ftsdc010_mmc_init(0);
 #endif
-#endif
return 0;
 }
diff --git a/board/AndesTech/adp-ag101p/adp-ag101p.c 
b/board/AndesTech/adp-ag101p/adp-ag101p.c
index a462941..826ba14 100644
--- a/board/AndesTech/adp-ag101p/adp-ag101p.c
+++ b/board/AndesTech/adp-ag101p/adp-ag101p.c
@@ -20,7 +20,6 @@ DECLARE_GLOBAL_DATA_PTR;
 /*
  * Miscellaneous platform dependent initializations
  */
-
 int board_init(void)
 {
/*
@@ -30,7 +29,6 @@ int board_init(void)
printf("Board: %s\n" , CONFIG_SYS_BOARD);
gd->bd->bi_arch_number = MACH_TYPE_ADPAG101P;
gd->bd->bi_boot_params = PHYS_SDRAM_0 + 0x400;
-
return 0;
 }
 
@@ -39,11 +37,8 @@ int dram_init(void)
unsigned long sdram_base = PHYS_SDRAM_0;
unsigned long expected_size = PHYS_SDRAM_0_SIZE + PHYS_SDRAM_1_SIZE;
unsigned long actual_size;
-
actual_size = get_ram_size((void *)sdram_base, expected_size);
-
gd->ram_size = actual_size;
-
if (expected_size != actual_size) {
printf("Warning: Only %lu of %lu MiB SDRAM is working\n",
actual_size >> 20, expected_size >> 20);
@@ -83,7 +78,7 @@ ulong board_flash_get_legacy(ulong base, int banknum, 
flash_info_t *info)
 
 int board_mmc_init(bd_t *bis)
 {
-#ifdef CONFIG_FTSDC010
+#if defined(CONFIG_FTSDC010) && !defined(CONFIG_DM_MMC)
ftsdc010_mmc_init(0);
 #endif
return 0;
diff --git a/configs/adp-ae3xx_defconfig b/configs/adp-ae3xx_defconfig
index cbef412..d12f307 100644
--- a/configs/adp-ae3xx_defco

Re: [U-Boot] [PATCH] nds32: mmc: Support ftsdc010 DM.

2017-05-25 Thread Jaehoon Chung
Hi,

On 05/24/2017 10:47 AM, Andes wrote:
> From: rick 
> 
> Support Andestech ftsdc010 SD/MMC device tree flow
> on AG101P/AE3XX platforms.
> Verification : boot linux kernel from sd card

Split the patch...

> 
> NDS32 # mmc rescan
> NDS32 # fatls mmc 0:1
> 13938796   boomimage-310y-ag101p.bin
> 
> 1 file(s)
> 
> NDS32 # fatload mmc 0:1 0x60 boomimage-310y-ag101p.bin
> reading boomimage-310y-ag101p.bin
> 13938796 bytes read in 17358 ms (784.2 KiB/s)
> NDS32 # bootm 0x60
>Image Name:
>Created:  2017-05-23   1:58:24 UTC
>Image Type:   NDS32 Linux Kernel Image (uncompressed)
>Data Size:13938732 Bytes = 13.3 MiB
>Load Address: c000
>Entry Point:  c000
>Verifying Checksum ... OK
>Loading Kernel Image ... OK
> Linux version 3.10.102-20420-g301b0f6 (rick@app09) (gcc version 4.9.3
> (2016-07-06_nds32le-linux-glibc-v3_experimental) )#798
> PREEMPT Tue May 23 09:57:59 CST 2017
> CPU: NDS32 N13, AndesCore ID(wb), CPU_VER 0x0d0c003f(id 13, rev 12, cfg 63)
>   ...
>   ...
> Signed-off-by: rick 
> ---
>  arch/nds32/dts/ae3xx.dts|8 ++
>  arch/nds32/dts/ag101p.dts   |8 ++
>  board/AndesTech/adp-ae3xx/adp-ae3xx.c   |4 +-
>  board/AndesTech/adp-ag101p/adp-ag101p.c |7 +-
>  configs/adp-ae3xx_defconfig |5 ++
>  configs/adp-ag101p_defconfig|5 ++
>  drivers/mmc/Kconfig |   12 +++
>  drivers/mmc/Makefile|1 +
>  drivers/mmc/ftsdc010_mci.c  |  140 
> ---
>  drivers/mmc/ftsdc010_mci.h  |   54 
>  drivers/mmc/nds32_mmc.c |  139 ++
>  include/configs/adp-ae3xx.h |1 -
>  include/configs/adp-ag101p.h|1 -
>  13 files changed, 344 insertions(+), 41 deletions(-)
>  create mode 100644 drivers/mmc/ftsdc010_mci.h
>  create mode 100644 drivers/mmc/nds32_mmc.c
> 
> diff --git a/arch/nds32/dts/ae3xx.dts b/arch/nds32/dts/ae3xx.dts
> index 4221e4b..781eabc 100644
> --- a/arch/nds32/dts/ae3xx.dts
> +++ b/arch/nds32/dts/ae3xx.dts
> @@ -62,6 +62,14 @@
>   interrupts = <25 4>;
>   };
>  
> + mmc0: mmc@f0e0 {
> + compatible = "andestech,atsdc010";
> + clock-freq-min-max = <40 1>;
> + fifo-depth = <0x10>;
> + reg = <0xf0e0 0x1000>;
> + interrupts = <17 4>;
> + };
> +
>   nor@0,0 {
>   compatible = "cfi-flash";
>   reg = <0x8800 0x1000>;
> diff --git a/arch/nds32/dts/ag101p.dts b/arch/nds32/dts/ag101p.dts
> index 99cde2f..dd2bf8f 100644
> --- a/arch/nds32/dts/ag101p.dts
> +++ b/arch/nds32/dts/ag101p.dts
> @@ -60,4 +60,12 @@
>   reg = <0x9090 0x1000>;
>   interrupts = <25 4>;
>   };
> +
> + mmc0: mmc@98e0 {
> + compatible = "andestech,atsdc010";
> + clock-freq-min-max = <40 3000>;
> + fifo-depth = <0x10>;
> + reg = <0x98e0 0x1000>;
> + interrupts = <5 4>;
> + };
>  };
> diff --git a/board/AndesTech/adp-ae3xx/adp-ae3xx.c 
> b/board/AndesTech/adp-ae3xx/adp-ae3xx.c
> index 98ed4d9..3903427 100644
> --- a/board/AndesTech/adp-ae3xx/adp-ae3xx.c
> +++ b/board/AndesTech/adp-ae3xx/adp-ae3xx.c
> @@ -77,10 +77,8 @@ ulong board_flash_get_legacy(ulong base, int banknum, 
> flash_info_t *info)
>  
>  int board_mmc_init(bd_t *bis)
>  {
> -#ifndef CONFIG_DM_MMC
> -#ifdef CONFIG_FTSDC010
> +#if defined(CONFIG_FTSDC010) && !defined(CONFIG_DM_MMC)
>   ftsdc010_mmc_init(0);
>  #endif
> -#endif
>   return 0;
>  }
> diff --git a/board/AndesTech/adp-ag101p/adp-ag101p.c 
> b/board/AndesTech/adp-ag101p/adp-ag101p.c
> index a462941..826ba14 100644
> --- a/board/AndesTech/adp-ag101p/adp-ag101p.c
> +++ b/board/AndesTech/adp-ag101p/adp-ag101p.c
> @@ -20,7 +20,6 @@ DECLARE_GLOBAL_DATA_PTR;
>  /*
>   * Miscellaneous platform dependent initializations
>   */
> -
>  int board_init(void)
>  {
>   /*
> @@ -30,7 +29,6 @@ int board_init(void)
>   printf("Board: %s\n" , CONFIG_SYS_BOARD);
>   gd->bd->bi_arch_number = MACH_TYPE_ADPAG101P;
>   gd->bd->bi_boot_params = PHYS_SDRAM_0 + 0x400;
> -
>   return 0;
>  }
>  
> @@ -39,11 +37,8 @@ int dram_init(void)
>   unsigned long sdram_base = PHYS_SDRAM_0;
>   unsigned long expected_size = PHYS_SDRAM_0_SIZE + PHYS_SDRAM_1_SIZE;
>   unsigned long actual_size;
> -
>   actual_size = get_ram_size((void *)sdram_base, expected_size);
> -
>   gd->ram_size = actual_size;
> -
>   if (expected_size != actual_size) {
>   printf("Warning: Only %lu of %lu MiB SDRAM is working\n",
>   actual_size >> 20, expected_size >> 20);
> @@ -83,7 +78,7 @@ ulong board_flash_get_legacy(ulong base, int banknum, 
> flash_info_t *info)
>  
>  int board_mmc_init(bd_t *bis)
>  {
> -#ifdef CON

Re: [U-Boot] [PATCH] nds32: mmc: Support ftsdc010 DM.

2017-05-30 Thread rick
Hi Jaehoon

Sorry for the late response because of the vacations.

I have splitted it to 3 parts.

Thanks

Rick

-Original Message-
From: U-Boot [mailto:u-boot-boun...@lists.denx.de] On Behalf Of Jaehoon Chung
Sent: Thursday, May 25, 2017 10:03 PM
To: Open Source Project uboot; u-boot@lists.denx.de; w...@denx.de; d...@denx.de
Subject: Re: [U-Boot] [PATCH] nds32: mmc: Support ftsdc010 DM.

Hi,

On 05/24/2017 10:47 AM, Andes wrote:
> From: rick 
>
> Support Andestech ftsdc010 SD/MMC device tree flow on AG101P/AE3XX
> platforms.
> Verification : boot linux kernel from sd card

Split the patch...

>
> NDS32 # mmc rescan
> NDS32 # fatls mmc 0:1
> 13938796   boomimage-310y-ag101p.bin
>
> 1 file(s)
>
> NDS32 # fatload mmc 0:1 0x60 boomimage-310y-ag101p.bin reading
> boomimage-310y-ag101p.bin
> 13938796 bytes read in 17358 ms (784.2 KiB/s)
> NDS32 # bootm 0x60
>Image Name:
>Created:  2017-05-23   1:58:24 UTC
>Image Type:   NDS32 Linux Kernel Image (uncompressed)
>Data Size:13938732 Bytes = 13.3 MiB
>Load Address: c000
>Entry Point:  c000
>Verifying Checksum ... OK
>Loading Kernel Image ... OK
> Linux version 3.10.102-20420-g301b0f6 (rick@app09) (gcc version 4.9.3
> (2016-07-06_nds32le-linux-glibc-v3_experimental) )#798 PREEMPT Tue May
> 23 09:57:59 CST 2017
> CPU: NDS32 N13, AndesCore ID(wb), CPU_VER 0x0d0c003f(id 13, rev 12, cfg 63)
>   ...
>   ...
> Signed-off-by: rick 
> ---
>  arch/nds32/dts/ae3xx.dts|8 ++
>  arch/nds32/dts/ag101p.dts   |8 ++
>  board/AndesTech/adp-ae3xx/adp-ae3xx.c   |4 +-
>  board/AndesTech/adp-ag101p/adp-ag101p.c |7 +-
>  configs/adp-ae3xx_defconfig |5 ++
>  configs/adp-ag101p_defconfig|5 ++
>  drivers/mmc/Kconfig |   12 +++
>  drivers/mmc/Makefile|1 +
>  drivers/mmc/ftsdc010_mci.c  |  140 
> ---
>  drivers/mmc/ftsdc010_mci.h  |   54 
>  drivers/mmc/nds32_mmc.c |  139 ++
>  include/configs/adp-ae3xx.h |1 -
>  include/configs/adp-ag101p.h|1 -
>  13 files changed, 344 insertions(+), 41 deletions(-)  create mode
> 100644 drivers/mmc/ftsdc010_mci.h  create mode 100644
> drivers/mmc/nds32_mmc.c
>
> diff --git a/arch/nds32/dts/ae3xx.dts b/arch/nds32/dts/ae3xx.dts index
> 4221e4b..781eabc 100644
> --- a/arch/nds32/dts/ae3xx.dts
> +++ b/arch/nds32/dts/ae3xx.dts
> @@ -62,6 +62,14 @@
>   interrupts = <25 4>;
>   };
>
> + mmc0: mmc@f0e0 {
> + compatible = "andestech,atsdc010";
> + clock-freq-min-max = <40 1>;
> + fifo-depth = <0x10>;
> + reg = <0xf0e0 0x1000>;
> + interrupts = <17 4>;
> + };
> +
>   nor@0,0 {
>   compatible = "cfi-flash";
>   reg = <0x8800 0x1000>;
> diff --git a/arch/nds32/dts/ag101p.dts b/arch/nds32/dts/ag101p.dts
> index 99cde2f..dd2bf8f 100644
> --- a/arch/nds32/dts/ag101p.dts
> +++ b/arch/nds32/dts/ag101p.dts
> @@ -60,4 +60,12 @@
>   reg = <0x9090 0x1000>;
>   interrupts = <25 4>;
>   };
> +
> + mmc0: mmc@98e0 {
> + compatible = "andestech,atsdc010";
> + clock-freq-min-max = <40 3000>;
> + fifo-depth = <0x10>;
> + reg = <0x98e0 0x1000>;
> + interrupts = <5 4>;
> + };
>  };
> diff --git a/board/AndesTech/adp-ae3xx/adp-ae3xx.c
> b/board/AndesTech/adp-ae3xx/adp-ae3xx.c
> index 98ed4d9..3903427 100644
> --- a/board/AndesTech/adp-ae3xx/adp-ae3xx.c
> +++ b/board/AndesTech/adp-ae3xx/adp-ae3xx.c
> @@ -77,10 +77,8 @@ ulong board_flash_get_legacy(ulong base, int
> banknum, flash_info_t *info)
>
>  int board_mmc_init(bd_t *bis)
>  {
> -#ifndef CONFIG_DM_MMC
> -#ifdef CONFIG_FTSDC010
> +#if defined(CONFIG_FTSDC010) && !defined(CONFIG_DM_MMC)
>   ftsdc010_mmc_init(0);
>  #endif
> -#endif
>   return 0;
>  }
> diff --git a/board/AndesTech/adp-ag101p/adp-ag101p.c
> b/board/AndesTech/adp-ag101p/adp-ag101p.c
> index a462941..826ba14 100644
> --- a/board/AndesTech/adp-ag101p/adp-ag101p.c
> +++ b/board/AndesTech/adp-ag101p/adp-ag101p.c
> @@ -20,7 +20,6 @@ DECLARE_GLOBAL_DATA_PTR;
>  /*
>   * Miscellaneous platform dependent initializations
>   */
> -
>  int board_init(void)
>  {
>   /*
> @@ -30,7 +29,6 @@ int board_init(void