Skip to content

Commit 51ced59

Browse files
ahunter6storulf
authored andcommitted
mmc: sdhci-pci: Use ACPI DSM to get driver strength for some Intel devices
Make use of an Intel ACPI _DSM that provides eMMC driver strength. Signed-off-by: Adrian Hunter <[email protected]> Signed-off-by: Ulf Hansson <[email protected]> Tested-by: Ludovic Desroches <[email protected]>
1 parent c959a6b commit 51ced59

File tree

2 files changed

+14
-66
lines changed

2 files changed

+14
-66
lines changed

drivers/mmc/host/sdhci-pci-core.c

+14-63
Original file line numberDiff line numberDiff line change
@@ -261,11 +261,13 @@ static const struct sdhci_pci_fixes sdhci_intel_pch_sdio = {
261261

262262
enum {
263263
INTEL_DSM_FNS = 0,
264+
INTEL_DSM_DRV_STRENGTH = 9,
264265
INTEL_DSM_D3_RETUNE = 10,
265266
};
266267

267268
struct intel_host {
268269
u32 dsm_fns;
270+
int drv_strength;
269271
bool d3_retune;
270272
};
271273

@@ -326,6 +328,9 @@ static void intel_dsm_init(struct intel_host *intel_host, struct device *dev,
326328
pr_debug("%s: DSM function mask %#x\n",
327329
mmc_hostname(mmc), intel_host->dsm_fns);
328330

331+
err = intel_dsm(intel_host, dev, INTEL_DSM_DRV_STRENGTH, &val);
332+
intel_host->drv_strength = err ? 0 : val;
333+
329334
err = intel_dsm(intel_host, dev, INTEL_DSM_D3_RETUNE, &val);
330335
intel_host->d3_retune = err ? true : !!val;
331336
}
@@ -345,67 +350,15 @@ static void sdhci_pci_int_hw_reset(struct sdhci_host *host)
345350
usleep_range(300, 1000);
346351
}
347352

348-
static int spt_select_drive_strength(struct sdhci_host *host,
349-
struct mmc_card *card,
350-
unsigned int max_dtr,
351-
int host_drv, int card_drv, int *drv_type)
353+
static int intel_select_drive_strength(struct mmc_card *card,
354+
unsigned int max_dtr, int host_drv,
355+
int card_drv, int *drv_type)
352356
{
353-
int drive_strength;
354-
355-
if (sdhci_pci_spt_drive_strength > 0)
356-
drive_strength = sdhci_pci_spt_drive_strength & 0xf;
357-
else
358-
drive_strength = 0; /* Default 50-ohm */
359-
360-
if ((mmc_driver_type_mask(drive_strength) & card_drv) == 0)
361-
drive_strength = 0; /* Default 50-ohm */
362-
363-
return drive_strength;
364-
}
365-
366-
/* Try to read the drive strength from the card */
367-
static void spt_read_drive_strength(struct sdhci_host *host)
368-
{
369-
u32 val, i, t;
370-
u16 m;
371-
372-
if (sdhci_pci_spt_drive_strength)
373-
return;
374-
375-
sdhci_pci_spt_drive_strength = -1;
376-
377-
m = sdhci_readw(host, SDHCI_HOST_CONTROL2) & 0x7;
378-
if (m != 3 && m != 5)
379-
return;
380-
val = sdhci_readl(host, SDHCI_PRESENT_STATE);
381-
if (val & 0x3)
382-
return;
383-
sdhci_writel(host, 0x007f0023, SDHCI_INT_ENABLE);
384-
sdhci_writel(host, 0, SDHCI_SIGNAL_ENABLE);
385-
sdhci_writew(host, 0x10, SDHCI_TRANSFER_MODE);
386-
sdhci_writeb(host, 0xe, SDHCI_TIMEOUT_CONTROL);
387-
sdhci_writew(host, 512, SDHCI_BLOCK_SIZE);
388-
sdhci_writew(host, 1, SDHCI_BLOCK_COUNT);
389-
sdhci_writel(host, 0, SDHCI_ARGUMENT);
390-
sdhci_writew(host, 0x83b, SDHCI_COMMAND);
391-
for (i = 0; i < 1000; i++) {
392-
val = sdhci_readl(host, SDHCI_INT_STATUS);
393-
if (val & 0xffff8000)
394-
return;
395-
if (val & 0x20)
396-
break;
397-
udelay(1);
398-
}
399-
val = sdhci_readl(host, SDHCI_PRESENT_STATE);
400-
if (!(val & 0x800))
401-
return;
402-
for (i = 0; i < 47; i++)
403-
val = sdhci_readl(host, SDHCI_BUFFER);
404-
t = val & 0xf00;
405-
if (t != 0x200 && t != 0x300)
406-
return;
357+
struct sdhci_host *host = mmc_priv(card->host);
358+
struct sdhci_pci_slot *slot = sdhci_priv(host);
359+
struct intel_host *intel_host = sdhci_pci_priv(slot);
407360

408-
sdhci_pci_spt_drive_strength = 0x10 | ((val >> 12) & 0xf);
361+
return intel_host->drv_strength;
409362
}
410363

411364
static int bxt_get_cd(struct mmc_host *mmc)
@@ -451,10 +404,8 @@ static int byt_emmc_probe_slot(struct sdhci_pci_slot *slot)
451404
slot->hw_reset = sdhci_pci_int_hw_reset;
452405
if (slot->chip->pdev->device == PCI_DEVICE_ID_INTEL_BSW_EMMC)
453406
slot->host->timeout_clk = 1000; /* 1000 kHz i.e. 1 MHz */
454-
if (slot->chip->pdev->device == PCI_DEVICE_ID_INTEL_SPT_EMMC) {
455-
spt_read_drive_strength(slot->host);
456-
slot->select_drive_strength = spt_select_drive_strength;
457-
}
407+
slot->host->mmc_host_ops.select_drive_strength =
408+
intel_select_drive_strength;
458409
return 0;
459410
}
460411

drivers/mmc/host/sdhci-pci-data.c

-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,3 @@
33

44
struct sdhci_pci_data *(*sdhci_pci_get_data)(struct pci_dev *pdev, int slotno);
55
EXPORT_SYMBOL_GPL(sdhci_pci_get_data);
6-
7-
int sdhci_pci_spt_drive_strength;
8-
EXPORT_SYMBOL_GPL(sdhci_pci_spt_drive_strength);

0 commit comments

Comments
 (0)