Skip to contentSkip to conversation

Make some changes to SDP

PATCH Superseded Sherry Sun 2 participants 8 messages Aug 22, 2019 – Aug 26, 2019

Subsystems (4)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Sherry Sun

author
#0 lore raw

v3 cover Make some changes to SDP

Changes in v3:
- Add reviewed-by tag for patch2/4 and patch4/4 since this two have been reviewed in v1.

Changes in v2:
- Update the commit log in patch 1/4.

This patchset adds:
1. Add usb_gadget_initialize() and usb_gadget_release() to initialize and release UDC during sdp download.
2. Add high speed endpoint descriptor for sdp.
3. Add a macro definition--CONFIG_SDP_LOADADDR as default sdp load address while SDP_WRITE and SDP_JUMP command addr is zero.

The current patches have been validated on both i.MX8 and i.MX8M platform.

Sherry Sun (4):
imx: spl: Change USB boot device type for imx8/8m
SDP: use CONFIG_SDP_LOADADDR as default load address
SDP: fix wrong usb request size and add high speed endpoint descriptor
SDP: Call usb_gadget_initialize and usb_gadget_release to support UDC

 arch/arm/mach-imx/spl.c    |  2 +-
 common/spl/spl_sdp.c       |  4 ++++
 drivers/usb/gadget/Kconfig |  4 ++++
 drivers/usb/gadget/f_sdp.c | 39 +++++++++++++++++++++++++++++++++-----
 4 files changed, 43 insertions(+), 6 deletions(-)
Signature · 1 line
2.17.1
author
#1 lore raw

PATCH v3 1/4 imx: spl: Change USB boot device type for imx8/8m

The SPL SDP is configured as BOOT_DEVICE_BOARD, but for i.MX8 and i.MX8M, the boot_device_spl is still set to BOOT_DEVICE_USB, which may cause SDP can't work, in order to fix this issue, when booting from USB in spl, we change its type to BOOT_DEVICE_BOARD.

---
 arch/arm/mach-imx/spl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-imx/spl.c +1 -1
index 1f230aca33..a74d222dd6 100644
@@ -158,7 +158,7 @@ u32 spl_boot_device(void)
 	case SPI_NOR_BOOT:
 		return BOOT_DEVICE_SPI;
 	case USB_BOOT:
-		return BOOT_DEVICE_USB;
+		return BOOT_DEVICE_BOARD;
 	default:
 		return BOOT_DEVICE_NONE;
 	}
Signature · 1 line
2.17.1
#2 lore raw

PATCH v3 1/4 imx: spl: Change USB boot device type for imx8/8m

Hi Sherry,

Quoted 16 lines

The SPL SDP is configured as BOOT_DEVICE_BOARD, but for i.MX8 and i.MX8M, the boot_device_spl is still set to BOOT_DEVICE_USB, which may cause SDP can't work, in order to fix this issue, when booting from USB in spl, we change its type to BOOT_DEVICE_BOARD.

---
 arch/arm/mach-imx/spl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-imx/spl.c +0 -0
index 1f230aca33..a74d222dd6 100644

arch/arm/mach-imx/spl.c u32 spl_boot_device(void) · line 164

Quoted 8 lines
arch/arm/mach-imx/spl.c +1 -1
@@ -158,7 +158,7 @@ u32 spl_boot_device(void)
 	case SPI_NOR_BOOT:
 		return BOOT_DEVICE_SPI;
 	case USB_BOOT:
-		return BOOT_DEVICE_USB;
+		return BOOT_DEVICE_BOARD;
 	default:
 		return BOOT_DEVICE_NONE;
 	}

Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma at denx.de -------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190826/01baef7d/attachment.sig>

author
#3 lore raw

PATCH v3 2/4 SDP: use CONFIG_SDP_LOADADDR as default load address

In reply to Sherry Sun

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

