* [PATCH v2 0/3] Add SDHCI ACPI driver
@ 2012-11-23 11:35 Adrian Hunter
2012-11-23 11:35 ` [PATCH v2 1/3] PNPACPI: exclude devices already bound Adrian Hunter
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: Adrian Hunter @ 2012-11-23 11:35 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Rafael J. Wysocki, Chris Ball, mika.westerberg, linux-mmc,
linux-acpi, linux-kernel
Hi
Here is SDHCI ACPI driver.
Changes for v2:
Dropped "PNPACPI: exclude SDHCI devices"
Added "PNPACPI: exclude devices already bound"
Changed dev->acpi_handle to ACPI_HANDLE(dev)
Added Chris' Ack for sdhci-acpi
Adrian Hunter (2):
ACPI: add SDHCI to ACPI platform devices
mmc: sdhci-acpi: add SDHCI ACPI driver
Mika Westerberg (1):
PNPACPI: exclude devices already bound
drivers/acpi/scan.c | 2 +
drivers/mmc/host/Kconfig | 12 ++
drivers/mmc/host/Makefile | 1 +
drivers/mmc/host/sdhci-acpi.c | 304 ++++++++++++++++++++++++++++++++++++++++++
drivers/pnp/pnpacpi/core.c | 4 +
5 files changed, 323 insertions(+)
create mode 100644 drivers/mmc/host/sdhci-acpi.c
Regards
Adrian Hunter
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2 1/3] PNPACPI: exclude devices already bound
2012-11-23 11:35 [PATCH v2 0/3] Add SDHCI ACPI driver Adrian Hunter
@ 2012-11-23 11:35 ` Adrian Hunter
2012-11-23 11:36 ` [PATCH v2 2/3] ACPI: add SDHCI to ACPI platform devices Adrian Hunter
` (2 subsequent siblings)
3 siblings, 0 replies; 7+ messages in thread
From: Adrian Hunter @ 2012-11-23 11:35 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Rafael J. Wysocki, Chris Ball, mika.westerberg, linux-mmc,
linux-acpi, linux-kernel
From: Mika Westerberg <mika.westerberg@linux.intel.com>
This will exclude ACPI platform devices from also being created
as PNP devices.
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
drivers/pnp/pnpacpi/core.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/pnp/pnpacpi/core.c b/drivers/pnp/pnpacpi/core.c
index 26b5d4b..653d563 100644
--- a/drivers/pnp/pnpacpi/core.c
+++ b/drivers/pnp/pnpacpi/core.c
@@ -242,6 +242,10 @@ static int __init pnpacpi_add_device(struct acpi_device *device)
char *pnpid;
struct acpi_hardware_id *id;
+ /* Skip devices that are already bound */
+ if (device->physical_node_count)
+ return 0;
+
/*
* If a PnPacpi device is not present , the device
* driver should not be loaded.
--
1.7.11.7
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 2/3] ACPI: add SDHCI to ACPI platform devices
2012-11-23 11:35 [PATCH v2 0/3] Add SDHCI ACPI driver Adrian Hunter
2012-11-23 11:35 ` [PATCH v2 1/3] PNPACPI: exclude devices already bound Adrian Hunter
@ 2012-11-23 11:36 ` Adrian Hunter
2012-11-23 13:25 ` Mika Westerberg
2012-11-23 11:36 ` [PATCH v2 3/3] mmc: sdhci-acpi: add SDHCI ACPI driver Adrian Hunter
2012-11-23 20:35 ` [PATCH v2 0/3] Add " Rafael J. Wysocki
3 siblings, 1 reply; 7+ messages in thread
From: Adrian Hunter @ 2012-11-23 11:36 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Rafael J. Wysocki, Chris Ball, mika.westerberg, linux-mmc,
linux-acpi, linux-kernel
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
drivers/acpi/scan.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 8c4ac6d..67a7fa6 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -35,6 +35,8 @@ static const char *dummy_hid = "device";
*/
static const struct acpi_device_id acpi_platform_device_ids[] = {
+ { "PNP0D40" },
+
{ }
};
--
1.7.11.7
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 3/3] mmc: sdhci-acpi: add SDHCI ACPI driver
2012-11-23 11:35 [PATCH v2 0/3] Add SDHCI ACPI driver Adrian Hunter
2012-11-23 11:35 ` [PATCH v2 1/3] PNPACPI: exclude devices already bound Adrian Hunter
2012-11-23 11:36 ` [PATCH v2 2/3] ACPI: add SDHCI to ACPI platform devices Adrian Hunter
@ 2012-11-23 11:36 ` Adrian Hunter
2012-11-23 13:27 ` Mika Westerberg
2012-11-23 20:35 ` [PATCH v2 0/3] Add " Rafael J. Wysocki
3 siblings, 1 reply; 7+ messages in thread
From: Adrian Hunter @ 2012-11-23 11:36 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Rafael J. Wysocki, Chris Ball, mika.westerberg, linux-mmc,
linux-acpi, linux-kernel
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Acked-by: Chris Ball <cjb@laptop.org>
---
drivers/mmc/host/Kconfig | 12 ++
drivers/mmc/host/Makefile | 1 +
drivers/mmc/host/sdhci-acpi.c | 304 ++++++++++++++++++++++++++++++++++++++++++
3 files changed, 317 insertions(+)
create mode 100644 drivers/mmc/host/sdhci-acpi.c
diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig
index 9bf10e7..56eac10 100644
--- a/drivers/mmc/host/Kconfig
+++ b/drivers/mmc/host/Kconfig
@@ -81,6 +81,18 @@ config MMC_RICOH_MMC
If unsure, say Y.
+config MMC_SDHCI_ACPI
+ tristate "SDHCI support for ACPI enumerated SDHCI controllers"
+ depends on MMC_SDHCI && ACPI
+ help
+ This selects support for ACPI enumerated SDHCI controllers,
+ identified by ACPI Compatibility ID PNP0D40 or specific
+ ACPI Hardware IDs.
+
+ If you have a controller with this interface, say Y or M here.
+
+ If unsure, say N.
+
config MMC_SDHCI_PLTFM
tristate "SDHCI platform and OF driver helper"
depends on MMC_SDHCI
diff --git a/drivers/mmc/host/Makefile b/drivers/mmc/host/Makefile
index 17ad0a7..0e4960a 100644
--- a/drivers/mmc/host/Makefile
+++ b/drivers/mmc/host/Makefile
@@ -9,6 +9,7 @@ obj-$(CONFIG_MMC_MXS) += mxs-mmc.o
obj-$(CONFIG_MMC_SDHCI) += sdhci.o
obj-$(CONFIG_MMC_SDHCI_PCI) += sdhci-pci.o
obj-$(subst m,y,$(CONFIG_MMC_SDHCI_PCI)) += sdhci-pci-data.o
+obj-$(CONFIG_MMC_SDHCI_ACPI) += sdhci-acpi.o
obj-$(CONFIG_MMC_SDHCI_PXAV3) += sdhci-pxav3.o
obj-$(CONFIG_MMC_SDHCI_PXAV2) += sdhci-pxav2.o
obj-$(CONFIG_MMC_SDHCI_S3C) += sdhci-s3c.o
diff --git a/drivers/mmc/host/sdhci-acpi.c b/drivers/mmc/host/sdhci-acpi.c
new file mode 100644
index 0000000..6ac3617
--- /dev/null
+++ b/drivers/mmc/host/sdhci-acpi.c
@@ -0,0 +1,304 @@
+/*
+ * Secure Digital Host Controller Interface ACPI driver.
+ *
+ * Copyright (c) 2012, Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+
+#include <linux/init.h>
+#include <linux/export.h>
+#include <linux/module.h>
+#include <linux/device.h>
+#include <linux/platform_device.h>
+#include <linux/ioport.h>
+#include <linux/io.h>
+#include <linux/dma-mapping.h>
+#include <linux/compiler.h>
+#include <linux/stddef.h>
+#include <linux/bitops.h>
+#include <linux/types.h>
+#include <linux/err.h>
+#include <linux/interrupt.h>
+#include <linux/acpi.h>
+#include <linux/pm.h>
+#include <linux/pm_runtime.h>
+
+#include <linux/mmc/host.h>
+#include <linux/mmc/pm.h>
+#include <linux/mmc/sdhci.h>
+
+#include "sdhci.h"
+
+enum {
+ SDHCI_ACPI_SD_CD = BIT(0),
+ SDHCI_ACPI_RUNTIME_PM = BIT(1),
+};
+
+struct sdhci_acpi_chip {
+ const struct sdhci_ops *ops;
+ unsigned int quirks;
+ unsigned int quirks2;
+ unsigned long caps;
+ unsigned int caps2;
+ mmc_pm_flag_t pm_caps;
+};
+
+struct sdhci_acpi_slot {
+ const struct sdhci_acpi_chip *chip;
+ unsigned int quirks;
+ unsigned int quirks2;
+ unsigned long caps;
+ unsigned int caps2;
+ mmc_pm_flag_t pm_caps;
+ unsigned int flags;
+};
+
+struct sdhci_acpi_host {
+ struct sdhci_host *host;
+ const struct sdhci_acpi_slot *slot;
+ struct platform_device *pdev;
+ bool use_runtime_pm;
+};
+
+static inline bool sdhci_acpi_flag(struct sdhci_acpi_host *c, unsigned int flag)
+{
+ return c->slot && (c->slot->flags & flag);
+}
+
+static int sdhci_acpi_enable_dma(struct sdhci_host *host)
+{
+ return 0;
+}
+
+static const struct sdhci_ops sdhci_acpi_ops_dflt = {
+ .enable_dma = sdhci_acpi_enable_dma,
+};
+
+static const struct acpi_device_id sdhci_acpi_ids[] = {
+ { "PNP0D40" },
+ { },
+};
+MODULE_DEVICE_TABLE(acpi, sdhci_acpi_ids);
+
+static const struct sdhci_acpi_slot *sdhci_acpi_get_slot(const char *hid)
+{
+ const struct acpi_device_id *id;
+
+ for (id = sdhci_acpi_ids; id->id[0]; id++)
+ if (!strcmp(id->id, hid))
+ return (const struct sdhci_acpi_slot *)id->driver_data;
+ return NULL;
+}
+
+static int __devinit sdhci_acpi_probe(struct platform_device *pdev)
+{
+ struct device *dev = &pdev->dev;
+ acpi_handle handle = ACPI_HANDLE(dev);
+ struct acpi_device *device;
+ struct sdhci_acpi_host *c;
+ struct sdhci_host *host;
+ struct resource *iomem;
+ resource_size_t len;
+ const char *hid;
+ int err;
+
+ if (acpi_bus_get_device(handle, &device))
+ return -ENODEV;
+
+ if (acpi_bus_get_status(device) || !device->status.present)
+ return -ENODEV;
+
+ hid = acpi_device_hid(device);
+
+ iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ if (!iomem)
+ return -ENOMEM;
+
+ len = resource_size(iomem);
+ if (len < 0x100)
+ dev_err(dev, "Invalid iomem size!\n");
+
+ if (!devm_request_mem_region(dev, iomem->start, len, dev_name(dev)))
+ return -ENOMEM;
+
+ host = sdhci_alloc_host(dev, sizeof(struct sdhci_acpi_host));
+ if (IS_ERR(host))
+ return PTR_ERR(host);
+
+ c = sdhci_priv(host);
+ c->host = host;
+ c->slot = sdhci_acpi_get_slot(hid);
+ c->pdev = pdev;
+ c->use_runtime_pm = sdhci_acpi_flag(c, SDHCI_ACPI_RUNTIME_PM);
+
+ platform_set_drvdata(pdev, c);
+
+ host->hw_name = "ACPI";
+ host->ops = &sdhci_acpi_ops_dflt;
+ host->irq = platform_get_irq(pdev, 0);
+
+ host->ioaddr = devm_ioremap_nocache(dev, iomem->start,
+ resource_size(iomem));
+ if (host->ioaddr == NULL) {
+ err = -ENOMEM;
+ goto err_free;
+ }
+
+ if (!dev->dma_mask) {
+ u64 dma_mask;
+
+ if (sdhci_readl(host, SDHCI_CAPABILITIES) & SDHCI_CAN_64BIT) {
+ /* 64-bit DMA is not supported at present */
+ dma_mask = DMA_BIT_MASK(32);
+ } else {
+ dma_mask = DMA_BIT_MASK(32);
+ }
+
+ dev->dma_mask = &dev->coherent_dma_mask;
+ dev->coherent_dma_mask = dma_mask;
+ }
+
+ if (c->slot) {
+ if (c->slot->chip) {
+ host->ops = c->slot->chip->ops;
+ host->quirks |= c->slot->chip->quirks;
+ host->quirks2 |= c->slot->chip->quirks2;
+ host->mmc->caps |= c->slot->chip->caps;
+ host->mmc->caps2 |= c->slot->chip->caps2;
+ host->mmc->pm_caps |= c->slot->chip->pm_caps;
+ }
+ host->quirks |= c->slot->quirks;
+ host->quirks2 |= c->slot->quirks2;
+ host->mmc->caps |= c->slot->caps;
+ host->mmc->caps2 |= c->slot->caps2;
+ host->mmc->pm_caps |= c->slot->pm_caps;
+ }
+
+ err = sdhci_add_host(host);
+ if (err)
+ goto err_free;
+
+ if (c->use_runtime_pm) {
+ pm_suspend_ignore_children(dev, 1);
+ pm_runtime_set_autosuspend_delay(dev, 50);
+ pm_runtime_use_autosuspend(dev);
+ pm_runtime_enable(dev);
+ }
+
+ return 0;
+
+err_free:
+ platform_set_drvdata(pdev, NULL);
+ sdhci_free_host(c->host);
+ return err;
+}
+
+static int __devexit sdhci_acpi_remove(struct platform_device *pdev)
+{
+ struct sdhci_acpi_host *c = platform_get_drvdata(pdev);
+ struct device *dev = &pdev->dev;
+ int dead;
+
+ if (c->use_runtime_pm) {
+ pm_runtime_get_sync(dev);
+ pm_runtime_disable(dev);
+ pm_runtime_put_noidle(dev);
+ }
+
+ dead = (sdhci_readl(c->host, SDHCI_INT_STATUS) == ~0);
+ sdhci_remove_host(c->host, dead);
+ platform_set_drvdata(pdev, NULL);
+ sdhci_free_host(c->host);
+
+ return 0;
+}
+
+#ifdef CONFIG_PM_SLEEP
+
+static int sdhci_acpi_suspend(struct device *dev)
+{
+ struct sdhci_acpi_host *c = dev_get_drvdata(dev);
+
+ return sdhci_suspend_host(c->host);
+}
+
+static int sdhci_acpi_resume(struct device *dev)
+{
+ struct sdhci_acpi_host *c = dev_get_drvdata(dev);
+
+ return sdhci_resume_host(c->host);
+}
+
+#else
+
+#define sdhci_acpi_suspend NULL
+#define sdhci_acpi_resume NULL
+
+#endif
+
+#ifdef CONFIG_PM_RUNTIME
+
+static int sdhci_acpi_runtime_suspend(struct device *dev)
+{
+ struct sdhci_acpi_host *c = dev_get_drvdata(dev);
+
+ return sdhci_runtime_suspend_host(c->host);
+}
+
+static int sdhci_acpi_runtime_resume(struct device *dev)
+{
+ struct sdhci_acpi_host *c = dev_get_drvdata(dev);
+
+ return sdhci_runtime_resume_host(c->host);
+}
+
+static int sdhci_acpi_runtime_idle(struct device *dev)
+{
+ return 0;
+}
+
+#else
+
+#define sdhci_acpi_runtime_suspend NULL
+#define sdhci_acpi_runtime_resume NULL
+#define sdhci_acpi_runtime_idle NULL
+
+#endif
+
+static const struct dev_pm_ops sdhci_acpi_pm_ops = {
+ .suspend = sdhci_acpi_suspend,
+ .resume = sdhci_acpi_resume,
+ .runtime_suspend = sdhci_acpi_runtime_suspend,
+ .runtime_resume = sdhci_acpi_runtime_resume,
+ .runtime_idle = sdhci_acpi_runtime_idle,
+};
+
+static struct platform_driver sdhci_acpi_driver = {
+ .driver = {
+ .name = "sdhci-acpi",
+ .owner = THIS_MODULE,
+ .acpi_match_table = sdhci_acpi_ids,
+ .pm = &sdhci_acpi_pm_ops,
+ },
+ .probe = sdhci_acpi_probe,
+ .remove = __devexit_p(sdhci_acpi_remove),
+};
+
+module_platform_driver(sdhci_acpi_driver);
+
+MODULE_DESCRIPTION("Secure Digital Host Controller Interface ACPI driver");
+MODULE_AUTHOR("Adrian Hunter");
+MODULE_LICENSE("GPL v2");
--
1.7.11.7
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v2 2/3] ACPI: add SDHCI to ACPI platform devices
2012-11-23 11:36 ` [PATCH v2 2/3] ACPI: add SDHCI to ACPI platform devices Adrian Hunter
@ 2012-11-23 13:25 ` Mika Westerberg
0 siblings, 0 replies; 7+ messages in thread
From: Mika Westerberg @ 2012-11-23 13:25 UTC (permalink / raw)
To: Adrian Hunter
Cc: Rafael J. Wysocki, Rafael J. Wysocki, Chris Ball, linux-mmc,
linux-acpi, linux-kernel
On Fri, Nov 23, 2012 at 01:36:00PM +0200, Adrian Hunter wrote:
> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
> ---
> drivers/acpi/scan.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
> index 8c4ac6d..67a7fa6 100644
> --- a/drivers/acpi/scan.c
> +++ b/drivers/acpi/scan.c
> @@ -35,6 +35,8 @@ static const char *dummy_hid = "device";
> */
> static const struct acpi_device_id acpi_platform_device_ids[] = {
>
> + { "PNP0D40" },
> +
> { }
> };
>
> --
> 1.7.11.7
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 3/3] mmc: sdhci-acpi: add SDHCI ACPI driver
2012-11-23 11:36 ` [PATCH v2 3/3] mmc: sdhci-acpi: add SDHCI ACPI driver Adrian Hunter
@ 2012-11-23 13:27 ` Mika Westerberg
0 siblings, 0 replies; 7+ messages in thread
From: Mika Westerberg @ 2012-11-23 13:27 UTC (permalink / raw)
To: Adrian Hunter
Cc: Rafael J. Wysocki, Rafael J. Wysocki, Chris Ball, linux-mmc,
linux-acpi, linux-kernel
On Fri, Nov 23, 2012 at 01:36:01PM +0200, Adrian Hunter wrote:
> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
> Acked-by: Chris Ball <cjb@laptop.org>
Looks like you left that redundant check in place but it doesn't hurt
anyway.
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 0/3] Add SDHCI ACPI driver
2012-11-23 11:35 [PATCH v2 0/3] Add SDHCI ACPI driver Adrian Hunter
` (2 preceding siblings ...)
2012-11-23 11:36 ` [PATCH v2 3/3] mmc: sdhci-acpi: add SDHCI ACPI driver Adrian Hunter
@ 2012-11-23 20:35 ` Rafael J. Wysocki
3 siblings, 0 replies; 7+ messages in thread
From: Rafael J. Wysocki @ 2012-11-23 20:35 UTC (permalink / raw)
To: Adrian Hunter
Cc: Rafael J. Wysocki, Chris Ball, mika.westerberg, linux-mmc,
linux-acpi, linux-kernel
On Friday, November 23, 2012 01:35:58 PM Adrian Hunter wrote:
> Hi
>
> Here is SDHCI ACPI driver.
>
> Changes for v2:
>
> Dropped "PNPACPI: exclude SDHCI devices"
> Added "PNPACPI: exclude devices already bound"
> Changed dev->acpi_handle to ACPI_HANDLE(dev)
> Added Chris' Ack for sdhci-acpi
>
>
> Adrian Hunter (2):
> ACPI: add SDHCI to ACPI platform devices
> mmc: sdhci-acpi: add SDHCI ACPI driver
>
> Mika Westerberg (1):
> PNPACPI: exclude devices already bound
Applied to linux-pm.git/linux-next as v3.8 material.
Next time, however, I'll really prefer it if your changelogs (1) exist and (2)
are more descriptive than the (existing) ones in this series.
I added the changelogs for you (please check in the tree above if they make
sense), but that's not something I should be doing in general I think.
Thanks,
Rafael
--
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2012-11-23 20:30 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-23 11:35 [PATCH v2 0/3] Add SDHCI ACPI driver Adrian Hunter
2012-11-23 11:35 ` [PATCH v2 1/3] PNPACPI: exclude devices already bound Adrian Hunter
2012-11-23 11:36 ` [PATCH v2 2/3] ACPI: add SDHCI to ACPI platform devices Adrian Hunter
2012-11-23 13:25 ` Mika Westerberg
2012-11-23 11:36 ` [PATCH v2 3/3] mmc: sdhci-acpi: add SDHCI ACPI driver Adrian Hunter
2012-11-23 13:27 ` Mika Westerberg
2012-11-23 20:35 ` [PATCH v2 0/3] Add " Rafael J. Wysocki
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).