public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH 01/17] dm: usb: udc: Factor out plain udevice handler functions
@ 2023-08-19 14:23 Marek Vasut
  2023-08-19 14:23 ` [PATCH 02/17] usb: sandbox: Add DM_USB_GADGET support Marek Vasut
                   ` (17 more replies)
  0 siblings, 18 replies; 33+ messages in thread
From: Marek Vasut @ 2023-08-19 14:23 UTC (permalink / raw)
  To: u-boot
  Cc: Marek Vasut, Angus Ainslie, Dmitrii Merkurev, Eddie Cai,
	Kever Yang, Lukasz Majewski, Miquel Raynal, Mattijs Korpershoek,
	Nishanth Menon, Patrice Chotard, Patrick Delaunay,
	Philipp Tomsich, Simon Glass, Stefan Roese, kernel

Pull the functionality of UDC uclass that operates on plain udevice
and does not use this dev_array array into separate functions and
expose those functions, so that as much code as possible can be
switched over to these functions and the dev_array can be dropped.

Signed-off-by: Marek Vasut <marex@denx.de>
---
Cc: Angus Ainslie <angus@akkea.ca>
Cc: Dmitrii Merkurev <dimorinny@google.com>
Cc: Eddie Cai <eddie.cai.linux@gmail.com>
Cc: Kever Yang <kever.yang@rock-chips.com>
Cc: Lukasz Majewski <lukma@denx.de>
Cc: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: Mattijs Korpershoek <mkorpershoek@baylibre.com>
Cc: Nishanth Menon <nm@ti.com>
Cc: Patrice Chotard <patrice.chotard@foss.st.com>
Cc: Patrick Delaunay <patrick.delaunay@foss.st.com>
Cc: Philipp Tomsich <philipp.tomsich@vrull.eu>
Cc: Simon Glass <sjg@chromium.org>
Cc: Stefan Roese <sr@denx.de>
Cc: kernel@puri.sm
---
 drivers/usb/gadget/udc/Makefile     |  2 +-
 drivers/usb/gadget/udc/udc-uclass.c | 57 +++++++++++++++++++++++++----
 include/linux/usb/gadget.h          | 17 +++++++++
 3 files changed, 68 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/gadget/udc/Makefile b/drivers/usb/gadget/udc/Makefile
index 95dbf0c82ee..467c566f6d3 100644
--- a/drivers/usb/gadget/udc/Makefile
+++ b/drivers/usb/gadget/udc/Makefile
@@ -7,4 +7,4 @@ obj-$(CONFIG_USB_DWC3_GADGET)	+= udc-core.o
 endif
 
 obj-$(CONFIG_$(SPL_)DM_USB_GADGET)	+= udc-core.o
-obj-$(CONFIG_$(SPL_)DM) += udc-uclass.o
+obj-y += udc-uclass.o
diff --git a/drivers/usb/gadget/udc/udc-uclass.c b/drivers/usb/gadget/udc/udc-uclass.c
index de8861829c7..b4271b4be9f 100644
--- a/drivers/usb/gadget/udc/udc-uclass.c
+++ b/drivers/usb/gadget/udc/udc-uclass.c
@@ -14,6 +14,37 @@
 #if CONFIG_IS_ENABLED(DM_USB_GADGET)
 #define MAX_UDC_DEVICES 4
 static struct udevice *dev_array[MAX_UDC_DEVICES];
+
+int udc_device_get_by_index(int index, struct udevice **udev)
+{
+	struct udevice *dev = NULL;
+	int ret;
+
+	ret = uclass_get_device_by_seq(UCLASS_USB_GADGET_GENERIC, index, &dev);
+	if (!ret && dev) {
+		*udev = dev;
+		return 0;
+	}
+
+	ret = uclass_get_device(UCLASS_USB_GADGET_GENERIC, index, &dev);
+	if (!ret && dev) {
+		*udev = dev;
+		return 0;
+	}
+
+	pr_err("No USB device found\n");
+	return -ENODEV;
+}
+
+int udc_device_put(struct udevice *udev)
+{
+#if CONFIG_IS_ENABLED(DM_DEVICE_REMOVE)
+	return device_remove(udev, DM_REMOVE_NORMAL);
+#else
+	return -ENOSYS;
+#endif
+}
+
 int usb_gadget_initialize(int index)
 {
 	int ret;
@@ -23,13 +54,10 @@ int usb_gadget_initialize(int index)
 		return -EINVAL;
 	if (dev_array[index])
 		return 0;
-	ret = uclass_get_device_by_seq(UCLASS_USB_GADGET_GENERIC, index, &dev);
+	ret = udc_device_get_by_index(index, &dev);
 	if (!dev || ret) {
-		ret = uclass_get_device(UCLASS_USB_GADGET_GENERIC, index, &dev);
-		if (!dev || ret) {
-			pr_err("No USB device found\n");
-			return -ENODEV;
-		}
+		pr_err("No USB device found\n");
+		return -ENODEV;
 	}
 	dev_array[index] = dev;
 	return 0;
@@ -42,7 +70,7 @@ int usb_gadget_release(int index)
 	if (index < 0 || index >= ARRAY_SIZE(dev_array))
 		return -EINVAL;
 
-	ret = device_remove(dev_array[index], DM_REMOVE_NORMAL);
+	ret = device_remove(dev_array[index]);
 	if (!ret)
 		dev_array[index] = NULL;
 	return ret;
@@ -57,10 +85,25 @@ int usb_gadget_handle_interrupts(int index)
 		return -EINVAL;
 	return dm_usb_gadget_handle_interrupts(dev_array[index]);
 }
+#else
+/* Backwards hardware compatibility -- switch to DM_USB_GADGET */
+static int legacy_index;
+int udc_device_get_by_index(int index, struct udevice **udev)
+{
+	legacy_index = index;
+	return board_usb_init(index, USB_INIT_DEVICE);
+}
+
+int udc_device_put(struct udevice *udev)
+{
+	return board_usb_cleanup(legacy_index, USB_INIT_DEVICE);
+}
 #endif
 
+#if CONFIG_IS_ENABLED(DM)
 UCLASS_DRIVER(usb_gadget_generic) = {
 	.id		= UCLASS_USB_GADGET_GENERIC,
 	.name		= "usb",
 	.flags		= DM_UC_FLAG_SEQ_ALIAS,
 };
+#endif
diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
index 2f694fc25c1..5e9a6513d5b 100644
--- a/include/linux/usb/gadget.h
+++ b/include/linux/usb/gadget.h
@@ -1006,6 +1006,23 @@ extern void usb_ep_autoconfig_reset(struct usb_gadget *);
 
 extern int usb_gadget_handle_interrupts(int index);
 
+/**
+ * udc_device_get_by_index() - Get UDC udevice by index
+ * @index: UDC device index
+ * @udev: UDC udevice matching the index (if found)
+ *
+ * Return: 0 if Ok, -ve on error
+ */
+int udc_device_get_by_index(int index, struct udevice **udev);
+
+/**
+ * udc_device_put() - Put UDC udevice
+ * @udev: UDC udevice
+ *
+ * Return: 0 if Ok, -ve on error
+ */
+int udc_device_put(struct udevice *udev);
+
 #if CONFIG_IS_ENABLED(DM_USB_GADGET)
 int usb_gadget_initialize(int index);
 int usb_gadget_release(int index);
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 02/17] usb: sandbox: Add DM_USB_GADGET support
  2023-08-19 14:23 [PATCH 01/17] dm: usb: udc: Factor out plain udevice handler functions Marek Vasut
@ 2023-08-19 14:23 ` Marek Vasut
  2023-08-20 17:48   ` Simon Glass
  2023-08-22 16:10   ` Mattijs Korpershoek
  2023-08-19 14:23 ` [PATCH 03/17] configs: sandbox: Enable DM_USB_GADGET Marek Vasut
                   ` (16 subsequent siblings)
  17 siblings, 2 replies; 33+ messages in thread
From: Marek Vasut @ 2023-08-19 14:23 UTC (permalink / raw)
  To: u-boot
  Cc: Marek Vasut, Angus Ainslie, Dmitrii Merkurev, Eddie Cai,
	Kever Yang, Lukasz Majewski, Miquel Raynal, Mattijs Korpershoek,
	Nishanth Menon, Patrice Chotard, Patrick Delaunay,
	Philipp Tomsich, Simon Glass, Stefan Roese, kernel

Remove local usb_gadget_register_driver()/usb_gadget_unregister_driver()
implementation which is implemented in udc-core.c instead if DM_USB_GADGET
is enabled. Add no-op dm_usb_gadget_handle_interrupts() implementation.

Signed-off-by: Marek Vasut <marex@denx.de>
---
Cc: Angus Ainslie <angus@akkea.ca>
Cc: Dmitrii Merkurev <dimorinny@google.com>
Cc: Eddie Cai <eddie.cai.linux@gmail.com>
Cc: Kever Yang <kever.yang@rock-chips.com>
Cc: Lukasz Majewski <lukma@denx.de>
Cc: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: Mattijs Korpershoek <mkorpershoek@baylibre.com>
Cc: Nishanth Menon <nm@ti.com>
Cc: Patrice Chotard <patrice.chotard@foss.st.com>
Cc: Patrick Delaunay <patrick.delaunay@foss.st.com>
Cc: Philipp Tomsich <philipp.tomsich@vrull.eu>
Cc: Simon Glass <sjg@chromium.org>
Cc: Stefan Roese <sr@denx.de>
Cc: kernel@puri.sm
---
 drivers/usb/host/usb-sandbox.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/usb/host/usb-sandbox.c b/drivers/usb/host/usb-sandbox.c
index d1103dcb2e9..582f72d00c1 100644
--- a/drivers/usb/host/usb-sandbox.c
+++ b/drivers/usb/host/usb-sandbox.c
@@ -124,6 +124,12 @@ static int sandbox_submit_int(struct udevice *bus, struct usb_device *udev,
 	return ret;
 }
 
+#if CONFIG_IS_ENABLED(DM_USB_GADGET)
+int dm_usb_gadget_handle_interrupts(struct udevice *dev)
+{
+	return 0;
+}
+#else
 int usb_gadget_handle_interrupts(int index)
 {
 	return 0;
@@ -144,6 +150,7 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
 
 	return 0;
 }
+#endif
 
 static int sandbox_alloc_device(struct udevice *dev, struct usb_device *udev)
 {
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 03/17] configs: sandbox: Enable DM_USB_GADGET
  2023-08-19 14:23 [PATCH 01/17] dm: usb: udc: Factor out plain udevice handler functions Marek Vasut
  2023-08-19 14:23 ` [PATCH 02/17] usb: sandbox: Add DM_USB_GADGET support Marek Vasut
@ 2023-08-19 14:23 ` Marek Vasut
  2023-08-20 17:48   ` Simon Glass
  2023-08-22 16:10   ` Mattijs Korpershoek
  2023-08-19 14:23 ` [PATCH 04/17] cmd: fastboot: Use plain udevice for UDC controller interaction Marek Vasut
                   ` (15 subsequent siblings)
  17 siblings, 2 replies; 33+ messages in thread
From: Marek Vasut @ 2023-08-19 14:23 UTC (permalink / raw)
  To: u-boot
  Cc: Marek Vasut, Angus Ainslie, Dmitrii Merkurev, Eddie Cai,
	Kever Yang, Lukasz Majewski, Miquel Raynal, Mattijs Korpershoek,
	Nishanth Menon, Patrice Chotard, Patrick Delaunay,
	Philipp Tomsich, Simon Glass, Stefan Roese, kernel

Switch sandbox to DM_USB_GADGET, DM is the future.

Signed-off-by: Marek Vasut <marex@denx.de>
---
Cc: Angus Ainslie <angus@akkea.ca>
Cc: Dmitrii Merkurev <dimorinny@google.com>
Cc: Eddie Cai <eddie.cai.linux@gmail.com>
Cc: Kever Yang <kever.yang@rock-chips.com>
Cc: Lukasz Majewski <lukma@denx.de>
Cc: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: Mattijs Korpershoek <mkorpershoek@baylibre.com>
Cc: Nishanth Menon <nm@ti.com>
Cc: Patrice Chotard <patrice.chotard@foss.st.com>
Cc: Patrick Delaunay <patrick.delaunay@foss.st.com>
Cc: Philipp Tomsich <philipp.tomsich@vrull.eu>
Cc: Simon Glass <sjg@chromium.org>
Cc: Stefan Roese <sr@denx.de>
Cc: kernel@puri.sm
---
 configs/sandbox64_defconfig        | 1 +
 configs/sandbox_defconfig          | 1 +
 configs/sandbox_flattree_defconfig | 1 +
 configs/sandbox_noinst_defconfig   | 1 +
 configs/sandbox_spl_defconfig      | 1 +
 configs/sandbox_vpl_defconfig      | 1 +
 6 files changed, 6 insertions(+)

diff --git a/configs/sandbox64_defconfig b/configs/sandbox64_defconfig
index 69e5efe8748..72452695cdc 100644
--- a/configs/sandbox64_defconfig
+++ b/configs/sandbox64_defconfig
@@ -230,6 +230,7 @@ CONFIG_TIMER=y
 CONFIG_TIMER_EARLY=y
 CONFIG_SANDBOX_TIMER=y
 CONFIG_USB=y
+CONFIG_DM_USB_GADGET=y
 CONFIG_USB_EMUL=y
 CONFIG_USB_KEYBOARD=y
 CONFIG_VIDEO=y
diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig
index 1cd1c2ed7cd..9f8b81f5fe6 100644
--- a/configs/sandbox_defconfig
+++ b/configs/sandbox_defconfig
@@ -298,6 +298,7 @@ CONFIG_TIMER=y
 CONFIG_TIMER_EARLY=y
 CONFIG_SANDBOX_TIMER=y
 CONFIG_USB=y
+CONFIG_DM_USB_GADGET=y
 CONFIG_USB_EMUL=y
 CONFIG_USB_KEYBOARD=y
 CONFIG_USB_GADGET=y
diff --git a/configs/sandbox_flattree_defconfig b/configs/sandbox_flattree_defconfig
index 8aa295686dc..cedae60d3cf 100644
--- a/configs/sandbox_flattree_defconfig
+++ b/configs/sandbox_flattree_defconfig
@@ -204,6 +204,7 @@ CONFIG_TIMER=y
 CONFIG_TIMER_EARLY=y
 CONFIG_SANDBOX_TIMER=y
 CONFIG_USB=y
+CONFIG_DM_USB_GADGET=y
 CONFIG_USB_EMUL=y
 CONFIG_USB_KEYBOARD=y
 CONFIG_VIDEO=y
diff --git a/configs/sandbox_noinst_defconfig b/configs/sandbox_noinst_defconfig
index 2c6aab6c859..360686b9682 100644
--- a/configs/sandbox_noinst_defconfig
+++ b/configs/sandbox_noinst_defconfig
@@ -218,6 +218,7 @@ CONFIG_TIMER=y
 CONFIG_TIMER_EARLY=y
 CONFIG_SANDBOX_TIMER=y
 CONFIG_USB=y
+CONFIG_DM_USB_GADGET=y
 CONFIG_USB_EMUL=y
 CONFIG_USB_KEYBOARD=y
 CONFIG_VIDEO=y
diff --git a/configs/sandbox_spl_defconfig b/configs/sandbox_spl_defconfig
index 8d50162b274..bc79adfcd8f 100644
--- a/configs/sandbox_spl_defconfig
+++ b/configs/sandbox_spl_defconfig
@@ -224,6 +224,7 @@ CONFIG_TIMER=y
 CONFIG_TIMER_EARLY=y
 CONFIG_SANDBOX_TIMER=y
 CONFIG_USB=y
+CONFIG_DM_USB_GADGET=y
 CONFIG_USB_EMUL=y
 CONFIG_USB_KEYBOARD=y
 CONFIG_VIDEO=y
diff --git a/configs/sandbox_vpl_defconfig b/configs/sandbox_vpl_defconfig
index f3a0fd19a96..2c817b3847d 100644
--- a/configs/sandbox_vpl_defconfig
+++ b/configs/sandbox_vpl_defconfig
@@ -237,6 +237,7 @@ CONFIG_VPL_TIMER=y
 CONFIG_TIMER_EARLY=y
 CONFIG_SANDBOX_TIMER=y
 CONFIG_USB=y
+CONFIG_DM_USB_GADGET=y
 CONFIG_USB_EMUL=y
 CONFIG_USB_KEYBOARD=y
 CONFIG_VIDEO=y
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 04/17] cmd: fastboot: Use plain udevice for UDC controller interaction
  2023-08-19 14:23 [PATCH 01/17] dm: usb: udc: Factor out plain udevice handler functions Marek Vasut
  2023-08-19 14:23 ` [PATCH 02/17] usb: sandbox: Add DM_USB_GADGET support Marek Vasut
  2023-08-19 14:23 ` [PATCH 03/17] configs: sandbox: Enable DM_USB_GADGET Marek Vasut
@ 2023-08-19 14:23 ` Marek Vasut
  2023-08-22 16:22   ` Mattijs Korpershoek
  2023-08-19 14:23 ` [PATCH 05/17] cmd: rockusb: " Marek Vasut
                   ` (14 subsequent siblings)
  17 siblings, 1 reply; 33+ messages in thread
From: Marek Vasut @ 2023-08-19 14:23 UTC (permalink / raw)
  To: u-boot
  Cc: Marek Vasut, Angus Ainslie, Dmitrii Merkurev, Eddie Cai,
	Kever Yang, Lukasz Majewski, Miquel Raynal, Mattijs Korpershoek,
	Nishanth Menon, Patrice Chotard, Patrick Delaunay,
	Philipp Tomsich, Simon Glass, Stefan Roese, kernel

Convert to plain udevice interaction with UDC controller
device, avoid the use of UDC uclass dev_array .

Signed-off-by: Marek Vasut <marex@denx.de>
---
Cc: Angus Ainslie <angus@akkea.ca>
Cc: Dmitrii Merkurev <dimorinny@google.com>
Cc: Eddie Cai <eddie.cai.linux@gmail.com>
Cc: Kever Yang <kever.yang@rock-chips.com>
Cc: Lukasz Majewski <lukma@denx.de>
Cc: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: Mattijs Korpershoek <mkorpershoek@baylibre.com>
Cc: Nishanth Menon <nm@ti.com>
Cc: Patrice Chotard <patrice.chotard@foss.st.com>
Cc: Patrick Delaunay <patrick.delaunay@foss.st.com>
Cc: Philipp Tomsich <philipp.tomsich@vrull.eu>
Cc: Simon Glass <sjg@chromium.org>
Cc: Stefan Roese <sr@denx.de>
Cc: kernel@puri.sm
---
 cmd/fastboot.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/cmd/fastboot.c b/cmd/fastboot.c
index 3d5ff951eb6..17fb0a0aa7b 100644
--- a/cmd/fastboot.c
+++ b/cmd/fastboot.c
@@ -61,6 +61,7 @@ static int do_fastboot_usb(int argc, char *const argv[],
 {
 	int controller_index;
 	char *usb_controller;
+	struct udevice *udc;
 	char *endp;
 	int ret;
 
@@ -79,7 +80,7 @@ static int do_fastboot_usb(int argc, char *const argv[],
 		return CMD_RET_FAILURE;
 	}
 
-	ret = usb_gadget_initialize(controller_index);
+	ret = udc_device_get_by_index(controller_index, &udc);
 	if (ret) {
 		pr_err("USB init failed: %d\n", ret);
 		return CMD_RET_FAILURE;
@@ -103,13 +104,13 @@ static int do_fastboot_usb(int argc, char *const argv[],
 		if (ctrlc())
 			break;
 		schedule();
-		usb_gadget_handle_interrupts(controller_index);
+		dm_usb_gadget_handle_interrupts(udc);
 	}
 
 	ret = CMD_RET_SUCCESS;
 
 exit:
-	usb_gadget_release(controller_index);
+	udc_device_put(udc);
 	g_dnl_unregister();
 	g_dnl_clear_detach();
 
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 05/17] cmd: rockusb: Use plain udevice for UDC controller interaction
  2023-08-19 14:23 [PATCH 01/17] dm: usb: udc: Factor out plain udevice handler functions Marek Vasut
                   ` (2 preceding siblings ...)
  2023-08-19 14:23 ` [PATCH 04/17] cmd: fastboot: Use plain udevice for UDC controller interaction Marek Vasut
@ 2023-08-19 14:23 ` Marek Vasut
  2023-08-19 14:23 ` [PATCH 06/17] cmd: sdp: Reorder variable declaration Marek Vasut
                   ` (13 subsequent siblings)
  17 siblings, 0 replies; 33+ messages in thread
From: Marek Vasut @ 2023-08-19 14:23 UTC (permalink / raw)
  To: u-boot
  Cc: Marek Vasut, Angus Ainslie, Dmitrii Merkurev, Eddie Cai,
	Kever Yang, Lukasz Majewski, Miquel Raynal, Mattijs Korpershoek,
	Nishanth Menon, Patrice Chotard, Patrick Delaunay,
	Philipp Tomsich, Simon Glass, Stefan Roese, kernel

Convert to plain udevice interaction with UDC controller
device, avoid the use of UDC uclass dev_array .

Signed-off-by: Marek Vasut <marex@denx.de>
---
Cc: Angus Ainslie <angus@akkea.ca>
Cc: Dmitrii Merkurev <dimorinny@google.com>
Cc: Eddie Cai <eddie.cai.linux@gmail.com>
Cc: Kever Yang <kever.yang@rock-chips.com>
Cc: Lukasz Majewski <lukma@denx.de>
Cc: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: Mattijs Korpershoek <mkorpershoek@baylibre.com>
Cc: Nishanth Menon <nm@ti.com>
Cc: Patrice Chotard <patrice.chotard@foss.st.com>
Cc: Patrick Delaunay <patrick.delaunay@foss.st.com>
Cc: Philipp Tomsich <philipp.tomsich@vrull.eu>
Cc: Simon Glass <sjg@chromium.org>
Cc: Stefan Roese <sr@denx.de>
Cc: kernel@puri.sm
---
 cmd/rockusb.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/cmd/rockusb.c b/cmd/rockusb.c
