Skip to contentSkip to conversation

atmel-mci: Unified Atmel MCI drivers (AVR32 & AT91)

PATCH In review Rob Emanuele 7 participants 21 messages Jun 17, 2009 – Sep 2, 2009 2 messages not in the archive

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

PATCH 1/6 atmel-mci: Unified Atmel MCI drivers (AVR32 & AT91)

Unification of the atmel-mci driver to support the AT91 processors MCI interface. The atmel-mci driver currently supports the AVR32 and this patch adds AT91 support.

To use this new driver on a at91 the platform driver for your board needs to updated. See the following patch for an example of how to do that.

---
 drivers/mmc/host/Kconfig     |   16 ++++++++++++----
 drivers/mmc/host/atmel-mci.c |   37 +++++++++++++++++++++++++++++++++----
 2 files changed, 45 insertions(+), 8 deletions(-)
drivers/mmc/host/Kconfig +12 -4
index 40111a6..a0eaf69 100644
@@ -135,6 +135,12 @@ config MMC_AU1X
 
 	  If unsure, say N.
 
+choice
+	prompt "Atmel MMC Driver"
+	default MMC_ATMELMCI if AVR32
+	help
+	  Choose which driver to use for the Atmel MCI Silicon
+
 config MMC_AT91
 	tristate "AT91 SD/MMC Card Interface support"
 	depends on ARCH_AT91
@@ -145,17 +151,19 @@ config MMC_AT91
 
 config MMC_ATMELMCI
 	tristate "Atmel Multimedia Card Interface support"
-	depends on AVR32
+	depends on AVR32 || ARCH_AT91
 	help
 	  This selects the Atmel Multimedia Card Interface driver. If
-	  you have an AT32 (AVR32) platform with a Multimedia Card
-	  slot, say Y or M here.
+	  you have an AT32 (AVR32) or AT91 platform with a Multimedia
+	  Card slot, say Y or M here.
 
 	  If unsure, say N.
 
+endchoice
+
 config MMC_ATMELMCI_DMA
 	bool "Atmel MCI DMA support (EXPERIMENTAL)"
-	depends on MMC_ATMELMCI && DMA_ENGINE && EXPERIMENTAL
+	depends on MMC_ATMELMCI && AVR32 && DMA_ENGINE && EXPERIMENTAL
 	help
 	  Say Y here to have the Atmel MCI driver use a DMA engine to
 	  do data transfers and thus increase the throughput and
drivers/mmc/host/atmel-mci.c +33 -4
index 7b603e4..98b25de 100644
@@ -30,11 +30,14 @@
 #include <asm/io.h>
 #include <asm/unaligned.h>
 
+#include <mach/cpu.h>
 #include <mach/board.h>
 
 #include "atmel-mci-regs.h"
 
