Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

usb: gadget: udc: atmel: update endpoint allocation for sam9x60

The DPRAM memory from the USB High Speed Device Port (UDPHS) hardware
block was increased. This patch updates the endpoint allocation for sam9x60
to take advantage of this larger memory. At the same time the
constraint to allocate the endpoints in order was lifted. To handle old
and new hardware in the same driver the ep_prealloc was added.

Signed-off-by: Cristian Birsan <cristian.birsan@microchip.com>
Signed-off-by: Felipe Balbi <balbi@kernel.org>

authored by

Cristian Birsan and committed by
Felipe Balbi
26b32424 5b041a30

+19 -3
+17 -3
drivers/usb/gadget/udc/atmel_usba_udc.c
··· 1061 1061 1062 1062 case USB_ENDPOINT_XFER_ISOC: 1063 1063 ep->fifo_size = 1024; 1064 - ep->nr_banks = 2; 1064 + if (ep->udc->ep_prealloc) 1065 + ep->nr_banks = 2; 1065 1066 break; 1066 1067 1067 1068 case USB_ENDPOINT_XFER_BULK: 1068 1069 ep->fifo_size = 512; 1069 - ep->nr_banks = 1; 1070 + if (ep->udc->ep_prealloc) 1071 + ep->nr_banks = 1; 1070 1072 break; 1071 1073 1072 1074 case USB_ENDPOINT_XFER_INT: ··· 1078 1076 else 1079 1077 ep->fifo_size = 1080 1078 roundup_pow_of_two(le16_to_cpu(desc->wMaxPacketSize)); 1081 - ep->nr_banks = 1; 1079 + if (ep->udc->ep_prealloc) 1080 + ep->nr_banks = 1; 1082 1081 break; 1083 1082 } 1084 1083 ··· 2090 2087 .errata = &at91sam9rl_errata, 2091 2088 .config = ep_config_sam9, 2092 2089 .num_ep = ARRAY_SIZE(ep_config_sam9), 2090 + .ep_prealloc = true, 2093 2091 }; 2094 2092 2095 2093 static const struct usba_udc_config udc_at91sam9g45_cfg = { 2096 2094 .errata = &at91sam9g45_errata, 2097 2095 .config = ep_config_sam9, 2098 2096 .num_ep = ARRAY_SIZE(ep_config_sam9), 2097 + .ep_prealloc = true, 2099 2098 }; 2100 2099 2101 2100 static const struct usba_udc_config udc_sama5d3_cfg = { 2102 2101 .config = ep_config_sama5, 2103 2102 .num_ep = ARRAY_SIZE(ep_config_sama5), 2103 + .ep_prealloc = true, 2104 + }; 2105 + 2106 + static const struct usba_udc_config udc_sam9x60_cfg = { 2107 + .num_ep = ARRAY_SIZE(ep_config_sam9), 2108 + .config = ep_config_sam9, 2109 + .ep_prealloc = false, 2104 2110 }; 2105 2111 2106 2112 static const struct of_device_id atmel_udc_dt_ids[] = { 2107 2113 { .compatible = "atmel,at91sam9rl-udc", .data = &udc_at91sam9rl_cfg }, 2108 2114 { .compatible = "atmel,at91sam9g45-udc", .data = &udc_at91sam9g45_cfg }, 2109 2115 { .compatible = "atmel,sama5d3-udc", .data = &udc_sama5d3_cfg }, 2116 + { .compatible = "microchip,sam9x60-udc", .data = &udc_sam9x60_cfg }, 2110 2117 { /* sentinel */ } 2111 2118 }; 2112 2119 ··· 2144 2131 return ERR_PTR(-EINVAL); 2145 2132 2146 2133 udc_config = match->data; 2134 + udc->ep_prealloc = udc_config->ep_prealloc; 2147 2135 udc->errata = udc_config->errata; 2148 2136 if (udc->errata) { 2149 2137 pp = of_find_matching_node_and_match(NULL, atmel_pmc_dt_ids,
+2
drivers/usb/gadget/udc/atmel_usba_udc.h
··· 317 317 const struct usba_udc_errata *errata; 318 318 const struct usba_ep_config *config; 319 319 const int num_ep; 320 + const bool ep_prealloc; 320 321 }; 321 322 322 323 struct usba_udc { ··· 344 343 bool bias_pulse_needed; 345 344 bool clocked; 346 345 bool suspended; 346 + bool ep_prealloc; 347 347 348 348 u16 devstatus; 349 349