Skip to content

Commit 8da3191

Browse files
author
Herton R. Krzesinski
committed
Merge: mmc: patches to support NVIDIA Orin
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/1992 Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2144641 Fixes and updates for Nvidia Orin SoC. Signed-off-by: Mark Salter <msalter@redhat.com> Approved-by: Jerry Snitselaar <jsnitsel@redhat.com> Approved-by: Steve Best <sbest@redhat.com> Approved-by: Brian Masney <bmasney@redhat.com> Approved-by: Craig Magina <cmagina@redhat.com> Approved-by: Eric Chanudet <echanude@redhat.com> Approved-by: Mark Langsdorf <mlangsdo@redhat.com> Approved-by: Andrew Halaney <ahalaney@redhat.com> Signed-off-by: Herton R. Krzesinski <herton@redhat.com>
2 parents 569b438 + aa992a1 commit 8da3191

File tree

7 files changed

+246
-203
lines changed

7 files changed

+246
-203
lines changed

drivers/mmc/host/sdhci-acpi.c

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -298,23 +298,11 @@ static inline bool sdhci_acpi_byt_defer(struct device *dev)
298298
static int bxt_get_cd(struct mmc_host *mmc)
299299
{
300300
int gpio_cd = mmc_gpio_get_cd(mmc);
301-
struct sdhci_host *host = mmc_priv(mmc);
302-
unsigned long flags;
303-
int ret = 0;
304301

305302
if (!gpio_cd)
306303
return 0;
307304

308-
spin_lock_irqsave(&host->lock, flags);
309-
310-
if (host->flags & SDHCI_DEVICE_DEAD)
311-
goto out;
312-
313-
ret = !!(sdhci_readl(host, SDHCI_PRESENT_STATE) & SDHCI_CARD_PRESENT);
314-
out:
315-
spin_unlock_irqrestore(&host->lock, flags);
316-
317-
return ret;
305+
return sdhci_get_cd_nogpio(mmc);
318306
}
319307

320308
static int intel_probe_slot(struct platform_device *pdev, struct acpi_device *adev)

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

Lines changed: 36 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -297,15 +297,36 @@ static const struct sdhci_pci_fixes sdhci_ricoh_mmc = {
297297
SDHCI_QUIRK_MISSING_CAPS
298298
};
299299

300+
static void ene_714_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
301+
{
302+
struct sdhci_host *host = mmc_priv(mmc);
303+
304+
sdhci_set_ios(mmc, ios);
305+
306+
/*
307+
* Some (ENE) controllers misbehave on some ios operations,
308+
* signalling timeout and CRC errors even on CMD0. Resetting
309+
* it on each ios seems to solve the problem.
310+
*/
311+
if (!(host->flags & SDHCI_DEVICE_DEAD))
312+
sdhci_reset(host, SDHCI_RESET_CMD | SDHCI_RESET_DATA);
313+
}
314+
315+
static int ene_714_probe_slot(struct sdhci_pci_slot *slot)
316+
{
317+
slot->host->mmc_host_ops.set_ios = ene_714_set_ios;
318+
return 0;
319+
}
320+
300321
static const struct sdhci_pci_fixes sdhci_ene_712 = {
301322
.quirks = SDHCI_QUIRK_SINGLE_POWER_WRITE |
302323
SDHCI_QUIRK_BROKEN_DMA,
303324
};
304325

305326
static const struct sdhci_pci_fixes sdhci_ene_714 = {
306327
.quirks = SDHCI_QUIRK_SINGLE_POWER_WRITE |
307-
SDHCI_QUIRK_RESET_CMD_DATA_ON_IOS |
308328
SDHCI_QUIRK_BROKEN_DMA,
329+
.probe_slot = ene_714_probe_slot,
309330
};
310331

311332
static const struct sdhci_pci_fixes sdhci_cafe = {
@@ -345,73 +366,6 @@ static int pch_hc_probe_slot(struct sdhci_pci_slot *slot)
345366
return 0;
346367
}
347368

