Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp609807ybg; Fri, 12 Jun 2020 09:50:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyU5EQvaN6m5MnsiaycUBz/jGYJAI6QurScUKEdXBOab+1vzHP2KO7ZQ2bxeRm1q6rqyoxo X-Received: by 2002:a17:907:4240:: with SMTP id oi24mr13662473ejb.127.1591980617799; Fri, 12 Jun 2020 09:50:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591980617; cv=none; d=google.com; s=arc-20160816; b=QiNHDA/YdFXZCtD+0ExXe41xjFFIcg/asvQNMONZCLwBKidTWglYCvA3VeIgXUO1tC FBEjNpvOZcFCrvRRR684WbEdiJUReGGwBwZ8tTDFexS7NWToU2BRYNQqfGJLUTgH08pS HXUnCWMozhE84MGJ3iRFaAV6L9UuLrar8QaTUWShrHaedsY0FD8PYHOHDZigrBpG/KOu cjd915eHUgEO+cyf4gmFs43brKVL4vOAB5nt7GqD1d9LGuqq+jHuxMA58f/+zCyOAV5B 9gusrkikIQwugIWNvCcc+ptfDF7te9vlLehNRJp2RNphycqX4r78WkfX4ojpIiTGvtMJ P2Tw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=1IW+Nu94LHfdAV3AtMBLvBHQk3NOMJT81lGzXoJJfdk=; b=PC3KIxiToMhleI+q5cYu8rbFX7GwfJ2oM7qSp6O194N0rRN65Y3LOSCdjupJhXJdAi GJ61IBA+TDD8u7PTpvxPOvSv9JBE5mNG41aZedIYnhskwk2TjpO9XCm0pOY4EMxKcOwp WLBWlkL0QiO6FHMyDsVsd1wE8250jaPcO2VDSAxWibaT6VrI1wu8vJcnkqk7rHR0zRD6 pJ3HkERmmQZ6nf4MYbXalRd1VptIWjD61MNjtnRcwsZHRf6RCwGQKOhswFG0KQ5PQT84 oVYmqrYrqm91W+NSX8QGpbJ1n60yU5aDhNRGIccO5OcINv/+qPWoiXuR9XhQ8XdOvO22 g7qg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lj6si4136203ejb.108.2020.06.12.09.49.55; Fri, 12 Jun 2020 09:50:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726396AbgFLQrd (ORCPT + 99 others); Fri, 12 Jun 2020 12:47:33 -0400 Received: from mx2.suse.de ([195.135.220.15]:59046 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726263AbgFLQr1 (ORCPT ); Fri, 12 Jun 2020 12:47:27 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id E69F8ACDB; Fri, 12 Jun 2020 16:47:29 +0000 (UTC) From: Nicolas Saenz Julienne To: mbrugger@suse.com, u-boot@lists.denx.de, bmeng.cn@gmail.com, marex@denx.de, linux-kernel@vger.kernel.org Cc: sjg@chromium.org, m.szyprowski@samsung.com, s.nawrocki@samsung.com, mark.kettenis@xs4all.nl, Nicolas Saenz Julienne Subject: [PATCH v4 5/5] usb: xhci-pci: Add reset controller support Date: Fri, 12 Jun 2020 18:46:33 +0200 Message-Id: <20200612164632.25648-6-nsaenzjulienne@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200612164632.25648-1-nsaenzjulienne@suse.de> References: <20200612164632.25648-1-nsaenzjulienne@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Some atypical users of xhci-pci might need to manually reset their xHCI controller before starting the HCD setup. Check if a reset controller device is available to the PCI bus and trigger a reset. Signed-off-by: Nicolas Saenz Julienne --- drivers/usb/host/xhci-pci.c | 38 +++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c index 9fb6d2f763..710524fbb1 100644 --- a/drivers/usb/host/xhci-pci.c +++ b/drivers/usb/host/xhci-pci.c @@ -10,9 +10,14 @@ #include #include #include +#include #include #include +struct xhci_pci_platdata { + struct reset_ctl reset; +}; + static void xhci_pci_init(struct udevice *dev, struct xhci_hccr **ret_hccr, struct xhci_hcor **ret_hcor) { @@ -39,14 +44,43 @@ static void xhci_pci_init(struct udevice *dev, struct xhci_hccr **ret_hccr, static int xhci_pci_probe(struct udevice *dev) { + struct xhci_pci_platdata *plat = dev_get_platdata(dev); struct xhci_hccr *hccr; struct xhci_hcor *hcor; + int ret; + + ret = reset_get_by_index(dev, 0, &plat->reset); + if (ret && ret != -ENOENT) { + dev_err(dev, "failed to get reset\n"); + return ret; + } + + if (reset_valid(&plat->reset)) { + ret = reset_assert(&plat->reset); + if (ret) + return ret; + + ret = reset_deassert(&plat->reset); + if (ret) + return ret; + } xhci_pci_init(dev, &hccr, &hcor); return xhci_register(dev, hccr, hcor); } +static int xhci_pci_remove(struct udevice *dev) +{ + struct xhci_pci_platdata *plat = dev_get_platdata(dev); + + xhci_deregister(dev); + if (reset_valid(&plat->reset)) + reset_free(&plat->reset); + + return 0; +} + static const struct udevice_id xhci_pci_ids[] = { { .compatible = "xhci-pci" }, { } @@ -56,10 +90,10 @@ U_BOOT_DRIVER(xhci_pci) = { .name = "xhci_pci", .id = UCLASS_USB, .probe = xhci_pci_probe, - .remove = xhci_deregister, + .remove = xhci_pci_remove, .of_match = xhci_pci_ids, .ops = &xhci_usb_ops, - .platdata_auto_alloc_size = sizeof(struct usb_platdata), + .platdata_auto_alloc_size = sizeof(struct xhci_pci_platdata), .priv_auto_alloc_size = sizeof(struct xhci_ctrl), .flags = DM_FLAG_ALLOC_PRIV_DMA, }; -- 2.26.2