Skip to content

Commit 6c90b86

Browse files
committed
Merge tag 'mmc-v5.6-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc
Pull MMC fixes from Ulf Hansson: - rtsx_pci: Fix support for some various speed modes - sdhci-of-at91: Fix support for GPIO card detect on SAMA5D2 - sdhci-cadence: Fix support for DDR52 speed mode for eMMC on UniPhier - sdhci-acpi: Fix broken WP support on Acer Aspire Switch 10 - sdhci-acpi: Workaround FW bug for suspend on Lenovo Miix 320 * tag 'mmc-v5.6-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc: mmc: rtsx_pci: Fix support for speed-modes that relies on tuning mmc: sdhci-of-at91: fix cd-gpios for SAMA5D2 mmc: sdhci-cadence: set SDHCI_QUIRK2_PRESET_VALUE_BROKEN for UniPhier mmc: sdhci-acpi: Disable write protect detection on Acer Aspire Switch 10 (SW5-012) mmc: sdhci-acpi: Switch signal voltage back to 3.3V on suspend on external microSD on Lenovo Miix 320
2 parents cd60773 + 4686392 commit 6c90b86

File tree

8 files changed

+117
-14
lines changed

8 files changed

+117
-14
lines changed

drivers/misc/cardreader/rts5227.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ static const struct pcr_ops rts522a_pcr_ops = {
394394
void rts522a_init_params(struct rtsx_pcr *pcr)
395395
{
396396
rts5227_init_params(pcr);
397-
397+
pcr->tx_initial_phase = SET_CLOCK_PHASE(20, 20, 11);
398398
pcr->reg_pm_ctrl3 = RTS522A_PM_CTRL3;
399399

400400
pcr->option.ocp_en = 1;

drivers/misc/cardreader/rts5249.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,7 @@ static const struct pcr_ops rts524a_pcr_ops = {
618618
void rts524a_init_params(struct rtsx_pcr *pcr)
619619
{
620620
rts5249_init_params(pcr);
621+
pcr->tx_initial_phase = SET_CLOCK_PHASE(27, 29, 11);
621622
pcr->option.ltr_l1off_sspwrgate = LTR_L1OFF_SSPWRGATE_5250_DEF;
622623
pcr->option.ltr_l1off_snooze_sspwrgate =
623624
LTR_L1OFF_SNOOZE_SSPWRGATE_5250_DEF;
@@ -733,6 +734,7 @@ static const struct pcr_ops rts525a_pcr_ops = {
733734
void rts525a_init_params(struct rtsx_pcr *pcr)
734735
{
735736
rts5249_init_params(pcr);
737+
pcr->tx_initial_phase = SET_CLOCK_PHASE(25, 29, 11);
736738
pcr->option.ltr_l1off_sspwrgate = LTR_L1OFF_SSPWRGATE_5250_DEF;
737739
pcr->option.ltr_l1off_snooze_sspwrgate =
738740
LTR_L1OFF_SNOOZE_SSPWRGATE_5250_DEF;

drivers/misc/cardreader/rts5260.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,7 @@ void rts5260_init_params(struct rtsx_pcr *pcr)
662662
pcr->sd30_drive_sel_1v8 = CFG_DRIVER_TYPE_B;
663663
pcr->sd30_drive_sel_3v3 = CFG_DRIVER_TYPE_B;
664664
pcr->aspm_en = ASPM_L1_EN;
665-
pcr->tx_initial_phase = SET_CLOCK_PHASE(1, 29, 16);
665+
pcr->tx_initial_phase = SET_CLOCK_PHASE(27, 29, 11);
666666
pcr->rx_initial_phase = SET_CLOCK_PHASE(24, 6, 5);
667667

668668
pcr->ic_version = rts5260_get_ic_version(pcr);

drivers/misc/cardreader/rts5261.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,7 @@ void rts5261_init_params(struct rtsx_pcr *pcr)
764764
pcr->sd30_drive_sel_1v8 = CFG_DRIVER_TYPE_B;
765765
pcr->sd30_drive_sel_3v3 = CFG_DRIVER_TYPE_B;
766766
pcr->aspm_en = ASPM_L1_EN;
767-
pcr->tx_initial_phase = SET_CLOCK_PHASE(20, 27, 16);
767+
pcr->tx_initial_phase = SET_CLOCK_PHASE(27, 27, 11);
768768
pcr->rx_initial_phase = SET_CLOCK_PHASE(24, 6, 5);
769769

770770
pcr->ic_version = rts5261_get_ic_version(pcr);

drivers/mmc/host/rtsx_pci_sdmmc.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -606,19 +606,22 @@ static int sd_change_phase(struct realtek_pci_sdmmc *host,
606606
u8 sample_point, bool rx)
607607
{
608608
struct rtsx_pcr *pcr = host->pcr;
609-
609+
u16 SD_VP_CTL = 0;
610610
dev_dbg(sdmmc_dev(host), "%s(%s): sample_point = %d\n",
611611
__func__, rx ? "RX" : "TX", sample_point);
612612

613613
rtsx_pci_write_register(pcr, CLK_CTL, CHANGE_CLK, CHANGE_CLK);
614-
if (rx)
614+
if (rx) {
615+
SD_VP_CTL = SD_VPRX_CTL;
615616
rtsx_pci_write_register(pcr, SD_VPRX_CTL,
616617
PHASE_SELECT_MASK, sample_point);
617-
else
618+
} else {
619+
SD_VP_CTL = SD_VPTX_CTL;
618620
rtsx_pci_write_register(pcr, SD_VPTX_CTL,
619621
PHASE_SELECT_MASK, sample_point);
620-
rtsx_pci_write_register(pcr, SD_VPCLK0_CTL, PHASE_NOT_RESET, 0);
621-
rtsx_pci_write_register(pcr, SD_VPCLK0_CTL, PHASE_NOT_RESET,
622+
}
623+
rtsx_pci_write_register(pcr, SD_VP_CTL, PHASE_NOT_RESET, 0);
624+
rtsx_pci_write_register(pcr, SD_VP_CTL, PHASE_NOT_RESET,
622625
PHASE_NOT_RESET);
623626
rtsx_pci_write_register(pcr, CLK_CTL, CHANGE_CLK, 0);
624627
rtsx_pci_write_register(pcr, SD_CFG1, SD_ASYNC_FIFO_NOT_RST, 0);

drivers/mmc/host/sdhci-acpi.c

Lines changed: 82 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <linux/pm.h>
2424
#include <linux/pm_runtime.h>
2525
#include <linux/delay.h>
26+
#include <linux/dmi.h>
2627

2728
#include <linux/mmc/host.h>
2829
#include <linux/mmc/pm.h>
@@ -72,9 +73,16 @@ struct sdhci_acpi_host {
7273
const struct sdhci_acpi_slot *slot;
7374
struct platform_device *pdev;
7475
bool use_runtime_pm;
76+
bool is_intel;
77+
bool reset_signal_volt_on_suspend;
7578
unsigned long private[0] ____cacheline_aligned;
7679
};
7780

81+
enum {
82+
DMI_QUIRK_RESET_SD_SIGNAL_VOLT_ON_SUSP = BIT(0),
83+
DMI_QUIRK_SD_NO_WRITE_PROTECT = BIT(1),
84+
};
85+
7886
static inline void *sdhci_acpi_priv(struct sdhci_acpi_host *c)
7987
{
8088
return (void *)c->private;
@@ -391,6 +399,8 @@ static int intel_probe_slot(struct platform_device *pdev, struct acpi_device *ad
391399
host->mmc_host_ops.start_signal_voltage_switch =
392400
intel_start_signal_voltage_switch;
393401

402+
c->is_intel = true;
403+
394404
return 0;
395405
}
396406

@@ -647,6 +657,36 @@ static const struct acpi_device_id sdhci_acpi_ids[] = {
647657
};
648658
MODULE_DEVICE_TABLE(acpi, sdhci_acpi_ids);
649659

660+
static const struct dmi_system_id sdhci_acpi_quirks[] = {
661+
{
662+
/*
663+
* The Lenovo Miix 320-10ICR has a bug in the _PS0 method of
664+
* the SHC1 ACPI device, this bug causes it to reprogram the
665+
* wrong LDO (DLDO3) to 1.8V if 1.8V modes are used and the
666+
* card is (runtime) suspended + resumed. DLDO3 is used for
667+
* the LCD and setting it to 1.8V causes the LCD to go black.
668+
*/
669+
.matches = {
670+
DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
671+
DMI_MATCH(DMI_PRODUCT_VERSION, "Lenovo MIIX 320-10ICR"),
672+
},
673+
.driver_data = (void *)DMI_QUIRK_RESET_SD_SIGNAL_VOLT_ON_SUSP,
674+
},
675+
{
676+
/*
677+
* The Acer Aspire Switch 10 (SW5-012) microSD slot always
678+
* reports the card being write-protected even though microSD
679+
* cards do not have a write-protect switch at all.
680+
*/
681+
.matches = {
682+
DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
683+
DMI_MATCH(DMI_PRODUCT_NAME, "Aspire SW5-012"),
684+
},
685+
.driver_data = (void *)DMI_QUIRK_SD_NO_WRITE_PROTECT,
686+
},
687+
{} /* Terminating entry */
688+
};
689+
650690
static const struct sdhci_acpi_slot *sdhci_acpi_get_slot(struct acpi_device *adev)
651691
{
652692
const struct sdhci_acpi_uid_slot *u;
@@ -663,17 +703,23 @@ static int sdhci_acpi_probe(struct platform_device *pdev)
663703
struct device *dev = &pdev->dev;
664704
const struct sdhci_acpi_slot *slot;
665705
struct acpi_device *device, *child;
706+
const struct dmi_system_id *id;
666707
struct sdhci_acpi_host *c;
667708
struct sdhci_host *host;
668709
struct resource *iomem;
669710
resource_size_t len;
670711
size_t priv_size;
712+
int quirks = 0;
671713
int err;
672714

673715
device = ACPI_COMPANION(dev);
674716
if (!device)
675717
return -ENODEV;
676718

719+
id = dmi_first_match(sdhci_acpi_quirks);
720+
if (id)
721+
quirks = (long)id->driver_data;
722+
677723
slot = sdhci_acpi_get_slot(device);
678724

679725
/* Power on the SDHCI controller and its children */
@@ -759,6 +805,12 @@ static int sdhci_acpi_probe(struct platform_device *pdev)
759805
dev_warn(dev, "failed to setup card detect gpio\n");
760806
c->use_runtime_pm = false;
761807
}
808+
809+
if (quirks & DMI_QUIRK_RESET_SD_SIGNAL_VOLT_ON_SUSP)
810+
c->reset_signal_volt_on_suspend = true;
811+
812+
if (quirks & DMI_QUIRK_SD_NO_WRITE_PROTECT)
813+
host->mmc->caps2 |= MMC_CAP2_NO_WRITE_PROTECT;
762814
}
763815

764816
err = sdhci_setup_host(host);
@@ -823,17 +875,39 @@ static int sdhci_acpi_remove(struct platform_device *pdev)
823875
return 0;
824876
}
825877

878+
static void __maybe_unused sdhci_acpi_reset_signal_voltage_if_needed(
879+
struct device *dev)
880+
{
881+
struct sdhci_acpi_host *c = dev_get_drvdata(dev);
882+
struct sdhci_host *host = c->host;
883+
884+
if (c->is_intel && c->reset_signal_volt_on_suspend &&
885+
host->mmc->ios.signal_voltage != MMC_SIGNAL_VOLTAGE_330) {
886+
struct intel_host *intel_host = sdhci_acpi_priv(c);
887+
unsigned int fn = INTEL_DSM_V33_SWITCH;
888+
u32 result = 0;
889+
890+
intel_dsm(intel_host, dev, fn, &result);
891+
}
892+
}
893+
826894
#ifdef CONFIG_PM_SLEEP
827895

828896
static int sdhci_acpi_suspend(struct device *dev)
829897
{
830898
struct sdhci_acpi_host *c = dev_get_drvdata(dev);
831899
struct sdhci_host *host = c->host;
900+
int ret;
832901

833902
if (host->tuning_mode != SDHCI_TUNING_MODE_3)
834903
mmc_retune_needed(host->mmc);
835904

836-
return sdhci_suspend_host(host);
905+
ret = sdhci_suspend_host(host);
906+
if (ret)
907+
return ret;
908+
909+
sdhci_acpi_reset_signal_voltage_if_needed(dev);
910+
return 0;
837911
}
838912

839913
static int sdhci_acpi_resume(struct device *dev)
@@ -853,11 +927,17 @@ static int sdhci_acpi_runtime_suspend(struct device *dev)
853927
{
854928
struct sdhci_acpi_host *c = dev_get_drvdata(dev);
855929
struct sdhci_host *host = c->host;
930+
int ret;
856931

857932
if (host->tuning_mode != SDHCI_TUNING_MODE_3)
858933
mmc_retune_needed(host->mmc);
859934

860-
return sdhci_runtime_suspend_host(host);
935+
ret = sdhci_runtime_suspend_host(host);
936+
if (ret)
937+
return ret;
938+
939+
sdhci_acpi_reset_signal_voltage_if_needed(dev);
940+
return 0;
861941
}
862942

863943
static int sdhci_acpi_runtime_resume(struct device *dev)

drivers/mmc/host/sdhci-cadence.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <linux/mmc/host.h>
1212
#include <linux/mmc/mmc.h>
1313
#include <linux/of.h>
14+
#include <linux/of_device.h>
1415

1516
#include "sdhci-pltfm.h"
1617

@@ -235,6 +236,11 @@ static const struct sdhci_ops sdhci_cdns_ops = {
235236
.set_uhs_signaling = sdhci_cdns_set_uhs_signaling,
236237
};
237238

239+
static const struct sdhci_pltfm_data sdhci_cdns_uniphier_pltfm_data = {
240+
.ops = &sdhci_cdns_ops,
241+
.quirks2 = SDHCI_QUIRK2_PRESET_VALUE_BROKEN,
242+
};
243+
238244
static const struct sdhci_pltfm_data sdhci_cdns_pltfm_data = {
239245
.ops = &sdhci_cdns_ops,
240246
};
@@ -334,6 +340,7 @@ static void sdhci_cdns_hs400_enhanced_strobe(struct mmc_host *mmc,
334340
static int sdhci_cdns_probe(struct platform_device *pdev)
335341
{
336342
struct sdhci_host *host;
343+
const struct sdhci_pltfm_data *data;
337344
struct sdhci_pltfm_host *pltfm_host;
338345
struct sdhci_cdns_priv *priv;
339346
struct clk *clk;
@@ -350,8 +357,12 @@ static int sdhci_cdns_probe(struct platform_device *pdev)
350357
if (ret)
351358
return ret;
352359

360+
data = of_device_get_match_data(dev);
361+
if (!data)
362+
data = &sdhci_cdns_pltfm_data;
363+
353364
nr_phy_params = sdhci_cdns_phy_param_count(dev->of_node);
354-
host = sdhci_pltfm_init(pdev, &sdhci_cdns_pltfm_data,
365+
host = sdhci_pltfm_init(pdev, data,
355366
struct_size(priv, phy_params, nr_phy_params));
356367
if (IS_ERR(host)) {
357368
ret = PTR_ERR(host);
@@ -431,7 +442,10 @@ static const struct dev_pm_ops sdhci_cdns_pm_ops = {
431442
};
432443

433444
static const struct of_device_id sdhci_cdns_match[] = {
434-
{ .compatible = "socionext,uniphier-sd4hc" },
445+
{
446+
.compatible = "socionext,uniphier-sd4hc",
447+
.data = &sdhci_cdns_uniphier_pltfm_data,
448+
},
435449
{ .compatible = "cdns,sd4hc" },
436450
{ /* sentinel */ }
437451
};

drivers/mmc/host/sdhci-of-at91.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,8 @@ static void sdhci_at91_reset(struct sdhci_host *host, u8 mask)
132132

133133
sdhci_reset(host, mask);
134134

135-
if (host->mmc->caps & MMC_CAP_NONREMOVABLE)
135+
if ((host->mmc->caps & MMC_CAP_NONREMOVABLE)
136+
|| mmc_gpio_get_cd(host->mmc) >= 0)
136137
sdhci_at91_set_force_card_detect(host);
137138

138139
if (priv->cal_always_on && (mask & SDHCI_RESET_ALL))
@@ -427,8 +428,11 @@ static int sdhci_at91_probe(struct platform_device *pdev)
427428
* detection procedure using the SDMCC_CD signal is bypassed.
428429
* This bit is reset when a software reset for all command is performed
429430
* so we need to implement our own reset function to set back this bit.
431+
*
432+
* WA: SAMA5D2 doesn't drive CMD if using CD GPIO line.
430433
*/
431-
if (host->mmc->caps & MMC_CAP_NONREMOVABLE)
434+
if ((host->mmc->caps & MMC_CAP_NONREMOVABLE)
435+
|| mmc_gpio_get_cd(host->mmc) >= 0)
432436
sdhci_at91_set_force_card_detect(host);
433437

434438
pm_runtime_put_autosuspend(&pdev->dev);

0 commit comments

Comments
 (0)