From: Jon Pry <jonpry@gmail.com>
To: linux-mmc@vger.kernel.org
Cc: Jon Pry <jonpry@gmail.com>
Subject: [RFC][PATCH] Fix for Intel Baytrail-T errata regarding the non-functioning mmc_pwr pin
Date: Mon, 2 Jun 2014 19:54:14 -0400 [thread overview]
Message-ID: <1401753254-32729-1-git-send-email-jonpry@gmail.com> (raw)
This bug effects Asus T100 as well as other Baytrail-T devices.
Erratum in question can be found at
http://www.intel.com/content/dam/www/public/us/en/documents/specification-updates/atom-Z36xxx-Z37xxx-spec-update.pdf
Signed-off-by: Jon Pry <jonpry <at> gmail.com>
---
diff --git a/drivers/mmc/host/sdhci-acpi.c b/drivers/mmc/host/sdhci-acpi.c
index ebb3f39..ebed2a0 100644
--- a/drivers/mmc/host/sdhci-acpi.c
+++ b/drivers/mmc/host/sdhci-acpi.c
@@ -123,7 +123,7 @@ static const struct sdhci_acpi_slot sdhci_acpi_slot_int_emmc = {
static const struct sdhci_acpi_slot sdhci_acpi_slot_int_sdio = {
.quirks = SDHCI_QUIRK_BROKEN_CARD_DETECTION,
- .quirks2 = SDHCI_QUIRK2_HOST_OFF_CARD_ON,
+ .quirks2 = SDHCI_QUIRK2_HOST_OFF_CARD_ON | SDHCI_QUIRK2_BROKEN_POWER_ENABLE,
.caps = MMC_CAP_NONREMOVABLE | MMC_CAP_POWER_OFF_CARD,
.flags = SDHCI_ACPI_RUNTIME_PM,
.pm_caps = MMC_PM_KEEP_POWER,
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 9a79fc4..5a0e928 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -22,6 +22,7 @@
#include <linux/scatterlist.h>
#include <linux/regulator/consumer.h>
#include <linux/pm_runtime.h>
+#include <linux/gpio.h>
#include <linux/leds.h>
@@ -1261,6 +1262,10 @@ static inline void sdhci_update_clock(struct sdhci_host *host)
sdhci_set_clock(host, clock);
}
+static inline void sdhci_set_power_quirk(unsigned short power) {
+ gpio_set_value(SDHCI_POWER_QUIRK_GPIO, power);
+}
+
static int sdhci_set_power(struct sdhci_host *host, unsigned short power)
{
u8 pwr = 0;
@@ -1292,6 +1297,9 @@ static int sdhci_set_power(struct sdhci_host *host, unsigned short power)
sdhci_writeb(host, 0, SDHCI_POWER_CONTROL);
if (host->quirks2 & SDHCI_QUIRK2_CARD_ON_NEEDS_BUS_ON)
sdhci_runtime_pm_bus_off(host);
+ /* The intel Bay Trail SoCs need to assert a GPIO as a work around */
+ if (host->quirks2 & SDHCI_QUIRK2_BROKEN_POWER_ENABLE)
+ sdhci_set_power_quirk(0);
return 0;
}
@@ -1311,8 +1319,14 @@ static int sdhci_set_power(struct sdhci_host *host, unsigned short power)
pwr |= SDHCI_POWER_ON;
+
sdhci_writeb(host, pwr, SDHCI_POWER_CONTROL);
+ /* The intel Bay Trail SoCs need to assert a GPIO as a work around */
+ if (host->quirks2 & SDHCI_QUIRK2_BROKEN_POWER_ENABLE)
+ sdhci_set_power_quirk(1);
+
+
if (host->quirks2 & SDHCI_QUIRK2_CARD_ON_NEEDS_BUS_ON)
sdhci_runtime_pm_bus_on(host);
@@ -2820,6 +2841,18 @@ int sdhci_add_host(struct sdhci_host *host)
host->flags &= ~SDHCI_USE_SDMA;
}
+ if ((host->quirks2 & SDHCI_QUIRK2_BROKEN_POWER_ENABLE)) {
+ printk("Using GPIO for power enable as it is marked broken\n");
+ if (gpio_request(SDHCI_POWER_QUIRK_GPIO, "SDIO_PWR_EN") < 0) {
+ printk("Unable to request GPIO. SDIO may be broken.");
+ host->quirks2 = host->quirks2 & ~SDHCI_QUIRK2_BROKEN_POWER_ENABLE;
+ }
+ else if (gpio_direction_output(SDHCI_POWER_QUIRK_GPIO, 0) < 0) {
+ printk("Unable to set GPIO direction. SDIO may be broken.");
+ host->quirks2 = host->quirks2 & ~SDHCI_QUIRK2_BROKEN_POWER_ENABLE;
+ }
+ }
+
if ((host->version >= SDHCI_SPEC_200) &&
(caps[0] & SDHCI_CAN_DO_ADMA2))
host->flags |= SDHCI_USE_ADMA;
@@ -3325,6 +3358,10 @@ void sdhci_remove_host(struct sdhci_host *host, int dead)
tasklet_kill(&host->card_tasklet);
tasklet_kill(&host->finish_tasklet);
+ if (host->quirks2 & SDHCI_QUIRK2_BROKEN_POWER_ENABLE) {
+ gpio_free(SDHCI_POWER_QUIRK_GPIO);
+ }
+
if (host->vmmc) {
regulator_disable(host->vmmc);
regulator_put(host->vmmc);
diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
index 0a3ed01..027fcd1 100644
--- a/drivers/mmc/host/sdhci.h
+++ b/drivers/mmc/host/sdhci.h
@@ -84,11 +84,12 @@
#define SDHCI_CTRL_ADMA64 0x18
#define SDHCI_CTRL_8BITBUS 0x20
#define SDHCI_POWER_CONTROL 0x29
#define SDHCI_POWER_ON 0x01
#define SDHCI_POWER_180 0x0A
#define SDHCI_POWER_300 0x0C
#define SDHCI_POWER_330 0x0E
+#define SDHCI_POWER_QUIRK_GPIO 195 /*GPIO offset 41 of SCORE device is SD3_PWR_EN*/
#define SDHCI_BLOCK_GAP_CONTROL 0x2A
diff --git a/include/linux/mmc/sdhci.h b/include/linux/mmc/sdhci.h
index 7be12b8..92cec16 100644
--- a/include/linux/mmc/sdhci.h
+++ b/include/linux/mmc/sdhci.h
@@ -102,6 +102,9 @@ struct sdhci_host {
#define SDHCI_QUIRK2_BROKEN_HS200 (1<<6)
/* Controller does not support DDR50 */
#define SDHCI_QUIRK2_BROKEN_DDR50 (1<<7)
+/* Controller cannot initialize power (must use GPIO instead) */
+#define SDHCI_QUIRK2_BROKEN_POWER_ENABLE (1<<8)
+
int irq; /* Device IRQ */
void __iomem *ioaddr; /* Mapped address */
next reply other threads:[~2014-06-02 23:54 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-02 23:54 Jon Pry [this message]
2014-06-16 9:06 ` [RFC][PATCH] Fix for Intel Baytrail-T errata regarding the non-functioning mmc_pwr pin Ulf Hansson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1401753254-32729-1-git-send-email-jonpry@gmail.com \
--to=jonpry@gmail.com \
--cc=linux-mmc@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).