public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH 1/5] spl: sdp: call board_usb_init at spl_sdp_load_image
@ 2020-04-29  2:35 Peng Fan
  2020-04-29  2:35 ` [PATCH 2/5] usb: gadget: sdp: use CONFIG_SDP_LOADADDR as default load address Peng Fan
                   ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: Peng Fan @ 2020-04-29  2:35 UTC (permalink / raw)
  To: u-boot

From: Frank Li <Frank.Li@nxp.com>

Need initialize UDC before run sdp download

Signed-off-by: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 common/spl/spl_sdp.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/common/spl/spl_sdp.c b/common/spl/spl_sdp.c
index 806bf1327e..a54c7479d0 100644
--- a/common/spl/spl_sdp.c
+++ b/common/spl/spl_sdp.c
@@ -16,6 +16,8 @@ static int spl_sdp_load_image(struct spl_image_info *spl_image,
 	int ret;
 	const int controller_index = 0;
 
+	board_usb_init(0, USB_INIT_DEVICE);
+
 	g_dnl_clear_detach();
 	ret = g_dnl_register("usb_dnl_sdp");
 	if (ret) {
-- 
2.16.4

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

* [PATCH 2/5] usb: gadget: sdp: use CONFIG_SDP_LOADADDR as default load address
  2020-04-29  2:35 [PATCH 1/5] spl: sdp: call board_usb_init at spl_sdp_load_image Peng Fan
@ 2020-04-29  2:35 ` Peng Fan
  2020-05-04  7:34   ` sbabic at denx.de
  2020-04-29  2:35 ` [PATCH 3/5] spl: sdp: Add CONFIG_SPL_SDP_USB_DEV for USB device Peng Fan
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 10+ messages in thread
From: Peng Fan @ 2020-04-29  2:35 UTC (permalink / raw)
  To: u-boot

From: Frank Li <Frank.Li@nxp.com>

If SDP_WRITE and SDP_JUMP addr is zero, use CONFIG_SDP_LOADADDR
as default address

Signed-off-by: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/usb/gadget/Kconfig | 4 ++++
 drivers/usb/gadget/f_sdp.c | 4 ++--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 58ca82d4de..46aa3fe954 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -122,6 +122,10 @@ config USB_GADGET_VBUS_DRAW
 	   This value will be used except for system-specific gadget
 	   drivers that have more specific information.
 
+config SDP_LOADADDR
+	hex "Default load address at SDP_WRITE and SDP_JUMP"
+	default 0
+
 # Selected by UDC drivers that support high-speed operation.
 config USB_GADGET_DUALSPEED
 	bool
diff --git a/drivers/usb/gadget/f_sdp.c b/drivers/usb/gadget/f_sdp.c
index 50836db4a0..1732a3acf1 100644
--- a/drivers/usb/gadget/f_sdp.c
+++ b/drivers/usb/gadget/f_sdp.c
@@ -276,7 +276,7 @@ static void sdp_rx_command_complete(struct usb_ep *ep, struct usb_request *req)
 		sdp->error_status = SDP_WRITE_FILE_COMPLETE;
 
 		sdp->state = SDP_STATE_RX_FILE_DATA;
-		sdp->dnl_address = be32_to_cpu(cmd->addr);
+		sdp->dnl_address = cmd->addr ? be32_to_cpu(cmd->addr) : CONFIG_SDP_LOADADDR;
 		sdp->dnl_bytes_remaining = be32_to_cpu(cmd->cnt);
 		sdp->dnl_bytes = sdp->dnl_bytes_remaining;
 		sdp->next_state = SDP_STATE_IDLE;
@@ -304,7 +304,7 @@ static void sdp_rx_command_complete(struct usb_ep *ep, struct usb_request *req)
 		sdp->always_send_status = false;
 		sdp->error_status = 0;
 
-		sdp->jmp_address = be32_to_cpu(cmd->addr);
+		sdp->jmp_address = cmd->addr ? be32_to_cpu(cmd->addr) : CONFIG_SDP_LOADADDR;
 		sdp->state = SDP_STATE_TX_SEC_CONF;
 		sdp->next_state = SDP_STATE_JUMP;
 		break;
