mirror of
https://github.com/u-boot/u-boot.git
synced 2025-05-03 10:17:21 +00:00
mmc: arm_pl180_mmci: add .getcd callback
Add .getcd callback to check is MMC card is present Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
This commit is contained in:
parent
5f256fe71d
commit
5829fe2d59
2 changed files with 26 additions and 2 deletions
|
@ -18,9 +18,10 @@
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#include <mmc.h>
|
#include <mmc.h>
|
||||||
|
|
||||||
#include "arm_pl180_mmci.h"
|
|
||||||
|
|
||||||
#include <asm/io.h>
|
#include <asm/io.h>
|
||||||
|
#include <asm-generic/gpio.h>
|
||||||
|
|
||||||
|
#include "arm_pl180_mmci.h"
|
||||||
|
|
||||||
#ifdef CONFIG_DM_MMC
|
#ifdef CONFIG_DM_MMC
|
||||||
#include <dm.h>
|
#include <dm.h>
|
||||||
|
@ -435,6 +436,8 @@ static int arm_pl180_mmc_probe(struct udevice *dev)
|
||||||
MMC_CLOCK_MAX);
|
MMC_CLOCK_MAX);
|
||||||
host->version2 = dev_get_driver_data(dev);
|
host->version2 = dev_get_driver_data(dev);
|
||||||
|
|
||||||
|
gpio_request_by_name(dev, "cd-gpios", 0, &host->cd_gpio, GPIOD_IS_IN);
|
||||||
|
|
||||||
bus_width = dev_read_u32_default(dev, "bus-width", 1);
|
bus_width = dev_read_u32_default(dev, "bus-width", 1);
|
||||||
switch (bus_width) {
|
switch (bus_width) {
|
||||||
case 8:
|
case 8:
|
||||||
|
@ -477,9 +480,26 @@ static int dm_host_set_ios(struct udevice *dev)
|
||||||
return host_set_ios(mmc);
|
return host_set_ios(mmc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int dm_mmc_getcd(struct udevice *dev)
|
||||||
|
{
|
||||||
|
struct arm_pl180_mmc_plat *pdata = dev_get_platdata(dev);
|
||||||
|
struct mmc *mmc = &pdata->mmc;
|
||||||
|
struct pl180_mmc_host *host = mmc->priv;
|
||||||
|
int value = 1;
|
||||||
|
|
||||||
|
if (dm_gpio_is_valid(&host->cd_gpio)) {
|
||||||
|
value = dm_gpio_get_value(&host->cd_gpio);
|
||||||
|
if (host->cd_inverted)
|
||||||
|
return !value;
|
||||||
|
}
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
static const struct dm_mmc_ops arm_pl180_dm_mmc_ops = {
|
static const struct dm_mmc_ops arm_pl180_dm_mmc_ops = {
|
||||||
.send_cmd = dm_host_request,
|
.send_cmd = dm_host_request,
|
||||||
.set_ios = dm_host_set_ios,
|
.set_ios = dm_host_set_ios,
|
||||||
|
.get_cd = dm_mmc_getcd,
|
||||||
};
|
};
|
||||||
|
|
||||||
static int arm_pl180_mmc_ofdata_to_platdata(struct udevice *dev)
|
static int arm_pl180_mmc_ofdata_to_platdata(struct udevice *dev)
|
||||||
|
|
|
@ -191,6 +191,10 @@ struct pl180_mmc_host {
|
||||||
unsigned int pwr_init;
|
unsigned int pwr_init;
|
||||||
int version2;
|
int version2;
|
||||||
struct mmc_config cfg;
|
struct mmc_config cfg;
|
||||||
|
#ifdef CONFIG_DM_MMC
|
||||||
|
struct gpio_desc cd_gpio;
|
||||||
|
bool cd_inverted;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
int arm_pl180_mmci_init(struct pl180_mmc_host *host, struct mmc **mmc);
|
int arm_pl180_mmci_init(struct pl180_mmc_host *host, struct mmc **mmc);
|
||||||
|
|
Loading…
Add table
Reference in a new issue