Skip to content

Commit a8feb78

Browse files
committed
Merge tag 'mmc-v4.6-rc4' of git://git.linaro.org/people/ulf.hansson/mmc
Pull MMC fixes from Ulf Hansson: "Here are a two MMC host fixes: - sdhci-acpi: Reduce Baytrail eMMC/SD/SDIO hangs - sunxi: Disable eMMC HS-DDR for Allwinner A80" * tag 'mmc-v4.6-rc4' of git://git.linaro.org/people/ulf.hansson/mmc: mmc: sunxi: Disable eMMC HS-DDR (MMC_CAP_1_8V_DDR) for Allwinner A80 mmc: sdhci-acpi: Reduce Baytrail eMMC/SD/SDIO hangs
2 parents b9cc335 + 2963070 commit a8feb78

File tree

3 files changed

+87
-0
lines changed

3 files changed

+87
-0
lines changed

drivers/mmc/host/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ config MMC_RICOH_MMC
9797
config MMC_SDHCI_ACPI
9898
tristate "SDHCI support for ACPI enumerated SDHCI controllers"
9999
depends on MMC_SDHCI && ACPI
100+
select IOSF_MBI if X86
100101
help
101102
This selects support for ACPI enumerated SDHCI controllers,
102103
identified by ACPI Compatibility ID PNP0D40 or specific

drivers/mmc/host/sdhci-acpi.c

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@
4141
#include <linux/mmc/pm.h>
4242
#include <linux/mmc/slot-gpio.h>
4343

44+
#ifdef CONFIG_X86
45+
#include <asm/cpu_device_id.h>
46+
#include <asm/iosf_mbi.h>
47+
#endif
48+
4449
#include "sdhci.h"
4550

4651
enum {
@@ -116,6 +121,75 @@ static const struct sdhci_acpi_chip sdhci_acpi_chip_int = {
116121
.ops = &sdhci_acpi_ops_int,
117122
};
118123

124+
#ifdef CONFIG_X86
125+
126+
static bool sdhci_acpi_byt(void)
127+
{
128+
static const struct x86_cpu_id byt[] = {
129+
{ X86_VENDOR_INTEL, 6, 0x37 },
130+
{}
131+
};
132+
133+
return x86_match_cpu(byt);
134+
}
135+
136+
#define BYT_IOSF_SCCEP 0x63
137+
#define BYT_IOSF_OCP_NETCTRL0 0x1078
138+
#define BYT_IOSF_OCP_TIMEOUT_BASE GENMASK(10, 8)
139+
140+
static void sdhci_acpi_byt_setting(struct device *dev)
141+
{
142+
u32 val = 0;
143+
144+
if (!sdhci_acpi_byt())
145+
return;
146+
147+
if (iosf_mbi_read(BYT_IOSF_SCCEP, MBI_CR_READ, BYT_IOSF_OCP_NETCTRL0,
148+
&val)) {
149+
dev_err(dev, "%s read error\n", __func__);
150+
return;
151+
}
152+
153+
if (!(val & BYT_IOSF_OCP_TIMEOUT_BASE))
154+
return;
155+
156+
val &= ~BYT_IOSF_OCP_TIMEOUT_BASE;
157+
158+
if (iosf_mbi_write(BYT_IOSF_SCCEP, MBI_CR_WRITE, BYT_IOSF_OCP_NETCTRL0,
159+
val)) {
160+
dev_err(dev, "%s write error\n", __func__);
161+
return;
162+
}
163+
164+
dev_dbg(dev, "%s completed\n", __func__);
165+
}
166+
167+
static bool sdhci_acpi_byt_defer(struct device *dev)
168+
{
169+
if (!sdhci_acpi_byt())
170+
return false;
171+
172+
if (!iosf_mbi_available())
173+
return true;
174+
175+
sdhci_acpi_byt_setting(dev);
176+
177+
return false;
178+
}
179+
180+
#else
181+
182+
static inline void sdhci_acpi_byt_setting(struct device *dev)
183+
{
184+
}
185+
186+
static inline bool sdhci_acpi_byt_defer(struct device *dev)
187+
{
188+
return false;
189+
}
190+
191+
#endif
192+
119193
static int bxt_get_cd(struct mmc_host *mmc)
120194
{
121195
int gpio_cd = mmc_gpio_get_cd(mmc);
@@ -322,6 +396,9 @@ static int sdhci_acpi_probe(struct platform_device *pdev)
322396
if (acpi_bus_get_status(device) || !device->status.present)
323397
return -ENODEV;
324398

399+
if (sdhci_acpi_byt_defer(dev))
400+
return -EPROBE_DEFER;
401+
325402
hid = acpi_device_hid(device);
326403
uid = device->pnp.unique_id;
327404

@@ -447,6 +524,8 @@ static int sdhci_acpi_resume(struct device *dev)
447524
{
448525
struct sdhci_acpi_host *c = dev_get_drvdata(dev);
449526

527+
sdhci_acpi_byt_setting(&c->pdev->dev);
528+
450529
return sdhci_resume_host(c->host);
451530
}
452531

@@ -470,6 +549,8 @@ static int sdhci_acpi_runtime_resume(struct device *dev)
470549
{
471550
struct sdhci_acpi_host *c = dev_get_drvdata(dev);
472551

552+
sdhci_acpi_byt_setting(&c->pdev->dev);
553+
473554
return sdhci_runtime_resume_host(c->host);
474555
}
475556

drivers/mmc/host/sunxi-mmc.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,6 +1129,11 @@ static int sunxi_mmc_probe(struct platform_device *pdev)
11291129
MMC_CAP_1_8V_DDR |
11301130
MMC_CAP_ERASE | MMC_CAP_SDIO_IRQ;
11311131

1132+
/* TODO MMC DDR is not working on A80 */
1133+
if (of_device_is_compatible(pdev->dev.of_node,
1134+
"allwinner,sun9i-a80-mmc"))
1135+
mmc->caps &= ~MMC_CAP_1_8V_DDR;
1136+
11321137
ret = mmc_of_parse(mmc);
11331138
if (ret)
11341139
goto error_free_dma;

0 commit comments

Comments
 (0)