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
4651enum {
@@ -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+
119193static 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
0 commit comments