tree 8d9558816488311e06a7ad2434e342418f2c79d5
parent a9c4342beb4cd28b3a05c3401195e2536c37c150
author Pierre Ossman <[EMAIL PROTECTED]> Wed, 07 Sep 2005 05:18:55 -0700
committer Linus Torvalds <[EMAIL PROTECTED]> Thu, 08 Sep 2005 06:57:51 -0700

[PATCH] sd: SD 4-bit bus

Infrastructure for 4-bit bus transfers with SD cards.

Signed-off-by: Pierre Ossman <[EMAIL PROTECTED]>
Cc: Russell King <[EMAIL PROTECTED]>
Cc: David Brownell <[EMAIL PROTECTED]>
Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
Signed-off-by: Linus Torvalds <[EMAIL PROTECTED]>

 drivers/mmc/mmc.c            |   36 ++++++++++++++++++++++++++++++++++++
 include/linux/mmc/host.h     |    9 +++++++++
 include/linux/mmc/protocol.h |    7 +++++++
 3 files changed, 52 insertions(+)

diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -335,6 +335,40 @@ static int mmc_select_card(struct mmc_ho
        if (err != MMC_ERR_NONE)
                return err;
 
+       /*
+        * Default bus width is 1 bit.
+        */
+       host->ios.bus_width = MMC_BUS_WIDTH_1;
+
+       /*
+        * We can only change the bus width of the selected
+        * card so therefore we have to put the handling
+        * here.
+        */
+       if (host->caps & MMC_CAP_4_BIT_DATA) {
+               /*
+                * The card is in 1 bit mode by default so
+                * we only need to change if it supports the
+                * wider version.
+                */
+               if (mmc_card_sd(card) &&
+                       (card->scr.bus_widths & SD_SCR_BUS_WIDTH_4)) {
+                       struct mmc_command cmd;
+                       cmd.opcode = SD_APP_SET_BUS_WIDTH;
+                       cmd.arg = SD_BUS_WIDTH_4;
+                       cmd.flags = MMC_RSP_R1;
+
+                       err = mmc_wait_for_app_cmd(host, card->rca, &cmd,
+                               CMD_RETRIES);
+                       if (err != MMC_ERR_NONE)
+                               return err;
+
+                       host->ios.bus_width = MMC_BUS_WIDTH_4;
+               }
+       }
+
+       host->ops->set_ios(host, &host->ios);
+
        return MMC_ERR_NONE;
 }
 
@@ -653,6 +687,7 @@ static void mmc_power_up(struct mmc_host
        host->ios.bus_mode = MMC_BUSMODE_OPENDRAIN;
        host->ios.chip_select = MMC_CS_DONTCARE;
        host->ios.power_mode = MMC_POWER_UP;
+       host->ios.bus_width = MMC_BUS_WIDTH_1;
        host->ops->set_ios(host, &host->ios);
 
        mmc_delay(1);
@@ -671,6 +706,7 @@ static void mmc_power_off(struct mmc_hos
        host->ios.bus_mode = MMC_BUSMODE_OPENDRAIN;
        host->ios.chip_select = MMC_CS_DONTCARE;
        host->ios.power_mode = MMC_POWER_OFF;
+       host->ios.bus_width = MMC_BUS_WIDTH_1;
        host->ops->set_ios(host, &host->ios);
 }
 
diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
--- a/include/linux/mmc/host.h
+++ b/include/linux/mmc/host.h
@@ -57,6 +57,11 @@ struct mmc_ios {
 #define MMC_POWER_OFF          0
 #define MMC_POWER_UP           1
 #define MMC_POWER_ON           2
+
+       unsigned char   bus_width;              /* data bus width */
+
+#define MMC_BUS_WIDTH_1                0
+#define MMC_BUS_WIDTH_4                2
 };
 
 struct mmc_host_ops {
@@ -77,6 +82,10 @@ struct mmc_host {
        unsigned int            f_max;
        u32                     ocr_avail;
 
+       unsigned long           caps;           /* Host capabilities */
+
+#define MMC_CAP_4_BIT_DATA     (1 << 0)        /* Can the host do 4 bit 
transfers */
+
        /* host specific block data */
        unsigned int            max_seg_size;   /* see 
blk_queue_max_segment_size */
        unsigned short          max_hw_segs;    /* see 
blk_queue_max_hw_segments */
diff --git a/include/linux/mmc/protocol.h b/include/linux/mmc/protocol.h
--- a/include/linux/mmc/protocol.h
+++ b/include/linux/mmc/protocol.h
@@ -236,5 +236,12 @@ struct _mmc_csd {
 #define CSD_SPEC_VER_2      2           /* Implements system specification 2.0 
- 2.2 */
 #define CSD_SPEC_VER_3      3           /* Implements system specification 3.1 
*/
 
+
+/*
+ * SD bus widths
+ */
+#define SD_BUS_WIDTH_1      0
+#define SD_BUS_WIDTH_4      2
+
 #endif  /* MMC_MMC_PROTOCOL_H */
 
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to