Skip to content

Commit afd5877

Browse files
committed
Merge tag 'mmc-v6.17-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc
Pull MMC fixes from Ulf Hansson: "MMC host: - sdhci_am654: Disable HS400 for AM62P SR1.0 and SR1.1 - sdhci-of-arasan: Ensure CD logic stabilization before power-up - sdhci-pci-gli: Mask the replay timer timeout of AER for GL9763e MEMSTICK: - Fix deadlock by moving removing flag earlier" * tag 'mmc-v6.17-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc: mmc: sdhci_am654: Disable HS400 for AM62P SR1.0 and SR1.1 memstick: Fix deadlock by moving removing flag earlier mmc: sdhci-of-arasan: Ensure CD logic stabilization before power-up mmc: sdhci-pci-gli: GL9763e: Mask the replay timer timeout of AER mmc: sdhci-pci-gli: GL9763e: Rename the gli_set_gl9763e() for consistency mmc: sdhci-pci-gli: Add a new function to simplify the code
2 parents e2d324a + d2d7a96 commit afd5877

File tree

5 files changed

+71
-19
lines changed

5 files changed

+71
-19
lines changed

drivers/memstick/core/memstick.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,6 @@ EXPORT_SYMBOL(memstick_add_host);
555555
*/
556556
void memstick_remove_host(struct memstick_host *host)
557557
{
558-
host->removing = 1;
559558
flush_workqueue(workqueue);
560559
mutex_lock(&host->lock);
561560
if (host->card)

drivers/memstick/host/rtsx_usb_ms.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -812,6 +812,7 @@ static void rtsx_usb_ms_drv_remove(struct platform_device *pdev)
812812
int err;
813813

814814
host->eject = true;
815+
msh->removing = true;
815816
cancel_work_sync(&host->handle_req);
816817
cancel_delayed_work_sync(&host->poll_card);
817818

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

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@
9999
#define HIWORD_UPDATE(val, mask, shift) \
100100
((val) << (shift) | (mask) << ((shift) + 16))
101101

102+
#define CD_STABLE_TIMEOUT_US 1000000
103+
#define CD_STABLE_MAX_SLEEP_US 10
104+
102105
/**
103106
* struct sdhci_arasan_soc_ctl_field - Field used in sdhci_arasan_soc_ctl_map
104107
*
@@ -206,12 +209,15 @@ struct sdhci_arasan_data {
206209
* 19MHz instead
207210
*/
208211
#define SDHCI_ARASAN_QUIRK_CLOCK_25_BROKEN BIT(2)
212+
/* Enable CD stable check before power-up */
213+
#define SDHCI_ARASAN_QUIRK_ENSURE_CD_STABLE BIT(3)
209214
};
210215

211216
struct sdhci_arasan_of_data {
212217
const struct sdhci_arasan_soc_ctl_map *soc_ctl_map;
213218
const struct sdhci_pltfm_data *pdata;
214219
const struct sdhci_arasan_clk_ops *clk_ops;
220+
u32 quirks;
215221
};
216222

