Skip to contentSkip to conversation

libertas/sdio: set ECSI and SCSI bits for 1-bit transfers

PATCH In review Daniel Mack 5 participants 16 messages Mar 30, 2010 – Apr 13, 2010

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

PATCH 1/1 libertas/sdio: set ECSI and SCSI bits for 1-bit transfers

When operating in 1-bit mode, SDAT1 is used as dedicated interrupt line. However, the 8686 will only drive this line when the ECSI and SCSI bits are set in the CCCR_IF register.

Thanks to Alagu Sankar for pointing me in the right direction.

Cc Alagu Sankar <[email protected]>
Cc Volker Ernst <[email protected]>
Cc Dan Williams <[email protected]>
Cc John W. Linville <[email protected]>
Cc Holger Schurig <[email protected]>
Cc Bing Zhao <[email protected]>
---
 drivers/net/wireless/libertas/if_sdio.c |   24 ++++++++++++++++++++++++
 include/linux/mmc/sdio.h                |    2 ++
 2 files changed, 26 insertions(+), 0 deletions(-)
drivers/net/wireless/libertas/if_sdio.c +24 -0
index 7a73f62..d3170f2 100644
@@ -34,6 +34,8 @@
 #include <linux/mmc/card.h>
 #include <linux/mmc/sdio_func.h>
 #include <linux/mmc/sdio_ids.h>
+#include <linux/mmc/sdio.h>
+#include <linux/mmc/host.h>
 
 #include "host.h"
 #include "decl.h"
