summaryrefslogtreecommitdiff
path: root/port/musb/usb_glue_es.c
blob: 2d4e50969c93ef13f0fa9d1d31a2ceac9a1a4d1a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
 * Copyright (c) 2024, sakumisu
 *
 * SPDX-License-Identifier: Apache-2.0
 */
#include "usb_config.h"
#include "stdint.h"
#include "usb_musb_reg.h"

#if CONFIG_USB_MUSB_EP_NUM != 6
#error es32 chips only support 6 endpoints
#endif

#if CONFIG_USB_MUSB_PIPE_NUM != 6
#error es32 chips only support 6 pipes
#endif

// clang-format off
static struct musb_fifo_cfg musb_device_table[] = {
{ .ep_num =  0, .style = FIFO_TXRX,   .maxpacket = 64, },
{ .ep_num =  1, .style = FIFO_TXRX,   .maxpacket = 1024, },
{ .ep_num =  2, .style = FIFO_TXRX,   .maxpacket = 512, },
{ .ep_num =  3, .style = FIFO_TXRX,   .maxpacket = 512, },
{ .ep_num =  4, .style = FIFO_TXRX,   .maxpacket = 512, },
{ .ep_num =  5, .style = FIFO_TXRX,   .maxpacket = 512, },
};

static struct musb_fifo_cfg musb_host_table[] = {
{ .ep_num =  0, .style = FIFO_TXRX,   .maxpacket = 64, },
{ .ep_num =  1, .style = FIFO_TXRX,   .maxpacket = 1024, },
{ .ep_num =  2, .style = FIFO_TXRX,   .maxpacket = 512, },
{ .ep_num =  3, .style = FIFO_TXRX,   .maxpacket = 512, },
{ .ep_num =  4, .style = FIFO_TXRX,   .maxpacket = 512, },
{ .ep_num =  5, .style = FIFO_TXRX,   .maxpacket = 512, },
};
// clang-format on

uint8_t usbd_get_musb_fifo_cfg(struct musb_fifo_cfg **cfg)
{
    *cfg = musb_device_table;
    return sizeof(musb_device_table) / sizeof(musb_device_table[0]);
}

uint8_t usbh_get_musb_fifo_cfg(struct musb_fifo_cfg **cfg)
{
    *cfg = musb_host_table;
    return sizeof(musb_host_table) / sizeof(musb_host_table[0]);
}

uint32_t usb_get_musb_ram_size(void)
{
    return 4096;
}

void usbd_musb_delay_ms(uint8_t ms)
{
    /* implement later */
}