9 #include "usbfifo_api.h"
13 #define USB_EP4_MAX_PKT_SIZE bUSB_EP_MAX_PKT_SIZE_64
14 #define USB_EP3_MAX_PKT_SIZE bUSB_EP_MAX_PKT_SIZE_64
16 extern USB_FIFO_CONFIG usbFifoConf;
18 void cold_reboot(void)
20 A_PRINTF("Cold reboot initiated.");
21 #if defined(PROJECT_MAGPIE)
22 HAL_WORD_REG_WRITE(WATCH_DOG_MAGIC_PATTERN_ADDR, 0);
23 #elif defined(PROJECT_K2)
24 HAL_WORD_REG_WRITE(MAGPIE_REG_RST_STATUS_ADDR, 0);
25 #endif /* #if defined(PROJECT_MAGPIE) */
30 * support more than 64 bytes command on ep4
32 void usb_reg_out_patch(void)
37 static volatile uint32_t *regaddr;
38 static uint16_t cmd_len;
40 BOOLEAN cmd_is_last = FALSE;
41 static BOOLEAN cmd_is_new = TRUE;
43 /* get the size of this transcation */
44 usbfifolen = USB_BYTE_REG_READ(ZM_EP4_BYTE_COUNT_LOW_OFFSET);
46 if (usbfifolen > USB_EP4_MAX_PKT_SIZE) {
47 A_PRINTF("EP4 FIFO Bug? Buffer is too big: %x\n", usbfifolen);
51 /* check is command is new */
54 buf = usbFifoConf.get_command_buf();
58 A_PRINTF("%s: Filed to get new buffer.\n", __func__);
62 /* copy free, assignment buffer of the address */
63 regaddr = (uint32_t *)buf->desc_list->buf_addr;
68 /* just in case, suppose should not happen */
72 /* if size is smaller, this is the last command!
73 * zero-length supposed should be set through 0x27/bit7->0x19/bit4, not here
75 if(usbfifolen < USB_EP4_MAX_PKT_SIZE)
78 /* accumulate the size */
79 cmd_len += usbfifolen;
81 if (cmd_len > buf->desc_list->buf_size) {
82 A_PRINTF("%s: Data length on EP4 FIFO is bigger as "
83 "allocated buffer data! Drop it!\n", __func__);
87 /* round it to alignment */
89 usbfifolen = (usbfifolen >> 2) + 1;
91 usbfifolen = usbfifolen >> 2;
93 /* retrieve the data from fifo */
94 for(ii = 0; ii < usbfifolen; ii++) {
95 /* read fifo data out */
96 ep4_data = USB_WORD_REG_READ(ZM_EP4_DATA_OFFSET);
101 /* if this is the last command, callback to HTC */
103 buf->desc_list->next_desc = NULL;
104 buf->desc_list->data_offset = 0;
105 buf->desc_list->data_size = cmd_len;
106 buf->desc_list->control = 0;
107 buf->next_buf = NULL;
108 buf->buf_length = cmd_len;
110 usbFifoConf.recv_command(buf);
117 /* we might get no command buffer here?
118 * but if we return here, the ep4 fifo will be lock out,
119 * so that we still read them out but just drop it? */
120 for(ii = 0; ii < usbfifolen; ii++)
121 ep4_data = USB_WORD_REG_READ(ZM_EP4_DATA_OFFSET);
124 /* mUSB_STATUS_IN_INT_ENABLE(); */