xref: /openbmc/linux/drivers/mmc/host/sdhci-acpi.c (revision 45a3fe3b)
1a61127c2SThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only
2c4e05037SAdrian Hunter /*
3c4e05037SAdrian Hunter  * Secure Digital Host Controller Interface ACPI driver.
4c4e05037SAdrian Hunter  *
5c4e05037SAdrian Hunter  * Copyright (c) 2012, Intel Corporation.
6c4e05037SAdrian Hunter  */
7c4e05037SAdrian Hunter 
8c4e05037SAdrian Hunter #include <linux/init.h>
9c4e05037SAdrian Hunter #include <linux/export.h>
10c4e05037SAdrian Hunter #include <linux/module.h>
11c4e05037SAdrian Hunter #include <linux/device.h>
12c4e05037SAdrian Hunter #include <linux/platform_device.h>
13c4e05037SAdrian Hunter #include <linux/ioport.h>
14c4e05037SAdrian Hunter #include <linux/io.h>
15c4e05037SAdrian Hunter #include <linux/dma-mapping.h>
16c4e05037SAdrian Hunter #include <linux/compiler.h>
17c4e05037SAdrian Hunter #include <linux/stddef.h>
18c4e05037SAdrian Hunter #include <linux/bitops.h>
19c4e05037SAdrian Hunter #include <linux/types.h>
20c4e05037SAdrian Hunter #include <linux/err.h>
21c4e05037SAdrian Hunter #include <linux/interrupt.h>
22c4e05037SAdrian Hunter #include <linux/acpi.h>
23c4e05037SAdrian Hunter #include <linux/pm.h>
24c4e05037SAdrian Hunter #include <linux/pm_runtime.h>
25b04fa064SAdrian Hunter #include <linux/delay.h>
2684d49b3dSHans de Goede #include <linux/dmi.h>
27c4e05037SAdrian Hunter 
28c4e05037SAdrian Hunter #include <linux/mmc/host.h>
29c4e05037SAdrian Hunter #include <linux/mmc/pm.h>
304fd4409cSAdrian Hunter #include <linux/mmc/slot-gpio.h>
31c4e05037SAdrian Hunter 
326e1c7d61SAdrian Hunter #ifdef CONFIG_X86
336e1c7d61SAdrian Hunter #include <asm/cpu_device_id.h>
348ba4cb53SDave Hansen #include <asm/intel-family.h>
356e1c7d61SAdrian Hunter #include <asm/iosf_mbi.h>
3617753d16SAdrian Hunter #include <linux/pci.h>
376e1c7d61SAdrian Hunter #endif
386e1c7d61SAdrian Hunter 
39c4e05037SAdrian Hunter #include "sdhci.h"
40c4e05037SAdrian Hunter 
41c4e05037SAdrian Hunter enum {
42c4e05037SAdrian Hunter 	SDHCI_ACPI_SD_CD		= BIT(0),
43c4e05037SAdrian Hunter 	SDHCI_ACPI_RUNTIME_PM		= BIT(1),
444fd4409cSAdrian Hunter 	SDHCI_ACPI_SD_CD_OVERRIDE_LEVEL	= BIT(2),
45c4e05037SAdrian Hunter };
46c4e05037SAdrian Hunter 
47c4e05037SAdrian Hunter struct sdhci_acpi_chip {
48c4e05037SAdrian Hunter 	const struct	sdhci_ops *ops;
49c4e05037SAdrian Hunter 	unsigned int	quirks;
50c4e05037SAdrian Hunter 	unsigned int	quirks2;
51c4e05037SAdrian Hunter 	unsigned long	caps;
52c4e05037SAdrian Hunter 	unsigned int	caps2;
53c4e05037SAdrian Hunter 	mmc_pm_flag_t	pm_caps;
54c4e05037SAdrian Hunter };
55c4e05037SAdrian Hunter 
56c4e05037SAdrian Hunter struct sdhci_acpi_slot {
57c4e05037SAdrian Hunter 	const struct	sdhci_acpi_chip *chip;
58c4e05037SAdrian Hunter 	unsigned int	quirks;
59c4e05037SAdrian Hunter 	unsigned int	quirks2;
60c4e05037SAdrian Hunter 	unsigned long	caps;
61c4e05037SAdrian Hunter 	unsigned int	caps2;
62c4e05037SAdrian Hunter 	mmc_pm_flag_t	pm_caps;
63c4e05037SAdrian Hunter 	unsigned int	flags;
64f07b7952SAdrian Hunter 	size_t		priv_size;
654f3cde3aSAndy Shevchenko 	int (*probe_slot)(struct platform_device *, struct acpi_device *);
66578b36b6SGao, Yunpeng 	int (*remove_slot)(struct platform_device *);
67c7eabbeeSWang Dongsheng 	int (*free_slot)(struct platform_device *pdev);
680cc1a0f4SAdrian Hunter 	int (*setup_host)(struct platform_device *pdev);
69c4e05037SAdrian Hunter };
70c4e05037SAdrian Hunter 
71c4e05037SAdrian Hunter struct sdhci_acpi_host {
72c4e05037SAdrian Hunter 	struct sdhci_host		*host;
73c4e05037SAdrian Hunter 	const struct sdhci_acpi_slot	*slot;
74c4e05037SAdrian Hunter 	struct platform_device		*pdev;
75c4e05037SAdrian Hunter 	bool				use_runtime_pm;
7684d49b3dSHans de Goede 	bool				is_intel;
7784d49b3dSHans de Goede 	bool				reset_signal_volt_on_suspend;
781a91a36aSGustavo A. R. Silva 	unsigned long			private[] ____cacheline_aligned;
79c4e05037SAdrian Hunter };
80c4e05037SAdrian Hunter 
8184d49b3dSHans de Goede enum {
8284d49b3dSHans de Goede 	DMI_QUIRK_RESET_SD_SIGNAL_VOLT_ON_SUSP			= BIT(0),
833397b251SHans de Goede 	DMI_QUIRK_SD_NO_WRITE_PROTECT				= BIT(1),
8484d49b3dSHans de Goede };
8584d49b3dSHans de Goede 
86f07b7952SAdrian Hunter static inline void *sdhci_acpi_priv(struct sdhci_acpi_host *c)
87f07b7952SAdrian Hunter {
88f07b7952SAdrian Hunter 	return (void *)c->private;
89f07b7952SAdrian Hunter }
90f07b7952SAdrian Hunter 
91c4e05037SAdrian Hunter static inline bool sdhci_acpi_flag(struct sdhci_acpi_host *c, unsigned int flag)
92c4e05037SAdrian Hunter {
93c4e05037SAdrian Hunter 	return c->slot && (c->slot->flags & flag);
94c4e05037SAdrian Hunter }
95c4e05037SAdrian Hunter 
960acccf41SAdrian Hunter #define INTEL_DSM_HS_CAPS_SDR25		BIT(0)
970acccf41SAdrian Hunter #define INTEL_DSM_HS_CAPS_DDR50		BIT(1)
980acccf41SAdrian Hunter #define INTEL_DSM_HS_CAPS_SDR50		BIT(2)
990acccf41SAdrian Hunter #define INTEL_DSM_HS_CAPS_SDR104	BIT(3)
1000acccf41SAdrian Hunter 
1011c451c13SAdrian Hunter enum {
1021c451c13SAdrian Hunter 	INTEL_DSM_FNS		=  0,
1031c451c13SAdrian Hunter 	INTEL_DSM_V18_SWITCH	=  3,
1041c451c13SAdrian Hunter 	INTEL_DSM_V33_SWITCH	=  4,
1050acccf41SAdrian Hunter 	INTEL_DSM_HS_CAPS	=  8,
1061c451c13SAdrian Hunter };
1071c451c13SAdrian Hunter 
1081c451c13SAdrian Hunter struct intel_host {
1091c451c13SAdrian Hunter 	u32	dsm_fns;
1100acccf41SAdrian Hunter 	u32	hs_caps;
1111c451c13SAdrian Hunter };
1121c451c13SAdrian Hunter 
1131c451c13SAdrian Hunter static const guid_t intel_dsm_guid =
1141c451c13SAdrian Hunter 	GUID_INIT(0xF6C13EA5, 0x65CD, 0x461F,
1151c451c13SAdrian Hunter 		  0xAB, 0x7A, 0x29, 0xF7, 0xE8, 0xD5, 0xBD, 0x61);
1161c451c13SAdrian Hunter 
1171c451c13SAdrian Hunter static int __intel_dsm(struct intel_host *intel_host, struct device *dev,
1181c451c13SAdrian Hunter 		       unsigned int fn, u32 *result)
1191c451c13SAdrian Hunter {
1201c451c13SAdrian Hunter 	union acpi_object *obj;
1211c451c13SAdrian Hunter 	int err = 0;
1221c451c13SAdrian Hunter 
1231c451c13SAdrian Hunter 	obj = acpi_evaluate_dsm(ACPI_HANDLE(dev), &intel_dsm_guid, 0, fn, NULL);
1241c451c13SAdrian Hunter 	if (!obj)
1251c451c13SAdrian Hunter 		return -EOPNOTSUPP;
1261c451c13SAdrian Hunter 
1271c451c13SAdrian Hunter 	if (obj->type == ACPI_TYPE_INTEGER) {
1281c451c13SAdrian Hunter 		*result = obj->integer.value;
1291c451c13SAdrian Hunter 	} else if (obj->type == ACPI_TYPE_BUFFER && obj->buffer.length > 0) {
1301c451c13SAdrian Hunter 		size_t len = min_t(size_t, obj->buffer.length, 4);
1311c451c13SAdrian Hunter 
1321c451c13SAdrian Hunter 		*result = 0;
1331c451c13SAdrian Hunter 		memcpy(result, obj->buffer.pointer, len);
1341c451c13SAdrian Hunter 	} else {
1351c451c13SAdrian Hunter 		dev_err(dev, "%s DSM fn %u obj->type %d obj->buffer.length %d\n",
1361c451c13SAdrian Hunter 			__func__, fn, obj->type, obj->buffer.length);
1371c451c13SAdrian Hunter 		err = -EINVAL;
1381c451c13SAdrian Hunter 	}
1391c451c13SAdrian Hunter 
1401c451c13SAdrian Hunter 	ACPI_FREE(obj);
1411c451c13SAdrian Hunter 
1421c451c13SAdrian Hunter 	return err;
1431c451c13SAdrian Hunter }
1441c451c13SAdrian Hunter 
1451c451c13SAdrian Hunter static int intel_dsm(struct intel_host *intel_host, struct device *dev,
1461c451c13SAdrian Hunter 		     unsigned int fn, u32 *result)
1471c451c13SAdrian Hunter {
1481c451c13SAdrian Hunter 	if (fn > 31 || !(intel_host->dsm_fns & (1 << fn)))
1491c451c13SAdrian Hunter 		return -EOPNOTSUPP;
1501c451c13SAdrian Hunter 
1511c451c13SAdrian Hunter 	return __intel_dsm(intel_host, dev, fn, result);
1521c451c13SAdrian Hunter }
1531c451c13SAdrian Hunter 
1541c451c13SAdrian Hunter static void intel_dsm_init(struct intel_host *intel_host, struct device *dev,
1551c451c13SAdrian Hunter 			   struct mmc_host *mmc)
1561c451c13SAdrian Hunter {
1571c451c13SAdrian Hunter 	int err;
1581c451c13SAdrian Hunter 
1590acccf41SAdrian Hunter 	intel_host->hs_caps = ~0;
1600acccf41SAdrian Hunter 
1611c451c13SAdrian Hunter 	err = __intel_dsm(intel_host, dev, INTEL_DSM_FNS, &intel_host->dsm_fns);
1621c451c13SAdrian Hunter 	if (err) {
1631c451c13SAdrian Hunter 		pr_debug("%s: DSM not supported, error %d\n",
1641c451c13SAdrian Hunter 			 mmc_hostname(mmc), err);
1651c451c13SAdrian Hunter 		return;
1661c451c13SAdrian Hunter 	}
1671c451c13SAdrian Hunter 
1681c451c13SAdrian Hunter 	pr_debug("%s: DSM function mask %#x\n",
1691c451c13SAdrian Hunter 		 mmc_hostname(mmc), intel_host->dsm_fns);
1700acccf41SAdrian Hunter 
1710acccf41SAdrian Hunter 	intel_dsm(intel_host, dev, INTEL_DSM_HS_CAPS, &intel_host->hs_caps);
1721c451c13SAdrian Hunter }
1731c451c13SAdrian Hunter 
1741c451c13SAdrian Hunter static int intel_start_signal_voltage_switch(struct mmc_host *mmc,
1751c451c13SAdrian Hunter 					     struct mmc_ios *ios)
1761c451c13SAdrian Hunter {
1771c451c13SAdrian Hunter 	struct device *dev = mmc_dev(mmc);
1781c451c13SAdrian Hunter 	struct sdhci_acpi_host *c = dev_get_drvdata(dev);
1791c451c13SAdrian Hunter 	struct intel_host *intel_host = sdhci_acpi_priv(c);
1801c451c13SAdrian Hunter 	unsigned int fn;
1811c451c13SAdrian Hunter 	u32 result = 0;
1821c451c13SAdrian Hunter 	int err;
1831c451c13SAdrian Hunter 
1841c451c13SAdrian Hunter 	err = sdhci_start_signal_voltage_switch(mmc, ios);
1851c451c13SAdrian Hunter 	if (err)
1861c451c13SAdrian Hunter 		return err;
1871c451c13SAdrian Hunter 
1881c451c13SAdrian Hunter 	switch (ios->signal_voltage) {
1891c451c13SAdrian Hunter 	case MMC_SIGNAL_VOLTAGE_330:
1901c451c13SAdrian Hunter 		fn = INTEL_DSM_V33_SWITCH;
1911c451c13SAdrian Hunter 		break;
1921c451c13SAdrian Hunter 	case MMC_SIGNAL_VOLTAGE_180:
1931c451c13SAdrian Hunter 		fn = INTEL_DSM_V18_SWITCH;
1941c451c13SAdrian Hunter 		break;
1951c451c13SAdrian Hunter 	default:
1961c451c13SAdrian Hunter 		return 0;
1971c451c13SAdrian Hunter 	}
1981c451c13SAdrian Hunter 
1991c451c13SAdrian Hunter 	err = intel_dsm(intel_host, dev, fn, &result);
2001c451c13SAdrian Hunter 	pr_debug("%s: %s DSM fn %u error %d result %u\n",
2011c451c13SAdrian Hunter 		 mmc_hostname(mmc), __func__, fn, err, result);
2021c451c13SAdrian Hunter 
2031c451c13SAdrian Hunter 	return 0;
2041c451c13SAdrian Hunter }
2051c451c13SAdrian Hunter 
206b04fa064SAdrian Hunter static void sdhci_acpi_int_hw_reset(struct sdhci_host *host)
207b04fa064SAdrian Hunter {
208b04fa064SAdrian Hunter 	u8 reg;
209b04fa064SAdrian Hunter 
210b04fa064SAdrian Hunter 	reg = sdhci_readb(host, SDHCI_POWER_CONTROL);
211b04fa064SAdrian Hunter 	reg |= 0x10;
212b04fa064SAdrian Hunter 	sdhci_writeb(host, reg, SDHCI_POWER_CONTROL);
213b04fa064SAdrian Hunter 	/* For eMMC, minimum is 1us but give it 9us for good measure */
214b04fa064SAdrian Hunter 	udelay(9);
215b04fa064SAdrian Hunter 	reg &= ~0x10;
216b04fa064SAdrian Hunter 	sdhci_writeb(host, reg, SDHCI_POWER_CONTROL);
217b04fa064SAdrian Hunter 	/* For eMMC, minimum is 200us but give it 300us for good measure */
218b04fa064SAdrian Hunter 	usleep_range(300, 1000);
219b04fa064SAdrian Hunter }
220b04fa064SAdrian Hunter 
221c4e05037SAdrian Hunter static const struct sdhci_ops sdhci_acpi_ops_dflt = {
2221771059cSRussell King 	.set_clock = sdhci_set_clock,
2232317f56cSRussell King 	.set_bus_width = sdhci_set_bus_width,
22403231f9bSRussell King 	.reset = sdhci_reset,
22596d7b78cSRussell King 	.set_uhs_signaling = sdhci_set_uhs_signaling,
226c4e05037SAdrian Hunter };
227c4e05037SAdrian Hunter 
228b04fa064SAdrian Hunter static const struct sdhci_ops sdhci_acpi_ops_int = {
2291771059cSRussell King 	.set_clock = sdhci_set_clock,
2302317f56cSRussell King 	.set_bus_width = sdhci_set_bus_width,
23103231f9bSRussell King 	.reset = sdhci_reset,
23296d7b78cSRussell King 	.set_uhs_signaling = sdhci_set_uhs_signaling,
233b04fa064SAdrian Hunter 	.hw_reset   = sdhci_acpi_int_hw_reset,
234b04fa064SAdrian Hunter };
235b04fa064SAdrian Hunter 
236b04fa064SAdrian Hunter static const struct sdhci_acpi_chip sdhci_acpi_chip_int = {
237b04fa064SAdrian Hunter 	.ops = &sdhci_acpi_ops_int,
238b04fa064SAdrian Hunter };
239b04fa064SAdrian Hunter 
2406e1c7d61SAdrian Hunter #ifdef CONFIG_X86
2416e1c7d61SAdrian Hunter 
2426e1c7d61SAdrian Hunter static bool sdhci_acpi_byt(void)
2436e1c7d61SAdrian Hunter {
2446e1c7d61SAdrian Hunter 	static const struct x86_cpu_id byt[] = {
2451e41eb15SThomas Gleixner 		X86_MATCH_INTEL_FAM6_MODEL(ATOM_SILVERMONT, NULL),
2466e1c7d61SAdrian Hunter 		{}
2476e1c7d61SAdrian Hunter 	};
2486e1c7d61SAdrian Hunter 
2496e1c7d61SAdrian Hunter 	return x86_match_cpu(byt);
2506e1c7d61SAdrian Hunter }
2516e1c7d61SAdrian Hunter 
25217753d16SAdrian Hunter static bool sdhci_acpi_cht(void)
25317753d16SAdrian Hunter {
25417753d16SAdrian Hunter 	static const struct x86_cpu_id cht[] = {
2551e41eb15SThomas Gleixner 		X86_MATCH_INTEL_FAM6_MODEL(ATOM_AIRMONT, NULL),
25617753d16SAdrian Hunter 		{}
25717753d16SAdrian Hunter 	};
25817753d16SAdrian Hunter 
25917753d16SAdrian Hunter 	return x86_match_cpu(cht);
26017753d16SAdrian Hunter }
26117753d16SAdrian Hunter 
2626e1c7d61SAdrian Hunter #define BYT_IOSF_SCCEP			0x63
2636e1c7d61SAdrian Hunter #define BYT_IOSF_OCP_NETCTRL0		0x1078
2646e1c7d61SAdrian Hunter #define BYT_IOSF_OCP_TIMEOUT_BASE	GENMASK(10, 8)
2656e1c7d61SAdrian Hunter 
2666e1c7d61SAdrian Hunter static void sdhci_acpi_byt_setting(struct device *dev)
2676e1c7d61SAdrian Hunter {
2686e1c7d61SAdrian Hunter 	u32 val = 0;
2696e1c7d61SAdrian Hunter 
2706e1c7d61SAdrian Hunter 	if (!sdhci_acpi_byt())
2716e1c7d61SAdrian Hunter 		return;
2726e1c7d61SAdrian Hunter 
2736e1c7d61SAdrian Hunter 	if (iosf_mbi_read(BYT_IOSF_SCCEP, MBI_CR_READ, BYT_IOSF_OCP_NETCTRL0,
2746e1c7d61SAdrian Hunter 			  &val)) {
2756e1c7d61SAdrian Hunter 		dev_err(dev, "%s read error\n", __func__);
2766e1c7d61SAdrian Hunter 		return;
2776e1c7d61SAdrian Hunter 	}
2786e1c7d61SAdrian Hunter 
2796e1c7d61SAdrian Hunter 	if (!(val & BYT_IOSF_OCP_TIMEOUT_BASE))
2806e1c7d61SAdrian Hunter 		return;
2816e1c7d61SAdrian Hunter 
2826e1c7d61SAdrian Hunter 	val &= ~BYT_IOSF_OCP_TIMEOUT_BASE;
2836e1c7d61SAdrian Hunter 
2846e1c7d61SAdrian Hunter 	if (iosf_mbi_write(BYT_IOSF_SCCEP, MBI_CR_WRITE, BYT_IOSF_OCP_NETCTRL0,
2856e1c7d61SAdrian Hunter 			   val)) {
2866e1c7d61SAdrian Hunter 		dev_err(dev, "%s write error\n", __func__);
2876e1c7d61SAdrian Hunter 		return;
2886e1c7d61SAdrian Hunter 	}
2896e1c7d61SAdrian Hunter 
2906e1c7d61SAdrian Hunter 	dev_dbg(dev, "%s completed\n", __func__);
2916e1c7d61SAdrian Hunter }
2926e1c7d61SAdrian Hunter 
2936e1c7d61SAdrian Hunter static bool sdhci_acpi_byt_defer(struct device *dev)
2946e1c7d61SAdrian Hunter {
2956e1c7d61SAdrian Hunter 	if (!sdhci_acpi_byt())
2966e1c7d61SAdrian Hunter 		return false;
2976e1c7d61SAdrian Hunter 
2986e1c7d61SAdrian Hunter 	if (!iosf_mbi_available())
2996e1c7d61SAdrian Hunter 		return true;
3006e1c7d61SAdrian Hunter 
3016e1c7d61SAdrian Hunter 	sdhci_acpi_byt_setting(dev);
3026e1c7d61SAdrian Hunter 
3036e1c7d61SAdrian Hunter 	return false;
3046e1c7d61SAdrian Hunter }
3056e1c7d61SAdrian Hunter 
30617753d16SAdrian Hunter static bool sdhci_acpi_cht_pci_wifi(unsigned int vendor, unsigned int device,
30717753d16SAdrian Hunter 				    unsigned int slot, unsigned int parent_slot)
30817753d16SAdrian Hunter {
30917753d16SAdrian Hunter 	struct pci_dev *dev, *parent, *from = NULL;
31017753d16SAdrian Hunter 
31117753d16SAdrian Hunter 	while (1) {
31217753d16SAdrian Hunter 		dev = pci_get_device(vendor, device, from);
31317753d16SAdrian Hunter 		pci_dev_put(from);
31417753d16SAdrian Hunter 		if (!dev)
31517753d16SAdrian Hunter 			break;
31617753d16SAdrian Hunter 		parent = pci_upstream_bridge(dev);
31717753d16SAdrian Hunter 		if (ACPI_COMPANION(&dev->dev) && PCI_SLOT(dev->devfn) == slot &&
31817753d16SAdrian Hunter 		    parent && PCI_SLOT(parent->devfn) == parent_slot &&
31917753d16SAdrian Hunter 		    !pci_upstream_bridge(parent)) {
32017753d16SAdrian Hunter 			pci_dev_put(dev);
32117753d16SAdrian Hunter 			return true;
32217753d16SAdrian Hunter 		}
32317753d16SAdrian Hunter 		from = dev;
32417753d16SAdrian Hunter 	}
32517753d16SAdrian Hunter 
32617753d16SAdrian Hunter 	return false;
32717753d16SAdrian Hunter }
32817753d16SAdrian Hunter 
32917753d16SAdrian Hunter /*
33017753d16SAdrian Hunter  * GPDwin uses PCI wifi which conflicts with SDIO's use of
33117753d16SAdrian Hunter  * acpi_device_fix_up_power() on child device nodes. Identifying GPDwin is
33217753d16SAdrian Hunter  * problematic, but since SDIO is only used for wifi, the presence of the PCI
33317753d16SAdrian Hunter  * wifi card in the expected slot with an ACPI companion node, is used to
33417753d16SAdrian Hunter  * indicate that acpi_device_fix_up_power() should be avoided.
33517753d16SAdrian Hunter  */
3364f3cde3aSAndy Shevchenko static inline bool sdhci_acpi_no_fixup_child_power(struct acpi_device *adev)
33717753d16SAdrian Hunter {
33817753d16SAdrian Hunter 	return sdhci_acpi_cht() &&
3394f3cde3aSAndy Shevchenko 	       acpi_dev_hid_uid_match(adev, "80860F14", "2") &&
34017753d16SAdrian Hunter 	       sdhci_acpi_cht_pci_wifi(0x14e4, 0x43ec, 0, 28);
34117753d16SAdrian Hunter }
34217753d16SAdrian Hunter 
3436e1c7d61SAdrian Hunter #else
3446e1c7d61SAdrian Hunter 
3456e1c7d61SAdrian Hunter static inline void sdhci_acpi_byt_setting(struct device *dev)
3466e1c7d61SAdrian Hunter {
3476e1c7d61SAdrian Hunter }
3486e1c7d61SAdrian Hunter 
3496e1c7d61SAdrian Hunter static inline bool sdhci_acpi_byt_defer(struct device *dev)
3506e1c7d61SAdrian Hunter {
3516e1c7d61SAdrian Hunter 	return false;
3526e1c7d61SAdrian Hunter }
3536e1c7d61SAdrian Hunter 
3544f3cde3aSAndy Shevchenko static inline bool sdhci_acpi_no_fixup_child_power(struct acpi_device *adev)
35517753d16SAdrian Hunter {
35617753d16SAdrian Hunter 	return false;
35717753d16SAdrian Hunter }
35817753d16SAdrian Hunter 
3596e1c7d61SAdrian Hunter #endif
3606e1c7d61SAdrian Hunter 
3616a645dd8SAdrian Hunter static int bxt_get_cd(struct mmc_host *mmc)
3626a645dd8SAdrian Hunter {
3636a645dd8SAdrian Hunter 	int gpio_cd = mmc_gpio_get_cd(mmc);
3646a645dd8SAdrian Hunter 	struct sdhci_host *host = mmc_priv(mmc);
3656a645dd8SAdrian Hunter 	unsigned long flags;
3666a645dd8SAdrian Hunter 	int ret = 0;
3676a645dd8SAdrian Hunter 
3686a645dd8SAdrian Hunter 	if (!gpio_cd)
3696a645dd8SAdrian Hunter 		return 0;
3706a645dd8SAdrian Hunter 
3716a645dd8SAdrian Hunter 	spin_lock_irqsave(&host->lock, flags);
3726a645dd8SAdrian Hunter 
3736a645dd8SAdrian Hunter 	if (host->flags & SDHCI_DEVICE_DEAD)
3746a645dd8SAdrian Hunter 		goto out;
3756a645dd8SAdrian Hunter 
3766a645dd8SAdrian Hunter 	ret = !!(sdhci_readl(host, SDHCI_PRESENT_STATE) & SDHCI_CARD_PRESENT);
3776a645dd8SAdrian Hunter out:
3786a645dd8SAdrian Hunter 	spin_unlock_irqrestore(&host->lock, flags);
3796a645dd8SAdrian Hunter 
3806a645dd8SAdrian Hunter 	return ret;
3816a645dd8SAdrian Hunter }
3826a645dd8SAdrian Hunter 
3834f3cde3aSAndy Shevchenko static int intel_probe_slot(struct platform_device *pdev, struct acpi_device *adev)
384578b36b6SGao, Yunpeng {
385578b36b6SGao, Yunpeng 	struct sdhci_acpi_host *c = platform_get_drvdata(pdev);
3861c451c13SAdrian Hunter 	struct intel_host *intel_host = sdhci_acpi_priv(c);
387159cd328SAdrian Hunter 	struct sdhci_host *host = c->host;
388578b36b6SGao, Yunpeng 
3894f3cde3aSAndy Shevchenko 	if (acpi_dev_hid_uid_match(adev, "80860F14", "1") &&
3908024379eSAdrian Hunter 	    sdhci_readl(host, SDHCI_CAPABILITIES) == 0x446cc8b2 &&
3918024379eSAdrian Hunter 	    sdhci_readl(host, SDHCI_CAPABILITIES_1) == 0x00000807)
3928024379eSAdrian Hunter 		host->timeout_clk = 1000; /* 1000 kHz i.e. 1 MHz */
3938024379eSAdrian Hunter 
3944f3cde3aSAndy Shevchenko 	if (acpi_dev_hid_uid_match(adev, "80865ACA", NULL))
3956a645dd8SAdrian Hunter 		host->mmc_host_ops.get_cd = bxt_get_cd;
3966a645dd8SAdrian Hunter 
3971c451c13SAdrian Hunter 	intel_dsm_init(intel_host, &pdev->dev, host->mmc);
3981c451c13SAdrian Hunter 
3991c451c13SAdrian Hunter 	host->mmc_host_ops.start_signal_voltage_switch =
4001c451c13SAdrian Hunter 					intel_start_signal_voltage_switch;
4011c451c13SAdrian Hunter 
40284d49b3dSHans de Goede 	c->is_intel = true;
40384d49b3dSHans de Goede 
404578b36b6SGao, Yunpeng 	return 0;
405578b36b6SGao, Yunpeng }
406578b36b6SGao, Yunpeng 
4070acccf41SAdrian Hunter static int intel_setup_host(struct platform_device *pdev)
4080acccf41SAdrian Hunter {
4090acccf41SAdrian Hunter 	struct sdhci_acpi_host *c = platform_get_drvdata(pdev);
4100acccf41SAdrian Hunter 	struct intel_host *intel_host = sdhci_acpi_priv(c);
4110acccf41SAdrian Hunter 
4120acccf41SAdrian Hunter 	if (!(intel_host->hs_caps & INTEL_DSM_HS_CAPS_SDR25))
4130acccf41SAdrian Hunter 		c->host->mmc->caps &= ~MMC_CAP_UHS_SDR25;
4140acccf41SAdrian Hunter 
4150acccf41SAdrian Hunter 	if (!(intel_host->hs_caps & INTEL_DSM_HS_CAPS_SDR50))
4160acccf41SAdrian Hunter 		c->host->mmc->caps &= ~MMC_CAP_UHS_SDR50;
4170acccf41SAdrian Hunter 
4180acccf41SAdrian Hunter 	if (!(intel_host->hs_caps & INTEL_DSM_HS_CAPS_DDR50))
4190acccf41SAdrian Hunter 		c->host->mmc->caps &= ~MMC_CAP_UHS_DDR50;
4200acccf41SAdrian Hunter 
4210acccf41SAdrian Hunter 	if (!(intel_host->hs_caps & INTEL_DSM_HS_CAPS_SDR104))
4220acccf41SAdrian Hunter 		c->host->mmc->caps &= ~MMC_CAP_UHS_SDR104;
4230acccf41SAdrian Hunter 
4240acccf41SAdrian Hunter 	return 0;
4250acccf41SAdrian Hunter }
4260acccf41SAdrian Hunter 
42707a58883SAdrian Hunter static const struct sdhci_acpi_slot sdhci_acpi_slot_int_emmc = {
428b04fa064SAdrian Hunter 	.chip    = &sdhci_acpi_chip_int,
429f25c3372SMaurice Petallo 	.caps    = MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE |
4309d65cb88SAdrian Hunter 		   MMC_CAP_HW_RESET | MMC_CAP_1_8V_DDR |
431c80f275fSAdrian Hunter 		   MMC_CAP_CMD_DURING_TFR | MMC_CAP_WAIT_WHILE_BUSY,
43207a58883SAdrian Hunter 	.flags   = SDHCI_ACPI_RUNTIME_PM,
433197ce1a5SAdrian Hunter 	.quirks  = SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC |
434197ce1a5SAdrian Hunter 		   SDHCI_QUIRK_NO_LED,
435e839b134SAdrian Hunter 	.quirks2 = SDHCI_QUIRK2_PRESET_VALUE_BROKEN |
436e839b134SAdrian Hunter 		   SDHCI_QUIRK2_STOP_WITH_TC |
437e839b134SAdrian Hunter 		   SDHCI_QUIRK2_CAPS_BIT63_FOR_HS400,
438159cd328SAdrian Hunter 	.probe_slot	= intel_probe_slot,
4390acccf41SAdrian Hunter 	.setup_host	= intel_setup_host,
4401c451c13SAdrian Hunter 	.priv_size	= sizeof(struct intel_host),
44107a58883SAdrian Hunter };
44207a58883SAdrian Hunter 
443e5571397SAdrian Hunter static const struct sdhci_acpi_slot sdhci_acpi_slot_int_sdio = {
444e1f5633aSAdrian Hunter 	.quirks  = SDHCI_QUIRK_BROKEN_CARD_DETECTION |
445197ce1a5SAdrian Hunter 		   SDHCI_QUIRK_NO_LED |
446e1f5633aSAdrian Hunter 		   SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC,
447e5571397SAdrian Hunter 	.quirks2 = SDHCI_QUIRK2_HOST_OFF_CARD_ON,
4489d65cb88SAdrian Hunter 	.caps    = MMC_CAP_NONREMOVABLE | MMC_CAP_POWER_OFF_CARD |
449265984b3SAdrian Hunter 		   MMC_CAP_WAIT_WHILE_BUSY,
450e5571397SAdrian Hunter 	.flags   = SDHCI_ACPI_RUNTIME_PM,
451e5571397SAdrian Hunter 	.pm_caps = MMC_PM_KEEP_POWER,
452159cd328SAdrian Hunter 	.probe_slot	= intel_probe_slot,
4530acccf41SAdrian Hunter 	.setup_host	= intel_setup_host,
4541c451c13SAdrian Hunter 	.priv_size	= sizeof(struct intel_host),
455e5571397SAdrian Hunter };
456e5571397SAdrian Hunter 
45707a58883SAdrian Hunter static const struct sdhci_acpi_slot sdhci_acpi_slot_int_sd = {
4584fd4409cSAdrian Hunter 	.flags   = SDHCI_ACPI_SD_CD | SDHCI_ACPI_SD_CD_OVERRIDE_LEVEL |
4594fd4409cSAdrian Hunter 		   SDHCI_ACPI_RUNTIME_PM,
460197ce1a5SAdrian Hunter 	.quirks  = SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC |
461197ce1a5SAdrian Hunter 		   SDHCI_QUIRK_NO_LED,
462934e31b9SAdrian Hunter 	.quirks2 = SDHCI_QUIRK2_CARD_ON_NEEDS_BUS_ON |
463934e31b9SAdrian Hunter 		   SDHCI_QUIRK2_STOP_WITH_TC,
464d3e97407SAzhar Shaikh 	.caps    = MMC_CAP_WAIT_WHILE_BUSY | MMC_CAP_AGGRESSIVE_PM,
465159cd328SAdrian Hunter 	.probe_slot	= intel_probe_slot,
4660acccf41SAdrian Hunter 	.setup_host	= intel_setup_host,
4671c451c13SAdrian Hunter 	.priv_size	= sizeof(struct intel_host),
46807a58883SAdrian Hunter };
46907a58883SAdrian Hunter 
47096ccb858SWang Dongsheng #define VENDOR_SPECIFIC_PWRCTL_CLEAR_REG	0x1a8
47196ccb858SWang Dongsheng #define VENDOR_SPECIFIC_PWRCTL_CTL_REG		0x1ac
47296ccb858SWang Dongsheng static irqreturn_t sdhci_acpi_qcom_handler(int irq, void *ptr)
47396ccb858SWang Dongsheng {
47496ccb858SWang Dongsheng 	struct sdhci_host *host = ptr;
47596ccb858SWang Dongsheng 
47696ccb858SWang Dongsheng 	sdhci_writel(host, 0x3, VENDOR_SPECIFIC_PWRCTL_CLEAR_REG);
47796ccb858SWang Dongsheng 	sdhci_writel(host, 0x1, VENDOR_SPECIFIC_PWRCTL_CTL_REG);
47896ccb858SWang Dongsheng 
47996ccb858SWang Dongsheng 	return IRQ_HANDLED;
48096ccb858SWang Dongsheng }
48196ccb858SWang Dongsheng 
4824f3cde3aSAndy Shevchenko static int qcom_probe_slot(struct platform_device *pdev, struct acpi_device *adev)
48396ccb858SWang Dongsheng {
48496ccb858SWang Dongsheng 	struct sdhci_acpi_host *c = platform_get_drvdata(pdev);
48596ccb858SWang Dongsheng 	struct sdhci_host *host = c->host;
48696ccb858SWang Dongsheng 	int *irq = sdhci_acpi_priv(c);
48796ccb858SWang Dongsheng 
48896ccb858SWang Dongsheng 	*irq = -EINVAL;
48996ccb858SWang Dongsheng 
4904f3cde3aSAndy Shevchenko 	if (!acpi_dev_hid_uid_match(adev, "QCOM8051", NULL))
49196ccb858SWang Dongsheng 		return 0;
49296ccb858SWang Dongsheng 
49396ccb858SWang Dongsheng 	*irq = platform_get_irq(pdev, 1);
49496ccb858SWang Dongsheng 	if (*irq < 0)
49596ccb858SWang Dongsheng 		return 0;
49696ccb858SWang Dongsheng 
49796ccb858SWang Dongsheng 	return request_threaded_irq(*irq, NULL, sdhci_acpi_qcom_handler,
49896ccb858SWang Dongsheng 				    IRQF_ONESHOT | IRQF_TRIGGER_HIGH,
49996ccb858SWang Dongsheng 				    "sdhci_qcom", host);
50096ccb858SWang Dongsheng }
50196ccb858SWang Dongsheng 
50296ccb858SWang Dongsheng static int qcom_free_slot(struct platform_device *pdev)
50396ccb858SWang Dongsheng {
50496ccb858SWang Dongsheng 	struct device *dev = &pdev->dev;
50596ccb858SWang Dongsheng 	struct sdhci_acpi_host *c = platform_get_drvdata(pdev);
50696ccb858SWang Dongsheng 	struct sdhci_host *host = c->host;
50796ccb858SWang Dongsheng 	struct acpi_device *adev;
50896ccb858SWang Dongsheng 	int *irq = sdhci_acpi_priv(c);
50996ccb858SWang Dongsheng 
51096ccb858SWang Dongsheng 	adev = ACPI_COMPANION(dev);
51196ccb858SWang Dongsheng 	if (!adev)
51296ccb858SWang Dongsheng 		return -ENODEV;
51396ccb858SWang Dongsheng 
5144f3cde3aSAndy Shevchenko 	if (!acpi_dev_hid_uid_match(adev, "QCOM8051", NULL))
51596ccb858SWang Dongsheng 		return 0;
51696ccb858SWang Dongsheng 
51796ccb858SWang Dongsheng 	if (*irq < 0)
51896ccb858SWang Dongsheng 		return 0;
51996ccb858SWang Dongsheng 
52096ccb858SWang Dongsheng 	free_irq(*irq, host);
52196ccb858SWang Dongsheng 	return 0;
52296ccb858SWang Dongsheng }
52396ccb858SWang Dongsheng 
52470cce2afSPhilip Elcan static const struct sdhci_acpi_slot sdhci_acpi_slot_qcom_sd_3v = {
52570cce2afSPhilip Elcan 	.quirks  = SDHCI_QUIRK_BROKEN_CARD_DETECTION,
52670cce2afSPhilip Elcan 	.quirks2 = SDHCI_QUIRK2_NO_1_8_V,
52770cce2afSPhilip Elcan 	.caps    = MMC_CAP_NONREMOVABLE,
52896ccb858SWang Dongsheng 	.priv_size	= sizeof(int),
52996ccb858SWang Dongsheng 	.probe_slot	= qcom_probe_slot,
53096ccb858SWang Dongsheng 	.free_slot	= qcom_free_slot,
53170cce2afSPhilip Elcan };
53270cce2afSPhilip Elcan 
53370cce2afSPhilip Elcan static const struct sdhci_acpi_slot sdhci_acpi_slot_qcom_sd = {
53470cce2afSPhilip Elcan 	.quirks  = SDHCI_QUIRK_BROKEN_CARD_DETECTION,
53570cce2afSPhilip Elcan 	.caps    = MMC_CAP_NONREMOVABLE,
53670cce2afSPhilip Elcan };
53770cce2afSPhilip Elcan 
53834597a3fSShah Nehal-Bakulchandra /* AMD sdhci reset dll register. */
53934597a3fSShah Nehal-Bakulchandra #define SDHCI_AMD_RESET_DLL_REGISTER    0x908
54034597a3fSShah Nehal-Bakulchandra 
54134597a3fSShah Nehal-Bakulchandra static int amd_select_drive_strength(struct mmc_card *card,
54234597a3fSShah Nehal-Bakulchandra 				     unsigned int max_dtr, int host_drv,
54334597a3fSShah Nehal-Bakulchandra 				     int card_drv, int *drv_type)
54434597a3fSShah Nehal-Bakulchandra {
54534597a3fSShah Nehal-Bakulchandra 	return MMC_SET_DRIVER_TYPE_A;
54634597a3fSShah Nehal-Bakulchandra }
54734597a3fSShah Nehal-Bakulchandra 
54834597a3fSShah Nehal-Bakulchandra static void sdhci_acpi_amd_hs400_dll(struct sdhci_host *host)
54934597a3fSShah Nehal-Bakulchandra {
55034597a3fSShah Nehal-Bakulchandra 	/* AMD Platform requires dll setting */
55134597a3fSShah Nehal-Bakulchandra 	sdhci_writel(host, 0x40003210, SDHCI_AMD_RESET_DLL_REGISTER);
55234597a3fSShah Nehal-Bakulchandra 	usleep_range(10, 20);
55334597a3fSShah Nehal-Bakulchandra 	sdhci_writel(host, 0x40033210, SDHCI_AMD_RESET_DLL_REGISTER);
55434597a3fSShah Nehal-Bakulchandra }
55534597a3fSShah Nehal-Bakulchandra 
55634597a3fSShah Nehal-Bakulchandra /*
55734597a3fSShah Nehal-Bakulchandra  * For AMD Platform it is required to disable the tuning
55834597a3fSShah Nehal-Bakulchandra  * bit first controller to bring to HS Mode from HS200
55934597a3fSShah Nehal-Bakulchandra  * mode, later enable to tune to HS400 mode.
56034597a3fSShah Nehal-Bakulchandra  */
56134597a3fSShah Nehal-Bakulchandra static void amd_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
56234597a3fSShah Nehal-Bakulchandra {
56334597a3fSShah Nehal-Bakulchandra 	struct sdhci_host *host = mmc_priv(mmc);
56434597a3fSShah Nehal-Bakulchandra 	unsigned int old_timing = host->timing;
56534597a3fSShah Nehal-Bakulchandra 
56634597a3fSShah Nehal-Bakulchandra 	sdhci_set_ios(mmc, ios);
56734597a3fSShah Nehal-Bakulchandra 	if (old_timing == MMC_TIMING_MMC_HS200 &&
56834597a3fSShah Nehal-Bakulchandra 	    ios->timing == MMC_TIMING_MMC_HS)
56934597a3fSShah Nehal-Bakulchandra 		sdhci_writew(host, 0x9, SDHCI_HOST_CONTROL2);
57034597a3fSShah Nehal-Bakulchandra 	if (old_timing != MMC_TIMING_MMC_HS400 &&
57134597a3fSShah Nehal-Bakulchandra 	    ios->timing == MMC_TIMING_MMC_HS400) {
57234597a3fSShah Nehal-Bakulchandra 		sdhci_writew(host, 0x80, SDHCI_HOST_CONTROL2);
57334597a3fSShah Nehal-Bakulchandra 		sdhci_acpi_amd_hs400_dll(host);
57434597a3fSShah Nehal-Bakulchandra 	}
57534597a3fSShah Nehal-Bakulchandra }
57634597a3fSShah Nehal-Bakulchandra 
57734597a3fSShah Nehal-Bakulchandra static const struct sdhci_ops sdhci_acpi_ops_amd = {
57834597a3fSShah Nehal-Bakulchandra 	.set_clock	= sdhci_set_clock,
57934597a3fSShah Nehal-Bakulchandra 	.set_bus_width	= sdhci_set_bus_width,
58034597a3fSShah Nehal-Bakulchandra 	.reset		= sdhci_reset,
58134597a3fSShah Nehal-Bakulchandra 	.set_uhs_signaling = sdhci_set_uhs_signaling,
58234597a3fSShah Nehal-Bakulchandra };
58334597a3fSShah Nehal-Bakulchandra 
58434597a3fSShah Nehal-Bakulchandra static const struct sdhci_acpi_chip sdhci_acpi_chip_amd = {
58534597a3fSShah Nehal-Bakulchandra 	.ops = &sdhci_acpi_ops_amd,
58634597a3fSShah Nehal-Bakulchandra };
58734597a3fSShah Nehal-Bakulchandra 
58834597a3fSShah Nehal-Bakulchandra static int sdhci_acpi_emmc_amd_probe_slot(struct platform_device *pdev,
5894f3cde3aSAndy Shevchenko 					  struct acpi_device *adev)
59034597a3fSShah Nehal-Bakulchandra {
59134597a3fSShah Nehal-Bakulchandra 	struct sdhci_acpi_host *c = platform_get_drvdata(pdev);
59234597a3fSShah Nehal-Bakulchandra 	struct sdhci_host *host   = c->host;
59334597a3fSShah Nehal-Bakulchandra 
59434597a3fSShah Nehal-Bakulchandra 	sdhci_read_caps(host);
59534597a3fSShah Nehal-Bakulchandra 	if (host->caps1 & SDHCI_SUPPORT_DDR50)
59634597a3fSShah Nehal-Bakulchandra 		host->mmc->caps = MMC_CAP_1_8V_DDR;
59734597a3fSShah Nehal-Bakulchandra 
59834597a3fSShah Nehal-Bakulchandra 	if ((host->caps1 & SDHCI_SUPPORT_SDR104) &&
59934597a3fSShah Nehal-Bakulchandra 	    (host->mmc->caps & MMC_CAP_1_8V_DDR))
60034597a3fSShah Nehal-Bakulchandra 		host->mmc->caps2 = MMC_CAP2_HS400_1_8V;
60134597a3fSShah Nehal-Bakulchandra 
60234597a3fSShah Nehal-Bakulchandra 	host->mmc_host_ops.select_drive_strength = amd_select_drive_strength;
60334597a3fSShah Nehal-Bakulchandra 	host->mmc_host_ops.set_ios = amd_set_ios;
60434597a3fSShah Nehal-Bakulchandra 	return 0;
60534597a3fSShah Nehal-Bakulchandra }
60634597a3fSShah Nehal-Bakulchandra 
60734597a3fSShah Nehal-Bakulchandra static const struct sdhci_acpi_slot sdhci_acpi_slot_amd_emmc = {
60834597a3fSShah Nehal-Bakulchandra 	.chip		= &sdhci_acpi_chip_amd,
60934597a3fSShah Nehal-Bakulchandra 	.caps		= MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE,
61045a3fe3bSRaul E Rangel 	.quirks		= SDHCI_QUIRK_32BIT_DMA_ADDR |
61145a3fe3bSRaul E Rangel 			  SDHCI_QUIRK_32BIT_DMA_SIZE |
61234597a3fSShah Nehal-Bakulchandra 			  SDHCI_QUIRK_32BIT_ADMA_SIZE,
61345a3fe3bSRaul E Rangel 	.quirks2	= SDHCI_QUIRK2_BROKEN_64_BIT_DMA,
61434597a3fSShah Nehal-Bakulchandra 	.probe_slot     = sdhci_acpi_emmc_amd_probe_slot,
61534597a3fSShah Nehal-Bakulchandra };
61634597a3fSShah Nehal-Bakulchandra 
61707a58883SAdrian Hunter struct sdhci_acpi_uid_slot {
61807a58883SAdrian Hunter 	const char *hid;
61907a58883SAdrian Hunter 	const char *uid;
62007a58883SAdrian Hunter 	const struct sdhci_acpi_slot *slot;
62107a58883SAdrian Hunter };
62207a58883SAdrian Hunter 
62307a58883SAdrian Hunter static const struct sdhci_acpi_uid_slot sdhci_acpi_uids[] = {
624e839b134SAdrian Hunter 	{ "80865ACA", NULL, &sdhci_acpi_slot_int_sd },
625e839b134SAdrian Hunter 	{ "80865ACC", NULL, &sdhci_acpi_slot_int_emmc },
626e839b134SAdrian Hunter 	{ "80865AD0", NULL, &sdhci_acpi_slot_int_sdio },
62707a58883SAdrian Hunter 	{ "80860F14" , "1" , &sdhci_acpi_slot_int_emmc },
628db52d4f8SDaniel Drake 	{ "80860F14" , "2" , &sdhci_acpi_slot_int_sdio },
62907a58883SAdrian Hunter 	{ "80860F14" , "3" , &sdhci_acpi_slot_int_sd   },
630aad95dc4SAdrian Hunter 	{ "80860F16" , NULL, &sdhci_acpi_slot_int_sd   },
63107a58883SAdrian Hunter 	{ "INT33BB"  , "2" , &sdhci_acpi_slot_int_sdio },
6327147eaf3SAdrian Hunter 	{ "INT33BB"  , "3" , &sdhci_acpi_slot_int_sd },
63307a58883SAdrian Hunter 	{ "INT33C6"  , NULL, &sdhci_acpi_slot_int_sdio },
63407c001c1SMika Westerberg 	{ "INT3436"  , NULL, &sdhci_acpi_slot_int_sdio },
635d0ed8e6bSAdrian Hunter 	{ "INT344D"  , NULL, &sdhci_acpi_slot_int_sdio },
6360cd2f044SMichele Curti 	{ "PNP0FFF"  , "3" , &sdhci_acpi_slot_int_sd   },
63707a58883SAdrian Hunter 	{ "PNP0D40"  },
63870cce2afSPhilip Elcan 	{ "QCOM8051", NULL, &sdhci_acpi_slot_qcom_sd_3v },
63970cce2afSPhilip Elcan 	{ "QCOM8052", NULL, &sdhci_acpi_slot_qcom_sd },
64034597a3fSShah Nehal-Bakulchandra 	{ "AMDI0040", NULL, &sdhci_acpi_slot_amd_emmc },
64107a58883SAdrian Hunter 	{ },
64207a58883SAdrian Hunter };
64307a58883SAdrian Hunter 
644c4e05037SAdrian Hunter static const struct acpi_device_id sdhci_acpi_ids[] = {
645e839b134SAdrian Hunter 	{ "80865ACA" },
646e839b134SAdrian Hunter 	{ "80865ACC" },
647e839b134SAdrian Hunter 	{ "80865AD0" },
64807a58883SAdrian Hunter 	{ "80860F14" },
649aad95dc4SAdrian Hunter 	{ "80860F16" },
65007a58883SAdrian Hunter 	{ "INT33BB"  },
65107a58883SAdrian Hunter 	{ "INT33C6"  },
65207c001c1SMika Westerberg 	{ "INT3436"  },
653d0ed8e6bSAdrian Hunter 	{ "INT344D"  },
654c4e05037SAdrian Hunter 	{ "PNP0D40"  },
65570cce2afSPhilip Elcan 	{ "QCOM8051" },
65670cce2afSPhilip Elcan 	{ "QCOM8052" },
65734597a3fSShah Nehal-Bakulchandra 	{ "AMDI0040" },
658c4e05037SAdrian Hunter 	{ },
659c4e05037SAdrian Hunter };
660c4e05037SAdrian Hunter MODULE_DEVICE_TABLE(acpi, sdhci_acpi_ids);
661c4e05037SAdrian Hunter 
66284d49b3dSHans de Goede static const struct dmi_system_id sdhci_acpi_quirks[] = {
66384d49b3dSHans de Goede 	{
66484d49b3dSHans de Goede 		/*
66584d49b3dSHans de Goede 		 * The Lenovo Miix 320-10ICR has a bug in the _PS0 method of
66684d49b3dSHans de Goede 		 * the SHC1 ACPI device, this bug causes it to reprogram the
66784d49b3dSHans de Goede 		 * wrong LDO (DLDO3) to 1.8V if 1.8V modes are used and the
66884d49b3dSHans de Goede 		 * card is (runtime) suspended + resumed. DLDO3 is used for
66984d49b3dSHans de Goede 		 * the LCD and setting it to 1.8V causes the LCD to go black.
67084d49b3dSHans de Goede 		 */
67184d49b3dSHans de Goede 		.matches = {
67284d49b3dSHans de Goede 			DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
67384d49b3dSHans de Goede 			DMI_MATCH(DMI_PRODUCT_VERSION, "Lenovo MIIX 320-10ICR"),
67484d49b3dSHans de Goede 		},
67584d49b3dSHans de Goede 		.driver_data = (void *)DMI_QUIRK_RESET_SD_SIGNAL_VOLT_ON_SUSP,
67684d49b3dSHans de Goede 	},
6773397b251SHans de Goede 	{
6783397b251SHans de Goede 		/*
6793397b251SHans de Goede 		 * The Acer Aspire Switch 10 (SW5-012) microSD slot always
6803397b251SHans de Goede 		 * reports the card being write-protected even though microSD
6813397b251SHans de Goede 		 * cards do not have a write-protect switch at all.
6823397b251SHans de Goede 		 */
6833397b251SHans de Goede 		.matches = {
6843397b251SHans de Goede 			DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
6853397b251SHans de Goede 			DMI_MATCH(DMI_PRODUCT_NAME, "Aspire SW5-012"),
6863397b251SHans de Goede 		},
6873397b251SHans de Goede 		.driver_data = (void *)DMI_QUIRK_SD_NO_WRITE_PROTECT,
6883397b251SHans de Goede 	},
68984d49b3dSHans de Goede 	{} /* Terminating entry */
69084d49b3dSHans de Goede };
69184d49b3dSHans de Goede 
6924f3cde3aSAndy Shevchenko static const struct sdhci_acpi_slot *sdhci_acpi_get_slot(struct acpi_device *adev)
693c4e05037SAdrian Hunter {
69407a58883SAdrian Hunter 	const struct sdhci_acpi_uid_slot *u;
695c4e05037SAdrian Hunter 
69607a58883SAdrian Hunter 	for (u = sdhci_acpi_uids; u->hid; u++) {
6974f3cde3aSAndy Shevchenko 		if (acpi_dev_hid_uid_match(adev, u->hid, u->uid))
69807a58883SAdrian Hunter 			return u->slot;
69907a58883SAdrian Hunter 	}
700c4e05037SAdrian Hunter 	return NULL;
701c4e05037SAdrian Hunter }
702c4e05037SAdrian Hunter 
7034e608e4eSGreg Kroah-Hartman static int sdhci_acpi_probe(struct platform_device *pdev)
704c4e05037SAdrian Hunter {
705c4e05037SAdrian Hunter 	struct device *dev = &pdev->dev;
706f07b7952SAdrian Hunter 	const struct sdhci_acpi_slot *slot;
707e5bbf307SAdrian Hunter 	struct acpi_device *device, *child;
70884d49b3dSHans de Goede 	const struct dmi_system_id *id;
709c4e05037SAdrian Hunter 	struct sdhci_acpi_host *c;
710c4e05037SAdrian Hunter 	struct sdhci_host *host;
711c4e05037SAdrian Hunter 	struct resource *iomem;
712c4e05037SAdrian Hunter 	resource_size_t len;
713f07b7952SAdrian Hunter 	size_t priv_size;
71484d49b3dSHans de Goede 	int quirks = 0;
71587875655SMika Westerberg 	int err;
716c4e05037SAdrian Hunter 
717cd25c7beSAndy Shevchenko 	device = ACPI_COMPANION(dev);
718cd25c7beSAndy Shevchenko 	if (!device)
719c4e05037SAdrian Hunter 		return -ENODEV;
720c4e05037SAdrian Hunter 
72184d49b3dSHans de Goede 	id = dmi_first_match(sdhci_acpi_quirks);
72284d49b3dSHans de Goede 	if (id)
72384d49b3dSHans de Goede 		quirks = (long)id->driver_data;
72484d49b3dSHans de Goede 
7254f3cde3aSAndy Shevchenko 	slot = sdhci_acpi_get_slot(device);
726f07b7952SAdrian Hunter 
727e5bbf307SAdrian Hunter 	/* Power on the SDHCI controller and its children */
728e5bbf307SAdrian Hunter 	acpi_device_fix_up_power(device);
7294f3cde3aSAndy Shevchenko 	if (!sdhci_acpi_no_fixup_child_power(device)) {
730e5bbf307SAdrian Hunter 		list_for_each_entry(child, &device->children, node)
731e1d070c3SHans de Goede 			if (child->status.present && child->status.enabled)
732e5bbf307SAdrian Hunter 				acpi_device_fix_up_power(child);
73317753d16SAdrian Hunter 	}
734e5bbf307SAdrian Hunter 
7356e1c7d61SAdrian Hunter 	if (sdhci_acpi_byt_defer(dev))
7366e1c7d61SAdrian Hunter 		return -EPROBE_DEFER;
7376e1c7d61SAdrian Hunter 
738c4e05037SAdrian Hunter 	iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
739c4e05037SAdrian Hunter 	if (!iomem)
740c4e05037SAdrian Hunter 		return -ENOMEM;
741c4e05037SAdrian Hunter 
742c4e05037SAdrian Hunter 	len = resource_size(iomem);
743c4e05037SAdrian Hunter 	if (len < 0x100)
744c4e05037SAdrian Hunter 		dev_err(dev, "Invalid iomem size!\n");
745c4e05037SAdrian Hunter 
746c4e05037SAdrian Hunter 	if (!devm_request_mem_region(dev, iomem->start, len, dev_name(dev)))
747c4e05037SAdrian Hunter 		return -ENOMEM;
748c4e05037SAdrian Hunter 
749f07b7952SAdrian Hunter 	priv_size = slot ? slot->priv_size : 0;
750f07b7952SAdrian Hunter 	host = sdhci_alloc_host(dev, sizeof(struct sdhci_acpi_host) + priv_size);
751c4e05037SAdrian Hunter 	if (IS_ERR(host))
752c4e05037SAdrian Hunter 		return PTR_ERR(host);
753c4e05037SAdrian Hunter 
754c4e05037SAdrian Hunter 	c = sdhci_priv(host);
755c4e05037SAdrian Hunter 	c->host = host;
756f07b7952SAdrian Hunter 	c->slot = slot;
757c4e05037SAdrian Hunter 	c->pdev = pdev;
758c4e05037SAdrian Hunter 	c->use_runtime_pm = sdhci_acpi_flag(c, SDHCI_ACPI_RUNTIME_PM);
759c4e05037SAdrian Hunter 
760c4e05037SAdrian Hunter 	platform_set_drvdata(pdev, c);
761c4e05037SAdrian Hunter 
762c4e05037SAdrian Hunter 	host->hw_name	= "ACPI";
763c4e05037SAdrian Hunter 	host->ops	= &sdhci_acpi_ops_dflt;
764c4e05037SAdrian Hunter 	host->irq	= platform_get_irq(pdev, 0);
765d58ac803SAdrian Hunter 	if (host->irq < 0) {
7661b7ba57eSArvind Yadav 		err = -EINVAL;
7671b7ba57eSArvind Yadav 		goto err_free;
7681b7ba57eSArvind Yadav 	}
769c4e05037SAdrian Hunter 
7704bdc0d67SChristoph Hellwig 	host->ioaddr = devm_ioremap(dev, iomem->start,
771c4e05037SAdrian Hunter 					    resource_size(iomem));
772c4e05037SAdrian Hunter 	if (host->ioaddr == NULL) {
773c4e05037SAdrian Hunter 		err = -ENOMEM;
774c4e05037SAdrian Hunter 		goto err_free;
775c4e05037SAdrian Hunter 	}
776c4e05037SAdrian Hunter 
777c4e05037SAdrian Hunter 	if (c->slot) {
778578b36b6SGao, Yunpeng 		if (c->slot->probe_slot) {
7794f3cde3aSAndy Shevchenko 			err = c->slot->probe_slot(pdev, device);
780578b36b6SGao, Yunpeng 			if (err)
781578b36b6SGao, Yunpeng 				goto err_free;
782578b36b6SGao, Yunpeng 		}
783c4e05037SAdrian Hunter 		if (c->slot->chip) {
784c4e05037SAdrian Hunter 			host->ops            = c->slot->chip->ops;
785c4e05037SAdrian Hunter 			host->quirks        |= c->slot->chip->quirks;
786c4e05037SAdrian Hunter 			host->quirks2       |= c->slot->chip->quirks2;
787c4e05037SAdrian Hunter 			host->mmc->caps     |= c->slot->chip->caps;
788c4e05037SAdrian Hunter 			host->mmc->caps2    |= c->slot->chip->caps2;
789c4e05037SAdrian Hunter 			host->mmc->pm_caps  |= c->slot->chip->pm_caps;
790c4e05037SAdrian Hunter 		}
791c4e05037SAdrian Hunter 		host->quirks        |= c->slot->quirks;
792c4e05037SAdrian Hunter 		host->quirks2       |= c->slot->quirks2;
793c4e05037SAdrian Hunter 		host->mmc->caps     |= c->slot->caps;
794c4e05037SAdrian Hunter 		host->mmc->caps2    |= c->slot->caps2;
795c4e05037SAdrian Hunter 		host->mmc->pm_caps  |= c->slot->pm_caps;
796c4e05037SAdrian Hunter 	}
797c4e05037SAdrian Hunter 
7980d3e3350SAdrian Hunter 	host->mmc->caps2 |= MMC_CAP2_NO_PRESCAN_POWERUP;
7990d3e3350SAdrian Hunter 
8004fd4409cSAdrian Hunter 	if (sdhci_acpi_flag(c, SDHCI_ACPI_SD_CD)) {
8014fd4409cSAdrian Hunter 		bool v = sdhci_acpi_flag(c, SDHCI_ACPI_SD_CD_OVERRIDE_LEVEL);
8024fd4409cSAdrian Hunter 
803d0052ad9SMichał Mirosław 		err = mmc_gpiod_request_cd(host->mmc, NULL, 0, v, 0);
804e28d6f04SZhang Rui 		if (err) {
805e28d6f04SZhang Rui 			if (err == -EPROBE_DEFER)
806e28d6f04SZhang Rui 				goto err_free;
8074fd4409cSAdrian Hunter 			dev_warn(dev, "failed to setup card detect gpio\n");
8084fd4409cSAdrian Hunter 			c->use_runtime_pm = false;
8094fd4409cSAdrian Hunter 		}
81084d49b3dSHans de Goede 
81184d49b3dSHans de Goede 		if (quirks & DMI_QUIRK_RESET_SD_SIGNAL_VOLT_ON_SUSP)
81284d49b3dSHans de Goede 			c->reset_signal_volt_on_suspend = true;
8133397b251SHans de Goede 
8143397b251SHans de Goede 		if (quirks & DMI_QUIRK_SD_NO_WRITE_PROTECT)
8153397b251SHans de Goede 			host->mmc->caps2 |= MMC_CAP2_NO_WRITE_PROTECT;
8164fd4409cSAdrian Hunter 	}
8174fd4409cSAdrian Hunter 
8180cc1a0f4SAdrian Hunter 	err = sdhci_setup_host(host);
819c4e05037SAdrian Hunter 	if (err)
820c4e05037SAdrian Hunter 		goto err_free;
821c4e05037SAdrian Hunter 
8220cc1a0f4SAdrian Hunter 	if (c->slot && c->slot->setup_host) {
8230cc1a0f4SAdrian Hunter 		err = c->slot->setup_host(pdev);
8240cc1a0f4SAdrian Hunter 		if (err)
8250cc1a0f4SAdrian Hunter 			goto err_cleanup;
8260cc1a0f4SAdrian Hunter 	}
8270cc1a0f4SAdrian Hunter 
8280cc1a0f4SAdrian Hunter 	err = __sdhci_add_host(host);
8290cc1a0f4SAdrian Hunter 	if (err)
8300cc1a0f4SAdrian Hunter 		goto err_cleanup;
8310cc1a0f4SAdrian Hunter 
832c4e05037SAdrian Hunter 	if (c->use_runtime_pm) {
8331d1ff458SAdrian Hunter 		pm_runtime_set_active(dev);
834c4e05037SAdrian Hunter 		pm_suspend_ignore_children(dev, 1);
835c4e05037SAdrian Hunter 		pm_runtime_set_autosuspend_delay(dev, 50);
836c4e05037SAdrian Hunter 		pm_runtime_use_autosuspend(dev);
837c4e05037SAdrian Hunter 		pm_runtime_enable(dev);
838c4e05037SAdrian Hunter 	}
839c4e05037SAdrian Hunter 
8404e6a2ef9SFu, Zhonghui 	device_enable_async_suspend(dev);
8414e6a2ef9SFu, Zhonghui 
842c4e05037SAdrian Hunter 	return 0;
843c4e05037SAdrian Hunter 
8440cc1a0f4SAdrian Hunter err_cleanup:
8450cc1a0f4SAdrian Hunter 	sdhci_cleanup_host(c->host);
846c4e05037SAdrian Hunter err_free:
847c7eabbeeSWang Dongsheng 	if (c->slot && c->slot->free_slot)
848c7eabbeeSWang Dongsheng 		c->slot->free_slot(pdev);
849c7eabbeeSWang Dongsheng 
850c4e05037SAdrian Hunter 	sdhci_free_host(c->host);
851c4e05037SAdrian Hunter 	return err;
852c4e05037SAdrian Hunter }
853c4e05037SAdrian Hunter 
8544e608e4eSGreg Kroah-Hartman static int sdhci_acpi_remove(struct platform_device *pdev)
855c4e05037SAdrian Hunter {
856c4e05037SAdrian Hunter 	struct sdhci_acpi_host *c = platform_get_drvdata(pdev);
857c4e05037SAdrian Hunter 	struct device *dev = &pdev->dev;
858c4e05037SAdrian Hunter 	int dead;
859c4e05037SAdrian Hunter 
860c4e05037SAdrian Hunter 	if (c->use_runtime_pm) {
861c4e05037SAdrian Hunter 		pm_runtime_get_sync(dev);
862c4e05037SAdrian Hunter 		pm_runtime_disable(dev);
863c4e05037SAdrian Hunter 		pm_runtime_put_noidle(dev);
864c4e05037SAdrian Hunter 	}
865c4e05037SAdrian Hunter 
866578b36b6SGao, Yunpeng 	if (c->slot && c->slot->remove_slot)
867578b36b6SGao, Yunpeng 		c->slot->remove_slot(pdev);
868578b36b6SGao, Yunpeng 
869c4e05037SAdrian Hunter 	dead = (sdhci_readl(c->host, SDHCI_INT_STATUS) == ~0);
870c4e05037SAdrian Hunter 	sdhci_remove_host(c->host, dead);
871c7eabbeeSWang Dongsheng 
872c7eabbeeSWang Dongsheng 	if (c->slot && c->slot->free_slot)
873c7eabbeeSWang Dongsheng 		c->slot->free_slot(pdev);
874c7eabbeeSWang Dongsheng 
875c4e05037SAdrian Hunter 	sdhci_free_host(c->host);
876c4e05037SAdrian Hunter 
877c4e05037SAdrian Hunter 	return 0;
878c4e05037SAdrian Hunter }
879c4e05037SAdrian Hunter 
88084d49b3dSHans de Goede static void __maybe_unused sdhci_acpi_reset_signal_voltage_if_needed(
88184d49b3dSHans de Goede 	struct device *dev)
88284d49b3dSHans de Goede {
88384d49b3dSHans de Goede 	struct sdhci_acpi_host *c = dev_get_drvdata(dev);
88484d49b3dSHans de Goede 	struct sdhci_host *host = c->host;
88584d49b3dSHans de Goede 
88684d49b3dSHans de Goede 	if (c->is_intel && c->reset_signal_volt_on_suspend &&
88784d49b3dSHans de Goede 	    host->mmc->ios.signal_voltage != MMC_SIGNAL_VOLTAGE_330) {
88884d49b3dSHans de Goede 		struct intel_host *intel_host = sdhci_acpi_priv(c);
88984d49b3dSHans de Goede 		unsigned int fn = INTEL_DSM_V33_SWITCH;
89084d49b3dSHans de Goede 		u32 result = 0;
89184d49b3dSHans de Goede 
89284d49b3dSHans de Goede 		intel_dsm(intel_host, dev, fn, &result);
89384d49b3dSHans de Goede 	}
89484d49b3dSHans de Goede }
89584d49b3dSHans de Goede 
896c4e05037SAdrian Hunter #ifdef CONFIG_PM_SLEEP
897c4e05037SAdrian Hunter 
898c4e05037SAdrian Hunter static int sdhci_acpi_suspend(struct device *dev)
899c4e05037SAdrian Hunter {
900c4e05037SAdrian Hunter 	struct sdhci_acpi_host *c = dev_get_drvdata(dev);
901d38dcad4SAdrian Hunter 	struct sdhci_host *host = c->host;
90284d49b3dSHans de Goede 	int ret;
903c4e05037SAdrian Hunter 
904d38dcad4SAdrian Hunter 	if (host->tuning_mode != SDHCI_TUNING_MODE_3)
905d38dcad4SAdrian Hunter 		mmc_retune_needed(host->mmc);
906d38dcad4SAdrian Hunter 
90784d49b3dSHans de Goede 	ret = sdhci_suspend_host(host);
90884d49b3dSHans de Goede 	if (ret)
90984d49b3dSHans de Goede 		return ret;
91084d49b3dSHans de Goede 
91184d49b3dSHans de Goede 	sdhci_acpi_reset_signal_voltage_if_needed(dev);
91284d49b3dSHans de Goede 	return 0;
913c4e05037SAdrian Hunter }
914c4e05037SAdrian Hunter 
915c4e05037SAdrian Hunter static int sdhci_acpi_resume(struct device *dev)
916c4e05037SAdrian Hunter {
917c4e05037SAdrian Hunter 	struct sdhci_acpi_host *c = dev_get_drvdata(dev);
918c4e05037SAdrian Hunter 
9196e1c7d61SAdrian Hunter 	sdhci_acpi_byt_setting(&c->pdev->dev);
9206e1c7d61SAdrian Hunter 
921c4e05037SAdrian Hunter 	return sdhci_resume_host(c->host);
922c4e05037SAdrian Hunter }
923c4e05037SAdrian Hunter 
924c4e05037SAdrian Hunter #endif
925c4e05037SAdrian Hunter 
926162d6f98SRafael J. Wysocki #ifdef CONFIG_PM
927c4e05037SAdrian Hunter 
928c4e05037SAdrian Hunter static int sdhci_acpi_runtime_suspend(struct device *dev)
929c4e05037SAdrian Hunter {
930c4e05037SAdrian Hunter 	struct sdhci_acpi_host *c = dev_get_drvdata(dev);
931d38dcad4SAdrian Hunter 	struct sdhci_host *host = c->host;
93284d49b3dSHans de Goede 	int ret;
933c4e05037SAdrian Hunter 
934d38dcad4SAdrian Hunter 	if (host->tuning_mode != SDHCI_TUNING_MODE_3)
935d38dcad4SAdrian Hunter 		mmc_retune_needed(host->mmc);
936d38dcad4SAdrian Hunter 
93784d49b3dSHans de Goede 	ret = sdhci_runtime_suspend_host(host);
93884d49b3dSHans de Goede 	if (ret)
93984d49b3dSHans de Goede 		return ret;
94084d49b3dSHans de Goede 
94184d49b3dSHans de Goede 	sdhci_acpi_reset_signal_voltage_if_needed(dev);
94284d49b3dSHans de Goede 	return 0;
943c4e05037SAdrian Hunter }
944c4e05037SAdrian Hunter 
945c4e05037SAdrian Hunter static int sdhci_acpi_runtime_resume(struct device *dev)
946c4e05037SAdrian Hunter {
947c4e05037SAdrian Hunter 	struct sdhci_acpi_host *c = dev_get_drvdata(dev);
948c4e05037SAdrian Hunter 
9496e1c7d61SAdrian Hunter 	sdhci_acpi_byt_setting(&c->pdev->dev);
9506e1c7d61SAdrian Hunter 
951c6303c5dSBaolin Wang 	return sdhci_runtime_resume_host(c->host, 0);
952c4e05037SAdrian Hunter }
953c4e05037SAdrian Hunter 
954c4e05037SAdrian Hunter #endif
955c4e05037SAdrian Hunter 
956c4e05037SAdrian Hunter static const struct dev_pm_ops sdhci_acpi_pm_ops = {
957dafed447SUlf Hansson 	SET_SYSTEM_SLEEP_PM_OPS(sdhci_acpi_suspend, sdhci_acpi_resume)
9581d75f74bSPeter Griffin 	SET_RUNTIME_PM_OPS(sdhci_acpi_runtime_suspend,
9599b449e99SUlf Hansson 			sdhci_acpi_runtime_resume, NULL)
960c4e05037SAdrian Hunter };
961c4e05037SAdrian Hunter 
962c4e05037SAdrian Hunter static struct platform_driver sdhci_acpi_driver = {
963c4e05037SAdrian Hunter 	.driver = {
964c4e05037SAdrian Hunter 		.name			= "sdhci-acpi",
965c4e05037SAdrian Hunter 		.acpi_match_table	= sdhci_acpi_ids,
966c4e05037SAdrian Hunter 		.pm			= &sdhci_acpi_pm_ops,
967c4e05037SAdrian Hunter 	},
968c4e05037SAdrian Hunter 	.probe	= sdhci_acpi_probe,
9694e608e4eSGreg Kroah-Hartman 	.remove	= sdhci_acpi_remove,
970c4e05037SAdrian Hunter };
971c4e05037SAdrian Hunter 
972c4e05037SAdrian Hunter module_platform_driver(sdhci_acpi_driver);
973c4e05037SAdrian Hunter 
974c4e05037SAdrian Hunter MODULE_DESCRIPTION("Secure Digital Host Controller Interface ACPI driver");
975c4e05037SAdrian Hunter MODULE_AUTHOR("Adrian Hunter");
976c4e05037SAdrian Hunter MODULE_LICENSE("GPL v2");
977