Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp3112100rdh; Thu, 28 Sep 2023 03:04:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGYm2kXDolxDxNWQnm865ky751nGSkZxax7mBZjVy6/AJ+LOKTupnLCm/CtCAvhT3wv8GCN X-Received: by 2002:a05:6a00:2e0e:b0:68f:cf6f:e212 with SMTP id fc14-20020a056a002e0e00b0068fcf6fe212mr621136pfb.20.1695895444924; Thu, 28 Sep 2023 03:04:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695895444; cv=none; d=google.com; s=arc-20160816; b=OI4dfDHBiXrhjplyiHAdnuWWat0uhjmw0om2eGS7/8vFB17noHQ1216mn9OC7pIT12 3izsZWgOw1Dz27v6SxSOzmw26dAjvP2wSGeLojbPpVKllsfQTht+ODP705rlyksZ/vhO HfHKAyKTSsCv8NXXh1S3071fDulnJHkKZe/EFOvwR6K1h7C3pAuhViOcToxr/yL13u2a zMbNEV2752JMxJzHY3LdtJcIlg4iakZFoiMlB8Z8ZykMyoOQNqszk5x7/0+0KudfblGt McPq6gbFWpito+ZPzEO8vthrwbWotVCHbMnoQ+EcTHWaFcbw1qa9RZ+1mVd+N3AIM3D+ bKuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=rc3mSsTelRM9+riVC9By4bVOpWW1+6+kMbhiVOvkGmc=; fh=1ZFgw0YHDIWduaWRfTBnDItdUVZfg1ZQGJTcoCRzi2c=; b=qqQRA+n+p8OyuTi3RZzza4Kw1sDytCVzzsYFEo8TROXOV433zsCmqrbV/LlBeMsM9w DUQQLzFr9E2DxdgEbl7kth/+e0YT29hDtmDEE9GY4gnE1iAn3thtIM/sgmbRMRfHy0yp SxB2KRbov+sWmbc42rdZ71dE8jcRRXajARoyQ636a8YhbiS0nm2m8c+CH0P47CdeMFSB Q85RLiVImWplmsEl7RtDCB613LqO9J3mhABnbtE8jKTPmZ3+TGOsVuYN227HY7jhNRF8 vmHzBWsZTH47VdmhdO0qMkW2n6LPL74TPbNYdyahsFYbbJJR4Oq1aZwiVoU6D+y6at3d 4XbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NMXSWKEl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id b7-20020a056a000cc700b0068ff3a3c9d0si3194533pfv.91.2023.09.28.03.04.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Sep 2023 03:04:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NMXSWKEl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id DF1AD8335285; Thu, 28 Sep 2023 02:56:14 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230320AbjI1J4G (ORCPT + 99 others); Thu, 28 Sep 2023 05:56:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230525AbjI1J4B (ORCPT ); Thu, 28 Sep 2023 05:56:01 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86D73180 for ; Thu, 28 Sep 2023 02:55:56 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 21997C433C8; Thu, 28 Sep 2023 09:55:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695894956; bh=+DSkHuvZmTOScbwhjWVKRNlUFglCaEELGK+8EY7Tp/I=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=NMXSWKElxk6xfVfY06vGjZCgODlqRzzee6ia03JW8afHrGDE771oQpZ3dPJehOEpH OQejT+hMGdVDQRswZqSOuzET/BZgEYVLIPBjPveFZh1PxSwsS5rt8eEOsduy/vQONM x5zAIKHBA6PpMj7zieC72VqN9I8Bmdlc0rEozi6tW9BN7iXDtmwU5I4xim7dAptRbX OTbtbLZMwG0yy6Qx80iiHFfeobSHARVHw3MEEiC0aKYLJKwPBOdQkYY/ZUtRZK864h HdJLTbIDJ9fg1yG3+e5b/vaZmxKHEnvdfnWwk0AxdKJeB6Xq41dIay69zk6PUw3M/w hqTmjwuJcMDow== Date: Thu, 28 Sep 2023 17:55:44 +0800 From: Peter Chen To: Tomer Maimon Cc: gregkh@linuxfoundation.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, xu.yang_2@nxp.com, peng.fan@nxp.com, avifishman70@gmail.com, tali.perry1@gmail.com, joel@jms.id.au, venture@google.com, yuenn@google.com, benjaminfair@google.com, j.neuschaefer@gmx.net, openbmc@lists.ozlabs.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: Re: [PATCH v2 3/3] usb: chipidea: Add support for NPCM Message-ID: <20230928095544.GB2081690@nchen-desktop> References: <20230927095509.267029-1-tmaimon77@gmail.com> <20230927095509.267029-4-tmaimon77@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230927095509.267029-4-tmaimon77@gmail.com> X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Thu, 28 Sep 2023 02:56:15 -0700 (PDT) On 23-09-27 12:55:09, Tomer Maimon wrote: > Add Nuvoton NPCM BMC SoCs support to USB ChipIdea driver. > NPCM SoC include ChipIdea IP block that used for USB device controller > mode. > > Signed-off-by: Tomer Maimon Acked-by: Peter Chen Peter > --- > drivers/usb/chipidea/Kconfig | 4 + > drivers/usb/chipidea/Makefile | 1 + > drivers/usb/chipidea/ci_hdrc_npcm.c | 117 ++++++++++++++++++++++++++++ > 3 files changed, 122 insertions(+) > create mode 100644 drivers/usb/chipidea/ci_hdrc_npcm.c > > diff --git a/drivers/usb/chipidea/Kconfig b/drivers/usb/chipidea/Kconfig > index c815824a0b2d..bab45bc62361 100644 > --- a/drivers/usb/chipidea/Kconfig > +++ b/drivers/usb/chipidea/Kconfig > @@ -43,6 +43,10 @@ config USB_CHIPIDEA_MSM > tristate "Enable MSM hsusb glue driver" if EXPERT > default USB_CHIPIDEA > > +config USB_CHIPIDEA_NPCM > + tristate "Enable NPCM hsusb glue driver" if EXPERT > + default USB_CHIPIDEA > + > config USB_CHIPIDEA_IMX > tristate "Enable i.MX USB glue driver" if EXPERT > depends on OF > diff --git a/drivers/usb/chipidea/Makefile b/drivers/usb/chipidea/Makefile > index 71afeab97e83..718cb24603dd 100644 > --- a/drivers/usb/chipidea/Makefile > +++ b/drivers/usb/chipidea/Makefile > @@ -13,6 +13,7 @@ ci_hdrc-$(CONFIG_USB_OTG_FSM) += otg_fsm.o > > obj-$(CONFIG_USB_CHIPIDEA_GENERIC) += ci_hdrc_usb2.o > obj-$(CONFIG_USB_CHIPIDEA_MSM) += ci_hdrc_msm.o > +obj-$(CONFIG_USB_CHIPIDEA_NPCM) += ci_hdrc_npcm.o > obj-$(CONFIG_USB_CHIPIDEA_PCI) += ci_hdrc_pci.o > obj-$(CONFIG_USB_CHIPIDEA_IMX) += usbmisc_imx.o ci_hdrc_imx.o > obj-$(CONFIG_USB_CHIPIDEA_TEGRA) += ci_hdrc_tegra.o > diff --git a/drivers/usb/chipidea/ci_hdrc_npcm.c b/drivers/usb/chipidea/ci_hdrc_npcm.c > new file mode 100644 > index 000000000000..4169855e7940 > --- /dev/null > +++ b/drivers/usb/chipidea/ci_hdrc_npcm.c > @@ -0,0 +1,117 @@ > +// SPDX-License-Identifier: GPL-2.0 > +// Copyright (c) 2023 Nuvoton Technology corporation. > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#include "ci.h" > + > +struct npcm_udc_data { > + struct platform_device *ci; > + struct clk *core_clk; > + struct ci_hdrc_platform_data pdata; > +}; > + > +static int npcm_udc_notify_event(struct ci_hdrc *ci, unsigned event) > +{ > + struct device *dev = ci->dev->parent; > + > + switch (event) { > + case CI_HDRC_CONTROLLER_RESET_EVENT: > + /* clear all mode bits */ > + hw_write(ci, OP_USBMODE, 0xffffffff, 0x0); > + break; > + default: > + dev_dbg(dev, "unknown ci_hdrc event\n"); > + break; > + } > + > + return 0; > +} > + > +static int npcm_udc_probe(struct platform_device *pdev) > +{ > + int ret; > + struct npcm_udc_data *ci; > + struct platform_device *plat_ci; > + struct device *dev = &pdev->dev; > + > + ci = devm_kzalloc(&pdev->dev, sizeof(*ci), GFP_KERNEL); > + if (!ci) > + return -ENOMEM; > + platform_set_drvdata(pdev, ci); > + > + ci->core_clk = devm_clk_get_optional(dev, NULL); > + if (IS_ERR(ci->core_clk)) > + return PTR_ERR(ci->core_clk); > + > + ret = clk_prepare_enable(ci->core_clk); > + if (ret) { > + dev_err(dev, "failed to enable the clock: %d\n", ret); > + return ret; > + } > + > + ci->pdata.name = dev_name(dev); > + ci->pdata.capoffset = DEF_CAPOFFSET; > + ci->pdata.flags = CI_HDRC_REQUIRES_ALIGNED_DMA | > + CI_HDRC_FORCE_VBUS_ACTIVE_ALWAYS; > + ci->pdata.phy_mode = USBPHY_INTERFACE_MODE_UTMI; > + ci->pdata.notify_event = npcm_udc_notify_event; > + > + plat_ci = ci_hdrc_add_device(dev, pdev->resource, pdev->num_resources, > + &ci->pdata); > + if (IS_ERR(plat_ci)) { > + ret = PTR_ERR(plat_ci); > + dev_err(dev, "failed to register HDRC NPCM device: %d\n", ret); > + goto clk_err; > + } > + > + pm_runtime_no_callbacks(dev); > + pm_runtime_enable(dev); > + > + return 0; > + > +clk_err: > + clk_disable_unprepare(ci->core_clk); > + return ret; > +} > + > +static int npcm_udc_remove(struct platform_device *pdev) > +{ > + struct npcm_udc_data *ci = platform_get_drvdata(pdev); > + > + pm_runtime_disable(&pdev->dev); > + ci_hdrc_remove_device(ci->ci); > + clk_disable_unprepare(ci->core_clk); > + > + return 0; > +} > + > +static const struct of_device_id npcm_udc_dt_match[] = { > + { .compatible = "nuvoton,npcm750-udc", }, > + { .compatible = "nuvoton,npcm845-udc", }, > + { } > +}; > +MODULE_DEVICE_TABLE(of, npcm_udc_dt_match); > + > +static struct platform_driver npcm_udc_driver = { > + .probe = npcm_udc_probe, > + .remove = npcm_udc_remove, > + .driver = { > + .name = "npcm_udc", > + .of_match_table = npcm_udc_dt_match, > + }, > +}; > + > +module_platform_driver(npcm_udc_driver); > + > +MODULE_DESCRIPTION("NPCM USB device controller driver"); > +MODULE_AUTHOR("Tomer Maimon "); > +MODULE_ALIAS("platform:npcm-udc"); > +MODULE_LICENSE("GPL v2"); > -- > 2.33.0 > -- Thanks, Peter Chen