usb: designware: support max packet size override

Change-Id: I75d3aca1599ce064c604c96f2b5ed4c041f975b8
This commit is contained in:
mojyack 2026-01-03 18:05:22 +09:00
parent d92b42c70f
commit 8873cbb57e
2 changed files with 14 additions and 11 deletions

View file

@ -1589,8 +1589,6 @@ void usb_drv_ep_reset_alloc_ctx(struct usb_drv_ep_alloc_ctx* ctx)
bool usb_drv_ep_allocate(struct usb_drv_ep_alloc_ctx* ctx, int ep, int type, int max_packet_size)
{
(void)max_packet_size; /* FIXME: support max packet size override */
const uint8_t epnum = EP_NUM(ep);
const uint8_t epdir = EP_DIR(ep);
@ -1629,12 +1627,12 @@ bool usb_drv_ep_allocate(struct usb_drv_ep_alloc_ctx* ctx, int ep, int type, int
ok:
ctx->type[epnum][epdir] = type;
ctx->max_packet_size[epnum][epdir] = max_packet_size;
return true;
}
void usb_drv_ep_init(const struct usb_drv_ep_alloc_ctx* ctx, int ep)
{
/* FIXME: support max packet size override */
const int epnum = EP_NUM(ep);
const int epdir_ = EP_DIR(ep);
const int type = ctx->type[epnum][epdir_];
@ -1642,18 +1640,21 @@ void usb_drv_ep_init(const struct usb_drv_ep_alloc_ctx* ctx, int ep)
enum usb_dw_epdir epdir = (epdir_ == DIR_IN) ? USB_DW_EPDIR_IN : USB_DW_EPDIR_OUT;
struct usb_dw_ep* dw_ep = usb_dw_get_ep(EP_NUM(ep), epdir);
int maxpktsize;
int mps = ctx->max_packet_size[epnum][epdir_];
if(mps == -1)
{
if(type == EPTYP_ISOCHRONOUS)
{
maxpktsize = 1023;
mps = 1023;
}
else
{
maxpktsize = usb_drv_port_speed() ? 512 : 64;
mps = usb_drv_port_speed() ? 512 : 64;
}
}
usb_dw_target_disable_irq();
usb_dw_configure_ep(ctx, epnum, epdir, type, maxpktsize);
usb_dw_configure_ep(ctx, epnum, epdir, type, mps);
usb_dw_target_enable_irq();
dw_ep->active = true;

View file

@ -294,6 +294,8 @@ extern void usb_dw_target_clear_irq(void);
struct usb_drv_ep_alloc_ctx_dw
{
int8_t type[USB_NUM_ENDPOINTS][2];
int max_packet_size[USB_NUM_ENDPOINTS][2];
uint16_t txfifo_usage;
uint8_t assigned_txfifos[USB_NUM_ENDPOINTS];
};