-#define ATMCI_DATA_ERROR_FLAGS	(MCI_DCRCE | MCI_DTOE | MCI_OVRE | MCI_UNRE)
+#define ATMCI_DATA_ERROR_FLAGS	(MCI_RINDE | MCI_RDIRE | MCI_RCRCE  \
+				 | MCI_RENDE | MCI_RTOE | MCI_DCRCE \
+				 | MCI_DTOE | MCI_OVRE | MCI_UNRE)
 #define ATMCI_DMA_THRESHOLD	16
 
 enum {
@@ -210,6 +213,18 @@ struct atmel_mci_slot {
 	set_bit(event, &host->pending_events)
 
 /*
+ * Enable or disable features/registers based on
+ * whether the processor supports them
+ */
+static bool mci_has_rwproof(void)
+{
+	if (cpu_is_at91sam9261() || cpu_is_at91rm9200())
+		return false;
+	else
+		return true;
+}
+
+/*
  * The debugfs stuff below is mostly optimized away when
  * CONFIG_DEBUG_FS is not set.
  */
@@ -276,8 +291,13 @@ static void atmci_show_status_reg(struct seq_file *s,
 		[3]	= "BLKE",
 		[4]	= "DTIP",
 		[5]	= "NOTBUSY",
+		[6]	= "ENDRX",
+		[7]	= "ENDTX",
 		[8]	= "SDIOIRQA",
 		[9]	= "SDIOIRQB",
+		[12]	= "SDIOWAIT",
+		[14]	= "RXBUFF",
+		[15]	= "TXBUFE",
 		[16]	= "RINDE",
 		[17]	= "RDIRE",
 		[18]	= "RCRCE",
@@ -285,6 +305,11 @@ static void atmci_show_status_reg(struct seq_file *s,
 		[20]	= "RTOE",
 		[21]	= "DCRCE",
 		[22]	= "DTOE",
+		[23]    = "CSTOE",
+		[24]    = "BLKOVRE",
+		[25]    = "DMADONE",
+		[26]    = "FIFOEMPTY",
+		[27]    = "XFRDONE",
 		[30]	= "OVRE",
 		[31]	= "UNRE",
 	};
@@ -849,13 +874,15 @@ static void atmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
 			clkdiv = 255;
 		}
 
+		host->mode_reg = MCI_MR_CLKDIV(clkdiv);
+
 		/*
 		 * WRPROOF and RDPROOF prevent overruns/underruns by
 		 * stopping the clock when the FIFO is full/empty.
 		 * This state is not expected to last for long.
 		 */
-		host->mode_reg = MCI_MR_CLKDIV(clkdiv) | MCI_MR_WRPROOF
-					| MCI_MR_RDPROOF;
+		if (mci_has_rwproof())
+			host->mode_reg |= (MCI_MR_WRPROOF | MCI_MR_RDPROOF);
 
 		if (list_empty(&host->queue))
 			mci_writel(host, MR, host->mode_reg);
@@ -1648,8 +1675,10 @@ static int __init atmci_probe(struct platform_device *pdev)
 			nr_slots++;
 	}
 
-	if (!nr_slots)
+	if (!nr_slots) {
+		printk(KERN_ERR "Atmel MCI controller init failed.  atmci_init_slot error or no slots with bus_width > 0.\n");
 		goto err_init_slot;
+	}
 
 	dev_info(&pdev->dev,
 			"Atmel MCI controller at 0x%08lx irq %d, %u slots\n",
Signature · 1 line
1.6.0.4
#1 lore raw

PATCH 2/6 atmel-mci: Platform configuration to the the atmel-mci driver

Created a modified version of the at91sam9g20 evaluation kit platform (board-sam9g20ek-2slot-mmc.c) and device support to make use of the updated atmel-mci driver.

This patch shows how an AT91 developer could add support for both SD slots for their project.

This requires getting the most updated arch/arm/tools/mach-types from http://www.arm.linux.org.uk/developer/machines/download.php to have the machine type for the modified at91sam9g20ek.

---
 arch/arm/mach-at91/Kconfig                     |    7 +
 arch/arm/mach-at91/Makefile                    |    1 +
 arch/arm/mach-at91/at91sam9260_devices.c       |   95 ++++++++
 arch/arm/mach-at91/board-sam9g20ek-2slot-mmc.c |  277 ++++++++++++++++++++++++
 arch/arm/mach-at91/include/mach/board.h        |    5 +
 5 files changed, 385 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-at91/board-sam9g20ek-2slot-mmc.c
arch/arm/mach-at91/Kconfig +7 -0
index 323b47f..5c8d770 100644
@@ -276,6 +276,13 @@ config MACH_AT91SAM9G20EK
 	help
 	  Select this if you are using Atmel's AT91SAM9G20-EK Evaluation Kit.
 
+config MACH_AT91SAM9G20EK_2MMC
+	bool "Atmel AT91SAM9G20-EK Evaluation Kit modified for 2 MMC Slots"
+	depends on ARCH_AT91SAM9G20
+	help
+	  Select this if you are using an Atmel AT91SAM9G20-EK Evaluation Kit
+	  Rev A or B modified for 2 MMC Slots.
+
 endif
 
 # ----------------------------------------------------------
arch/arm/mach-at91/Makefile +1 -0
index c69ff23..cdddba8 100644
@@ -54,6 +54,7 @@ obj-$(CONFIG_MACH_AT91SAM9RLEK)	+= board-sam9rlek.o
 
 # AT91SAM9G20 board-specific support
 obj-$(CONFIG_MACH_AT91SAM9G20EK) += board-sam9g20ek.o
+obj-$(CONFIG_MACH_AT91SAM9G20EK_2MMC) += board-sam9g20ek-2slot-mmc.o
 
 # AT91CAP9 board-specific support
 obj-$(CONFIG_MACH_AT91CAP9ADK)	+= board-cap9adk.o
arch/arm/mach-at91/at91sam9260_devices.c +95 -0

101 lines not on this page · raw message

arch/arm/mach-at91/board-sam9g20ek-2slot-mmc.c new file +277 -0

277 lines not on this page · raw message

arch/arm/mach-at91/include/mach/board.h +5 -0
index e6afff8..a635dad 100644
@@ -37,6 +37,7 @@
 #include <linux/leds.h>
 #include <linux/spi/spi.h>
 #include <linux/usb/atmel_usba_udc.h>
+#include <linux/atmel-mci.h>
 
  /* USB Device */
 struct at91_udc_data {
@@ -63,6 +64,7 @@ struct at91_cf_data {
 extern void __init at91_add_device_cf(struct at91_cf_data *data);
 
  /* MMC / SD */
+  /* at91_mci platform config */
 struct at91_mmc_data {
 	u8		det_pin;	/* card detect IRQ */
 	unsigned	slot_b:1;	/* uses Slot B */
@@ -72,6 +74,9 @@ struct at91_mmc_data {
 };
 extern void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data);
 
+  /* atmel-mci platform config */
+extern void __init at91_add_device_mci(short mmc_id, struct mci_platform_data *data);
+
  /* Ethernet (EMAC & MACB) */
 struct at91_eth_data {
 	u32		phy_mask;
Signature · 1 line
1.6.0.4
#2 lore raw

Re: [PATCH 2/6] atmel-mci: Platform configuration to the the atmel-mci driver

Rob Emanuele :

Quoted 3 lines

Created a modified version of the at91sam9g20 evaluation kit platform (board-sam9g20ek-2slot-mmc.c) and device support to make use of the updated atmel-mci driver.

This patch shows how an AT91 developer could add support for both SD slots for their project.

Comment formated.

Quoted 1 line

This requires getting the most updated arch/arm/tools/mach-types from http://www.arm.linux.org.uk/developer/machines/download.php to have the machine type for the modified at91sam9g20ek.

Ok moved below "---"

Quoted 81 lines
---
 arch/arm/mach-at91/Kconfig                     |    7 +
 arch/arm/mach-at91/Makefile                    |    1 +
 arch/arm/mach-at91/at91sam9260_devices.c       |   95 ++++++++
 arch/arm/mach-at91/board-sam9g20ek-2slot-mmc.c |  277 ++++++++++++++++++++++++
 arch/arm/mach-at91/include/mach/board.h        |    5 +
 5 files changed, 385 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-at91/board-sam9g20ek-2slot-mmc.c
arch/arm/mach-at91/Kconfig +7 -0
index 323b47f..5c8d770 100644
@@ -276,6 +276,13 @@ config MACH_AT91SAM9G20EK
 	help
 	  Select this if you are using Atmel's AT91SAM9G20-EK Evaluation Kit.
 
+config MACH_AT91SAM9G20EK_2MMC
+	bool "Atmel AT91SAM9G20-EK Evaluation Kit modified for 2 MMC Slots"
+	depends on ARCH_AT91SAM9G20
+	help
+	  Select this if you are using an Atmel AT91SAM9G20-EK Evaluation Kit
+	  Rev A or B modified for 2 MMC Slots.
+
 endif
 
 # ----------------------------------------------------------
arch/arm/mach-at91/Makefile +1 -0
index c69ff23..cdddba8 100644
@@ -54,6 +54,7 @@ obj-$(CONFIG_MACH_AT91SAM9RLEK)	+= board-sam9rlek.o
 
 # AT91SAM9G20 board-specific support
 obj-$(CONFIG_MACH_AT91SAM9G20EK) += board-sam9g20ek.o
+obj-$(CONFIG_MACH_AT91SAM9G20EK_2MMC) += board-sam9g20ek-2slot-mmc.o
 
 # AT91CAP9 board-specific support
 obj-$(CONFIG_MACH_AT91CAP9ADK)	+= board-cap9adk.o
arch/arm/mach-at91/at91sam9260_devices.c +33 -0
index d74c9ac..c372f4f 100644
@@ -278,6 +278,101 @@ void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data)
 void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data) {}
 #endif
 
+/* --------------------------------------------------------------------
+ *  MMC / SD Slot for Atmel MCI Driver
+ * -------------------------------------------------------------------- */
+
+#if defined(CONFIG_MMC_ATMELMCI) || defined(CONFIG_MMC_ATMELMCI_MODULE)
+static u64 mmc_dmamask = DMA_BIT_MASK(32);
+static struct mci_platform_data mmc_data;
+
+static struct resource mmc_resources[] = {
+	[0] = {
+		.start	= AT91SAM9260_BASE_MCI,
+		.end	= AT91SAM9260_BASE_MCI + SZ_16K - 1,
+		.flags	= IORESOURCE_MEM,
+	},
+	[1] = {
+		.start	= AT91SAM9260_ID_MCI,
+		.end	= AT91SAM9260_ID_MCI,
+		.flags	= IORESOURCE_IRQ,
+	},
+};
+
+static struct platform_device at91sam9260_mmc_device = {
+	.name		= "atmel_mci",
+	.id		= -1,
+	.dev		= {
+				.dma_mask		= &mmc_dmamask,
+				.coherent_dma_mask	= DMA_BIT_MASK(32),
+				.platform_data		= &mmc_data,
+	},
+	.resource	= mmc_resources,
+	.num_resources	= ARRAY_SIZE(mmc_resources),
+};
+

arch/arm/mach-at91/at91sam9260_devices.c void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data) · line 323

Quoted 10 lines
arch/arm/mach-at91/at91sam9260_devices.c +10 -0
+void __init at91_add_device_mci(short mmc_id, struct mci_platform_data *data)
+{
+	unsigned int i;
+	unsigned int slot_count = 0;
+
+	if (!data)
+		return;
+
+	for (i = 0; i < ATMEL_MCI_MAX_NR_SLOTS; i++) {
+	   if (data->slot[i].bus_width) {

Indentation.

Quoted 9 lines
arch/arm/mach-at91/at91sam9260_devices.c +9 -0
+			/* input/irq */
+			if (data->slot[i].detect_pin) {
+				at91_set_gpio_input(data->slot[i].detect_pin, 1);
+				at91_set_deglitch(data->slot[i].detect_pin, 1);
+			}
+			if (data->slot[i].wp_pin)
+				at91_set_gpio_input(data->slot[i].wp_pin, 1);
+
+			switch(i) {

arch/arm/mach-at91/at91sam9260_devices.c void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data) · line 342

Quoted 10 lines
arch/arm/mach-at91/at91sam9260_devices.c +10 -0
+			case 0:
+				/* CMD */
+				at91_set_A_periph(AT91_PIN_PA7, 1);
+				/* DAT0, maybe DAT1..DAT3 */
+				at91_set_A_periph(AT91_PIN_PA6, 1);
+				if (data->slot[i].bus_width == 4) {
+					at91_set_A_periph(AT91_PIN_PA9, 1);
+					at91_set_A_periph(AT91_PIN_PA10, 1);
+					at91_set_A_periph(AT91_PIN_PA11, 1);
+				}

I put slot_count here...
+ slot_count++;

arch/arm/mach-at91/at91sam9260_devices.c void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data) · line 353

Quoted 11 lines
arch/arm/mach-at91/at91sam9260_devices.c +11 -0
+				break;
+			case 1:
+				/* CMD */
+				at91_set_B_periph(AT91_PIN_PA1, 1);
+				/* DAT0, maybe DAT1..DAT3 */
+				at91_set_B_periph(AT91_PIN_PA0, 1);
+				if (data->slot[i].bus_width == 4) {
+					at91_set_B_periph(AT91_PIN_PA5, 1);
+					at91_set_B_periph(AT91_PIN_PA4, 1);
+					at91_set_B_periph(AT91_PIN_PA3, 1);
+				}

and here...
+ slot_count++;

arch/arm/mach-at91/at91sam9260_devices.c void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data) · line 356

Quoted 3 lines
arch/arm/mach-at91/at91sam9260_devices.c +3 -0
+				break;
+			default:
+				printk("Configuration Error, No MMC Port %d\n",i);

Replaced with:

                      printk(KERN_ERR
                            "AT91: SD/MMC slot %d not available\n", i);

arch/arm/mach-at91/at91sam9260_devices.c void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data) · line 358

Quoted 2 lines
arch/arm/mach-at91/at91sam9260_devices.c +2 -0
+				break;
+			};

removed here.

arch/arm/mach-at91/board-sam9g20ek-2slot-mmc.c

Quoted 25 lines
arch/arm/mach-at91/at91sam9260_devices.c +17 -0
+			slot_count++;
+		}
+	}
+
+	if (slot_count) {
+		/* CLK */
+		at91_set_A_periph(AT91_PIN_PA8, 0);
+
+		mmc_data = *data;
+		platform_device_register(&at91sam9260_mmc_device);
+	}
+}
+#else
+void __init at91_add_device_mci(short mmc_id, struct mci_platform_data *data) {}
+#endif
+
+
 
 /* --------------------------------------------------------------------
  *  NAND / SmartMedia
arch/arm/mach-at91/board-sam9g20ek-2slot-mmc.c new file +0 -0
new file mode 100644
index 0000000..a28e53f

Ok. True that it duplicates code but it is simpler.
It also can be a testbed for future -EK revision D and following.

[..]

Quoted 21 lines
arch/arm/mach-at91/include/mach/board.h +2 -0
index e6afff8..a635dad 100644
@@ -37,6 +37,7 @@
 #include <linux/leds.h>
 #include <linux/spi/spi.h>
 #include <linux/usb/atmel_usba_udc.h>
+#include <linux/atmel-mci.h>
 
  /* USB Device */
 struct at91_udc_data {
@@ -63,6 +64,7 @@ struct at91_cf_data {
 extern void __init at91_add_device_cf(struct at91_cf_data *data);
 
  /* MMC / SD */
+  /* at91_mci platform config */
 struct at91_mmc_data {
 	u8		det_pin;	/* card detect IRQ */
 	unsigned	slot_b:1;	/* uses Slot B */

arch/arm/mach-at91/include/mach/board.h struct at91_mmc_data { · line 82

Quoted 9 lines
arch/arm/mach-at91/include/mach/board.h +3 -0
@@ -72,6 +74,9 @@ struct at91_mmc_data {
 };
 extern void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data);
 
+  /* atmel-mci platform config */
+extern void __init at91_add_device_mci(short mmc_id, struct mci_platform_data *data);
+
  /* Ethernet (EMAC & MACB) */
 struct at91_eth_data {
 	u32		phy_mask;

Ok.

I post the patch to Andrew Victor with the tiny modifications above (your SOB & From: preserved of course).

Thanks, Bye,

Signature · 1 line
Nicolas Ferre
#3 lore raw

Re: [PATCH 2/6] atmel-mci: Platform configuration to the the atmel-mci driver

In reply to Rob Emanuele

hi,

arch/arm/mach-at91/at91sam9260_devices.c void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data) · line 330

Quoted 8 lines
arch/arm/mach-at91/at91sam9260_devices.c +8 -0
+          if (data->slot[i].bus_width) {
+                       /* input/irq */
+                       if (data->slot[i].detect_pin) {
+                               at91_set_gpio_input(data->slot[i].detect_pin, 1);
+                               at91_set_deglitch(data->slot[i].detect_pin, 1);
+                       }
+                       if (data->slot[i].wp_pin)
+                               at91_set_gpio_input(data->slot[i].wp_pin, 1);

The current at91_mci also allows the driver to control the "vcc_pin". Can that functionality be merged into atmel_mci driver?

Regards.
Andre Victor

#4 lore raw

Re: [PATCH 2/6] atmel-mci: Platform configuration to the the atmel-mci driver

Quoted 2 lines

The current at91_mci also allows the driver to control the "vcc_pin". Can that functionality be merged into atmel_mci driver?

Ignore that comment, I see it's in Patch 5.

#5 lore raw

PATCH 3/6 atmel-mci: Optional controller reset before every command

In reply to Rob Emanuele

This patch adds the compile time configuration option for the atmel-mci driver to reset the Atmel MCI controller before every command.

This is sometimes needed for the Atmel controller / board to function properly.

---
 drivers/mmc/host/Kconfig     |   10 ++++++++++
 drivers/mmc/host/atmel-mci.c |   11 ++++++++++-
 2 files changed, 20 insertions(+), 1 deletions(-)
drivers/mmc/host/Kconfig +10 -0
index a0eaf69..5875125 100644
@@ -161,6 +161,16 @@ config MMC_ATMELMCI
 
 endchoice
 
+config MMC_ATMELMCI_ALWAYS_RESET
+	bool "Reset before every request.  Sometimes needed for buggy chips."
+	depends on MMC_ATMELMCI
+	help
+	  There are reports that some buggy controllers work better
+	  with a reset before every command.  This may improve your
+	  controller's reliability.
+
+	  If unsure, say N.
+
 config MMC_ATMELMCI_DMA
 	bool "Atmel MCI DMA support (EXPERIMENTAL)"
 	depends on MMC_ATMELMCI && AVR32 && DMA_ENGINE && EXPERIMENTAL
drivers/mmc/host/atmel-mci.c +10 -1
index 98b25de..e5894f6 100644
@@ -63,6 +63,15 @@ struct atmel_mci_dma {
 #endif
 };
 
+/*
+ * Configuration options from the kernel config
+ */
+#ifdef CONFIG_MMC_ATMELMCI_ALWAYS_RESET
+#define MMC_ALWAYS_RESET 1
+#else
+#define MMC_ALWAYS_RESET 0
+#endif
+
 /**
  * struct atmel_mci - MMC controller state shared between all slots
  * @lock: Spinlock protecting the queue and associated data.
@@ -720,7 +729,7 @@ static void atmci_start_request(struct atmel_mci *host,
 	host->completed_events = 0;
 	host->data_status = 0;
 
-	if (host->need_reset) {
+	if (host->need_reset || MMC_ALWAYS_RESET) {
 		mci_writel(host, CR, MCI_CR_SWRST);
 		mci_writel(host, CR, MCI_CR_MCIEN);
 		mci_writel(host, MR, host->mode_reg);
Signature · 1 line
1.6.0.4
#6 lore raw

Re: [PATCH 3/6] atmel-mci: Optional controller reset before every command

Hi!

Quoted 37 lines · On Wednesday 17 June 2009 02:54:36 Rob Emanuele wrote:

This patch adds the compile time configuration option for the atmel-mci driver to reset the Atmel MCI controller before every command.

This is sometimes needed for the Atmel controller / board to function properly.

---
 drivers/mmc/host/Kconfig     |   10 ++++++++++
 drivers/mmc/host/atmel-mci.c |   11 ++++++++++-
 2 files changed, 20 insertions(+), 1 deletions(-)
drivers/mmc/host/Kconfig +10 -0
index a0eaf69..5875125 100644
@@ -161,6 +161,16 @@ config MMC_ATMELMCI
 
 endchoice
 
+config MMC_ATMELMCI_ALWAYS_RESET
+	bool "Reset before every request.  Sometimes needed for buggy chips."
+	depends on MMC_ATMELMCI
+	help
+	  There are reports that some buggy controllers work better
+	  with a reset before every command.  This may improve your
+	  controller's reliability.
+
+	  If unsure, say N.
+
 config MMC_ATMELMCI_DMA
 	bool "Atmel MCI DMA support (EXPERIMENTAL)"
 	depends on MMC_ATMELMCI && AVR32 && DMA_ENGINE && EXPERIMENTAL
drivers/mmc/host/atmel-mci.c +0 -0
index 98b25de..e5894f6 100644
@@ -63,6 +63,15 @@ struct atmel_mci_dma {
 #endif

drivers/mmc/host/atmel-mci.c struct atmel_mci_dma { · line 73

Quoted 10 lines
drivers/mmc/host/atmel-mci.c +8 -0
 };
 
+/*
+ * Configuration options from the kernel config
+ */
+#ifdef CONFIG_MMC_ATMELMCI_ALWAYS_RESET
+#define MMC_ALWAYS_RESET 1
+#else
+#define MMC_ALWAYS_RESET 0
+#endif

Some chips are known to hang after (some) transfer. There is no need for this configuration option, I think we should just do :

#define MMC_ALWAYS_RESET (cpu_is_at91rm9200() || add_your_cpu_name_here())

drivers/mmc/host/atmel-mci.c static void atmci_start_request(struct atmel_mci *host, · line 735

Quoted 13 lines
drivers/mmc/host/atmel-mci.c +2 -1
+
 /**
  * struct atmel_mci - MMC controller state shared between all slots
  * @lock: Spinlock protecting the queue and associated data.
@@ -720,7 +729,7 @@ static void atmci_start_request(struct atmel_mci *host,
 	host->completed_events = 0;
 	host->data_status = 0;
 
-	if (host->need_reset) {
+	if (host->need_reset || MMC_ALWAYS_RESET) {
 		mci_writel(host, CR, MCI_CR_SWRST);
 		mci_writel(host, CR, MCI_CR_MCIEN);
 		mci_writel(host, MR, host->mode_reg);

Another option is to always reset the controller.

The reset operation won't hurt, it is simple and fast, and the code will be simpler and better tested.

Best regards

Marc

#7 lore raw

Re: [PATCH 3/6] atmel-mci: Optional controller reset before every command

Marc,

(This may be a resend, gmail and its fancy text hates me.)

There has been debate over whether always reseting the MCI controller is the correct thing to do. I think for some platforms it is required but there is no consensus to what those platforms are. I think the config option is the best of both worlds as a user of this kernel/driver can choose to enable this or not without having to modify their source. It may even be a decent idea to enable this option if they are using certain chips that we know reseting improves their behavior.

Thank you,
Rob

#8 lore raw

PATCH 4/6 atmel-mci: CLKDIV cap to restrict the MCI controller speed

In reply to Rob Emanuele

This patch adds the compile time configuration option for the atmel-mci driver to cap the MCI CLKDIV register value to a minimum value.

This is useful for debugging and for boards that have a long mci clock line.

---
 drivers/mmc/host/Kconfig     |   14 ++++++++++++++
 drivers/mmc/host/atmel-mci.c |   10 ++++++++++
 2 files changed, 24 insertions(+), 0 deletions(-)
drivers/mmc/host/Kconfig +14 -0
index 5875125..b628037 100644
@@ -161,6 +161,20 @@ config MMC_ATMELMCI
 
 endchoice
 
+config MMC_ATMELMCI_CLKDIV_CAP
+	int "Cap the CLKDIV to keep the controller from going too fast."
+	depends on MMC_ATMELMCI
+	default 0
+	range 0 255
+	help
+	  This is the lowest value the clock divisor for the MMC
+	  controller can be.  Value is between 0 and 255.
+	  MCI_CK = MCK/(2*(CLKDIV+1))
+	  Raising this value may improve your controller's reliability
+	  at the cost of speed.
+
+	  If unsure, leave at 0.
+
 config MMC_ATMELMCI_ALWAYS_RESET
 	bool "Reset before every request.  Sometimes needed for buggy chips."
 	depends on MMC_ATMELMCI
drivers/mmc/host/atmel-mci.c +10 -0
index e5894f6..601dae7 100644
@@ -72,6 +72,10 @@ struct atmel_mci_dma {
 #define MMC_ALWAYS_RESET 0
 #endif
 
+#ifndef CONFIG_MMC_ATMELMCI_CLKDIV_CAP
+#define CONFIG_MMC_ATMELMCI_CLKDIV_CAP 0
+#endif
+
 /**
  * struct atmel_mci - MMC controller state shared between all slots
  * @lock: Spinlock protecting the queue and associated data.
@@ -882,6 +886,12 @@ static void atmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
 				clock_min, host->bus_hz / (2 * 256));
 			clkdiv = 255;
 		}
+		if (clkdiv < CONFIG_MMC_ATMELMCI_CLKDIV_CAP) {
+			dev_warn(&mmc->class_dev,
+				"clkdiv %u too fast; capped using %u\n",
+				 clkdiv, CONFIG_MMC_ATMELMCI_CLKDIV_CAP);
+			clkdiv = CONFIG_MMC_ATMELMCI_CLKDIV_CAP;
+		}
 
 		host->mode_reg = MCI_MR_CLKDIV(clkdiv);
 
Signature · 1 line
1.6.0.4
#9 lore raw

PATCH 5/6 atmel-mci: Power control option for each MMC Slot

In reply to Rob Emanuele

Add support to the atmel-mci driver for a VCC pin in order to conserve power by removing power from an MMC Slot.

---
 drivers/mmc/host/atmel-mci.c |   33 ++++++++++++++++++++-------------
 include/linux/atmel-mci.h    |    2 ++
 2 files changed, 22 insertions(+), 13 deletions(-)
drivers/mmc/host/atmel-mci.c +20 -13
index 601dae7..63cd5c7 100644
@@ -214,6 +214,8 @@ struct atmel_mci_slot {
 	int			detect_pin;
 	int			wp_pin;
 	bool			detect_is_active_high;
+	int			vcc_pin;
+	bool			vcc_active_low;
 
 	struct timer_list	detect_timer;
 };
@@ -932,23 +934,19 @@ static void atmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
 	}
 
 	switch (ios->power_mode) {
+	case MMC_POWER_OFF:
+		if (gpio_is_valid(slot->vcc_pin))
+			gpio_set_value(slot->vcc_pin, slot->vcc_active_low);
+		break;
 	case MMC_POWER_UP:
+		if (gpio_is_valid(slot->vcc_pin))
+			gpio_set_value(slot->vcc_pin, !slot->vcc_active_low);
 		set_bit(ATMCI_CARD_NEED_INIT, &slot->flags);
 		break;
-	default:
-		/*
-		 * TODO: None of the currently available AVR32-based
-		 * boards allow MMC power to be turned off. Implement
-		 * power control when this can be tested properly.
-		 *
-		 * We also need to hook this into the clock management
-		 * somehow so that newly inserted cards aren't
-		 * subjected to a fast clock before we have a chance
-		 * to figure out what the maximum rate is. Currently,
-		 * there's no way to avoid this, and there never will
-		 * be for boards that don't support power control.
-		 */
+	case MMC_POWER_ON:
 		break;
+	default:
+		WARN_ON(1);
 	}
 }
 
@@ -1507,6 +1505,8 @@ static int __init atmci_init_slot(struct atmel_mci *host,
 	slot->detect_pin = slot_data->detect_pin;
 	slot->wp_pin = slot_data->wp_pin;
 	slot->detect_is_active_high = slot_data->detect_is_active_high;
+	slot->vcc_pin = slot_data->vcc_pin;
+	slot->vcc_active_low = slot_data->vcc_active_low;
 	slot->sdc_reg = sdc_reg;
 
 	mmc->ops = &atmci_ops;
@@ -1544,6 +1544,13 @@ static int __init atmci_init_slot(struct atmel_mci *host,
 		}
 	}
 
+	if (gpio_is_valid(slot->vcc_pin)) {
+		if (gpio_request(slot->vcc_pin, "mmc_pow")) {
+			dev_dbg(&mmc->class_dev, "no power pin available\n");
+			slot->vcc_pin = -EBUSY;
+		}
+	}
+
 	host->slot[id] = slot;
 	mmc_add_host(mmc);
 
include/linux/atmel-mci.h +2 -0
index 57b1846..7c15a7c 100644
@@ -26,6 +26,8 @@ struct mci_slot_pdata {
 	int			detect_pin;
 	int			wp_pin;
 	bool			detect_is_active_high;
+	int			vcc_pin;
+	unsigned		vcc_active_low:1;
 };
 
 /**
Signature · 1 line
1.6.0.4
#10 lore raw

Re: [PATCH 5/6] atmel-mci: Power control option for each MMC Slot

Hi!

Quoted 1 line · On Wednesday 17 June 2009 02:54:38 Rob Emanuele wrote:

Add support to the atmel-mci driver for a VCC pin in order to conserve power by removing power from an MMC Slot.

...

drivers/mmc/host/atmel-mci.c static int __init atmci_init_slot(struct atmel_mci *host, · line 1548

Quoted 6 lines
drivers/mmc/host/atmel-mci.c +2 -0
@@ -1544,6 +1544,13 @@ static int __init atmci_init_slot(struct atmel_mci *host,
 		}
 	}
 
+	if (gpio_is_valid(slot->vcc_pin)) {
+		if (gpio_request(slot->vcc_pin, "mmc_pow")) {

gpio_request will check for "gpio_is_valid" so this is not necessary.

drivers/mmc/host/atmel-mci.c static int __init atmci_init_slot(struct atmel_mci *host, · line 1553

Quoted 5 lines
drivers/mmc/host/atmel-mci.c +5 -0
+			dev_dbg(&mmc->class_dev, "no power pin available\n");
+			slot->vcc_pin = -EBUSY;
+		}
+	}
+

...

Best regards

Marc

#11 lore raw

PATCH 6/6 atmel-mci: Platform driver MMC slot power control

In reply to Rob Emanuele

Add support to the at91sam9g20ek_2mmc platform (board-sam9g20ek-2slot-mmc.c) and support files for a VCC pin using the atmel-mci driver.

---
 arch/arm/mach-at91/at91sam9260_devices.c       |    2 ++
 arch/arm/mach-at91/board-sam9g20ek-2slot-mmc.c |    3 +++
 2 files changed, 5 insertions(+), 0 deletions(-)
arch/arm/mach-at91/at91sam9260_devices.c +2 -0
index c372f4f..7634632 100644
@@ -328,6 +328,8 @@ void __init at91_add_device_mci(short mmc_id, struct mci_platform_data *data)
 			}
 			if (data->slot[i].wp_pin)
 				at91_set_gpio_input(data->slot[i].wp_pin, 1);
+			if (data->slot[i].vcc_pin)
+				at91_set_gpio_output(data->slot[i].vcc_pin, 0);
 
 			switch(i) {
 			case 0:
arch/arm/mach-at91/board-sam9g20ek-2slot-mmc.c +3 -0
index a28e53f..20c6738 100644
@@ -202,11 +202,14 @@ static struct mci_platform_data __initdata ek_mmc_data = {
 		.bus_width	= 4,
 		.detect_pin	= -ENODEV,
 		.wp_pin		= -ENODEV,
+		.vcc_pin	= AT91_PIN_PA30,
+		.vcc_active_low	= 1,
 	},
 	.slot[1] = {
 		.bus_width	= 4,
 		.detect_pin	= -ENODEV,
 		.wp_pin		= -ENODEV,
+		.vcc_pin	= -ENODEV,
 	},
 
 };
Signature · 1 line
1.6.0.4
#12 lore raw

Re: [PATCH 6/6] atmel-mci: Platform driver MMC slot power control

Quoted 13 lines · Rob Emanuele

Add support to the at91sam9g20ek_2mmc platform (board-sam9g20ek-2slot-mmc.c) and support files for a VCC pin using the atmel-mci driver.

---
 arch/arm/mach-at91/at91sam9260_devices.c       |    2 ++
 arch/arm/mach-at91/board-sam9g20ek-2slot-mmc.c |    3 +++
 2 files changed, 5 insertions(+), 0 deletions(-)
arch/arm/mach-at91/at91sam9260_devices.c +0 -0
index c372f4f..7634632 100644

arch/arm/mach-at91/at91sam9260_devices.c void __init at91_add_device_mci(short mmc_id, struct mci_platform_data *data) · line 333

Quoted 6 lines
arch/arm/mach-at91/at91sam9260_devices.c +2 -0
@@ -328,6 +328,8 @@ void __init at91_add_device_mci(short mmc_id, struct mci_platform_data *data)
 			}
 			if (data->slot[i].wp_pin)
 				at91_set_gpio_input(data->slot[i].wp_pin, 1);
+			if (data->slot[i].vcc_pin)
+				at91_set_gpio_output(data->slot[i].vcc_pin, 0);
 

Can use gpio_direction_output on these.

~Ryan

Signature · 8 lines
Bluewater Systems Ltd - ARM Technology Solution Centre

       Ryan Mallon                              Unit 5, Amuri Park
       Phone: +64 3 3779127                     404 Barbadoes St
       Fax:   +64 3 3779135                     PO Box 13 889
       Email: [email protected]             Christchurch, 8013
       Web:   http://www.bluewatersys.com       New Zealand
       Freecall Australia  1800 148 751         USA 1800 261 2934
#13 lore raw
In reply to Rob Emanuele

Rob, Haavard,

Rob Emanuele :

Quoted 3 lines

Unification of the atmel-mci driver to support the AT91 processors MCI interface. The atmel-mci driver currently supports the AVR32 and this patch adds AT91 support.

To use this new driver on a at91 the platform driver for your board needs to updated. See the following patch for an example of how to do that.

I format those lines remove last sentence and add :
"Add read/write proof selection switch dependent on chip availability
of this feature."

Quoted 11 lines
---
 drivers/mmc/host/Kconfig     |   16 ++++++++++++----
 drivers/mmc/host/atmel-mci.c |   37 +++++++++++++++++++++++++++++++++----
 2 files changed, 45 insertions(+), 8 deletions(-)
drivers/mmc/host/Kconfig +0 -0
index 40111a6..a0eaf69 100644

drivers/mmc/host/Kconfig config MMC_AU1X · line 139

Quoted 5 lines
drivers/mmc/host/Kconfig +2 -0
@@ -135,6 +135,12 @@ config MMC_AU1X
 
 	  If unsure, say N.
 
+choice
+	prompt "Atmel MMC Driver"

I add SD/MMC

Quoted 38 lines
drivers/mmc/host/Kconfig +10 -4
+	default MMC_ATMELMCI if AVR32
+	help
+	  Choose which driver to use for the Atmel MCI Silicon
+
 config MMC_AT91
 	tristate "AT91 SD/MMC Card Interface support"
 	depends on ARCH_AT91
@@ -145,17 +151,19 @@ config MMC_AT91
 
 config MMC_ATMELMCI
 	tristate "Atmel Multimedia Card Interface support"
-	depends on AVR32
+	depends on AVR32 || ARCH_AT91
 	help
 	  This selects the Atmel Multimedia Card Interface driver. If
-	  you have an AT32 (AVR32) platform with a Multimedia Card
-	  slot, say Y or M here.
+	  you have an AT32 (AVR32) or AT91 platform with a Multimedia
+	  Card slot, say Y or M here.
 
 	  If unsure, say N.
 
+endchoice
+
 config MMC_ATMELMCI_DMA
 	bool "Atmel MCI DMA support (EXPERIMENTAL)"
-	depends on MMC_ATMELMCI && DMA_ENGINE && EXPERIMENTAL
+	depends on MMC_ATMELMCI && AVR32 && DMA_ENGINE && EXPERIMENTAL
 	help
 	  Say Y here to have the Atmel MCI driver use a DMA engine to
 	  do data transfers and thus increase the throughput and
drivers/mmc/host/atmel-mci.c +0 -0
index 7b603e4..98b25de 100644
@@ -30,11 +30,14 @@
 #include <asm/io.h>
 #include <asm/unaligned.h>

drivers/mmc/host/atmel-mci.c line 40

Quoted 10 lines
drivers/mmc/host/atmel-mci.c +4 -1
 
+#include <mach/cpu.h>
 #include <mach/board.h>
 
 #include "atmel-mci-regs.h"
 
-#define ATMCI_DATA_ERROR_FLAGS	(MCI_DCRCE | MCI_DTOE | MCI_OVRE | MCI_UNRE)
+#define ATMCI_DATA_ERROR_FLAGS	(MCI_RINDE | MCI_RDIRE | MCI_RCRCE  \
+				 | MCI_RENDE | MCI_RTOE | MCI_DCRCE \
+				 | MCI_DTOE | MCI_OVRE | MCI_UNRE)

Haavard, is it ok to add those flags on an AVR32 platform for now ?

Quoted 37 lines
drivers/mmc/host/atmel-mci.c +17 -0
 #define ATMCI_DMA_THRESHOLD	16
 
 enum {
@@ -210,6 +213,18 @@ struct atmel_mci_slot {
 	set_bit(event, &host->pending_events)
 
 /*
+ * Enable or disable features/registers based on
+ * whether the processor supports them
+ */
+static bool mci_has_rwproof(void)
+{
+	if (cpu_is_at91sam9261() || cpu_is_at91rm9200())
+		return false;
+	else
+		return true;
+}
+
+/*
  * The debugfs stuff below is mostly optimized away when
  * CONFIG_DEBUG_FS is not set.
  */
@@ -276,8 +291,13 @@ static void atmci_show_status_reg(struct seq_file *s,
 		[3]	= "BLKE",
 		[4]	= "DTIP",
 		[5]	= "NOTBUSY",
+		[6]	= "ENDRX",
+		[7]	= "ENDTX",
 		[8]	= "SDIOIRQA",
 		[9]	= "SDIOIRQB",
+		[12]	= "SDIOWAIT",
+		[14]	= "RXBUFF",
+		[15]	= "TXBUFE",
 		[16]	= "RINDE",
 		[17]	= "RDIRE",
 		[18]	= "RCRCE",

drivers/mmc/host/atmel-mci.c static void atmci_show_status_reg(struct seq_file *s, · line 312

Quoted 8 lines
drivers/mmc/host/atmel-mci.c +5 -0
@@ -285,6 +305,11 @@ static void atmci_show_status_reg(struct seq_file *s,
 		[20]	= "RTOE",
 		[21]	= "DCRCE",
 		[22]	= "DTOE",
+		[23]    = "CSTOE",
+		[24]    = "BLKOVRE",
+		[25]    = "DMADONE",
+		[26]    = "FIFOEMPTY",
+		[27]    = "XFRDONE",

Little indentation modifications.

Quoted 22 lines
drivers/mmc/host/atmel-mci.c +4 -2
 		[30]	= "OVRE",
 		[31]	= "UNRE",
 	};
@@ -849,13 +874,15 @@ static void atmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
 			clkdiv = 255;
 		}
 
+		host->mode_reg = MCI_MR_CLKDIV(clkdiv);
+
 		/*
 		 * WRPROOF and RDPROOF prevent overruns/underruns by
 		 * stopping the clock when the FIFO is full/empty.
 		 * This state is not expected to last for long.
 		 */
-		host->mode_reg = MCI_MR_CLKDIV(clkdiv) | MCI_MR_WRPROOF
-					| MCI_MR_RDPROOF;
+		if (mci_has_rwproof())
+			host->mode_reg |= (MCI_MR_WRPROOF | MCI_MR_RDPROOF);
 
 		if (list_empty(&host->queue))
 			mci_writel(host, MR, host->mode_reg);

drivers/mmc/host/atmel-mci.c static int __init atmci_probe(struct platform_device *pdev) · line 1679

Quoted 6 lines
drivers/mmc/host/atmel-mci.c +2 -1
@@ -1648,8 +1675,10 @@ static int __init atmci_probe(struct platform_device *pdev)
 			nr_slots++;
 	}
 
-	if (!nr_slots)
+	if (!nr_slots) {
+		printk(KERN_ERR "Atmel MCI controller init failed.  atmci_init_slot error or no slots with bus_width > 0.\n");

I change this to :
dev_err(&pdev->dev, "init failed: no slot defined\n");

drivers/mmc/host/atmel-mci.c static int __init atmci_probe(struct platform_device *pdev) · line 1684

Quoted 5 lines
drivers/mmc/host/atmel-mci.c +1 -0
 		goto err_init_slot;
+	}
 
 	dev_info(&pdev->dev,
 			"Atmel MCI controller at 0x%08lx irq %d, %u slots\n",

If Haavard is ok, I post the patch to Pierre Ossman with the tiny modifications above (your SOB & From: preserved of course).

Thanks, Bye,

Signature · 1 line
Nicolas Ferre
#14 lore raw
Quoted 6 lines · Nicolas Ferre

drivers/mmc/host/atmel-mci.c line 40

Quoted 4 lines
drivers/mmc/host/atmel-mci.c +3 -1
-#define ATMCI_DATA_ERROR_FLAGS	(MCI_DCRCE | MCI_DTOE | MCI_OVRE | MCI_UNRE)
+#define ATMCI_DATA_ERROR_FLAGS	(MCI_RINDE | MCI_RDIRE | MCI_RCRCE  \
+				 | MCI_RENDE | MCI_RTOE | MCI_DCRCE \
+				 | MCI_DTOE | MCI_OVRE | MCI_UNRE)  

Haavard, is it ok to add those flags on an AVR32 platform for now ?

It probably doesn't hurt on AVR32. But I'm not a great fan since it seems like the wrong thing to do, and it may simply mask the real problem.

Haavard

#15 lore raw

Haavard Skinnemoen :

Quoted 10 lines
Quoted 5 lines · Nicolas Ferre

drivers/mmc/host/atmel-mci.c line 40

Quoted 4 lines
drivers/mmc/host/atmel-mci.c +3 -1
-#define ATMCI_DATA_ERROR_FLAGS	(MCI_DCRCE | MCI_DTOE | MCI_OVRE | MCI_UNRE)
+#define ATMCI_DATA_ERROR_FLAGS	(MCI_RINDE | MCI_RDIRE | MCI_RCRCE  \
+				 | MCI_RENDE | MCI_RTOE | MCI_DCRCE \
+				 | MCI_DTOE | MCI_OVRE | MCI_UNRE)  

Haavard, is it ok to add those flags on an AVR32 platform for now ?

It probably doesn't hurt on AVR32. But I'm not a great fan since it seems like the wrong thing to do, and it may simply mask the real problem.

Agreed.

To move forward, I will submit a first patch series without those flags added.

Best regards,

Signature · 1 line
Nicolas Ferre
#16 lore raw

PATCH 1/2 atmel-mci: Unified Atmel MCI drivers (AVR32 & AT91)

In reply to Rob Emanuele

From: Rob Emanuele <[email protected]>

Unification of the atmel-mci driver to support the AT91 processors MCI interface. The atmel-mci driver currently supports the AVR32 and this patch adds AT91 support.
Add read/write proof selection switch dependent on chip availability of this feature.

To use this new driver on a at91 the platform driver for your board needs to updated.

[[email protected] indent, Kconfig comment and one printk modification]
---
 drivers/mmc/host/Kconfig     |   16 ++++++++++++----
 drivers/mmc/host/atmel-mci.c |   33 ++++++++++++++++++++++++++++++---
 2 files changed, 42 insertions(+), 7 deletions(-)
drivers/mmc/host/Kconfig +12 -4
index b4cf691..e779049 100644
@@ -124,6 +124,12 @@ config MMC_AU1X
 
 	  If unsure, say N.
 
+choice
+	prompt "Atmel SD/MMC Driver"
+	default MMC_ATMELMCI if AVR32
+	help
+	  Choose which driver to use for the Atmel MCI Silicon
+
 config MMC_AT91
 	tristate "AT91 SD/MMC Card Interface support"
 	depends on ARCH_AT91
@@ -134,17 +140,19 @@ config MMC_AT91
 
 config MMC_ATMELMCI
 	tristate "Atmel Multimedia Card Interface support"
-	depends on AVR32
+	depends on AVR32 || ARCH_AT91
 	help
 	  This selects the Atmel Multimedia Card Interface driver. If
-	  you have an AT32 (AVR32) platform with a Multimedia Card
-	  slot, say Y or M here.
+	  you have an AT32 (AVR32) or AT91 platform with a Multimedia
+	  Card slot, say Y or M here.
 
 	  If unsure, say N.
 
+endchoice
+
 config MMC_ATMELMCI_DMA
 	bool "Atmel MCI DMA support (EXPERIMENTAL)"
-	depends on MMC_ATMELMCI && DMA_ENGINE && EXPERIMENTAL
+	depends on MMC_ATMELMCI && AVR32 && DMA_ENGINE && EXPERIMENTAL
 	help
 	  Say Y here to have the Atmel MCI driver use a DMA engine to
 	  do data transfers and thus increase the throughput and
drivers/mmc/host/atmel-mci.c +30 -3
index 7b603e4..065fa81 100644
@@ -30,6 +30,7 @@
 #include <asm/io.h>
 #include <asm/unaligned.h>
 
+#include <mach/cpu.h>
 #include <mach/board.h>
 
 #include "atmel-mci-regs.h"
@@ -210,6 +211,18 @@ struct atmel_mci_slot {
 	set_bit(event, &host->pending_events)
 
 /*
+ * Enable or disable features/registers based on
+ * whether the processor supports them
+ */
+static bool mci_has_rwproof(void)
+{
+	if (cpu_is_at91sam9261() || cpu_is_at91rm9200())
+		return false;
+	else
+		return true;
+}
+
+/*
  * The debugfs stuff below is mostly optimized away when
  * CONFIG_DEBUG_FS is not set.
  */
@@ -276,8 +289,13 @@ static void atmci_show_status_reg(struct seq_file *s,
 		[3]	= "BLKE",
 		[4]	= "DTIP",
 		[5]	= "NOTBUSY",
+		[6]	= "ENDRX",
+		[7]	= "ENDTX",
 		[8]	= "SDIOIRQA",
 		[9]	= "SDIOIRQB",
+		[12]	= "SDIOWAIT",
+		[14]	= "RXBUFF",
+		[15]	= "TXBUFE",
 		[16]	= "RINDE",
 		[17]	= "RDIRE",
 		[18]	= "RCRCE",
@@ -285,6 +303,11 @@ static void atmci_show_status_reg(struct seq_file *s,
 		[20]	= "RTOE",
 		[21]	= "DCRCE",
 		[22]	= "DTOE",
+		[23]	= "CSTOE",
+		[24]	= "BLKOVRE",
+		[25]	= "DMADONE",
+		[26]	= "FIFOEMPTY",
+		[27]	= "XFRDONE",
 		[30]	= "OVRE",
 		[31]	= "UNRE",
 	};
@@ -849,13 +872,15 @@ static void atmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
 			clkdiv = 255;
 		}
 
+		host->mode_reg = MCI_MR_CLKDIV(clkdiv);
+
 		/*
 		 * WRPROOF and RDPROOF prevent overruns/underruns by
 		 * stopping the clock when the FIFO is full/empty.
 		 * This state is not expected to last for long.
 		 */
-		host->mode_reg = MCI_MR_CLKDIV(clkdiv) | MCI_MR_WRPROOF
-					| MCI_MR_RDPROOF;
+		if (mci_has_rwproof())
+			host->mode_reg |= (MCI_MR_WRPROOF | MCI_MR_RDPROOF);
 
 		if (list_empty(&host->queue))
 			mci_writel(host, MR, host->mode_reg);
@@ -1648,8 +1673,10 @@ static int __init atmci_probe(struct platform_device *pdev)
 			nr_slots++;
 	}
 
-	if (!nr_slots)
+	if (!nr_slots) {
+		dev_err(&pdev->dev, "init failed: no slot defined\n");
 		goto err_init_slot;
+	}
 
 	dev_info(&pdev->dev,
 			"Atmel MCI controller at 0x%08lx irq %d, %u slots\n",
Signature · 1 line
1.5.3.7
Acked-by on v1 1/2
#17 lore raw
Quoted 8 lines · Nicolas Ferre

From: Rob Emanuele <[email protected]>

Unification of the atmel-mci driver to support the AT91 processors MCI interface. The atmel-mci driver currently supports the AVR32 and this patch adds AT91 support.
Add read/write proof selection switch dependent on chip availability of this feature.

Quoted 6 lines

To use this new driver on a at91 the platform driver for your board needs to updated.

[[email protected] indent, Kconfig comment and one printk modification]
#18 lore raw

PATCH 2/2 AT91: atmel-mci: Platform configuration to the the atmel-mci driver

In reply to Rob Emanuele

From: Rob Emanuele <[email protected]>

Created a modified version of the at91sam9g20 evaluation kit platform (board-sam9g20ek-2slot-mmc.c) and device support to make use of the updated atmel-mci driver.
As the use of two slots modify GPIO pin allocation, we create another board file.

[[email protected]: printk, slot_count modification in at91sam9260_devices.c file]

---
This requires getting the most updated arch/arm/tools/mach-types from
http://www.arm.linux.org.uk/developer/machines/download.php to have the machine type for the at91sam9g20ek-2slot-mmc board.

 arch/arm/mach-at91/Kconfig                     |    7 +
 arch/arm/mach-at91/Makefile                    |    1 +
 arch/arm/mach-at91/at91sam9260_devices.c       |   96 ++++++++
 arch/arm/mach-at91/board-sam9g20ek-2slot-mmc.c |  277 ++++++++++++++++++++++++
 arch/arm/mach-at91/include/mach/board.h        |    5 +
 5 files changed, 386 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-at91/board-sam9g20ek-2slot-mmc.c
arch/arm/mach-at91/Kconfig +7 -0
index 323b47f..5c8d770 100644
@@ -276,6 +276,13 @@ config MACH_AT91SAM9G20EK
 	help
 	  Select this if you are using Atmel's AT91SAM9G20-EK Evaluation Kit.
 
+config MACH_AT91SAM9G20EK_2MMC
+	bool "Atmel AT91SAM9G20-EK Evaluation Kit modified for 2 MMC Slots"
+	depends on ARCH_AT91SAM9G20
+	help
+	  Select this if you are using an Atmel AT91SAM9G20-EK Evaluation Kit
+	  Rev A or B modified for 2 MMC Slots.
+
 endif
 
 # ----------------------------------------------------------
arch/arm/mach-at91/Makefile +1 -0
index c69ff23..cdddba8 100644
@@ -54,6 +54,7 @@ obj-$(CONFIG_MACH_AT91SAM9RLEK)	+= board-sam9rlek.o
 
 # AT91SAM9G20 board-specific support
 obj-$(CONFIG_MACH_AT91SAM9G20EK) += board-sam9g20ek.o
+obj-$(CONFIG_MACH_AT91SAM9G20EK_2MMC) += board-sam9g20ek-2slot-mmc.o
 
 # AT91CAP9 board-specific support
 obj-$(CONFIG_MACH_AT91CAP9ADK)	+= board-cap9adk.o
arch/arm/mach-at91/at91sam9260_devices.c +96 -0

102 lines not on this page · raw message

arch/arm/mach-at91/board-sam9g20ek-2slot-mmc.c new file +277 -0

277 lines not on this page · raw message

arch/arm/mach-at91/include/mach/board.h +5 -0
index e6afff8..a635dad 100644
@@ -37,6 +37,7 @@
 #include <linux/leds.h>
 #include <linux/spi/spi.h>
 #include <linux/usb/atmel_usba_udc.h>
+#include <linux/atmel-mci.h>
 
  /* USB Device */
 struct at91_udc_data {
@@ -63,6 +64,7 @@ struct at91_cf_data {
 extern void __init at91_add_device_cf(struct at91_cf_data *data);
 
  /* MMC / SD */
+  /* at91_mci platform config */
 struct at91_mmc_data {
 	u8		det_pin;	/* card detect IRQ */
 	unsigned	slot_b:1;	/* uses Slot B */
@@ -72,6 +74,9 @@ struct at91_mmc_data {
 };
 extern void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data);
 
+  /* atmel-mci platform config */
+extern void __init at91_add_device_mci(short mmc_id, struct mci_platform_data *data);
+
  /* Ethernet (EMAC & MACB) */
 struct at91_eth_data {
 	u32		phy_mask;
Signature · 1 line
1.5.3.7

A message that is not in the archive (sent off-list or not yet received): 95818a17c2b96d3769f4e1d3de26208647111758.1245778411.git.nicolas.ferre@atmel.com

A message that is not in the archive (sent off-list or not yet received): f8889fb59887a970581697beb313363a6a065606.1245778411.git.nicolas.ferre@atmel.com

#21 lore raw

Re: [PATCH 2/2] AT91: atmel-mci: Platform configuration to the the atmel-mci driver

Quoted 29 lines · Nicolas Ferre

From: Rob Emanuele <[email protected]>

Created a modified version of the at91sam9g20 evaluation kit platform (board-sam9g20ek-2slot-mmc.c) and device support to make use of the updated atmel-mci driver.
As the use of two slots modify GPIO pin allocation, we create another board file.

[[email protected]: printk, slot_count modification in at91sam9260_devices.c file]

---
This requires getting the most updated arch/arm/tools/mach-types from
http://www.arm.linux.org.uk/developer/machines/download.php to have the machine type for the at91sam9g20ek-2slot-mmc board.

 arch/arm/mach-at91/Kconfig                     |    7 +
 arch/arm/mach-at91/Makefile                    |    1 +
 arch/arm/mach-at91/at91sam9260_devices.c       |   96 ++++++++
 arch/arm/mach-at91/board-sam9g20ek-2slot-mmc.c |  277 ++++++++++++++++++++++++
 arch/arm/mach-at91/include/mach/board.h        |    5 +
 5 files changed, 386 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-at91/board-sam9g20ek-2slot-mmc.c
arch/arm/mach-at91/Kconfig +0 -0
index 323b47f..5c8d770 100644

arch/arm/mach-at91/Kconfig config MACH_AT91SAM9G20EK · line 284

Quoted 9 lines
arch/arm/mach-at91/Kconfig +6 -0
@@ -276,6 +276,13 @@ config MACH_AT91SAM9G20EK
 	help
 	  Select this if you are using Atmel's AT91SAM9G20-EK Evaluation Kit.
 
+config MACH_AT91SAM9G20EK_2MMC
+	bool "Atmel AT91SAM9G20-EK Evaluation Kit modified for 2 MMC Slots"
+	depends on ARCH_AT91SAM9G20
+	help
+	  Select this if you are using an Atmel AT91SAM9G20-EK Evaluation Kit
+	  Rev A or B modified for 2 MMC Slots.

create a new machine id for just such update :(
is this not possible to detect it and use the same machine?

Best Regards,
J.

#22 lore raw

Re: [PATCH 2/2] AT91: atmel-mci: Platform configuration to the the atmel-mci driver

After talking with Nicholas Ferre, we decided there were enough changes made to the at91sam9g20-ek (eval kit) that it warranted its own machine and related board-xxx.c file. In addition, Atmel has released schematics for its newest revision of the at91sam9g20-ek (rev. D) which will go into production once their supply of rev. C boards is sufficiently small. The rev. D board is much different than the previous revisions. The new machine with its board file is an excellent base to build on once the rev. D board is released.

Thank you,

Rob Emanuele