Skip to content

Commit b658af7

Browse files
ahunter6storulf
authored andcommitted
mmc: mmc: Add functions to enable / disable the Command Queue
Add helper functions to enable or disable the Command Queue. Signed-off-by: Adrian Hunter <[email protected]> Reviewed-by: Linus Walleij <[email protected]> Signed-off-by: Ulf Hansson <[email protected]>
1 parent 7b410d0 commit b658af7

File tree

5 files changed

+34
-0
lines changed

5 files changed

+34
-0
lines changed

Documentation/mmc/mmc-dev-attrs.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ All attributes are read-only.
3030
rel_sectors Reliable write sector count
3131
ocr Operation Conditions Register
3232
dsr Driver Stage Register
33+
cmdq_en Command Queue enabled: 1 => enabled, 0 => not enabled
3334

3435
Note on Erase Size and Preferred Erase Size:
3536

drivers/mmc/core/mmc.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -790,6 +790,7 @@ MMC_DEV_ATTR(enhanced_area_size, "%u\n", card->ext_csd.enhanced_area_size);
790790
MMC_DEV_ATTR(raw_rpmb_size_mult, "%#x\n", card->ext_csd.raw_rpmb_size_mult);
791791
MMC_DEV_ATTR(rel_sectors, "%#x\n", card->ext_csd.rel_sectors);
792792
MMC_DEV_ATTR(ocr, "%08x\n", card->ocr);
793+
MMC_DEV_ATTR(cmdq_en, "%d\n", card->ext_csd.cmdq_en);
793794

794795
static ssize_t mmc_fwrev_show(struct device *dev,
795796
struct device_attribute *attr,
@@ -845,6 +846,7 @@ static struct attribute *mmc_std_attrs[] = {
845846
&dev_attr_rel_sectors.attr,
846847
&dev_attr_ocr.attr,
847848
&dev_attr_dsr.attr,
849+
&dev_attr_cmdq_en.attr,
848850
NULL,
849851
};
850852
ATTRIBUTE_GROUPS(mmc_std);

drivers/mmc/core/mmc_ops.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -838,3 +838,31 @@ int mmc_can_ext_csd(struct mmc_card *card)
838838
{
839839
return (card && card->csd.mmca_vsn > CSD_SPEC_VER_3);
840840
}
841+
842+
static int mmc_cmdq_switch(struct mmc_card *card, bool enable)
843+
{
844+
u8 val = enable ? EXT_CSD_CMDQ_MODE_ENABLED : 0;
845+
int err;
846+
847+
if (!card->ext_csd.cmdq_support)
848+
return -EOPNOTSUPP;
849+
850+
err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_CMDQ_MODE_EN,
851+
val, card->ext_csd.generic_cmd6_time);
852+
if (!err)
853+
card->ext_csd.cmdq_en = enable;
854+
855+
return err;
856+
}
857+
858+
int mmc_cmdq_enable(struct mmc_card *card)
859+
{
860+
return mmc_cmdq_switch(card, true);
861+
}
862+
EXPORT_SYMBOL_GPL(mmc_cmdq_enable);
863+
864+
int mmc_cmdq_disable(struct mmc_card *card)
865+
{
866+
return mmc_cmdq_switch(card, false);
867+
}
868+
EXPORT_SYMBOL_GPL(mmc_cmdq_disable);

drivers/mmc/core/mmc_ops.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ int mmc_read_bkops_status(struct mmc_card *card);
4646
void mmc_start_bkops(struct mmc_card *card, bool from_exception);
4747
int mmc_can_reset(struct mmc_card *card);
4848
int mmc_flush_cache(struct mmc_card *card);
49+
int mmc_cmdq_enable(struct mmc_card *card);
50+
int mmc_cmdq_disable(struct mmc_card *card);
4951

5052
#endif
5153

include/linux/mmc/card.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ struct mmc_ext_csd {
8989
unsigned int boot_ro_lock; /* ro lock support */
9090
bool boot_ro_lockable;
9191
bool ffu_capable; /* Firmware upgrade support */
92+
bool cmdq_en; /* Command Queue enabled */
9293
bool cmdq_support; /* Command Queue supported */
9394
unsigned int cmdq_depth; /* Command Queue depth */
9495
#define MMC_FIRMWARE_LEN 8

0 commit comments

Comments
 (0)