mmc: atmel: Add atmel sdhci support
PATCH v3 1/1 mmc: atmel: Add atmel sdhci support
The SDHCI is introduced by sama5d2, named as Secure Digital Multimedia Card Controller(SDMMC). It supports the embedded MultiMedia Card (e.MMC) Specification V4.41, the SD Memory Card Specification V3.0, and the SDIO V3.0 specification. It is compliant with the SD Host Controller Standard V3.0 specification.
---
Changes in v3:
1./ return -ENODEV instead of -1, when failing to get proper clock. 2./ add free host instance when failing to get proper clock.
Changes in v2:
- According to Bo Shen's comments,
1./ change the macro ATMEL_SDHC_MIN_FRQ -> ATMEL_SDHC_MIN_FREQ. 2./ change the return value to -ENOMEM and print log for malloc failure. 3./ add the failed return and log for getting improper clock. 4./ add more commit log.
arch/arm/mach-at91/include/mach/atmel_sdhci.h | 13 ++++++++ drivers/mmc/Makefile | 1 + drivers/mmc/atmel_sdhci.c | 40 +++++++++++++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 arch/arm/mach-at91/include/mach/atmel_sdhci.h create mode 100644 drivers/mmc/atmel_sdhci.c
arch/arm/mach-at91/include/mach/atmel_sdhci.h new file +13 -0
@@ -0,0 +1,13 @@ +/* +* Copyright (c) 2015 Atmel Corporation +* Wenyou.Yang <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +#ifndef __ATMEL_SDHCI_H +#define __ATMEL_SDHCI_H + +int atmel_sdhci_init (void *regbase,u32 id); + +#endif
drivers/mmc/Makefile +1 -0
@@ -8,6 +8,7 @@ obj-$(CONFIG_DM_MMC) += mmc-uclass.o obj-$(CONFIG_ARM_PL180_MMCI) += arm_pl180_mmci.o +obj-$(CONFIG_ATMEL_SDHCI) += atmel_sdhci.o obj-$(CONFIG_BCM2835_SDHCI) += bcm2835_sdhci.o obj-$(CONFIG_BFIN_SDH) += bfin_sdh.o obj-$(CONFIG_DAVINCI_MMC) += davinci_mmc.o
drivers/mmc/atmel_sdhci.c new file +40 -0
@@ -0,0 +1,40 @@ +/* +* Copyright (C) 2015 Atmel Corporation +* Wenyou.Yang <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +#include <common.h> +#include <malloc.h> +#include <sdhci.h> +#include <asm/arch/clk.h> + +#define ATMEL_SDHC_MIN_FREQ 400000 + +int atmel_sdhci_init (void *regbase,u32 id) +{ +struct sdhci_host *host =NULL ; +u32 max_clk, min_clk =ATMEL_SDHC_MIN_FREQ ; + + host = (struct sdhci_host *)malloc (sizeof (struct sdhci_host )); +if (!host) { +printf ("%s: sdhci_host malloc failed\n" , __func__); +return -ENOMEM ; + } + + host->name ="atmel_sdhci" ; + host->ioaddr = (void *)regbase; + host->quirks =0 ; + host->version =sdhci_readw (host,SDHCI_HOST_VERSION ); + max_clk =at91_get_periph_generated_clk (id); +if (!max_clk) { +printf ("%s: Failed to get the proper clock\n" , __func__); +free (host); +return -ENODEV ; + } + +add_sdhci (host, max_clk, min_clk); + +return 0 ; +}
Signature · 1 line
1.7.9.5
PATCH v3 1/1 mmc: atmel: Add atmel sdhci support
Hi Wenyou,
Quoted 69 lines · Wenyou Yang
The SDHCI is introduced by sama5d2, named as Secure Digital Multimedia Card Controller(SDMMC). It supports the embedded MultiMedia Card (e.MMC) Specification V4.41, the SD Memory Card Specification V3.0, and the SDIO V3.0 specification. It is compliant with the SD Host Controller Standard V3.0 specification.
Signed-off-by Wenyou Yang <[email protected]>---
Changes in v3:
1./ return-ENODEVinstead of -1, when failing to get proper clock. 2./ add free host instance when failing to get proper clock.Changes in v2:
- According to Bo Shen's comments,
1./ change the macroATMEL_SDHC_MIN_FRQ->ATMEL_SDHC_MIN_FREQ. 2./ change the return value to-ENOMEMand print log for malloc failure. 3./ add the failed return and log for getting improper clock. 4./ add more commit log.arch/arm/mach-at91/include/mach/atmel_sdhci.h | 13 ++++++++ drivers/mmc/Makefile | 1 + drivers/mmc/atmel_sdhci.c | 40 +++++++++++++++++++++++++ 3 files changed, 54 insertions(+)create mode 100644
arch/arm/mach-at91/include/mach/atmel_sdhci.hcreate mode 100644drivers/mmc/atmel_sdhci.carch/arm/mach-at91/include/mach/atmel_sdhci.h new file +13
-0@@ -0,0 +1,13 @@ +/* +* Copyright (c) 2015 Atmel Corporation +* Wenyou.Yang <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +#ifndef __ATMEL_SDHCI_H +#define __ATMEL_SDHCI_H + +int atmel_sdhci_init (void *regbase,u32 id); + +#endif drivers/mmc/Makefile +1
-0@@ -8,6 +8,7 @@ obj-$(CONFIG_DM_MMC) += mmc-uclass.o obj-$(CONFIG_ARM_PL180_MMCI) += arm_pl180_mmci.o +obj-$(CONFIG_ATMEL_SDHCI) += atmel_sdhci.o obj-$(CONFIG_BCM2835_SDHCI) += bcm2835_sdhci.o obj-$(CONFIG_BFIN_SDH) += bfin_sdh.o obj-$(CONFIG_DAVINCI_MMC) += davinci_mmc.odrivers/mmc/atmel_sdhci.c new file +5
-0@@ -0,0 +1,40 @@ +/* +* Copyright (C) 2015 Atmel Corporation +* Wenyou.Yang <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0+
drivers/mmc/atmel_sdhci.c line 15
Quoted 10 lines
drivers/mmc/atmel_sdhci.c new file +10
-0+*/ + +#include <common.h> +#include <malloc.h> +#include <sdhci.h> +#include <asm/arch/clk.h> + +#define ATMEL_SDHC_MIN_FREQ 400000 + +int atmel_sdhci_init (void *regbase,u32 id)
I think the regbase type should be u32, if you keep it as "void *", then the following don't need to be covert to "void *".
drivers/mmc/atmel_sdhci.c line 17
Quoted 2 lines
drivers/mmc/atmel_sdhci.c new file +2
-0+{ +struct sdhci_host *host =NULL ;
I think it is no need to pass NULL to host.
drivers/mmc/atmel_sdhci.c line 20
Quoted 3 lines
drivers/mmc/atmel_sdhci.c new file +3
-0+u32 max_clk, min_clk =ATMEL_SDHC_MIN_FREQ ; + + host = (struct sdhci_host *)malloc (sizeof (struct sdhci_host ));
Maybe calloc will be better.
drivers/mmc/atmel_sdhci.c line 27
Quoted 7 lines
drivers/mmc/atmel_sdhci.c new file +7
-0+if (!host) { +printf ("%s: sdhci_host malloc failed\n" , __func__); +return -ENOMEM ; + } + + host->name ="atmel_sdhci" ; + host->ioaddr = (void *)regbase;
Here no need to do covert if the original type is the same.
Quoted 4 lines
drivers/mmc/atmel_sdhci.c new file +3
-0+ host->quirks =0 ; + host->version =sdhci_readw (host,SDHCI_HOST_VERSION ); + max_clk =at91_get_periph_generated_clk (id);
drivers/mmc/atmel_sdhci.c line 40
Quoted 10 lines
drivers/mmc/atmel_sdhci.c new file +10
-0+if (!max_clk) { +printf ("%s: Failed to get the proper clock\n" , __func__); +free (host); +return -ENODEV ; + } + +add_sdhci (host, max_clk, min_clk); + +return 0 ; +}
Best Regards,
Bo Shen
Yang
PATCH v3 1/1 mmc: atmel: Add atmel sdhci support
Hi Bo Shen,
Thank you for your review.
Quoted 88 lines
-----Original Message-----
From: Bo Shen [mailto:voice.shen at gmail.com]
Sent: 2015?10?28? 11:03
To: Yang, Wenyou
Cc: U-Boot Mailing List; andreas.devel at googlemail.com; Pantelis Antoniou
Subject: Re: [PATCH v3] mmc: atmel: Add atmel sdhci supportHi Wenyou,
Quoted 11 lines · Wenyou Yang
The SDHCI is introduced by sama5d2, named as Secure Digital Multimedia Card Controller(SDMMC). It supports the embedded MultiMedia Card (e.MMC) Specification V4.41, the SD Memory Card Specification V3.0, and the SDIO
V3.0 specification. It is compliant with the SD Host Controller Standard
V3.0 specification.Signed-off-by Wenyou Yang <[email protected]>---
Quoted 7 lines
Changes in v3:
1./ return-ENODEVinstead of -1, when failing to get proper clock. 2./ add free host instance when failing to get proper clock.Changes in v2:
- According to Bo Shen's comments,
1./ change the macroATMEL_SDHC_MIN_FRQ->
ATMEL_SDHC_MIN_FREQ.Quoted 7 lines
2./ change the return value to
-ENOMEMand print log for malloc failure. 3./ add the failed return and log for getting improper clock. 4./ add more commit log.arch/arm/mach-at91/include/mach/atmel_sdhci.h | 13 ++++++++ drivers/mmc/Makefile | 1 + drivers/mmc/atmel_sdhci.c | 40+++++++++++++++++++++++++
Quoted 51 lines
3 files changed, 54 insertions(+)create mode 100644
arch/arm/mach-at91/include/mach/atmel_sdhci.hcreate mode 100644drivers/mmc/atmel_sdhci.carch/arm/mach-at91/include/mach/atmel_sdhci.h new file +13
-0@@ -0,0 +1,13 @@ +/* +* Copyright (c) 2015 Atmel Corporation +* Wenyou.Yang <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +#ifndef __ATMEL_SDHCI_H +#define __ATMEL_SDHCI_H + +int atmel_sdhci_init (void *regbase,u32 id); + +#endif drivers/mmc/Makefile index renamed from drivers/mmc/Makefile +0
-099d0295..5d35705 100644
drivers/mmc/Makefile +1
-0@@ -8,6 +8,7 @@ obj-$(CONFIG_DM_MMC) += mmc-uclass.o obj-$(CONFIG_ARM_PL180_MMCI) += arm_pl180_mmci.o +obj-$(CONFIG_ATMEL_SDHCI) += atmel_sdhci.o obj-$(CONFIG_BCM2835_SDHCI) += bcm2835_sdhci.o obj-$(CONFIG_BFIN_SDH) += bfin_sdh.o obj-$(CONFIG_DAVINCI_MMC) += davinci_mmc.o diff --git
a/drivers/mmc/atmel_sdhci.cb/drivers/mmc/atmel_sdhci.cnew file mode 100644 index 0000000..185a36edrivers/mmc/atmel_sdhci.c new file +10
-0@@ -0,0 +1,40 @@ +/* +* Copyright (C) 2015 Atmel Corporation +* Wenyou.Yang <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +#include <common.h> +#include <malloc.h> +#include <sdhci.h>
Quoted 8 lines
drivers/mmc/atmel_sdhci.c line 15
Quoted 5 lines
drivers/mmc/atmel_sdhci.c new file +5
-0+#include <asm/arch/clk.h> + +#define ATMEL_SDHC_MIN_FREQ 400000 + +int atmel_sdhci_init (void *regbase,u32 id)I think the regbase type should be u32, if you keep it as "void *", then the following don't need to be covert to "void *".
You are right. The following convert should be removed.
Quoted 5 lines
drivers/mmc/atmel_sdhci.c line 17
Quoted 3 lines
drivers/mmc/atmel_sdhci.c new file +2
-0+{ +struct sdhci_host *host =NULL ;I think it is no need to pass NULL to host.
Yes, NULL is not needed.
Quoted 6 lines
drivers/mmc/atmel_sdhci.c line 20
Quoted 4 lines
drivers/mmc/atmel_sdhci.c new file +3
-0+u32 max_clk, min_clk =ATMEL_SDHC_MIN_FREQ ; + + host = (struct sdhci_host *)malloc (sizeof (struct sdhci_host ));Maybe calloc will be better.
calloc() is better, zero-initialized the buffer
Quoted 10 lines
drivers/mmc/atmel_sdhci.c line 27
Quoted 8 lines
drivers/mmc/atmel_sdhci.c new file +7
-0+if (!host) { +printf ("%s: sdhci_host malloc failed\n" , __func__); +return -ENOMEM ; + } + + host->name ="atmel_sdhci" ; + host->ioaddr = (void *)regbase;Here no need to do covert if the original type is the same.
Yes, removed.
Quoted 10 lines
Quoted 10 lines
drivers/mmc/atmel_sdhci.c new file +9
-0+ host->quirks =0 ; + host->version =sdhci_readw (host,SDHCI_HOST_VERSION ); + max_clk =at91_get_periph_generated_clk (id); +if (!max_clk) { +printf ("%s: Failed to get the proper clock\n" , __func__); +free (host); +return -ENODEV ; + } +
Quoted 8 lines
drivers/mmc/atmel_sdhci.c line 40
Quoted 5 lines
drivers/mmc/atmel_sdhci.c new file +4
-0+add_sdhci (host, max_clk, min_clk); + +return 0 ; +}Best Regards,
Bo Shen
Best Regards,
Wenyou Yang