Skip to content

Commit 45e5d0a

Browse files
committed
drivers: udc_rpi_pico: move control endpoint enable/disable
Move control endpoint enable/disable calls to udc_enable()/udc_disable(). It does not change much during USB device support initialization, but it seems to resolve an issue when starting from RAM, though the real cause is unknown. Signed-off-by: Dmitrii Sharshakov <d3dx12.xx@gmail.com>
1 parent 9d0942b commit 45e5d0a

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

drivers/usb/udc/udc_rpi_pico.c

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,6 +1044,18 @@ static int udc_rpi_pico_enable(const struct device *dev)
10441044
USB_USB_PWR_VBUS_DETECT_OVERRIDE_EN_BITS, (mm_reg_t)&base->pwr);
10451045
}
10461046

1047+
if (udc_ep_enable_internal(dev, USB_CONTROL_EP_OUT,
1048+
USB_EP_TYPE_CONTROL, 64, 0)) {
1049+
LOG_ERR("Failed to enable control endpoint");
1050+
return -EIO;
1051+
}
1052+
1053+
if (udc_ep_enable_internal(dev, USB_CONTROL_EP_IN,
1054+
USB_EP_TYPE_CONTROL, 64, 0)) {
1055+
LOG_ERR("Failed to enable control endpoint");
1056+
return -EIO;
1057+
}
1058+
10471059
/* Enable an interrupt per EP0 transaction */
10481060
sys_write32(USB_SIE_CTRL_EP0_INT_1BUF_BITS, (mm_reg_t)&base->sie_ctrl);
10491061

@@ -1082,6 +1094,16 @@ static int udc_rpi_pico_disable(const struct device *dev)
10821094
{
10831095
const struct rpi_pico_config *config = dev->config;
10841096

1097+
if (udc_ep_disable_internal(dev, USB_CONTROL_EP_OUT)) {
1098+
LOG_ERR("Failed to disable control endpoint");
1099+
return -EIO;
1100+
}
1101+
1102+
if (udc_ep_disable_internal(dev, USB_CONTROL_EP_IN)) {
1103+
LOG_ERR("Failed to disable control endpoint");
1104+
return -EIO;
1105+
}
1106+
10851107
config->irq_disable_func(dev);
10861108
LOG_DBG("Disable device %p", dev);
10871109

@@ -1094,18 +1116,6 @@ static int udc_rpi_pico_init(const struct device *dev)
10941116
const struct pinctrl_dev_config *const pcfg = config->pcfg;
10951117
int err;
10961118

1097-
if (udc_ep_enable_internal(dev, USB_CONTROL_EP_OUT,
1098-
USB_EP_TYPE_CONTROL, 64, 0)) {
1099-
LOG_ERR("Failed to enable control endpoint");
1100-
return -EIO;
1101-
}
1102-
1103-
if (udc_ep_enable_internal(dev, USB_CONTROL_EP_IN,
1104-
USB_EP_TYPE_CONTROL, 64, 0)) {
1105-
LOG_ERR("Failed to enable control endpoint");
1106-
return -EIO;
1107-
}
1108-
11091119
if (pcfg != NULL) {
11101120
err = pinctrl_apply_state(pcfg, PINCTRL_STATE_DEFAULT);
11111121
if (err) {
@@ -1121,16 +1131,6 @@ static int udc_rpi_pico_shutdown(const struct device *dev)
11211131
{
11221132
const struct rpi_pico_config *config = dev->config;
11231133

1124-
if (udc_ep_disable_internal(dev, USB_CONTROL_EP_OUT)) {
1125-
LOG_ERR("Failed to disable control endpoint");
1126-
return -EIO;
1127-
}
1128-
1129-
if (udc_ep_disable_internal(dev, USB_CONTROL_EP_IN)) {
1130-
LOG_ERR("Failed to disable control endpoint");
1131-
return -EIO;
1132-
}
1133-
11341134
return clock_control_off(config->clk_dev, config->clk_sys);
11351135
}
11361136

0 commit comments

Comments
 (0)