Re: [U-Boot] [PATCH 1/2] MMC: add sdhci generic framework
-Original Message- From: u-boot-boun...@lists.denx.de [mailto:u-boot-boun...@lists.denx.de] On Behalf Of Lei Wen Sent: Sunday, July 17, 2011 12:54 PM To: Gérald Kerma Cc: Lei Wen; Yu Tang; Rob Herring; u-boot@lists.denx.de; Andy Fleming; Ashish Karkare; Prabhanjan Sarnaik Subject: Re: [U-Boot] [PATCH 1/2] MMC: add sdhci generic framework Hi Gérald, On Sun, Jul 17, 2011 at 3:20 PM, Gérald Kerma gera...@gmail.com wrote: Hello Lei, Le 29/06/2011 07:58, Lei Wen a écrit : Hi Gérald, On Wed, Jun 29, 2011 at 1:53 PM, Gérald Kerma gera...@gmail.com wrote: Hello, Is this driver adaptable for sheevaplug ? In the Linux kernel, the sdhci-dove.c does the similar way to support the kirkwood. The linux kernel use mvsdio driver for kirkwood. MMC_MVSDIO Marvell MMC/SD/SDIO host driver This selects the Marvell SDIO host driver. SDIO may currently be found on the Kirkwood 88F6281 and 88F6192 SoC controllers. MMC_SDHCI_DOVE SDHCI support on Marvell's Dove SoC This selects the Secure Digital Host Controller Interface in Marvell's Dove SoC. a driver patch which use the old generic driver was adapted from Marvell UBoot (mvsdio). It's not included in the Denx uboot mainline but is available in the Debian Uboot. I just don't object kirkwood to resue the old way. But since sdhci could be a generic framework, it is nice that denx mainline could also use sdhci for kirkwood which is actively maintained like in the linux kernel. I don't see an issue here, if sdhci is more generic, it will support few more SoCs then it should go for mainlining. Regards.. Prafulla . . . Best regards, Lei ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 1/2] MMC: add sdhci generic framework
Hello Lei, Le 29/06/2011 07:58, Lei Wen a écrit : Hi Gérald, On Wed, Jun 29, 2011 at 1:53 PM, Gérald Kerma gera...@gmail.com wrote: Hello, Is this driver adaptable for sheevaplug ? In the Linux kernel, the sdhci-dove.c does the similar way to support the kirkwood. The linux kernel use mvsdio driver for kirkwood. MMC_MVSDIO Marvell MMC/SD/SDIO host driver This selects the Marvell SDIO host driver. SDIO may currently be found on the Kirkwood 88F6281 and 88F6192 SoC controllers. MMC_SDHCI_DOVE SDHCI support on Marvell's Dove SoC This selects the Secure Digital Host Controller Interface in Marvell's Dove SoC. a driver patch which use the old generic driver was adapted from Marvell UBoot (mvsdio). It's not included in the Denx uboot mainline but is available in the Debian Uboot. -- A+ - Amicalement - Gk2 [:-] --- Un arc-en-ciel ça n'existe pas ! Et pourtant tout le monde en a déjà vu... (Albert Jacquart) ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 1/2] MMC: add sdhci generic framework
Hi Gérald, On Sun, Jul 17, 2011 at 3:20 PM, Gérald Kerma gera...@gmail.com wrote: Hello Lei, Le 29/06/2011 07:58, Lei Wen a écrit : Hi Gérald, On Wed, Jun 29, 2011 at 1:53 PM, Gérald Kerma gera...@gmail.com wrote: Hello, Is this driver adaptable for sheevaplug ? In the Linux kernel, the sdhci-dove.c does the similar way to support the kirkwood. The linux kernel use mvsdio driver for kirkwood. MMC_MVSDIO Marvell MMC/SD/SDIO host driver This selects the Marvell SDIO host driver. SDIO may currently be found on the Kirkwood 88F6281 and 88F6192 SoC controllers. MMC_SDHCI_DOVE SDHCI support on Marvell's Dove SoC This selects the Secure Digital Host Controller Interface in Marvell's Dove SoC. a driver patch which use the old generic driver was adapted from Marvell UBoot (mvsdio). It's not included in the Denx uboot mainline but is available in the Debian Uboot. I just don't object kirkwood to resue the old way. But since sdhci could be a generic framework, it is nice that denx mainline could also use sdhci for kirkwood which is actively maintained like in the linux kernel. Best regards, Lei ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 1/2] MMC: add sdhci generic framework
-Original Message- From: Lei Wen [mailto:adrian.w...@gmail.com] Sent: Wednesday, June 29, 2011 9:17 AM To: Lei Wen Cc: Andy Fleming; Rob Herring; u-boot@lists.denx.de; Prafulla Wadaskar; Yu Tang; Prabhanjan Sarnaik; Ashish Karkare Subject: Re: [U-Boot] [PATCH 1/2] MMC: add sdhci generic framework Hi All, Any comment to this patch set, could it be merged in this open window? Hi Lei, I ack for the driver. Can you re-submit v2 patches as per review comments for v1? Copying Andy Fleming on his alternate email id. Regards.. Prafulla . . ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 1/2] MMC: add sdhci generic framework
Hi Prafulla, On Wed, Jun 29, 2011 at 2:56 PM, Prafulla Wadaskar prafu...@marvell.com wrote: -Original Message- From: Lei Wen [mailto:adrian.w...@gmail.com] Sent: Wednesday, June 29, 2011 9:17 AM To: Lei Wen Cc: Andy Fleming; Rob Herring; u-boot@lists.denx.de; Prafulla Wadaskar; Yu Tang; Prabhanjan Sarnaik; Ashish Karkare Subject: Re: [U-Boot] [PATCH 1/2] MMC: add sdhci generic framework Hi All, Any comment to this patch set, could it be merged in this open window? Hi Lei, I ack for the driver. Can you re-submit v2 patches as per review comments for v1? Ok, I would push the v2 patch later. Thanks, Lei ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 1/2] MMC: add sdhci generic framework
Hi All, Any comment to this patch set, could it be merged in this open window? Thanks, Lei On Thu, Jun 16, 2011 at 11:17 PM, Lei Wen lei...@marvell.com wrote: Nowdays, there are plenty of mmc driver in uboot adopt the sd standard host design, aka as sdhci. It is better to centralize the common logic together to better maintenance. Signed-off-by: Lei Wen lei...@marvell.com --- drivers/mmc/Makefile | 1 + drivers/mmc/sdhci.c | 433 ++ include/sdhci.h | 325 + 3 files changed, 759 insertions(+), 0 deletions(-) create mode 100644 drivers/mmc/sdhci.c create mode 100644 include/sdhci.h diff --git a/drivers/mmc/Makefile b/drivers/mmc/Makefile index a8fe17a..50b5117 100644 --- a/drivers/mmc/Makefile +++ b/drivers/mmc/Makefile @@ -38,6 +38,7 @@ COBJS-$(CONFIG_OMAP3_MMC) += omap3_mmc.o COBJS-$(CONFIG_OMAP_HSMMC) += omap_hsmmc.o COBJS-$(CONFIG_PXA_MMC) += pxa_mmc.o COBJS-$(CONFIG_S5P_MMC) += s5p_mmc.o +COBJS-$(CONFIG_SDHCI) += sdhci.o COBJS := $(COBJS-y) SRCS := $(COBJS:.o=.c) diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c new file mode 100644 index 000..9ebd33d --- /dev/null +++ b/drivers/mmc/sdhci.c @@ -0,0 +1,433 @@ +/* + * Copyright 2011, Marvell Semiconductor Inc. + * Lei Wen lei...@marvell.com + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * Back ported to the 8xx platform (from the 8260 platform) by + * murray.jen...@cmst.csiro.au, 27-Jan-01. + */ + +#include common.h +#include malloc.h +#include mmc.h +#include sdhci.h + +void *aligned_buffer; + +static void sdhci_reset(struct sdhci_host *host, u8 mask) +{ + unsigned long timeout; + + /* Wait max 100 ms */ + timeout = 100; + sdhci_writeb(host, mask, SDHCI_SOFTWARE_RESET); + while (sdhci_readb(host, SDHCI_SOFTWARE_RESET) mask) { + if (timeout == 0) { + printf(Reset 0x%x never completed.\n, (int)mask); + return; + } + timeout--; + udelay(1000); + } +} + +static void sdhci_cmd_done(struct sdhci_host *host, struct mmc_cmd *cmd) +{ + int i; + if (cmd-resp_type MMC_RSP_136) { + /* CRC is stripped so we need to do some shifting. */ + for (i = 0; i 4; i++) { + cmd-response[i] = sdhci_readl(host, + SDHCI_RESPONSE + (3-i)*4) 8; + if (i != 3) + cmd-response[i] |= sdhci_readb(host, + SDHCI_RESPONSE + (3-i)*4-1); + } + } else { + cmd-response[0] = sdhci_readl(host, SDHCI_RESPONSE); + } +} + +static void sdhci_transfer_pio(struct sdhci_host *host, struct mmc_data *data) +{ + int i; + char *offs; + for (i = 0; i data-blocksize; i += 4) { + offs = data-dest + i; + if (data-flags == MMC_DATA_READ) + *(u32 *)offs = sdhci_readl(host, SDHCI_BUFFER); + else + sdhci_writel(host, *(u32 *)offs, SDHCI_BUFFER); + } +} + +static int sdhci_transfer_data(struct sdhci_host *host, struct mmc_data *data, + unsigned int start_addr) +{ + unsigned int stat, rdy, mask, block = 0; + + rdy = SDHCI_INT_SPACE_AVAIL | SDHCI_INT_DATA_AVAIL; + mask = SDHCI_DATA_AVAILABLE | SDHCI_SPACE_AVAILABLE; + do { + stat = sdhci_readl(host, SDHCI_INT_STATUS); + if (stat SDHCI_INT_ERROR) { + printf(Error detected in status(0x%X)!\n, stat); + return -1; + } + if (stat rdy) { + if (!(sdhci_readl(host, SDHCI_PRESENT_STATE) mask)) + continue; + sdhci_writel(host, rdy, SDHCI_INT_STATUS); + sdhci_transfer_pio(host, data); + data-dest += data-blocksize; +
Re: [U-Boot] [PATCH 1/2] MMC: add sdhci generic framework
Hello, Is this driver adaptable for sheevaplug ? Le 29/06/2011 05:46, Lei Wen a écrit : Hi All, Any comment to this patch set, could it be merged in this open window? Thanks, Lei On Thu, Jun 16, 2011 at 11:17 PM, Lei Wen lei...@marvell.com wrote: Nowdays, there are plenty of mmc driver in uboot adopt the sd standard host design, aka as sdhci. It is better to centralize the common logic together to better maintenance. Signed-off-by: Lei Wen lei...@marvell.com --- drivers/mmc/Makefile |1 + drivers/mmc/sdhci.c | 433 ++ include/sdhci.h | 325 + 3 files changed, 759 insertions(+), 0 deletions(-) create mode 100644 drivers/mmc/sdhci.c create mode 100644 include/sdhci.h diff --git a/drivers/mmc/Makefile b/drivers/mmc/Makefile index a8fe17a..50b5117 100644 --- a/drivers/mmc/Makefile +++ b/drivers/mmc/Makefile @@ -38,6 +38,7 @@ COBJS-$(CONFIG_OMAP3_MMC) += omap3_mmc.o COBJS-$(CONFIG_OMAP_HSMMC) += omap_hsmmc.o COBJS-$(CONFIG_PXA_MMC) += pxa_mmc.o COBJS-$(CONFIG_S5P_MMC) += s5p_mmc.o +COBJS-$(CONFIG_SDHCI) += sdhci.o COBJS := $(COBJS-y) SRCS := $(COBJS:.o=.c) diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c new file mode 100644 index 000..9ebd33d --- /dev/null +++ b/drivers/mmc/sdhci.c @@ -0,0 +1,433 @@ +/* + * Copyright 2011, Marvell Semiconductor Inc. + * Lei Wen lei...@marvell.com + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * Back ported to the 8xx platform (from the 8260 platform) by + * murray.jen...@cmst.csiro.au, 27-Jan-01. + */ + +#include common.h +#include malloc.h +#include mmc.h +#include sdhci.h + +void *aligned_buffer; + +static void sdhci_reset(struct sdhci_host *host, u8 mask) +{ + unsigned long timeout; + + /* Wait max 100 ms */ + timeout = 100; + sdhci_writeb(host, mask, SDHCI_SOFTWARE_RESET); + while (sdhci_readb(host, SDHCI_SOFTWARE_RESET) mask) { + if (timeout == 0) { + printf(Reset 0x%x never completed.\n, (int)mask); + return; + } + timeout--; + udelay(1000); + } +} + +static void sdhci_cmd_done(struct sdhci_host *host, struct mmc_cmd *cmd) +{ + int i; + if (cmd-resp_type MMC_RSP_136) { + /* CRC is stripped so we need to do some shifting. */ + for (i = 0; i 4; i++) { + cmd-response[i] = sdhci_readl(host, + SDHCI_RESPONSE + (3-i)*4) 8; + if (i != 3) + cmd-response[i] |= sdhci_readb(host, + SDHCI_RESPONSE + (3-i)*4-1); + } + } else { + cmd-response[0] = sdhci_readl(host, SDHCI_RESPONSE); + } +} + +static void sdhci_transfer_pio(struct sdhci_host *host, struct mmc_data *data) +{ + int i; + char *offs; + for (i = 0; i data-blocksize; i += 4) { + offs = data-dest + i; + if (data-flags == MMC_DATA_READ) + *(u32 *)offs = sdhci_readl(host, SDHCI_BUFFER); + else + sdhci_writel(host, *(u32 *)offs, SDHCI_BUFFER); + } +} + +static int sdhci_transfer_data(struct sdhci_host *host, struct mmc_data *data, + unsigned int start_addr) +{ + unsigned int stat, rdy, mask, block = 0; + + rdy = SDHCI_INT_SPACE_AVAIL | SDHCI_INT_DATA_AVAIL; + mask = SDHCI_DATA_AVAILABLE | SDHCI_SPACE_AVAILABLE; + do { + stat = sdhci_readl(host, SDHCI_INT_STATUS); + if (stat SDHCI_INT_ERROR) { + printf(Error detected in status(0x%X)!\n, stat); + return -1; + } + if (stat rdy) { + if (!(sdhci_readl(host, SDHCI_PRESENT_STATE) mask)) + continue; + sdhci_writel(host, rdy, SDHCI_INT_STATUS); +
Re: [U-Boot] [PATCH 1/2] MMC: add sdhci generic framework
Hi Gérald, On Wed, Jun 29, 2011 at 1:53 PM, Gérald Kerma gera...@gmail.com wrote: Hello, Is this driver adaptable for sheevaplug ? Sheevaplug use kirkwood series, which is different from the platform current develop on. But since this is a generic framework, any controller follow sdhci host spec certainly could be supported. In the Linux kernel, the sdhci-dove.c does the similar way to support the kirkwood. Best regards, Lei ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 1/2] MMC: add sdhci generic framework
Nowdays, there are plenty of mmc driver in uboot adopt the sd standard host design, aka as sdhci. It is better to centralize the common logic together to better maintenance. Signed-off-by: Lei Wen lei...@marvell.com --- drivers/mmc/Makefile |1 + drivers/mmc/sdhci.c | 433 ++ include/sdhci.h | 325 + 3 files changed, 759 insertions(+), 0 deletions(-) create mode 100644 drivers/mmc/sdhci.c create mode 100644 include/sdhci.h diff --git a/drivers/mmc/Makefile b/drivers/mmc/Makefile index a8fe17a..50b5117 100644 --- a/drivers/mmc/Makefile +++ b/drivers/mmc/Makefile @@ -38,6 +38,7 @@ COBJS-$(CONFIG_OMAP3_MMC) += omap3_mmc.o COBJS-$(CONFIG_OMAP_HSMMC) += omap_hsmmc.o COBJS-$(CONFIG_PXA_MMC) += pxa_mmc.o COBJS-$(CONFIG_S5P_MMC) += s5p_mmc.o +COBJS-$(CONFIG_SDHCI) += sdhci.o COBJS := $(COBJS-y) SRCS := $(COBJS:.o=.c) diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c new file mode 100644 index 000..9ebd33d --- /dev/null +++ b/drivers/mmc/sdhci.c @@ -0,0 +1,433 @@ +/* + * Copyright 2011, Marvell Semiconductor Inc. + * Lei Wen lei...@marvell.com + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * Back ported to the 8xx platform (from the 8260 platform) by + * murray.jen...@cmst.csiro.au, 27-Jan-01. + */ + +#include common.h +#include malloc.h +#include mmc.h +#include sdhci.h + +void *aligned_buffer; + +static void sdhci_reset(struct sdhci_host *host, u8 mask) +{ + unsigned long timeout; + + /* Wait max 100 ms */ + timeout = 100; + sdhci_writeb(host, mask, SDHCI_SOFTWARE_RESET); + while (sdhci_readb(host, SDHCI_SOFTWARE_RESET) mask) { + if (timeout == 0) { + printf(Reset 0x%x never completed.\n, (int)mask); + return; + } + timeout--; + udelay(1000); + } +} + +static void sdhci_cmd_done(struct sdhci_host *host, struct mmc_cmd *cmd) +{ + int i; + if (cmd-resp_type MMC_RSP_136) { + /* CRC is stripped so we need to do some shifting. */ + for (i = 0; i 4; i++) { + cmd-response[i] = sdhci_readl(host, + SDHCI_RESPONSE + (3-i)*4) 8; + if (i != 3) + cmd-response[i] |= sdhci_readb(host, + SDHCI_RESPONSE + (3-i)*4-1); + } + } else { + cmd-response[0] = sdhci_readl(host, SDHCI_RESPONSE); + } +} + +static void sdhci_transfer_pio(struct sdhci_host *host, struct mmc_data *data) +{ + int i; + char *offs; + for (i = 0; i data-blocksize; i += 4) { + offs = data-dest + i; + if (data-flags == MMC_DATA_READ) + *(u32 *)offs = sdhci_readl(host, SDHCI_BUFFER); + else + sdhci_writel(host, *(u32 *)offs, SDHCI_BUFFER); + } +} + +static int sdhci_transfer_data(struct sdhci_host *host, struct mmc_data *data, + unsigned int start_addr) +{ + unsigned int stat, rdy, mask, block = 0; + + rdy = SDHCI_INT_SPACE_AVAIL | SDHCI_INT_DATA_AVAIL; + mask = SDHCI_DATA_AVAILABLE | SDHCI_SPACE_AVAILABLE; + do { + stat = sdhci_readl(host, SDHCI_INT_STATUS); + if (stat SDHCI_INT_ERROR) { + printf(Error detected in status(0x%X)!\n, stat); + return -1; + } + if (stat rdy) { + if (!(sdhci_readl(host, SDHCI_PRESENT_STATE) mask)) + continue; + sdhci_writel(host, rdy, SDHCI_INT_STATUS); + sdhci_transfer_pio(host, data); + data-dest += data-blocksize; + if (++block = data-blocks) + break; + } +#ifdef CONFIG_MMC_SDMA + if (stat SDHCI_INT_DMA_END) { + sdhci_writel(host, SDHCI_INT_DMA_END, SDHCI_INT_STATUS); + start_addr =