Skip to content

Commit 5425191

Browse files
andy-shevgregkh
authored andcommitted
usb: dwc3: gadget: Add support for snps,reserved-endpoints property
The snps,reserved-endpoints property lists the reserved endpoints that shouldn't be used for normal transfers. Add support for that to the driver. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Tested-by: Ferry Toth <fntoth@gmail.com> Acked-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com> Link: https://lore.kernel.org/r/20250212193116.2487289-4-andriy.shevchenko@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent eafba02 commit 5425191

File tree

1 file changed

+40
-1
lines changed

1 file changed

+40
-1
lines changed

drivers/usb/dwc3/gadget.c

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3403,14 +3403,53 @@ static int dwc3_gadget_init_endpoint(struct dwc3 *dwc, u8 epnum)
34033403
return 0;
34043404
}
34053405

3406+
static int dwc3_gadget_get_reserved_endpoints(struct dwc3 *dwc, const char *propname,
3407+
u8 *eps, u8 num)
3408+
{
3409+
u8 count;
3410+
int ret;
3411+
3412+
if (!device_property_present(dwc->dev, propname))
3413+
return 0;
3414+
3415+
ret = device_property_count_u8(dwc->dev, propname);
3416+
if (ret < 0)
3417+
return ret;
3418+
count = ret;
3419+
3420+
ret = device_property_read_u8_array(dwc->dev, propname, eps, min(num, count));
3421+
if (ret)
3422+
return ret;
3423+
3424+
return count;
3425+
}
3426+
34063427
static int dwc3_gadget_init_endpoints(struct dwc3 *dwc, u8 total)
34073428
{
3429+
const char *propname = "snps,reserved-endpoints";
34083430
u8 epnum;
3431+
u8 reserved_eps[DWC3_ENDPOINTS_NUM];
3432+
u8 count;
3433+
u8 num;
3434+
int ret;
34093435

34103436
INIT_LIST_HEAD(&dwc->gadget->ep_list);
34113437

3438+
ret = dwc3_gadget_get_reserved_endpoints(dwc, propname,
3439+
reserved_eps, ARRAY_SIZE(reserved_eps));
3440+
if (ret < 0) {
3441+
dev_err(dwc->dev, "failed to read %s\n", propname);
3442+
return ret;
3443+
}
3444+
count = ret;
3445+
34123446
for (epnum = 0; epnum < total; epnum++) {
3413-
int ret;
3447+
for (num = 0; num < count; num++) {
3448+
if (epnum == reserved_eps[num])
3449+
break;
3450+
}
3451+
if (num < count)
3452+
continue;
34143453

34153454
ret = dwc3_gadget_init_endpoint(dwc, epnum);
34163455
if (ret)

0 commit comments

Comments
 (0)