summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Zhu <jason.zhu@rock-chips.com>2019-02-22 21:48:53 +0800
committerJianhong Chen <chenjh@rock-chips.com>2019-03-28 15:51:05 +0800
commit5743ef647faabacaf12f7272c027f0ea6dee8557 (patch)
tree642fd5dfccc0ef0a2e21935e337ef5778ba3f9c5
parent0476014ebb59f4b6ab5b30c8b192ebec6ac99655 (diff)
mmc: dw_mmc: support get_cd in struct dm_mmc_ops
Add function get_cd to detect storage device directly instead of detect it by mmc command. Change-Id: I486dee836c62092baabe40fc6de995904849f91d Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
-rw-r--r--drivers/mmc/dw_mmc.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/drivers/mmc/dw_mmc.c b/drivers/mmc/dw_mmc.c
index 3a13b51a41..81981c7911 100644
--- a/drivers/mmc/dw_mmc.c
+++ b/drivers/mmc/dw_mmc.c
@@ -13,6 +13,10 @@
#include <memalign.h>
#include <mmc.h>
#include <dwmmc.h>
+#ifdef CONFIG_DM_GPIO
+#include <asm/gpio.h>
+#include <asm-generic/gpio.h>
+#endif
#define PAGE_SIZE 4096
@@ -623,6 +627,24 @@ static int dwmci_init(struct mmc *mmc)
return 0;
}
+static int dwmci_get_cd(struct udevice *dev)
+{
+ int ret = -1;
+#ifndef CONFIG_SPL_BUILD
+#ifdef CONFIG_DM_GPIO
+ struct gpio_desc detect;
+
+ ret = gpio_request_by_name(dev, "cd-gpios", 0, &detect, GPIOD_IS_IN);
+ if (ret) {
+ return ret;
+ }
+
+ ret = !dm_gpio_get_value(&detect);
+#endif
+#endif
+ return ret;
+}
+
#ifdef CONFIG_DM_MMC
int dwmci_probe(struct udevice *dev)
{
@@ -635,6 +657,7 @@ const struct dm_mmc_ops dm_dwmci_ops = {
.card_busy = dwmci_card_busy,
.send_cmd = dwmci_send_cmd,
.set_ios = dwmci_set_ios,
+ .get_cd = dwmci_get_cd,
.execute_tuning = dwmci_execute_tuning,
};
@@ -643,6 +666,7 @@ static const struct mmc_ops dwmci_ops = {
.card_busy = dwmci_card_busy,
.send_cmd = dwmci_send_cmd,
.set_ios = dwmci_set_ios,
+ .get_cd = dwmci_get_cd,
.init = dwmci_init,
.execute_tuning = dwmci_execute_tuning,
};