From patchwork Wed Jan 8 09:39:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 11323131 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 43EFB109A for ; Wed, 8 Jan 2020 09:39:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 223672070E for ; Wed, 8 Jan 2020 09:39:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="gPt3qGjh" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726276AbgAHJjL (ORCPT ); Wed, 8 Jan 2020 04:39:11 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:44519 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726079AbgAHJjL (ORCPT ); Wed, 8 Jan 2020 04:39:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578476349; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ucdMpNBbGXBTkeXu903VBIVtK19pACZHTp0j1oDnBuY=; b=gPt3qGjh3N9rPeJPVv0zxcE4K7j6nkgd5F3acYW/xdQj8UEo0PZzAbeC/gx9g0tmS79ybY WZ2lC3Jl+yF72FjsjAuragRqUQhioHAFIUHq6Oess59S4kAJqo7gS2Z7yTGqWhGKxkjzBm 66tw61wHlNHcyZnMBFLsRktDvAHwPO8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-328-63xeSvhfMBqn9F_TL1YwLQ-1; Wed, 08 Jan 2020 04:39:08 -0500 X-MC-Unique: 63xeSvhfMBqn9F_TL1YwLQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 17445593A0; Wed, 8 Jan 2020 09:39:07 +0000 (UTC) Received: from shalem.localdomain.com (ovpn-117-178.ams2.redhat.com [10.36.117.178]) by smtp.corp.redhat.com (Postfix) with ESMTP id F39CA5D9E1; Wed, 8 Jan 2020 09:39:05 +0000 (UTC) From: Hans de Goede To: Adrian Hunter , Ulf Hansson Cc: Hans de Goede , "russianneuromancer @ ya . ru" , linux-mmc@vger.kernel.org Subject: [PATCH 1/2] mmc: sdhci-acpi: Disable 1.8V modes on external microSD on Lenovo Miix 320 Date: Wed, 8 Jan 2020 10:39:02 +0100 Message-Id: <20200108093903.57620-2-hdegoede@redhat.com> In-Reply-To: <20200108093903.57620-1-hdegoede@redhat.com> References: <20200108093903.57620-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org Based on a sample of 7 DSDTs from Cherry Trail devices using an AXP288 PMIC depending on the design one of 2 possible LDOs on the PMIC is used for the MMC signalling voltage, either DLDO3 or GPIO1LDO (GPIO1 pin in low noise LDO mode). The Lenovo Miix 320-10ICR uses GPIO1LDO in the SHC1 ACPI device's DSM methods to set 3.3 or 1.8 signalling voltage and this appears to work as advertised, so presumably the device is actually using GPIO1LDO for the external microSD signalling voltage. But this device has a bug in the _PS0 method of the SHC1 ACPI device, the DSM remembers the last set signalling voltage and the _PS0 restores this after a (runtime) suspend-resume cycle, but it "restores" the voltage on DLDO3 instead of setting it on GPIO1LDO as the DSM method does. DLDO3 is used for the LCD and setting it to 1.8V causes the LCD to go black. This issue can be worked around by setting the SDHCI_QUIRK2_NO_1_8_V quirk on the sdhci_host so that the DSM never gets used to program the signalling voltage to 1.8V. So far we have mostly been able to avoid using device specific quirks in the sdhci-acpi code, but given that this issue is specific to this one model and we certainly do not want to disable 1.8V modes everywhere I see no other option. This commit adds a new mechanism for setting sdhci-acpi specific quirks and a matching sdhci-acpi.quirks module parameter to make testing quirks / similar issues on other devices easier. The first quirk supported by this mechanism is SDHCI_ACPI_QUIRK_SD_NO_1_8V, which when set causes any slots with the SDHCI_ACPI_SD_CD flag to get the SDHCI_QUIRK2_NO_1_8_V quirk set on their sdhci_host. This commit also adds a DMI table for specifying default quirks for some models and adds an entry for the Lenovo Miix 320-10ICR which enables the SDHCI_QUIRK2_NO_1_8_V by default on this model, fixing the LCD going black when the external microSD slot is used. BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=111294 BugLink: https://gitlab.freedesktop.org/drm/intel/issues/355 Reported-by: russianneuromancer Signed-off-by: Hans de Goede Signed-off-by: Adrian Hunter --- drivers/mmc/host/sdhci-acpi.c | 39 +++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/drivers/mmc/host/sdhci-acpi.c b/drivers/mmc/host/sdhci-acpi.c index 105e73d4a3b9..9f150c73e958 100644 --- a/drivers/mmc/host/sdhci-acpi.c +++ b/drivers/mmc/host/sdhci-acpi.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -75,6 +76,14 @@ struct sdhci_acpi_host { unsigned long private[0] ____cacheline_aligned; }; +enum { + SDHCI_ACPI_QUIRK_SD_NO_1_8V = BIT(0), +}; + +static int quirks = -1; +module_param(quirks, int, 0444); +MODULE_PARM_DESC(quirks, "Override sdhci-acpi specific quirks"); + static inline void *sdhci_acpi_priv(struct sdhci_acpi_host *c) { return (void *)c->private; @@ -647,6 +656,24 @@ static const struct acpi_device_id sdhci_acpi_ids[] = { }; MODULE_DEVICE_TABLE(acpi, sdhci_acpi_ids); +static const struct dmi_system_id sdhci_acpi_quirks[] = { + { + /* + * The Lenovo Miix 320-10ICR has a bug in the _PS0 method of + * the SHC1 ACPI device, this bug causes it to reprogram the + * wrong LDO (DLDO3) to 1.8V if 1.8V modes are used and the + * card is (runtime) suspended + resumed. DLDO3 is used for + * the LCD and setting it to 1.8V causes the LCD to go black. + */ + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), + DMI_MATCH(DMI_PRODUCT_VERSION, "Lenovo MIIX 320-10ICR"), + }, + .driver_data = (void *)SDHCI_ACPI_QUIRK_SD_NO_1_8V, + }, + {} /* Terminating entry */ +}; + static const struct sdhci_acpi_slot *sdhci_acpi_get_slot(struct acpi_device *adev) { const struct sdhci_acpi_uid_slot *u; @@ -663,6 +690,7 @@ static int sdhci_acpi_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; const struct sdhci_acpi_slot *slot; struct acpi_device *device, *child; + const struct dmi_system_id *id; struct sdhci_acpi_host *c; struct sdhci_host *host; struct resource *iomem; @@ -670,6 +698,14 @@ static int sdhci_acpi_probe(struct platform_device *pdev) size_t priv_size; int err; + if (quirks == -1) { + id = dmi_first_match(sdhci_acpi_quirks); + if (id) + quirks = (long)id->driver_data; + else + quirks = 0; + } + device = ACPI_COMPANION(dev); if (!device) return -ENODEV; @@ -759,6 +795,9 @@ static int sdhci_acpi_probe(struct platform_device *pdev) dev_warn(dev, "failed to setup card detect gpio\n"); c->use_runtime_pm = false; } + + if (quirks & SDHCI_ACPI_QUIRK_SD_NO_1_8V) + host->quirks2 |= SDHCI_QUIRK2_NO_1_8_V; } err = sdhci_setup_host(host); From patchwork Wed Jan 8 09:39:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 11323129 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0F9191398 for ; Wed, 8 Jan 2020 09:39:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E240B2070E for ; Wed, 8 Jan 2020 09:39:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="AL69Ais+" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726462AbgAHJjL (ORCPT ); Wed, 8 Jan 2020 04:39:11 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:59378 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726276AbgAHJjL (ORCPT ); Wed, 8 Jan 2020 04:39:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578476350; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eM1uGwh8VVmZ6cIDPHTHCs/4ViYZmWvL5osn0w16oWg=; b=AL69Ais+b5B8P5ZvSe4e/TQ914BIa6mqi68cfbb+J1v99yvktX3MkMJj515Wf+daoycIJX UiVtzIQQuIriUs2BbovOHC3tj+se1N+DVP4YJhUqSOTUZhM3/0/TGAi+ah0ZEexiA9zCXz qOAb+9PyV6vsh70ofsBgw0DSBk8T4JE= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-186-RLTu6sVCOryA6GlAuUbURQ-1; Wed, 08 Jan 2020 04:39:09 -0500 X-MC-Unique: RLTu6sVCOryA6GlAuUbURQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 747F91800D4E; Wed, 8 Jan 2020 09:39:08 +0000 (UTC) Received: from shalem.localdomain.com (ovpn-117-178.ams2.redhat.com [10.36.117.178]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5C3EF5D9E1; Wed, 8 Jan 2020 09:39:07 +0000 (UTC) From: Hans de Goede To: Adrian Hunter , Ulf Hansson Cc: Hans de Goede , "russianneuromancer @ ya . ru" , linux-mmc@vger.kernel.org Subject: [PATCH 2/2] mmc: sdhci-acpi: Disable write protect detection on Acer Aspire Switch 10 (SW5-012) Date: Wed, 8 Jan 2020 10:39:03 +0100 Message-Id: <20200108093903.57620-3-hdegoede@redhat.com> In-Reply-To: <20200108093903.57620-1-hdegoede@redhat.com> References: <20200108093903.57620-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org On the Acer Aspire Switch 10 (SW5-012) microSD slot always reports the card being write-protected even though microSD cards do not have a write-protect switch at all. Add a new SDHCI_ACPI_QUIRK_SD_NO_WRITE_PROTECT quirk which when set sets the MMC_CAP2_NO_WRITE_PROTECT flag on the controller for the external SD slot, and add a DMI quirk which enables this new quirk by default on the Acer SW5-012. Signed-off-by: Hans de Goede --- drivers/mmc/host/sdhci-acpi.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/mmc/host/sdhci-acpi.c b/drivers/mmc/host/sdhci-acpi.c index 9f150c73e958..69485d29b6bc 100644 --- a/drivers/mmc/host/sdhci-acpi.c +++ b/drivers/mmc/host/sdhci-acpi.c @@ -78,6 +78,7 @@ struct sdhci_acpi_host { enum { SDHCI_ACPI_QUIRK_SD_NO_1_8V = BIT(0), + SDHCI_ACPI_QUIRK_SD_NO_WRITE_PROTECT = BIT(1), }; static int quirks = -1; @@ -671,6 +672,18 @@ static const struct dmi_system_id sdhci_acpi_quirks[] = { }, .driver_data = (void *)SDHCI_ACPI_QUIRK_SD_NO_1_8V, }, + { + /* + * The Acer Aspire Switch 10 (SW5-012) microSD slot always + * reports the card being write-protected even though microSD + * cards do not have a write-protect switch at all. + */ + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Acer"), + DMI_MATCH(DMI_PRODUCT_NAME, "Aspire SW5-012"), + }, + .driver_data = (void *)SDHCI_ACPI_QUIRK_SD_NO_WRITE_PROTECT, + }, {} /* Terminating entry */ }; @@ -798,6 +811,9 @@ static int sdhci_acpi_probe(struct platform_device *pdev) if (quirks & SDHCI_ACPI_QUIRK_SD_NO_1_8V) host->quirks2 |= SDHCI_QUIRK2_NO_1_8_V; + + if (quirks & SDHCI_ACPI_QUIRK_SD_NO_WRITE_PROTECT) + host->mmc->caps2 |= MMC_CAP2_NO_WRITE_PROTECT; } err = sdhci_setup_host(host);