From patchwork Sun Dec 25 10:21:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 9488223 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B79BB60471 for ; Sun, 25 Dec 2016 10:21:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9B48226223 for ; Sun, 25 Dec 2016 10:21:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8F9DF26253; Sun, 25 Dec 2016 10:21:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BA57926247 for ; Sun, 25 Dec 2016 10:21:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752422AbcLYKVx (ORCPT ); Sun, 25 Dec 2016 05:21:53 -0500 Received: from mx1.redhat.com ([209.132.183.28]:58962 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751873AbcLYKVw (ORCPT ); Sun, 25 Dec 2016 05:21:52 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 940793B470; Sun, 25 Dec 2016 10:21:51 +0000 (UTC) Received: from shalem.localdomain.com (vpn1-7-144.ams2.redhat.com [10.36.7.144]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id uBPALmR7016937; Sun, 25 Dec 2016 05:21:49 -0500 From: Hans de Goede To: "Rafael J . Wysocki" , Len Brown , Adrian Hunter , Ulf Hansson Cc: linux-acpi@vger.kernel.org, "russianneuromancer @ ya . ru" , linux-mmc@vger.kernel.org, Hans de Goede , stable@vger.kernel.org Subject: [PATCH] ACPI / LPSS: Work around wrong sdio _ADR 0 entry on some byt/cht devices Date: Sun, 25 Dec 2016 11:21:48 +0100 Message-Id: <20161225102148.7706-1-hdegoede@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Sun, 25 Dec 2016 10:21:52 +0000 (UTC) Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The firmware on some cherrytrail devices wrongly adds _ADR 0 to their entry describing the 80860F14 uid "2" sd-controller. I believe the firmware writers intended this as a sdio function address, but it is in the wrong place for this, so it gets interpreted as a pci address, causing the node describing the sd-controller used for the sdio-wifi to get seen as a firmware_node for the pci host bridge, rather then being stand-alone device. This commit adds a byt_sdio_setup function which detects this scenario and removes the wrong firmware_node link from the pci host bridge, which fixes acpi_create_platform_device returning NULL, leading to non-working sdio-wifi. BugLink: https://github.com/hadess/rtl8723bs/issues/80 Cc: stable@vger.kernel.org Signed-off-by: Hans de Goede --- drivers/acpi/acpi_lpss.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c index 373657f..df9cc66 100644 --- a/drivers/acpi/acpi_lpss.c +++ b/drivers/acpi/acpi_lpss.c @@ -84,6 +84,7 @@ static const struct lpss_device_desc lpss_dma_desc = { }; struct lpss_private_data { + struct acpi_device *adev; void __iomem *mmio_base; resource_size_t mmio_size; unsigned int fixed_clk_rate; @@ -154,6 +155,33 @@ static void byt_i2c_setup(struct lpss_private_data *pdata) writel(0, pdata->mmio_base + LPSS_I2C_ENABLE); } +static void byt_sdio_setup(struct lpss_private_data *pdata) +{ + unsigned long long adr; + acpi_status status; + struct device *dev; + + /* + * Some firmware has a broken _ADR 0 enter for the 80860F14:2 + * device, which causes it to get seen as the firmware_node + * for the pci host bridge, rather then a stand alone device. + * + * Check if this is the case, and if it is remove the link. + */ + if (strcmp(acpi_device_uid(pdata->adev), "2") != 0) + return; + + status = acpi_evaluate_integer(pdata->adev->handle, "_ADR", NULL, &adr); + if (ACPI_FAILURE(status) || adr != 0) + return; + + dev = acpi_get_first_physical_node(pdata->adev); + if (!dev) + return; + + acpi_unbind_one(dev); +} + static const struct lpss_device_desc lpt_dev_desc = { .flags = LPSS_CLK | LPSS_CLK_GATE | LPSS_CLK_DIVIDER | LPSS_LTR, .prv_offset = 0x800, @@ -217,6 +245,7 @@ static const struct lpss_device_desc byt_spi_dev_desc = { static const struct lpss_device_desc byt_sdio_dev_desc = { .flags = LPSS_CLK, + .setup = byt_sdio_setup, }; static const struct lpss_device_desc byt_i2c_dev_desc = { @@ -425,6 +454,7 @@ static int acpi_lpss_create_device(struct acpi_device *adev, goto err_out; } + pdata->adev = adev; pdata->dev_desc = dev_desc; if (dev_desc->setup)