@@ -942,6 +944,7 @@ static int if_sdio_probe(struct sdio_func *func,
 	int ret, i;
 	unsigned int model;
 	struct if_sdio_packet *packet;
+	struct mmc_host *host = func->card->host;
 
 	lbs_deb_enter(LBS_DEB_SDIO);
 
@@ -1022,6 +1025,27 @@ static int if_sdio_probe(struct sdio_func *func,
 	if (ret)
 		goto disable;
 
+	/* For 1-bit transfers, we need to enable the interrupt flags in
+	 * the CCCR register. Temporarily set the function number to 0
+	 * for that. */
+	if ((host->caps & MMC_CAP_SDIO_IRQ) &&
+	    (host->ios.bus_width == MMC_BUS_WIDTH_1)) {
+		unsigned int num = func->num;
+		u8 reg;
+
+		func->num = 0;
+		reg = sdio_readb(func, SDIO_CCCR_IF, &ret);
+		if (ret)
+			goto release_int;
+
+		reg |= SDIO_BUS_ECSI | SDIO_BUS_SCSI;
+		sdio_writeb(func, reg, SDIO_CCCR_IF, &ret);
+		if (ret)
+			goto release_int;
+
+		func->num = num;
+	}
+
 	card->ioport = sdio_readb(func, IF_SDIO_IOPORT, &ret);
 	if (ret)
 		goto release_int;
include/linux/mmc/sdio.h +2 -0
index 0ebaef5..329a8fa 100644
@@ -94,6 +94,8 @@
 
 #define  SDIO_BUS_WIDTH_1BIT	0x00
 #define  SDIO_BUS_WIDTH_4BIT	0x02
+#define  SDIO_BUS_ECSI		0x20	/* Enable continuous SPI interrupt */
+#define  SDIO_BUS_SCSI		0x40	/* Support continuous SPI interrupt */
 
 #define  SDIO_BUS_ASYNC_INT	0x20
 
Signature · 1 line
1.7.0
Acked-by on v1 1/1
#1 lore raw
Quoted 3 lines · Daniel Mack

When operating in 1-bit mode, SDAT1 is used as dedicated interrupt line. However, the 8686 will only drive this line when the ECSI and SCSI bits are set in the CCCR_IF register.

While this looks fine enough to me, I don't have enough knowledge of the SDIO stack to know whether or not this would be considered a layering violation or not. Given that I don't think there's an active maintainer for the SDIO subsystem though, I'd say it's fine enough for me...

Any thoughts David since it appears to be at least somewhat SPI related?

Quoted 79 lines

Thanks to Alagu Sankar for pointing me in the right direction.

Cc Alagu Sankar <[email protected]>
Cc Volker Ernst <[email protected]>
Cc Dan Williams <[email protected]>
Cc John W. Linville <[email protected]>
Cc Holger Schurig <[email protected]>
Cc Bing Zhao <[email protected]>
---
 drivers/net/wireless/libertas/if_sdio.c |   24 ++++++++++++++++++++++++
 include/linux/mmc/sdio.h                |    2 ++
 2 files changed, 26 insertions(+), 0 deletions(-)
drivers/net/wireless/libertas/if_sdio.c +24 -0
index 7a73f62..d3170f2 100644
@@ -34,6 +34,8 @@
 #include <linux/mmc/card.h>
 #include <linux/mmc/sdio_func.h>
 #include <linux/mmc/sdio_ids.h>
+#include <linux/mmc/sdio.h>
+#include <linux/mmc/host.h>
 
 #include "host.h"
 #include "decl.h"
@@ -942,6 +944,7 @@ static int if_sdio_probe(struct sdio_func *func,
 	int ret, i;
 	unsigned int model;
 	struct if_sdio_packet *packet;
+	struct mmc_host *host = func->card->host;
 
 	lbs_deb_enter(LBS_DEB_SDIO);
 
@@ -1022,6 +1025,27 @@ static int if_sdio_probe(struct sdio_func *func,
 	if (ret)
 		goto disable;
 
+	/* For 1-bit transfers, we need to enable the interrupt flags in
+	 * the CCCR register. Temporarily set the function number to 0
+	 * for that. */
+	if ((host->caps & MMC_CAP_SDIO_IRQ) &&
+	    (host->ios.bus_width == MMC_BUS_WIDTH_1)) {
+		unsigned int num = func->num;
+		u8 reg;
+
+		func->num = 0;
+		reg = sdio_readb(func, SDIO_CCCR_IF, &ret);
+		if (ret)
+			goto release_int;
+
+		reg |= SDIO_BUS_ECSI | SDIO_BUS_SCSI;
+		sdio_writeb(func, reg, SDIO_CCCR_IF, &ret);
+		if (ret)
+			goto release_int;
+
+		func->num = num;
+	}
+
 	card->ioport = sdio_readb(func, IF_SDIO_IOPORT, &ret);
 	if (ret)
 		goto release_int;
include/linux/mmc/sdio.h +2 -0
index 0ebaef5..329a8fa 100644
@@ -94,6 +94,8 @@
 
 #define  SDIO_BUS_WIDTH_1BIT	0x00
 #define  SDIO_BUS_WIDTH_4BIT	0x02
+#define  SDIO_BUS_ECSI		0x20	/* Enable continuous SPI interrupt */
+#define  SDIO_BUS_SCSI		0x40	/* Support continuous SPI interrupt */
 
 #define  SDIO_BUS_ASYNC_INT	0x20
 
#2 lore raw
Quoted 11 lines · Dan Williams
Quoted 3 lines · Daniel Mack

When operating in 1-bit mode, SDAT1 is used as dedicated interrupt line. However, the 8686 will only drive this line when the ECSI and SCSI bits are set in the CCCR_IF register.

While this looks fine enough to me, I don't have enough knowledge of the SDIO stack to know whether or not this would be considered a layering violation or not. Given that I don't think there's an active maintainer for the SDIO subsystem though, I'd say it's fine enough for me...

Any thoughts David since it appears to be at least somewhat SPI related?

I believe that these bits in question are just abused in this case. The device is not in SPI mode, so according to the specs, the bits shouldn't make any difference. This makes me think that this is specific to libertas, and doesn't belong in any lower level.

Quoted 1 line

Thanks!

Daniel

#3 lore raw
In reply to Daniel Mack

SCSI is read-only. We ideally should be checking this bit and then set the ECSI accordingly, rather than setting both ECSI and SCSI.

- Alagu Sankar

Quoted 87 lines · Daniel Mack

When operating in 1-bit mode, SDAT1 is used as dedicated interrupt line. However, the 8686 will only drive this line when the ECSI and SCSI bits are set in the CCCR_IF register.

Thanks to Alagu Sankar for pointing me in the right direction.

Cc Alagu Sankar <[email protected]>
Cc Volker Ernst <[email protected]>
Cc Dan Williams <[email protected]>
Cc John W. Linville <[email protected]>
Cc Holger Schurig <[email protected]>
Cc Bing Zhao <[email protected]>

---
 drivers/net/wireless/libertas/if_sdio.c |   24 ++++++++++++++++++++++++ include/linux/mmc/sdio.h                |    2 ++

 2 files changed, 26 insertions(+), 0 deletions(-)
drivers/net/wireless/libertas/if_sdio.c +24 -0
index 7a73f62..d3170f2 100644
@@ -34,6 +34,8 @@
  #include <linux/mmc/card.h>
  #include <linux/mmc/sdio_func.h>
  #include <linux/mmc/sdio_ids.h>
+#include <linux/mmc/sdio.h>
+#include <linux/mmc/host.h>
 
  #include "host.h"
  #include "decl.h"
@@ -942,6 +944,7 @@ static int if_sdio_probe(struct sdio_func *func,
        int ret, i;
        unsigned int model;
        struct if_sdio_packet *packet;
+       struct mmc_host *host = func->card->host;
 
        lbs_deb_enter(LBS_DEB_SDIO);
 
@@ -1022,6 +1025,27 @@ static int if_sdio_probe(struct sdio_func *func,
        if (ret)
                goto disable;
 
+       /* For 1-bit transfers, we need to enable the interrupt flags in
+        * the CCCR register. Temporarily set the function number to 0
+        * for that. */
+       if ((host->caps & MMC_CAP_SDIO_IRQ) &&
+           (host->ios.bus_width == MMC_BUS_WIDTH_1)) {
+               unsigned int num = func->num;
+               u8 reg;
+
+               func->num = 0;
+               reg = sdio_readb(func, SDIO_CCCR_IF, &ret);
+               if (ret)
+                       goto release_int;
+
+               reg |= SDIO_BUS_ECSI | SDIO_BUS_SCSI;
+               sdio_writeb(func, reg, SDIO_CCCR_IF, &ret);
+               if (ret)
+                       goto release_int;
+
+               func->num = num;
+       }
+
        card->ioport = sdio_readb(func, IF_SDIO_IOPORT, &ret);
        if (ret)
                goto release_int;
include/linux/mmc/sdio.h +2 -1
index 0ebaef5..329a8fa 100644
@@ -94,6 +94,8 @@
 
  #define  SDIO_BUS_WIDTH_1BIT   0x00
  #define  SDIO_BUS_WIDTH_4BIT   0x02
+#define  SDIO_BUS_ECSI         0x20    /* Enable continuous SPI interrupt */
+#define  SDIO_BUS_SCSI         0x40    /* Support continuous SPI interrupt */
 
  #define  SDIO_BUS_ASYNC_INT    0x20
 
--

1.7.0

#4 lore raw
Quoted 2 lines · Alagu Sankar Vellaichamy

SCSI is read-only. We ideally should be checking this bit and then set the ECSI accordingly, rather than setting both ECSI and SCSI.

Thanks for noticing. However, the libertas chip does not set SCSI, so we have to do it unconditionally. New patch has just been sent.

Daniel

Quoted 88 lines · Daniel Mack
Quoted 87 lines

When operating in 1-bit mode, SDAT1 is used as dedicated interrupt line. However, the 8686 will only drive this line when the ECSI and SCSI bits are set in the CCCR_IF register.

Thanks to Alagu Sankar for pointing me in the right direction.

Cc Alagu Sankar <[email protected]>
Cc Volker Ernst <[email protected]>
Cc Dan Williams <[email protected]>
Cc John W. Linville <[email protected]>
Cc Holger Schurig <[email protected]>
Cc Bing Zhao <[email protected]>

---
 drivers/net/wireless/libertas/if_sdio.c |   24 ++++++++++++++++++++++++ include/linux/mmc/sdio.h                |    2 ++

 2 files changed, 26 insertions(+), 0 deletions(-)
drivers/net/wireless/libertas/if_sdio.c +24 -0
index 7a73f62..d3170f2 100644
@@ -34,6 +34,8 @@
  #include <linux/mmc/card.h>
  #include <linux/mmc/sdio_func.h>
  #include <linux/mmc/sdio_ids.h>
+#include <linux/mmc/sdio.h>
+#include <linux/mmc/host.h>
 
  #include "host.h"
  #include "decl.h"
@@ -942,6 +944,7 @@ static int if_sdio_probe(struct sdio_func *func,
        int ret, i;
        unsigned int model;
        struct if_sdio_packet *packet;
+       struct mmc_host *host = func->card->host;
 
        lbs_deb_enter(LBS_DEB_SDIO);
 
@@ -1022,6 +1025,27 @@ static int if_sdio_probe(struct sdio_func *func,
        if (ret)
                goto disable;
 
+       /* For 1-bit transfers, we need to enable the interrupt flags in
+        * the CCCR register. Temporarily set the function number to 0
+        * for that. */
+       if ((host->caps & MMC_CAP_SDIO_IRQ) &&
+           (host->ios.bus_width == MMC_BUS_WIDTH_1)) {
+               unsigned int num = func->num;
+               u8 reg;
+
+               func->num = 0;
+               reg = sdio_readb(func, SDIO_CCCR_IF, &ret);
+               if (ret)
+                       goto release_int;
+
+               reg |= SDIO_BUS_ECSI | SDIO_BUS_SCSI;
+               sdio_writeb(func, reg, SDIO_CCCR_IF, &ret);
+               if (ret)
+                       goto release_int;
+
+               func->num = num;
+       }
+
        card->ioport = sdio_readb(func, IF_SDIO_IOPORT, &ret);
        if (ret)
                goto release_int;
include/linux/mmc/sdio.h +2 -1
index 0ebaef5..329a8fa 100644
@@ -94,6 +94,8 @@
 
  #define  SDIO_BUS_WIDTH_1BIT   0x00
  #define  SDIO_BUS_WIDTH_4BIT   0x02
+#define  SDIO_BUS_ECSI         0x20    /* Enable continuous SPI interrupt */
+#define  SDIO_BUS_SCSI         0x40    /* Support continuous SPI interrupt */
 
  #define  SDIO_BUS_ASYNC_INT    0x20
 
--

1.7.0

#5 lore raw
In reply to Daniel Mack

2010/3/30 Daniel Mack <[email protected]>:
[...]

Quoted 18 lines
drivers/net/wireless/libertas/if_sdio.c +14 -0
@@ -1022,6 +1025,27 @@ static int if_sdio_probe(struct sdio_func *func,
        if (ret)
                goto disable;
 
+       /* For 1-bit transfers, we need to enable the interrupt flags in
+        * the CCCR register. Temporarily set the function number to 0
+        * for that. */
+       if ((host->caps & MMC_CAP_SDIO_IRQ) &&
+           (host->ios.bus_width == MMC_BUS_WIDTH_1)) {
+               unsigned int num = func->num;
+               u8 reg;
+
+               func->num = 0;
+               reg = sdio_readb(func, SDIO_CCCR_IF, &ret);
+               if (ret)
+                       goto release_int;
+
+               reg |= SDIO_BUS_ECSI | SDIO_BUS_SCSI;

drivers/net/wireless/libertas/if_sdio.c static int if_sdio_probe(struct sdio_func *func, · line 1051

Quoted 10 lines
drivers/net/wireless/libertas/if_sdio.c +7 -0
+               sdio_writeb(func, reg, SDIO_CCCR_IF, &ret);
+               if (ret)
+                       goto release_int;
+
+               func->num = num;
+       }
+
        card->ioport = sdio_readb(func, IF_SDIO_IOPORT, &ret);
        if (ret)
                goto release_int;

You should probably just use mmc_io_rw_direct() in this case instead of abusing func->num.

Best Regards,
Michał Mirosław

#6 lore raw
Quoted 25 lines · Michał Mirosław

2010/3/30 Daniel Mack <[email protected]>:
[...]

Quoted 23 lines
drivers/net/wireless/libertas/if_sdio.c +19 -0
@@ -1022,6 +1025,27 @@ static int if_sdio_probe(struct sdio_func *func,
        if (ret)
                goto disable;
 
+       /* For 1-bit transfers, we need to enable the interrupt flags in
+        * the CCCR register. Temporarily set the function number to 0
+        * for that. */
+       if ((host->caps & MMC_CAP_SDIO_IRQ) &&
+           (host->ios.bus_width == MMC_BUS_WIDTH_1)) {
+               unsigned int num = func->num;
+               u8 reg;
+
+               func->num = 0;
+               reg = sdio_readb(func, SDIO_CCCR_IF, &ret);
+               if (ret)
+                       goto release_int;
+
+               reg |= SDIO_BUS_ECSI | SDIO_BUS_SCSI;
+               sdio_writeb(func, reg, SDIO_CCCR_IF, &ret);
+               if (ret)
+                       goto release_int;
+
+               func->num = num;
Quoted 8 lines

drivers/net/wireless/libertas/if_sdio.c static int if_sdio_probe(struct sdio_func *func, · line 1051

Quoted 5 lines
drivers/net/wireless/libertas/if_sdio.c +2 -0
+       }
+
        card->ioport = sdio_readb(func, IF_SDIO_IOPORT, &ret);
        if (ret)
                goto release_int;

You should probably just use mmc_io_rw_direct() in this case instead of abusing func->num.

Hmm, that function isn't exported, and I didn't want to change this. You say you'd prefer that? I can cook up something that does it, no problem.

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

#7 lore raw
Quoted 35 lines · W dniu 31 marca 2010 11:08 użytkownik Daniel Mack <[email protected]> napisał:
Quoted 25 lines · Michał Mirosław

2010/3/30 Daniel Mack <[email protected]>:
[...]

Quoted 23 lines
drivers/net/wireless/libertas/if_sdio.c +19 -0
@@ -1022,6 +1025,27 @@ static int if_sdio_probe(struct sdio_func *func,
        if (ret)
                goto disable;
 
+       /* For 1-bit transfers, we need to enable the interrupt flags in
+        * the CCCR register. Temporarily set the function number to 0
+        * for that. */
+       if ((host->caps & MMC_CAP_SDIO_IRQ) &&
+           (host->ios.bus_width == MMC_BUS_WIDTH_1)) {
+               unsigned int num = func->num;
+               u8 reg;
+
+               func->num = 0;
+               reg = sdio_readb(func, SDIO_CCCR_IF, &ret);
+               if (ret)
+                       goto release_int;
+
+               reg |= SDIO_BUS_ECSI | SDIO_BUS_SCSI;
+               sdio_writeb(func, reg, SDIO_CCCR_IF, &ret);
+               if (ret)
+                       goto release_int;
+
+               func->num = num;
Quoted 8 lines

drivers/net/wireless/libertas/if_sdio.c static int if_sdio_probe(struct sdio_func *func, · line 1051

Quoted 5 lines
drivers/net/wireless/libertas/if_sdio.c +2 -0
+       }
+
        card->ioport = sdio_readb(func, IF_SDIO_IOPORT, &ret);
        if (ret)
                goto release_int;

You should probably just use mmc_io_rw_direct() in this case instead of abusing func->num.

Quoted 2 lines

Hmm, that function isn't exported, and I didn't want to change this. You say you'd prefer that? I can cook up something that does it, no problem.

BTW, I can't see any exported functions to access fn#0 directly from drivers. Maybe it's time to introduce them now - at least CCCR has some vendor-defined parts that drivers may want to access and there is a lot of place in CIS area that can be (ab)used by devices.

Best Regards,
Michał Mirosław

#8 lore raw
Quoted 8 lines · Michał Mirosław
Quoted 2 lines · W dniu 31 marca 2010 11:08 użytkownik Daniel Mack <[email protected]> napisał:

Hmm, that function isn't exported, and I didn't want to change this. You say you'd prefer that? I can cook up something that does it, no problem.

BTW, I can't see any exported functions to access fn#0 directly from drivers. Maybe it's time to introduce them now - at least CCCR has some vendor-defined parts that drivers may want to access and there is a lot of place in CIS area that can be (ab)used by devices.

In fact, there is sdio_f0_{read,write}b() - I overlooked them. Will resend a new patch.

Thanks for checking,
Daniel

#9 lore raw

PATCH 1/1 libertas/sdio: set ECSI bit for 1-bit transfers

In reply to Michał Mirosław

When operating in 1-bit mode, SDAT1 is used as dedicated interrupt line. However, the 8686 will only drive this line when the ECSI bit is set in the CCCR_IF register.

Thanks to Alagu Sankar for pointing me in the right direction.

Cc Alagu Sankar <[email protected]>
Cc Volker Ernst <[email protected]>
Cc Dan Williams <[email protected]>
Cc John W. Linville <[email protected]>
Cc Holger Schurig <[email protected]>
Cc Bing Zhao <[email protected]>
---
 drivers/net/wireless/libertas/if_sdio.c |   21 +++++++++++++++++++++
 include/linux/mmc/sdio.h                |    2 ++
 2 files changed, 23 insertions(+), 0 deletions(-)
drivers/net/wireless/libertas/if_sdio.c +21 -0
index 7a73f62..f89bb8b 100644
@@ -34,6 +34,8 @@
 #include <linux/mmc/card.h>
 #include <linux/mmc/sdio_func.h>
 #include <linux/mmc/sdio_ids.h>
+#include <linux/mmc/sdio.h>
+#include <linux/mmc/host.h>
 
 #include "host.h"
 #include "decl.h"
@@ -942,6 +944,7 @@ static int if_sdio_probe(struct sdio_func *func,
 	int ret, i;
 	unsigned int model;
 	struct if_sdio_packet *packet;
+	struct mmc_host *host = func->card->host;
 
 	lbs_deb_enter(LBS_DEB_SDIO);
 
@@ -1022,6 +1025,24 @@ static int if_sdio_probe(struct sdio_func *func,
 	if (ret)
 		goto disable;
 
+	/* For 1-bit transfers, we need to enable the interrupt flag in
+	 * the CCCR register. Set the MMC_QUIRK_LENIENT_FN0 bit to allow
+	 * access to non-vendor registers. */
+	if ((host->caps & MMC_CAP_SDIO_IRQ) &&
+	    (host->ios.bus_width == MMC_BUS_WIDTH_1)) {
+		u8 reg;
+
+		func->card->quirks |= MMC_QUIRK_LENIENT_FN0;
+		reg = sdio_f0_readb(func, SDIO_CCCR_IF, &ret);
+		if (ret)
+			goto release_int;
+
+		reg |= SDIO_BUS_ECSI;
+		sdio_f0_writeb(func, reg, SDIO_CCCR_IF, &ret);
+		if (ret)
+			goto release_int;
+	}
+
 	card->ioport = sdio_readb(func, IF_SDIO_IOPORT, &ret);
 	if (ret)
 		goto release_int;
include/linux/mmc/sdio.h +2 -0
index 0ebaef5..329a8fa 100644
@@ -94,6 +94,8 @@
 
 #define  SDIO_BUS_WIDTH_1BIT	0x00
 #define  SDIO_BUS_WIDTH_4BIT	0x02
+#define  SDIO_BUS_ECSI		0x20	/* Enable continuous SPI interrupt */
+#define  SDIO_BUS_SCSI		0x40	/* Support continuous SPI interrupt */
 
 #define  SDIO_BUS_ASYNC_INT	0x20
 
Signature · 1 line
1.7.0
#10 lore raw

Re: [PATCH] libertas/sdio: set ECSI bit for 1-bit transfers

Quoted 5 lines · Daniel Mack

When operating in 1-bit mode, SDAT1 is used as dedicated interrupt line. However, the 8686 will only drive this line when the ECSI bit is set in the CCCR_IF register.

Thanks to Alagu Sankar for pointing me in the right direction.

Could you modify the patch to do this *only* for the 8686? Apparently only the 8686 this hardware "quirk" and thus this might have odd side-effects on the 8688 or the 8385.

Check the 'struct if_sdio_card' model member and compare it to IF_SDIO_MODEL_8686 like if_sdio_probe() does.

Thanks!
Dan

Quoted 74 lines
Cc Alagu Sankar <[email protected]>
Cc Volker Ernst <[email protected]>
Cc Dan Williams <[email protected]>
Cc John W. Linville <[email protected]>
Cc Holger Schurig <[email protected]>
Cc Bing Zhao <[email protected]>
---
 drivers/net/wireless/libertas/if_sdio.c |   21 +++++++++++++++++++++
 include/linux/mmc/sdio.h                |    2 ++
 2 files changed, 23 insertions(+), 0 deletions(-)
drivers/net/wireless/libertas/if_sdio.c +21 -0
index 7a73f62..f89bb8b 100644
@@ -34,6 +34,8 @@
 #include <linux/mmc/card.h>
 #include <linux/mmc/sdio_func.h>
 #include <linux/mmc/sdio_ids.h>
+#include <linux/mmc/sdio.h>
+#include <linux/mmc/host.h>
 
 #include "host.h"
 #include "decl.h"
@@ -942,6 +944,7 @@ static int if_sdio_probe(struct sdio_func *func,
 	int ret, i;
 	unsigned int model;
 	struct if_sdio_packet *packet;
+	struct mmc_host *host = func->card->host;
 
 	lbs_deb_enter(LBS_DEB_SDIO);
 
@@ -1022,6 +1025,24 @@ static int if_sdio_probe(struct sdio_func *func,
 	if (ret)
 		goto disable;
 
+	/* For 1-bit transfers, we need to enable the interrupt flag in
+	 * the CCCR register. Set the MMC_QUIRK_LENIENT_FN0 bit to allow
+	 * access to non-vendor registers. */
+	if ((host->caps & MMC_CAP_SDIO_IRQ) &&
+	    (host->ios.bus_width == MMC_BUS_WIDTH_1)) {
+		u8 reg;
+
+		func->card->quirks |= MMC_QUIRK_LENIENT_FN0;
+		reg = sdio_f0_readb(func, SDIO_CCCR_IF, &ret);
+		if (ret)
+			goto release_int;
+
+		reg |= SDIO_BUS_ECSI;
+		sdio_f0_writeb(func, reg, SDIO_CCCR_IF, &ret);
+		if (ret)
+			goto release_int;
+	}
+
 	card->ioport = sdio_readb(func, IF_SDIO_IOPORT, &ret);
 	if (ret)
 		goto release_int;
include/linux/mmc/sdio.h +2 -0
index 0ebaef5..329a8fa 100644
@@ -94,6 +94,8 @@
 
 #define  SDIO_BUS_WIDTH_1BIT	0x00
 #define  SDIO_BUS_WIDTH_4BIT	0x02
+#define  SDIO_BUS_ECSI		0x20	/* Enable continuous SPI interrupt */
+#define  SDIO_BUS_SCSI		0x40	/* Support continuous SPI interrupt */
 
 #define  SDIO_BUS_ASYNC_INT	0x20
 
#11 lore raw

PATCH 1/1 libertas/sdio: 8686: set ECSI bit for 1-bit transfers

When operating in 1-bit mode, SDAT1 is used as dedicated interrupt line. However, the 8686 will only drive this line when the ECSI bit is set in the CCCR_IF register.

Thanks to Alagu Sankar for pointing me in the right direction.

Cc Alagu Sankar <[email protected]>
Cc Volker Ernst <[email protected]>
Cc Dan Williams <[email protected]>
Cc John W. Linville <[email protected]>
Cc Holger Schurig <[email protected]>
Cc Bing Zhao <[email protected]>
---
 drivers/net/wireless/libertas/if_sdio.c |   22 ++++++++++++++++++++++
 include/linux/mmc/sdio.h                |    2 ++
 2 files changed, 24 insertions(+), 0 deletions(-)
drivers/net/wireless/libertas/if_sdio.c +22 -0
index 7a73f62..33206a9 100644
@@ -34,6 +34,8 @@
 #include <linux/mmc/card.h>
 #include <linux/mmc/sdio_func.h>
 #include <linux/mmc/sdio_ids.h>
+#include <linux/mmc/sdio.h>
+#include <linux/mmc/host.h>
 
 #include "host.h"
 #include "decl.h"
@@ -942,6 +944,7 @@ static int if_sdio_probe(struct sdio_func *func,
 	int ret, i;
 	unsigned int model;
 	struct if_sdio_packet *packet;
+	struct mmc_host *host = func->card->host;
 
 	lbs_deb_enter(LBS_DEB_SDIO);
 
@@ -1022,6 +1025,25 @@ static int if_sdio_probe(struct sdio_func *func,
 	if (ret)
 		goto disable;
 
+	/* For 1-bit transfers to the 8686 model, we need to enable the
+	 * interrupt flag in the CCCR register. Set the MMC_QUIRK_LENIENT_FN0
+	 * bit to allow access to non-vendor registers. */
+	if ((card->model == IF_SDIO_MODEL_8686) &&
+	    (host->caps & MMC_CAP_SDIO_IRQ) &&
+	    (host->ios.bus_width == MMC_BUS_WIDTH_1)) {
+		u8 reg;
+
+		func->card->quirks |= MMC_QUIRK_LENIENT_FN0;
+		reg = sdio_f0_readb(func, SDIO_CCCR_IF, &ret);
+		if (ret)
+			goto release_int;
+
+		reg |= SDIO_BUS_ECSI;
+		sdio_f0_writeb(func, reg, SDIO_CCCR_IF, &ret);
+		if (ret)
+			goto release_int;
+	}
+
 	card->ioport = sdio_readb(func, IF_SDIO_IOPORT, &ret);
 	if (ret)
 		goto release_int;
include/linux/mmc/sdio.h +2 -0
index 0ebaef5..329a8fa 100644
@@ -94,6 +94,8 @@
 
 #define  SDIO_BUS_WIDTH_1BIT	0x00
 #define  SDIO_BUS_WIDTH_4BIT	0x02
+#define  SDIO_BUS_ECSI		0x20	/* Enable continuous SPI interrupt */
+#define  SDIO_BUS_SCSI		0x40	/* Support continuous SPI interrupt */
 
 #define  SDIO_BUS_ASYNC_INT	0x20
 
Signature · 1 line
1.7.0.3
Acked-by on v1 1/1
#12 lore raw

Re: [PATCH] libertas/sdio: 8686: set ECSI bit for 1-bit transfers

Quoted 6 lines · Daniel Mack

When operating in 1-bit mode, SDAT1 is used as dedicated interrupt line. However, the 8686 will only drive this line when the ECSI bit is set in the CCCR_IF register.

Thanks to Alagu Sankar for pointing me in the right direction.

Quoted 10 lines
Cc Alagu Sankar <[email protected]>
Cc Volker Ernst <[email protected]>
Cc Dan Williams <[email protected]>
Cc John W. Linville <[email protected]>
Cc Holger Schurig <[email protected]>
Cc Bing Zhao <[email protected]>
Quoted 65 lines
---
 drivers/net/wireless/libertas/if_sdio.c |   22 ++++++++++++++++++++++
 include/linux/mmc/sdio.h                |    2 ++
 2 files changed, 24 insertions(+), 0 deletions(-)
drivers/net/wireless/libertas/if_sdio.c +22 -0
index 7a73f62..33206a9 100644
@@ -34,6 +34,8 @@
 #include <linux/mmc/card.h>
 #include <linux/mmc/sdio_func.h>
 #include <linux/mmc/sdio_ids.h>
+#include <linux/mmc/sdio.h>
+#include <linux/mmc/host.h>
 
 #include "host.h"
 #include "decl.h"
@@ -942,6 +944,7 @@ static int if_sdio_probe(struct sdio_func *func,
 	int ret, i;
 	unsigned int model;
 	struct if_sdio_packet *packet;
+	struct mmc_host *host = func->card->host;
 
 	lbs_deb_enter(LBS_DEB_SDIO);
 
@@ -1022,6 +1025,25 @@ static int if_sdio_probe(struct sdio_func *func,
 	if (ret)
 		goto disable;
 
+	/* For 1-bit transfers to the 8686 model, we need to enable the
+	 * interrupt flag in the CCCR register. Set the MMC_QUIRK_LENIENT_FN0
+	 * bit to allow access to non-vendor registers. */
+	if ((card->model == IF_SDIO_MODEL_8686) &&
+	    (host->caps & MMC_CAP_SDIO_IRQ) &&
+	    (host->ios.bus_width == MMC_BUS_WIDTH_1)) {
+		u8 reg;
+
+		func->card->quirks |= MMC_QUIRK_LENIENT_FN0;
+		reg = sdio_f0_readb(func, SDIO_CCCR_IF, &ret);
+		if (ret)
+			goto release_int;
+
+		reg |= SDIO_BUS_ECSI;
+		sdio_f0_writeb(func, reg, SDIO_CCCR_IF, &ret);
+		if (ret)
+			goto release_int;
+	}
+
 	card->ioport = sdio_readb(func, IF_SDIO_IOPORT, &ret);
 	if (ret)
 		goto release_int;
include/linux/mmc/sdio.h +2 -0
index 0ebaef5..329a8fa 100644
@@ -94,6 +94,8 @@
 
 #define  SDIO_BUS_WIDTH_1BIT	0x00
 #define  SDIO_BUS_WIDTH_4BIT	0x02
+#define  SDIO_BUS_ECSI		0x20	/* Enable continuous SPI interrupt */
+#define  SDIO_BUS_SCSI		0x40	/* Support continuous SPI interrupt */
 
 #define  SDIO_BUS_ASYNC_INT	0x20
 
#13 lore raw

Re: [PATCH] libertas/sdio: 8686: set ECSI bit for 1-bit transfers

Quoted 18 lines · Dan Williams
Quoted 6 lines · Daniel Mack

When operating in 1-bit mode, SDAT1 is used as dedicated interrupt line. However, the 8686 will only drive this line when the ECSI bit is set in the CCCR_IF register.

Thanks to Alagu Sankar for pointing me in the right direction.

Quoted 10 lines
Cc Alagu Sankar <[email protected]>
Cc Volker Ernst <[email protected]>
Cc Dan Williams <[email protected]>
Cc John W. Linville <[email protected]>
Cc Holger Schurig <[email protected]>
Cc Bing Zhao <[email protected]>
Quoted 1 line

Was this picked by anyone?
Just asking because I didn't see it in the wireless-2.6.git yet.

Thanks,
Daniel

Quoted 68 lines
Quoted 66 lines
---
 drivers/net/wireless/libertas/if_sdio.c |   22 ++++++++++++++++++++++
 include/linux/mmc/sdio.h                |    2 ++
 2 files changed, 24 insertions(+), 0 deletions(-)
drivers/net/wireless/libertas/if_sdio.c +22 -0
index 7a73f62..33206a9 100644
@@ -34,6 +34,8 @@
 #include <linux/mmc/card.h>
 #include <linux/mmc/sdio_func.h>
 #include <linux/mmc/sdio_ids.h>
+#include <linux/mmc/sdio.h>
+#include <linux/mmc/host.h>
 
 #include "host.h"
 #include "decl.h"
@@ -942,6 +944,7 @@ static int if_sdio_probe(struct sdio_func *func,
 	int ret, i;
 	unsigned int model;
 	struct if_sdio_packet *packet;
+	struct mmc_host *host = func->card->host;
 
 	lbs_deb_enter(LBS_DEB_SDIO);
 
@@ -1022,6 +1025,25 @@ static int if_sdio_probe(struct sdio_func *func,
 	if (ret)
 		goto disable;
 
+	/* For 1-bit transfers to the 8686 model, we need to enable the
+	 * interrupt flag in the CCCR register. Set the MMC_QUIRK_LENIENT_FN0
+	 * bit to allow access to non-vendor registers. */
+	if ((card->model == IF_SDIO_MODEL_8686) &&
+	    (host->caps & MMC_CAP_SDIO_IRQ) &&
+	    (host->ios.bus_width == MMC_BUS_WIDTH_1)) {
+		u8 reg;
+
+		func->card->quirks |= MMC_QUIRK_LENIENT_FN0;
+		reg = sdio_f0_readb(func, SDIO_CCCR_IF, &ret);
+		if (ret)
+			goto release_int;
+
+		reg |= SDIO_BUS_ECSI;
+		sdio_f0_writeb(func, reg, SDIO_CCCR_IF, &ret);
+		if (ret)
+			goto release_int;
+	}
+
 	card->ioport = sdio_readb(func, IF_SDIO_IOPORT, &ret);
 	if (ret)
 		goto release_int;
include/linux/mmc/sdio.h +2 -0
index 0ebaef5..329a8fa 100644
@@ -94,6 +94,8 @@
 
 #define  SDIO_BUS_WIDTH_1BIT	0x00
 #define  SDIO_BUS_WIDTH_4BIT	0x02
+#define  SDIO_BUS_ECSI		0x20	/* Enable continuous SPI interrupt */
+#define  SDIO_BUS_SCSI		0x40	/* Support continuous SPI interrupt */
 
 #define  SDIO_BUS_ASYNC_INT	0x20
 
#14 lore raw

Re: [PATCH] libertas/sdio: 8686: set ECSI bit for 1-bit transfers

Quoted 19 lines · Daniel Mack
Quoted 18 lines · Dan Williams
Quoted 16 lines · Daniel Mack

When operating in 1-bit mode, SDAT1 is used as dedicated interrupt line. However, the 8686 will only drive this line when the ECSI bit is set in the CCCR_IF register.

Thanks to Alagu Sankar for pointing me in the right direction.

Cc Alagu Sankar <[email protected]>
Cc Volker Ernst <[email protected]>
Cc Dan Williams <[email protected]>
Cc John W. Linville <[email protected]>
Cc Holger Schurig <[email protected]>
Cc Bing Zhao <[email protected]>
Quoted 4 lines
Quoted 1 line

Was this picked by anyone?
Just asking because I didn't see it in the wireless-2.6.git yet.

It is in wireless-next-2.6, queued for 2.6.35.

John

Signature · 2 lines
John W. Linville		Someday the world will need a hero, and you
[email protected]			might be all we have.  Be ready.
#15 lore raw

Re: [PATCH] libertas/sdio: 8686: set ECSI bit for 1-bit transfers

Quoted 5 lines · John W. Linville
Quoted 2 lines · Daniel Mack

Was this picked by anyone?
Just asking because I didn't see it in the wireless-2.6.git yet.

It is in wireless-next-2.6, queued for 2.6.35.

Thanks a lot!

Daniel