[maz at misterjones.org: [PATCH 3/5] [PCMCIA] Add support for platform dependant quirks]

Marc Zyngier maz at misterjones.org
Tue Aug 12 08:11:41 EDT 2008


On Tue, 12 Aug 2008 10:59:48 +0100
Russell King <rmk+pcmcia at arm.linux.org.uk> wrote:

Russell,

Thanks a lot for your comments.

> Also, the setting of MECR should be moved to a separate static
> function - the setup should be indentical for both the successful
> probe and the resume paths.
> 
> Finally, the question of setting MECR itself.  I think there's more to
> the support than what we see here - MECR doesn't power on the PCMCIA
> sockets...  Maybe that's a misunderstanding because of the loseness of
> the patch description.

I reworked the patch based on your comments. I hope that the patch
description is clear enough this time.

Please let me know it something like this is acceptable, or if I should
try the "machine_is_viper()" approach.

Regards,

	M.

[PCMCIA] Add support for platform dependant quirks

The Arcom/Eurotech Viper needs some extra care to run. On this board,
the PC104 connector is actually wired to the second PCMCIA slot.
Therefore, this second socket needs to be enabled, despite not being
managed by the PCMCIA code.

Add a quirks field to the pcmcia_low_level structure that the SOC
dependant code can inspect.

Introduce a PXA2XX_QUIRK_NEEDS_MECR_NOS that can be used by the
offending board.

Signed-off-by: Marc Zyngier <marc.zyngier at altran.com>
---
 drivers/pcmcia/pxa2xx_base.c |   38 ++++++++++++++++++++------------------
 drivers/pcmcia/pxa2xx_base.h |    7 +++++++
 drivers/pcmcia/soc_common.h  |    2 ++
 3 files changed, 29 insertions(+), 18 deletions(-)

diff --git a/drivers/pcmcia/pxa2xx_base.c b/drivers/pcmcia/pxa2xx_base.c
index 1b07af5..80cc367 100644
--- a/drivers/pcmcia/pxa2xx_base.c
+++ b/drivers/pcmcia/pxa2xx_base.c
@@ -166,6 +166,23 @@ pxa2xx_pcmcia_frequency_change(struct soc_pcmcia_socket *skt,
 }
 #endif
 
+static void pxa2xx_configure_sockets(struct device *dev)
+{
+	struct pcmcia_low_level *ops = dev->platform_data;
+
+	/*
+	 * We have at least one socket, so set MECR:CIT
+	 * (Card Is There)
+	 */
+	MECR |= MECR_CIT;
+
+	/* Set MECR:NOS (Number Of Sockets) */
+	if (ops->nr > 1 || (ops->quirks & PXA2XX_QUIRK_NEEDS_MECR_NOS))
+		MECR |= MECR_NOS;
+	else
+		MECR &= ~MECR_NOS;
+}
+
 int __pxa2xx_drv_pcmcia_probe(struct device *dev)
 {
 	int ret;
@@ -187,19 +204,8 @@ int __pxa2xx_drv_pcmcia_probe(struct device *dev)
 
 	ret = soc_common_drv_pcmcia_probe(dev, ops, first, nr);
 
-	if (ret == 0) {
-		/*
-		 * We have at least one socket, so set MECR:CIT
-		 * (Card Is There)
-		 */
-		MECR |= MECR_CIT;
-
-		/* Set MECR:NOS (Number Of Sockets) */
-		if (nr > 1)
-			MECR |= MECR_NOS;
-		else
-			MECR &= ~MECR_NOS;
-	}
+	if (ret == 0)
+		pxa2xx_configure_sockets(dev);
 
 	return ret;
 }
@@ -223,11 +229,7 @@ static int pxa2xx_drv_pcmcia_suspend(struct platform_device *dev, pm_message_t s
 
 static int pxa2xx_drv_pcmcia_resume(struct platform_device *dev)
 {
-	struct pcmcia_low_level *ops = dev->dev.platform_data;
-	int nr = ops ? ops->nr : 0;
-
-	MECR = nr > 1 ? MECR_CIT | MECR_NOS : (nr > 0 ? MECR_CIT : 0);
-
+	pxa2xx_configure_sockets(&dev->dev);
 	return pcmcia_socket_dev_resume(&dev->dev);
 }
 
diff --git a/drivers/pcmcia/pxa2xx_base.h b/drivers/pcmcia/pxa2xx_base.h
index 235d681..956ee9d 100644
--- a/drivers/pcmcia/pxa2xx_base.h
+++ b/drivers/pcmcia/pxa2xx_base.h
@@ -1,3 +1,10 @@
+#ifndef PXA2XX_BASE
+#define PXA2XX_BASE
+
+#define PXA2XX_QUIRK_NEEDS_MECR_NOS		(1 << 0)
+
 /* temporary measure */
 extern int __pxa2xx_drv_pcmcia_probe(struct device *);
 
+#endif
+
diff --git a/drivers/pcmcia/soc_common.h b/drivers/pcmcia/soc_common.h
index 91ef6a0..9e288fc 100644
--- a/drivers/pcmcia/soc_common.h
+++ b/drivers/pcmcia/soc_common.h
@@ -76,6 +76,8 @@ struct pcmcia_low_level {
 	int first;
 	/* nr of sockets */
 	int nr;
+	/* Quirks required by this system, SOC dependant */
+	u32 quirks;
 
 	int (*hw_init)(struct soc_pcmcia_socket *);
 	void (*hw_shutdown)(struct soc_pcmcia_socket *);
-- 
1.5.4.3


-- 
A rat a day keeps the plague away.



More information about the linux-pcmcia mailing list