From patchwork Fri May 6 06:31:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jung Daehwan X-Patchwork-Id: 570429 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DD37BC433F5 for ; Fri, 6 May 2022 06:34:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1380576AbiEFGhp (ORCPT ); Fri, 6 May 2022 02:37:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352175AbiEFGha (ORCPT ); Fri, 6 May 2022 02:37:30 -0400 Received: from mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A78E66202 for ; Thu, 5 May 2022 23:33:48 -0700 (PDT) Received: from epcas2p1.samsung.com (unknown [182.195.41.53]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20220506063346epoutp02538118954d7f0e0515ff5f24ebc0bcd9~scHiFrOGP1115411154epoutp02H for ; Fri, 6 May 2022 06:33:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20220506063346epoutp02538118954d7f0e0515ff5f24ebc0bcd9~scHiFrOGP1115411154epoutp02H 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 LWtltmg52s5i0bxpCqvF5w2PGS267t5gtJh0UNRi/xUvB2GP378mMXp8+zqJxWN2w0UWj52z 7rJ7LN7zkslj06pONo871/aweeyfu4bdY/OSeo++LasYPdZvucri8XmTXABPVLZNRmpiSmqR Qmpecn5KZl66rZJ3cLxzvKmZgaGuoaWFuZJCXmJuqq2Si0+ArltmDtCHSgpliTmlQKGAxOJi JX07m6L80pJUhYz84hJbpdSClJwC8wK94sTc4tK8dL281BIrQwMDI1OgwoTsjKari9kLWpQq XlxuYW9gbJLpYuTkkBAwkeg51sTYxcjFISSwg1Hi2ukjzBDOJ0aJXbs3soNUCQl8Y5R49b0Q puPohpssEEV7GSVWXfrBCuH8YJRYP+UZWxcjBwebgJbE94VgY0UEpjNLnFzTywbiMAuc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eqzfcpXF4/MmuQCeKC6blNSczLLU In27BK6MpquL2QtalCpeXG5hb2Bskuli5OSQEDCROLrhJksXIxeHkMBuRoknU5+yQCQkJZbO vcEOYQtL3G85wgpR9I1RouPvXbYuRg4ONgEtie8LGUFqRATmMkts3VoEUsMscJZZ4s/T1WA1 wgKOEss38oLUsAioSkxp3coEYvMKuEq8P9kONV9O4ua5TmYQm1PATeLS1C1gM4WAahb++c48 gZFvASPDKkbJ1ILi3PTcYsMCw7zUcr3ixNzi0rx0veT83E2M4FjR0tzBuH3VB71DjEwcjIcY JTiYlUR4hWeVJAnxpiRWVqUW5ccXleakFh9ilOZgURLnvdB1Ml5IID2xJDU7NbUgtQgmy8TB KdXAdDrL8UagtMslFsYdm/6vmWSealDhGrDSoTBxhpfix79Tn+6Y88xrnla0k/T3A+8lvwXI letd3Rpy7UiZh3S6nsbpql+Wv7lTT23xm+gcyCAxIX3dxW3bwq5ldnxISVV7vX3+kdlLu8q3 bfpb8LmuyzKuz02ugLd8umBmco11wLyrr+Q15u9xzq7XbEnX9s9e0Wn3YodBdtfCmmmxJ162 L6tw/tqWNbnn56tDa5OD/FcIBt0vCrbx2f3xSFEem3+W2rSMj9tnCqzev6QtdOUK8Y+zGvcx FP91qT1n6TRB2/yn78azdcsWbZRace1foljkAdepk07KRqtxe1du0dyRvl3rb4PEwVN9B9iY H6b8UGIpzkg01GIuKk4EACDKll8EAwAA X-CMS-MailID: 20220506063340epcas2p4c9d88670f9be952f3637e3a545a7d1da X-Msg-Generator: CA 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> Precedence: bulk List-ID: X-Mailing-List: linux-usb@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: