Skip to content

Commit eb747bc

Browse files
committed
Merge tag 'mmc-v6.8-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc
Pull MMC fixes from Ulf Hansson: "MMC core: - Allow non-sleeping read-only slot-gpio MMC host: - sdhci-pci-o2micro: Fix a warm reboot BIOS issue" * tag 'mmc-v6.8-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc: mmc: slot-gpio: Allow non-sleeping GPIO ro mmc: sdhci-pci-o2micro: Fix a warm reboot issue that disk can't be detected by BIOS
2 parents 3760081 + cc9432c commit eb747bc

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

drivers/mmc/core/slot-gpio.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,15 @@ EXPORT_SYMBOL(mmc_gpio_set_cd_irq);
7575
int mmc_gpio_get_ro(struct mmc_host *host)
7676
{
7777
struct mmc_gpio *ctx = host->slot.handler_priv;
78+
int cansleep;
7879

7980
if (!ctx || !ctx->ro_gpio)
8081
return -ENOSYS;
8182

82-
return gpiod_get_value_cansleep(ctx->ro_gpio);
83+
cansleep = gpiod_cansleep(ctx->ro_gpio);
84+
return cansleep ?
85+
gpiod_get_value_cansleep(ctx->ro_gpio) :
86+
gpiod_get_value(ctx->ro_gpio);
8387
}
8488
EXPORT_SYMBOL(mmc_gpio_get_ro);
8589

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,35 @@ static int sdhci_pci_o2_init_sd_express(struct mmc_host *mmc, struct mmc_ios *io
693693
return 0;
694694
}
695695

696+
static void sdhci_pci_o2_set_power(struct sdhci_host *host, unsigned char mode, unsigned short vdd)
697+
{
698+
struct sdhci_pci_chip *chip;
699+
struct sdhci_pci_slot *slot = sdhci_priv(host);
700+
u32 scratch_32 = 0;
701+
u8 scratch_8 = 0;
702+
703+
chip = slot->chip;
704+
705+
if (mode == MMC_POWER_OFF) {
706+
/* UnLock WP */
707+
pci_read_config_byte(chip->pdev, O2_SD_LOCK_WP, &scratch_8);
708+
scratch_8 &= 0x7f;
709+
pci_write_config_byte(chip->pdev, O2_SD_LOCK_WP, scratch_8);
710+
711+
/* Set PCR 0x354[16] to switch Clock Source back to OPE Clock */
712+
pci_read_config_dword(chip->pdev, O2_SD_OUTPUT_CLK_SOURCE_SWITCH, &scratch_32);
713+
scratch_32 &= ~(O2_SD_SEL_DLL);
714+
pci_write_config_dword(chip->pdev, O2_SD_OUTPUT_CLK_SOURCE_SWITCH, scratch_32);
715+
716+
/* Lock WP */
717+
pci_read_config_byte(chip->pdev, O2_SD_LOCK_WP, &scratch_8);
718+
scratch_8 |= 0x80;
719+
pci_write_config_byte(chip->pdev, O2_SD_LOCK_WP, scratch_8);
720+
}
721+
722+
sdhci_set_power(host, mode, vdd);
723+
}
724+
696725
static int sdhci_pci_o2_probe_slot(struct sdhci_pci_slot *slot)
697726
{
698727
struct sdhci_pci_chip *chip;
@@ -1051,6 +1080,7 @@ static const struct sdhci_ops sdhci_pci_o2_ops = {
10511080
.set_bus_width = sdhci_set_bus_width,
10521081
.reset = sdhci_reset,
10531082
.set_uhs_signaling = sdhci_set_uhs_signaling,
1083+
.set_power = sdhci_pci_o2_set_power,
10541084
};
10551085

10561086
const struct sdhci_pci_fixes sdhci_o2 = {

0 commit comments

Comments
 (0)