From patchwork Thu Jun 7 10:38:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 10451611 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 33AA860375 for ; Thu, 7 Jun 2018 10:38:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2482A29B27 for ; Thu, 7 Jun 2018 10:38:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 18DBB29B29; Thu, 7 Jun 2018 10:38:50 +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=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham 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 8BEB129B27 for ; Thu, 7 Jun 2018 10:38:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753397AbeFGKis (ORCPT ); Thu, 7 Jun 2018 06:38:48 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:45342 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753076AbeFGKir (ORCPT ); Thu, 7 Jun 2018 06:38:47 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DC672402243B; Thu, 7 Jun 2018 10:38:46 +0000 (UTC) Received: from shalem.localdomain.com (unknown [10.36.118.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2EA2863F6C; Thu, 7 Jun 2018 10:38:46 +0000 (UTC) From: Hans de Goede To: Felipe Balbi , Greg Kroah-Hartman Cc: Hans de Goede , linux-usb@vger.kernel.org Subject: [PATCH 1/3] usb: dwc3: pci: Add GPIO lookup table on platforms without ACPI GPIO resources Date: Thu, 7 Jun 2018 12:38:43 +0200 Message-Id: <20180607103845.13515-1-hdegoede@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Thu, 07 Jun 2018 10:38:46 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Thu, 07 Jun 2018 10:38:46 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'hdegoede@redhat.com' RCPT:'' Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Bay Trail / BYT SoCs do not have a builtin device-mode phy, instead they require an external ULPI phy for device-mode. Only some BYT devices have an external phy, but even on those devices device-mode is not working because the dwc3 does not see the phy. The problem is that the ACPI fwnode for the dwc3 does not contain the expected GPIO resources for the GPIOs connected to the chip-select and reset pins of the phy. I've found the workaround which some Android x86 kernels use for this: https://github.com/BORETS24/Kernel-for-Asus-Zenfone-2/blob/master/arch/x86/platform/intel-mid/device_libs/pci/platform_usb_otg.c Which boils down to hardcoding the GPIOs for these devices. This commit adds a gpiod_lookup_table adding the mappings from Android, and installs this table on BYT system with their BIOS vendor DMI string set to "INSYDE Corp.". This seems to indicate that a (mostly) unmodified version of the reference design BIOS is used. 3 out of the 20 BYT tablets which I have for testing have an external ULPI phy and all 3 models use this vendor string. Signed-off-by: Hans de Goede --- drivers/usb/dwc3/dwc3-pci.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/drivers/usb/dwc3/dwc3-pci.c b/drivers/usb/dwc3/dwc3-pci.c index c961a94d136b..34b84d3bc7cf 100644 --- a/drivers/usb/dwc3/dwc3-pci.c +++ b/drivers/usb/dwc3/dwc3-pci.c @@ -8,6 +8,7 @@ * Sebastian Andrzej Siewior */ +#include #include #include #include @@ -16,6 +17,7 @@ #include #include #include +#include #include #include @@ -54,6 +56,7 @@ struct dwc3_pci { guid_t guid; unsigned int has_dsm_for_pm:1; + unsigned int gpio_mapping_added:1; struct work_struct wakeup_work; }; @@ -66,6 +69,15 @@ static const struct acpi_gpio_mapping acpi_dwc3_byt_gpios[] = { { }, }; +static struct gpiod_lookup_table platform_bytcr_gpios = { + .dev_id = "0000:00:16.0", + .table = { + GPIO_LOOKUP("INT33FC:00", 54, "reset", GPIO_ACTIVE_HIGH), + GPIO_LOOKUP("INT33FC:02", 14, "cs", GPIO_ACTIVE_HIGH), + {} + }, +}; + static int dwc3_pci_quirks(struct dwc3_pci *dwc) { struct platform_device *dwc3 = dwc->dwc3; @@ -120,12 +132,24 @@ static int dwc3_pci_quirks(struct dwc3_pci *dwc) if (pdev->device == PCI_DEVICE_ID_INTEL_BYT) { struct gpio_desc *gpio; + const char *vendor; ret = devm_acpi_dev_add_driver_gpios(&pdev->dev, acpi_dwc3_byt_gpios); if (ret) dev_dbg(&pdev->dev, "failed to add mapping table\n"); + /* + * A lot of BYT devices lack ACPI resource entries for + * the GPIOs, add a manual mapping on devices which use + * an unmodified "INSYDE Corp." reference BIOS / design. + */ + vendor = dmi_get_system_info(DMI_BIOS_VENDOR); + if (vendor && strcmp(vendor, "INSYDE Corp.") == 0) { + gpiod_add_lookup_table(&platform_bytcr_gpios); + dwc->gpio_mapping_added = true; + } + /* * These GPIOs will turn on the USB2 PHY. Note that we have to * put the gpio descriptors again here because the phy driver @@ -256,6 +280,9 @@ static void dwc3_pci_remove(struct pci_dev *pci) { struct dwc3_pci *dwc = pci_get_drvdata(pci); + if (dwc->gpio_mapping_added) + gpiod_remove_lookup_table(&platform_bytcr_gpios); + #ifdef CONFIG_PM cancel_work_sync(&dwc->wakeup_work); #endif