diff options
author | Solomon Peachy <pizza@shaftnet.org> | 2021-11-22 08:08:12 -0500 |
---|---|---|
committer | Solomon Peachy <pizza@shaftnet.org> | 2021-11-22 08:08:12 -0500 |
commit | 3d07ec46eed738e6dac6109598766f6568ac4669 (patch) | |
tree | 39c87d691c32110396de65c28dd8ecd0408a8c86 | |
parent | 5bd9ed801f4ef684e148222710e042c113e48e58 (diff) | |
download | rockbox-3d07ec46ee.tar.gz rockbox-3d07ec46ee.zip |
jz47x0: Minor code quality improvements in the jz47xx USB drivers
* Replace magic nubmers with #defined constant
* Tweak some logf messages
No functional changes!
Change-Id: I6a5e4c371a471197a8edbb853967e461621d73f8
-rw-r--r-- | firmware/export/jz4760b.h | 5 | ||||
-rw-r--r-- | firmware/target/mips/ingenic_jz47xx/usb-jz4740.c | 4 | ||||
-rw-r--r-- | firmware/target/mips/ingenic_jz47xx/usb-jz4760.c | 21 |
3 files changed, 19 insertions, 11 deletions
diff --git a/firmware/export/jz4760b.h b/firmware/export/jz4760b.h index 589f67800a..af1f36270b 100644 --- a/firmware/export/jz4760b.h +++ b/firmware/export/jz4760b.h @@ -7017,6 +7017,11 @@ do { \ #define USB_INTR_SUSPEND 0x01 #define USB_INTR_RESUME 0x02 #define USB_INTR_RESET 0x04 +#define USB_INTR_SOF 0x08 +#define USB_INTR_CONNECT 0x10 +#define USB_INTR_DISCONNECT 0x20 +#define USB_INTR_SESS_REQ 0x40 +#define USB_INTR_VBUS_ERR 0x80 #define USB_INTR_EP(n) (1 << (n)) diff --git a/firmware/target/mips/ingenic_jz47xx/usb-jz4740.c b/firmware/target/mips/ingenic_jz47xx/usb-jz4740.c index 07d24be380..07697da723 100644 --- a/firmware/target/mips/ingenic_jz47xx/usb-jz4740.c +++ b/firmware/target/mips/ingenic_jz47xx/usb-jz4740.c @@ -75,7 +75,7 @@ static unsigned char ep0_rx_buf[64]; static struct usb_endpoint endpoints[] = { { .type = ep_control, .fifo_addr = USB_FIFO_EP0, .fifo_size = 64 }, - { .type = ep_control, .fifo_addr = USB_FIFO_EP0, .buf = &ep0_rx_buf }, + { .type = ep_control, .fifo_addr = USB_FIFO_EP0, .buf = ep0_rx_buf }, { .type = ep_bulk, .fifo_addr = USB_FIFO_EP1, .fifo_size = 512 }, { .type = ep_bulk, .fifo_addr = USB_FIFO_EP1, .fifo_size = 512 }, { .type = ep_interrupt, .fifo_addr = USB_FIFO_EP2, .fifo_size = 64 }, @@ -193,7 +193,7 @@ static void EP0_send(void) if(ep->sent >= ep->length) { REG_USB_REG_CSR0 = (csr0 | USB_CSR0_INPKTRDY | USB_CSR0_DATAEND); /* Set data end! */ - usb_core_transfer_complete(0, USB_DIR_IN, 0, ep->sent); + usb_core_transfer_complete(EP_CONTROL, USB_DIR_IN, 0, ep->sent); ep_transfer_completed(ep); } else diff --git a/firmware/target/mips/ingenic_jz47xx/usb-jz4760.c b/firmware/target/mips/ingenic_jz47xx/usb-jz4760.c index 6db4a25d5c..474d45edee 100644 --- a/firmware/target/mips/ingenic_jz47xx/usb-jz4760.c +++ b/firmware/target/mips/ingenic_jz47xx/usb-jz4760.c @@ -106,7 +106,7 @@ static volatile bool ep0_data_requested = false; static struct usb_endpoint endpoints[] = { EP_INIT(ep_control, USB_FIFO_EP(0), 64, NULL), - EP_INIT(ep_control, USB_FIFO_EP(0), 64, &ep0_rx.buf), + EP_INIT(ep_control, USB_FIFO_EP(0), 64, ep0_rx.buf), EP_INIT(ep_bulk, USB_FIFO_EP(1), 512, NULL), EP_INIT(ep_bulk, USB_FIFO_EP(1), 512, NULL), EP_INIT(ep_interrupt, USB_FIFO_EP(2), 512, NULL), @@ -230,6 +230,8 @@ static void EP0_send(void) select_endpoint(0); csr0 = REG_USB_CSR0; + logf("%s(): 0x%x %d %d", __func__, csr0, ep->sent, ep->length); + if(ep->sent == 0) { length = MIN(ep->length, ep->fifo_size); @@ -245,7 +247,7 @@ static void EP0_send(void) { REG_USB_CSR0 = (csr0 | USB_CSR0_INPKTRDY | USB_CSR0_DATAEND); /* Set data end! */ if (!ep->wait) - usb_core_transfer_complete(0, USB_DIR_IN, 0, ep->sent); + usb_core_transfer_complete(EP_CONTROL, USB_DIR_IN, 0, ep->sent); ep->rc = 0; ep_transfer_completed(ep); } @@ -263,7 +265,7 @@ static void EP0_handler(void) select_endpoint(0); csr0 = REG_USB_CSR0; - logf("%s(): 0x%x", __func__, csr0); + logf("%s(): 0x%x %d", __func__, csr0, ep_send->busy); /* Check for SentStall: This bit is set when a STALL handshake is transmitted. The CPU should clear this bit. @@ -288,12 +290,12 @@ static void EP0_handler(void) if (ep_send->busy) { if (!ep_send->wait) - usb_core_transfer_complete(0, USB_DIR_IN, -1, 0); + usb_core_transfer_complete(EP_CONTROL, USB_DIR_IN, -1, 0); ep_transfer_completed(ep_send); } if (ep_recv->busy) { - usb_core_transfer_complete(0, USB_DIR_OUT, -1, 0); + usb_core_transfer_complete(EP_CONTROL, USB_DIR_OUT, -1, 0); ep_transfer_completed(ep_recv); } } @@ -304,7 +306,7 @@ static void EP0_handler(void) if (ep_send->busy) { if (!ep_send->wait) - usb_core_transfer_complete(0, USB_DIR_IN, -1, 0); + usb_core_transfer_complete(EP_CONTROL, USB_DIR_IN, -1, 0); ep_transfer_completed(ep_send); } if (ep_recv->busy && ep_recv->buf && ep_recv->length) @@ -315,7 +317,7 @@ static void EP0_handler(void) if (size < ep_recv->fifo_size || ep_recv->received >= ep_recv->length) { REG_USB_CSR0 = csr0 | USB_CSR0_SVDOUTPKTRDY | USB_CSR0_DATAEND; /* Set data end! */ - usb_core_transfer_complete(0, USB_DIR_OUT, 0, ep_recv->received); + usb_core_transfer_complete(EP_CONTROL, USB_DIR_OUT, 0, ep_recv->received); ep_transfer_completed(ep_recv); } else REG_USB_CSR0 = csr0 | USB_CSR0_SVDOUTPKTRDY; /* clear OUTPKTRDY bit */ @@ -815,7 +817,8 @@ static void udc_reset(void) { if (endpoints[0].wait) semaphore_release(&endpoints[0].complete); - else usb_core_transfer_complete(0, USB_DIR_IN, -1, 0); + else + usb_core_transfer_complete(EP_CONTROL, USB_DIR_IN, -1, 0); } endpoints[0].busy = false; @@ -825,7 +828,7 @@ static void udc_reset(void) endpoints[0].allocated = true; if (endpoints[1].busy) - usb_core_transfer_complete(0, USB_DIR_OUT, -1, 0); + usb_core_transfer_complete(EP_CONTROL, USB_DIR_OUT, -1, 0); endpoints[1].busy = false; endpoints[1].wait = false; |