Skip to contentSkip to conversation

Add SDHCI driver for Tegra

PATCH In review Olof Johansson 3 participants 6 messages Jan 2, 2011 – Jan 3, 2011

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

v4 cover Add SDHCI driver for Tegra

Here we go again. Just a couple of minor changes to the 8-bit code, i.e. allow boards to pass in which slots are actually wired 8-bit.

Changes since v1:
* Rewrote for sdhci-pltfm

Changes since v2:
* Whitespace fixes
* Changed order of test in get_ro
* 8-bit support
* Set gpio directions

Changes since v3:
* Add platform structure member for 8bit capabilities

#1 lore raw

PATCH v4 1/2 sdhci: add quirk for max len ADMA descriptors

Some controllers misparse segment length 0 as being 0, not 65536. Add a quirk to deal with it.

Change-Id I1422c9c605095addc133e844c66fc49f187dc17d
---
 drivers/mmc/host/sdhci.c  |   10 +++++++---
 include/linux/mmc/sdhci.h |    2 ++
 2 files changed, 9 insertions(+), 3 deletions(-)
drivers/mmc/host/sdhci.c +7 -3
index a25db426..c0094c1 100644
@@ -1928,10 +1928,14 @@ int sdhci_add_host(struct sdhci_host *host)
 	 * of bytes. When doing hardware scatter/gather, each entry cannot
 	 * be larger than 64 KiB though.
 	 */
-	if (host->flags & SDHCI_USE_ADMA)
-		mmc->max_seg_size = 65536;
-	else
+	if (host->flags & SDHCI_USE_ADMA) {
+		if (host->quirks & SDHCI_QUIRK_BROKEN_ADMA_ZEROLEN_DESC)
+			mmc->max_seg_size = 65535;
+		else
+			mmc->max_seg_size = 65536;
+	} else {
 		mmc->max_seg_size = mmc->max_req_size;
+	}
 
 	/*
 	 * Maximum block size. This varies from controller to controller and
include/linux/mmc/sdhci.h +2 -0
index 1fdc673..dfb2106 100644
@@ -83,6 +83,8 @@ struct sdhci_host {
 #define SDHCI_QUIRK_MULTIBLOCK_READ_ACMD12		(1<<28)
 /* Controller doesn't have HISPD bit field in HI-SPEED SD card */
 #define SDHCI_QUIRK_NO_HISPD_BIT			(1<<29)
+/* Controller treats ADMA descriptors with length 0000h incorrectly */
+#define SDHCI_QUIRK_BROKEN_ADMA_ZEROLEN_DESC		(1<<30)
 
 	int irq;		/* Device IRQ */
 	void __iomem *ioaddr;	/* Mapped address */
Signature · 1 line
1.7.3.GIT
#2 lore raw

PATCH v4 2/2 mmc: add sdhci-tegra driver for Tegra SoCs

SDHCI driver for Tegra. This driver plugs in as a new variant of sdhci-pltfm, using the platform data structure passed in to specify the GPIOs to use for card detect, write protect and card power enablement.

Original driver (of which only the header file is left):

The rest, which has been rewritten by now:

---

SDHCI driver for Tegra. Pretty straight forward, a few pieces of functionality left to fill in but nothing that stops it from going upstream. Board enablement submitted separately.

Changes since v1:
* Rewrote for sdhci-pltfm

Changes since v2:
* Whitespace fixes
* Changed order of test in get_ro
* 8-bit support
* Set gpio directions

Changes since v3:
* Add platform structure member for 8bit capabilities

Change-Id: I18b322b57a7285d80c530bafaba04a6d84f668d5

---
 arch/arm/mach-tegra/include/mach/sdhci.h |   29 ++++
 drivers/mmc/host/Kconfig                 |   10 ++
 drivers/mmc/host/Makefile                |    1 +
 drivers/mmc/host/sdhci-pltfm.c           |    3 +
 drivers/mmc/host/sdhci-pltfm.h           |    1 +
 drivers/mmc/host/sdhci-tegra.c           |  257 ++++++++++++++++++++++++++++++
 6 files changed, 301 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-tegra/include/mach/sdhci.h
 create mode 100644 drivers/mmc/host/sdhci-tegra.c
arch/arm/mach-tegra/include/mach/sdhci.h new file +29 -0
new file mode 100644
index 0000000..3ad086e
@@ -0,0 +1,29 @@
+/*
+ * include/asm-arm/arch-tegra/include/mach/sdhci.h
+ *
+ * Copyright (C) 2009 Palm, Inc.
+ * Author: Yvonne Yip <[email protected]>
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * 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.
+ *
+ */
+#ifndef __ASM_ARM_ARCH_TEGRA_SDHCI_H
+#define __ASM_ARM_ARCH_TEGRA_SDHCI_H
+
+#include <linux/mmc/host.h>
+
+struct tegra_sdhci_platform_data {
+	int cd_gpio;
+	int wp_gpio;
+	int power_gpio;
+	int is_8bit;
+};
+
+#endif
drivers/mmc/host/Kconfig +10 -0
index d618e86..25c6a2a 100644
@@ -140,6 +140,16 @@ config MMC_SDHCI_ESDHC_IMX
 
 	  If unsure, say N.
 
+config MMC_SDHCI_TEGRA
+	tristate "SDHCI platform support for the Tegra SD/MMC Controller"
+	depends on MMC_SDHCI_PLTFM && ARCH_TEGRA
+	select MMC_SDHCI_IO_ACCESSORS
+	help
+	  This selects the Tegra SD/MMC controller. If you have a Tegra
+	  platform with SD or MMC devices, say Y or M here.
+
+	  If unsure, say N.
+
 config MMC_SDHCI_S3C
 	tristate "SDHCI support on Samsung S3C SoC"
 	depends on MMC_SDHCI && PLAT_SAMSUNG
drivers/mmc/host/Makefile +1 -0
index 7b645ff..fc8f8f0 100644
@@ -39,6 +39,7 @@ obj-$(CONFIG_MMC_SDHCI_PLTFM)			+= sdhci-platform.o
 sdhci-platform-y				:= sdhci-pltfm.o
 sdhci-platform-$(CONFIG_MMC_SDHCI_CNS3XXX)	+= sdhci-cns3xxx.o
 sdhci-platform-$(CONFIG_MMC_SDHCI_ESDHC_IMX)	+= sdhci-esdhc-imx.o
+sdhci-platform-$(CONFIG_MMC_SDHCI_TEGRA)	+= sdhci-tegra.o
 
 obj-$(CONFIG_MMC_SDHCI_OF)	+= sdhci-of.o
 sdhci-of-y				:= sdhci-of-core.o
drivers/mmc/host/sdhci-pltfm.c +3 -0
index 0502f89..d9e6e88 100644
@@ -170,6 +170,9 @@ static const struct platform_device_id sdhci_pltfm_ids[] = {
 #ifdef CONFIG_MMC_SDHCI_ESDHC_IMX
 	{ "sdhci-esdhc-imx", (kernel_ulong_t)&sdhci_esdhc_imx_pdata },
 #endif
+#ifdef CONFIG_MMC_SDHCI_TEGRA
+	{ "sdhci-tegra", (kernel_ulong_t)&sdhci_tegra_pdata },
+#endif
 	{ },
 };
 MODULE_DEVICE_TABLE(platform, sdhci_pltfm_ids);
