From patchwork Wed Dec 30 12:49:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Guo X-Patchwork-Id: 355253 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp11304593jai; Wed, 30 Dec 2020 04:51:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJxOOtKJiTX0AumiO0yR4PkuuNResxrAgiGAsCi3Srk+OesZzs1w/zKquQUYNk+urPxtmug1 X-Received: by 2002:a17:906:7215:: with SMTP id m21mr39375150ejk.248.1609332675910; Wed, 30 Dec 2020 04:51:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609332675; cv=none; d=google.com; s=arc-20160816; b=OI8bo8blA4dbajDeEtAmd8q4kj94M0hvC+M8jzgGTr3T6Qa9TY4WeufMwknKLb7d48 id0GQT8G1uNXLCfXpq1TIqPxp/VnJyXkokC8vNZqVRqm90SpPVw63lomRrygaM8fUFPa 7BTFbD0hOgqnPQ28whYQwdqSu6o7CEAjxjMDRHFiAJe14zSpR3AdZ6IVRGjzl+AyU88X dgyco3qn9AWqwMRB5LmfbUyaKdR0CHbNbXQu+mcJdiX8UDUH4O6SGQUGLtDvTsVMkAJd XgV79yTb1PU6QqCPWGI3MH4mClD3REzMV6tucQjmTe3Id6rSSCXg9bWaV5SDZM1YvtaD pl8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature; bh=4QXq92NoxzM0UANAe9MUt462GjUbA9XMONuk/bFybLc=; b=JduLuUVXS20fFvlCFlpaTz2bcWRUPoA5EmVMzlR6pkLwgYUfXTfbnDizOt8brsjWlY t8EsBDuuwKni7mOeJwlu0aLqI27nY4D6Z1yNk+Hi2j7kX3md3cdQq6dYg8jUeBpS/Kyy UCHxKAkbf+vTBBRmhTVMadaWPwWZj4Jxb118MtPVO0VJFY2c9VqP2WN6LF8Ncs69Bz1+ a+yVSHJSjFhK5Y8TXFVRJym2eBzi/4tkb7nZR6Z3mCjwbXaDFW7q/ts+Eg8zSkf7/G3B CGQeOx8R+9Pmn5aVVWDrxJZ1I3q794ESeg8VPdK/UgIRifC/49NecLdP9cIOzmclxhsI T9Nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cnVQVgC4; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 3si22690441edw.263.2020.12.30.04.51.15; Wed, 30 Dec 2020 04:51:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cnVQVgC4; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726799AbgL3MuT (ORCPT + 15 others); Wed, 30 Dec 2020 07:50:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726749AbgL3MuS (ORCPT ); Wed, 30 Dec 2020 07:50:18 -0500 Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 716FCC06179B for ; Wed, 30 Dec 2020 04:49:38 -0800 (PST) Received: by mail-pg1-x536.google.com with SMTP id w5so11332338pgj.3 for ; Wed, 30 Dec 2020 04:49:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=4QXq92NoxzM0UANAe9MUt462GjUbA9XMONuk/bFybLc=; b=cnVQVgC45+Tj3uiAF7C26Ozxd0h/X32CMKWZE7b9n50LfvRYvAoU0rOUIZwtaB72Qv MTkkzbNqYenXME4PkEXK9oYnoVPBZ22Z3yQVtdDc8TfLw2kmsSivFTgX4fKdth7l56b7 DSuCOhnAwh9UYnmVcblEV0GhGMFIqardbKomWthV4DamA1eaio6L1VrbJTQYfMXazrWT 00CbYY3pP9O8dvU1JLekLDC80Y0oKDORethpTlRQo8mKyeVpYfJgNqct8rafmoJzhEmb 17zgXHESj3OJvSgZZrg7WIlKf0c3ohmv06rEdiswKdHEIyl6t5RQT4dUfrS5HEFLXvLJ l1Ww== 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; bh=4QXq92NoxzM0UANAe9MUt462GjUbA9XMONuk/bFybLc=; b=NrggRgBhwVXE+JqguMjk86aRayPkOLlNzIGPbB/fX2szTiYRj3w5Np2trPUYTIYCca J0VUSlP3jKaE1AzvvaEFot/IxlGw24dy+exd5iLQZ32SG0MqsIqnlMNV9IiBc9U7aRkD md21ekDZdY1qEknNj6x8xR87oHQk3snVtb3lOIzCvGenw5lGz/y1eCgHZPTSDruVK/mj 9ELuIrr1Z5OVSQ6j8AEBaEEu1Bn2KCc5iUgdOa9bOy9ag0ZtvN51SE79hVdD3CT8PC9B 1k/RlIYCAXFiprjn+8OmBVNMqhii6l9y99w77AG56dgS3aQIJiZ9LMUNe3HTcbMaj0nV z2Dg== X-Gm-Message-State: AOAM531KCdnbXJt6004Fx8pRF07e9CK262IiOIq8kN4idyjPFOh9wnQE rdmkb01+y4CVS4GaXaeyoGzpuA== X-Received: by 2002:a65:458d:: with SMTP id o13mr13919547pgq.450.1609332577967; Wed, 30 Dec 2020 04:49:37 -0800 (PST) Received: from localhost.localdomain (80.251.214.228.16clouds.com. [80.251.214.228]) by smtp.gmail.com with ESMTPSA id c18sm41265922pfj.200.2020.12.30.04.49.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Dec 2020 04:49:37 -0800 (PST) From: Shawn Guo To: Bjorn Andersson , Felipe Balbi Cc: linux-arm-msm@vger.kernel.org, linux-usb@vger.kernel.org, Shawn Guo Subject: [PATCH] usb: dwc3: qcom: add URS Host support for sdm845 ACPI boot Date: Wed, 30 Dec 2020 20:49:25 +0800 Message-Id: <20201230124925.19260-1-shawn.guo@linaro.org> X-Mailer: git-send-email 2.17.1 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org For sdm845 ACPI boot, the URS (USB Role Switch) node in ACPI DSDT table holds the memory resource, while interrupt resources reside in the child nodes USB0 and UFN0. It adds USB0 host support by probing URS node, creating platform device for USB0 node, and then retrieve interrupt resources from USB0 platform device. Signed-off-by: Shawn Guo --- drivers/usb/dwc3/dwc3-qcom.c | 50 +++++++++++++++++++++++++++++++++--- 1 file changed, 47 insertions(+), 3 deletions(-) -- 2.17.1 Reported-by: kernel test robot diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c index c703d552bbcf..5b70d34e75ab 100644 --- a/drivers/usb/dwc3/dwc3-qcom.c +++ b/drivers/usb/dwc3/dwc3-qcom.c @@ -60,12 +60,14 @@ struct dwc3_acpi_pdata { int dp_hs_phy_irq_index; int dm_hs_phy_irq_index; int ss_phy_irq_index; + bool is_urs; }; struct dwc3_qcom { struct device *dev; void __iomem *qscratch_base; struct platform_device *dwc3; + struct platform_device *urs_usb; struct clk **clks; int num_clocks; struct reset_control *resets; @@ -429,13 +431,15 @@ static void dwc3_qcom_select_utmi_clk(struct dwc3_qcom *qcom) static int dwc3_qcom_get_irq(struct platform_device *pdev, const char *name, int num) { + struct dwc3_qcom *qcom = platform_get_drvdata(pdev); + struct platform_device *pdev_irq = qcom->urs_usb ? qcom->urs_usb : pdev; struct device_node *np = pdev->dev.of_node; int ret; if (np) - ret = platform_get_irq_byname(pdev, name); + ret = platform_get_irq_byname(pdev_irq, name); else - ret = platform_get_irq(pdev, num); + ret = platform_get_irq(pdev_irq, num); return ret; } @@ -568,6 +572,8 @@ static int dwc3_qcom_acpi_register_core(struct platform_device *pdev) struct dwc3_qcom *qcom = platform_get_drvdata(pdev); struct device *dev = &pdev->dev; struct resource *res, *child_res = NULL; + struct platform_device *pdev_irq = qcom->urs_usb ? qcom->urs_usb : + pdev; int irq; int ret; @@ -597,7 +603,7 @@ static int dwc3_qcom_acpi_register_core(struct platform_device *pdev) child_res[0].end = child_res[0].start + qcom->acpi_pdata->dwc3_core_base_size; - irq = platform_get_irq(pdev, 0); + irq = platform_get_irq(pdev_irq, 0); child_res[1].flags = IORESOURCE_IRQ; child_res[1].start = child_res[1].end = irq; @@ -651,6 +657,24 @@ static int dwc3_qcom_of_register_core(struct platform_device *pdev) return 0; } +static struct platform_device * +dwc3_qcom_create_urs_usb_platdev(struct device *dev) +{ + struct fwnode_handle *fwh; + struct acpi_device *adev; + + /* Find the first child of URS node */ + fwh = fwnode_call_ptr_op(dev->fwnode, get_next_child_node, NULL); + if (!fwh) + return NULL; + + adev = to_acpi_device_node(fwh); + if (!adev) + return NULL; + + return acpi_create_platform_device(adev, NULL); +} + static int dwc3_qcom_probe(struct platform_device *pdev) { struct device_node *np = pdev->dev.of_node; @@ -715,6 +739,14 @@ static int dwc3_qcom_probe(struct platform_device *pdev) qcom->acpi_pdata->qscratch_base_offset; parent_res->end = parent_res->start + qcom->acpi_pdata->qscratch_base_size; + + if (qcom->acpi_pdata->is_urs) { + qcom->urs_usb = dwc3_qcom_create_urs_usb_platdev(dev); + if (!qcom->urs_usb) { + dev_err(dev, "failed to create URS USB platdev\n"); + return -ENODEV; + } + } } qcom->qscratch_base = devm_ioremap_resource(dev, parent_res); @@ -877,8 +909,20 @@ static const struct dwc3_acpi_pdata sdm845_acpi_pdata = { .ss_phy_irq_index = 2 }; +static const struct dwc3_acpi_pdata sdm845_acpi_urs_pdata = { + .qscratch_base_offset = SDM845_QSCRATCH_BASE_OFFSET, + .qscratch_base_size = SDM845_QSCRATCH_SIZE, + .dwc3_core_base_size = SDM845_DWC3_CORE_SIZE, + .hs_phy_irq_index = 1, + .dp_hs_phy_irq_index = 4, + .dm_hs_phy_irq_index = 3, + .ss_phy_irq_index = 2, + .is_urs = true, +}; + static const struct acpi_device_id dwc3_qcom_acpi_match[] = { { "QCOM2430", (unsigned long)&sdm845_acpi_pdata }, + { "QCOM0304", (unsigned long)&sdm845_acpi_urs_pdata }, { }, }; MODULE_DEVICE_TABLE(acpi, dwc3_qcom_acpi_match);