217223
static const struct sdhci_arasan_soc_ctl_map rk3399_soc_ctl_map = {
@@ -514,14 +520,32 @@ static int sdhci_arasan_voltage_switch(struct mmc_host *mmc,
514520
return -EINVAL;
515521
}
516522

523+
static void sdhci_arasan_set_power_and_bus_voltage(struct sdhci_host *host, unsigned char mode,
524+
unsigned short vdd)
525+
{
526+
struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
527+
struct sdhci_arasan_data *sdhci_arasan = sdhci_pltfm_priv(pltfm_host);
528+
u32 reg;
529+
530+
/*
531+
* Ensure that the card detect logic has stabilized before powering up, this is
532+
* necessary after a host controller reset.
533+
*/
534+
if (mode == MMC_POWER_UP && sdhci_arasan->quirks & SDHCI_ARASAN_QUIRK_ENSURE_CD_STABLE)
535+
read_poll_timeout(sdhci_readl, reg, reg & SDHCI_CD_STABLE, CD_STABLE_MAX_SLEEP_US,
536+
CD_STABLE_TIMEOUT_US, false, host, SDHCI_PRESENT_STATE);
537+
538+
sdhci_set_power_and_bus_voltage(host, mode, vdd);
539+
}
540+
517541
static const struct sdhci_ops sdhci_arasan_ops = {
518542
.set_clock = sdhci_arasan_set_clock,
519543
.get_max_clock = sdhci_pltfm_clk_get_max_clock,
520544
.get_timeout_clock = sdhci_pltfm_clk_get_max_clock,
521545
.set_bus_width = sdhci_set_bus_width,
522546
.reset = sdhci_arasan_reset,
523547
.set_uhs_signaling = sdhci_set_uhs_signaling,
524-
.set_power = sdhci_set_power_and_bus_voltage,
548+
.set_power = sdhci_arasan_set_power_and_bus_voltage,
525549
.hw_reset = sdhci_arasan_hw_reset,
526550
};
527551

@@ -570,7 +594,7 @@ static const struct sdhci_ops sdhci_arasan_cqe_ops = {
570594
.set_bus_width = sdhci_set_bus_width,
571595
.reset = sdhci_arasan_reset,
572596
.set_uhs_signaling = sdhci_set_uhs_signaling,
573-
.set_power = sdhci_set_power_and_bus_voltage,
597+
.set_power = sdhci_arasan_set_power_and_bus_voltage,
574598
.irq = sdhci_arasan_cqhci_irq,
575599
};
576600

@@ -1447,6 +1471,7 @@ static const struct sdhci_arasan_clk_ops zynqmp_clk_ops = {
14471471
static struct sdhci_arasan_of_data sdhci_arasan_zynqmp_data = {
14481472
.pdata = &sdhci_arasan_zynqmp_pdata,
14491473
.clk_ops = &zynqmp_clk_ops,
1474+
.quirks = SDHCI_ARASAN_QUIRK_ENSURE_CD_STABLE,
14501475
};
14511476

14521477
static const struct sdhci_arasan_clk_ops versal_clk_ops = {
@@ -1457,6 +1482,7 @@ static const struct sdhci_arasan_clk_ops versal_clk_ops = {
14571482
static struct sdhci_arasan_of_data sdhci_arasan_versal_data = {
14581483
.pdata = &sdhci_arasan_zynqmp_pdata,
14591484
.clk_ops = &versal_clk_ops,
1485+
.quirks = SDHCI_ARASAN_QUIRK_ENSURE_CD_STABLE,
14601486
};
14611487

14621488
static const struct sdhci_arasan_clk_ops versal_net_clk_ops = {
@@ -1467,6 +1493,7 @@ static const struct sdhci_arasan_clk_ops versal_net_clk_ops = {
14671493
static struct sdhci_arasan_of_data sdhci_arasan_versal_net_data = {
14681494
.pdata = &sdhci_arasan_versal_net_pdata,
14691495
.clk_ops = &versal_net_clk_ops,
1496+
.quirks = SDHCI_ARASAN_QUIRK_ENSURE_CD_STABLE,
14701497
};
14711498

14721499
static struct sdhci_arasan_of_data intel_keembay_emmc_data = {
@@ -1937,6 +1964,8 @@ static int sdhci_arasan_probe(struct platform_device *pdev)
19371964
if (of_device_is_compatible(np, "rockchip,rk3399-sdhci-5.1"))
19381965
sdhci_arasan_update_clockmultiplier(host, 0x0);
19391966

1967+
sdhci_arasan->quirks |= data->quirks;
1968+
19401969
if (of_device_is_compatible(np, "intel,keembay-sdhci-5.1-emmc") ||
19411970
of_device_is_compatible(np, "intel,keembay-sdhci-5.1-sd") ||
19421971
of_device_is_compatible(np, "intel,keembay-sdhci-5.1-sdio")) {

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

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,20 @@
287287
#define GLI_MAX_TUNING_LOOP 40
288288

289289
/* Genesys Logic chipset */
290+
static void sdhci_gli_mask_replay_timer_timeout(struct pci_dev *pdev)
291+
{
292+
int aer;
293+
u32 value;
294+
295+
/* mask the replay timer timeout of AER */
296+
aer = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_ERR);
297+
if (aer) {
298+
pci_read_config_dword(pdev, aer + PCI_ERR_COR_MASK, &value);
299+
value |= PCI_ERR_COR_REP_TIMER;
300+
pci_write_config_dword(pdev, aer + PCI_ERR_COR_MASK, value);
301+
}
302+
}
303+
290304
static inline void gl9750_wt_on(struct sdhci_host *host)
291305
{
292306
u32 wt_value;
@@ -607,7 +621,6 @@ static void gl9750_hw_setting(struct sdhci_host *host)
607621
{
608622
struct sdhci_pci_slot *slot = sdhci_priv(host);
609623
struct pci_dev *pdev;
610-
int aer;
611624
u32 value;
612625

613626
pdev = slot->chip->pdev;
@@ -626,12 +639,7 @@ static void gl9750_hw_setting(struct sdhci_host *host)
626639
pci_set_power_state(pdev, PCI_D0);
627640

628641
/* mask the replay timer timeout of AER */
629-
aer = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_ERR);
630-
if (aer) {
631-
pci_read_config_dword(pdev, aer + PCI_ERR_COR_MASK, &value);
632-
value |= PCI_ERR_COR_REP_TIMER;
633-
pci_write_config_dword(pdev, aer + PCI_ERR_COR_MASK, value);
634-
}
642+
sdhci_gli_mask_replay_timer_timeout(pdev);
635643

636644
gl9750_wt_off(host);
637645
}
@@ -806,7 +814,6 @@ static void sdhci_gl9755_set_clock(struct sdhci_host *host, unsigned int clock)
806814
static void gl9755_hw_setting(struct sdhci_pci_slot *slot)
807815
{
808816
struct pci_dev *pdev = slot->chip->pdev;
809-
int aer;
810817
u32 value;
811818

812819
gl9755_wt_on(pdev);
@@ -841,12 +848,7 @@ static void gl9755_hw_setting(struct sdhci_pci_slot *slot)
841848
pci_set_power_state(pdev, PCI_D0);
842849

843850
/* mask the replay timer timeout of AER */
844-
aer = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_ERR);
845-
if (aer) {
846-
pci_read_config_dword(pdev, aer + PCI_ERR_COR_MASK, &value);
847-
value |= PCI_ERR_COR_REP_TIMER;
848-
pci_write_config_dword(pdev, aer + PCI_ERR_COR_MASK, value);
849-
}
851+
sdhci_gli_mask_replay_timer_timeout(pdev);
850852

851853
gl9755_wt_off(pdev);
852854
}
@@ -1751,7 +1753,7 @@ static int gl9763e_add_host(struct sdhci_pci_slot *slot)
17511753
return ret;
17521754
}
17531755

1754-
static void gli_set_gl9763e(struct sdhci_pci_slot *slot)
1756+
static void gl9763e_hw_setting(struct sdhci_pci_slot *slot)
17551757
{
17561758
struct pci_dev *pdev = slot->chip->pdev;
17571759
u32 value;
@@ -1780,6 +1782,9 @@ static void gli_set_gl9763e(struct sdhci_pci_slot *slot)
17801782
value |= FIELD_PREP(GLI_9763E_HS400_RXDLY, GLI_9763E_HS400_RXDLY_5);
17811783
pci_write_config_dword(pdev, PCIE_GLI_9763E_CLKRXDLY, value);
17821784

1785+
/* mask the replay timer timeout of AER */
1786+
sdhci_gli_mask_replay_timer_timeout(pdev);
1787+
17831788
pci_read_config_dword(pdev, PCIE_GLI_9763E_VHS, &value);
17841789
value &= ~GLI_9763E_VHS_REV;
17851790
value |= FIELD_PREP(GLI_9763E_VHS_REV, GLI_9763E_VHS_REV_R);
@@ -1923,7 +1928,7 @@ static int gli_probe_slot_gl9763e(struct sdhci_pci_slot *slot)
19231928
gli_pcie_enable_msi(slot);
19241929
host->mmc_host_ops.hs400_enhanced_strobe =
19251930
gl9763e_hs400_enhanced_strobe;
1926-
gli_set_gl9763e(slot);
1931+
gl9763e_hw_setting(slot);
19271932
sdhci_enable_v4_mode(host);
19281933

19291934
return 0;

drivers/mmc/host/sdhci_am654.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ struct sdhci_am654_data {
156156

157157
#define SDHCI_AM654_QUIRK_FORCE_CDTEST BIT(0)
158158
#define SDHCI_AM654_QUIRK_SUPPRESS_V1P8_ENA BIT(1)
159+
#define SDHCI_AM654_QUIRK_DISABLE_HS400 BIT(2)
159160
};
160161

161162
struct window {
@@ -765,6 +766,7 @@ static int sdhci_am654_init(struct sdhci_host *host)
765766
{
766767
struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
767768
struct sdhci_am654_data *sdhci_am654 = sdhci_pltfm_priv(pltfm_host);
769+
struct device *dev = mmc_dev(host->mmc);
768770
u32 ctl_cfg_2 = 0;
769771
u32 mask;
770772
u32 val;
@@ -820,6 +822,12 @@ static int sdhci_am654_init(struct sdhci_host *host)
820822
if (ret)
821823
goto err_cleanup_host;
822824

825+
if (sdhci_am654->quirks & SDHCI_AM654_QUIRK_DISABLE_HS400 &&
826+
host->mmc->caps2 & (MMC_CAP2_HS400 | MMC_CAP2_HS400_ES)) {
827+
dev_info(dev, "HS400 mode not supported on this silicon revision, disabling it\n");
828+
host->mmc->caps2 &= ~(MMC_CAP2_HS400 | MMC_CAP2_HS400_ES);
829+
}
830+
823831
ret = __sdhci_add_host(host);
824832
if (ret)
825833
goto err_cleanup_host;
@@ -883,6 +891,12 @@ static int sdhci_am654_get_of_property(struct platform_device *pdev,
883891
return 0;
884892
}
885893

894+
static const struct soc_device_attribute sdhci_am654_descope_hs400[] = {
895+
{ .family = "AM62PX", .revision = "SR1.0" },
896+
{ .family = "AM62PX", .revision = "SR1.1" },
897+
{ /* sentinel */ }
898+
};
899+
886900
static const struct of_device_id sdhci_am654_of_match[] = {
887901
{
888902
.compatible = "ti,am654-sdhci-5.1",
@@ -970,6 +984,10 @@ static int sdhci_am654_probe(struct platform_device *pdev)
970984
if (ret)
971985
return dev_err_probe(dev, ret, "parsing dt failed\n");
972986

987+
soc = soc_device_match(sdhci_am654_descope_hs400);
988+
if (soc)
989+
sdhci_am654->quirks |= SDHCI_AM654_QUIRK_DISABLE_HS400;
990+
973991
host->mmc_host_ops.start_signal_voltage_switch = sdhci_am654_start_signal_voltage_switch;
974992
host->mmc_host_ops.execute_tuning = sdhci_am654_execute_tuning;
975993

0 commit comments

Comments
 (0)