Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp4737668iob; Sun, 8 May 2022 23:47:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzPSQoJE0SU0y7rbBozeMh9Ry6l6yFXhXSOQINTPL/ugEFrSYz9M3MlpD5pD+x4Tnr4gD7Z X-Received: by 2002:a17:902:e84d:b0:15e:b0af:477b with SMTP id t13-20020a170902e84d00b0015eb0af477bmr15011494plg.49.1652078837880; Sun, 08 May 2022 23:47:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652078837; cv=none; d=google.com; s=arc-20160816; b=YsuO0BVR65MY9Y93f1KEiBuveHObG2YXVNOmn5rQiOp8407kuVbPUMhVTIICSgYUiK rJ72xUK7HfefAyAPrV1TtjfHd4FTBAeV7MLBiv2NPBBQACH+JXX+gIbaSubyrhOHoX9B 4oT1spNEOLt7CW72q8GTevcBMaakR9OzTuDwYy2dLPkITUfUKfz+LV61oLBPBqADdNe+ QVM4xBDT/CJmGg4OQQGwmNlylosvHgBMpJFJ4pX+kv8ukxW7MsoMYUP5h4NjZtUwO8LW f+mfzvDUvnJ0q192y2/fOlDsNgxG2KL0QdvV3YVqMmPT+BtE8phG4Gx+Xbu3f43PwwPb Qkwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=vpPJY/MuCwL+4BDvJjQZTcpmm42QCpbT7+0VDmHpTQE=; b=lA7xKjmr/+4GHk+WlnqXEdTmsSieC6s3RhIAyXSaag6d2YlSEthMIG/mgi0E1N337O gjKbmRUh8KvWTak6o6K7nAMCkxl90l64FKb2kckjLkNBUXBbP2Lgnsq+1fCCmJZP80Nr gQzTO6JcDObvO/T+aZBnBNEcLin9GthyDifXPyLv3ApJAI4ahNbg3XxHQuxTmIiMOo7c /+kT4Sk1Q0cL1h9bfI9U5rVZZT/O8KZgMoHb4XJnrr+6NQbFR/xy8gVOhCyDtZXWbqvd VYMP3hN9WQjM6bpnbcNlNp8MRZGuJs719zBdNpHQR7Cm0y+LPCPbMViubg0FPMyHjeJl wg0A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id y23-20020a056a00181700b0050df172cd76si14756184pfa.11.2022.05.08.23.47.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 May 2022 23:47:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 048451912F9; Sun, 8 May 2022 23:43:56 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1389718AbiEFHzw (ORCPT + 99 others); Fri, 6 May 2022 03:55:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1389648AbiEFHzr (ORCPT ); Fri, 6 May 2022 03:55:47 -0400 Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.17.13]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D04EEBC15 for ; Fri, 6 May 2022 00:52:04 -0700 (PDT) Received: from mail-wr1-f43.google.com ([209.85.221.43]) by mrelayeu.kundenserver.de (mreue106 [213.165.67.113]) with ESMTPSA (Nemesis) id 1MPoTl-1nRcTw0K4B-00Mum3 for ; Fri, 06 May 2022 09:52:03 +0200 Received: by mail-wr1-f43.google.com with SMTP id c11so8898328wrn.8; Fri, 06 May 2022 00:52:03 -0700 (PDT) X-Gm-Message-State: AOAM530gqc5NG27NEqrWTQBxNWZiFRtdQPPsCaTA5+WlYnkubOC1hAnt G5D0bpY7zPzC/6k5O7L4x7EAJM2wAEi627uGN3Y= X-Received: by 2002:adf:e106:0:b0:20a:b31b:213d with SMTP id t6-20020adfe106000000b0020ab31b213dmr1568918wrz.219.1651823522731; Fri, 06 May 2022 00:52:02 -0700 (PDT) MIME-Version: 1.0 References: <1651818679-10594-1-git-send-email-dh10.jung@samsung.com> <1651818679-10594-7-git-send-email-dh10.jung@samsung.com> In-Reply-To: <1651818679-10594-7-git-send-email-dh10.jung@samsung.com> From: Arnd Bergmann Date: Fri, 6 May 2022 09:51:46 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH RFC v5 6/6] usb: dwc3: dwc3-exynos: add host init To: Daehwan Jung Cc: Felipe Balbi , Greg Kroah-Hartman , Krzysztof Kozlowski , Alim Akhtar , Mathias Nyman , Lukas Bulwahn , Tony Lindgren , Juergen Gross , Arnd Bergmann , Matthias Kaehlcke , open list , "open list:DESIGNWARE USB3 DRD IP DRIVER" , "moderated list:ARM/SAMSUNG S3C, S5P AND EXYNOS ARM ARCHITECTURES" , "open list:ARM/SAMSUNG S3C, S5P AND EXYNOS ARM ARCHITECTURES" , sc.suh@samsung.com, taehyun cho , jh0801.jung@samsung.com, eomji.oh@samsung.com Content-Type: text/plain; charset="UTF-8" X-Provags-ID: V03:K1:llXLQQxS6plLe7tKgrP4wsTvLfVS5V8EaDJtOEg1Wl0TqeU9JWU C+GWVTzEX4Mzr/Q+yZMmTFL3GZPKBoqRONzPVmhqo3X1MA5maHa5lgV2rd2QliJRb65kClS 9FCf4coLA88S8U6Mq0Z0T6Of7NrKRvgxtgIxnUNrFTAZagcqpjpvGHA2wlvX0iqGky9TOJS IoLmQVb7GDfTxx4of1Kig== X-UI-Out-Filterresults: notjunk:1;V03:K0:KLkmFtElyig=:8gfzD3mz5UVFEiPXnZzfij JclPc73xV6pp6RWXT1NmOX4DwoNZfVGUAG4hx8Wyn0k/OWNmL/2Riz2xRDDyS+U7r/1fgbdNs PSL4Vn48G9DFYJFZeiDkupr+zlwXUDFB8xJfoBs9SENh79X54yQnFuN7ydcj/Db5kxVj2Cf/W awJOC0yMpV7wcPWMP+uP2VAr43EA0ETy7+LFYJ9Y6N6e2EfIbGgfgBY9/LlIoviH2KgadEJbL qkj1kRQG55PGJssrd30cBdAU8u1CX1xjdCXVttx8oKruWwZPq7+HFNVaAXNRihqlmrvKR2KBk 9Sz4bAAl4BpJhS8lF5GDEzm3/DvfThnAtID9IZF5JDV6XrCmMPAwVh/skbGhQJiF/0NfCu6sf HKzeyfCVy2eApIOMWSSTjkst65bRqMBoK1XGMRQlwj4DdnQOwBOGhfgRDUlN7DsUjW02JIb5w ScRJDekQvZ7j0Q+t+SoO3rM9Gf07OIMlPt140fYX9K7CZalLldS0QbC++roW/erWScIiZSbXx TsB7keVYu5bb1kzcQGgn8ldEkTTOjVxj+alp+sogOXgTrZD+N/ILrRaaAD7k7BE5erPBbFH3B rvXVFbusjweBHKuYITVW9+7srnKWPAnAgyDR3Hit65f/TqVIV0aOMG21JSmQC/5tG+oHjUPgf VT68zzuXxqjh+nDnfK5s1ZywUApPZ1LnUQh3VUxJZDmdrMgUL6wV8uf2IIlCEy5gOUX+rxDJM +z5E4KFxQ+QZXEpx6KCnoyUjU3ptNQ6Dd98Jg+uk12JKgbXTwZFUyFndBejAqXm+9NVdwbpP1 1TG2MGAkX6goXIkA15ftkGPKRa9w78VEJ2OYc4enbadvBH14Fc= X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 On Fri, May 6, 2022 at 8:31 AM Daehwan Jung wrote: > > 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 Function declarations should always be in a header file, and not guarded by an #ifdef. This particular one is probably not needed anyway if the driver is done correctly though, see below. > @@ -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; > + } This looks like you have the abstraction backwards from what normal drivers do. If you need a specialization of a driver that already exists, create a new driver module with a platform_driver that matches the specialized of_device_id, and have it call into the more general driver, do avoid having the general driver know about the specializations. Allocating a platform_device and making it DMA capable doesn't generally work correctly, and misses the IOMMU setup, so make sure you have a device node for it instead and probe it from DT. Arnd