index f181ec61119..07088564a10 100644
--- a/cmd/rockusb.c
+++ b/cmd/rockusb.c
@@ -15,6 +15,7 @@ static int do_rockusb(struct cmd_tbl *cmdtp, int flag, int argc,
 {
 	int controller_index, dev_index;
 	char *usb_controller;
+	struct udevice *udc;
 	char *devtype;
 	char *devnum;
 	int ret;
@@ -34,7 +35,7 @@ static int do_rockusb(struct cmd_tbl *cmdtp, int flag, int argc,
 	dev_index = simple_strtoul(devnum, NULL, 0);
 	rockusb_dev_init(devtype, dev_index);
 
-	ret = usb_gadget_initialize(controller_index);
+	ret = udc_device_get_by_index(controller_index, &udc);
 	if (ret) {
 		printf("USB init failed: %d\n", ret);
 		return CMD_RET_FAILURE;
@@ -56,14 +57,14 @@ static int do_rockusb(struct cmd_tbl *cmdtp, int flag, int argc,
 			break;
 		if (ctrlc())
 			break;
-		usb_gadget_handle_interrupts(controller_index);
+		dm_usb_gadget_handle_interrupts(udc);
 	}
 	ret = CMD_RET_SUCCESS;
 
 exit:
 	g_dnl_unregister();
 	g_dnl_clear_detach();
-	usb_gadget_release(controller_index);
+	udc_device_put(udc);
 
 	return ret;
 }
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 06/17] cmd: sdp: Reorder variable declaration
  2023-08-19 14:23 [PATCH 01/17] dm: usb: udc: Factor out plain udevice handler functions Marek Vasut
                   ` (3 preceding siblings ...)
  2023-08-19 14:23 ` [PATCH 05/17] cmd: rockusb: " Marek Vasut
@ 2023-08-19 14:23 ` Marek Vasut
  2023-08-22 16:24   ` Mattijs Korpershoek
  2023-08-19 14:23 ` [PATCH 07/17] cmd: thordown: " Marek Vasut
                   ` (12 subsequent siblings)
  17 siblings, 1 reply; 33+ messages in thread
From: Marek Vasut @ 2023-08-19 14:23 UTC (permalink / raw)
  To: u-boot
  Cc: Marek Vasut, Angus Ainslie, Dmitrii Merkurev, Eddie Cai,
	Kever Yang, Lukasz Majewski, Miquel Raynal, Mattijs Korpershoek,
	Nishanth Menon, Patrice Chotard, Patrick Delaunay,
	Philipp Tomsich, Simon Glass, Stefan Roese, kernel

Move the variable declaration around to improve code readability.
No functional change.

Signed-off-by: Marek Vasut <marex@denx.de>
---
Cc: Angus Ainslie <angus@akkea.ca>
Cc: Dmitrii Merkurev <dimorinny@google.com>
Cc: Eddie Cai <eddie.cai.linux@gmail.com>
Cc: Kever Yang <kever.yang@rock-chips.com>
Cc: Lukasz Majewski <lukma@denx.de>
Cc: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: Mattijs Korpershoek <mkorpershoek@baylibre.com>
Cc: Nishanth Menon <nm@ti.com>
Cc: Patrice Chotard <patrice.chotard@foss.st.com>
Cc: Patrick Delaunay <patrick.delaunay@foss.st.com>
Cc: Philipp Tomsich <philipp.tomsich@vrull.eu>
Cc: Simon Glass <sjg@chromium.org>
Cc: Stefan Roese <sr@denx.de>
Cc: kernel@puri.sm
---
 cmd/usb_gadget_sdp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/cmd/usb_gadget_sdp.c b/cmd/usb_gadget_sdp.c
index 1af82e11366..784d1b49768 100644
--- a/cmd/usb_gadget_sdp.c
+++ b/cmd/usb_gadget_sdp.c
@@ -14,13 +14,13 @@
 
 static int do_sdp(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 {
+	int controller_index;
 	int ret;
 
 	if (argc < 2)
 		return CMD_RET_USAGE;
 
-	char *usb_controller = argv[1];
-	int controller_index = simple_strtoul(usb_controller, NULL, 0);
+	controller_index = simple_strtoul(argv[1], NULL, 0);
 	usb_gadget_initialize(controller_index);
 
 	g_dnl_clear_detach();
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 07/17] cmd: thordown: Reorder variable declaration
  2023-08-19 14:23 [PATCH 01/17] dm: usb: udc: Factor out plain udevice handler functions Marek Vasut
                   ` (4 preceding siblings ...)
  2023-08-19 14:23 ` [PATCH 06/17] cmd: sdp: Reorder variable declaration Marek Vasut
@ 2023-08-19 14:23 ` Marek Vasut
  2023-08-19 14:23 ` [PATCH 08/17] cmd: ums: Use plain udevice for UDC controller interaction Marek Vasut
                   ` (11 subsequent siblings)
  17 siblings, 0 replies; 33+ messages in thread
From: Marek Vasut @ 2023-08-19 14:23 UTC (permalink / raw)
  To: u-boot
  Cc: Marek Vasut, Angus Ainslie, Dmitrii Merkurev, Eddie Cai,
	Kever Yang, Lukasz Majewski, Miquel Raynal, Mattijs Korpershoek,
	Nishanth Menon, Patrice Chotard, Patrick Delaunay,
	Philipp Tomsich, Simon Glass, Stefan Roese, kernel

Move the variable declaration around to improve code readability.
No functional change.

Signed-off-by: Marek Vasut <marex@denx.de>
---
Cc: Angus Ainslie <angus@akkea.ca>
Cc: Dmitrii Merkurev <dimorinny@google.com>
Cc: Eddie Cai <eddie.cai.linux@gmail.com>
Cc: Kever Yang <kever.yang@rock-chips.com>
Cc: Lukasz Majewski <lukma@denx.de>
Cc: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: Mattijs Korpershoek <mkorpershoek@baylibre.com>
Cc: Nishanth Menon <nm@ti.com>
Cc: Patrice Chotard <patrice.chotard@foss.st.com>
Cc: Patrick Delaunay <patrick.delaunay@foss.st.com>
Cc: Philipp Tomsich <philipp.tomsich@vrull.eu>
Cc: Simon Glass <sjg@chromium.org>
Cc: Stefan Roese <sr@denx.de>
Cc: kernel@puri.sm
---
 cmd/thordown.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/cmd/thordown.c b/cmd/thordown.c
index 838764ccef7..0d8dcee5314 100644
--- a/cmd/thordown.c
+++ b/cmd/thordown.c
@@ -15,22 +15,23 @@
 
 int do_thor_down(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 {
+	char *interface, *devstring;
+	int controller_index;
+	int ret;
+
 	if (argc < 4)
 		return CMD_RET_USAGE;
 
-	char *usb_controller = argv[1];
-	char *interface = argv[2];
-	char *devstring = argv[3];
-
-	int ret;
-
 	puts("TIZEN \"THOR\" Downloader\n");
 
+	interface = argv[2];
+	devstring = argv[3];
+
 	ret = dfu_init_env_entities(interface, devstring);
 	if (ret)
 		goto done;
 
-	int controller_index = simple_strtoul(usb_controller, NULL, 0);
+	controller_index = simple_strtoul(argv[1], NULL, 0);
 	ret = usb_gadget_initialize(controller_index);
 	if (ret) {
 		pr_err("USB init failed: %d\n", ret);
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 08/17] cmd: ums: Use plain udevice for UDC controller interaction
  2023-08-19 14:23 [PATCH 01/17] dm: usb: udc: Factor out plain udevice handler functions Marek Vasut
                   ` (5 preceding siblings ...)
  2023-08-19 14:23 ` [PATCH 07/17] cmd: thordown: " Marek Vasut
@ 2023-08-19 14:23 ` Marek Vasut
  2023-08-22 16:29   ` Mattijs Korpershoek
  2023-08-19 14:23 ` [PATCH 09/17] dfu: Detach the controller on error Marek Vasut
                   ` (10 subsequent siblings)
  17 siblings, 1 reply; 33+ messages in thread
From: Marek Vasut @ 2023-08-19 14:23 UTC (permalink / raw)
  To: u-boot
  Cc: Marek Vasut, Angus Ainslie, Dmitrii Merkurev, Eddie Cai,
	Kever Yang, Lukasz Majewski, Miquel Raynal, Mattijs Korpershoek,
	Nishanth Menon, Patrice Chotard, Patrick Delaunay,
	Philipp Tomsich, Simon Glass, Stefan Roese, kernel

Convert to plain udevice interaction with UDC controller
device, avoid the use of UDC uclass dev_array .

Signed-off-by: Marek Vasut <marex@denx.de>
---
Cc: Angus Ainslie <angus@akkea.ca>
Cc: Dmitrii Merkurev <dimorinny@google.com>
Cc: Eddie Cai <eddie.cai.linux@gmail.com>
Cc: Kever Yang <kever.yang@rock-chips.com>
Cc: Lukasz Majewski <lukma@denx.de>
Cc: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: Mattijs Korpershoek <mkorpershoek@baylibre.com>
Cc: Nishanth Menon <nm@ti.com>
Cc: Patrice Chotard <patrice.chotard@foss.st.com>
Cc: Patrick Delaunay <patrick.delaunay@foss.st.com>
Cc: Philipp Tomsich <philipp.tomsich@vrull.eu>
Cc: Simon Glass <sjg@chromium.org>
Cc: Stefan Roese <sr@denx.de>
Cc: kernel@puri.sm
---
 cmd/usb_mass_storage.c              | 10 ++++++----
 drivers/usb/gadget/f_mass_storage.c |  8 ++++----
 include/usb_mass_storage.h          |  2 +-
 3 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/cmd/usb_mass_storage.c b/cmd/usb_mass_storage.c
index c3cc1975f9d..9c51ae0967f 100644
--- a/cmd/usb_mass_storage.c
+++ b/cmd/usb_mass_storage.c
@@ -143,6 +143,7 @@ static int do_usb_mass_storage(struct cmd_tbl *cmdtp, int flag,
 	const char *devtype;
 	const char *devnum;
 	unsigned int controller_index;
+	struct udevice *udc;
 	int rc;
 	int cable_ready_timeout __maybe_unused;
 
@@ -164,13 +165,14 @@ static int do_usb_mass_storage(struct cmd_tbl *cmdtp, int flag,
 
 	controller_index = (unsigned int)(simple_strtoul(
 				usb_controller,	NULL, 0));
-	if (usb_gadget_initialize(controller_index)) {
+	rc = udc_device_get_by_index(controller_index, &udc);
+	if (rc) {
 		pr_err("Couldn't init USB controller.\n");
 		rc = CMD_RET_FAILURE;
 		goto cleanup_ums_init;
 	}
 
-	rc = fsg_init(ums, ums_count, controller_index);
+	rc = fsg_init(ums, ums_count, udc);
 	if (rc) {
 		pr_err("fsg_init failed\n");
 		rc = CMD_RET_FAILURE;
@@ -215,7 +217,7 @@ static int do_usb_mass_storage(struct cmd_tbl *cmdtp, int flag,
 	}
 
 	while (1) {
-		usb_gadget_handle_interrupts(controller_index);
+		dm_usb_gadget_handle_interrupts(udc);
 
 		rc = fsg_main_thread(NULL);
 		if (rc) {
@@ -247,7 +249,7 @@ static int do_usb_mass_storage(struct cmd_tbl *cmdtp, int flag,
 cleanup_register:
 	g_dnl_unregister();
 cleanup_board:
-	usb_gadget_release(controller_index);
+	udc_device_put(udc);
 cleanup_ums_init:
 	ums_fini();
 
diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c
index f46829eb7ad..1d17331cb03 100644
--- a/drivers/usb/gadget/f_mass_storage.c
+++ b/drivers/usb/gadget/f_mass_storage.c
@@ -435,7 +435,7 @@ static void set_bulk_out_req_length(struct fsg_common *common,
 static struct ums *ums;
 static int ums_count;
 static struct fsg_common *the_fsg_common;
-static unsigned int controller_index;
+static struct udevice *udcdev;
 
 static int fsg_set_halt(struct fsg_dev *fsg, struct usb_ep *ep)
 {
@@ -680,7 +680,7 @@ static int sleep_thread(struct fsg_common *common)
 			k = 0;
 		}
 
-		usb_gadget_handle_interrupts(controller_index);
+		dm_usb_gadget_handle_interrupts(udcdev);
 	}
 	common->thread_wakeup_needed = 0;
 	return rc;
@@ -2764,11 +2764,11 @@ int fsg_add(struct usb_configuration *c)
 	return fsg_bind_config(c->cdev, c, fsg_common);
 }
 
-int fsg_init(struct ums *ums_devs, int count, unsigned int controller_idx)
+int fsg_init(struct ums *ums_devs, int count, struct udevice *udc)
 {
 	ums = ums_devs;
 	ums_count = count;
-	controller_index = controller_idx;
+	udcdev = udc;
 
 	return 0;
 }
diff --git a/include/usb_mass_storage.h b/include/usb_mass_storage.h
index 08ccc97cf22..83ab93b530d 100644
--- a/include/usb_mass_storage.h
+++ b/include/usb_mass_storage.h
@@ -25,7 +25,7 @@ struct ums {
 	struct blk_desc block_dev;
 };
 
-int fsg_init(struct ums *ums_devs, int count, unsigned int controller_idx);
+int fsg_init(struct ums *ums_devs, int count, struct udevice *udc);
 void fsg_cleanup(void);
 int fsg_main_thread(void *);
 int fsg_add(struct usb_configuration *c);
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 09/17] dfu: Detach the controller on error
  2023-08-19 14:23 [PATCH 01/17] dm: usb: udc: Factor out plain udevice handler functions Marek Vasut
                   ` (6 preceding siblings ...)
  2023-08-19 14:23 ` [PATCH 08/17] cmd: ums: Use plain udevice for UDC controller interaction Marek Vasut
@ 2023-08-19 14:23 ` Marek Vasut
  2023-08-22 16:32   ` Mattijs Korpershoek
  2023-08-19 14:24 ` [PATCH 10/17] dfu: Use plain udevice for UDC controller interaction Marek Vasut
                   ` (9 subsequent siblings)
  17 siblings, 1 reply; 33+ messages in thread
From: Marek Vasut @ 2023-08-19 14:23 UTC (permalink / raw)
  To: u-boot
  Cc: Marek Vasut, Angus Ainslie, Dmitrii Merkurev, Eddie Cai,
	Kever Yang, Lukasz Majewski, Miquel Raynal, Mattijs Korpershoek,
	Nishanth Menon, Patrice Chotard, Patrick Delaunay,
	Philipp Tomsich, Simon Glass, Stefan Roese, kernel

In case anything errors out during the DFU registration, detach
the controller instead of bailing out right away. This way, the
controller can be reattached on next attempt.

Signed-off-by: Marek Vasut <marex@denx.de>
---
Cc: Angus Ainslie <angus@akkea.ca>
Cc: Dmitrii Merkurev <dimorinny@google.com>
Cc: Eddie Cai <eddie.cai.linux@gmail.com>
Cc: Kever Yang <kever.yang@rock-chips.com>
Cc: Lukasz Majewski <lukma@denx.de>
Cc: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: Mattijs Korpershoek <mkorpershoek@baylibre.com>
Cc: Nishanth Menon <nm@ti.com>
Cc: Patrice Chotard <patrice.chotard@foss.st.com>
Cc: Patrick Delaunay <patrick.delaunay@foss.st.com>
Cc: Philipp Tomsich <philipp.tomsich@vrull.eu>
Cc: Simon Glass <sjg@chromium.org>
Cc: Stefan Roese <sr@denx.de>
Cc: kernel@puri.sm
---
 common/dfu.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/common/dfu.c b/common/dfu.c
index 96190889ab7..32fba84da16 100644
--- a/common/dfu.c
+++ b/common/dfu.c
@@ -34,7 +34,8 @@ int run_usb_dnl_gadget(int usbctrl_index, char *usb_dnl_gadget)
 	ret = g_dnl_register(usb_dnl_gadget);
 	if (ret) {
 		pr_err("g_dnl_register failed");
-		return CMD_RET_FAILURE;
+		ret = CMD_RET_FAILURE;
+		goto err_detach;
 	}
 
 #ifdef CONFIG_DFU_TIMEOUT
@@ -106,6 +107,7 @@ int run_usb_dnl_gadget(int usbctrl_index, char *usb_dnl_gadget)
 	}
 exit:
 	g_dnl_unregister();
+err_detach:
 	usb_gadget_release(usbctrl_index);
 
 	if (dfu_reset)
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 10/17] dfu: Use plain udevice for UDC controller interaction
  2023-08-19 14:23 [PATCH 01/17] dm: usb: udc: Factor out plain udevice handler functions Marek Vasut
                   ` (7 preceding siblings ...)
  2023-08-19 14:23 ` [PATCH 09/17] dfu: Detach the controller on error Marek Vasut
@ 2023-08-19 14:24 ` Marek Vasut
  2023-08-22 16:33   ` Mattijs Korpershoek
  2023-08-19 14:24 ` [PATCH 11/17] spl: sdp: Detach the controller on error Marek Vasut
                   ` (8 subsequent siblings)
  17 siblings, 1 reply; 33+ messages in thread
From: Marek Vasut @ 2023-08-19 14:24 UTC (permalink / raw)
  To: u-boot
  Cc: Marek Vasut, Angus Ainslie, Dmitrii Merkurev, Eddie Cai,
	Kever Yang, Lukasz Majewski, Miquel Raynal, Mattijs Korpershoek,
	Nishanth Menon, Patrice Chotard, Patrick Delaunay,
	Philipp Tomsich, Simon Glass, Stefan Roese, kernel

Convert to plain udevice interaction with UDC controller
device, avoid the use of UDC uclass dev_array .

Signed-off-by: Marek Vasut <marex@denx.de>
---
Cc: Angus Ainslie <angus@akkea.ca>
Cc: Dmitrii Merkurev <dimorinny@google.com>
Cc: Eddie Cai <eddie.cai.linux@gmail.com>
Cc: Kever Yang <kever.yang@rock-chips.com>
Cc: Lukasz Majewski <lukma@denx.de>
Cc: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: Mattijs Korpershoek <mkorpershoek@baylibre.com>
Cc: Nishanth Menon <nm@ti.com>
Cc: Patrice Chotard <patrice.chotard@foss.st.com>
Cc: Patrick Delaunay <patrick.delaunay@foss.st.com>
Cc: Philipp Tomsich <philipp.tomsich@vrull.eu>
Cc: Simon Glass <sjg@chromium.org>
Cc: Stefan Roese <sr@denx.de>
Cc: kernel@puri.sm
---
 common/dfu.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/common/dfu.c b/common/dfu.c
index 32fba84da16..45206b9e225 100644
--- a/common/dfu.c
+++ b/common/dfu.c
@@ -23,11 +23,12 @@
 int run_usb_dnl_gadget(int usbctrl_index, char *usb_dnl_gadget)
 {
 	bool dfu_reset = false;
+	struct udevice *udc;
 	int ret, i = 0;
 
-	ret = usb_gadget_initialize(usbctrl_index);
+	ret = udc_device_get_by_index(usbctrl_index, &udc);
 	if (ret) {
-		pr_err("usb_gadget_initialize failed\n");
+		pr_err("udc_device_get_by_index failed\n");
 		return CMD_RET_FAILURE;
 	}
 	g_dnl_clear_detach();
@@ -55,7 +56,7 @@ int run_usb_dnl_gadget(int usbctrl_index, char *usb_dnl_gadget)
 			}
 
 			/*
-			 * This extra number of usb_gadget_handle_interrupts()
+			 * This extra number of dm_usb_gadget_handle_interrupts()
 			 * calls is necessary to assure correct transmission
 			 * completion with dfu-util
 			 */
@@ -68,7 +69,7 @@ int run_usb_dnl_gadget(int usbctrl_index, char *usb_dnl_gadget)
 
 		if (dfu_get_defer_flush()) {
 			/*
-			 * Call to usb_gadget_handle_interrupts() is necessary
+			 * Call to dm_usb_gadget_handle_interrupts() is necessary
 			 * to act on ZLP OUT transaction from HOST PC after
 			 * transmitting the whole file.
 			 *
@@ -77,7 +78,7 @@ int run_usb_dnl_gadget(int usbctrl_index, char *usb_dnl_gadget)
 			 * 5 seconds). In such situation the dfu-util program
 			 * exits with error message.
 			 */
-			usb_gadget_handle_interrupts(usbctrl_index);
+			dm_usb_gadget_handle_interrupts(udc);
 			ret = dfu_flush(dfu_get_defer_flush(), NULL, 0, 0);
 			dfu_set_defer_flush(NULL);
 			if (ret) {
@@ -103,12 +104,12 @@ int run_usb_dnl_gadget(int usbctrl_index, char *usb_dnl_gadget)
 			goto exit;
 
 		schedule();
-		usb_gadget_handle_interrupts(usbctrl_index);
+		dm_usb_gadget_handle_interrupts(udc);
 	}
 exit:
 	g_dnl_unregister();
 err_detach:
-	usb_gadget_release(usbctrl_index);
+	udc_device_put(udc);
 
 	if (dfu_reset)
 		do_reset(NULL, 0, 0, NULL);
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 11/17] spl: sdp: Detach the controller on error
  2023-08-19 14:23 [PATCH 01/17] dm: usb: udc: Factor out plain udevice handler functions Marek Vasut
                   ` (8 preceding siblings ...)
  2023-08-19 14:24 ` [PATCH 10/17] dfu: Use plain udevice for UDC controller interaction Marek Vasut
@ 2023-08-19 14:24 ` Marek Vasut
  2023-08-22 16:44   ` Mattijs Korpershoek
  2023-08-19 14:24 ` [PATCH 12/17] sdp: Use plain udevice for UDC controller interaction Marek Vasut
                   ` (7 subsequent siblings)
  17 siblings, 1 reply; 33+ messages in thread
From: Marek Vasut @ 2023-08-19 14:24 UTC (permalink / raw)
  To: u-boot
  Cc: Marek Vasut, Angus Ainslie, Dmitrii Merkurev, Eddie Cai,
	Kever Yang, Lukasz Majewski, Miquel Raynal, Mattijs Korpershoek,
	Nishanth Menon, Patrice Chotard, Patrick Delaunay,
	Philipp Tomsich, Simon Glass, Stefan Roese, kernel

In case anything errors out during the SDP transfer, detach
the controller instead of bailing out right away. This way,
the controller can be reattached on next attempt.

Signed-off-by: Marek Vasut <marex@denx.de>
---
Cc: Angus Ainslie <angus@akkea.ca>
Cc: Dmitrii Merkurev <dimorinny@google.com>
Cc: Eddie Cai <eddie.cai.linux@gmail.com>
Cc: Kever Yang <kever.yang@rock-chips.com>
Cc: Lukasz Majewski <lukma@denx.de>
Cc: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: Mattijs Korpershoek <mkorpershoek@baylibre.com>
Cc: Nishanth Menon <nm@ti.com>
Cc: Patrice Chotard <patrice.chotard@foss.st.com>
Cc: Patrick Delaunay <patrick.delaunay@foss.st.com>
Cc: Philipp Tomsich <philipp.tomsich@vrull.eu>
Cc: Simon Glass <sjg@chromium.org>
Cc: Stefan Roese <sr@denx.de>
Cc: kernel@puri.sm
---
 common/spl/spl_sdp.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/common/spl/spl_sdp.c b/common/spl/spl_sdp.c
index cc4fb4f7cca..f6b99c1af5a 100644
--- a/common/spl/spl_sdp.c
+++ b/common/spl/spl_sdp.c
@@ -25,13 +25,13 @@ static int spl_sdp_load_image(struct spl_image_info *spl_image,
 	ret = g_dnl_register("usb_dnl_sdp");
 	if (ret) {
 		pr_err("SDP dnl register failed: %d\n", ret);
-		return ret;
+		goto err_detach;
 	}
 
 	ret = sdp_init(controller_index);
 	if (ret) {
 		pr_err("SDP init failed: %d\n", ret);
-		return -ENODEV;
+		goto err_detach;
 	}
 
 	/*
@@ -42,6 +42,7 @@ static int spl_sdp_load_image(struct spl_image_info *spl_image,
 	ret = spl_sdp_handle(controller_index, spl_image, bootdev);
 	debug("SDP ended\n");
 
+err_detach:
 	usb_gadget_release(controller_index);
 	return ret;
 }
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 12/17] sdp: Use plain udevice for UDC controller interaction
  2023-08-19 14:23 [PATCH 01/17] dm: usb: udc: Factor out plain udevice handler functions Marek Vasut
                   ` (9 preceding siblings ...)
  2023-08-19 14:24 ` [PATCH 11/17] spl: sdp: Detach the controller on error Marek Vasut
@ 2023-08-19 14:24 ` Marek Vasut
  2023-08-22 16:46   ` Mattijs Korpershoek
  2023-08-19 14:24 ` [PATCH 13/17] thordown: " Marek Vasut
                   ` (6 subsequent siblings)
  17 siblings, 1 reply; 33+ messages in thread
From: Marek Vasut @ 2023-08-19 14:24 UTC (permalink / raw)
  To: u-boot
  Cc: Marek Vasut, Angus Ainslie, Dmitrii Merkurev, Eddie Cai,
	Kever Yang, Lukasz Majewski, Miquel Raynal, Mattijs Korpershoek,
	Nishanth Menon, Patrice Chotard, Patrick Delaunay,
	Philipp Tomsich, Simon Glass, Stefan Roese, kernel

Convert to plain udevice interaction with UDC controller
device, avoid the use of UDC uclass dev_array .

Signed-off-by: Marek Vasut <marex@denx.de>
---
Cc: Angus Ainslie <angus@akkea.ca>
Cc: Dmitrii Merkurev <dimorinny@google.com>
Cc: Eddie Cai <eddie.cai.linux@gmail.com>
Cc: Kever Yang <kever.yang@rock-chips.com>
Cc: Lukasz Majewski <lukma@denx.de>
Cc: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: Mattijs Korpershoek <mkorpershoek@baylibre.com>
Cc: Nishanth Menon <nm@ti.com>
Cc: Patrice Chotard <patrice.chotard@foss.st.com>
Cc: Patrick Delaunay <patrick.delaunay@foss.st.com>
Cc: Philipp Tomsich <philipp.tomsich@vrull.eu>
Cc: Simon Glass <sjg@chromium.org>
Cc: Stefan Roese <sr@denx.de>
Cc: kernel@puri.sm
---
 cmd/usb_gadget_sdp.c       | 11 +++++++----
 common/spl/spl_sdp.c       | 13 ++++++++-----
 drivers/usb/gadget/f_sdp.c | 10 +++++-----
 include/sdp.h              |  6 +++---
 4 files changed, 23 insertions(+), 17 deletions(-)

diff --git a/cmd/usb_gadget_sdp.c b/cmd/usb_gadget_sdp.c
index 784d1b49768..748aa0a7488 100644
--- a/cmd/usb_gadget_sdp.c
+++ b/cmd/usb_gadget_sdp.c
@@ -15,13 +15,16 @@
 static int do_sdp(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 {
 	int controller_index;
+	struct udevice *udc;
 	int ret;
 
 	if (argc < 2)
 		return CMD_RET_USAGE;
 
 	controller_index = simple_strtoul(argv[1], NULL, 0);
-	usb_gadget_initialize(controller_index);
+	ret = udc_device_get_by_index(controller_index, &udc);
+	if (ret)
+		return ret;
 
 	g_dnl_clear_detach();
 	ret = g_dnl_register("usb_dnl_sdp");
@@ -30,20 +33,20 @@ static int do_sdp(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 		goto exit_register;
 	}
 
-	ret = sdp_init(controller_index);
+	ret = sdp_init(udc);
 	if (ret) {
 		pr_err("SDP init failed: %d\n", ret);
 		goto exit;
 	}
 
 	/* This command typically does not return but jumps to an image */
-	sdp_handle(controller_index);
+	sdp_handle(udc);
 	pr_err("SDP ended\n");
 
 exit:
 	g_dnl_unregister();
 exit_register:
-	usb_gadget_release(controller_index);
+	udc_device_put(udc);
 
 	return CMD_RET_FAILURE;
 }
diff --git a/common/spl/spl_sdp.c b/common/spl/spl_sdp.c
index f6b99c1af5a..83585cf82d3 100644
--- a/common/spl/spl_sdp.c
+++ b/common/spl/spl_sdp.c
@@ -14,10 +14,13 @@
 static int spl_sdp_load_image(struct spl_image_info *spl_image,
 			      struct spl_boot_device *bootdev)
 {
-	int ret;
 	const int controller_index = CONFIG_SPL_SDP_USB_DEV;
+	struct udevice *udc;
+	int ret;
 
-	usb_gadget_initialize(controller_index);
+	ret = udc_device_get_by_index(controller_index, &udc);
+	if (ret)
+		return ret;
 
 	board_usb_init(controller_index, USB_INIT_DEVICE);
 
@@ -28,7 +31,7 @@ static int spl_sdp_load_image(struct spl_image_info *spl_image,
 		goto err_detach;
 	}
 
-	ret = sdp_init(controller_index);
+	ret = sdp_init(udc);
 	if (ret) {
 		pr_err("SDP init failed: %d\n", ret);
 		goto err_detach;
@@ -39,11 +42,11 @@ static int spl_sdp_load_image(struct spl_image_info *spl_image,
 	 * or it loads a FIT image and returns it to be handled by the SPL
 	 * code.
 	 */
-	ret = spl_sdp_handle(controller_index, spl_image, bootdev);
+	ret = spl_sdp_handle(udc, spl_image, bootdev);
 	debug("SDP ended\n");
 
 err_detach:
-	usb_gadget_release(controller_index);
+	udc_device_put(udc);
 	return ret;
 }
 SPL_LOAD_IMAGE_METHOD("USB SDP", 0, BOOT_DEVICE_BOARD, spl_sdp_load_image);
diff --git a/drivers/usb/gadget/f_sdp.c b/drivers/usb/gadget/f_sdp.c
index 4da5a160a09..37f6281abfb 100644
--- a/drivers/usb/gadget/f_sdp.c
+++ b/drivers/usb/gadget/f_sdp.c
@@ -702,7 +702,7 @@ static int sdp_bind_config(struct usb_configuration *c)
 	return status;
 }
 
-int sdp_init(int controller_index)
+int sdp_init(struct udevice *udc)
 {
 	printf("SDP: initialize...\n");
 	while (!sdp_func->configuration_done) {
@@ -712,7 +712,7 @@ int sdp_init(int controller_index)
 		}
 
 		schedule();
-		usb_gadget_handle_interrupts(controller_index);
+		dm_usb_gadget_handle_interrupts(udc);
 	}
 
 	return 0;
@@ -911,9 +911,9 @@ static void sdp_handle_out_ep(void)
 }
 
 #ifndef CONFIG_SPL_BUILD
-int sdp_handle(int controller_index)
+int sdp_handle(struct udevice *udc)
 #else
-int spl_sdp_handle(int controller_index, struct spl_image_info *spl_image,
+int spl_sdp_handle(struct udevice *udc, struct spl_image_info *spl_image,
 		   struct spl_boot_device *bootdev)
 #endif
 {
@@ -929,7 +929,7 @@ int spl_sdp_handle(int controller_index, struct spl_image_info *spl_image,
 			return 0;
 
 		schedule();
-		usb_gadget_handle_interrupts(controller_index);
+		dm_usb_gadget_handle_interrupts(udc);
 
 #ifdef CONFIG_SPL_BUILD
 		flag = sdp_handle_in_ep(spl_image, bootdev);
diff --git a/include/sdp.h b/include/sdp.h
index 6d89baa04ec..5492f9c47d2 100644
--- a/include/sdp.h
+++ b/include/sdp.h
@@ -9,15 +9,15 @@
 #ifndef __SDP_H_
 #define __SDP_H_
 
-int sdp_init(int controller_index);
+int sdp_init(struct udevice *udc);
 
 #ifdef CONFIG_SPL_BUILD
 #include <spl.h>
 
-int spl_sdp_handle(int controller_index, struct spl_image_info *spl_image,
+int spl_sdp_handle(struct udevice *udc, struct spl_image_info *spl_image,
 		   struct spl_boot_device *bootdev);
 #else
-int sdp_handle(int controller_index);
+int sdp_handle(struct udevice *udc);
 #endif
 
 #endif /* __SDP_H_ */
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 13/17] thordown: Use plain udevice for UDC controller interaction
  2023-08-19 14:23 [PATCH 01/17] dm: usb: udc: Factor out plain udevice handler functions Marek Vasut
                   ` (10 preceding siblings ...)
  2023-08-19 14:24 ` [PATCH 12/17] sdp: Use plain udevice for UDC controller interaction Marek Vasut
@ 2023-08-19 14:24 ` Marek Vasut
  2023-08-19 14:24 ` [PATCH 14/17] usb: gadget: acm: " Marek Vasut
                   ` (5 subsequent siblings)
  17 siblings, 0 replies; 33+ messages in thread
From: Marek Vasut @ 2023-08-19 14:24 UTC (permalink / raw)
  To: u-boot
  Cc: Marek Vasut, Angus Ainslie, Dmitrii Merkurev, Eddie Cai,
	Kever Yang, Lukasz Majewski, Miquel Raynal, Mattijs Korpershoek,
	Nishanth Menon, Patrice Chotard, Patrick Delaunay,
	Philipp Tomsich, Simon Glass, Stefan Roese, kernel

Convert to plain udevice interaction with UDC controller
device, avoid the use of UDC uclass dev_array .

Signed-off-by: Marek Vasut <marex@denx.de>
---
Cc: Angus Ainslie <angus@akkea.ca>
Cc: Dmitrii Merkurev <dimorinny@google.com>
Cc: Eddie Cai <eddie.cai.linux@gmail.com>
Cc: Kever Yang <kever.yang@rock-chips.com>
Cc: Lukasz Majewski <lukma@denx.de>
Cc: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: Mattijs Korpershoek <mkorpershoek@baylibre.com>
Cc: Nishanth Menon <nm@ti.com>
Cc: Patrice Chotard <patrice.chotard@foss.st.com>
Cc: Patrick Delaunay <patrick.delaunay@foss.st.com>
Cc: Philipp Tomsich <philipp.tomsich@vrull.eu>
Cc: Simon Glass <sjg@chromium.org>
Cc: Stefan Roese <sr@denx.de>
Cc: kernel@puri.sm
---
 cmd/thordown.c              |  9 +++--
 drivers/usb/gadget/f_thor.c | 74 +++++++++++++++++++------------------
 include/thor.h              |  4 +-
 3 files changed, 45 insertions(+), 42 deletions(-)

diff --git a/cmd/thordown.c b/cmd/thordown.c
index 0d8dcee5314..fcfd38f523c 100644
--- a/cmd/thordown.c
+++ b/cmd/thordown.c
@@ -17,6 +17,7 @@ int do_thor_down(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 {
 	char *interface, *devstring;
 	int controller_index;
+	struct udevice *udc;
 	int ret;
 
 	if (argc < 4)
@@ -32,7 +33,7 @@ int do_thor_down(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 		goto done;
 
 	controller_index = simple_strtoul(argv[1], NULL, 0);
-	ret = usb_gadget_initialize(controller_index);
+	ret = udc_device_get_by_index(controller_index, &udc);
 	if (ret) {
 		pr_err("USB init failed: %d\n", ret);
 		ret = CMD_RET_FAILURE;
@@ -46,7 +47,7 @@ int do_thor_down(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 		goto exit;
 	}
 
-	ret = thor_init();
+	ret = thor_init(udc);
 	if (ret) {
 		pr_err("THOR DOWNLOAD failed: %d\n", ret);
 		ret = CMD_RET_FAILURE;
@@ -54,7 +55,7 @@ int do_thor_down(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 	}
 
 	do {
-		ret = thor_handle();
+		ret = thor_handle(udc);
 		if (ret == THOR_DFU_REINIT_NEEDED) {
 			dfu_free_entities();
 			ret = dfu_init_env_entities(interface, devstring);
@@ -67,7 +68,7 @@ int do_thor_down(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 	} while (ret == 0);
 exit:
 	g_dnl_unregister();
-	usb_gadget_release(controller_index);
+	udc_device_put(udc);
 done:
 	dfu_free_entities();
 
diff --git a/drivers/usb/gadget/f_thor.c b/drivers/usb/gadget/f_thor.c
index 47ef55b2fd3..3caa4c36387 100644
--- a/drivers/usb/gadget/f_thor.c
+++ b/drivers/usb/gadget/f_thor.c
@@ -15,9 +15,10 @@
  */
 
 #include <command.h>
-#include <errno.h>
 #include <common.h>
 #include <console.h>
+#include <dm.h>
+#include <errno.h>
 #include <init.h>
 #include <log.h>
 #include <malloc.h>
@@ -34,9 +35,9 @@
 
 #include "f_thor.h"
 
-static void thor_tx_data(unsigned char *data, int len);
+static void thor_tx_data(struct udevice *udc, unsigned char *data, int len);
 static void thor_set_dma(void *addr, int len);
-static int thor_rx_data(void);
+static int thor_rx_data(struct udevice *udc);
 
 static struct f_thor *thor_func;
 static inline struct f_thor *func_to_thor(struct usb_function *f)
@@ -56,15 +57,15 @@ DEFINE_CACHE_ALIGN_BUFFER(char, f_name, F_NAME_BUF_SIZE + 1);
 static unsigned long long int thor_file_size;
 static int alt_setting_num;
 
-static void send_rsp(const struct rsp_box *rsp)
+static void send_rsp(struct udevice *udc, const struct rsp_box *rsp)
 {
 	memcpy(thor_tx_data_buf, rsp, sizeof(struct rsp_box));
-	thor_tx_data(thor_tx_data_buf, sizeof(struct rsp_box));
+	thor_tx_data(udc, thor_tx_data_buf, sizeof(struct rsp_box));
 
 	debug("-RSP: %d, %d\n", rsp->rsp, rsp->rsp_data);
 }
 
-static void send_data_rsp(s32 ack, s32 count)
+static void send_data_rsp(struct udevice *udc, s32 ack, s32 count)
 {
 	ALLOC_CACHE_ALIGN_BUFFER(struct data_rsp_box, rsp,
 				 sizeof(struct data_rsp_box));
@@ -73,12 +74,12 @@ static void send_data_rsp(s32 ack, s32 count)
 	rsp->count = count;
 
 	memcpy(thor_tx_data_buf, rsp, sizeof(struct data_rsp_box));
-	thor_tx_data(thor_tx_data_buf, sizeof(struct data_rsp_box));
+	thor_tx_data(udc, thor_tx_data_buf, sizeof(struct data_rsp_box));
 
 	debug("-DATA RSP: %d, %d\n", ack, count);
 }
 
-static int process_rqt_info(const struct rqt_box *rqt)
+static int process_rqt_info(struct udevice *udc, const struct rqt_box *rqt)
 {
 	ALLOC_CACHE_ALIGN_BUFFER(struct rsp_box, rsp, sizeof(struct rsp_box));
 	memset(rsp, 0, sizeof(struct rsp_box));
@@ -111,11 +112,11 @@ static int process_rqt_info(const struct rqt_box *rqt)
 		return -EINVAL;
 	}
 
-	send_rsp(rsp);
+	send_rsp(udc, rsp);
 	return true;
 }
 
-static int process_rqt_cmd(const struct rqt_box *rqt)
+static int process_rqt_cmd(struct udevice *udc, const struct rqt_box *rqt)
 {
 	ALLOC_CACHE_ALIGN_BUFFER(struct rsp_box, rsp, sizeof(struct rsp_box));
 	memset(rsp, 0, sizeof(struct rsp_box));
@@ -126,7 +127,7 @@ static int process_rqt_cmd(const struct rqt_box *rqt)
 	switch (rqt->rqt_data) {
 	case RQT_CMD_REBOOT:
 		debug("TARGET RESET\n");
-		send_rsp(rsp);
+		send_rsp(udc, rsp);
 		g_dnl_unregister();
 		dfu_free_entities();
 #ifdef CONFIG_THOR_RESET_OFF
@@ -136,7 +137,7 @@ static int process_rqt_cmd(const struct rqt_box *rqt)
 		break;
 	case RQT_CMD_POWEROFF:
 	case RQT_CMD_EFSCLEAR:
-		send_rsp(rsp);
+		send_rsp(udc, rsp);
 	default:
 		printf("Command not supported -> cmd: %d\n", rqt->rqt_data);
 		return -EINVAL;
@@ -145,7 +146,8 @@ static int process_rqt_cmd(const struct rqt_box *rqt)
 	return true;
 }
 
-static long long int download_head(unsigned long long total,
+static long long int download_head(struct udevice *udc,
+				   unsigned long long total,
 				   unsigned int packet_size,
 				   long long int *left,
 				   int *cnt)
@@ -166,7 +168,7 @@ static long long int download_head(unsigned long long total,
 	while (total - rcv_cnt >= packet_size) {
 		thor_set_dma(buf, packet_size);
 		buf += packet_size;
-		ret_rcv = thor_rx_data();
+		ret_rcv = thor_rx_data(udc);
 		if (ret_rcv < 0)
 			return ret_rcv;
 		rcv_cnt += ret_rcv;
@@ -184,7 +186,7 @@ static long long int download_head(unsigned long long total,
 			}
 			buf = transfer_buffer;
 		}
-		send_data_rsp(0, ++usb_pkt_cnt);
+		send_data_rsp(udc, 0, ++usb_pkt_cnt);
 	}
 
 	/* Calculate the amount of data to arrive from PC (in bytes) */
@@ -200,11 +202,11 @@ static long long int download_head(unsigned long long total,
 
 	if (left_to_rcv) {
 		thor_set_dma(buf, packet_size);
-		ret_rcv = thor_rx_data();
+		ret_rcv = thor_rx_data(udc);
 		if (ret_rcv < 0)
 			return ret_rcv;
 		rcv_cnt += ret_rcv;
-		send_data_rsp(0, ++usb_pkt_cnt);
+		send_data_rsp(udc, 0, ++usb_pkt_cnt);
 	}
 
 	debug("%s: %llu total: %llu cnt: %d\n", __func__, rcv_cnt, total, *cnt);
@@ -254,7 +256,7 @@ static int download_tail(long long int left, int cnt)
 	return ret;
 }
 
-static long long int process_rqt_download(const struct rqt_box *rqt)
+static long long int process_rqt_download(struct udevice *udc, const struct rqt_box *rqt)
 {
 	ALLOC_CACHE_ALIGN_BUFFER(struct rsp_box, rsp, sizeof(struct rsp_box));
 	static long long int left, ret_head;
@@ -301,8 +303,8 @@ static long long int process_rqt_download(const struct rqt_box *rqt)
 		}
 		break;
 	case RQT_DL_FILE_START:
-		send_rsp(rsp);
-		ret_head = download_head(thor_file_size, THOR_PACKET_SIZE,
+		send_rsp(udc, rsp);
+		ret_head = download_head(udc, thor_file_size, THOR_PACKET_SIZE,
 					 &left, &cnt);
 		if (ret_head < 0) {
 			left = 0;
@@ -324,11 +326,11 @@ static long long int process_rqt_download(const struct rqt_box *rqt)
 		ret = -ENOTSUPP;
 	}
 
-	send_rsp(rsp);
+	send_rsp(udc, rsp);
 	return ret;
 }
 
-static int process_data(void)
+static int process_data(struct udevice *udc)
 {
 	ALLOC_CACHE_ALIGN_BUFFER(struct rqt_box, rqt, sizeof(struct rqt_box));
 	int ret = -EINVAL;
@@ -339,13 +341,13 @@ static int process_data(void)
 
 	switch (rqt->rqt) {
 	case RQT_INFO:
-		ret = process_rqt_info(rqt);
+		ret = process_rqt_info(udc, rqt);
 		break;
 	case RQT_CMD:
-		ret = process_rqt_cmd(rqt);
+		ret = process_rqt_cmd(udc, rqt);
 		break;
 	case RQT_DL:
-		ret = (int) process_rqt_download(rqt);
+		ret = (int) process_rqt_download(udc, rqt);
 		break;
 	case RQT_UL:
 		puts("RQT: UPLOAD not supported!\n");
@@ -536,7 +538,7 @@ static struct usb_request *alloc_ep_req(struct usb_ep *ep, unsigned length)
 	return req;
 }
 
-static int thor_rx_data(void)
+static int thor_rx_data(struct udevice *udc)
 {
 	struct thor_dev *dev = thor_func->dev;
 	int data_to_rx, tmp, status;
@@ -557,7 +559,7 @@ static int thor_rx_data(void)
 		}
 
 		while (!dev->rxdata) {
-			usb_gadget_handle_interrupts(0);
+			dm_usb_gadget_handle_interrupts(udc);
 			if (ctrlc())
 				return -1;
 		}
@@ -568,7 +570,7 @@ static int thor_rx_data(void)
 	return tmp;
 }
 
-static void thor_tx_data(unsigned char *data, int len)
+static void thor_tx_data(struct udevice *udc, unsigned char *data, int len)
 {
 	struct thor_dev *dev = thor_func->dev;
 	unsigned char *ptr = dev->in_req->buf;
@@ -591,7 +593,7 @@ static void thor_tx_data(unsigned char *data, int len)
 
 	/* Wait until tx interrupt received */
 	while (!dev->txdata)
-		usb_gadget_handle_interrupts(0);
+		dm_usb_gadget_handle_interrupts(udc);
 
 	dev->txdata = 0;
 }
@@ -685,18 +687,18 @@ static void thor_set_dma(void *addr, int len)
 	dev->out_req->length = len;
 }
 
-int thor_init(void)
+int thor_init(struct udevice *udc)
 {
 	struct thor_dev *dev = thor_func->dev;
 
 	/* Wait for a device enumeration and configuration settings */
 	debug("THOR enumeration/configuration setting....\n");
 	while (!dev->configuration_done)
-		usb_gadget_handle_interrupts(0);
+		dm_usb_gadget_handle_interrupts(udc);
 
 	thor_set_dma(thor_rx_data_buf, strlen("THOR"));
 	/* detect the download request from Host PC */
-	if (thor_rx_data() < 0) {
+	if (thor_rx_data(udc) < 0) {
 		printf("%s: Data not received!\n", __func__);
 		return -1;
 	}
@@ -706,7 +708,7 @@ int thor_init(void)
 		udelay(30 * 1000); /* 30 ms */
 
 		strcpy((char *)thor_tx_data_buf, "ROHT");
-		thor_tx_data(thor_tx_data_buf, strlen("ROHT"));
+		thor_tx_data(udc, thor_tx_data_buf, strlen("ROHT"));
 	} else {
 		puts("Wrong reply information\n");
 		return -1;
@@ -715,17 +717,17 @@ int thor_init(void)
 	return 0;
 }
 
-int thor_handle(void)
+int thor_handle(struct udevice *udc)
 {
 	int ret;
 
 	/* receive the data from Host PC */
 	while (1) {
 		thor_set_dma(thor_rx_data_buf, sizeof(struct rqt_box));
-		ret = thor_rx_data();
+		ret = thor_rx_data(udc);
 
 		if (ret > 0) {
-			ret = process_data();
+			ret = process_data(udc);
 #ifdef CONFIG_THOR_RESET_OFF
 			if (ret == RESET_DONE)
 				break;
diff --git a/include/thor.h b/include/thor.h
index ee67ab0a270..3cb56b654ae 100644
--- a/include/thor.h
+++ b/include/thor.h
@@ -14,7 +14,7 @@
 
 #define THOR_DFU_REINIT_NEEDED	0xFFFFFFFE
 
-int thor_handle(void);
-int thor_init(void);
+int thor_handle(struct udevice *udc);
+int thor_init(struct udevice *udc);
 int thor_add(struct usb_configuration *c);
 #endif /* __THOR_H_ */
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 14/17] usb: gadget: acm: Use plain udevice for UDC controller interaction
  2023-08-19 14:23 [PATCH 01/17] dm: usb: udc: Factor out plain udevice handler functions Marek Vasut
                   ` (11 preceding siblings ...)
  2023-08-19 14:24 ` [PATCH 13/17] thordown: " Marek Vasut
@ 2023-08-19 14:24 ` Marek Vasut
  2023-08-19 14:24 ` [PATCH 15/17] usb: gadget: ether: " Marek Vasut
                   ` (4 subsequent siblings)
  17 siblings, 0 replies; 33+ messages in thread
From: Marek Vasut @ 2023-08-19 14:24 UTC (permalink / raw)
  To: u-boot
  Cc: Marek Vasut, Angus Ainslie, Dmitrii Merkurev, Eddie Cai,
	Kever Yang, Lukasz Majewski, Miquel Raynal, Mattijs Korpershoek,
	Nishanth Menon, Patrice Chotard, Patrick Delaunay,
	Philipp Tomsich, Simon Glass, Stefan Roese, kernel

Convert to plain udevice interaction with UDC controller
device, avoid the use of UDC uclass dev_array .

Signed-off-by: Marek Vasut <marex@denx.de>
---
Cc: Angus Ainslie <angus@akkea.ca>
Cc: Dmitrii Merkurev <dimorinny@google.com>
Cc: Eddie Cai <eddie.cai.linux@gmail.com>
Cc: Kever Yang <kever.yang@rock-chips.com>
Cc: Lukasz Majewski <lukma@denx.de>
Cc: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: Mattijs Korpershoek <mkorpershoek@baylibre.com>
Cc: Nishanth Menon <nm@ti.com>
Cc: Patrice Chotard <patrice.chotard@foss.st.com>
Cc: Patrick Delaunay <patrick.delaunay@foss.st.com>
Cc: Philipp Tomsich <philipp.tomsich@vrull.eu>
Cc: Simon Glass <sjg@chromium.org>
Cc: Stefan Roese <sr@denx.de>
Cc: kernel@puri.sm
---
 drivers/usb/gadget/f_acm.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/gadget/f_acm.c b/drivers/usb/gadget/f_acm.c
index b2ddd1ada8b..de42e0189e8 100644
--- a/drivers/usb/gadget/f_acm.c
+++ b/drivers/usb/gadget/f_acm.c
@@ -51,7 +51,7 @@ struct f_acm {
 #define ACM_CTRL_RTS	BIT(1)	/* unused with full duplex */
 #define ACM_CTRL_DTR	BIT(0)	/* host is ready for data r/w */
 
-	int controller_index;
+	struct udevice *udc;
 };
 
 static struct f_acm *default_acm_function;
@@ -489,7 +489,7 @@ static void __acm_tx(struct f_acm *f_acm)
 	int len, ret;
 
 	do {
-		usb_gadget_handle_interrupts(f_acm->controller_index);
+		dm_usb_gadget_handle_interrupts(f_acm->udc);
 
 		if (!(f_acm->handshake_bits & ACM_CTRL_DTR))
 			break;
@@ -520,7 +520,7 @@ static bool acm_connected(struct stdio_dev *dev)
 	struct f_acm *f_acm = stdio_to_acm(dev);
 
 	/* give a chance to process udc irq */
-	usb_gadget_handle_interrupts(f_acm->controller_index);
+	dm_usb_gadget_handle_interrupts(f_acm->udc);
 
 	return f_acm->connected;
 }
@@ -543,7 +543,10 @@ static int acm_add(struct usb_configuration *c)
 	f_acm->usb_function.descriptors = acm_fs_function;
 	f_acm->usb_function.hs_descriptors = acm_hs_function;
 	f_acm->usb_function.setup = acm_setup;
-	f_acm->controller_index = 0;
+
+	status = udc_device_get_by_index(0, &f_acm->udc);
+	if (status)
+		return status;
 
 	status = usb_add_function(c, &f_acm->usb_function);
 	if (status) {
@@ -567,7 +570,7 @@ static int acm_stdio_tstc(struct stdio_dev *dev)
 {
 	struct f_acm *f_acm = stdio_to_acm(dev);
 
-	usb_gadget_handle_interrupts(f_acm->controller_index);
+	dm_usb_gadget_handle_interrupts(f_acm->udc);
 
 	return (f_acm->rx_buf.size > 0);
 }
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 15/17] usb: gadget: ether: Use plain udevice for UDC controller interaction
  2023-08-19 14:23 [PATCH 01/17] dm: usb: udc: Factor out plain udevice handler functions Marek Vasut
                   ` (12 preceding siblings ...)
  2023-08-19 14:24 ` [PATCH 14/17] usb: gadget: acm: " Marek Vasut
@ 2023-08-19 14:24 ` Marek Vasut
  2023-08-19 14:24 ` [PATCH 16/17] dm: usb: udc: Drop legacy udevice handler functions Marek Vasut
                   ` (3 subsequent siblings)
  17 siblings, 0 replies; 33+ messages in thread
From: Marek Vasut @ 2023-08-19 14:24 UTC (permalink / raw)
  To: u-boot
  Cc: Marek Vasut, Angus Ainslie, Dmitrii Merkurev, Eddie Cai,
	Kever Yang, Lukasz Majewski, Miquel Raynal, Mattijs Korpershoek,
	Nishanth Menon, Patrice Chotard, Patrick Delaunay,
	Philipp Tomsich, Simon Glass, Stefan Roese, kernel

Convert to plain udevice interaction with UDC controller
device, avoid the use of UDC uclass dev_array .

Signed-off-by: Marek Vasut <marex@denx.de>
---
Cc: Angus Ainslie <angus@akkea.ca>
Cc: Dmitrii Merkurev <dimorinny@google.com>
Cc: Eddie Cai <eddie.cai.linux@gmail.com>
Cc: Kever Yang <kever.yang@rock-chips.com>
Cc: Lukasz Majewski <lukma@denx.de>
Cc: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: Mattijs Korpershoek <mkorpershoek@baylibre.com>
Cc: Nishanth Menon <nm@ti.com>
Cc: Patrice Chotard <patrice.chotard@foss.st.com>
Cc: Patrick Delaunay <patrick.delaunay@foss.st.com>
Cc: Philipp Tomsich <philipp.tomsich@vrull.eu>
Cc: Simon Glass <sjg@chromium.org>
Cc: Stefan Roese <sr@denx.de>
Cc: kernel@puri.sm
---
 drivers/usb/gadget/ether.c | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
index 5ff06d3814b..cb1317fd9f3 100644
--- a/drivers/usb/gadget/ether.c
+++ b/drivers/usb/gadget/ether.c
@@ -137,6 +137,7 @@ struct eth_dev {
 struct ether_priv {
 	struct eth_dev ethdev;
 	struct udevice *netdev;
+	struct udevice *udcdev;
 	struct usb_gadget_driver eth_driver;
 };
 
@@ -1895,7 +1896,7 @@ static int eth_stop(struct eth_dev *dev)
 		/* Wait until host receives OID_GEN_MEDIA_CONNECT_STATUS */
 		ts = get_timer(0);
 		while (get_timer(ts) < timeout)
-			usb_gadget_handle_interrupts(0);
+			dm_usb_gadget_handle_interrupts(priv->udcdev);
 #endif
 
 		rndis_uninit(dev->rndis_config);
@@ -2300,7 +2301,7 @@ static int usb_eth_start(struct udevice *udev)
 			pr_err("The remote end did not respond in time.");
 			goto fail;
 		}
-		usb_gadget_handle_interrupts(0);
+		dm_usb_gadget_handle_interrupts(priv->udcdev);
 	}
 
 	packet_received = 0;
@@ -2370,7 +2371,7 @@ static int usb_eth_send(struct udevice *udev, void *packet, int length)
 			printf("timeout sending packets to usb ethernet\n");
 			return -1;
 		}
-		usb_gadget_handle_interrupts(0);
+		dm_usb_gadget_handle_interrupts(priv->udcdev);
 	}
 	free(rndis_pkt);
 
@@ -2406,7 +2407,7 @@ static void usb_eth_stop(struct udevice *udev)
 
 	/* Clear pending interrupt */
 	if (dev->network_started) {
-		usb_gadget_handle_interrupts(0);
+		dm_usb_gadget_handle_interrupts(priv->udcdev);
 		dev->network_started = 0;
 	}
 }
@@ -2416,7 +2417,7 @@ static int usb_eth_recv(struct udevice *dev, int flags, uchar **packetp)
 	struct ether_priv *priv = dev_get_priv(dev);
 	struct eth_dev *ethdev = &priv->ethdev;
 
-	usb_gadget_handle_interrupts(0);
+	dm_usb_gadget_handle_interrupts(priv->udcdev);
 
 	if (packet_received) {
 		if (ethdev->rx_req) {
@@ -2452,6 +2453,7 @@ static const struct eth_ops usb_eth_ops = {
 
 int usb_ether_init(void)
 {
+	struct ether_priv *priv;
 	struct udevice *usb_dev;
 	int ret;
 
@@ -2467,7 +2469,8 @@ int usb_ether_init(void)
 		return ret;
 	}
 
-	return usb_gadget_initialize(0);
+	priv = dev_get_priv(usb_dev);
+	return udc_device_get_by_index(0, &priv->udcdev);
 }
 
 static int usb_eth_probe(struct udevice *dev)
@@ -2478,6 +2481,9 @@ static int usb_eth_probe(struct udevice *dev)
 	priv->netdev = dev;
 	l_priv = priv;
 
+	if (!priv->udcdev)
+		priv->udcdev = dev->parent;
+
 	get_ether_addr(CONFIG_USBNET_DEV_ADDR, pdata->enetaddr);
 	eth_env_set_enetaddr("usbnet_devaddr", pdata->enetaddr);
 
@@ -2528,7 +2534,9 @@ static int usb_eth_remove(struct udevice *dev)
 
 static int usb_eth_unbind(struct udevice *dev)
 {
-	usb_gadget_release(0);
+	struct ether_priv *priv = dev_get_priv(dev);
+
+	udc_device_put(priv->udcdev);
 
 	return 0;
 }
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 16/17] dm: usb: udc: Drop legacy udevice handler functions
  2023-08-19 14:23 [PATCH 01/17] dm: usb: udc: Factor out plain udevice handler functions Marek Vasut
                   ` (13 preceding siblings ...)
  2023-08-19 14:24 ` [PATCH 15/17] usb: gadget: ether: " Marek Vasut
@ 2023-08-19 14:24 ` Marek Vasut
  2023-08-22 16:52   ` Mattijs Korpershoek
  2023-08-19 14:24 ` [PATCH 17/17] board: usb: Replace legacy usb_gadget_handle_interrupts() Marek Vasut
                   ` (2 subsequent siblings)
  17 siblings, 1 reply; 33+ messages in thread
From: Marek Vasut @ 2023-08-19 14:24 UTC (permalink / raw)
  To: u-boot
  Cc: Marek Vasut, Angus Ainslie, Dmitrii Merkurev, Eddie Cai,
	Kever Yang, Lukasz Majewski, Miquel Raynal, Mattijs Korpershoek,
	Nishanth Menon, Patrice Chotard, Patrick Delaunay,
	Philipp Tomsich, Simon Glass, Stefan Roese, kernel

Remove legacy functions limited by the dev_array array,
those are no longer used anywhere, all the code uses
plain udevice based access now.

The usb_gadget_handle_interrupts() is doing udevice look up
until all call sites use dm_usb_gadget_handle_interrupts().

Signed-off-by: Marek Vasut <marex@denx.de>
---
Cc: Angus Ainslie <angus@akkea.ca>
Cc: Dmitrii Merkurev <dimorinny@google.com>
Cc: Eddie Cai <eddie.cai.linux@gmail.com>
Cc: Kever Yang <kever.yang@rock-chips.com>
Cc: Lukasz Majewski <lukma@denx.de>
Cc: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: Mattijs Korpershoek <mkorpershoek@baylibre.com>
Cc: Nishanth Menon <nm@ti.com>
Cc: Patrice Chotard <patrice.chotard@foss.st.com>
Cc: Patrick Delaunay <patrick.delaunay@foss.st.com>
Cc: Philipp Tomsich <philipp.tomsich@vrull.eu>
Cc: Simon Glass <sjg@chromium.org>
Cc: Stefan Roese <sr@denx.de>
Cc: kernel@puri.sm
---
 drivers/usb/gadget/udc/udc-uclass.c | 44 ++++-------------------------
 include/linux/usb/gadget.h          | 17 -----------
 2 files changed, 6 insertions(+), 55 deletions(-)

diff --git a/drivers/usb/gadget/udc/udc-uclass.c b/drivers/usb/gadget/udc/udc-uclass.c
index b4271b4be9f..7f54a3b00cb 100644
--- a/drivers/usb/gadget/udc/udc-uclass.c
+++ b/drivers/usb/gadget/udc/udc-uclass.c
@@ -12,9 +12,6 @@
 #include <linux/usb/gadget.h>
 
 #if CONFIG_IS_ENABLED(DM_USB_GADGET)
-#define MAX_UDC_DEVICES 4
-static struct udevice *dev_array[MAX_UDC_DEVICES];
-
 int udc_device_get_by_index(int index, struct udevice **udev)
 {
 	struct udevice *dev = NULL;
@@ -45,45 +42,16 @@ int udc_device_put(struct udevice *udev)
 #endif
 }
 
-int usb_gadget_initialize(int index)
-{
-	int ret;
-	struct udevice *dev = NULL;
-
-	if (index < 0 || index >= ARRAY_SIZE(dev_array))
-		return -EINVAL;
-	if (dev_array[index])
-		return 0;
-	ret = udc_device_get_by_index(index, &dev);
-	if (!dev || ret) {
-		pr_err("No USB device found\n");
-		return -ENODEV;
-	}
-	dev_array[index] = dev;
-	return 0;
-}
-
-int usb_gadget_release(int index)
+int usb_gadget_handle_interrupts(int index)
 {
-#if CONFIG_IS_ENABLED(DM_DEVICE_REMOVE)
+	struct udevice *udc;
 	int ret;
-	if (index < 0 || index >= ARRAY_SIZE(dev_array))
-		return -EINVAL;
 
-	ret = device_remove(dev_array[index]);
-	if (!ret)
-		dev_array[index] = NULL;
-	return ret;
-#else
-	return -ENOSYS;
-#endif
-}
+	ret = udc_device_get_by_index(index, &udc);
+	if (ret)
+		return ret;
 
-int usb_gadget_handle_interrupts(int index)
-{
-	if (index < 0 || index >= ARRAY_SIZE(dev_array))
-		return -EINVAL;
-	return dm_usb_gadget_handle_interrupts(dev_array[index]);
+	return dm_usb_gadget_handle_interrupts(udc);
 }
 #else
 /* Backwards hardware compatibility -- switch to DM_USB_GADGET */
diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
index 5e9a6513d5b..54875d2716e 100644
--- a/include/linux/usb/gadget.h
+++ b/include/linux/usb/gadget.h
@@ -1023,21 +1023,4 @@ int udc_device_get_by_index(int index, struct udevice **udev);
  */
 int udc_device_put(struct udevice *udev);
 
-#if CONFIG_IS_ENABLED(DM_USB_GADGET)
-int usb_gadget_initialize(int index);
-int usb_gadget_release(int index);
-int dm_usb_gadget_handle_interrupts(struct udevice *dev);
-#else
-#include <usb.h>
-static inline int usb_gadget_initialize(int index)
-{
-	return board_usb_init(index, USB_INIT_DEVICE);
-}
-
-static inline int usb_gadget_release(int index)
-{
-	return board_usb_cleanup(index, USB_INIT_DEVICE);
-}
-#endif
-
 #endif	/* __LINUX_USB_GADGET_H */
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 17/17] board: usb: Replace legacy usb_gadget_handle_interrupts()
  2023-08-19 14:23 [PATCH 01/17] dm: usb: udc: Factor out plain udevice handler functions Marek Vasut
                   ` (14 preceding siblings ...)
  2023-08-19 14:24 ` [PATCH 16/17] dm: usb: udc: Drop legacy udevice handler functions Marek Vasut
@ 2023-08-19 14:24 ` Marek Vasut
  2023-08-22 16:58   ` Mattijs Korpershoek
  2023-08-21  8:39 ` [PATCH 01/17] dm: usb: udc: Factor out plain udevice handler functions Miquel Raynal
  2023-08-22 16:07 ` Mattijs Korpershoek
  17 siblings, 1 reply; 33+ messages in thread
From: Marek Vasut @ 2023-08-19 14:24 UTC (permalink / raw)
  To: u-boot
  Cc: Marek Vasut, Angus Ainslie, Dmitrii Merkurev, Eddie Cai,
	Kever Yang, Lukasz Majewski, Miquel Raynal, Mattijs Korpershoek,
	Nishanth Menon, Patrice Chotard, Patrick Delaunay,
	Philipp Tomsich, Simon Glass, Stefan Roese, kernel

The usb_gadget_handle_interrupts() is no longer used anywhere,
replace the remaining uses with dm_usb_gadget_handle_interrupts()
which takes udevice as a parameter.

Some of the UDC drivers currently ignore the index parameter altogether,
those also ignore the udevice and have to be reworked. Other like the
dwc3_uboot_handle_interrupt() had to be switched from index to udevice
look up to avoid breakage.

Signed-off-by: Marek Vasut <marex@denx.de>
---
NOTE: Next step, get rid of dwc3_uboot_init()/dwc3_uboot_exit()
---
Cc: Angus Ainslie <angus@akkea.ca>
Cc: Dmitrii Merkurev <dimorinny@google.com>
Cc: Eddie Cai <eddie.cai.linux@gmail.com>
Cc: Kever Yang <kever.yang@rock-chips.com>
Cc: Lukasz Majewski <lukma@denx.de>
Cc: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: Mattijs Korpershoek <mkorpershoek@baylibre.com>
Cc: Nishanth Menon <nm@ti.com>
Cc: Patrice Chotard <patrice.chotard@foss.st.com>
Cc: Patrick Delaunay <patrick.delaunay@foss.st.com>
Cc: Philipp Tomsich <philipp.tomsich@vrull.eu>
Cc: Simon Glass <sjg@chromium.org>
Cc: Stefan Roese <sr@denx.de>
Cc: kernel@puri.sm
---
 arch/arm/mach-rockchip/board.c      |  4 ++--
 board/purism/librem5/spl.c          |  4 ++--
 board/samsung/common/exynos5-dt.c   |  4 ++--
 board/st/stih410-b2260/board.c      |  4 ++--
 board/ti/am43xx/board.c             |  6 +++---
 drivers/usb/dwc3/core.c             |  6 +++---
 drivers/usb/dwc3/dwc3-omap.c        |  8 ++++----
 drivers/usb/gadget/at91_udc.c       |  2 +-
 drivers/usb/gadget/atmel_usba_udc.c |  3 +--
 drivers/usb/gadget/ci_udc.c         |  4 ++--
 drivers/usb/gadget/dwc2_udc_otg.c   | 12 ++----------
 drivers/usb/gadget/udc/udc-uclass.c | 12 ------------
 drivers/usb/host/usb-sandbox.c      |  5 -----
 drivers/usb/musb-new/musb_uboot.c   |  2 +-
 include/dwc3-omap-uboot.h           |  2 +-
 include/dwc3-uboot.h                |  2 +-
 include/linux/usb/gadget.h          |  2 +-
 17 files changed, 28 insertions(+), 54 deletions(-)

diff --git a/arch/arm/mach-rockchip/board.c b/arch/arm/mach-rockchip/board.c
index 8d7b39ba157..57f08e0be0e 100644
--- a/arch/arm/mach-rockchip/board.c
+++ b/arch/arm/mach-rockchip/board.c
@@ -299,9 +299,9 @@ static struct dwc3_device dwc3_device_data = {
 	.hsphy_mode = USBPHY_INTERFACE_MODE_UTMIW,
 };
 
-int usb_gadget_handle_interrupts(int index)
+int dm_usb_gadget_handle_interrupts(struct udevice *dev)
 {
-	dwc3_uboot_handle_interrupt(0);
+	dwc3_uboot_handle_interrupt(dev);
 	return 0;
 }
 
diff --git a/board/purism/librem5/spl.c b/board/purism/librem5/spl.c
index 90f1fcf415f..581f0929662 100644
--- a/board/purism/librem5/spl.c
+++ b/board/purism/librem5/spl.c
@@ -418,9 +418,9 @@ out:
 	return rv;
 }
 
-int usb_gadget_handle_interrupts(int index)
+int dm_usb_gadget_handle_interrupts(struct udevice *dev)
 {
-	dwc3_uboot_handle_interrupt(0);
+	dwc3_uboot_handle_interrupt(dev);
 	return 0;
 }
 
diff --git a/board/samsung/common/exynos5-dt.c b/board/samsung/common/exynos5-dt.c
index cde77d79a0f..726b7f0667a 100644
--- a/board/samsung/common/exynos5-dt.c
+++ b/board/samsung/common/exynos5-dt.c
@@ -126,9 +126,9 @@ static struct dwc3_device dwc3_device_data = {
 	.index = 0,
 };
 
-int usb_gadget_handle_interrupts(int index)
+int dm_usb_gadget_handle_interrupts(struct udevice *dev)
 {
-	dwc3_uboot_handle_interrupt(0);
+	dwc3_uboot_handle_interrupt(dev);
 	return 0;
 }
 
diff --git a/board/st/stih410-b2260/board.c b/board/st/stih410-b2260/board.c
index cd3a7dc51a2..e21cbc270e9 100644
--- a/board/st/stih410-b2260/board.c
+++ b/board/st/stih410-b2260/board.c
@@ -50,9 +50,9 @@ static struct dwc3_device dwc3_device_data = {
 	.index = 0,
 };
 
-int usb_gadget_handle_interrupts(int index)
+int dm_usb_gadget_handle_interrupts(struct udevice *dev)
 {
-	dwc3_uboot_handle_interrupt(index);
+	dwc3_uboot_handle_interrupt(dev);
 	return 0;
 }
 
diff --git a/board/ti/am43xx/board.c b/board/ti/am43xx/board.c
index 87e552a4701..58bfe7cd455 100644
--- a/board/ti/am43xx/board.c
+++ b/board/ti/am43xx/board.c
@@ -760,13 +760,13 @@ static struct ti_usb_phy_device usb_phy2_device = {
 	.index = 1,
 };
 
-int usb_gadget_handle_interrupts(int index)
+int dm_usb_gadget_handle_interrupts(struct udevice *dev)
 {
 	u32 status;
 
-	status = dwc3_omap_uboot_interrupt_status(index);
+	status = dwc3_omap_uboot_interrupt_status(dev);
 	if (status)
-		dwc3_uboot_handle_interrupt(index);
+		dwc3_uboot_handle_interrupt(dev);
 
 	return 0;
 }
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 49f6a1900b0..7ca9d09824e 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -986,18 +986,18 @@ void dwc3_uboot_exit(int index)
 
 /**
  * dwc3_uboot_handle_interrupt - handle dwc3 core interrupt
- * @index: index of this controller
+ * @dev: device of this controller
  *
  * Invokes dwc3 gadget interrupts.
  *
  * Generally called from board file.
  */
-void dwc3_uboot_handle_interrupt(int index)
+void dwc3_uboot_handle_interrupt(struct udevice *dev)
 {
 	struct dwc3 *dwc = NULL;
 
 	list_for_each_entry(dwc, &dwc3_list, list) {
-		if (dwc->index != index)
+		if (dwc->dev != dev)
 			continue;
 
 		dwc3_gadget_uboot_handle_interrupt(dwc);
diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c
index 9596bf144c3..ff4ebfb4447 100644
--- a/drivers/usb/dwc3/dwc3-omap.c
+++ b/drivers/usb/dwc3/dwc3-omap.c
@@ -119,7 +119,7 @@
 #define USBOTGSS_UTMI_OTG_STATUS_VBUSVALID	(1 << 1)
 
 struct dwc3_omap {
-	struct device		*dev;
+	struct udevice		*dev;
 
 	void __iomem		*base;
 
@@ -429,19 +429,19 @@ void dwc3_omap_uboot_exit(int index)
 
 /**
  * dwc3_omap_uboot_interrupt_status - check the status of interrupt
- * @index: index of this controller
+ * @dev: device of this controller
  *
  * Checks the status of interrupts and returns true if an interrupt
  * is detected or false otherwise.
  *
  * Generally called from board file.
  */
-int dwc3_omap_uboot_interrupt_status(int index)
+int dwc3_omap_uboot_interrupt_status(struct udevice *dev)
 {
 	struct dwc3_omap *omap = NULL;
 
 	list_for_each_entry(omap, &dwc3_omap_list, list)
-		if (omap->index == index)
+		if (omap->dev == dev)
 			return dwc3_omap_interrupt(-1, omap);
 
 	return 0;
diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c
index baa4c431fed..61d2aa5b929 100644
--- a/drivers/usb/gadget/at91_udc.c
+++ b/drivers/usb/gadget/at91_udc.c
@@ -1429,7 +1429,7 @@ static const struct at91_udc_caps at91sam9261_udc_caps = {
 };
 #endif
 
-int usb_gadget_handle_interrupts(int index)
+int dm_usb_gadget_handle_interrupts(struct udevice *dev)
 {
 	struct at91_udc *udc = controller;
 
diff --git a/drivers/usb/gadget/atmel_usba_udc.c b/drivers/usb/gadget/atmel_usba_udc.c
index f4dcd205a4f..90b248a0777 100644
--- a/drivers/usb/gadget/atmel_usba_udc.c
+++ b/drivers/usb/gadget/atmel_usba_udc.c
@@ -1198,14 +1198,13 @@ static struct usba_udc controller = {
 	},
 };
 
-int usb_gadget_handle_interrupts(int index)
+int dm_usb_gadget_handle_interrupts(struct udevice *dev)
 {
 	struct usba_udc *udc = &controller;
 
 	return usba_udc_irq(udc);
 }
 
-
 int usb_gadget_register_driver(struct usb_gadget_driver *driver)
 {
 	struct usba_udc *udc = &controller;
diff --git a/drivers/usb/gadget/ci_udc.c b/drivers/usb/gadget/ci_udc.c
index 5bb26d7ab4a..44d2da0b4fb 100644
--- a/drivers/usb/gadget/ci_udc.c
+++ b/drivers/usb/gadget/ci_udc.c
@@ -869,10 +869,10 @@ void udc_irq(void)
 	}
 }
 
-int usb_gadget_handle_interrupts(int index)
+int dm_usb_gadget_handle_interrupts(struct udevice *dev)
 {
-	u32 value;
 	struct ci_udc *udc = (struct ci_udc *)controller.ctrl->hcor;
+	u32 value;
 
 	value = readl(&udc->usbsts);
 	if (value)
diff --git a/drivers/usb/gadget/dwc2_udc_otg.c b/drivers/usb/gadget/dwc2_udc_otg.c
index 0a3bc0886e6..ff5173eda68 100644
--- a/drivers/usb/gadget/dwc2_udc_otg.c
+++ b/drivers/usb/gadget/dwc2_udc_otg.c
@@ -941,15 +941,12 @@ int dwc2_udc_handle_interrupt(void)
 	return 0;
 }
 
-#if !CONFIG_IS_ENABLED(DM_USB_GADGET)
-
-int usb_gadget_handle_interrupts(int index)
+int dm_usb_gadget_handle_interrupts(struct udevice *dev)
 {
 	return dwc2_udc_handle_interrupt();
 }
 
-#else /* CONFIG_IS_ENABLED(DM_USB_GADGET) */
-
+#if CONFIG_IS_ENABLED(DM_USB_GADGET)
 struct dwc2_priv_data {
 	struct clk_bulk		clks;
 	struct reset_ctl_bulk	resets;
@@ -957,11 +954,6 @@ struct dwc2_priv_data {
 	struct udevice *usb33d_supply;
 };
 
-int dm_usb_gadget_handle_interrupts(struct udevice *dev)
-{
-	return dwc2_udc_handle_interrupt();
-}
-
 static int dwc2_phy_setup(struct udevice *dev, struct phy_bulk *phys)
 {
 	int ret;
diff --git a/drivers/usb/gadget/udc/udc-uclass.c b/drivers/usb/gadget/udc/udc-uclass.c
index 7f54a3b00cb..9dfae08313b 100644
--- a/drivers/usb/gadget/udc/udc-uclass.c
+++ b/drivers/usb/gadget/udc/udc-uclass.c
@@ -41,18 +41,6 @@ int udc_device_put(struct udevice *udev)
 	return -ENOSYS;
 #endif
 }
-
-int usb_gadget_handle_interrupts(int index)
-{
-	struct udevice *udc;
-	int ret;
-
-	ret = udc_device_get_by_index(index, &udc);
-	if (ret)
-		return ret;
-
-	return dm_usb_gadget_handle_interrupts(udc);
-}
 #else
 /* Backwards hardware compatibility -- switch to DM_USB_GADGET */
 static int legacy_index;
diff --git a/drivers/usb/host/usb-sandbox.c b/drivers/usb/host/usb-sandbox.c
index 582f72d00c1..3d4f8d653b5 100644
--- a/drivers/usb/host/usb-sandbox.c
+++ b/drivers/usb/host/usb-sandbox.c
@@ -130,11 +130,6 @@ int dm_usb_gadget_handle_interrupts(struct udevice *dev)
 	return 0;
 }
 #else
-int usb_gadget_handle_interrupts(int index)
-{
-	return 0;
-}
-
 int usb_gadget_register_driver(struct usb_gadget_driver *driver)
 {
 	struct sandbox_udc *dev = this_controller;
diff --git a/drivers/usb/musb-new/musb_uboot.c b/drivers/usb/musb-new/musb_uboot.c
index 67dc11669d2..0dcc428efeb 100644
--- a/drivers/usb/musb-new/musb_uboot.c
+++ b/drivers/usb/musb-new/musb_uboot.c
@@ -376,7 +376,7 @@ struct dm_usb_ops musb_usb_ops = {
 #if defined(CONFIG_USB_MUSB_GADGET) && !CONFIG_IS_ENABLED(DM_USB_GADGET)
 static struct musb *gadget;
 
-int usb_gadget_handle_interrupts(int index)
+int dm_usb_gadget_handle_interrupts(struct udevice *dev)
 {
 	schedule();
 	if (!gadget || !gadget->isr)
diff --git a/include/dwc3-omap-uboot.h b/include/dwc3-omap-uboot.h
index 7c982e3798b..9e0e717dc98 100644
--- a/include/dwc3-omap-uboot.h
+++ b/include/dwc3-omap-uboot.h
@@ -27,5 +27,5 @@ struct dwc3_omap_device {
 
 int dwc3_omap_uboot_init(struct dwc3_omap_device *dev);
 void dwc3_omap_uboot_exit(int index);
-int dwc3_omap_uboot_interrupt_status(int index);
+int dwc3_omap_uboot_interrupt_status(struct udevice *dev);
 #endif /* __DWC3_OMAP_UBOOT_H_ */
diff --git a/include/dwc3-uboot.h b/include/dwc3-uboot.h
index e08530ec4e5..bb0436c0973 100644
--- a/include/dwc3-uboot.h
+++ b/include/dwc3-uboot.h
@@ -44,7 +44,7 @@ struct dwc3_device {
 
 int dwc3_uboot_init(struct dwc3_device *dev);
 void dwc3_uboot_exit(int index);
-void dwc3_uboot_handle_interrupt(int index);
+void dwc3_uboot_handle_interrupt(struct udevice *dev);
 
 struct phy;
 #if CONFIG_IS_ENABLED(PHY) && CONFIG_IS_ENABLED(DM_USB)
diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
index 54875d2716e..40228e320b3 100644
--- a/include/linux/usb/gadget.h
+++ b/include/linux/usb/gadget.h
@@ -1004,7 +1004,7 @@ extern struct usb_ep *usb_ep_autoconfig(struct usb_gadget *,
 
 extern void usb_ep_autoconfig_reset(struct usb_gadget *);
 
-extern int usb_gadget_handle_interrupts(int index);
+extern int dm_usb_gadget_handle_interrupts(struct udevice *);
 
 /**
  * udc_device_get_by_index() - Get UDC udevice by index
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* Re: [PATCH 02/17] usb: sandbox: Add DM_USB_GADGET support
  2023-08-19 14:23 ` [PATCH 02/17] usb: sandbox: Add DM_USB_GADGET support Marek Vasut
@ 2023-08-20 17:48   ` Simon Glass
  2023-08-22 16:10   ` Mattijs Korpershoek
  1 sibling, 0 replies; 33+ messages in thread
From: Simon Glass @ 2023-08-20 17:48 UTC (permalink / raw)
  To: Marek Vasut
  Cc: u-boot, Angus Ainslie, Dmitrii Merkurev, Eddie Cai, Kever Yang,
	Lukasz Majewski, Miquel Raynal, Mattijs Korpershoek,
	Nishanth Menon, Patrice Chotard, Patrick Delaunay,
	Philipp Tomsich, Stefan Roese, kernel

On Sat, 19 Aug 2023 at 08:24, Marek Vasut <marex@denx.de> wrote:
>
> Remove local usb_gadget_register_driver()/usb_gadget_unregister_driver()
> implementation which is implemented in udc-core.c instead if DM_USB_GADGET
> is enabled. Add no-op dm_usb_gadget_handle_interrupts() implementation.
>
> Signed-off-by: Marek Vasut <marex@denx.de>
> ---
> Cc: Angus Ainslie <angus@akkea.ca>
> Cc: Dmitrii Merkurev <dimorinny@google.com>
> Cc: Eddie Cai <eddie.cai.linux@gmail.com>
> Cc: Kever Yang <kever.yang@rock-chips.com>
> Cc: Lukasz Majewski <lukma@denx.de>
> Cc: Miquel Raynal <miquel.raynal@bootlin.com>
> Cc: Mattijs Korpershoek <mkorpershoek@baylibre.com>
> Cc: Nishanth Menon <nm@ti.com>
> Cc: Patrice Chotard <patrice.chotard@foss.st.com>
> Cc: Patrick Delaunay <patrick.delaunay@foss.st.com>
> Cc: Philipp Tomsich <philipp.tomsich@vrull.eu>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Stefan Roese <sr@denx.de>
> Cc: kernel@puri.sm
> ---
>  drivers/usb/host/usb-sandbox.c | 7 +++++++
>  1 file changed, 7 insertions(+)

Reviewed-by: Simon Glass <sjg@chromium.org>

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 03/17] configs: sandbox: Enable DM_USB_GADGET
  2023-08-19 14:23 ` [PATCH 03/17] configs: sandbox: Enable DM_USB_GADGET Marek Vasut
@ 2023-08-20 17:48   ` Simon Glass
  2023-08-22 16:10   ` Mattijs Korpershoek
  1 sibling, 0 replies; 33+ messages in thread
From: Simon Glass @ 2023-08-20 17:48 UTC (permalink / raw)
  To: Marek Vasut
  Cc: u-boot, Angus Ainslie, Dmitrii Merkurev, Eddie Cai, Kever Yang,
	Lukasz Majewski, Miquel Raynal, Mattijs Korpershoek,
	Nishanth Menon, Patrice Chotard, Patrick Delaunay,
	Philipp Tomsich, Stefan Roese, kernel

On Sat, 19 Aug 2023 at 08:24, Marek Vasut <marex@denx.de> wrote:
>
> Switch sandbox to DM_USB_GADGET, DM is the future.
>
> Signed-off-by: Marek Vasut <marex@denx.de>
> ---
> Cc: Angus Ainslie <angus@akkea.ca>
> Cc: Dmitrii Merkurev <dimorinny@google.com>
> Cc: Eddie Cai <eddie.cai.linux@gmail.com>
> Cc: Kever Yang <kever.yang@rock-chips.com>
> Cc: Lukasz Majewski <lukma@denx.de>
> Cc: Miquel Raynal <miquel.raynal@bootlin.com>
> Cc: Mattijs Korpershoek <mkorpershoek@baylibre.com>
> Cc: Nishanth Menon <nm@ti.com>
> Cc: Patrice Chotard <patrice.chotard@foss.st.com>
> Cc: Patrick Delaunay <patrick.delaunay@foss.st.com>
> Cc: Philipp Tomsich <philipp.tomsich@vrull.eu>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Stefan Roese <sr@denx.de>
> Cc: kernel@puri.sm
> ---
>  configs/sandbox64_defconfig        | 1 +
>  configs/sandbox_defconfig          | 1 +
>  configs/sandbox_flattree_defconfig | 1 +
>  configs/sandbox_noinst_defconfig   | 1 +
>  configs/sandbox_spl_defconfig      | 1 +
>  configs/sandbox_vpl_defconfig      | 1 +
>  6 files changed, 6 insertions(+)

Reviewed-by: Simon Glass <sjg@chromium.org>

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 01/17] dm: usb: udc: Factor out plain udevice handler functions
  2023-08-19 14:23 [PATCH 01/17] dm: usb: udc: Factor out plain udevice handler functions Marek Vasut
                   ` (15 preceding siblings ...)
  2023-08-19 14:24 ` [PATCH 17/17] board: usb: Replace legacy usb_gadget_handle_interrupts() Marek Vasut
@ 2023-08-21  8:39 ` Miquel Raynal
  2023-08-22 16:07 ` Mattijs Korpershoek
  17 siblings, 0 replies; 33+ messages in thread
From: Miquel Raynal @ 2023-08-21  8:39 UTC (permalink / raw)
  To: Marek Vasut
  Cc: u-boot, Angus Ainslie, Dmitrii Merkurev, Eddie Cai, Kever Yang,
	Lukasz Majewski, Mattijs Korpershoek, Nishanth Menon,
	Patrice Chotard, Patrick Delaunay, Philipp Tomsich, Simon Glass,
	Stefan Roese, kernel

Hi Marek,

marex@denx.de wrote on Sat, 19 Aug 2023 16:23:51 +0200:

> Pull the functionality of UDC uclass that operates on plain udevice
> and does not use this dev_array array into separate functions and
> expose those functions, so that as much code as possible can be
> switched over to these functions and the dev_array can be dropped.
> 
> Signed-off-by: Marek Vasut <marex@denx.de>
> ---
> Cc: Angus Ainslie <angus@akkea.ca>
> Cc: Dmitrii Merkurev <dimorinny@google.com>
> Cc: Eddie Cai <eddie.cai.linux@gmail.com>
> Cc: Kever Yang <kever.yang@rock-chips.com>
> Cc: Lukasz Majewski <lukma@denx.de>
> Cc: Miquel Raynal <miquel.raynal@bootlin.com>
> Cc: Mattijs Korpershoek <mkorpershoek@baylibre.com>
> Cc: Nishanth Menon <nm@ti.com>
> Cc: Patrice Chotard <patrice.chotard@foss.st.com>
> Cc: Patrick Delaunay <patrick.delaunay@foss.st.com>
> Cc: Philipp Tomsich <philipp.tomsich@vrull.eu>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Stefan Roese <sr@denx.de>
> Cc: kernel@puri.sm
> ---

Would you mind adding a cover letter to your series? It would be easier
for us to (a) know what is the final purpose of the series and (b) have
a location where to send global feedback.

Indeed, I did not yet investigate, in particular because every time
fastboot is broken I cannot easily test new images without going
through a whole recovery step with another image, but it seems like the
network over USB is no longer working (not 100% sure about that one,
sometimes the network is capricious) and anyway just calling unbind
crashes:

=> dm tree
[...]
 misc          0  [ + ]   ti-musb-wrapper       |   |-- usb@47400000
 usb           0  [ + ]   ti-musb-peripheral    |   |   |-- usb@47401000
 ethernet      1  [ + ]   usb_ether             |   |   |   `-- usb_ether
 bootdev       3  [   ]   eth_bootdev           |   |   |       `-- usb_ether.bootdev
 usb           0  [   ]   ti-musb-host          |   |   `-- usb@47401800
=> unbind ethernet 1
data abort
pc : [<9ff9a0e6>]          lr : [<9ff9a0e7>]
reloc pc : [<808350e6>]    lr : [<808350e7>]
sp : 9df2f998  ip : 0000001c     fp : 00000003
r10: 9df4d800  r9 : 9df44ea0     r8 : 9ffe4a0c
r7 : 9ff82ad9  r6 : 9df4d800     r5 : 84000000  r4 : 9df4cf48
r3 : 9ff9a0e1  r2 : 00000000     r1 : 00000000  r0 : 00000000
Flags: NzCv  IRQs off  FIQs on  Mode SVC_32 (T)
Code: 9ffd b508 f7ec fe63 (f8d0) 00b0 
Resetting CPU ...

Thanks,
Miquèl

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 01/17] dm: usb: udc: Factor out plain udevice handler functions
  2023-08-19 14:23 [PATCH 01/17] dm: usb: udc: Factor out plain udevice handler functions Marek Vasut
                   ` (16 preceding siblings ...)
  2023-08-21  8:39 ` [PATCH 01/17] dm: usb: udc: Factor out plain udevice handler functions Miquel Raynal
@ 2023-08-22 16:07 ` Mattijs Korpershoek
  17 siblings, 0 replies; 33+ messages in thread
From: Mattijs Korpershoek @ 2023-08-22 16:07 UTC (permalink / raw)
  To: Marek Vasut, u-boot
  Cc: Marek Vasut, Angus Ainslie, Dmitrii Merkurev, Eddie Cai,
	Kever Yang, Lukasz Majewski, Miquel Raynal, Nishanth Menon,
	Patrice Chotard, Patrick Delaunay, Philipp Tomsich, Simon Glass,
	Stefan Roese, kernel

On sam., août 19, 2023 at 16:23, Marek Vasut <marex@denx.de> wrote:

> Pull the functionality of UDC uclass that operates on plain udevice
> and does not use this dev_array array into separate functions and
> expose those functions, so that as much code as possible can be
> switched over to these functions and the dev_array can be dropped.
>
> Signed-off-by: Marek Vasut <marex@denx.de>
> ---
> Cc: Angus Ainslie <angus@akkea.ca>
> Cc: Dmitrii Merkurev <dimorinny@google.com>
> Cc: Eddie Cai <eddie.cai.linux@gmail.com>
> Cc: Kever Yang <kever.yang@rock-chips.com>
> Cc: Lukasz Majewski <lukma@denx.de>
> Cc: Miquel Raynal <miquel.raynal@bootlin.com>
> Cc: Mattijs Korpershoek <mkorpershoek@baylibre.com>
> Cc: Nishanth Menon <nm@ti.com>
> Cc: Patrice Chotard <patrice.chotard@foss.st.com>
> Cc: Patrick Delaunay <patrick.delaunay@foss.st.com>
> Cc: Philipp Tomsich <philipp.tomsich@vrull.eu>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Stefan Roese <sr@denx.de>
> Cc: kernel@puri.sm
> ---

Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>

>  drivers/usb/gadget/udc/Makefile     |  2 +-
>  drivers/usb/gadget/udc/udc-uclass.c | 57 +++++++++++++++++++++++++----
>  include/linux/usb/gadget.h          | 17 +++++++++
>  3 files changed, 68 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/usb/gadget/udc/Makefile b/drivers/usb/gadget/udc/Makefile
> index 95dbf0c82ee..467c566f6d3 100644
> --- a/drivers/usb/gadget/udc/Makefile
> +++ b/drivers/usb/gadget/udc/Makefile
> @@ -7,4 +7,4 @@ obj-$(CONFIG_USB_DWC3_GADGET)	+= udc-core.o
>  endif
>  
>  obj-$(CONFIG_$(SPL_)DM_USB_GADGET)	+= udc-core.o
> -obj-$(CONFIG_$(SPL_)DM) += udc-uclass.o
> +obj-y += udc-uclass.o
> diff --git a/drivers/usb/gadget/udc/udc-uclass.c b/drivers/usb/gadget/udc/udc-uclass.c
> index de8861829c7..b4271b4be9f 100644
> --- a/drivers/usb/gadget/udc/udc-uclass.c
> +++ b/drivers/usb/gadget/udc/udc-uclass.c
> @@ -14,6 +14,37 @@
>  #if CONFIG_IS_ENABLED(DM_USB_GADGET)
>  #define MAX_UDC_DEVICES 4
>  static struct udevice *dev_array[MAX_UDC_DEVICES];
> +
> +int udc_device_get_by_index(int index, struct udevice **udev)
> +{
> +	struct udevice *dev = NULL;
> +	int ret;
> +
> +	ret = uclass_get_device_by_seq(UCLASS_USB_GADGET_GENERIC, index, &dev);
> +	if (!ret && dev) {
> +		*udev = dev;
> +		return 0;
> +	}
> +
> +	ret = uclass_get_device(UCLASS_USB_GADGET_GENERIC, index, &dev);
> +	if (!ret && dev) {
> +		*udev = dev;
> +		return 0;
> +	}
> +
> +	pr_err("No USB device found\n");
> +	return -ENODEV;
> +}
> +
> +int udc_device_put(struct udevice *udev)
> +{
> +#if CONFIG_IS_ENABLED(DM_DEVICE_REMOVE)
> +	return device_remove(udev, DM_REMOVE_NORMAL);
> +#else
> +	return -ENOSYS;
> +#endif
> +}
> +
>  int usb_gadget_initialize(int index)
>  {
>  	int ret;
> @@ -23,13 +54,10 @@ int usb_gadget_initialize(int index)
>  		return -EINVAL;
>  	if (dev_array[index])
>  		return 0;
> -	ret = uclass_get_device_by_seq(UCLASS_USB_GADGET_GENERIC, index, &dev);
> +	ret = udc_device_get_by_index(index, &dev);
>  	if (!dev || ret) {
> -		ret = uclass_get_device(UCLASS_USB_GADGET_GENERIC, index, &dev);
> -		if (!dev || ret) {
> -			pr_err("No USB device found\n");
> -			return -ENODEV;
> -		}
> +		pr_err("No USB device found\n");
> +		return -ENODEV;
>  	}
>  	dev_array[index] = dev;
>  	return 0;
> @@ -42,7 +70,7 @@ int usb_gadget_release(int index)
>  	if (index < 0 || index >= ARRAY_SIZE(dev_array))
>  		return -EINVAL;
>  
> -	ret = device_remove(dev_array[index], DM_REMOVE_NORMAL);
> +	ret = device_remove(dev_array[index]);
>  	if (!ret)
>  		dev_array[index] = NULL;
>  	return ret;
> @@ -57,10 +85,25 @@ int usb_gadget_handle_interrupts(int index)
>  		return -EINVAL;
>  	return dm_usb_gadget_handle_interrupts(dev_array[index]);
>  }
> +#else
> +/* Backwards hardware compatibility -- switch to DM_USB_GADGET */
> +static int legacy_index;
> +int udc_device_get_by_index(int index, struct udevice **udev)
> +{
> +	legacy_index = index;
> +	return board_usb_init(index, USB_INIT_DEVICE);
> +}
> +
> +int udc_device_put(struct udevice *udev)
> +{
> +	return board_usb_cleanup(legacy_index, USB_INIT_DEVICE);
> +}
>  #endif
>  
> +#if CONFIG_IS_ENABLED(DM)
>  UCLASS_DRIVER(usb_gadget_generic) = {
>  	.id		= UCLASS_USB_GADGET_GENERIC,
>  	.name		= "usb",
>  	.flags		= DM_UC_FLAG_SEQ_ALIAS,
>  };
> +#endif
> diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
> index 2f694fc25c1..5e9a6513d5b 100644
> --- a/include/linux/usb/gadget.h
> +++ b/include/linux/usb/gadget.h
> @@ -1006,6 +1006,23 @@ extern void usb_ep_autoconfig_reset(struct usb_gadget *);
>  
>  extern int usb_gadget_handle_interrupts(int index);
>  
> +/**
> + * udc_device_get_by_index() - Get UDC udevice by index
> + * @index: UDC device index
> + * @udev: UDC udevice matching the index (if found)
> + *
> + * Return: 0 if Ok, -ve on error
> + */
> +int udc_device_get_by_index(int index, struct udevice **udev);
> +
> +/**
> + * udc_device_put() - Put UDC udevice
> + * @udev: UDC udevice
> + *
> + * Return: 0 if Ok, -ve on error
> + */
> +int udc_device_put(struct udevice *udev);
> +
>  #if CONFIG_IS_ENABLED(DM_USB_GADGET)
>  int usb_gadget_initialize(int index);
>  int usb_gadget_release(int index);
> -- 
> 2.40.1

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 02/17] usb: sandbox: Add DM_USB_GADGET support
  2023-08-19 14:23 ` [PATCH 02/17] usb: sandbox: Add DM_USB_GADGET support Marek Vasut
  2023-08-20 17:48   ` Simon Glass
@ 2023-08-22 16:10   ` Mattijs Korpershoek
  1 sibling, 0 replies; 33+ messages in thread
From: Mattijs Korpershoek @ 2023-08-22 16:10 UTC (permalink / raw)
  To: Marek Vasut, u-boot
  Cc: Marek Vasut, Angus Ainslie, Dmitrii Merkurev, Eddie Cai,
	Kever Yang, Lukasz Majewski, Miquel Raynal, Nishanth Menon,
	Patrice Chotard, Patrick Delaunay, Philipp Tomsich, Simon Glass,
	Stefan Roese, kernel

On sam., août 19, 2023 at 16:23, Marek Vasut <marex@denx.de> wrote:

> Remove local usb_gadget_register_driver()/usb_gadget_unregister_driver()
> implementation which is implemented in udc-core.c instead if DM_USB_GADGET
> is enabled. Add no-op dm_usb_gadget_handle_interrupts() implementation.
>
> Signed-off-by: Marek Vasut <marex@denx.de>
> ---
> Cc: Angus Ainslie <angus@akkea.ca>
> Cc: Dmitrii Merkurev <dimorinny@google.com>
> Cc: Eddie Cai <eddie.cai.linux@gmail.com>
> Cc: Kever Yang <kever.yang@rock-chips.com>
> Cc: Lukasz Majewski <lukma@denx.de>
> Cc: Miquel Raynal <miquel.raynal@bootlin.com>
> Cc: Mattijs Korpershoek <mkorpershoek@baylibre.com>
> Cc: Nishanth Menon <nm@ti.com>
> Cc: Patrice Chotard <patrice.chotard@foss.st.com>
> Cc: Patrick Delaunay <patrick.delaunay@foss.st.com>
> Cc: Philipp Tomsich <philipp.tomsich@vrull.eu>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Stefan Roese <sr@denx.de>
> Cc: kernel@puri.sm
> ---
>  drivers/usb/host/usb-sandbox.c | 7 +++++++
>  1 file changed, 7 insertions(+)

Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>

>
> diff --git a/drivers/usb/host/usb-sandbox.c b/drivers/usb/host/usb-sandbox.c
> index d1103dcb2e9..582f72d00c1 100644
> --- a/drivers/usb/host/usb-sandbox.c
> +++ b/drivers/usb/host/usb-sandbox.c
> @@ -124,6 +124,12 @@ static int sandbox_submit_int(struct udevice *bus, struct usb_device *udev,
>  	return ret;
>  }
>  
> +#if CONFIG_IS_ENABLED(DM_USB_GADGET)
> +int dm_usb_gadget_handle_interrupts(struct udevice *dev)
> +{
> +	return 0;
> +}
> +#else
>  int usb_gadget_handle_interrupts(int index)
>  {
>  	return 0;
> @@ -144,6 +150,7 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
>  
>  	return 0;
>  }
> +#endif
>  
>  static int sandbox_alloc_device(struct udevice *dev, struct usb_device *udev)
>  {
> -- 
> 2.40.1

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 03/17] configs: sandbox: Enable DM_USB_GADGET
  2023-08-19 14:23 ` [PATCH 03/17] configs: sandbox: Enable DM_USB_GADGET Marek Vasut
  2023-08-20 17:48   ` Simon Glass
@ 2023-08-22 16:10   ` Mattijs Korpershoek
  1 sibling, 0 replies; 33+ messages in thread
From: Mattijs Korpershoek @ 2023-08-22 16:10 UTC (permalink / raw)
  To: Marek Vasut, u-boot
  Cc: Marek Vasut, Angus Ainslie, Dmitrii Merkurev, Eddie Cai,
	Kever Yang, Lukasz Majewski, Miquel Raynal, Nishanth Menon,
	Patrice Chotard, Patrick Delaunay, Philipp Tomsich, Simon Glass,
	Stefan Roese, kernel

On sam., août 19, 2023 at 16:23, Marek Vasut <marex@denx.de> wrote:

> Switch sandbox to DM_USB_GADGET, DM is the future.
>
> Signed-off-by: Marek Vasut <marex@denx.de>
> ---
> Cc: Angus Ainslie <angus@akkea.ca>
> Cc: Dmitrii Merkurev <dimorinny@google.com>
> Cc: Eddie Cai <eddie.cai.linux@gmail.com>
> Cc: Kever Yang <kever.yang@rock-chips.com>
> Cc: Lukasz Majewski <lukma@denx.de>
> Cc: Miquel Raynal <miquel.raynal@bootlin.com>
> Cc: Mattijs Korpershoek <mkorpershoek@baylibre.com>
> Cc: Nishanth Menon <nm@ti.com>
> Cc: Patrice Chotard <patrice.chotard@foss.st.com>
> Cc: Patrick Delaunay <patrick.delaunay@foss.st.com>
> Cc: Philipp Tomsich <philipp.tomsich@vrull.eu>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Stefan Roese <sr@denx.de>
> Cc: kernel@puri.sm
> ---
>  configs/sandbox64_defconfig        | 1 +
>  configs/sandbox_defconfig          | 1 +
>  configs/sandbox_flattree_defconfig | 1 +
>  configs/sandbox_noinst_defconfig   | 1 +
>  configs/sandbox_spl_defconfig      | 1 +
>  configs/sandbox_vpl_defconfig      | 1 +
>  6 files changed, 6 insertions(+)

Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>

>
> diff --git a/configs/sandbox64_defconfig b/configs/sandbox64_defconfig
> index 69e5efe8748..72452695cdc 100644
> --- a/configs/sandbox64_defconfig
> +++ b/configs/sandbox64_defconfig
> @@ -230,6 +230,7 @@ CONFIG_TIMER=y
>  CONFIG_TIMER_EARLY=y
>  CONFIG_SANDBOX_TIMER=y
>  CONFIG_USB=y
> +CONFIG_DM_USB_GADGET=y
>  CONFIG_USB_EMUL=y
>  CONFIG_USB_KEYBOARD=y
>  CONFIG_VIDEO=y
> diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig
> index 1cd1c2ed7cd..9f8b81f5fe6 100644
> --- a/configs/sandbox_defconfig
> +++ b/configs/sandbox_defconfig
> @@ -298,6 +298,7 @@ CONFIG_TIMER=y
>  CONFIG_TIMER_EARLY=y
>  CONFIG_SANDBOX_TIMER=y
>  CONFIG_USB=y
> +CONFIG_DM_USB_GADGET=y
>  CONFIG_USB_EMUL=y
>  CONFIG_USB_KEYBOARD=y
>  CONFIG_USB_GADGET=y
> diff --git a/configs/sandbox_flattree_defconfig b/configs/sandbox_flattree_defconfig
> index 8aa295686dc..cedae60d3cf 100644
> --- a/configs/sandbox_flattree_defconfig
> +++ b/configs/sandbox_flattree_defconfig
> @@ -204,6 +204,7 @@ CONFIG_TIMER=y
>  CONFIG_TIMER_EARLY=y
>  CONFIG_SANDBOX_TIMER=y
>  CONFIG_USB=y
> +CONFIG_DM_USB_GADGET=y
>  CONFIG_USB_EMUL=y
>  CONFIG_USB_KEYBOARD=y
>  CONFIG_VIDEO=y
> diff --git a/configs/sandbox_noinst_defconfig b/configs/sandbox_noinst_defconfig
> index 2c6aab6c859..360686b9682 100644
> --- a/configs/sandbox_noinst_defconfig
> +++ b/configs/sandbox_noinst_defconfig
> @@ -218,6 +218,7 @@ CONFIG_TIMER=y
>  CONFIG_TIMER_EARLY=y
>  CONFIG_SANDBOX_TIMER=y
>  CONFIG_USB=y
> +CONFIG_DM_USB_GADGET=y
>  CONFIG_USB_EMUL=y
>  CONFIG_USB_KEYBOARD=y
>  CONFIG_VIDEO=y
> diff --git a/configs/sandbox_spl_defconfig b/configs/sandbox_spl_defconfig
> index 8d50162b274..bc79adfcd8f 100644
> --- a/configs/sandbox_spl_defconfig
> +++ b/configs/sandbox_spl_defconfig
> @@ -224,6 +224,7 @@ CONFIG_TIMER=y
>  CONFIG_TIMER_EARLY=y
>  CONFIG_SANDBOX_TIMER=y
>  CONFIG_USB=y
> +CONFIG_DM_USB_GADGET=y
>  CONFIG_USB_EMUL=y
>  CONFIG_USB_KEYBOARD=y
>  CONFIG_VIDEO=y
> diff --git a/configs/sandbox_vpl_defconfig b/configs/sandbox_vpl_defconfig
> index f3a0fd19a96..2c817b3847d 100644
> --- a/configs/sandbox_vpl_defconfig
> +++ b/configs/sandbox_vpl_defconfig
> @@ -237,6 +237,7 @@ CONFIG_VPL_TIMER=y
>  CONFIG_TIMER_EARLY=y
>  CONFIG_SANDBOX_TIMER=y
>  CONFIG_USB=y
> +CONFIG_DM_USB_GADGET=y
>  CONFIG_USB_EMUL=y
>  CONFIG_USB_KEYBOARD=y
>  CONFIG_VIDEO=y
> -- 
> 2.40.1

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 04/17] cmd: fastboot: Use plain udevice for UDC controller interaction
  2023-08-19 14:23 ` [PATCH 04/17] cmd: fastboot: Use plain udevice for UDC controller interaction Marek Vasut
@ 2023-08-22 16:22   ` Mattijs Korpershoek
  0 siblings, 0 replies; 33+ messages in thread
From: Mattijs Korpershoek @ 2023-08-22 16:22 UTC (permalink / raw)
  To: Marek Vasut, u-boot
  Cc: Marek Vasut, Angus Ainslie, Dmitrii Merkurev, Eddie Cai,
	Kever Yang, Lukasz Majewski, Miquel Raynal, Nishanth Menon,
	Patrice Chotard, Patrick Delaunay, Philipp Tomsich, Simon Glass,
	Stefan Roese, kernel

On sam., août 19, 2023 at 16:23, Marek Vasut <marex@denx.de> wrote:

> Convert to plain udevice interaction with UDC controller
> device, avoid the use of UDC uclass dev_array .
>
> Signed-off-by: Marek Vasut <marex@denx.de>
> ---
> Cc: Angus Ainslie <angus@akkea.ca>
> Cc: Dmitrii Merkurev <dimorinny@google.com>
> Cc: Eddie Cai <eddie.cai.linux@gmail.com>
> Cc: Kever Yang <kever.yang@rock-chips.com>
> Cc: Lukasz Majewski <lukma@denx.de>
> Cc: Miquel Raynal <miquel.raynal@bootlin.com>
> Cc: Mattijs Korpershoek <mkorpershoek@baylibre.com>
> Cc: Nishanth Menon <nm@ti.com>
> Cc: Patrice Chotard <patrice.chotard@foss.st.com>
> Cc: Patrick Delaunay <patrick.delaunay@foss.st.com>
> Cc: Philipp Tomsich <philipp.tomsich@vrull.eu>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Stefan Roese <sr@denx.de>
> Cc: kernel@puri.sm
> ---
>  cmd/fastboot.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)

Tested that I could reflash the bootloader (raw) partition with:

$ fastboot flash bootloader u-boot_kvim3_noab.bin

Works fine!

Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
Tested-by: Mattijs Korpershoek <mkorpershoek@baylibre.com> # on khadas vim3

Based on: 2023.10-rc3

>
> diff --git a/cmd/fastboot.c b/cmd/fastboot.c
> index 3d5ff951eb6..17fb0a0aa7b 100644
> --- a/cmd/fastboot.c
> +++ b/cmd/fastboot.c
> @@ -61,6 +61,7 @@ static int do_fastboot_usb(int argc, char *const argv[],
>  {
>  	int controller_index;
>  	char *usb_controller;
> +	struct udevice *udc;
>  	char *endp;
>  	int ret;
>  
> @@ -79,7 +80,7 @@ static int do_fastboot_usb(int argc, char *const argv[],
>  		return CMD_RET_FAILURE;
>  	}
>  
> -	ret = usb_gadget_initialize(controller_index);
> +	ret = udc_device_get_by_index(controller_index, &udc);
>  	if (ret) {
>  		pr_err("USB init failed: %d\n", ret);
>  		return CMD_RET_FAILURE;
> @@ -103,13 +104,13 @@ static int do_fastboot_usb(int argc, char *const argv[],
>  		if (ctrlc())
>  			break;
>  		schedule();
> -		usb_gadget_handle_interrupts(controller_index);
> +		dm_usb_gadget_handle_interrupts(udc);
>  	}
>  
>  	ret = CMD_RET_SUCCESS;
>  
>  exit:
> -	usb_gadget_release(controller_index);
> +	udc_device_put(udc);
>  	g_dnl_unregister();
>  	g_dnl_clear_detach();
>  
> -- 
> 2.40.1

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 06/17] cmd: sdp: Reorder variable declaration
  2023-08-19 14:23 ` [PATCH 06/17] cmd: sdp: Reorder variable declaration Marek Vasut
@ 2023-08-22 16:24   ` Mattijs Korpershoek
  0 siblings, 0 replies; 33+ messages in thread
From: Mattijs Korpershoek @ 2023-08-22 16:24 UTC (permalink / raw)
  To: Marek Vasut, u-boot
  Cc: Marek Vasut, Angus Ainslie, Dmitrii Merkurev, Eddie Cai,
	Kever Yang, Lukasz Majewski, Miquel Raynal, Nishanth Menon,
	Patrice Chotard, Patrick Delaunay, Philipp Tomsich, Simon Glass,
	Stefan Roese, kernel

On sam., août 19, 2023 at 16:23, Marek Vasut <marex@denx.de> wrote:

> Move the variable declaration around to improve code readability.
> No functional change.
>
> Signed-off-by: Marek Vasut <marex@denx.de>
> ---
> Cc: Angus Ainslie <angus@akkea.ca>
> Cc: Dmitrii Merkurev <dimorinny@google.com>
> Cc: Eddie Cai <eddie.cai.linux@gmail.com>
> Cc: Kever Yang <kever.yang@rock-chips.com>
> Cc: Lukasz Majewski <lukma@denx.de>
> Cc: Miquel Raynal <miquel.raynal@bootlin.com>
> Cc: Mattijs Korpershoek <mkorpershoek@baylibre.com>
> Cc: Nishanth Menon <nm@ti.com>
> Cc: Patrice Chotard <patrice.chotard@foss.st.com>
> Cc: Patrick Delaunay <patrick.delaunay@foss.st.com>
> Cc: Philipp Tomsich <philipp.tomsich@vrull.eu>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Stefan Roese <sr@denx.de>
> Cc: kernel@puri.sm
> ---
>  cmd/usb_gadget_sdp.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>

>
> diff --git a/cmd/usb_gadget_sdp.c b/cmd/usb_gadget_sdp.c
> index 1af82e11366..784d1b49768 100644
> --- a/cmd/usb_gadget_sdp.c
> +++ b/cmd/usb_gadget_sdp.c
> @@ -14,13 +14,13 @@
>  
>  static int do_sdp(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
>  {
> +	int controller_index;
>  	int ret;
>  
>  	if (argc < 2)
>  		return CMD_RET_USAGE;
>  
> -	char *usb_controller = argv[1];
> -	int controller_index = simple_strtoul(usb_controller, NULL, 0);
> +	controller_index = simple_strtoul(argv[1], NULL, 0);
>  	usb_gadget_initialize(controller_index);
>  
>  	g_dnl_clear_detach();
> -- 
> 2.40.1

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 08/17] cmd: ums: Use plain udevice for UDC controller interaction
  2023-08-19 14:23 ` [PATCH 08/17] cmd: ums: Use plain udevice for UDC controller interaction Marek Vasut
@ 2023-08-22 16:29   ` Mattijs Korpershoek
  0 siblings, 0 replies; 33+ messages in thread
From: Mattijs Korpershoek @ 2023-08-22 16:29 UTC (permalink / raw)
  To: Marek Vasut, u-boot
  Cc: Marek Vasut, Angus Ainslie, Dmitrii Merkurev, Eddie Cai,
	Kever Yang, Lukasz Majewski, Miquel Raynal, Nishanth Menon,
	Patrice Chotard, Patrick Delaunay, Philipp Tomsich, Simon Glass,
	Stefan Roese, kernel

On sam., août 19, 2023 at 16:23, Marek Vasut <marex@denx.de> wrote:

> Convert to plain udevice interaction with UDC controller
> device, avoid the use of UDC uclass dev_array .
>
> Signed-off-by: Marek Vasut <marex@denx.de>
> ---
> Cc: Angus Ainslie <angus@akkea.ca>
> Cc: Dmitrii Merkurev <dimorinny@google.com>
> Cc: Eddie Cai <eddie.cai.linux@gmail.com>
> Cc: Kever Yang <kever.yang@rock-chips.com>
> Cc: Lukasz Majewski <lukma@denx.de>
> Cc: Miquel Raynal <miquel.raynal@bootlin.com>
> Cc: Mattijs Korpershoek <mkorpershoek@baylibre.com>
> Cc: Nishanth Menon <nm@ti.com>
> Cc: Patrice Chotard <patrice.chotard@foss.st.com>
> Cc: Patrick Delaunay <patrick.delaunay@foss.st.com>
> Cc: Philipp Tomsich <philipp.tomsich@vrull.eu>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Stefan Roese <sr@denx.de>
> Cc: kernel@puri.sm
> ---
>  cmd/usb_mass_storage.c              | 10 ++++++----
>  drivers/usb/gadget/f_mass_storage.c |  8 ++++----
>  include/usb_mass_storage.h          |  2 +-
>  3 files changed, 11 insertions(+), 9 deletions(-)

Tested on vim3 with:
=> ums 0 mmc 2

Tested that I could read some files from the android data partition.

Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
Tested-by: Mattijs Korpershoek <mkorpershoek@baylibre.com> # on khadas vim3

>
> diff --git a/cmd/usb_mass_storage.c b/cmd/usb_mass_storage.c
> index c3cc1975f9d..9c51ae0967f 100644
> --- a/cmd/usb_mass_storage.c
> +++ b/cmd/usb_mass_storage.c
> @@ -143,6 +143,7 @@ static int do_usb_mass_storage(struct cmd_tbl *cmdtp, int flag,
>  	const char *devtype;
>  	const char *devnum;
>  	unsigned int controller_index;
> +	struct udevice *udc;
>  	int rc;
>  	int cable_ready_timeout __maybe_unused;
>  
> @@ -164,13 +165,14 @@ static int do_usb_mass_storage(struct cmd_tbl *cmdtp, int flag,
>  
>  	controller_index = (unsigned int)(simple_strtoul(
>  				usb_controller,	NULL, 0));
> -	if (usb_gadget_initialize(controller_index)) {
> +	rc = udc_device_get_by_index(controller_index, &udc);
> +	if (rc) {
>  		pr_err("Couldn't init USB controller.\n");
>  		rc = CMD_RET_FAILURE;
>  		goto cleanup_ums_init;
>  	}
>  
> -	rc = fsg_init(ums, ums_count, controller_index);
> +	rc = fsg_init(ums, ums_count, udc);
>  	if (rc) {
>  		pr_err("fsg_init failed\n");
>  		rc = CMD_RET_FAILURE;
> @@ -215,7 +217,7 @@ static int do_usb_mass_storage(struct cmd_tbl *cmdtp, int flag,
>  	}
>  
>  	while (1) {
> -		usb_gadget_handle_interrupts(controller_index);
> +		dm_usb_gadget_handle_interrupts(udc);
>  
>  		rc = fsg_main_thread(NULL);
>  		if (rc) {
> @@ -247,7 +249,7 @@ static int do_usb_mass_storage(struct cmd_tbl *cmdtp, int flag,
>  cleanup_register:
>  	g_dnl_unregister();
>  cleanup_board:
> -	usb_gadget_release(controller_index);
> +	udc_device_put(udc);
>  cleanup_ums_init:
>  	ums_fini();
>  
> diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c
> index f46829eb7ad..1d17331cb03 100644
> --- a/drivers/usb/gadget/f_mass_storage.c
> +++ b/drivers/usb/gadget/f_mass_storage.c
> @@ -435,7 +435,7 @@ static void set_bulk_out_req_length(struct fsg_common *common,
>  static struct ums *ums;
>  static int ums_count;
>  static struct fsg_common *the_fsg_common;
> -static unsigned int controller_index;
> +static struct udevice *udcdev;
>  
>  static int fsg_set_halt(struct fsg_dev *fsg, struct usb_ep *ep)
>  {
> @@ -680,7 +680,7 @@ static int sleep_thread(struct fsg_common *common)
>  			k = 0;
>  		}
>  
> -		usb_gadget_handle_interrupts(controller_index);
> +		dm_usb_gadget_handle_interrupts(udcdev);
>  	}
>  	common->thread_wakeup_needed = 0;
>  	return rc;
> @@ -2764,11 +2764,11 @@ int fsg_add(struct usb_configuration *c)
>  	return fsg_bind_config(c->cdev, c, fsg_common);
>  }
>  
> -int fsg_init(struct ums *ums_devs, int count, unsigned int controller_idx)
> +int fsg_init(struct ums *ums_devs, int count, struct udevice *udc)
>  {
>  	ums = ums_devs;
>  	ums_count = count;
> -	controller_index = controller_idx;
> +	udcdev = udc;
>  
>  	return 0;
>  }
> diff --git a/include/usb_mass_storage.h b/include/usb_mass_storage.h
> index 08ccc97cf22..83ab93b530d 100644
> --- a/include/usb_mass_storage.h
> +++ b/include/usb_mass_storage.h
> @@ -25,7 +25,7 @@ struct ums {
>  	struct blk_desc block_dev;
>  };
>  
> -int fsg_init(struct ums *ums_devs, int count, unsigned int controller_idx);
> +int fsg_init(struct ums *ums_devs, int count, struct udevice *udc);
>  void fsg_cleanup(void);
>  int fsg_main_thread(void *);
>  int fsg_add(struct usb_configuration *c);
> -- 
> 2.40.1

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 09/17] dfu: Detach the controller on error
  2023-08-19 14:23 ` [PATCH 09/17] dfu: Detach the controller on error Marek Vasut
@ 2023-08-22 16:32   ` Mattijs Korpershoek
  0 siblings, 0 replies; 33+ messages in thread
From: Mattijs Korpershoek @ 2023-08-22 16:32 UTC (permalink / raw)
  To: Marek Vasut, u-boot
  Cc: Marek Vasut, Angus Ainslie, Dmitrii Merkurev, Eddie Cai,
	Kever Yang, Lukasz Majewski, Miquel Raynal, Nishanth Menon,
	Patrice Chotard, Patrick Delaunay, Philipp Tomsich, Simon Glass,
	Stefan Roese, kernel

On sam., août 19, 2023 at 16:23, Marek Vasut <marex@denx.de> wrote:

> In case anything errors out during the DFU registration, detach
> the controller instead of bailing out right away. This way, the
> controller can be reattached on next attempt.
>
> Signed-off-by: Marek Vasut <marex@denx.de>
> ---
> Cc: Angus Ainslie <angus@akkea.ca>
> Cc: Dmitrii Merkurev <dimorinny@google.com>
> Cc: Eddie Cai <eddie.cai.linux@gmail.com>
> Cc: Kever Yang <kever.yang@rock-chips.com>
> Cc: Lukasz Majewski <lukma@denx.de>
> Cc: Miquel Raynal <miquel.raynal@bootlin.com>
> Cc: Mattijs Korpershoek <mkorpershoek@baylibre.com>
> Cc: Nishanth Menon <nm@ti.com>
> Cc: Patrice Chotard <patrice.chotard@foss.st.com>
> Cc: Patrick Delaunay <patrick.delaunay@foss.st.com>
> Cc: Philipp Tomsich <philipp.tomsich@vrull.eu>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Stefan Roese <sr@denx.de>
> Cc: kernel@puri.sm
> ---
>  common/dfu.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)

Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>

>
> diff --git a/common/dfu.c b/common/dfu.c
> index 96190889ab7..32fba84da16 100644
> --- a/common/dfu.c
> +++ b/common/dfu.c
> @@ -34,7 +34,8 @@ int run_usb_dnl_gadget(int usbctrl_index, char *usb_dnl_gadget)
>  	ret = g_dnl_register(usb_dnl_gadget);
>  	if (ret) {
>  		pr_err("g_dnl_register failed");
> -		return CMD_RET_FAILURE;
> +		ret = CMD_RET_FAILURE;
> +		goto err_detach;
>  	}
>  
>  #ifdef CONFIG_DFU_TIMEOUT
> @@ -106,6 +107,7 @@ int run_usb_dnl_gadget(int usbctrl_index, char *usb_dnl_gadget)
>  	}
>  exit:
>  	g_dnl_unregister();
> +err_detach:
>  	usb_gadget_release(usbctrl_index);
>  
>  	if (dfu_reset)
> -- 
> 2.40.1

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 10/17] dfu: Use plain udevice for UDC controller interaction
  2023-08-19 14:24 ` [PATCH 10/17] dfu: Use plain udevice for UDC controller interaction Marek Vasut
@ 2023-08-22 16:33   ` Mattijs Korpershoek
  0 siblings, 0 replies; 33+ messages in thread
From: Mattijs Korpershoek @ 2023-08-22 16:33 UTC (permalink / raw)
  To: Marek Vasut, u-boot
  Cc: Marek Vasut, Angus Ainslie, Dmitrii Merkurev, Eddie Cai,
	Kever Yang, Lukasz Majewski, Miquel Raynal, Nishanth Menon,
	Patrice Chotard, Patrick Delaunay, Philipp Tomsich, Simon Glass,
	Stefan Roese, kernel

On sam., août 19, 2023 at 16:24, Marek Vasut <marex@denx.de> wrote:

> Convert to plain udevice interaction with UDC controller
> device, avoid the use of UDC uclass dev_array .
>
> Signed-off-by: Marek Vasut <marex@denx.de>
> ---
> Cc: Angus Ainslie <angus@akkea.ca>
> Cc: Dmitrii Merkurev <dimorinny@google.com>
> Cc: Eddie Cai <eddie.cai.linux@gmail.com>
> Cc: Kever Yang <kever.yang@rock-chips.com>
> Cc: Lukasz Majewski <lukma@denx.de>
> Cc: Miquel Raynal <miquel.raynal@bootlin.com>
> Cc: Mattijs Korpershoek <mkorpershoek@baylibre.com>
> Cc: Nishanth Menon <nm@ti.com>
> Cc: Patrice Chotard <patrice.chotard@foss.st.com>
> Cc: Patrick Delaunay <patrick.delaunay@foss.st.com>
> Cc: Philipp Tomsich <philipp.tomsich@vrull.eu>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Stefan Roese <sr@denx.de>
> Cc: kernel@puri.sm
> ---
>  common/dfu.c | 15 ++++++++-------
>  1 file changed, 8 insertions(+), 7 deletions(-)

Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>

>
> diff --git a/common/dfu.c b/common/dfu.c
> index 32fba84da16..45206b9e225 100644
> --- a/common/dfu.c
> +++ b/common/dfu.c
> @@ -23,11 +23,12 @@
>  int run_usb_dnl_gadget(int usbctrl_index, char *usb_dnl_gadget)
>  {
>  	bool dfu_reset = false;
> +	struct udevice *udc;
>  	int ret, i = 0;
>  
> -	ret = usb_gadget_initialize(usbctrl_index);
> +	ret = udc_device_get_by_index(usbctrl_index, &udc);
>  	if (ret) {
> -		pr_err("usb_gadget_initialize failed\n");
> +		pr_err("udc_device_get_by_index failed\n");
>  		return CMD_RET_FAILURE;
>  	}
>  	g_dnl_clear_detach();
> @@ -55,7 +56,7 @@ int run_usb_dnl_gadget(int usbctrl_index, char *usb_dnl_gadget)
>  			}
>  
>  			/*
> -			 * This extra number of usb_gadget_handle_interrupts()
> +			 * This extra number of dm_usb_gadget_handle_interrupts()
>  			 * calls is necessary to assure correct transmission
>  			 * completion with dfu-util
>  			 */
> @@ -68,7 +69,7 @@ int run_usb_dnl_gadget(int usbctrl_index, char *usb_dnl_gadget)
>  
>  		if (dfu_get_defer_flush()) {
>  			/*
> -			 * Call to usb_gadget_handle_interrupts() is necessary
> +			 * Call to dm_usb_gadget_handle_interrupts() is necessary
>  			 * to act on ZLP OUT transaction from HOST PC after
>  			 * transmitting the whole file.
>  			 *
> @@ -77,7 +78,7 @@ int run_usb_dnl_gadget(int usbctrl_index, char *usb_dnl_gadget)
>  			 * 5 seconds). In such situation the dfu-util program
>  			 * exits with error message.
>  			 */
> -			usb_gadget_handle_interrupts(usbctrl_index);
> +			dm_usb_gadget_handle_interrupts(udc);
>  			ret = dfu_flush(dfu_get_defer_flush(), NULL, 0, 0);
>  			dfu_set_defer_flush(NULL);
>  			if (ret) {
> @@ -103,12 +104,12 @@ int run_usb_dnl_gadget(int usbctrl_index, char *usb_dnl_gadget)
>  			goto exit;
>  
>  		schedule();
> -		usb_gadget_handle_interrupts(usbctrl_index);
> +		dm_usb_gadget_handle_interrupts(udc);
>  	}
>  exit:
>  	g_dnl_unregister();
>  err_detach:
> -	usb_gadget_release(usbctrl_index);
> +	udc_device_put(udc);
>  
>  	if (dfu_reset)
>  		do_reset(NULL, 0, 0, NULL);
> -- 
> 2.40.1

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 11/17] spl: sdp: Detach the controller on error
  2023-08-19 14:24 ` [PATCH 11/17] spl: sdp: Detach the controller on error Marek Vasut
@ 2023-08-22 16:44   ` Mattijs Korpershoek
  2023-09-01  9:52     ` Marek Vasut
  0 siblings, 1 reply; 33+ messages in thread
From: Mattijs Korpershoek @ 2023-08-22 16:44 UTC (permalink / raw)
  To: Marek Vasut, u-boot
  Cc: Marek Vasut, Angus Ainslie, Dmitrii Merkurev, Eddie Cai,
	Kever Yang, Lukasz Majewski, Miquel Raynal, Nishanth Menon,
	Patrice Chotard, Patrick Delaunay, Philipp Tomsich, Simon Glass,
	Stefan Roese, kernel

On sam., août 19, 2023 at 16:24, Marek Vasut <marex@denx.de> wrote:

> In case anything errors out during the SDP transfer, detach
> the controller instead of bailing out right away. This way,
> the controller can be reattached on next attempt.
>
> Signed-off-by: Marek Vasut <marex@denx.de>
> ---
> Cc: Angus Ainslie <angus@akkea.ca>
> Cc: Dmitrii Merkurev <dimorinny@google.com>
> Cc: Eddie Cai <eddie.cai.linux@gmail.com>
> Cc: Kever Yang <kever.yang@rock-chips.com>
> Cc: Lukasz Majewski <lukma@denx.de>
> Cc: Miquel Raynal <miquel.raynal@bootlin.com>
> Cc: Mattijs Korpershoek <mkorpershoek@baylibre.com>
> Cc: Nishanth Menon <nm@ti.com>
> Cc: Patrice Chotard <patrice.chotard@foss.st.com>
> Cc: Patrick Delaunay <patrick.delaunay@foss.st.com>
> Cc: Philipp Tomsich <philipp.tomsich@vrull.eu>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Stefan Roese <sr@denx.de>
> Cc: kernel@puri.sm
> ---

Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>

Nitpick/question below

>  common/spl/spl_sdp.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/common/spl/spl_sdp.c b/common/spl/spl_sdp.c
> index cc4fb4f7cca..f6b99c1af5a 100644
> --- a/common/spl/spl_sdp.c
> +++ b/common/spl/spl_sdp.c
> @@ -25,13 +25,13 @@ static int spl_sdp_load_image(struct spl_image_info *spl_image,
>  	ret = g_dnl_register("usb_dnl_sdp");
>  	if (ret) {
>  		pr_err("SDP dnl register failed: %d\n", ret);
> -		return ret;
> +		goto err_detach;
>  	}
>  
>  	ret = sdp_init(controller_index);
>  	if (ret) {
>  		pr_err("SDP init failed: %d\n", ret);
> -		return -ENODEV;
> +		goto err_detach;

Shouldn't we call g_dnl_unregister(); here since g_dnl_register() was
sucessfully called before?

This would match what's done in common/dfu.c

>  	}
>  
>  	/*
> @@ -42,6 +42,7 @@ static int spl_sdp_load_image(struct spl_image_info *spl_image,
>  	ret = spl_sdp_handle(controller_index, spl_image, bootdev);
>  	debug("SDP ended\n");
>  
> +err_detach:
>  	usb_gadget_release(controller_index);
>  	return ret;
>  }
> -- 
> 2.40.1

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 12/17] sdp: Use plain udevice for UDC controller interaction
  2023-08-19 14:24 ` [PATCH 12/17] sdp: Use plain udevice for UDC controller interaction Marek Vasut
@ 2023-08-22 16:46   ` Mattijs Korpershoek
  0 siblings, 0 replies; 33+ messages in thread
From: Mattijs Korpershoek @ 2023-08-22 16:46 UTC (permalink / raw)
  To: Marek Vasut, u-boot
  Cc: Marek Vasut, Angus Ainslie, Dmitrii Merkurev, Eddie Cai,
	Kever Yang, Lukasz Majewski, Miquel Raynal, Nishanth Menon,
	Patrice Chotard, Patrick Delaunay, Philipp Tomsich, Simon Glass,
	Stefan Roese, kernel

On sam., août 19, 2023 at 16:24, Marek Vasut <marex@denx.de> wrote:

> Convert to plain udevice interaction with UDC controller
> device, avoid the use of UDC uclass dev_array .
>
> Signed-off-by: Marek Vasut <marex@denx.de>
> ---
> Cc: Angus Ainslie <angus@akkea.ca>
> Cc: Dmitrii Merkurev <dimorinny@google.com>
> Cc: Eddie Cai <eddie.cai.linux@gmail.com>
> Cc: Kever Yang <kever.yang@rock-chips.com>
> Cc: Lukasz Majewski <lukma@denx.de>
> Cc: Miquel Raynal <miquel.raynal@bootlin.com>
> Cc: Mattijs Korpershoek <mkorpershoek@baylibre.com>
> Cc: Nishanth Menon <nm@ti.com>
> Cc: Patrice Chotard <patrice.chotard@foss.st.com>
> Cc: Patrick Delaunay <patrick.delaunay@foss.st.com>
> Cc: Philipp Tomsich <philipp.tomsich@vrull.eu>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Stefan Roese <sr@denx.de>
> Cc: kernel@puri.sm
> ---
>  cmd/usb_gadget_sdp.c       | 11 +++++++----
>  common/spl/spl_sdp.c       | 13 ++++++++-----
>  drivers/usb/gadget/f_sdp.c | 10 +++++-----
>  include/sdp.h              |  6 +++---
>  4 files changed, 23 insertions(+), 17 deletions(-)

Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>

>
> diff --git a/cmd/usb_gadget_sdp.c b/cmd/usb_gadget_sdp.c
> index 784d1b49768..748aa0a7488 100644
> --- a/cmd/usb_gadget_sdp.c
> +++ b/cmd/usb_gadget_sdp.c
> @@ -15,13 +15,16 @@
>  static int do_sdp(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
>  {
>  	int controller_index;
> +	struct udevice *udc;
>  	int ret;
>  
>  	if (argc < 2)
>  		return CMD_RET_USAGE;
>  
>  	controller_index = simple_strtoul(argv[1], NULL, 0);
> -	usb_gadget_initialize(controller_index);
> +	ret = udc_device_get_by_index(controller_index, &udc);
> +	if (ret)
> +		return ret;
>  
>  	g_dnl_clear_detach();
>  	ret = g_dnl_register("usb_dnl_sdp");
> @@ -30,20 +33,20 @@ static int do_sdp(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
>  		goto exit_register;
>  	}
>  
> -	ret = sdp_init(controller_index);
> +	ret = sdp_init(udc);
>  	if (ret) {
>  		pr_err("SDP init failed: %d\n", ret);
>  		goto exit;
>  	}
>  
>  	/* This command typically does not return but jumps to an image */
> -	sdp_handle(controller_index);
> +	sdp_handle(udc);
>  	pr_err("SDP ended\n");
>  
>  exit:
>  	g_dnl_unregister();
>  exit_register:
> -	usb_gadget_release(controller_index);
> +	udc_device_put(udc);
>  
>  	return CMD_RET_FAILURE;
>  }
> diff --git a/common/spl/spl_sdp.c b/common/spl/spl_sdp.c
> index f6b99c1af5a..83585cf82d3 100644
> --- a/common/spl/spl_sdp.c
> +++ b/common/spl/spl_sdp.c
> @@ -14,10 +14,13 @@
>  static int spl_sdp_load_image(struct spl_image_info *spl_image,
>  			      struct spl_boot_device *bootdev)
>  {
> -	int ret;
>  	const int controller_index = CONFIG_SPL_SDP_USB_DEV;
> +	struct udevice *udc;
> +	int ret;
>  
> -	usb_gadget_initialize(controller_index);
> +	ret = udc_device_get_by_index(controller_index, &udc);
> +	if (ret)
> +		return ret;
>  
>  	board_usb_init(controller_index, USB_INIT_DEVICE);
>  
> @@ -28,7 +31,7 @@ static int spl_sdp_load_image(struct spl_image_info *spl_image,
>  		goto err_detach;
>  	}
>  
> -	ret = sdp_init(controller_index);
> +	ret = sdp_init(udc);
>  	if (ret) {
>  		pr_err("SDP init failed: %d\n", ret);
>  		goto err_detach;
> @@ -39,11 +42,11 @@ static int spl_sdp_load_image(struct spl_image_info *spl_image,
>  	 * or it loads a FIT image and returns it to be handled by the SPL
>  	 * code.
>  	 */
> -	ret = spl_sdp_handle(controller_index, spl_image, bootdev);
> +	ret = spl_sdp_handle(udc, spl_image, bootdev);
>  	debug("SDP ended\n");
>  
>  err_detach:
> -	usb_gadget_release(controller_index);
> +	udc_device_put(udc);
>  	return ret;
>  }
>  SPL_LOAD_IMAGE_METHOD("USB SDP", 0, BOOT_DEVICE_BOARD, spl_sdp_load_image);
> diff --git a/drivers/usb/gadget/f_sdp.c b/drivers/usb/gadget/f_sdp.c
> index 4da5a160a09..37f6281abfb 100644
> --- a/drivers/usb/gadget/f_sdp.c
> +++ b/drivers/usb/gadget/f_sdp.c
> @@ -702,7 +702,7 @@ static int sdp_bind_config(struct usb_configuration *c)
>  	return status;
>  }
>  
> -int sdp_init(int controller_index)
> +int sdp_init(struct udevice *udc)
>  {
>  	printf("SDP: initialize...\n");
>  	while (!sdp_func->configuration_done) {
> @@ -712,7 +712,7 @@ int sdp_init(int controller_index)
>  		}
>  
>  		schedule();
> -		usb_gadget_handle_interrupts(controller_index);
> +		dm_usb_gadget_handle_interrupts(udc);
>  	}
>  
>  	return 0;
> @@ -911,9 +911,9 @@ static void sdp_handle_out_ep(void)
>  }
>  
>  #ifndef CONFIG_SPL_BUILD
> -int sdp_handle(int controller_index)
> +int sdp_handle(struct udevice *udc)
>  #else
> -int spl_sdp_handle(int controller_index, struct spl_image_info *spl_image,
> +int spl_sdp_handle(struct udevice *udc, struct spl_image_info *spl_image,
>  		   struct spl_boot_device *bootdev)
>  #endif
>  {
> @@ -929,7 +929,7 @@ int spl_sdp_handle(int controller_index, struct spl_image_info *spl_image,
>  			return 0;
>  
>  		schedule();
> -		usb_gadget_handle_interrupts(controller_index);
> +		dm_usb_gadget_handle_interrupts(udc);
>  
>  #ifdef CONFIG_SPL_BUILD
>  		flag = sdp_handle_in_ep(spl_image, bootdev);
> diff --git a/include/sdp.h b/include/sdp.h
> index 6d89baa04ec..5492f9c47d2 100644
> --- a/include/sdp.h
> +++ b/include/sdp.h
> @@ -9,15 +9,15 @@
>  #ifndef __SDP_H_
>  #define __SDP_H_
>  
> -int sdp_init(int controller_index);
> +int sdp_init(struct udevice *udc);
>  
>  #ifdef CONFIG_SPL_BUILD
>  #include <spl.h>
>  
> -int spl_sdp_handle(int controller_index, struct spl_image_info *spl_image,
> +int spl_sdp_handle(struct udevice *udc, struct spl_image_info *spl_image,
>  		   struct spl_boot_device *bootdev);
>  #else
> -int sdp_handle(int controller_index);
> +int sdp_handle(struct udevice *udc);
>  #endif
>  
>  #endif /* __SDP_H_ */
> -- 
> 2.40.1

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 16/17] dm: usb: udc: Drop legacy udevice handler functions
  2023-08-19 14:24 ` [PATCH 16/17] dm: usb: udc: Drop legacy udevice handler functions Marek Vasut
@ 2023-08-22 16:52   ` Mattijs Korpershoek
  0 siblings, 0 replies; 33+ messages in thread
From: Mattijs Korpershoek @ 2023-08-22 16:52 UTC (permalink / raw)
  To: Marek Vasut, u-boot
  Cc: Marek Vasut, Angus Ainslie, Dmitrii Merkurev, Eddie Cai,
	Kever Yang, Lukasz Majewski, Miquel Raynal, Nishanth Menon,
	Patrice Chotard, Patrick Delaunay, Philipp Tomsich, Simon Glass,
	Stefan Roese, kernel

On sam., août 19, 2023 at 16:24, Marek Vasut <marex@denx.de> wrote:

> Remove legacy functions limited by the dev_array array,
> those are no longer used anywhere, all the code uses
> plain udevice based access now.
>
> The usb_gadget_handle_interrupts() is doing udevice look up
> until all call sites use dm_usb_gadget_handle_interrupts().
>
> Signed-off-by: Marek Vasut <marex@denx.de>
> ---
> Cc: Angus Ainslie <angus@akkea.ca>
> Cc: Dmitrii Merkurev <dimorinny@google.com>
> Cc: Eddie Cai <eddie.cai.linux@gmail.com>
> Cc: Kever Yang <kever.yang@rock-chips.com>
> Cc: Lukasz Majewski <lukma@denx.de>
> Cc: Miquel Raynal <miquel.raynal@bootlin.com>
> Cc: Mattijs Korpershoek <mkorpershoek@baylibre.com>
> Cc: Nishanth Menon <nm@ti.com>
> Cc: Patrice Chotard <patrice.chotard@foss.st.com>
> Cc: Patrick Delaunay <patrick.delaunay@foss.st.com>
> Cc: Philipp Tomsich <philipp.tomsich@vrull.eu>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Stefan Roese <sr@denx.de>
> Cc: kernel@puri.sm
> ---
>  drivers/usb/gadget/udc/udc-uclass.c | 44 ++++-------------------------
>  include/linux/usb/gadget.h          | 17 -----------
>  2 files changed, 6 insertions(+), 55 deletions(-)

Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>

>
> diff --git a/drivers/usb/gadget/udc/udc-uclass.c b/drivers/usb/gadget/udc/udc-uclass.c
> index b4271b4be9f..7f54a3b00cb 100644
> --- a/drivers/usb/gadget/udc/udc-uclass.c
> +++ b/drivers/usb/gadget/udc/udc-uclass.c
> @@ -12,9 +12,6 @@
>  #include <linux/usb/gadget.h>
>  
>  #if CONFIG_IS_ENABLED(DM_USB_GADGET)
> -#define MAX_UDC_DEVICES 4
> -static struct udevice *dev_array[MAX_UDC_DEVICES];
> -
>  int udc_device_get_by_index(int index, struct udevice **udev)
>  {
>  	struct udevice *dev = NULL;
> @@ -45,45 +42,16 @@ int udc_device_put(struct udevice *udev)
>  #endif
>  }
>  
> -int usb_gadget_initialize(int index)
> -{
> -	int ret;
> -	struct udevice *dev = NULL;
> -
> -	if (index < 0 || index >= ARRAY_SIZE(dev_array))
> -		return -EINVAL;
> -	if (dev_array[index])
> -		return 0;
> -	ret = udc_device_get_by_index(index, &dev);
> -	if (!dev || ret) {
> -		pr_err("No USB device found\n");
> -		return -ENODEV;
> -	}
> -	dev_array[index] = dev;
> -	return 0;
> -}
> -
> -int usb_gadget_release(int index)
> +int usb_gadget_handle_interrupts(int index)
>  {
> -#if CONFIG_IS_ENABLED(DM_DEVICE_REMOVE)
> +	struct udevice *udc;
>  	int ret;
> -	if (index < 0 || index >= ARRAY_SIZE(dev_array))
> -		return -EINVAL;
>  
> -	ret = device_remove(dev_array[index]);
> -	if (!ret)
> -		dev_array[index] = NULL;
> -	return ret;
> -#else
> -	return -ENOSYS;
> -#endif
> -}
> +	ret = udc_device_get_by_index(index, &udc);
> +	if (ret)
> +		return ret;
>  
> -int usb_gadget_handle_interrupts(int index)
> -{
> -	if (index < 0 || index >= ARRAY_SIZE(dev_array))
> -		return -EINVAL;
> -	return dm_usb_gadget_handle_interrupts(dev_array[index]);
> +	return dm_usb_gadget_handle_interrupts(udc);
>  }
>  #else
>  /* Backwards hardware compatibility -- switch to DM_USB_GADGET */
> diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
> index 5e9a6513d5b..54875d2716e 100644
> --- a/include/linux/usb/gadget.h
> +++ b/include/linux/usb/gadget.h
> @@ -1023,21 +1023,4 @@ int udc_device_get_by_index(int index, struct udevice **udev);
>   */
>  int udc_device_put(struct udevice *udev);
>  
> -#if CONFIG_IS_ENABLED(DM_USB_GADGET)
> -int usb_gadget_initialize(int index);
> -int usb_gadget_release(int index);
> -int dm_usb_gadget_handle_interrupts(struct udevice *dev);
> -#else
> -#include <usb.h>
> -static inline int usb_gadget_initialize(int index)
> -{
> -	return board_usb_init(index, USB_INIT_DEVICE);
> -}
> -
> -static inline int usb_gadget_release(int index)
> -{
> -	return board_usb_cleanup(index, USB_INIT_DEVICE);
> -}
> -#endif
> -
>  #endif	/* __LINUX_USB_GADGET_H */
> -- 
> 2.40.1

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 17/17] board: usb: Replace legacy usb_gadget_handle_interrupts()
  2023-08-19 14:24 ` [PATCH 17/17] board: usb: Replace legacy usb_gadget_handle_interrupts() Marek Vasut
@ 2023-08-22 16:58   ` Mattijs Korpershoek
  0 siblings, 0 replies; 33+ messages in thread
From: Mattijs Korpershoek @ 2023-08-22 16:58 UTC (permalink / raw)
  To: Marek Vasut, u-boot
  Cc: Marek Vasut, Angus Ainslie, Dmitrii Merkurev, Eddie Cai,
	Kever Yang, Lukasz Majewski, Miquel Raynal, Nishanth Menon,
	Patrice Chotard, Patrick Delaunay, Philipp Tomsich, Simon Glass,
	Stefan Roese, kernel

On sam., août 19, 2023 at 16:24, Marek Vasut <marex@denx.de> wrote:

> The usb_gadget_handle_interrupts() is no longer used anywhere,
> replace the remaining uses with dm_usb_gadget_handle_interrupts()
> which takes udevice as a parameter.
>
> Some of the UDC drivers currently ignore the index parameter altogether,
> those also ignore the udevice and have to be reworked. Other like the
> dwc3_uboot_handle_interrupt() had to be switched from index to udevice
> look up to avoid breakage.
>
> Signed-off-by: Marek Vasut <marex@denx.de>
> ---
> NOTE: Next step, get rid of dwc3_uboot_init()/dwc3_uboot_exit()
> ---
> Cc: Angus Ainslie <angus@akkea.ca>
> Cc: Dmitrii Merkurev <dimorinny@google.com>
> Cc: Eddie Cai <eddie.cai.linux@gmail.com>
> Cc: Kever Yang <kever.yang@rock-chips.com>
> Cc: Lukasz Majewski <lukma@denx.de>
> Cc: Miquel Raynal <miquel.raynal@bootlin.com>
> Cc: Mattijs Korpershoek <mkorpershoek@baylibre.com>
> Cc: Nishanth Menon <nm@ti.com>
> Cc: Patrice Chotard <patrice.chotard@foss.st.com>
> Cc: Patrick Delaunay <patrick.delaunay@foss.st.com>
> Cc: Philipp Tomsich <philipp.tomsich@vrull.eu>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Stefan Roese <sr@denx.de>
> Cc: kernel@puri.sm
> ---
>  arch/arm/mach-rockchip/board.c      |  4 ++--
>  board/purism/librem5/spl.c          |  4 ++--
>  board/samsung/common/exynos5-dt.c   |  4 ++--
>  board/st/stih410-b2260/board.c      |  4 ++--
>  board/ti/am43xx/board.c             |  6 +++---
>  drivers/usb/dwc3/core.c             |  6 +++---
>  drivers/usb/dwc3/dwc3-omap.c        |  8 ++++----
>  drivers/usb/gadget/at91_udc.c       |  2 +-
>  drivers/usb/gadget/atmel_usba_udc.c |  3 +--
>  drivers/usb/gadget/ci_udc.c         |  4 ++--
>  drivers/usb/gadget/dwc2_udc_otg.c   | 12 ++----------
>  drivers/usb/gadget/udc/udc-uclass.c | 12 ------------
>  drivers/usb/host/usb-sandbox.c      |  5 -----
>  drivers/usb/musb-new/musb_uboot.c   |  2 +-
>  include/dwc3-omap-uboot.h           |  2 +-
>  include/dwc3-uboot.h                |  2 +-
>  include/linux/usb/gadget.h          |  2 +-
>  17 files changed, 28 insertions(+), 54 deletions(-)

Tested that I could reflash the vim3 bootloader (on mmc2boot0)

Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
Tested-by: Mattijs Korpershoek <mkorpershoek@baylibre.com> # on khadas vim3

>
> diff --git a/arch/arm/mach-rockchip/board.c b/arch/arm/mach-rockchip/board.c
> index 8d7b39ba157..57f08e0be0e 100644
> --- a/arch/arm/mach-rockchip/board.c
> +++ b/arch/arm/mach-rockchip/board.c
> @@ -299,9 +299,9 @@ static struct dwc3_device dwc3_device_data = {
>  	.hsphy_mode = USBPHY_INTERFACE_MODE_UTMIW,
>  };
>  
> -int usb_gadget_handle_interrupts(int index)
> +int dm_usb_gadget_handle_interrupts(struct udevice *dev)
>  {
> -	dwc3_uboot_handle_interrupt(0);
> +	dwc3_uboot_handle_interrupt(dev);
>  	return 0;
>  }
>  
> diff --git a/board/purism/librem5/spl.c b/board/purism/librem5/spl.c
> index 90f1fcf415f..581f0929662 100644
> --- a/board/purism/librem5/spl.c
> +++ b/board/purism/librem5/spl.c
> @@ -418,9 +418,9 @@ out:
>  	return rv;
>  }
>  
> -int usb_gadget_handle_interrupts(int index)
> +int dm_usb_gadget_handle_interrupts(struct udevice *dev)
>  {
> -	dwc3_uboot_handle_interrupt(0);
> +	dwc3_uboot_handle_interrupt(dev);
>  	return 0;
>  }
>  
> diff --git a/board/samsung/common/exynos5-dt.c b/board/samsung/common/exynos5-dt.c
> index cde77d79a0f..726b7f0667a 100644
> --- a/board/samsung/common/exynos5-dt.c
> +++ b/board/samsung/common/exynos5-dt.c
> @@ -126,9 +126,9 @@ static struct dwc3_device dwc3_device_data = {
>  	.index = 0,
>  };
>  
> -int usb_gadget_handle_interrupts(int index)
> +int dm_usb_gadget_handle_interrupts(struct udevice *dev)
>  {
> -	dwc3_uboot_handle_interrupt(0);
> +	dwc3_uboot_handle_interrupt(dev);
>  	return 0;
>  }
>  
> diff --git a/board/st/stih410-b2260/board.c b/board/st/stih410-b2260/board.c
> index cd3a7dc51a2..e21cbc270e9 100644
> --- a/board/st/stih410-b2260/board.c
> +++ b/board/st/stih410-b2260/board.c
> @@ -50,9 +50,9 @@ static struct dwc3_device dwc3_device_data = {
>  	.index = 0,
>  };
>  
> -int usb_gadget_handle_interrupts(int index)
> +int dm_usb_gadget_handle_interrupts(struct udevice *dev)
>  {
> -	dwc3_uboot_handle_interrupt(index);
> +	dwc3_uboot_handle_interrupt(dev);
>  	return 0;
>  }
>  
> diff --git a/board/ti/am43xx/board.c b/board/ti/am43xx/board.c
> index 87e552a4701..58bfe7cd455 100644
> --- a/board/ti/am43xx/board.c
> +++ b/board/ti/am43xx/board.c
> @@ -760,13 +760,13 @@ static struct ti_usb_phy_device usb_phy2_device = {
>  	.index = 1,
>  };
>  
> -int usb_gadget_handle_interrupts(int index)
> +int dm_usb_gadget_handle_interrupts(struct udevice *dev)
>  {
>  	u32 status;
>  
> -	status = dwc3_omap_uboot_interrupt_status(index);
> +	status = dwc3_omap_uboot_interrupt_status(dev);
>  	if (status)
> -		dwc3_uboot_handle_interrupt(index);
> +		dwc3_uboot_handle_interrupt(dev);
>  
>  	return 0;
>  }
> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
> index 49f6a1900b0..7ca9d09824e 100644
> --- a/drivers/usb/dwc3/core.c
> +++ b/drivers/usb/dwc3/core.c
> @@ -986,18 +986,18 @@ void dwc3_uboot_exit(int index)
>  
>  /**
>   * dwc3_uboot_handle_interrupt - handle dwc3 core interrupt
> - * @index: index of this controller
> + * @dev: device of this controller
>   *
>   * Invokes dwc3 gadget interrupts.
>   *
>   * Generally called from board file.
>   */
> -void dwc3_uboot_handle_interrupt(int index)
> +void dwc3_uboot_handle_interrupt(struct udevice *dev)
>  {
>  	struct dwc3 *dwc = NULL;
>  
>  	list_for_each_entry(dwc, &dwc3_list, list) {
> -		if (dwc->index != index)
> +		if (dwc->dev != dev)
>  			continue;
>  
>  		dwc3_gadget_uboot_handle_interrupt(dwc);
> diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c
> index 9596bf144c3..ff4ebfb4447 100644
> --- a/drivers/usb/dwc3/dwc3-omap.c
> +++ b/drivers/usb/dwc3/dwc3-omap.c
> @@ -119,7 +119,7 @@
>  #define USBOTGSS_UTMI_OTG_STATUS_VBUSVALID	(1 << 1)
>  
>  struct dwc3_omap {
> -	struct device		*dev;
> +	struct udevice		*dev;
>  
>  	void __iomem		*base;
>  
> @@ -429,19 +429,19 @@ void dwc3_omap_uboot_exit(int index)
>  
>  /**
>   * dwc3_omap_uboot_interrupt_status - check the status of interrupt
> - * @index: index of this controller
> + * @dev: device of this controller
>   *
>   * Checks the status of interrupts and returns true if an interrupt
>   * is detected or false otherwise.
>   *
>   * Generally called from board file.
>   */
> -int dwc3_omap_uboot_interrupt_status(int index)
> +int dwc3_omap_uboot_interrupt_status(struct udevice *dev)
>  {
>  	struct dwc3_omap *omap = NULL;
>  
>  	list_for_each_entry(omap, &dwc3_omap_list, list)
> -		if (omap->index == index)
> +		if (omap->dev == dev)
>  			return dwc3_omap_interrupt(-1, omap);
>  
>  	return 0;
> diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c
> index baa4c431fed..61d2aa5b929 100644
> --- a/drivers/usb/gadget/at91_udc.c
> +++ b/drivers/usb/gadget/at91_udc.c
> @@ -1429,7 +1429,7 @@ static const struct at91_udc_caps at91sam9261_udc_caps = {
>  };
>  #endif
>  
> -int usb_gadget_handle_interrupts(int index)
> +int dm_usb_gadget_handle_interrupts(struct udevice *dev)
>  {
>  	struct at91_udc *udc = controller;
>  
> diff --git a/drivers/usb/gadget/atmel_usba_udc.c b/drivers/usb/gadget/atmel_usba_udc.c
> index f4dcd205a4f..90b248a0777 100644
> --- a/drivers/usb/gadget/atmel_usba_udc.c
> +++ b/drivers/usb/gadget/atmel_usba_udc.c
> @@ -1198,14 +1198,13 @@ static struct usba_udc controller = {
>  	},
>  };
>  
> -int usb_gadget_handle_interrupts(int index)
> +int dm_usb_gadget_handle_interrupts(struct udevice *dev)
>  {
>  	struct usba_udc *udc = &controller;
>  
>  	return usba_udc_irq(udc);
>  }
>  
> -
>  int usb_gadget_register_driver(struct usb_gadget_driver *driver)
>  {
>  	struct usba_udc *udc = &controller;
> diff --git a/drivers/usb/gadget/ci_udc.c b/drivers/usb/gadget/ci_udc.c
> index 5bb26d7ab4a..44d2da0b4fb 100644
> --- a/drivers/usb/gadget/ci_udc.c
> +++ b/drivers/usb/gadget/ci_udc.c
> @@ -869,10 +869,10 @@ void udc_irq(void)
>  	}
>  }
>  
> -int usb_gadget_handle_interrupts(int index)
> +int dm_usb_gadget_handle_interrupts(struct udevice *dev)
>  {
> -	u32 value;
>  	struct ci_udc *udc = (struct ci_udc *)controller.ctrl->hcor;
> +	u32 value;
>  
>  	value = readl(&udc->usbsts);
>  	if (value)
> diff --git a/drivers/usb/gadget/dwc2_udc_otg.c b/drivers/usb/gadget/dwc2_udc_otg.c
> index 0a3bc0886e6..ff5173eda68 100644
> --- a/drivers/usb/gadget/dwc2_udc_otg.c
> +++ b/drivers/usb/gadget/dwc2_udc_otg.c
> @@ -941,15 +941,12 @@ int dwc2_udc_handle_interrupt(void)
>  	return 0;
>  }
>  
> -#if !CONFIG_IS_ENABLED(DM_USB_GADGET)
> -
> -int usb_gadget_handle_interrupts(int index)
> +int dm_usb_gadget_handle_interrupts(struct udevice *dev)
>  {
>  	return dwc2_udc_handle_interrupt();
>  }
>  
> -#else /* CONFIG_IS_ENABLED(DM_USB_GADGET) */
> -
> +#if CONFIG_IS_ENABLED(DM_USB_GADGET)
>  struct dwc2_priv_data {
>  	struct clk_bulk		clks;
>  	struct reset_ctl_bulk	resets;
> @@ -957,11 +954,6 @@ struct dwc2_priv_data {
>  	struct udevice *usb33d_supply;
>  };
>  
> -int dm_usb_gadget_handle_interrupts(struct udevice *dev)
> -{
> -	return dwc2_udc_handle_interrupt();
> -}
> -
>  static int dwc2_phy_setup(struct udevice *dev, struct phy_bulk *phys)
>  {
>  	int ret;
> diff --git a/drivers/usb/gadget/udc/udc-uclass.c b/drivers/usb/gadget/udc/udc-uclass.c
> index 7f54a3b00cb..9dfae08313b 100644
> --- a/drivers/usb/gadget/udc/udc-uclass.c
> +++ b/drivers/usb/gadget/udc/udc-uclass.c
> @@ -41,18 +41,6 @@ int udc_device_put(struct udevice *udev)
>  	return -ENOSYS;
>  #endif
>  }
> -
> -int usb_gadget_handle_interrupts(int index)
> -{
> -	struct udevice *udc;
> -	int ret;
> -
> -	ret = udc_device_get_by_index(index, &udc);
> -	if (ret)
> -		return ret;
> -
> -	return dm_usb_gadget_handle_interrupts(udc);
> -}
>  #else
>  /* Backwards hardware compatibility -- switch to DM_USB_GADGET */
>  static int legacy_index;
> diff --git a/drivers/usb/host/usb-sandbox.c b/drivers/usb/host/usb-sandbox.c
> index 582f72d00c1..3d4f8d653b5 100644
> --- a/drivers/usb/host/usb-sandbox.c
> +++ b/drivers/usb/host/usb-sandbox.c
> @@ -130,11 +130,6 @@ int dm_usb_gadget_handle_interrupts(struct udevice *dev)
>  	return 0;
>  }
>  #else
> -int usb_gadget_handle_interrupts(int index)
> -{
> -	return 0;
> -}
> -
>  int usb_gadget_register_driver(struct usb_gadget_driver *driver)
>  {
>  	struct sandbox_udc *dev = this_controller;
> diff --git a/drivers/usb/musb-new/musb_uboot.c b/drivers/usb/musb-new/musb_uboot.c
> index 67dc11669d2..0dcc428efeb 100644
> --- a/drivers/usb/musb-new/musb_uboot.c
> +++ b/drivers/usb/musb-new/musb_uboot.c
> @@ -376,7 +376,7 @@ struct dm_usb_ops musb_usb_ops = {
>  #if defined(CONFIG_USB_MUSB_GADGET) && !CONFIG_IS_ENABLED(DM_USB_GADGET)
>  static struct musb *gadget;
>  
> -int usb_gadget_handle_interrupts(int index)
> +int dm_usb_gadget_handle_interrupts(struct udevice *dev)
>  {
>  	schedule();
>  	if (!gadget || !gadget->isr)
> diff --git a/include/dwc3-omap-uboot.h b/include/dwc3-omap-uboot.h
> index 7c982e3798b..9e0e717dc98 100644
> --- a/include/dwc3-omap-uboot.h
> +++ b/include/dwc3-omap-uboot.h
> @@ -27,5 +27,5 @@ struct dwc3_omap_device {
>  
>  int dwc3_omap_uboot_init(struct dwc3_omap_device *dev);
>  void dwc3_omap_uboot_exit(int index);
> -int dwc3_omap_uboot_interrupt_status(int index);
> +int dwc3_omap_uboot_interrupt_status(struct udevice *dev);
>  #endif /* __DWC3_OMAP_UBOOT_H_ */
> diff --git a/include/dwc3-uboot.h b/include/dwc3-uboot.h
> index e08530ec4e5..bb0436c0973 100644
> --- a/include/dwc3-uboot.h
> +++ b/include/dwc3-uboot.h
> @@ -44,7 +44,7 @@ struct dwc3_device {
>  
>  int dwc3_uboot_init(struct dwc3_device *dev);
>  void dwc3_uboot_exit(int index);
> -void dwc3_uboot_handle_interrupt(int index);
> +void dwc3_uboot_handle_interrupt(struct udevice *dev);
>  
>  struct phy;
>  #if CONFIG_IS_ENABLED(PHY) && CONFIG_IS_ENABLED(DM_USB)
> diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
> index 54875d2716e..40228e320b3 100644
> --- a/include/linux/usb/gadget.h
> +++ b/include/linux/usb/gadget.h
> @@ -1004,7 +1004,7 @@ extern struct usb_ep *usb_ep_autoconfig(struct usb_gadget *,
>  
>  extern void usb_ep_autoconfig_reset(struct usb_gadget *);
>  
> -extern int usb_gadget_handle_interrupts(int index);
> +extern int dm_usb_gadget_handle_interrupts(struct udevice *);
>  
>  /**
>   * udc_device_get_by_index() - Get UDC udevice by index
> -- 
> 2.40.1

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 11/17] spl: sdp: Detach the controller on error
  2023-08-22 16:44   ` Mattijs Korpershoek
@ 2023-09-01  9:52     ` Marek Vasut
  0 siblings, 0 replies; 33+ messages in thread
From: Marek Vasut @ 2023-09-01  9:52 UTC (permalink / raw)
  To: Mattijs Korpershoek, u-boot
  Cc: Angus Ainslie, Dmitrii Merkurev, Eddie Cai, Kever Yang,
	Lukasz Majewski, Miquel Raynal, Nishanth Menon, Patrice Chotard,
	Patrick Delaunay, Philipp Tomsich, Simon Glass, Stefan Roese,
	kernel

On 8/22/23 18:44, Mattijs Korpershoek wrote:
> On sam., août 19, 2023 at 16:24, Marek Vasut <marex@denx.de> wrote:
> 
>> In case anything errors out during the SDP transfer, detach
>> the controller instead of bailing out right away. This way,
>> the controller can be reattached on next attempt.
>>
>> Signed-off-by: Marek Vasut <marex@denx.de>
>> ---
>> Cc: Angus Ainslie <angus@akkea.ca>
>> Cc: Dmitrii Merkurev <dimorinny@google.com>
>> Cc: Eddie Cai <eddie.cai.linux@gmail.com>
>> Cc: Kever Yang <kever.yang@rock-chips.com>
>> Cc: Lukasz Majewski <lukma@denx.de>
>> Cc: Miquel Raynal <miquel.raynal@bootlin.com>
>> Cc: Mattijs Korpershoek <mkorpershoek@baylibre.com>
>> Cc: Nishanth Menon <nm@ti.com>
>> Cc: Patrice Chotard <patrice.chotard@foss.st.com>
>> Cc: Patrick Delaunay <patrick.delaunay@foss.st.com>
>> Cc: Philipp Tomsich <philipp.tomsich@vrull.eu>
>> Cc: Simon Glass <sjg@chromium.org>
>> Cc: Stefan Roese <sr@denx.de>
>> Cc: kernel@puri.sm
>> ---
> 
> Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
> 
> Nitpick/question below
> 
>>   common/spl/spl_sdp.c | 5 +++--
>>   1 file changed, 3 insertions(+), 2 deletions(-)
>>
>> diff --git a/common/spl/spl_sdp.c b/common/spl/spl_sdp.c
>> index cc4fb4f7cca..f6b99c1af5a 100644
>> --- a/common/spl/spl_sdp.c
>> +++ b/common/spl/spl_sdp.c
>> @@ -25,13 +25,13 @@ static int spl_sdp_load_image(struct spl_image_info *spl_image,
>>   	ret = g_dnl_register("usb_dnl_sdp");
>>   	if (ret) {
>>   		pr_err("SDP dnl register failed: %d\n", ret);
>> -		return ret;
>> +		goto err_detach;
>>   	}
>>   
>>   	ret = sdp_init(controller_index);
>>   	if (ret) {
>>   		pr_err("SDP init failed: %d\n", ret);
>> -		return -ENODEV;
>> +		goto err_detach;
> 
> Shouldn't we call g_dnl_unregister(); here since g_dnl_register() was
> sucessfully called before?

It should, fixed in V2, thanks for your help !

^ permalink raw reply	[flat|nested] 33+ messages in thread

end of thread, other threads:[~2023-09-01  9:53 UTC | newest]

Thread overview: 33+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-19 14:23 [PATCH 01/17] dm: usb: udc: Factor out plain udevice handler functions Marek Vasut
2023-08-19 14:23 ` [PATCH 02/17] usb: sandbox: Add DM_USB_GADGET support Marek Vasut
2023-08-20 17:48   ` Simon Glass
2023-08-22 16:10   ` Mattijs Korpershoek
2023-08-19 14:23 ` [PATCH 03/17] configs: sandbox: Enable DM_USB_GADGET Marek Vasut
2023-08-20 17:48   ` Simon Glass
2023-08-22 16:10   ` Mattijs Korpershoek
2023-08-19 14:23 ` [PATCH 04/17] cmd: fastboot: Use plain udevice for UDC controller interaction Marek Vasut
2023-08-22 16:22   ` Mattijs Korpershoek
2023-08-19 14:23 ` [PATCH 05/17] cmd: rockusb: " Marek Vasut
2023-08-19 14:23 ` [PATCH 06/17] cmd: sdp: Reorder variable declaration Marek Vasut
2023-08-22 16:24   ` Mattijs Korpershoek
2023-08-19 14:23 ` [PATCH 07/17] cmd: thordown: " Marek Vasut
2023-08-19 14:23 ` [PATCH 08/17] cmd: ums: Use plain udevice for UDC controller interaction Marek Vasut
2023-08-22 16:29   ` Mattijs Korpershoek
2023-08-19 14:23 ` [PATCH 09/17] dfu: Detach the controller on error Marek Vasut
2023-08-22 16:32   ` Mattijs Korpershoek
2023-08-19 14:24 ` [PATCH 10/17] dfu: Use plain udevice for UDC controller interaction Marek Vasut
2023-08-22 16:33   ` Mattijs Korpershoek
2023-08-19 14:24 ` [PATCH 11/17] spl: sdp: Detach the controller on error Marek Vasut
2023-08-22 16:44   ` Mattijs Korpershoek
2023-09-01  9:52     ` Marek Vasut
2023-08-19 14:24 ` [PATCH 12/17] sdp: Use plain udevice for UDC controller interaction Marek Vasut
2023-08-22 16:46   ` Mattijs Korpershoek
2023-08-19 14:24 ` [PATCH 13/17] thordown: " Marek Vasut
2023-08-19 14:24 ` [PATCH 14/17] usb: gadget: acm: " Marek Vasut
2023-08-19 14:24 ` [PATCH 15/17] usb: gadget: ether: " Marek Vasut
2023-08-19 14:24 ` [PATCH 16/17] dm: usb: udc: Drop legacy udevice handler functions Marek Vasut
2023-08-22 16:52   ` Mattijs Korpershoek
2023-08-19 14:24 ` [PATCH 17/17] board: usb: Replace legacy usb_gadget_handle_interrupts() Marek Vasut
2023-08-22 16:58   ` Mattijs Korpershoek
2023-08-21  8:39 ` [PATCH 01/17] dm: usb: udc: Factor out plain udevice handler functions Miquel Raynal
2023-08-22 16:07 ` Mattijs Korpershoek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox