From patchwork Tue May 11 22:52:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthias Kaehlcke X-Patchwork-Id: 434667 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 23902C433B4 for ; Tue, 11 May 2021 22:52:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F340B61432 for ; Tue, 11 May 2021 22:52:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230210AbhEKWxv (ORCPT ); Tue, 11 May 2021 18:53:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230213AbhEKWxn (ORCPT ); Tue, 11 May 2021 18:53:43 -0400 Received: from mail-pg1-x530.google.com (mail-pg1-x530.google.com [IPv6:2607:f8b0:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 854D4C06175F for ; Tue, 11 May 2021 15:52:36 -0700 (PDT) Received: by mail-pg1-x530.google.com with SMTP id q15so12567044pgg.12 for ; Tue, 11 May 2021 15:52:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gRQceREUuiCBW1dDPT9pW8DTooXv4gDopBNig6+8fl4=; b=OW/P9sC+CSrENSE0CY93ntk7hv9X6EHj0SeYCSCRFvGnpoEkq8Sew+c+2aaen4Y4K4 kw5ZEA8bZQEfaC22bL9WCkpgBJCw7Oh2I2KMxHBBl09OiE0h3IHk0PpfLa2rRiyKnako YjWRH4n3oKTAQQHr4q8V0LQ2eu/E14u86KaOQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gRQceREUuiCBW1dDPT9pW8DTooXv4gDopBNig6+8fl4=; b=H44HzDsPkj/zOuJmrvGxdxpi9g/PQVYFmOWmGhJYvpvqI6ETh27D8kD/IQHP9zGRr1 mvnyi1CwEUKLAksWS9oB5HfkQE4htQhPewf5K8QfEOxQTZ97IRrTE5gijhgzvIGVPupu FPZMRCO8WgDaQecV2XxoXQpsX9J2EC9PbfkCXrLATjWzD2bmSvxMrAtOTuSo/DbJeFj9 cveXkqpvhelfk3WYYpqooNZX8eoBotjIGT5z4X8EpJ2oPu3z0pWhOR6vM3RWpxrcZdQQ 9l7gxDhoRIESG5clMgXDuFQJD7jfBS8d/pyLse4U/C8kx+qx69yI2PHSrUqNS7dfQWGb xEOA== X-Gm-Message-State: AOAM533PE4mehNX8zwF4XThkJuXU8ftAE6cph5C2RAgpQJruP16BStOm /dWQocFlviENSWa1kG0xqLJfHw== X-Google-Smtp-Source: ABdhPJxC4sUDqeEqFhnkGv/ppoRkR1ADL9dIeJz19eEymRt580OLgyluH6yVAteZp+18x70blvmgsw== X-Received: by 2002:aa7:808d:0:b029:2bf:bf00:c6f6 with SMTP id v13-20020aa7808d0000b02902bfbf00c6f6mr12699793pff.64.1620773556081; Tue, 11 May 2021 15:52:36 -0700 (PDT) Received: from localhost ([2620:15c:202:201:f1d7:673a:456e:c653]) by smtp.gmail.com with UTF8SMTPSA id h15sm14441528pfk.26.2021.05.11.15.52.34 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 11 May 2021 15:52:35 -0700 (PDT) From: Matthias Kaehlcke To: Greg Kroah-Hartman , Alan Stern , Rob Herring , Frank Rowand Cc: Michal Simek , devicetree@vger.kernel.org, Douglas Anderson , linux-usb@vger.kernel.org, Peter Chen , linux-kernel@vger.kernel.org, Stephen Boyd , Ravi Chandra Sadineni , Krzysztof Kozlowski , Bastien Nocera , Matthias Kaehlcke , Al Cooper , Bjorn Andersson , Christian Lamparter , Colin Ian King , Dmitry Osipenko , Fabio Estevam , Masahiro Yamada , Mathias Nyman , Vinod Koul Subject: [PATCH v10 4/5] usb: host: xhci-plat: Create platform device for onboard hubs in probe() Date: Tue, 11 May 2021 15:52:22 -0700 Message-Id: <20210511155152.v10.4.I7a3a7d9d2126c34079b1cab87aa0b2ec3030f9b7@changeid> X-Mailer: git-send-email 2.31.1.607.g51e8a6a459-goog In-Reply-To: <20210511225223.550762-1-mka@chromium.org> References: <20210511225223.550762-1-mka@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Check during probe() if a hub supported by the onboard_usb_hub driver is connected to the controller. If such a hub is found create the corresponding platform device. This requires the device tree to have a node for the hub with its vendor and product id (which is not common for USB devices). Further the platform device is only created when CONFIG_USB_ONBOARD_HUB=y/m. Signed-off-by: Matthias Kaehlcke --- Changes in v10: - none Changes in v9: - added dependency on USB_ONBOARD_HUB (or !!USB_ONBOARD_HUB) to USB_XHCI_PLATFORM Changes in v8: - none Changes in v7: - none Changes in v6: - none Changes in v5: - patch added to the series drivers/usb/host/Kconfig | 1 + drivers/usb/host/xhci-plat.c | 16 ++++++++++++++++ include/linux/usb/hcd.h | 2 ++ 3 files changed, 19 insertions(+) diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig index b94f2a070c05..da50496787fe 100644 --- a/drivers/usb/host/Kconfig +++ b/drivers/usb/host/Kconfig @@ -54,6 +54,7 @@ config USB_XHCI_PCI_RENESAS config USB_XHCI_PLATFORM tristate "Generic xHCI driver for a platform device" select USB_XHCI_RCAR if ARCH_RENESAS + depends on USB_ONBOARD_HUB || !USB_ONBOARD_HUB help Adds an xHCI host driver for a generic platform device, which provides a memory space and an irq. diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c index c1edcc9b13ce..9c0fb7e8df1f 100644 --- a/drivers/usb/host/xhci-plat.c +++ b/drivers/usb/host/xhci-plat.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -195,6 +196,7 @@ static int xhci_plat_probe(struct platform_device *pdev) int ret; int irq; struct xhci_plat_priv *priv = NULL; + struct device_node *np; if (usb_disabled()) @@ -374,6 +376,17 @@ static int xhci_plat_probe(struct platform_device *pdev) */ pm_runtime_forbid(&pdev->dev); + np = usb_of_get_device_node(hcd->self.root_hub, hcd->self.busnum); + if (np && of_is_onboard_usb_hub(np)) { + struct platform_device *pdev; + + pdev = of_platform_device_create(np, NULL, NULL); + if (pdev) + hcd->onboard_hub_dev = &pdev->dev; + else + xhci_warn(xhci, "failed to create onboard hub platform device\n"); + } + return 0; @@ -420,6 +433,9 @@ static int xhci_plat_remove(struct platform_device *dev) usb_remove_hcd(hcd); usb_put_hcd(shared_hcd); + if (hcd->onboard_hub_dev) + of_platform_device_destroy(hcd->onboard_hub_dev, NULL); + clk_disable_unprepare(clk); clk_disable_unprepare(reg_clk); usb_put_hcd(hcd); diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h index 96281cd50ff6..d02a508e19b0 100644 --- a/include/linux/usb/hcd.h +++ b/include/linux/usb/hcd.h @@ -225,6 +225,8 @@ struct usb_hcd { * (ohci 32, uhci 1024, ehci 256/512/1024). */ + struct device *onboard_hub_dev; + /* The HC driver's private data is stored at the end of * this structure. */