[U-Boot,2/4] SDP: use CONFIG_SDP_LOADADDR as default load address
diff mbox series

Message ID 1563414056-20331-3-git-send-email-sherry.sun@nxp.com
State Superseded
Delegated to: Stefano Babic
Headers show
Series
  • Make some changes to SDP
Related show

Commit Message

Sherry Sun July 18, 2019, 1:40 a.m. UTC
From: Sherry Sun <sherry.sun@nxp.com>

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

Signed-off-by: Sherry Sun <sherry.sun@nxp.com>
Signed-off-by: Frank Li <Frank.Li@nxp.com>
---
 drivers/usb/gadget/Kconfig | 4 ++++
 drivers/usb/gadget/f_sdp.c | 6 ++++--
 2 files changed, 8 insertions(+), 2 deletions(-)

Comments

Lukasz Majewski July 18, 2019, 7:29 a.m. UTC | #1
On Thu, 18 Jul 2019 09:40:54 +0800
sherry sun <sherry.sun@nxp.com> wrote:

> From: Sherry Sun <sherry.sun@nxp.com>
> 
> If SDP_WRITE and SDP_JUMP command addr is zero, use
> CONFIG_SDP_LOADADDR as default address.
> 
> Signed-off-by: Sherry Sun <sherry.sun@nxp.com>
> Signed-off-by: Frank Li <Frank.Li@nxp.com>
> ---
>  drivers/usb/gadget/Kconfig | 4 ++++
>  drivers/usb/gadget/f_sdp.c | 6 ++++--
>  2 files changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
> index 26b4d12a09..172a82195b 100644
> --- a/drivers/usb/gadget/Kconfig
> +++ b/drivers/usb/gadget/Kconfig
> @@ -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
> diff --git a/drivers/usb/gadget/f_sdp.c b/drivers/usb/gadget/f_sdp.c
> index fab7ce6f97..b1601575e0 100644
> --- a/drivers/usb/gadget/f_sdp.c
> +++ b/drivers/usb/gadget/f_sdp.c
> @@ -275,7 +275,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;
> @@ -303,7 +304,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;

Reviewed-by: Lukasz Majewski <lukma@denx.de>


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@denx.de

Patch
diff mbox series

diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 26b4d12a09..172a82195b 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -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
diff --git a/drivers/usb/gadget/f_sdp.c b/drivers/usb/gadget/f_sdp.c
index fab7ce6f97..b1601575e0 100644
--- a/drivers/usb/gadget/f_sdp.c
+++ b/drivers/usb/gadget/f_sdp.c
@@ -275,7 +275,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;
@@ -303,7 +304,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;