348-
#ifdef CONFIG_PM
349-
350-
static irqreturn_t sdhci_pci_sd_cd(int irq, void *dev_id)
351-
{
352-
struct sdhci_pci_slot *slot = dev_id;
353-
struct sdhci_host *host = slot->host;
354-
355-
mmc_detect_change(host->mmc, msecs_to_jiffies(200));
356-
return IRQ_HANDLED;
357-
}
358-
359-
static void sdhci_pci_add_own_cd(struct sdhci_pci_slot *slot)
360-
{
361-
int err, irq, gpio = slot->cd_gpio;
362-
363-
slot->cd_gpio = -EINVAL;
364-
slot->cd_irq = -EINVAL;
365-
366-
if (!gpio_is_valid(gpio))
367-
return;
368-
369-
err = devm_gpio_request(&slot->chip->pdev->dev, gpio, "sd_cd");
370-
if (err < 0)
371-
goto out;
372-
373-
err = gpio_direction_input(gpio);
374-
if (err < 0)
375-
goto out_free;
376-
377-
irq = gpio_to_irq(gpio);
378-
if (irq < 0)
379-
goto out_free;
380-
381-
err = request_irq(irq, sdhci_pci_sd_cd, IRQF_TRIGGER_RISING |
382-
IRQF_TRIGGER_FALLING, "sd_cd", slot);
383-
if (err)
384-
goto out_free;
385-
386-
slot->cd_gpio = gpio;
387-
slot->cd_irq = irq;
388-
389-
return;
390-
391-
out_free:
392-
devm_gpio_free(&slot->chip->pdev->dev, gpio);
393-
out:
394-
dev_warn(&slot->chip->pdev->dev, "failed to setup card detect wake up\n");
395-
}
396-
397-
static void sdhci_pci_remove_own_cd(struct sdhci_pci_slot *slot)
398-
{
399-
if (slot->cd_irq >= 0)
400-
free_irq(slot->cd_irq, slot);
401-
}
402-
403-
#else
404-
405-
static inline void sdhci_pci_add_own_cd(struct sdhci_pci_slot *slot)
406-
{
407-
}
408-
409-
static inline void sdhci_pci_remove_own_cd(struct sdhci_pci_slot *slot)
410-
{
411-
}
412-
413-
#endif
414-
415369
static int mfd_emmc_probe_slot(struct sdhci_pci_slot *slot)
416370
{
417371
slot->host->mmc->caps |= MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE;
@@ -619,23 +573,16 @@ static int intel_select_drive_strength(struct mmc_card *card,
619573
static int bxt_get_cd(struct mmc_host *mmc)
620574
{
621575
int gpio_cd = mmc_gpio_get_cd(mmc);
622-
struct sdhci_host *host = mmc_priv(mmc);
623-
unsigned long flags;
624-
int ret = 0;
625576

626577
if (!gpio_cd)
627578
return 0;
628579

629-
spin_lock_irqsave(&host->lock, flags);
630-
631-
if (host->flags & SDHCI_DEVICE_DEAD)
632-
goto out;
633-
634-
ret = !!(sdhci_readl(host, SDHCI_PRESENT_STATE) & SDHCI_CARD_PRESENT);
635-
out:
636-
spin_unlock_irqrestore(&host->lock, flags);
580+
return sdhci_get_cd_nogpio(mmc);
581+
}
637582

638-
return ret;
583+
static int mrfld_get_cd(struct mmc_host *mmc)
584+
{
585+
return sdhci_get_cd_nogpio(mmc);
639586
}
640587

641588
#define SDHCI_INTEL_PWR_TIMEOUT_CNT 20
@@ -1336,6 +1283,14 @@ static int intel_mrfld_mmc_probe_slot(struct sdhci_pci_slot *slot)
13361283
MMC_CAP_1_8V_DDR;
13371284
break;
13381285
case INTEL_MRFLD_SD:
1286+
slot->cd_idx = 0;
1287+
slot->cd_override_level = true;
1288+
/*
1289+
* There are two PCB designs of SD card slot with the opposite
1290+
* card detection sense. Quirk this out by ignoring GPIO state
1291+
* completely in the custom ->get_cd() callback.
1292+
*/
1293+
slot->host->mmc_host_ops.get_cd = mrfld_get_cd;
13391294
slot->host->quirks2 |= SDHCI_QUIRK2_NO_1_8_V;
13401295
break;
13411296
case INTEL_MRFLD_SDIO:
@@ -1976,21 +1931,6 @@ int sdhci_pci_enable_dma(struct sdhci_host *host)
19761931
return 0;
19771932
}
19781933

1979-
static void sdhci_pci_gpio_hw_reset(struct sdhci_host *host)
1980-
{
1981-
struct sdhci_pci_slot *slot = sdhci_priv(host);
1982-
int rst_n_gpio = slot->rst_n_gpio;
1983-
1984-
if (!gpio_is_valid(rst_n_gpio))
1985-
return;
1986-
gpio_set_value_cansleep(rst_n_gpio, 0);
1987-
/* For eMMC, minimum is 1us but give it 10us for good measure */
1988-
udelay(10);
1989-
gpio_set_value_cansleep(rst_n_gpio, 1);
1990-
/* For eMMC, minimum is 200us but give it 300us for good measure */
1991-
usleep_range(300, 1000);
1992-
}
1993-
19941934
static void sdhci_pci_hw_reset(struct sdhci_host *host)
19951935
{
19961936
struct sdhci_pci_slot *slot = sdhci_priv(host);
@@ -2121,8 +2061,6 @@ static struct sdhci_pci_slot *sdhci_pci_probe_slot(
21212061

21222062
slot->chip = chip;
21232063
slot->host = host;
2124-
slot->rst_n_gpio = -EINVAL;
2125-
slot->cd_gpio = -EINVAL;
21262064
slot->cd_idx = -1;
21272065

21282066
host->hw_name = "PCI";
@@ -2148,17 +2086,6 @@ static struct sdhci_pci_slot *sdhci_pci_probe_slot(
21482086
goto cleanup;
21492087
}
21502088

2151-
if (gpio_is_valid(slot->rst_n_gpio)) {
2152-
if (!devm_gpio_request(&pdev->dev, slot->rst_n_gpio, "eMMC_reset")) {
2153-
gpio_direction_output(slot->rst_n_gpio, 1);
2154-
slot->host->mmc->caps |= MMC_CAP_HW_RESET;
2155-
slot->hw_reset = sdhci_pci_gpio_hw_reset;
2156-
} else {
2157-
dev_warn(&pdev->dev, "failed to request rst_n_gpio\n");
2158-
slot->rst_n_gpio = -EINVAL;
2159-
}
2160-
}
2161-
21622089
host->mmc->pm_caps = MMC_PM_KEEP_POWER;
21632090
host->mmc->slotno = slotno;
21642091
host->mmc->caps2 |= MMC_CAP2_NO_PRESCAN_POWERUP;
@@ -2193,15 +2120,11 @@ static struct sdhci_pci_slot *sdhci_pci_probe_slot(
21932120
if (ret)
21942121
goto remove;
21952122

2196-
sdhci_pci_add_own_cd(slot);
2197-
21982123
/*
21992124
* Check if the chip needs a separate GPIO for card detect to wake up
22002125
* from runtime suspend. If it is not there, don't allow runtime PM.
2201-
* Note sdhci_pci_add_own_cd() sets slot->cd_gpio to -EINVAL on failure.
22022126
*/
2203-
if (chip->fixes && chip->fixes->own_cd_for_runtime_pm &&
2204-
!gpio_is_valid(slot->cd_gpio) && slot->cd_idx < 0)
2127+
if (chip->fixes && chip->fixes->own_cd_for_runtime_pm && slot->cd_idx < 0)
22052128
chip->allow_runtime_pm = false;
22062129

22072130
return slot;
@@ -2221,8 +2144,6 @@ static void sdhci_pci_remove_slot(struct sdhci_pci_slot *slot)
22212144
int dead;
22222145
u32 scratch;
22232146

2224-
sdhci_pci_remove_own_cd(slot);
2225-
22262147
dead = 0;
22272148
scratch = readl(slot->host->ioaddr + SDHCI_INT_STATUS);
22282149
if (scratch == (u32)-1)

drivers/mmc/host/sdhci-pci.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,6 @@ struct sdhci_pci_slot {
157157
struct sdhci_pci_chip *chip;
158158
struct sdhci_host *host;
159159

160-
int rst_n_gpio;
161-
int cd_gpio;
162-
int cd_irq;
163-
164160
int cd_idx;
165161
bool cd_override_level;
166162

0 commit comments

Comments
 (0)