From: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
To: Ze Huang <huangze@whut.edu.cn>
Cc: Vinod Koul <vkoul@kernel.org>,
Kishon Vijay Abraham I <kishon@kernel.org>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>, Yixun Lan <dlan@gentoo.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Philipp Zabel <p.zabel@pengutronix.de>,
Thinh Nguyen <Thinh.Nguyen@synopsys.com>,
Paul Walmsley <paul.walmsley@sifive.com>,
Palmer Dabbelt <palmer@dabbelt.com>,
Albert Ou <aou@eecs.berkeley.edu>,
Alexandre Ghiti <alex@ghiti.fr>,
"linux-phy@lists.infradead.org" <linux-phy@lists.infradead.org>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
"linux-riscv@lists.infradead.org"
<linux-riscv@lists.infradead.org>,
"spacemit@lists.linux.dev" <spacemit@lists.linux.dev>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>
Subject: Re: [PATCH 6/7] usb: dwc3: add spacemit dwc3 glue layer driver
Date: Wed, 9 Apr 2025 22:34:55 +0000 [thread overview]
Message-ID: <20250409223452.svwckotac4dbze6v@synopsys.com> (raw)
In-Reply-To: <20250407-b4-k1-usb3-v3-2-v1-6-bf0bcc41c9ba@whut.edu.cn>
On Mon, Apr 07, 2025, Ze Huang wrote:
> Add SpacemiT glue logic to support dwc3 HC on K1 SoC. The driver manages
> clock, reset and interrupt resource.
>
> Signed-off-by: Ze Huang <huangze@whut.edu.cn>
> ---
> drivers/usb/dwc3/Kconfig | 7 +++
> drivers/usb/dwc3/Makefile | 1 +
> drivers/usb/dwc3/dwc3-spacemit.c | 127 +++++++++++++++++++++++++++++++++++++++
> 3 files changed, 135 insertions(+)
>
> diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig
> index 310d182e10b50b253d7e5a51674806e6ec442a2a..3c30680fa4f83565fc03c6800e867c6ced0fe101 100644
> --- a/drivers/usb/dwc3/Kconfig
> +++ b/drivers/usb/dwc3/Kconfig
> @@ -189,4 +189,11 @@ config USB_DWC3_RTK
> or dual-role mode.
> Say 'Y' or 'M' if you have such device.
>
> +config USB_DWC3_SPACEMIT
> + tristate "Spacemit Platforms"
Does this depend on other configs like OF and COMMON_CLK?
> + default USB_DWC3
> + help
> + Support SPACEMIT platforms with DesignWare Core USB3 IP.
> + Say 'Y' or 'M' here if you have one such device
> +
> endif
> diff --git a/drivers/usb/dwc3/Makefile b/drivers/usb/dwc3/Makefile
> index 124eda2522d9c1f4caab222ec9770d0deaf655fc..61a87765c0c591e0a53c33b5a6544db056166f96 100644
> --- a/drivers/usb/dwc3/Makefile
> +++ b/drivers/usb/dwc3/Makefile
> @@ -56,3 +56,4 @@ obj-$(CONFIG_USB_DWC3_IMX8MP) += dwc3-imx8mp.o
> obj-$(CONFIG_USB_DWC3_XILINX) += dwc3-xilinx.o
> obj-$(CONFIG_USB_DWC3_OCTEON) += dwc3-octeon.o
> obj-$(CONFIG_USB_DWC3_RTK) += dwc3-rtk.o
> +obj-$(CONFIG_USB_DWC3_SPACEMIT) += dwc3-spacemit.o
> diff --git a/drivers/usb/dwc3/dwc3-spacemit.c b/drivers/usb/dwc3/dwc3-spacemit.c
> new file mode 100644
> index 0000000000000000000000000000000000000000..4574ad3b34a200ffe999c7da61b74c2ef33c0483
> --- /dev/null
> +++ b/drivers/usb/dwc3/dwc3-spacemit.c
> @@ -0,0 +1,127 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/*
> + * dwc3-spacemit.c - Spacemit DWC3 Specific Glue layer
> + *
> + * Copyright (C) 2025 SpacemiT (Hangzhou) Technology Co. Ltd
> + *
> + * Author: Wilson <long.wan@spacemit.com>
> + * Contributor: Ze Huang <huangze@whut.edu.cn>
> + */
> +
> +#include <linux/clk.h>
> +#include <linux/delay.h>
> +#include <linux/of_platform.h>
> +#include <linux/of_address.h>
> +#include <linux/platform_device.h>
> +#include <linux/reset.h>
> +
> +struct dwc3_spacemit {
> + struct device *dev;
> + struct clk *clk;
> + struct reset_control *reset;
> +};
> +
> +static int dwc3_spacemit_init(struct dwc3_spacemit *data)
> +{
> + struct device *dev = data->dev;
> + int ret = 0;
> +
> + data->reset = devm_reset_control_get(dev, NULL);
> + if (IS_ERR(data->reset))
> + return dev_err_probe(dev, PTR_ERR(data->reset), "failed to get reset\n");
> +
> + ret = reset_control_assert(data->reset);
> + if (ret)
> + return dev_err_probe(dev, ret, "failed to assert reset\n");
> +
> + usleep_range(10, 20);
> +
> + ret = reset_control_deassert(data->reset);
> + if (ret)
> + return dev_err_probe(dev, ret, "failed to deassert reset\n");
> +
> + return 0;
> +}
> +
> +static int dwc3_spacemit_probe(struct platform_device *pdev)
> +{
> + struct device *dev = &pdev->dev;
> + struct device_node *node = dev->of_node;
> + struct dwc3_spacemit *spacemit;
> + int ret;
> +
> + spacemit = devm_kzalloc(dev, sizeof(*spacemit), GFP_KERNEL);
> + if (!spacemit)
> + return -ENOMEM;
> +
> + spacemit->dev = dev;
> +
> + platform_set_drvdata(pdev, spacemit);
> +
> + spacemit->clk = devm_clk_get_enabled(dev, NULL);
> + if (IS_ERR(spacemit->clk))
> + return dev_err_probe(dev, PTR_ERR(spacemit->clk), "Failed to get clock\n");
> +
> + ret = dwc3_spacemit_init(spacemit);
> + if (ret)
> + return dev_err_probe(dev, ret, "failed to init SpacemiT USB3 glue\n");
> +
> + ret = of_platform_populate(node, NULL, NULL, dev);
> + if (ret)
> + dev_err_probe(dev, ret, "failed to add dwc3 core\n");
> +
> + return 0;
> +}
> +
> +static void dwc3_spacemit_remove(struct platform_device *pdev)
> +{
> + of_platform_depopulate(&pdev->dev);
> +}
> +
> +static const struct of_device_id spacemit_dwc3_match[] = {
> + { .compatible = "spacemit,k1-dwc3", },
> + { /* sentinel */ }
> +};
> +MODULE_DEVICE_TABLE(of, spacemit_dwc3_match);
> +
> +#ifdef CONFIG_PM_SLEEP
> +static int dwc3_spacemit_suspend(struct device *dev)
> +{
> + struct dwc3_spacemit *spacemit = dev_get_drvdata(dev);
> +
> + clk_disable_unprepare(spacemit->clk);
> +
> + return 0;
> +}
> +
> +static int dwc3_spacemit_resume(struct device *dev)
> +{
> + struct dwc3_spacemit *spacemit = dev_get_drvdata(dev);
> + int ret;
> +
> + ret = clk_prepare_enable(spacemit->clk);
> +
> + return ret;
> +}
> +
> +static const struct dev_pm_ops dwc3_spacemit_dev_pm_ops = {
> + SET_SYSTEM_SLEEP_PM_OPS(dwc3_spacemit_suspend, dwc3_spacemit_resume)
> +};
> +#endif /* CONFIG_PM_SLEEP */
> +
Use DEFINE_SIMPLE_DEV_PM_OPS to remove the CONFIG_PM_SLEEP guards.
> +static struct platform_driver dwc3_spacemit_driver = {
> + .probe = dwc3_spacemit_probe,
> + .remove = dwc3_spacemit_remove,
> + .driver = {
> + .name = "spacemit-dwc3",
> + .of_match_table = spacemit_dwc3_match,
> +#ifdef CONFIG_PM_SLEEP
> + .pm = &dwc3_spacemit_dev_pm_ops,
> +#endif /* CONFIG_PM_SLEEP */
> + },
> +};
> +module_platform_driver(dwc3_spacemit_driver);
> +
> +MODULE_AUTHOR("Wilson <long.wan@spacemit.com>");
The author is different than the commiter? Also, is there a last name?
> +MODULE_LICENSE("GPL");
> +MODULE_DESCRIPTION("DesignWare USB3 Spacemit Glue Layer");
>
> --
> 2.49.0
>
The logic in this glue driver looks quite simple. Can this platform work
as dwc3-of-simple?
Thanks,
Thinh
next prev parent reply other threads:[~2025-04-09 22:35 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-07 12:38 [PATCH 0/7] Add USB3.0 PHY and host controller support for SpacemiT K1 SoC Ze Huang
2025-04-07 12:38 ` [PATCH 1/7] dt-bindings: phy: spacemit: add K1 USB2 PHY Ze Huang
2025-04-07 13:18 ` Krzysztof Kozlowski
2025-04-09 8:01 ` Ze Huang
2025-04-10 20:53 ` Rob Herring (Arm)
2025-04-07 12:38 ` [PATCH 2/7] dt-bindings: phy: spacemit: add K1 PCIe/USB3 combo PHY Ze Huang
2025-04-07 13:20 ` Krzysztof Kozlowski
2025-04-09 8:05 ` Ze Huang
2025-04-07 12:38 ` [PATCH 3/7] dt-bindings: usb: add SpacemiT K1 DWC3 glue Ze Huang
2025-04-07 13:22 ` Krzysztof Kozlowski
2025-04-09 8:16 ` Ze Huang
2025-04-09 10:08 ` Krzysztof Kozlowski
2025-04-07 13:51 ` Rob Herring (Arm)
2025-04-09 8:30 ` Ze Huang
2025-04-07 12:38 ` [PATCH 4/7] phy: spacemit: support K1 USB2.0 PHY controller Ze Huang
2025-04-07 13:25 ` Krzysztof Kozlowski
2025-04-09 8:18 ` Ze Huang
2025-04-07 12:38 ` [PATCH 5/7] phy: spacemit: add USB3 support for K1 PCIe/USB3 combo PHY Ze Huang
2025-04-07 13:28 ` Krzysztof Kozlowski
2025-04-09 9:43 ` Ze Huang
2025-04-09 10:10 ` Krzysztof Kozlowski
2025-04-09 11:38 ` Pan Junzhong
2025-04-09 11:42 ` Ze Huang
2025-04-07 12:38 ` [PATCH 6/7] usb: dwc3: add spacemit dwc3 glue layer driver Ze Huang
2025-04-09 22:34 ` Thinh Nguyen [this message]
2025-04-10 1:34 ` Ze Huang
2025-04-07 12:38 ` [PATCH 7/7] riscv: dts: spacemit: add usb3.0 support for K1 Ze Huang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250409223452.svwckotac4dbze6v@synopsys.com \
--to=thinh.nguyen@synopsys.com \
--cc=alex@ghiti.fr \
--cc=aou@eecs.berkeley.edu \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dlan@gentoo.org \
--cc=gregkh@linuxfoundation.org \
--cc=huangze@whut.edu.cn \
--cc=kishon@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-phy@lists.infradead.org \
--cc=linux-riscv@lists.infradead.org \
--cc=linux-usb@vger.kernel.org \
--cc=p.zabel@pengutronix.de \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
--cc=robh@kernel.org \
--cc=spacemit@lists.linux.dev \
--cc=vkoul@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox