[PATCH] misc: usb2244: Add support to reset usb2244 usb2.0 SD controller

Venkatesh Yadav Abbarapu venkatesh.abbarapu at amd.com
Fri Jan 12 05:47:28 CET 2024


Usb2244 driver needs to be reset to bring usb2244 out of reset. This
driver will reset the controller using gpio.

Signed-off-by: T Karthik Reddy <t.karthik.reddy at xilinx.com>
Signed-off-by: Venkatesh Yadav Abbarapu <venkatesh.abbarapu at amd.com>
---
 MAINTAINERS            |  1 +
 drivers/misc/Kconfig   |  8 +++++
 drivers/misc/Makefile  |  1 +
 drivers/misc/usb2244.c | 69 ++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 79 insertions(+)
 create mode 100644 drivers/misc/usb2244.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 1e950c3b45..be50fddc38 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -815,6 +815,7 @@ F:	drivers/i2c/i2c-cdns.c
 F:	drivers/i2c/muxes/pca954x.c
 F:	drivers/i2c/zynq_i2c.c
 F:	drivers/mailbox/zynqmp-ipi.c
+F:	drivers/misc/usb2244.c
 F:	drivers/misc/usb5744.c
 F:	drivers/mmc/zynq_sdhci.c
 F:	drivers/mtd/nand/raw/zynq_nand.c
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index b7022c31ee..3b6ca7d4bc 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -696,4 +696,12 @@ config USB5744
 	  This enables support for Microchip USB5744 Hub. This driver reset
 	  the hub using gpio pin and configure hub via i2c.
 
+config USB2244
+	bool "Microchip USB2244 Ultra Fast USB 2.0 SD driver"
+	depends on DM_USB && DM_GPIO
+	help
+	  This option enables support for Microchip USB2244 Ultra Fast USB 2.0
+	  SD controller. This driver will reset the usb2244 controller using a
+	  gpio pin.
+
 endmenu
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index 19f5afa885..82b7b92c0a 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -91,3 +91,4 @@ obj-$(CONFIG_ESM_K3) += k3_esm.o
 obj-$(CONFIG_ESM_PMIC) += esm_pmic.o
 obj-$(CONFIG_SL28CPLD) += sl28cpld.o
 obj-$(CONFIG_USB5744)  += usb5744.o
+obj-$(CONFIG_USB2244)  += usb2244.o
diff --git a/drivers/misc/usb2244.c b/drivers/misc/usb2244.c
new file mode 100644
index 0000000000..19dcd1eef6
--- /dev/null
+++ b/drivers/misc/usb2244.c
@@ -0,0 +1,69 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Driver for the Microchip USB2244 Ultra Fast USB 2.0 SD controller.
+ *
+ * Copyright (C) 2024,Advanced Micro Devices, Inc.
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <usb.h>
+#include <asm/gpio.h>
+#include <linux/delay.h>
+
+struct usb2244_priv {
+	struct gpio_desc reset_gpio;
+};
+
+static int usb2244_probe(struct udevice *dev)
+{
+	struct usb2244_priv *priv = dev_get_priv(dev);
+	int ret;
+
+	ret = dm_gpio_set_value(&priv->reset_gpio, 1);
+	if (ret)
+		return ret;
+
+	mdelay(5);
+
+	ret = dm_gpio_set_value(&priv->reset_gpio, 0);
+	if (ret)
+		return ret;
+
+	mdelay(5);
+
+	return 0;
+}
+
+static int usb2244_plat(struct udevice *dev)
+{
+	struct usb2244_priv *priv = dev_get_priv(dev);
+	int ret;
+
+	ret = gpio_request_by_name(dev, "reset-gpios", 0, &priv->reset_gpio,
+				   GPIOD_IS_OUT | GPIOD_ACTIVE_LOW);
+	if (ret) {
+		printf("%s, gpio request failed err: %d\n", __func__, ret);
+		return ret;
+	}
+
+	return 0;
+}
+
+U_BOOT_DRIVER(usb2244) = {
+	.name = "usb2244",
+	.id = UCLASS_MISC,
+	.probe = usb2244_probe,
+	.of_to_plat = usb2244_plat,
+	.priv_auto = sizeof(struct usb2244_priv),
+};
+
+static const struct usb_device_id usb2244_id_table[] = {
+	{
+		.idVendor = 0x0424,
+		.idProduct = 0x2240
+	},
+	{ }
+};
+
+U_BOOT_USB_DEVICE(usb2244, usb2244_id_table);
-- 
2.25.1



More information about the U-Boot mailing list