From 42333dc28233c9bb8c2e47a3898abcaee2322eab Mon Sep 17 00:00:00 2001 From: Frank Li Date: Sun, 11 Apr 2021 21:50:21 +0800 Subject: [PATCH] driver: usdhc: add option to disable 1.8v When 1.8V is disabled, sdhc can only communicate at low speed. But this can save the external circuit for switching between 3.3V and 1.8V, which is very practical in costdown scenarios. Signed-off-by: Frank Li --- drivers/disk/usdhc.c | 18 +++++++++++++----- dts/bindings/mmc/nxp,imx-usdhc.yaml | 7 +++++++ 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/drivers/disk/usdhc.c b/drivers/disk/usdhc.c index 8f1f6134855..49e3dcadb62 100644 --- a/drivers/disk/usdhc.c +++ b/drivers/disk/usdhc.c @@ -388,6 +388,8 @@ struct usdhc_config { uint8_t detect_pin; gpio_dt_flags_t detect_flags; + bool no_1_8_v; + uint32_t data_timeout; /* Data timeout value */ @@ -2339,8 +2341,10 @@ static int usdhc_sd_init(struct usdhc_priv *priv) /* allow user select the work voltage, if not select, * sdmmc will handle it automatically */ - if (USDHC_SUPPORT_V180_FLAG != SDMMCHOST_NOT_SUPPORT) { - app_cmd_41_arg |= SD_OCR_SWITCH_18_REQ_FLAG; + if (priv->config->no_1_8_v == false) { + if (USDHC_SUPPORT_V180_FLAG != SDMMCHOST_NOT_SUPPORT) { + app_cmd_41_arg |= SD_OCR_SWITCH_18_REQ_FLAG; + } } /* Check card's supported interface condition. */ @@ -2387,9 +2391,12 @@ APP_SEND_OP_COND_AGAIN: if (cmd->response[0U] & SD_OCR_CARD_CAP_FLAG) { priv->card_info.card_flags |= SDHC_HIGH_CAPACITY_FLAG; } - /* 1.8V support */ - if (cmd->response[0U] & SD_OCR_SWITCH_18_ACCEPT_FLAG) { - priv->card_info.card_flags |= SDHC_1800MV_FLAG; + + if (priv->config->no_1_8_v == false) { + /* 1.8V support */ + if (cmd->response[0U] & SD_OCR_SWITCH_18_ACCEPT_FLAG) { + priv->card_info.card_flags |= SDHC_1800MV_FLAG; + } } priv->card_info.raw_ocr = cmd->response[0U]; } else { @@ -2831,6 +2838,7 @@ static int disk_usdhc_init(const struct device *dev) .nusdhc = n, \ DISK_ACCESS_USDHC_INIT_PWR(n) \ DISK_ACCESS_USDHC_INIT_CD(n) \ + .no_1_8_v = DT_INST_PROP(n, no_1_8_v), \ .data_timeout = USDHC_DATA_TIMEOUT, \ .endian = USDHC_LITTLE_ENDIAN, \ .read_watermark = USDHC_READ_WATERMARK_LEVEL, \ diff --git a/dts/bindings/mmc/nxp,imx-usdhc.yaml b/dts/bindings/mmc/nxp,imx-usdhc.yaml index c64cd43ca26..a0c2ada9c69 100644 --- a/dts/bindings/mmc/nxp,imx-usdhc.yaml +++ b/dts/bindings/mmc/nxp,imx-usdhc.yaml @@ -27,5 +27,12 @@ properties: property value should ensure the flags properly describe the signal that is presented to the driver. + no-1-8-v: + type: boolean + required: false + description: + When the external SD card circuit does not support 1.8V, add this + property to disable 1.8v card voltage of SD card controller. + label: required: true