drivers/mmc/host/sdhci-pltfm.h +1 -0
index c1bfe48..6f631e3 100644
@@ -22,5 +22,6 @@ struct sdhci_pltfm_host {
 
 extern struct sdhci_pltfm_data sdhci_cns3xxx_pdata;
 extern struct sdhci_pltfm_data sdhci_esdhc_imx_pdata;
+extern struct sdhci_pltfm_data sdhci_tegra_pdata;
 
 #endif /* _DRIVERS_MMC_SDHCI_PLTFM_H */
drivers/mmc/host/sdhci-tegra.c new file +257 -0

257 lines not on this page · raw message

Signature · 1 line
1.7.3.GIT
#3 lore raw

Re: [PATCH 2/2 v4] mmc: add sdhci-tegra driver for Tegra SoCs

Hi Olof,

Quoted 3 lines · Olof Johansson

SDHCI driver for Tegra. This driver plugs in as a new variant of sdhci-pltfm, using the platform data structure passed in to specify the GPIOs to use for card detect, write protect and card power enablement.

I've pushed this patchset to mmc-next for .38 now. Thanks! I removed the Change-Id: tags from both commit messages, matching Linus' policy:
http://thread.gmane.org/gmane.linux.kernel/1075380.

Also:

drivers/mmc/host/sdhci-tegra.c line 6

Quoted 9 lines
drivers/mmc/host/sdhci-tegra.c new file +6 -0
@@ -0,0 +1,257 @@
+/*
+ * Copyright (C) 2010 The Chromium OS Authors <[email protected]>
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.

As discussed on IRC, this is the first time this attribution line's been used in mainline, so I'd like to hear more about whether The Chromium OS Authors is actually a copyright-holding entity.

Thanks,

Signature · 2 lines
Chris Ball   <[email protected]>   <http://printf.net/>
One Laptop Per Child
#4 lore raw

Re: [PATCH 2/2 v4] mmc: add sdhci-tegra driver for Tegra SoCs

Quoted 10 lines · Chris Ball

Hi Olof,

Quoted 3 lines · Olof Johansson

SDHCI driver for Tegra. This driver plugs in as a new variant of sdhci-pltfm, using the platform data structure passed in to specify the GPIOs to use for card detect, write protect and card power enablement.

I've pushed this patchset to mmc-next for .38 now.  Thanks!  I removed the Change-Id: tags from both commit messages, matching Linus' policy:
http://thread.gmane.org/gmane.linux.kernel/1075380.

Crap, stupid repo -- I forgot to remove them by hand. Sorry about that.

Quoted 15 lines

Also:

drivers/mmc/host/sdhci-tegra.c line 6

Quoted 9 lines
drivers/mmc/host/sdhci-tegra.c new file +6 -0
@@ -0,0 +1,257 @@
+/*
+ * Copyright (C) 2010 The Chromium OS Authors <[email protected]>
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.

As discussed on IRC, this is the first time this attribution line's been used in mainline, so I'd like to hear more about whether The Chromium OS Authors is actually a copyright-holding entity.

Yep, I'll follow up on this.

-Olof

Acked-by on v4 1/2
#5 lore raw

Re: [PATCH 1/2 v4] sdhci: add quirk for max len ADMA descriptors

In reply to Olof Johansson

It's also valid as SDHCI at Samsung SoCs.

Quoted 53 lines · Olof Johansson

Some controllers misparse segment length 0 as being 0, not 65536. Add a quirk to deal with it.

Change-Id I1422c9c605095addc133e844c66fc49f187dc17d

---
 drivers/mmc/host/sdhci.c  |   10 +++++++---
 include/linux/mmc/sdhci.h |    2 ++

 2 files changed, 9 insertions(+), 3 deletions(-)
drivers/mmc/host/sdhci.c +7 -3
index a25db426..c0094c1 100644
@@ -1928,10 +1928,14 @@ int sdhci_add_host(struct sdhci_host *host)
         * of bytes. When doing hardware scatter/gather, each entry cannot
         * be larger than 64 KiB though.
         */
-       if (host->flags & SDHCI_USE_ADMA)
-               mmc->max_seg_size = 65536;
-       else
+       if (host->flags & SDHCI_USE_ADMA) {
+               if (host->quirks & SDHCI_QUIRK_BROKEN_ADMA_ZEROLEN_DESC)
+                       mmc->max_seg_size = 65535;
+               else
+                       mmc->max_seg_size = 65536;
+       } else {
                mmc->max_seg_size = mmc->max_req_size;
+       }
 
        /*
         * Maximum block size. This varies from controller to controller and
include/linux/mmc/sdhci.h +2 -0
index 1fdc673..dfb2106 100644
@@ -83,6 +83,8 @@ struct sdhci_host {
  #define SDHCI_QUIRK_MULTIBLOCK_READ_ACMD12             (1<<28)
  /* Controller doesn't have HISPD bit field in HI-SPEED SD card */
  #define SDHCI_QUIRK_NO_HISPD_BIT                       (1<<29)
+/* Controller treats ADMA descriptors with length 0000h incorrectly */
+#define SDHCI_QUIRK_BROKEN_ADMA_ZEROLEN_DESC           (1<<30)
 

       int irq;                /* Device IRQ */ void __iomem *ioaddr;   /* Mapped address */ --
1.7.3.GIT

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html