diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c index 416168f..50068a7 100644 --- a/drivers/mci/mci-core.c +++ b/drivers/mci/mci-core.c @@ -1596,6 +1596,24 @@ device_initcall(mci_init); +int mci_detect_card(struct mci_host *host) +{ + int rc; + + rc = mci_check_if_already_initialized(host->mci); + if (rc != 0) + return 0; + + return mci_card_probe(host->mci); +} + +static int mci_detect(struct device_d *dev) +{ + struct mci *mci = container_of(dev, struct mci, dev); + + return mci_detect_card(mci->host); +} + /** * Create a new mci device (for convenience) * @param host mci_host for this MCI device @@ -1619,6 +1637,9 @@ mci->dev.platform_data = host; mci->dev.parent = host->hw_dev; + mci->host = host; + host->mci = mci; + mci->dev.detect = mci_detect; ret = register_device(&mci->dev); if (ret) diff --git a/include/mci.h b/include/mci.h index 1eb967d..eb8a195 100644 --- a/include/mci.h +++ b/include/mci.h @@ -285,9 +285,12 @@ #define MMC_1_8V_SDR_MODE 4 }; +struct mci; + /** host information */ struct mci_host { struct device_d *hw_dev; /**< the host MCI hardware device */ + struct mci *mci; char *devname; /**< the devicename for the card, defaults to disk%d */ unsigned voltages; unsigned host_caps; /**< Host's interface capabilities, refer MMC_VDD_* */ @@ -308,8 +311,6 @@ int (*card_write_protected)(struct mci_host *); }; -struct mci; - #define MMC_NUM_BOOT_PARTITION 2 #define MMC_NUM_GP_PARTITION 4 #define MMC_NUM_PHY_PARTITION 6 @@ -362,5 +363,6 @@ }; int mci_register(struct mci_host*); +int mci_detect_card(struct mci_host *); #endif /* _MCI_H_ */