---
 drivers/usb/gadget/Kconfig | 4 ++++
 drivers/usb/gadget/f_sdp.c | 6 ++++--
 2 files changed, 8 insertions(+), 2 deletions(-)
drivers/usb/gadget/Kconfig +4 -0
index 26b4d12a09..172a82195b 100644
@@ -115,6 +115,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
drivers/usb/gadget/f_sdp.c +4 -2
index bcd1c5d47c..841814bc07 100644
@@ -276,7 +276,8 @@ 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 +305,8 @@ 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;
Signature · 1 line
2.17.1
author
#4 lore raw

PATCH v3 3/4 SDP: fix wrong usb request size and add high speed endpoint descriptor

In reply to Sherry Sun

Because the buffer length of sdp usb request is 65, we have to allocate 65 bytes not 64 bytes. Otherwise there is potential buffer overflow.

So the wMaxPacketSize of fullspeed can't meet the needs. Add HS endpoint descriptor for SDP. Then we can use high speed endpoint, and the SDP device can send packet with 512 byte size.

---
 drivers/usb/gadget/f_sdp.c | 33 ++++++++++++++++++++++++++++++---
 1 file changed, 30 insertions(+), 3 deletions(-)
drivers/usb/gadget/f_sdp.c +30 -3
index 841814bc07..8aaed92e9b 100644
@@ -158,6 +158,16 @@ static struct usb_endpoint_descriptor in_desc = {
 	.bInterval =		1,
 };
 
