* [PATCH] mmc: sdio: bind acpi with sdio function device
@ 2013-03-05 3:24 Aaron Lu
2013-03-20 6:00 ` Aaron Lu
2013-03-22 16:27 ` Chris Ball
0 siblings, 2 replies; 3+ messages in thread
From: Aaron Lu @ 2013-03-05 3:24 UTC (permalink / raw)
To: Chris Ball
Cc: Adrian Hunter, Rafael J. Wysocki, linux-mmc, linux-acpi, linux-pm,
Aaron Lu, Aaron Lu
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: Aaron Lu <aaron.lu@intel.com>
Reviewed-by: Adrian Hunter <adrian.hunter@intel.com>
---
drivers/mmc/core/sdio_bus.c | 20 +++++++++++++++++++-
drivers/mmc/host/sdhci-pci.c | 1 +
include/linux/mmc/host.h | 2 ++
3 files changed, 22 insertions(+), 1 deletion(-)
diff --git a/drivers/mmc/core/sdio_bus.c b/drivers/mmc/core/sdio_bus.c
index 5e57048..8d6bb18 100644
--- a/drivers/mmc/core/sdio_bus.c
+++ b/drivers/mmc/core/sdio_bus.c
@@ -16,6 +16,7 @@
#include <linux/export.h>
#include <linux/slab.h>
#include <linux/pm_runtime.h>
+#include <linux/acpi.h>
#include <linux/mmc/card.h>
#include <linux/mmc/host.h>
@@ -299,6 +300,19 @@ struct sdio_func *sdio_alloc_func(struct mmc_card *card)
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.
*/
@@ -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);
+ sdio_acpi_set_handle(func);
ret = device_add(&func->dev);
- if (ret == 0)
+ if (ret == 0) {
sdio_func_set_present(func);
+ acpi_dev_pm_attach(&func->dev, false);
+ }
return ret;
}
@@ -326,6 +343,7 @@ void sdio_remove_func(struct sdio_func *func)
if (!sdio_func_present(func))
return;
+ acpi_dev_pm_detach(&func->dev, false);
device_del(&func->dev);
put_device(&func->dev);
}
diff --git a/drivers/mmc/host/sdhci-pci.c b/drivers/mmc/host/sdhci-pci.c
index c7ccf30..3dee22d 100644
--- a/drivers/mmc/host/sdhci-pci.c
+++ b/drivers/mmc/host/sdhci-pci.c
@@ -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->slotno = slotno;
ret = sdhci_add_host(host);
if (ret)
diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
index d6f20cc..17d7148 100644
--- a/include/linux/mmc/host.h
+++ b/include/linux/mmc/host.h
@@ -361,6 +361,8 @@ struct mmc_host {
unsigned int actual_clock; /* Actual HC clock rate */
+ unsigned int slotno; /* used for sdio acpi binding */
+
unsigned long private[0] ____cacheline_aligned;
};
--
1.8.1.2
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] mmc: sdio: bind acpi with sdio function device
2013-03-05 3:24 [PATCH] mmc: sdio: bind acpi with sdio function device Aaron Lu
@ 2013-03-20 6:00 ` Aaron Lu
2013-03-22 16:27 ` Chris Ball
1 sibling, 0 replies; 3+ messages in thread
From: Aaron Lu @ 2013-03-20 6:00 UTC (permalink / raw)
To: Chris Ball
Cc: Adrian Hunter, Rafael J. Wysocki, linux-mmc, linux-acpi, linux-pm
Hi Chris,
Any comments on this patch?
Thanks,
Aaron
On 03/05/2013 11:24 AM, Aaron Lu wrote:
> 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: Aaron Lu <aaron.lu@intel.com>
> Reviewed-by: Adrian Hunter <adrian.hunter@intel.com>
> ---
> drivers/mmc/core/sdio_bus.c | 20 +++++++++++++++++++-
> drivers/mmc/host/sdhci-pci.c | 1 +
> include/linux/mmc/host.h | 2 ++
> 3 files changed, 22 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mmc/core/sdio_bus.c b/drivers/mmc/core/sdio_bus.c
> index 5e57048..8d6bb18 100644
> --- a/drivers/mmc/core/sdio_bus.c
> +++ b/drivers/mmc/core/sdio_bus.c
> @@ -16,6 +16,7 @@
> #include <linux/export.h>
> #include <linux/slab.h>
> #include <linux/pm_runtime.h>
> +#include <linux/acpi.h>
>
> #include <linux/mmc/card.h>
> #include <linux/mmc/host.h>
> @@ -299,6 +300,19 @@ struct sdio_func *sdio_alloc_func(struct mmc_card *card)
> 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.
> */
> @@ -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);
>
> + sdio_acpi_set_handle(func);
> ret = device_add(&func->dev);
> - if (ret == 0)
> + if (ret == 0) {
> sdio_func_set_present(func);
> + acpi_dev_pm_attach(&func->dev, false);
> + }
>
> return ret;
> }
> @@ -326,6 +343,7 @@ void sdio_remove_func(struct sdio_func *func)
> if (!sdio_func_present(func))
> return;
>
> + acpi_dev_pm_detach(&func->dev, false);
> device_del(&func->dev);
> put_device(&func->dev);
> }
> diff --git a/drivers/mmc/host/sdhci-pci.c b/drivers/mmc/host/sdhci-pci.c
> index c7ccf30..3dee22d 100644
> --- a/drivers/mmc/host/sdhci-pci.c
> +++ b/drivers/mmc/host/sdhci-pci.c
> @@ -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->slotno = slotno;
>
> ret = sdhci_add_host(host);
> if (ret)
> diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
> index d6f20cc..17d7148 100644
> --- a/include/linux/mmc/host.h
> +++ b/include/linux/mmc/host.h
> @@ -361,6 +361,8 @@ struct mmc_host {
>
> unsigned int actual_clock; /* Actual HC clock rate */
>
> + unsigned int slotno; /* used for sdio acpi binding */
> +
> unsigned long private[0] ____cacheline_aligned;
> };
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] mmc: sdio: bind acpi with sdio function device
2013-03-05 3:24 [PATCH] mmc: sdio: bind acpi with sdio function device Aaron Lu
2013-03-20 6:00 ` Aaron Lu
@ 2013-03-22 16:27 ` Chris Ball
1 sibling, 0 replies; 3+ messages in thread
From: Chris Ball @ 2013-03-22 16:27 UTC (permalink / raw)
To: Aaron Lu
Cc: Adrian Hunter, Rafael J. Wysocki, linux-mmc, linux-acpi, linux-pm,
Aaron Lu
Hi Aaron,
On Mon, Mar 04 2013, Aaron Lu wrote:
> 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: Aaron Lu <aaron.lu@intel.com>
> Reviewed-by: Adrian Hunter <adrian.hunter@intel.com>
Thanks, pushed to mmc-next for 3.10.
- Chris.
--
Chris Ball <cjb@laptop.org> <http://printf.net/>
One Laptop Per Child
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-03-22 16:27 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-05 3:24 [PATCH] mmc: sdio: bind acpi with sdio function device Aaron Lu
2013-03-20 6:00 ` Aaron Lu
2013-03-22 16:27 ` Chris Ball
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).