mmc: mmc: Add functions to enable / disable the Command Queue
authorAdrian Hunter <adrian.hunter@intel.com>
Mon, 13 Mar 2017 12:36:37 +0000 (14:36 +0200)
committerUlf Hansson <ulf.hansson@linaro.org>
Mon, 24 Apr 2017 19:42:02 +0000 (21:42 +0200)
Add helper functions to enable or disable the Command Queue.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Documentation/mmc/mmc-dev-attrs.txt
drivers/mmc/core/mmc.c
drivers/mmc/core/mmc_ops.c
drivers/mmc/core/mmc_ops.h
include/linux/mmc/card.h

index 404a0e9e92b0c8ea5823271eecc06c965ffaed35..dcd1252877fbad39208f2a04701cbc908b6beb95 100644 (file)
@@ -30,6 +30,7 @@ All attributes are read-only.
        rel_sectors             Reliable write sector count
        ocr                     Operation Conditions Register
        dsr                     Driver Stage Register
+       cmdq_en                 Command Queue enabled: 1 => enabled, 0 => not enabled
 
 Note on Erase Size and Preferred Erase Size:
 
index b502601df228156c60e03e3ddabd64006bd515f7..35b2d0f767cac68df2a12ef7620355c8e7ae57b6 100644 (file)
@@ -790,6 +790,7 @@ MMC_DEV_ATTR(enhanced_area_size, "%u\n", card->ext_csd.enhanced_area_size);
 MMC_DEV_ATTR(raw_rpmb_size_mult, "%#x\n", card->ext_csd.raw_rpmb_size_mult);
 MMC_DEV_ATTR(rel_sectors, "%#x\n", card->ext_csd.rel_sectors);
 MMC_DEV_ATTR(ocr, "%08x\n", card->ocr);
+MMC_DEV_ATTR(cmdq_en, "%d\n", card->ext_csd.cmdq_en);
 
 static ssize_t mmc_fwrev_show(struct device *dev,
                              struct device_attribute *attr,
@@ -845,6 +846,7 @@ static struct attribute *mmc_std_attrs[] = {
        &dev_attr_rel_sectors.attr,
        &dev_attr_ocr.attr,
        &dev_attr_dsr.attr,
+       &dev_attr_cmdq_en.attr,
        NULL,
 };
 ATTRIBUTE_GROUPS(mmc_std);
index fe80f26d69717dd14d357e5563bd6b788e5a5069..24c58d24c19a790c2f848bd9c40a03af9278c73f 100644 (file)
@@ -838,3 +838,31 @@ int mmc_can_ext_csd(struct mmc_card *card)
 {
        return (card && card->csd.mmca_vsn > CSD_SPEC_VER_3);
 }
+
+static int mmc_cmdq_switch(struct mmc_card *card, bool enable)
+{
+       u8 val = enable ? EXT_CSD_CMDQ_MODE_ENABLED : 0;
+       int err;
+
+       if (!card->ext_csd.cmdq_support)
+               return -EOPNOTSUPP;
+
+       err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_CMDQ_MODE_EN,
+                        val, card->ext_csd.generic_cmd6_time);
+       if (!err)
+               card->ext_csd.cmdq_en = enable;
+
+       return err;
+}
+
+int mmc_cmdq_enable(struct mmc_card *card)
+{
+       return mmc_cmdq_switch(card, true);
+}
+EXPORT_SYMBOL_GPL(mmc_cmdq_enable);
+
+int mmc_cmdq_disable(struct mmc_card *card)
+{
+       return mmc_cmdq_switch(card, false);
+}
+EXPORT_SYMBOL_GPL(mmc_cmdq_disable);
index 74beea8a9c7e52e487b40923036cb612bf4322f8..978bd2e60f8a5df8bc28a01cb895652d9b7bd2d8 100644 (file)
@@ -46,6 +46,8 @@ int mmc_read_bkops_status(struct mmc_card *card);
 void mmc_start_bkops(struct mmc_card *card, bool from_exception);
 int mmc_can_reset(struct mmc_card *card);
 int mmc_flush_cache(struct mmc_card *card);
+int mmc_cmdq_enable(struct mmc_card *card);
+int mmc_cmdq_disable(struct mmc_card *card);
 
 #endif
 
index 119ef8f0155c6df4d422e9e994fd52bf9f276088..94637796b99c2eed1438328c2eda3220ed67e6ec 100644 (file)
@@ -89,6 +89,7 @@ struct mmc_ext_csd {
        unsigned int            boot_ro_lock;           /* ro lock support */
        bool                    boot_ro_lockable;
        bool                    ffu_capable;    /* Firmware upgrade support */
+       bool                    cmdq_en;        /* Command Queue enabled */
        bool                    cmdq_support;   /* Command Queue supported */
        unsigned int            cmdq_depth;     /* Command Queue depth */
 #define MMC_FIRMWARE_LEN 8