Skip to content

Commit 966d696

Browse files
ahunter6storulf
authored andcommitted
mmc: sdhci-pci: Add runtime suspend/resume callbacks
Add runtime suspend/resume callbacks to match suspend/resume callbacks. Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> Tested-by: Ludovic Desroches <ludovic.desroches@microchip.com>
1 parent 30cf280 commit 966d696

File tree

2 files changed

+62
-40
lines changed

2 files changed

+62
-40
lines changed

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

Lines changed: 58 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,56 @@ int sdhci_pci_resume_host(struct sdhci_pci_chip *chip)
119119
}
120120
#endif
121121

122+
#ifdef CONFIG_PM
123+
static int sdhci_pci_runtime_suspend_host(struct sdhci_pci_chip *chip)
124+
{
125+
struct sdhci_pci_slot *slot;
126+
struct sdhci_host *host;
127+
int i, ret;
128+
129+
for (i = 0; i < chip->num_slots; i++) {
130+
slot = chip->slots[i];
131+
if (!slot)
132+
continue;
133+
134+
host = slot->host;
135+
136+
ret = sdhci_runtime_suspend_host(host);
137+
if (ret)
138+
goto err_pci_runtime_suspend;
139+
140+
if (chip->rpm_retune &&
141+
host->tuning_mode != SDHCI_TUNING_MODE_3)
142+
mmc_retune_needed(host->mmc);
143+
}
144+
145+
return 0;
146+
147+
err_pci_runtime_suspend:
148+
while (--i >= 0)
149+
sdhci_runtime_resume_host(chip->slots[i]->host);
150+
return ret;
151+
}
152+
153+
static int sdhci_pci_runtime_resume_host(struct sdhci_pci_chip *chip)
154+
{
155+
struct sdhci_pci_slot *slot;
156+
int i, ret;
157+
158+
for (i = 0; i < chip->num_slots; i++) {
159+
slot = chip->slots[i];
160+
if (!slot)
161+
continue;
162+
163+
ret = sdhci_runtime_resume_host(slot->host);
164+
if (ret)
165+
return ret;
166+
}
167+
168+
return 0;
169+
}
170+
#endif
171+
122172
/*****************************************************************************\
123173
* *
124174
* Hardware specific quirk handling *
@@ -1796,61 +1846,29 @@ static int sdhci_pci_resume(struct device *dev)
17961846
static int sdhci_pci_runtime_suspend(struct device *dev)
17971847
{
17981848
struct pci_dev *pdev = to_pci_dev(dev);
1799-
struct sdhci_pci_chip *chip;
1800-
struct sdhci_pci_slot *slot;
1801-
struct sdhci_host *host;
1802-
int i, ret;
1849+
struct sdhci_pci_chip *chip = pci_get_drvdata(pdev);
18031850

1804-
chip = pci_get_drvdata(pdev);
18051851
if (!chip)
18061852
return 0;
18071853

1808-
for (i = 0; i < chip->num_slots; i++) {
1809-
slot = chip->slots[i];
1810-
if (!slot)
1811-
continue;
1812-
1813-
host = slot->host;
1814-
1815-
ret = sdhci_runtime_suspend_host(host);
1816-
if (ret)
1817-
goto err_pci_runtime_suspend;
1818-
1819-
if (chip->rpm_retune &&
1820-
host->tuning_mode != SDHCI_TUNING_MODE_3)
1821-
mmc_retune_needed(host->mmc);
1822-
}
1823-
1824-
return 0;
1854+
if (chip->fixes && chip->fixes->runtime_suspend)
1855+
return chip->fixes->runtime_suspend(chip);
18251856

1826-
err_pci_runtime_suspend:
1827-
while (--i >= 0)
1828-
sdhci_runtime_resume_host(chip->slots[i]->host);
1829-
return ret;
1857+
return sdhci_pci_runtime_suspend_host(chip);
18301858
}
18311859

18321860
static int sdhci_pci_runtime_resume(struct device *dev)
18331861
{
18341862
struct pci_dev *pdev = to_pci_dev(dev);
1835-
struct sdhci_pci_chip *chip;
1836-
struct sdhci_pci_slot *slot;
1837-
int i, ret;
1863+
struct sdhci_pci_chip *chip = pci_get_drvdata(pdev);
18381864

1839-
chip = pci_get_drvdata(pdev);
18401865
if (!chip)
18411866
return 0;
18421867

1843-
for (i = 0; i < chip->num_slots; i++) {
1844-
slot = chip->slots[i];
1845-
if (!slot)
1846-
continue;
1868+
if (chip->fixes && chip->fixes->runtime_resume)
1869+
return chip->fixes->runtime_resume(chip);
18471870

1848-
ret = sdhci_runtime_resume_host(slot->host);
1849-
if (ret)
1850-
return ret;
1851-
}
1852-
1853-
return 0;
1871+
return sdhci_pci_runtime_resume_host(chip);
18541872
}
18551873
#endif
18561874

drivers/mmc/host/sdhci-pci.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ struct sdhci_pci_fixes {
7171
int (*suspend) (struct sdhci_pci_chip *);
7272
int (*resume) (struct sdhci_pci_chip *);
7373
#endif
74+
#ifdef CONFIG_PM
75+
int (*runtime_suspend) (struct sdhci_pci_chip *);
76+
int (*runtime_resume) (struct sdhci_pci_chip *);
77+
#endif
7478

7579
const struct sdhci_ops *ops;
7680
size_t priv_size;

0 commit comments

Comments
 (0)