-- 
2.16.4

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

* [PATCH 3/5] spl: sdp: Add CONFIG_SPL_SDP_USB_DEV for USB device
  2020-04-29  2:35 [PATCH 1/5] spl: sdp: call board_usb_init at spl_sdp_load_image Peng Fan
  2020-04-29  2:35 ` [PATCH 2/5] usb: gadget: sdp: use CONFIG_SDP_LOADADDR as default load address Peng Fan
@ 2020-04-29  2:35 ` Peng Fan
  2020-05-04  7:35   ` sbabic at denx.de
  2020-04-29  2:35 ` [PATCH 4/5] spl: sdp: Add a callback to clean up USB driver Peng Fan
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 10+ messages in thread
From: Peng Fan @ 2020-04-29  2:35 UTC (permalink / raw)
  To: u-boot

From: Ye Li <ye.li@nxp.com>

Add a new configuration CONFIG_SPL_SDP_USB_DEV to specify the
usb index for spl sdp driver, so that we change use different device.
The default value is 0.

Signed-off-by: Ye Li <ye.li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 common/spl/Kconfig   | 8 ++++++++
 common/spl/spl_sdp.c | 4 ++--
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index ef5bf66696..8c44274992 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -1181,6 +1181,14 @@ config SPL_USB_SDP_SUPPORT
 	  Enable Serial Download Protocol (SDP) device support in SPL. This
 	  allows to download images into memory and execute (jump to) them
 	  using the same protocol as implemented by the i.MX family's boot ROM.
+
+config SPL_SDP_USB_DEV
+	int "SDP USB controller index"
+	default 0
+	depends on SPL_USB_SDP_SUPPORT
+	help
+	  Some boards have USB controller other than 0. Define this option
+	  so it can be used in compiled environment.
 endif
 
 config SPL_WATCHDOG_SUPPORT
