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>
This commit is contained in:
parent
0476014ebb
commit
5743ef647f
|
|
@ -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,
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue