From: Christian Lamparter Date: Fri, 22 Mar 2013 21:21:34 +0000 (+0100) Subject: carl9170 firmware: always reset usb endpoints X-Git-Tag: 1.9.8~5 X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=1c85595695219f59d3c41bfd26b0a6a5dbad839c;p=carl9170fw.git carl9170 firmware: always reset usb endpoints It isn't clear what the firmware is supposed to do when it is initializing the usb phy. The spec says something about clearing the STALLED/HALTED flags however the original firmware doesn't do that?! Signed-off-by: Christian Lamparter --- diff --git a/carlfw/include/usb.h b/carlfw/include/usb.h index fb258bf..1066fe0 100644 --- a/carlfw/include/usb.h +++ b/carlfw/include/usb.h @@ -184,6 +184,7 @@ void __noreturn jump_to_bootcode(void); void send_cmd_to_host(const uint8_t len, const uint8_t type, const uint8_t ext, const uint8_t *body); +void usb_reset_eps(void); void usb_init(void); void usb_ep0rx(void); void usb_ep0tx(void); diff --git a/carlfw/usb/main.c b/carlfw/usb/main.c index 890970c..1fb119e 100644 --- a/carlfw/usb/main.c +++ b/carlfw/usb/main.c @@ -377,6 +377,7 @@ static void usb_handler(uint8_t usb_interrupt_level1) if (usb_interrupt_level2 & AR9170_USB_INTR_SRC7_USB_RESET) { usb_reset_ack(); + usb_reset_eps(); reboot(); } diff --git a/carlfw/usb/usb.c b/carlfw/usb/usb.c index 0c66b82..d7bc432 100644 --- a/carlfw/usb/usb.c +++ b/carlfw/usb/usb.c @@ -166,8 +166,7 @@ static struct ar9170_usb_config usb_config_fullspeed = { }, }; -#ifdef CONFIG_CARL9170FW_USB_MODESWITCH -static void usb_reset_eps(void) +void usb_reset_eps(void) { unsigned int i; @@ -188,8 +187,6 @@ static void usb_reset_eps(void) usb_clear_output_ep_stall(i); } } -#endif /* CONFIG_CARL9170FW_USB_MODESWITCH */ - static void usb_pta_init(void) { @@ -503,7 +500,7 @@ static int usb_get_configuration(const struct usb_ctrlrequest *ctrl) if (USB_CHECK_REQTYPE(ctrl, USB_RECIP_DEVICE, USB_DIR_IN)) return -1; - return usb_ep0tx_data(&fw.usb.config, 1); + return usb_ep0tx_data(&fw.usb.config, fw.usb.config); } static int usb_set_configuration(const struct usb_ctrlrequest *ctrl) @@ -519,10 +516,10 @@ static int usb_set_configuration(const struct usb_ctrlrequest *ctrl) /* Disable Device */ andb(AR9170_USB_REG_DEVICE_ADDRESS, (uint8_t) ~(AR9170_USB_DEVICE_ADDRESS_CONFIGURE)); -#ifdef CONFIG_CARL9170FW_USB_MODESWITCH case 1: fw.usb.config = config; +#ifdef CONFIG_CARL9170FW_USB_MODESWITCH if (usb_detect_highspeed()) { /* High Speed Configuration */ usb_init_highspeed_fifo_cfg(); @@ -530,25 +527,21 @@ static int usb_set_configuration(const struct usb_ctrlrequest *ctrl) /* Full Speed Configuration */ usb_init_fullspeed_fifo_cfg(); } + /* usb_pta_init() ? */ break; +#endif /* CONFIG_CARL9170FW_USB_MODESWITCH */ - default: - return -1; - } - /* usb_pta_init() ? */ + usb_reset_eps(); + orb(AR9170_USB_REG_DEVICE_ADDRESS, + (AR9170_USB_DEVICE_ADDRESS_CONFIGURE)); - usb_reset_eps(); - orb(AR9170_USB_REG_DEVICE_ADDRESS, - (AR9170_USB_DEVICE_ADDRESS_CONFIGURE)); + usb_enable_global_int(); + usb_trigger_out(); + return 1; - usb_enable_global_int(); - usb_trigger_out(); - return 1; -#else default: return -1; } -#endif /* CONFIG_CARL9170FW_USB_MODESWITCH */ } static int usb_set_address(const struct usb_ctrlrequest *ctrl)