From patchwork Fri Mar 5 19:38:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthias Kaehlcke X-Patchwork-Id: 393711 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=-18.8 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, USER_AGENT_GIT autolearn=ham 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 BAFEEC433E0 for ; Fri, 5 Mar 2021 19:40:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8036F650A8 for ; Fri, 5 Mar 2021 19:40:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229718AbhCETjn (ORCPT ); Fri, 5 Mar 2021 14:39:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229815AbhCETjU (ORCPT ); Fri, 5 Mar 2021 14:39:20 -0500 Received: from mail-pg1-x532.google.com (mail-pg1-x532.google.com [IPv6:2607:f8b0:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F5E7C061762 for ; Fri, 5 Mar 2021 11:39:09 -0800 (PST) Received: by mail-pg1-x532.google.com with SMTP id t25so2055848pga.2 for ; Fri, 05 Mar 2021 11:39:09 -0800 (PST) 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=qfOOFCL5r8iHO/1j7UcG3TomzokVFUS4JgqthyKt1sM=; b=BPXEmEa3zqi8kL8PefolV0beqB93cLI8VYOwiiklwdkGHEzPW6Za6EzB52WcGOLxH0 HdkPYUY2fsMiy5KR1L8BfRrLmNScDnU/f+IlyosiP4ObRTLYDroON9ZDjA48YGww+zne Zn60HTcRpMcFQ6p8x/Iml9UWCybFJ9H/eGHOQ= 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=qfOOFCL5r8iHO/1j7UcG3TomzokVFUS4JgqthyKt1sM=; b=gTQDqKnaUECUpHxvFe7iYdWTHO3m4CGaiPPvzfhgjHe4ii3SY+6EOkoSmFXy/7UX7n sKgYLupyDWwAF9dUy86L9mhYzFnZ3rlKXdEXD4PlBl7nGDGi68jPSCGNZO43h6cKbJfa PjrmCvPYKQIzy7NocxZllZ25o7iTVH2US9B9kgI91Ycx8emTymnwSenncs+MVJ4Dht+A ZCpq3ZZHmYZoxRGThSZkXvnBDob9IiuKdmNFl4DlT6L1yzXufrkX+n+lewa3W+nocVs0 yuA3Gia42CTfotlUmMMvI41q9vDjDANb7o8XygN8vXcnGzuOJgo83Kf5xwYla+RuRe// rppg== X-Gm-Message-State: AOAM533hMPHut8CiYG/yUs4q7XAKF1F7MhkIkdkuT+p9Mr8Pw8oOpd1I NyncZQNYUlnim/uZ5PBZIap/rQ== X-Google-Smtp-Source: ABdhPJyoea1Pf3EFQWzUSEi8x9f9lo9NqyFxIivys520joj8yl+3mZteFM76/xjubenJrzcq+DZeyw== X-Received: by 2002:aa7:8e51:0:b029:1ed:2928:18ff with SMTP id d17-20020aa78e510000b02901ed292818ffmr10196325pfr.76.1614973148701; Fri, 05 Mar 2021 11:39:08 -0800 (PST) Received: from localhost ([2620:15c:202:1:2878:25d1:94cb:a547]) by smtp.gmail.com with UTF8SMTPSA id a24sm3501721pff.18.2021.03.05.11.39.07 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 05 Mar 2021 11:39:08 -0800 (PST) From: Matthias Kaehlcke To: Greg Kroah-Hartman , Alan Stern , Rob Herring , Frank Rowand Cc: Ravi Chandra Sadineni , Peter Chen , Michal Simek , Stephen Boyd , linux-kernel@vger.kernel.org, Bastien Nocera , linux-usb@vger.kernel.org, Douglas Anderson , devicetree@vger.kernel.org, Krzysztof Kozlowski , Matthias Kaehlcke , Mathias Nyman Subject: [PATCH v6 4/5] usb: host: xhci-plat: Create platform device for onboard hubs in probe() Date: Fri, 5 Mar 2021 11:38:52 -0800 Message-Id: <20210305113832.v6.4.I7a3a7d9d2126c34079b1cab87aa0b2ec3030f9b7@changeid> X-Mailer: git-send-email 2.30.1.766.gb4fecdf3b7-goog In-Reply-To: <20210305193853.2040456-1-mka@chromium.org> References: <20210305193853.2040456-1-mka@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@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 v6: - none Changes in v5: - patch added to the series drivers/usb/host/xhci-plat.c | 16 ++++++++++++++++ include/linux/usb/hcd.h | 2 ++ 2 files changed, 18 insertions(+) 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. */