Commit eed222ac authored by Aaron Lu's avatar Aaron Lu Committed by Chris Ball

mmc: sdio: bind acpi with sdio function device

ACPI spec 5 defined the _ADR encoding for sdio bus as:
High word - slot number (0 based)
Low word  - function number

This patch adds support for binding sdio function device with acpi node,
and if successful, involve acpi into its power management.
Signed-off-by: default avatarAaron Lu <aaron.lu@intel.com>
Reviewed-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
Signed-off-by: default avatarChris Ball <cjb@laptop.org>
parent 94144a46
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include <linux/export.h> #include <linux/export.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/pm_runtime.h> #include <linux/pm_runtime.h>
#include <linux/acpi.h>
#include <linux/mmc/card.h> #include <linux/mmc/card.h>
#include <linux/mmc/host.h> #include <linux/mmc/host.h>
...@@ -299,6 +300,19 @@ struct sdio_func *sdio_alloc_func(struct mmc_card *card) ...@@ -299,6 +300,19 @@ struct sdio_func *sdio_alloc_func(struct mmc_card *card)
return func; return func;
} }
#ifdef CONFIG_ACPI
static void sdio_acpi_set_handle(struct sdio_func *func)
{
struct mmc_host *host = func->card->host;
u64 addr = (host->slotno << 16) | func->num;
ACPI_HANDLE_SET(&func->dev,
acpi_get_child(ACPI_HANDLE(host->parent), addr));
}
#else
static inline void sdio_acpi_set_handle(struct sdio_func *func) {}
#endif
/* /*
* Register a new SDIO function with the driver model. * Register a new SDIO function with the driver model.
*/ */
...@@ -308,9 +322,12 @@ int sdio_add_func(struct sdio_func *func) ...@@ -308,9 +322,12 @@ int sdio_add_func(struct sdio_func *func)
dev_set_name(&func->dev, "%s:%d", mmc_card_id(func->card), func->num); dev_set_name(&func->dev, "%s:%d", mmc_card_id(func->card), func->num);
sdio_acpi_set_handle(func);
ret = device_add(&func->dev); ret = device_add(&func->dev);
if (ret == 0) if (ret == 0) {
sdio_func_set_present(func); sdio_func_set_present(func);
acpi_dev_pm_attach(&func->dev, false);
}
return ret; return ret;
} }
...@@ -326,6 +343,7 @@ void sdio_remove_func(struct sdio_func *func) ...@@ -326,6 +343,7 @@ void sdio_remove_func(struct sdio_func *func)
if (!sdio_func_present(func)) if (!sdio_func_present(func))
return; return;
acpi_dev_pm_detach(&func->dev, false);
device_del(&func->dev); device_del(&func->dev);
put_device(&func->dev); put_device(&func->dev);
} }
......
...@@ -1279,6 +1279,7 @@ static struct sdhci_pci_slot *sdhci_pci_probe_slot( ...@@ -1279,6 +1279,7 @@ static struct sdhci_pci_slot *sdhci_pci_probe_slot(
} }
host->mmc->pm_caps = MMC_PM_KEEP_POWER | MMC_PM_WAKE_SDIO_IRQ; host->mmc->pm_caps = MMC_PM_KEEP_POWER | MMC_PM_WAKE_SDIO_IRQ;
host->mmc->slotno = slotno;
ret = sdhci_add_host(host); ret = sdhci_add_host(host);
if (ret) if (ret)
......
...@@ -361,6 +361,8 @@ struct mmc_host { ...@@ -361,6 +361,8 @@ struct mmc_host {
unsigned int actual_clock; /* Actual HC clock rate */ unsigned int actual_clock; /* Actual HC clock rate */
unsigned int slotno; /* used for sdio acpi binding */
unsigned long private[0] ____cacheline_aligned; unsigned long private[0] ____cacheline_aligned;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment