Skip to content

drivers: udc: rpi_pico: fix RP2350 warm ep init #91905

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 22 additions & 22 deletions drivers/usb/udc/udc_rpi_pico.c
Original file line number Diff line number Diff line change
Expand Up @@ -1044,6 +1044,18 @@ static int udc_rpi_pico_enable(const struct device *dev)
USB_USB_PWR_VBUS_DETECT_OVERRIDE_EN_BITS, (mm_reg_t)&base->pwr);
}

if (udc_ep_enable_internal(dev, USB_CONTROL_EP_OUT,
USB_EP_TYPE_CONTROL, 64, 0)) {
LOG_ERR("Failed to enable control endpoint");
return -EIO;
}

if (udc_ep_enable_internal(dev, USB_CONTROL_EP_IN,
USB_EP_TYPE_CONTROL, 64, 0)) {
LOG_ERR("Failed to enable control endpoint");
return -EIO;
}

/* Enable an interrupt per EP0 transaction */
sys_write32(USB_SIE_CTRL_EP0_INT_1BUF_BITS, (mm_reg_t)&base->sie_ctrl);

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

if (udc_ep_disable_internal(dev, USB_CONTROL_EP_OUT)) {
LOG_ERR("Failed to disable control endpoint");
return -EIO;
}

if (udc_ep_disable_internal(dev, USB_CONTROL_EP_IN)) {
LOG_ERR("Failed to disable control endpoint");
return -EIO;
}

config->irq_disable_func(dev);
LOG_DBG("Disable device %p", dev);

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

if (udc_ep_enable_internal(dev, USB_CONTROL_EP_OUT,
USB_EP_TYPE_CONTROL, 64, 0)) {
LOG_ERR("Failed to enable control endpoint");
return -EIO;
}

if (udc_ep_enable_internal(dev, USB_CONTROL_EP_IN,
USB_EP_TYPE_CONTROL, 64, 0)) {
LOG_ERR("Failed to enable control endpoint");
return -EIO;
}

if (pcfg != NULL) {
err = pinctrl_apply_state(pcfg, PINCTRL_STATE_DEFAULT);
if (err) {
Expand All @@ -1121,16 +1131,6 @@ static int udc_rpi_pico_shutdown(const struct device *dev)
{
const struct rpi_pico_config *config = dev->config;

if (udc_ep_disable_internal(dev, USB_CONTROL_EP_OUT)) {
LOG_ERR("Failed to disable control endpoint");
return -EIO;
}

if (udc_ep_disable_internal(dev, USB_CONTROL_EP_IN)) {
LOG_ERR("Failed to disable control endpoint");
return -EIO;
}

return clock_control_off(config->clk_dev, config->clk_sys);
}

Expand Down