Bladeren bron

usb:cdns3:Add StarFive wrapper driver for CDNS USB3 controller

Add driver to handle StarFive  specific wrapper for Cadence USB3 controller
present on JH7110  SoC.

Signed-off-by: yanhong.wang <yanhong.wang@starfivetech.com>
yanhong.wang 2 jaren geleden
bovenliggende
commit
11477926e3
3 gewijzigde bestanden met toevoegingen van 88 en 0 verwijderingen
  1. 8 0
      drivers/usb/cdns3/Kconfig
  2. 1 0
      drivers/usb/cdns3/Makefile
  3. 79 0
      drivers/usb/cdns3/cdns3-starfive.c

+ 8 - 0
drivers/usb/cdns3/Kconfig

@@ -55,4 +55,12 @@ config USB_CDNS3_TI
 	help
 	  Say 'Y' here if you are building for Texas Instruments
 	  platforms that contain Cadence USB3 controller core. E.g.: J721e.
+
+config USB_CDNS3_STARFIVE
+	tristate "Cadence USB3 support on StarFive SoC"
+	depends on USB_CDNS3
+	help
+	  Say 'Y' here if you are building for StarFive SoCs
+	  that contain Cadence USB3 controller core. E.g.: JH7110.
+
 endif

+ 1 - 0
drivers/usb/cdns3/Makefile

@@ -9,3 +9,4 @@ cdns3-$(CONFIG_$(SPL_)USB_CDNS3_GADGET)	+= gadget.o ep0.o
 cdns3-$(CONFIG_$(SPL_)USB_CDNS3_HOST)	+= host.o
 
 obj-$(CONFIG_USB_CDNS3_TI)		+= cdns3-ti.o
+obj-$(CONFIG_USB_CDNS3_STARFIVE)	+= cdns3-starfive.o

+ 79 - 0
drivers/usb/cdns3/cdns3-starfive.c

@@ -0,0 +1,79 @@
+// SPDX-License-Identifier: GPL-2.0
+/**
+ * cdns-starfive.c - Cadence USB Controller
+ *
+ * Copyright (C) 2022 Starfive, Inc.
+ * Author:	yanhong <yanhong.wang@starfivetech.com>
+ */
+
+#include <common.h>
+#include <clk.h>
+#include <dm.h>
+#include <dm/device_compat.h>
+#include <linux/usb/otg.h>
+#include <reset.h>
+
+#include "core.h"
+
+struct cdns_starfive {
+	struct udevice *dev;
+	struct clk_bulk clks;
+	struct reset_ctl_bulk resets;
+};
+
+static int cdns_starfive_probe(struct udevice *dev)
+{
+	struct cdns_starfive *data = dev_get_plat(dev);
+	int ret;
+
+	data->dev = dev;
+
+	ret = clk_get_bulk(dev, &data->clks);
+	if (ret)
+		goto err;
+
+	ret = reset_get_bulk(dev, &data->resets);
+	if (ret)
+		goto err_clk;
+
+	ret = clk_enable_bulk(&data->clks);
+	if (ret)
+		goto err_reset;
+
+	ret = reset_deassert_bulk(&data->resets);
+	if (ret)
+		goto err_reset;
+
+	return 0;
+err_reset:
+	reset_release_bulk(&data->resets);
+err_clk:
+	clk_release_bulk(&data->clks);
+err:
+	return ret;
+}
+
+static int cdns_starfive_remove(struct udevice *dev)
+{
+	struct cdns_starfive *data = dev_get_plat(dev);
+
+	clk_release_bulk(&data->clks);
+//	reset_assert_bulk(&data->resets);
+
+	return 0;
+}
+
+static const struct udevice_id cdns_starfive_of_match[] = {
+	{ .compatible = "starfive,jh7110-cdns3", },
+	{},
+};
+
+U_BOOT_DRIVER(cdns_starfive) = {
+	.name = "cdns-starfive",
+	.id = UCLASS_NOP,
+	.of_match = cdns_starfive_of_match,
+	.bind = cdns3_bind,
+	.probe = cdns_starfive_probe,
+	.remove = cdns_starfive_remove,
+	.plat_auto	= sizeof(struct cdns_starfive),
+};