+static struct usb_endpoint_descriptor in_hs_desc = {
+	.bLength =		USB_DT_ENDPOINT_SIZE,
+	.bDescriptorType =	USB_DT_ENDPOINT, /*USB_DT_CS_ENDPOINT*/
+
+	.bEndpointAddress =	1 | USB_DIR_IN,
+	.bmAttributes =	USB_ENDPOINT_XFER_INT,
+	.wMaxPacketSize =	512,
+	.bInterval =		1,
+};
+
 static struct usb_descriptor_header *sdp_runtime_descs[] = {
 	(struct usb_descriptor_header *)&sdp_intf_runtime,
 	(struct usb_descriptor_header *)&sdp_hid_desc,
@@ -165,6 +175,13 @@ static struct usb_descriptor_header *sdp_runtime_descs[] = {
 	NULL,
 };
 
+static struct usb_descriptor_header *sdp_runtime_hs_descs[] = {
+	(struct usb_descriptor_header *)&sdp_intf_runtime,
+	(struct usb_descriptor_header *)&sdp_hid_desc,
+	(struct usb_descriptor_header *)&in_hs_desc,
+	NULL,
+};
+
 /* This is synchronized with what the SoC implementation reports */
 static struct hid_report sdp_hid_report = {
 	.usage_page = {
@@ -490,6 +507,11 @@ static int sdp_bind(struct usb_configuration *c, struct usb_function *f)
 		goto error;
 	}
 
+	if (gadget_is_dualspeed(gadget)) {
+		/* Assume endpoint addresses are the same for both speeds */
+		in_hs_desc.bEndpointAddress = in_desc.bEndpointAddress;
+	}
+
 	sdp->in_ep = ep; /* Store IN EP for enabling @ setup */
 
 	cdev->req->context = sdp;
@@ -527,7 +549,7 @@ static struct usb_request *sdp_start_ep(struct usb_ep *ep)
 {
 	struct usb_request *req;
 
-	req = alloc_ep_req(ep, 64);
+	req = alloc_ep_req(ep, 65);
 	debug("%s: ep:%p req:%p\n", __func__, ep, req);
 
 	if (!req)
@@ -542,11 +564,15 @@ static int sdp_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
 {
 	struct f_sdp *sdp = func_to_sdp(f);
 	struct usb_composite_dev *cdev = f->config->cdev;
+	struct usb_gadget *gadget = cdev->gadget;
 	int result;
 
 	debug("%s: intf: %d alt: %d\n", __func__, intf, alt);
 
-	result = usb_ep_enable(sdp->in_ep, &in_desc);
+	if (gadget_is_dualspeed(gadget) && gadget->speed == USB_SPEED_HIGH)
+		result = usb_ep_enable(sdp->in_ep, &in_hs_desc);
+	else
+		result = usb_ep_enable(sdp->in_ep, &in_desc);
 	if (result)
 		return result;
 	sdp->in_req = sdp_start_ep(sdp->in_ep);
@@ -592,7 +618,7 @@ static int sdp_bind_config(struct usb_configuration *c)
 	memset(sdp_func, 0, sizeof(*sdp_func));
 
 	sdp_func->usb_function.name = "sdp";
-	sdp_func->usb_function.hs_descriptors = sdp_runtime_descs;
+	sdp_func->usb_function.hs_descriptors = sdp_runtime_hs_descs;
 	sdp_func->usb_function.descriptors = sdp_runtime_descs;
 	sdp_func->usb_function.bind = sdp_bind;
 	sdp_func->usb_function.unbind = sdp_unbind;
@@ -725,6 +751,7 @@ static void sdp_handle_in_ep(struct spl_image_info *spl_image)
 			/* In SPL, allow jumps to U-Boot images */
 			struct spl_image_info spl_image = {};
 			spl_parse_image_header(&spl_image, header);
+
 			jump_to_image_no_args(&spl_image);
 #else
 			/* In U-Boot, allow jumps to scripts */
Signature · 1 line
2.17.1
#5 lore raw

PATCH v3 3/4 SDP: fix wrong usb request size and add high speed endpoint descriptor

Quoted 64 lines · On Thu, 22 Aug 2019 01:46:20 +0000 Sherry Sun <[email protected]> wrote:

Because the buffer length of sdp usb request is 65, we have to allocate 65 bytes not 64 bytes. Otherwise there is potential buffer overflow.

So the wMaxPacketSize of fullspeed can't meet the needs. Add HS endpoint descriptor for SDP. Then we can use high speed endpoint, and the SDP device can send packet with 512 byte size.

---
 drivers/usb/gadget/f_sdp.c | 33 ++++++++++++++++++++++++++++++---
 1 file changed, 30 insertions(+), 3 deletions(-)
drivers/usb/gadget/f_sdp.c +18 -0
index 841814bc07..8aaed92e9b 100644
@@ -158,6 +158,16 @@ static struct usb_endpoint_descriptor in_desc = {
 	.bInterval =		1,
 };
 
+static struct usb_endpoint_descriptor in_hs_desc = {
+	.bLength =		USB_DT_ENDPOINT_SIZE,
+	.bDescriptorType =	USB_DT_ENDPOINT,
 /*USB_DT_CS_ENDPOINT*/ +
+	.bEndpointAddress =	1 | USB_DIR_IN,
+	.bmAttributes =	USB_ENDPOINT_XFER_INT,
+	.wMaxPacketSize =	512,
+	.bInterval =		1,
+};
+
 static struct usb_descriptor_header *sdp_runtime_descs[] = {
 	(struct usb_descriptor_header *)&sdp_intf_runtime,
 	(struct usb_descriptor_header *)&sdp_hid_desc,
@@ -165,6 +175,13 @@ static struct usb_descriptor_header
 *sdp_runtime_descs[] = { NULL,
 };
 
+static struct usb_descriptor_header *sdp_runtime_hs_descs[] = {
+	(struct usb_descriptor_header *)&sdp_intf_runtime,
+	(struct usb_descriptor_header *)&sdp_hid_desc,
+	(struct usb_descriptor_header *)&in_hs_desc,
+	NULL,
+};
+
 /* This is synchronized with what the SoC implementation reports */
 static struct hid_report sdp_hid_report = {
 	.usage_page = {
@@ -490,6 +507,11 @@ static int sdp_bind(struct usb_configuration *c,
 struct usb_function *f) goto error;
 	}
 
+	if (gadget_is_dualspeed(gadget)) {
+		/* Assume endpoint addresses are the same for both

speeds */

drivers/usb/gadget/f_sdp.c +1 -0
+		in_hs_desc.bEndpointAddress =

in_desc.bEndpointAddress;

drivers/usb/gadget/f_sdp.c +2 -0
+	}
+
 	sdp->in_ep = ep; /* Store IN EP for enabling @ setup */
 
 	cdev->req->context = sdp;

drivers/usb/gadget/f_sdp.c static struct usb_request *sdp_start_ep(struct · line 552

Quoted 5 lines
drivers/usb/gadget/f_sdp.c +1 -1
@@ -527,7 +549,7 @@ static struct usb_request *sdp_start_ep(struct
 usb_ep *ep) {
 	struct usb_request *req;
 
-	req = alloc_ep_req(ep, 64);
+	req = alloc_ep_req(ep, 65);

Maybe it would be good to have the #define for this magic number (65)?

If normally we have 64, then it is pretty clear. With 65 we may need #define with some extra comment in the code.

Quoted 32 lines
drivers/usb/gadget/f_sdp.c +5 -1
 	debug("%s: ep:%p req:%p\n", __func__, ep, req);
 
 	if (!req)
@@ -542,11 +564,15 @@ static int sdp_set_alt(struct usb_function *f,
 unsigned intf, unsigned alt) {
 	struct f_sdp *sdp = func_to_sdp(f);
 	struct usb_composite_dev *cdev = f->config->cdev;
+	struct usb_gadget *gadget = cdev->gadget;
 	int result;
 
 	debug("%s: intf: %d alt: %d\n", __func__, intf, alt);
 
-	result = usb_ep_enable(sdp->in_ep, &in_desc);
+	if (gadget_is_dualspeed(gadget) && gadget->speed ==
 USB_SPEED_HIGH)
+		result = usb_ep_enable(sdp->in_ep, &in_hs_desc);
+	else
+		result = usb_ep_enable(sdp->in_ep, &in_desc);
 	if (result)
 		return result;
drivers/usb/gadget/f_sdp.c +1 -1
 	sdp->in_req = sdp_start_ep(sdp->in_ep);
@@ -592,7 +618,7 @@ static int sdp_bind_config(struct
 usb_configuration *c) memset(sdp_func, 0, sizeof(*sdp_func));
 
 	sdp_func->usb_function.name = "sdp";
-	sdp_func->usb_function.hs_descriptors = sdp_runtime_descs;
+	sdp_func->usb_function.hs_descriptors = sdp_runtime_hs_descs;
 	sdp_func->usb_function.descriptors = sdp_runtime_descs;
 	sdp_func->usb_function.bind = sdp_bind;
 	sdp_func->usb_function.unbind = sdp_unbind;
@@ -725,6 +751,7 @@ static void sdp_handle_in_ep(struct

spl_image_info *spl_image) /* In SPL, allow jumps to U-Boot images */

drivers/usb/gadget/f_sdp.c static void sdp_handle_in_ep(struct spl_image_info *spl_image) · line 754

Quoted 3 lines
drivers/usb/gadget/f_sdp.c +1 -0
 			struct spl_image_info spl_image = {};
 			spl_parse_image_header(&spl_image, header);
+

Minor:

Please remove this white space.

drivers/usb/gadget/f_sdp.c static void sdp_handle_in_ep(struct spl_image_info *spl_image) · line 757

Quoted 3 lines
drivers/usb/gadget/f_sdp.c +0 -0
 			jump_to_image_no_args(&spl_image);
 #else
 			/* In U-Boot, allow jumps to scripts */

Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma at denx.de -------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190826/e3787b22/attachment.sig>

author
#6 lore raw

PATCH v3 3/4 SDP: fix wrong usb request size and add high speed endpoint descriptor

Hi Lukasz,

Quoted 70 lines
Quoted 25 lines · On Thu, 22 Aug 2019 01:46:20 +0000 Sherry Sun <[email protected]> wrote:

Because the buffer length of sdp usb request is 65, we have to allocate 65 bytes not 64 bytes. Otherwise there is potential buffer overflow.

So the wMaxPacketSize of fullspeed can't meet the needs. Add HS endpoint descriptor for SDP. Then we can use high speed endpoint, and the SDP device can send packet with 512 byte size.

---
 drivers/usb/gadget/f_sdp.c | 33 ++++++++++++++++++++++++++++++---
 1 file changed, 30 insertions(+), 3 deletions(-)
drivers/usb/gadget/f_sdp.c +3 -0
index 841814bc07..8aaed92e9b 100644
@@ -158,6 +158,16 @@ static struct usb_endpoint_descriptor in_desc = {
 	.bInterval =		1,
 };
 
+static struct usb_endpoint_descriptor in_hs_desc = {
+	.bLength =		USB_DT_ENDPOINT_SIZE,
+	.bDescriptorType =	USB_DT_ENDPOINT,

drivers/usb/gadget/f_sdp.c static struct usb_endpoint_descriptor in_desc = {

Quoted 10 lines
drivers/usb/gadget/f_sdp.c +6 -0
 /*USB_DT_CS_ENDPOINT*/ +
+	.bEndpointAddress =	1 | USB_DIR_IN,
+	.bmAttributes =	USB_ENDPOINT_XFER_INT,
+	.wMaxPacketSize =	512,
+	.bInterval =		1,
+};
+
 static struct usb_descriptor_header *sdp_runtime_descs[] = {
 	(struct usb_descriptor_header *)&sdp_intf_runtime,
 	(struct usb_descriptor_header *)&sdp_hid_desc, @@ -165,6 +175,13

@@

Quoted 30 lines

static struct usb_descriptor_header *sdp_runtime_descs[] = { NULL, };

drivers/usb/gadget/f_sdp.c +7 -0
+static struct usb_descriptor_header *sdp_runtime_hs_descs[] = {
+	(struct usb_descriptor_header *)&sdp_intf_runtime,
+	(struct usb_descriptor_header *)&sdp_hid_desc,
+	(struct usb_descriptor_header *)&in_hs_desc,
+	NULL,
+};
+
 /* This is synchronized with what the SoC implementation reports */

static struct hid_report sdp_hid_report = {

drivers/usb/gadget/f_sdp.c +2 -0
 	.usage_page = {
@@ -490,6 +507,11 @@ static int sdp_bind(struct usb_configuration *c,
 struct usb_function *f) goto error;
 	}
 
+	if (gadget_is_dualspeed(gadget)) {
+		/* Assume endpoint addresses are the same for both

speeds */

drivers/usb/gadget/f_sdp.c +1 -0
+		in_hs_desc.bEndpointAddress =

in_desc.bEndpointAddress;

drivers/usb/gadget/f_sdp.c +2 -0
+	}
+
 	sdp->in_ep = ep; /* Store IN EP for enabling @ setup */
 
 	cdev->req->context = sdp;
@@ -527,7 +549,7 @@ static struct usb_request *sdp_start_ep(struct
 usb_ep *ep) {
 	struct usb_request *req;
 
Quoted 7 lines

drivers/usb/gadget/f_sdp.c static struct usb_request *sdp_start_ep(struct usb_ep *ep) · line 552

Quoted 2 lines
drivers/usb/gadget/f_sdp.c +1 -1
-	req = alloc_ep_req(ep, 64);
+	req = alloc_ep_req(ep, 65);

Maybe it would be good to have the #define for this magic number (65)?

If normally we have 64, then it is pretty clear. With 65 we may need #define with some extra comment in the code.

Okay, I will add this.

Quoted 39 lines
Quoted 21 lines
drivers/usb/gadget/f_sdp.c +5 -1
 	debug("%s: ep:%p req:%p\n", __func__, ep, req);
 
 	if (!req)
@@ -542,11 +564,15 @@ static int sdp_set_alt(struct usb_function *f,
 unsigned intf, unsigned alt) {
 	struct f_sdp *sdp = func_to_sdp(f);
 	struct usb_composite_dev *cdev = f->config->cdev;
+	struct usb_gadget *gadget = cdev->gadget;
 	int result;
 
 	debug("%s: intf: %d alt: %d\n", __func__, intf, alt);
 
-	result = usb_ep_enable(sdp->in_ep, &in_desc);
+	if (gadget_is_dualspeed(gadget) && gadget->speed ==
 USB_SPEED_HIGH)
+		result = usb_ep_enable(sdp->in_ep, &in_hs_desc);
+	else
+		result = usb_ep_enable(sdp->in_ep, &in_desc);
 	if (result)
 		return result;
Quoted 1 line

sdp->in_req = sdp_start_ep(sdp->in_ep); @@ -592,7 +618,7 @@

static

drivers/usb/gadget/f_sdp.c static int sdp_bind_config(struct usb_configuration *c)

Quoted 9 lines

int sdp_bind_config(struct usb_configuration *c) memset(sdp_func, 0, sizeof(*sdp_func));

drivers/usb/gadget/f_sdp.c +1 -1
 	sdp_func->usb_function.name = "sdp";
-	sdp_func->usb_function.hs_descriptors = sdp_runtime_descs;
+	sdp_func->usb_function.hs_descriptors = sdp_runtime_hs_descs;
 	sdp_func->usb_function.descriptors = sdp_runtime_descs;
 	sdp_func->usb_function.bind = sdp_bind;
 	sdp_func->usb_function.unbind = sdp_unbind; @@ -725,6 +751,7

@@

drivers/usb/gadget/f_sdp.c static void sdp_handle_in_ep(struct spl_image_info *spl_image) · line 754

Quoted 5 lines

static void sdp_handle_in_ep(struct spl_image_info *spl_image) /* In SPL, allow jumps to U-Boot images */

drivers/usb/gadget/f_sdp.c +1 -0
 			struct spl_image_info spl_image = {};
 			spl_parse_image_header(&spl_image, header);
+
Quoted 3 lines

Minor:

Please remove this white space.

Thanks for your reminder, I will do it.

Best regards
Sherry sun

Quoted 17 lines

drivers/usb/gadget/f_sdp.c static void sdp_handle_in_ep(struct spl_image_info *spl_image) · line 757

Quoted 4 lines
drivers/usb/gadget/f_sdp.c +0 -0
 			jump_to_image_no_args(&spl_image);
 #else
 			/* In U-Boot, allow jumps to scripts */

Best regards,

Lukasz Majewski

--

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

author
#7 lore raw

PATCH v3 4/4 SDP: Call usb_gadget_initialize and usb_gadget_release to support UDC

In reply to Sherry Sun

Need initialize UDC before run sdp download and release it at the end of sdp.

---
 common/spl/spl_sdp.c | 4 ++++
 1 file changed, 4 insertions(+)
common/spl/spl_sdp.c +4 -0
index 806bf1327e..7b0a213d4c 100644
@@ -16,6 +16,8 @@ static int spl_sdp_load_image(struct spl_image_info *spl_image,
 	int ret;
 	const int controller_index = 0;
 
+	usb_gadget_initialize(controller_index);
+
 	g_dnl_clear_detach();
 	ret = g_dnl_register("usb_dnl_sdp");
 	if (ret) {
@@ -37,6 +39,8 @@ static int spl_sdp_load_image(struct spl_image_info *spl_image,
 	ret = spl_sdp_handle(controller_index, spl_image);
 	debug("SDP ended\n");
 
+	usb_gadget_release(controller_index);
+
 	return ret;
 }
 SPL_LOAD_IMAGE_METHOD("USB SDP", 0, BOOT_DEVICE_BOARD, spl_sdp_load_image);
Signature · 1 line
2.17.1