Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp2724046iob; Fri, 6 May 2022 09:04:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwSF3yMA7ZT7GI++NvD2LfZiNckfyeU/cVCL9mFNIG7DGRY4JacKbV7sUir80XuDtnp9R7L X-Received: by 2002:a05:6638:4388:b0:32b:6c04:9561 with SMTP id bo8-20020a056638438800b0032b6c049561mr1727853jab.241.1651853081932; Fri, 06 May 2022 09:04:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651853081; cv=none; d=google.com; s=arc-20160816; b=NHX5eCZVvhyB+JtyXbIF85Q0yEgkrhx/QUiI3lYbmhSioTHkxTgo3khqrm34PcmneK UxsUg4NuRnlGnf5Xaitu01fBp8cusi8ZGlJNjeD5fE8ylFNRalDJXCTxZgHewT3mrdwP a6FOzUCuj7EZ0UMc1PdBY5zY/dKy5Shjf2XQjghirsOHZ/7UH8s+NOHhFMirt2pX4Cql qfpyZPD1EGmrzfWj8uEz5pIAqZb75ONv6u1poW0b13IVApajNfB7UoUwRoIsmmXtVqC2 UR9RABb8HGJub2e4tvNJP12j9+Dn0jukhz+l1nTk7CJ4kIXmmzzdm0cd0TOajdw2Ji+e fT1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:dlp-filter:cms-type:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature:dkim-filter; bh=a4Ha8wEr3wq1zSlLNuAyl1253SWX0FU94jcVWiTwflM=; b=ciM25D8wyZfqtLl1HGBQo6ysqDmf/d+V2AKD7souOYeILVfXaoEVr1oxrtEunl0tb/ BD5hO+E2C8/EWXMlz4xNqS4hkOfa3qav9mDXoDc/T9jFXP5u3chd1r+RPmZuF4GD1x5J IuRLuXwOAF4foHj6qJxBscXog6uZW4gVzl9MiOUQycCTM/rJzlWKKyvQg9Eqvg1ABluu //Z+agKhkDCC1sUzDptW3LgX7XcQZ0VOi2siv6JmRlBZBgBpfymGA7JoKN9ZfXDh/+Te I2HftlBlWULLppbfJ3fwAw+5O0ZvsP0BrutAPiCvcux+T3sEN0zAz6t4y5sBOKPi9YsV sMWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=NyIxckSj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x18-20020a056602161200b0064958084521si3374603iow.62.2022.05.06.09.04.26; Fri, 06 May 2022 09:04:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=NyIxckSj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359662AbiEFGhw (ORCPT + 99 others); Fri, 6 May 2022 02:37:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355564AbiEFGhb (ORCPT ); Fri, 6 May 2022 02:37:31 -0400 Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A98D66208 for ; Thu, 5 May 2022 23:33:48 -0700 (PDT) Received: from epcas2p1.samsung.com (unknown [182.195.41.53]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20220506063346epoutp04ed771ff66395f3e114dfda4697d9f82e~scHiFtijZ2011620116epoutp04S for ; Fri, 6 May 2022 06:33:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20220506063346epoutp04ed771ff66395f3e114dfda4697d9f82e~scHiFtijZ2011620116epoutp04S DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1651818826; bh=a4Ha8wEr3wq1zSlLNuAyl1253SWX0FU94jcVWiTwflM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NyIxckSjT3QDkDuUVthcZjfp43rZ17kRDyX/9WuwUiylymt5YTJTmjYO4YJ8F29pJ A6qVyzKDnyh40wOe1vAjqP+W1EgkMyxpSukdbj+3EOo9FbfiA+aKVleDkJ0PqBRLdJ s7JEnLdOVh/Dc1TWsaINqAgfEz1lALt5/hb8ZJds= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas2p2.samsung.com (KnoxPortal) with ESMTP id 20220506063345epcas2p221a69de6758e82525668975853da6cf8~scHhh1sU_1423714237epcas2p2H; Fri, 6 May 2022 06:33:45 +0000 (GMT) Received: from epsmges2p1.samsung.com (unknown [182.195.36.88]) by epsnrtp3.localdomain (Postfix) with ESMTP id 4KvgkY08TBz4x9Px; Fri, 6 May 2022 06:33:41 +0000 (GMT) Received: from epcas2p2.samsung.com ( [182.195.41.54]) by epsmges2p1.samsung.com (Symantec Messaging Gateway) with SMTP id DF.41.10069.441C4726; Fri, 6 May 2022 15:33:40 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas2p4.samsung.com (KnoxPortal) with ESMTPA id 20220506063340epcas2p4c9d88670f9be952f3637e3a545a7d1da~scHcnp9i71119911199epcas2p4j; Fri, 6 May 2022 06:33:40 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220506063340epsmtrp28eaa0984bb745a087836f8a1472067ba~scHcmjYem0438604386epsmtrp2Y; Fri, 6 May 2022 06:33:40 +0000 (GMT) X-AuditID: b6c32a45-a8fff70000002755-62-6274c144fcf0 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id EB.55.11276.441C4726; Fri, 6 May 2022 15:33:40 +0900 (KST) Received: from ubuntu.dsn.sec.samsung.com (unknown [10.229.95.128]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220506063340epsmtip2baa6570955d62dfa934b8183334829ba~scHcZxRzm0642406424epsmtip2D; Fri, 6 May 2022 06:33:40 +0000 (GMT) From: Daehwan Jung To: Felipe Balbi , Greg Kroah-Hartman , Krzysztof Kozlowski , Alim Akhtar , Mathias Nyman , Lukas Bulwahn , Tony Lindgren , Juergen Gross , Arnd Bergmann , Matthias Kaehlcke Cc: linux-kernel@vger.kernel.org (open list), linux-usb@vger.kernel.org (open list:DESIGNWARE USB3 DRD IP DRIVER), linux-arm-kernel@lists.infradead.org (moderated list:ARM/SAMSUNG S3C, S5P AND EXYNOS ARM ARCHITECTURES), linux-samsung-soc@vger.kernel.org (open list:ARM/SAMSUNG S3C, S5P AND EXYNOS ARM ARCHITECTURES), sc.suh@samsung.com, taehyun.cho@samsung.com, jh0801.jung@samsung.com, eomji.oh@samsung.com, Daehwan Jung Subject: [PATCH RFC v5 6/6] usb: dwc3: dwc3-exynos: add host init Date: Fri, 6 May 2022 15:31:19 +0900 Message-Id: <1651818679-10594-7-git-send-email-dh10.jung@samsung.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1651818679-10594-1-git-send-email-dh10.jung@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrOJsWRmVeSWpSXmKPExsWy7bCmma7LwZIkg76ZVhYP5m1js/g76Ri7 xbG2J+wWdxZMY7I4tXwhk0Xz4vVsFnNuGlncffiDxWLv663sFpseX2O1uLxrDpvFjPP7mCwW LWtltmg52s5i0bxpCqvF5w2PGS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WbZRace1foljkAdepk07KRqtxe1du0dyRvl3rb4PEwVN9B9iY H6b8UGIpzkg01GIuKk4EACDKll8EAwAA X-CMS-MailID: 20220506063340epcas2p4c9d88670f9be952f3637e3a545a7d1da X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220506063340epcas2p4c9d88670f9be952f3637e3a545a7d1da References: <1651818679-10594-1-git-send-email-dh10.jung@samsung.com> X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is for xHCI Host Controller driver on Exynos SOC. It registers vendor ops before loading xhci platform driver. Signed-off-by: Daehwan Jung --- drivers/usb/dwc3/dwc3-exynos.c | 100 ++++++++++++++++++++++++++++++++- 1 file changed, 99 insertions(+), 1 deletion(-) diff --git a/drivers/usb/dwc3/dwc3-exynos.c b/drivers/usb/dwc3/dwc3-exynos.c index 0ecf20eeceee..c22ea5cd6ab0 100644 --- a/drivers/usb/dwc3/dwc3-exynos.c +++ b/drivers/usb/dwc3/dwc3-exynos.c @@ -17,6 +17,12 @@ #include #include +#include "core.h" + +#if IS_ENABLED(CONFIG_USB_XHCI_EXYNOS) +int xhci_exynos_register_vendor_ops(void); +#endif + #define DWC3_EXYNOS_MAX_CLOCKS 4 struct dwc3_exynos_driverdata { @@ -27,6 +33,7 @@ struct dwc3_exynos_driverdata { struct dwc3_exynos { struct device *dev; + struct dwc3 *dwc; const char **clk_names; struct clk *clks[DWC3_EXYNOS_MAX_CLOCKS]; @@ -46,12 +53,81 @@ static int dwc3_exynos_remove_child(struct device *dev, void *unused) return 0; } +#if IS_ENABLED(CONFIG_USB_XHCI_EXYNOS) +static int dwc3_exynos_host_init(struct dwc3_exynos *exynos) +{ + struct dwc3 *dwc = exynos->dwc; + struct device *dev = exynos->dev; + struct platform_device *xhci; + struct resource *res; + struct platform_device *dwc3_pdev = to_platform_device(dwc->dev); + int ret = 0; + + /* Configuration xhci resources */ + xhci_exynos_register_vendor_ops(); + + res = platform_get_resource(dwc3_pdev, IORESOURCE_MEM, 0); + if (!res) { + dev_err(dev, "missing memory resource\n"); + return -ENODEV; + } + dwc->xhci_resources[0].start = res->start; + dwc->xhci_resources[0].end = dwc->xhci_resources[0].start + + DWC3_XHCI_REGS_END; + dwc->xhci_resources[0].flags = res->flags; + dwc->xhci_resources[0].name = res->name; + + res = platform_get_resource(dwc3_pdev, IORESOURCE_IRQ, 0); + if (!res) { + dev_err(dev, "missing irq resource\n"); + return -ENODEV; + } + + dwc->xhci_resources[1].start = dwc->irq_gadget; + dwc->xhci_resources[1].end = dwc->irq_gadget; + dwc->xhci_resources[1].flags = res->flags; + dwc->xhci_resources[1].name = res->name; + + xhci = platform_device_alloc("xhci-hcd", PLATFORM_DEVID_AUTO); + if (!xhci) { + dev_err(dwc->dev, "couldn't allocate xHCI device\n"); + return -ENOMEM; + } + + xhci->dev.parent = dwc->dev; + ret = dma_set_mask_and_coherent(&xhci->dev, DMA_BIT_MASK(36)); + if (ret) { + pr_err("xhci dma set mask ret = %d\n", ret); + return ret; + } + + ret = platform_device_add_resources(xhci, dwc->xhci_resources, + DWC3_XHCI_RESOURCES_NUM); + if (ret) { + dev_err(dwc->dev, "couldn't add resources to xHCI device\n"); + goto err; + } + + ret = platform_device_add(xhci); + if (ret) { + dev_err(dwc->dev, "couldn't add xHCI device\n"); + goto err; + } + + return 0; +err: + platform_device_put(xhci); + return ret; +} +#endif + static int dwc3_exynos_probe(struct platform_device *pdev) { struct dwc3_exynos *exynos; struct device *dev = &pdev->dev; - struct device_node *node = dev->of_node; + struct device_node *node = dev->of_node, *dwc3_np; const struct dwc3_exynos_driverdata *driver_data; + struct platform_device *dwc3_pdev; int i, ret; exynos = devm_kzalloc(dev, sizeof(*exynos), GFP_KERNEL); @@ -109,6 +185,12 @@ static int dwc3_exynos_probe(struct platform_device *pdev) goto vdd10_err; } + dwc3_np = of_get_compatible_child(node, "snps,dwc3"); + if (!dwc3_np) { + dev_err(dev, "failed to find dwc3 core child!\n"); + goto vdd33_err; + } + if (node) { ret = of_platform_populate(node, NULL, NULL, dev); if (ret) { @@ -121,6 +203,22 @@ static int dwc3_exynos_probe(struct platform_device *pdev) goto populate_err; } + dwc3_pdev = of_find_device_by_node(dwc3_np); + exynos->dwc = platform_get_drvdata(dwc3_pdev); + if (!exynos->dwc) { + ret = -EPROBE_DEFER; + dev_err(dev, "failed to get dwc3 core node!\n"); + goto populate_err; + } + +#if IS_ENABLED(CONFIG_USB_XHCI_EXYNOS) + /* USB host initialization. */ + ret = dwc3_exynos_host_init(exynos); + if (ret) { + dev_err(dev, "USB host pre-initialization fail!\n"); + goto populate_err; + } +#endif return 0; populate_err: -- 2.31.1