1 /*
2  * Copyright (c) 2024, sakumisu
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 #include "usb_config.h"
7 #include "stdint.h"
8 #include "usb_musb_reg.h"
9 
10 #if CONFIG_USB_MUSB_EP_NUM != 6
11 #error es32 chips only support 6 endpoints
12 #endif
13 
14 #if CONFIG_USB_MUSB_PIPE_NUM != 6
15 #error es32 chips only support 6 pipes
16 #endif
17 
18 // clang-format off
19 static struct musb_fifo_cfg musb_device_table[] = {
20 { .ep_num =  0, .style = FIFO_TXRX,   .maxpacket = 64, },
21 { .ep_num =  1, .style = FIFO_TXRX,   .maxpacket = 1024, },
22 { .ep_num =  2, .style = FIFO_TXRX,   .maxpacket = 512, },
23 { .ep_num =  3, .style = FIFO_TXRX,   .maxpacket = 512, },
24 { .ep_num =  4, .style = FIFO_TXRX,   .maxpacket = 512, },
25 { .ep_num =  5, .style = FIFO_TXRX,   .maxpacket = 512, },
26 };
27 
28 static struct musb_fifo_cfg musb_host_table[] = {
29 { .ep_num =  0, .style = FIFO_TXRX,   .maxpacket = 64, },
30 { .ep_num =  1, .style = FIFO_TXRX,   .maxpacket = 1024, },
31 { .ep_num =  2, .style = FIFO_TXRX,   .maxpacket = 512, },
32 { .ep_num =  3, .style = FIFO_TXRX,   .maxpacket = 512, },
33 { .ep_num =  4, .style = FIFO_TXRX,   .maxpacket = 512, },
34 { .ep_num =  5, .style = FIFO_TXRX,   .maxpacket = 512, },
35 };
36 // clang-format on
37 
usbd_get_musb_fifo_cfg(struct musb_fifo_cfg ** cfg)38 uint8_t usbd_get_musb_fifo_cfg(struct musb_fifo_cfg **cfg)
39 {
40     *cfg = musb_device_table;
41     return sizeof(musb_device_table) / sizeof(musb_device_table[0]);
42 }
43 
usbh_get_musb_fifo_cfg(struct musb_fifo_cfg ** cfg)44 uint8_t usbh_get_musb_fifo_cfg(struct musb_fifo_cfg **cfg)
45 {
46     *cfg = musb_host_table;
47     return sizeof(musb_host_table) / sizeof(musb_host_table[0]);
48 }
49 
usb_get_musb_ram_size(void)50 uint32_t usb_get_musb_ram_size(void)
51 {
52     return 4096;
53 }
54 
usbd_musb_delay_ms(uint8_t ms)55 void usbd_musb_delay_ms(uint8_t ms)
56 {
57     /* implement later */
58 }
59