diff --git a/common/spl/spl_sdp.c b/common/spl/spl_sdp.c
index a54c7479d0..82bce0bd2e 100644
--- a/common/spl/spl_sdp.c
+++ b/common/spl/spl_sdp.c
@@ -14,9 +14,9 @@ static int spl_sdp_load_image(struct spl_image_info *spl_image,
 			      struct spl_boot_device *bootdev)
 {
 	int ret;
-	const int controller_index = 0;
+	const int controller_index = CONFIG_SPL_SDP_USB_DEV;
 
-	board_usb_init(0, USB_INIT_DEVICE);
+	board_usb_init(controller_index, USB_INIT_DEVICE);
 
 	g_dnl_clear_detach();
 	ret = g_dnl_register("usb_dnl_sdp");
-- 
2.16.4

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

* [PATCH 4/5] spl: sdp: Add a callback to clean up USB driver
  2020-04-29  2:35 [PATCH 1/5] spl: sdp: call board_usb_init at spl_sdp_load_image Peng Fan
  2020-04-29  2:35 ` [PATCH 2/5] usb: gadget: sdp: use CONFIG_SDP_LOADADDR as default load address Peng Fan
  2020-04-29  2:35 ` [PATCH 3/5] spl: sdp: Add CONFIG_SPL_SDP_USB_DEV for USB device Peng Fan
@ 2020-04-29  2:35 ` Peng Fan
  2020-05-04  7:35   ` sbabic at denx.de
  2020-04-29  2:35 ` [PATCH 5/5] spl: sdp: Add DM gadget support for sdp Peng Fan
  2020-05-04  7:34 ` [PATCH 1/5] spl: sdp: call board_usb_init at spl_sdp_load_image sbabic at denx.de
  4 siblings, 1 reply; 10+ messages in thread
From: Peng Fan @ 2020-04-29  2:35 UTC (permalink / raw)
  To: u-boot

From: Ye Li <ye.li@nxp.com>

Because SDP directly jumps to next level boot image, we'd better
clean up the USB driver before it. Implement a weak callback function,
that spl sdp can use it to clean up USB driver.

Signed-off-by: Ye Li <ye.li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 common/spl/spl_sdp.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/spl/spl_sdp.c b/common/spl/spl_sdp.c
index 82bce0bd2e..d150951b86 100644
--- a/common/spl/spl_sdp.c
+++ b/common/spl/spl_sdp.c
@@ -39,6 +39,7 @@ static int spl_sdp_load_image(struct spl_image_info *spl_image,
 	ret = spl_sdp_handle(controller_index, spl_image);
 	debug("SDP ended\n");
 
+	board_usb_cleanup(controller_index, USB_INIT_DEVICE);
 	return ret;
 }
 SPL_LOAD_IMAGE_METHOD("USB SDP", 0, BOOT_DEVICE_BOARD, spl_sdp_load_image);
-- 
2.16.4

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

* [PATCH 5/5] spl: sdp: Add DM gadget support for sdp
  2020-04-29  2:35 [PATCH 1/5] spl: sdp: call board_usb_init at spl_sdp_load_image Peng Fan
                   ` (2 preceding siblings ...)
  2020-04-29  2:35 ` [PATCH 4/5] spl: sdp: Add a callback to clean up USB driver Peng Fan
@ 2020-04-29  2:35 ` Peng Fan
  2020-05-04  7:34   ` sbabic at denx.de
  2020-05-04  7:34 ` [PATCH 1/5] spl: sdp: call board_usb_init at spl_sdp_load_image sbabic at denx.de
  4 siblings, 1 reply; 10+ messages in thread
From: Peng Fan @ 2020-04-29  2:35 UTC (permalink / raw)
  To: u-boot

From: Sherry Sun <sherry.sun@nxp.com>

When enable CONFG_SPL_DM_USB_GADGET, sdp should use
usb_gadget_initialize() and usb_gadget_release() to
support DM gadget driver.

Signed-off-by: Sherry Sun <sherry.sun@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 common/spl/spl_sdp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/common/spl/spl_sdp.c b/common/spl/spl_sdp.c
index d150951b86..644dfa8cc3 100644
--- a/common/spl/spl_sdp.c
+++ b/common/spl/spl_sdp.c
@@ -16,7 +16,7 @@ static int spl_sdp_load_image(struct spl_image_info *spl_image,
 	int ret;
 	const int controller_index = CONFIG_SPL_SDP_USB_DEV;
 
-	board_usb_init(controller_index, USB_INIT_DEVICE);
+	usb_gadget_initialize(controller_index);
 
 	g_dnl_clear_detach();
 	ret = g_dnl_register("usb_dnl_sdp");
@@ -39,7 +39,7 @@ static int spl_sdp_load_image(struct spl_image_info *spl_image,
 	ret = spl_sdp_handle(controller_index, spl_image);
 	debug("SDP ended\n");
 
-	board_usb_cleanup(controller_index, USB_INIT_DEVICE);
+	usb_gadget_release(controller_index);
 	return ret;
 }
 SPL_LOAD_IMAGE_METHOD("USB SDP", 0, BOOT_DEVICE_BOARD, spl_sdp_load_image);
-- 
2.16.4

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

* [PATCH 2/5] usb: gadget: sdp: use CONFIG_SDP_LOADADDR as default load address
  2020-04-29  2:35 ` [PATCH 2/5] usb: gadget: sdp: use CONFIG_SDP_LOADADDR as default load address Peng Fan
@ 2020-05-04  7:34   ` sbabic at denx.de
  0 siblings, 0 replies; 10+ messages in thread
From: sbabic at denx.de @ 2020-05-04  7:34 UTC (permalink / raw)
  To: u-boot

> From: Frank Li <Frank.Li@nxp.com>
> If SDP_WRITE and SDP_JUMP addr is zero, use CONFIG_SDP_LOADADDR
> as default address
> Signed-off-by: Frank Li <Frank.Li@nxp.com>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

-- 
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================

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

* [PATCH 1/5] spl: sdp: call board_usb_init at spl_sdp_load_image
  2020-04-29  2:35 [PATCH 1/5] spl: sdp: call board_usb_init at spl_sdp_load_image Peng Fan
                   ` (3 preceding siblings ...)
  2020-04-29  2:35 ` [PATCH 5/5] spl: sdp: Add DM gadget support for sdp Peng Fan
@ 2020-05-04  7:34 ` sbabic at denx.de
  4 siblings, 0 replies; 10+ messages in thread
From: sbabic at denx.de @ 2020-05-04  7:34 UTC (permalink / raw)
  To: u-boot

> From: Frank Li <Frank.Li@nxp.com>
> Need initialize UDC before run sdp download
> Signed-off-by: Frank Li <Frank.Li@nxp.com>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

-- 
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================

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

* [PATCH 5/5] spl: sdp: Add DM gadget support for sdp
  2020-04-29  2:35 ` [PATCH 5/5] spl: sdp: Add DM gadget support for sdp Peng Fan
@ 2020-05-04  7:34   ` sbabic at denx.de
  0 siblings, 0 replies; 10+ messages in thread
From: sbabic at denx.de @ 2020-05-04  7:34 UTC (permalink / raw)
  To: u-boot

> From: Sherry Sun <sherry.sun@nxp.com>
> When enable CONFG_SPL_DM_USB_GADGET, sdp should use
> usb_gadget_initialize() and usb_gadget_release() to
> support DM gadget driver.
> Signed-off-by: Sherry Sun <sherry.sun@nxp.com>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

-- 
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================

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

* [PATCH 4/5] spl: sdp: Add a callback to clean up USB driver
  2020-04-29  2:35 ` [PATCH 4/5] spl: sdp: Add a callback to clean up USB driver Peng Fan
@ 2020-05-04  7:35   ` sbabic at denx.de
  0 siblings, 0 replies; 10+ messages in thread
From: sbabic at denx.de @ 2020-05-04  7:35 UTC (permalink / raw)
  To: u-boot

> From: Ye Li <ye.li@nxp.com>
> Because SDP directly jumps to next level boot image, we'd better
> clean up the USB driver before it. Implement a weak callback function,
> that spl sdp can use it to clean up USB driver.
> Signed-off-by: Ye Li <ye.li@nxp.com>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

-- 
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================

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

* [PATCH 3/5] spl: sdp: Add CONFIG_SPL_SDP_USB_DEV for USB device
  2020-04-29  2:35 ` [PATCH 3/5] spl: sdp: Add CONFIG_SPL_SDP_USB_DEV for USB device Peng Fan
@ 2020-05-04  7:35   ` sbabic at denx.de
  0 siblings, 0 replies; 10+ messages in thread
From: sbabic at denx.de @ 2020-05-04  7:35 UTC (permalink / raw)
  To: u-boot

> From: Ye Li <ye.li@nxp.com>
> Add a new configuration CONFIG_SPL_SDP_USB_DEV to specify the
> usb index for spl sdp driver, so that we change use different device.
> The default value is 0.
> Signed-off-by: Ye Li <ye.li@nxp.com>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

-- 
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================

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

end of thread, other threads:[~2020-05-04  7:35 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-04-29  2:35 [PATCH 1/5] spl: sdp: call board_usb_init at spl_sdp_load_image Peng Fan
2020-04-29  2:35 ` [PATCH 2/5] usb: gadget: sdp: use CONFIG_SDP_LOADADDR as default load address Peng Fan
2020-05-04  7:34   ` sbabic at denx.de
2020-04-29  2:35 ` [PATCH 3/5] spl: sdp: Add CONFIG_SPL_SDP_USB_DEV for USB device Peng Fan
2020-05-04  7:35   ` sbabic at denx.de
2020-04-29  2:35 ` [PATCH 4/5] spl: sdp: Add a callback to clean up USB driver Peng Fan
2020-05-04  7:35   ` sbabic at denx.de
2020-04-29  2:35 ` [PATCH 5/5] spl: sdp: Add DM gadget support for sdp Peng Fan
2020-05-04  7:34   ` sbabic at denx.de
2020-05-04  7:34 ` [PATCH 1/5] spl: sdp: call board_usb_init at spl_sdp_load_image sbabic at denx.de

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