Lines Matching +full:iso +full:- +full:out +full:- +full:mps
4 * SPDX-License-Identifier: Apache-2.0
15 #include <zephyr/dt-bindings/interrupt-controller/it8xxx2-wuc.h>
76 #define DC_CONNECT_TO_HOST BIT(6) /* internal pull-up */
127 /* shared OUT FIFO state */
167 const struct usb_it82xx2_config *config = dev->config; in it82xx2_get_ext_ctrl()
168 struct usb_it82xx2_regs *const usb_regs = config->base; in it82xx2_get_ext_ctrl()
170 usb_regs->fifo_regs[EP_EXT_REGS_9X].ext_4_15.epn0n1_ext_ctrl; in it82xx2_get_ext_ctrl()
172 usb_regs->fifo_regs[EP_EXT_REGS_DX].ext_0_3.epn_ext_ctrl; in it82xx2_get_ext_ctrl()
175 idx = ((ep_idx - 4) % 3) + 1; in it82xx2_get_ext_ctrl()
179 idx = (ep_idx - 4) / 2; in it82xx2_get_ext_ctrl()
186 const struct usb_it82xx2_config *config = dev->config; in it82xx2_usb_extend_ep_ctrl()
187 struct usb_it82xx2_regs *const usb_regs = config->base; in it82xx2_usb_extend_ep_ctrl()
188 struct it82xx2_usb_ep_regs *ep_regs = usb_regs->usb_ep_regs; in it82xx2_usb_extend_ep_ctrl()
190 usb_regs->fifo_regs[EP_EXT_REGS_DX].ext_0_3.epn_ext_ctrl; in it82xx2_usb_extend_ep_ctrl()
205 epn0n1_ext_ctrl->fields.epn1_send_stall_bit = enable; in it82xx2_usb_extend_ep_ctrl()
207 epn0n1_ext_ctrl->fields.epn0_send_stall_bit = enable; in it82xx2_usb_extend_ep_ctrl()
212 epn0n1_ext_ctrl->fields.epn1_iso_enable_bit = enable; in it82xx2_usb_extend_ep_ctrl()
214 epn0n1_ext_ctrl->fields.epn0_iso_enable_bit = enable; in it82xx2_usb_extend_ep_ctrl()
219 epn0n1_ext_ctrl->fields.epn1_outdata_sequence_bit = enable; in it82xx2_usb_extend_ep_ctrl()
221 epn0n1_ext_ctrl->fields.epn0_outdata_sequence_bit = enable; in it82xx2_usb_extend_ep_ctrl()
229 if (epn0n1_ext_ctrl->fields.epn1_outdata_sequence_bit) { in it82xx2_usb_extend_ep_ctrl()
230 epn0n1_ext_ctrl->fields.epn1_outdata_sequence_bit = 0; in it82xx2_usb_extend_ep_ctrl()
232 epn0n1_ext_ctrl->fields.epn1_outdata_sequence_bit = 1; in it82xx2_usb_extend_ep_ctrl()
235 if (epn0n1_ext_ctrl->fields.epn0_outdata_sequence_bit) { in it82xx2_usb_extend_ep_ctrl()
236 epn0n1_ext_ctrl->fields.epn0_outdata_sequence_bit = 0; in it82xx2_usb_extend_ep_ctrl()
238 epn0n1_ext_ctrl->fields.epn0_outdata_sequence_bit = 1; in it82xx2_usb_extend_ep_ctrl()
243 if (((ep_idx - 4) / 3 == 0)) { in it82xx2_usb_extend_ep_ctrl()
244 epn_ext_ctrl1->fields.epn0_direction_bit = enable; in it82xx2_usb_extend_ep_ctrl()
245 } else if (((ep_idx - 4) / 3 == 1)) { in it82xx2_usb_extend_ep_ctrl()
246 epn_ext_ctrl1->fields.epn3_direction_bit = enable; in it82xx2_usb_extend_ep_ctrl()
247 } else if (((ep_idx - 4) / 3 == 2)) { in it82xx2_usb_extend_ep_ctrl()
248 epn_ext_ctrl1->fields.epn6_direction_bit = enable; in it82xx2_usb_extend_ep_ctrl()
249 } else if (((ep_idx - 4) / 3 == 3)) { in it82xx2_usb_extend_ep_ctrl()
250 epn_ext_ctrl1->fields.epn9_direction_bit = enable; in it82xx2_usb_extend_ep_ctrl()
253 return -EINVAL; in it82xx2_usb_extend_ep_ctrl()
257 if (((ep_idx - 4) / 3 == 0)) { in it82xx2_usb_extend_ep_ctrl()
258 epn_ext_ctrl1->fields.epn0_enable_bit = enable; in it82xx2_usb_extend_ep_ctrl()
259 } else if (((ep_idx - 4) / 3 == 1)) { in it82xx2_usb_extend_ep_ctrl()
260 epn_ext_ctrl1->fields.epn3_enable_bit = enable; in it82xx2_usb_extend_ep_ctrl()
261 } else if (((ep_idx - 4) / 3 == 2)) { in it82xx2_usb_extend_ep_ctrl()
262 epn_ext_ctrl1->fields.epn6_enable_bit = enable; in it82xx2_usb_extend_ep_ctrl()
263 } else if (((ep_idx - 4) / 3 == 3)) { in it82xx2_usb_extend_ep_ctrl()
264 epn_ext_ctrl1->fields.epn9_enable_bit = enable; in it82xx2_usb_extend_ep_ctrl()
267 return -EINVAL; in it82xx2_usb_extend_ep_ctrl()
271 int idx = ((ep_idx - 4) % 3) + 1; in it82xx2_usb_extend_ep_ctrl()
273 (enable) ? (ext_ctrl[idx].epn_ext_ctrl2 |= BIT((ep_idx - 4) / 3)) in it82xx2_usb_extend_ep_ctrl()
274 : (ext_ctrl[idx].epn_ext_ctrl2 &= ~BIT((ep_idx - 4) / 3)); in it82xx2_usb_extend_ep_ctrl()
279 return -EINVAL; in it82xx2_usb_extend_ep_ctrl()
288 const struct usb_it82xx2_config *config = dev->config; in it82xx2_usb_ep_ctrl()
289 struct usb_it82xx2_regs *const usb_regs = config->base; in it82xx2_usb_ep_ctrl()
290 struct it82xx2_usb_ep_regs *ep_regs = usb_regs->usb_ep_regs; in it82xx2_usb_ep_ctrl()
295 return -EINVAL; in it82xx2_usb_ep_ctrl()
351 return -EINVAL; in it82xx2_usb_ep_ctrl()
385 /* Wake-up interrupt (USB D+) Enable/Disable */
388 const struct usb_it82xx2_config *config = dev->config; in it82xx2_enable_wu_irq()
391 it8xxx2_wuc_clear_status(config->wuc.dev, config->wuc.mask); in it82xx2_enable_wu_irq()
394 irq_enable(config->wu_irq); in it82xx2_enable_wu_irq()
396 irq_disable(config->wu_irq); in it82xx2_enable_wu_irq()
411 const struct usb_it82xx2_config *config = dev->config; in it8xxx2_usb_dc_wuc_init()
414 it8xxx2_wuc_set_polarity(config->wuc.dev, config->wuc.mask, WUC_TYPE_EDGE_FALLING); in it8xxx2_usb_dc_wuc_init()
415 it8xxx2_wuc_clear_status(config->wuc.dev, config->wuc.mask); in it8xxx2_usb_dc_wuc_init()
418 it8xxx2_wuc_enable(config->wuc.dev, config->wuc.mask); in it8xxx2_usb_dc_wuc_init()
421 irq_connect_dynamic(config->wu_irq, 0, it82xx2_wu_isr, dev, 0); in it8xxx2_usb_dc_wuc_init()
427 const struct usb_it82xx2_config *config = dev->config; in it82xx2_usb_fifo_ctrl()
428 struct usb_it82xx2_regs *const usb_regs = config->base; in it82xx2_usb_fifo_ctrl()
429 volatile uint8_t *ep_fifo_ctrl = usb_regs->fifo_regs[EP_EXT_REGS_BX].fifo_ctrl.ep_fifo_ctrl; in it82xx2_usb_fifo_ctrl()
430 uint8_t fifon_ctrl = (ep_fifo_res[ep_idx % SHARED_FIFO_NUM] - 1) * 2; in it82xx2_usb_fifo_ctrl()
436 return -EINVAL; in it82xx2_usb_fifo_ctrl()
453 ep_fifo_ctrl[fifon_ctrl + 1] = BIT(ep_idx - 8); in it82xx2_usb_fifo_ctrl()
459 ep_fifo_ctrl[fifon_ctrl + 1] |= BIT(ep_idx - 8); in it82xx2_usb_fifo_ctrl()
463 ret = -EINVAL; in it82xx2_usb_fifo_ctrl()
486 it82xx2_event_submit(dev, cfg->addr, IT82xx2_EVT_XFER); in it82xx2_ep_enqueue()
492 const uint8_t ep_idx = USB_EP_GET_IDX(cfg->addr); in it82xx2_ep_dequeue()
493 const struct usb_it82xx2_config *config = dev->config; in it82xx2_ep_dequeue()
494 struct usb_it82xx2_regs *const usb_regs = config->base; in it82xx2_ep_dequeue()
495 struct it82xx2_usb_ep_fifo_regs *ff_regs = usb_regs->fifo_regs; in it82xx2_ep_dequeue()
502 if (USB_EP_DIR_IS_IN(cfg->addr)) { in it82xx2_ep_dequeue()
509 buf = udc_buf_get_all(dev, cfg->addr); in it82xx2_ep_dequeue()
511 udc_submit_ep_event(dev, buf, -ECONNABORTED); in it82xx2_ep_dequeue()
514 udc_ep_set_busy(dev, cfg->addr, false); in it82xx2_ep_dequeue()
521 const struct usb_it82xx2_config *config = dev->config; in ctrl_ep_stall_workaround()
522 struct usb_it82xx2_regs *const usb_regs = config->base; in ctrl_ep_stall_workaround()
523 struct it82xx2_usb_ep_regs *ep_regs = usb_regs->usb_ep_regs; in ctrl_ep_stall_workaround()
529 priv->stall_is_sent = true; in ctrl_ep_stall_workaround()
542 gctrl_regs->GCTRL_WNCKR = 0; in ctrl_ep_stall_workaround()
554 const uint8_t ep_idx = USB_EP_GET_IDX(cfg->addr); in it82xx2_ep_set_halt()
563 LOG_DBG("Endpoint 0x%x is halted", cfg->addr); in it82xx2_ep_set_halt()
570 const uint8_t ep_idx = USB_EP_GET_IDX(cfg->addr); in it82xx2_ep_clear_halt()
574 LOG_DBG("Endpoint 0x%x clear halted", cfg->addr); in it82xx2_ep_clear_halt()
581 const uint8_t ep_idx = USB_EP_GET_IDX(cfg->addr); in it82xx2_ep_enable()
585 if (USB_EP_DIR_IS_IN(cfg->addr)) { in it82xx2_ep_enable()
589 it82xx2_usb_fifo_ctrl(dev, cfg->addr, true); in it82xx2_ep_enable()
592 it82xx2_usb_fifo_ctrl(dev, cfg->addr, false); in it82xx2_ep_enable()
595 switch (cfg->attributes & USB_EP_TRANSFER_TYPE_MASK) { in it82xx2_ep_enable()
607 return -ENOTSUP; in it82xx2_ep_enable()
620 LOG_DBG("Endpoint 0x%02x is enabled", cfg->addr); in it82xx2_ep_enable()
627 const uint8_t ep_idx = USB_EP_GET_IDX(cfg->addr); in it82xx2_ep_disable()
631 LOG_DBG("Endpoint 0x%02x is disabled", cfg->addr); in it82xx2_ep_disable()
639 const struct usb_it82xx2_config *config = dev->config; in it82xx2_host_wakeup()
640 struct usb_it82xx2_regs *const usb_regs = config->base; in it82xx2_host_wakeup()
641 int ret = -EACCES; in it82xx2_host_wakeup()
644 usb_regs->dc_control = DC_GLOBAL_ENABLE | DC_FULL_SPEED_LINE_POLARITY | in it82xx2_host_wakeup()
652 usb_regs->dc_control = DC_GLOBAL_ENABLE | DC_FULL_SPEED_LINE_POLARITY | in it82xx2_host_wakeup()
655 ret = k_sem_take(&priv->suspended_sem, K_MSEC(500)); in it82xx2_host_wakeup()
666 const struct usb_it82xx2_config *config = dev->config; in it82xx2_set_address()
667 struct usb_it82xx2_regs *const usb_regs = config->base; in it82xx2_set_address()
669 usb_regs->dc_address = addr & DC_ADDR_MASK; in it82xx2_set_address()
678 const struct usb_it82xx2_config *config = dev->config; in it82xx2_usb_dc_ip_init()
679 struct usb_it82xx2_regs *const usb_regs = config->base; in it82xx2_usb_dc_ip_init()
682 usb_regs->host_device_control = RESET_CORE; in it82xx2_usb_dc_ip_init()
684 usb_regs->port0_misc_control &= ~(PULL_DOWN_EN); in it82xx2_usb_dc_ip_init()
685 usb_regs->port1_misc_control &= ~(PULL_DOWN_EN); in it82xx2_usb_dc_ip_init()
688 usb_regs->host_device_control = 0; in it82xx2_usb_dc_ip_init()
690 usb_regs->dc_interrupt_status = in it82xx2_usb_dc_ip_init()
693 usb_regs->dc_interrupt_mask = 0x00; in it82xx2_usb_dc_ip_init()
694 usb_regs->dc_interrupt_mask = in it82xx2_usb_dc_ip_init()
697 usb_regs->dc_address = DC_ADDR_NULL; in it82xx2_usb_dc_ip_init()
704 const struct usb_it82xx2_config *config = dev->config; in it82xx2_enable_resume_int()
705 struct usb_it82xx2_regs *const usb_regs = config->base; in it82xx2_enable_resume_int()
707 usb_regs->dc_interrupt_status = DC_RESUME_EVENT; in it82xx2_enable_resume_int()
709 usb_regs->dc_interrupt_mask |= DC_RESUME_EVENT; in it82xx2_enable_resume_int()
711 usb_regs->dc_interrupt_mask &= ~DC_RESUME_EVENT; in it82xx2_enable_resume_int()
717 const struct usb_it82xx2_config *config = dev->config; in it82xx2_enable_sof_int()
718 struct usb_it82xx2_regs *const usb_regs = config->base; in it82xx2_enable_sof_int()
720 usb_regs->dc_interrupt_status = DC_SOF_RECEIVED; in it82xx2_enable_sof_int()
722 usb_regs->dc_interrupt_mask |= DC_SOF_RECEIVED; in it82xx2_enable_sof_int()
724 usb_regs->dc_interrupt_mask &= ~DC_SOF_RECEIVED; in it82xx2_enable_sof_int()
730 const struct usb_it82xx2_config *config = dev->config; in it82xx2_dc_reset()
731 struct usb_it82xx2_regs *const usb_regs = config->base; in it82xx2_dc_reset()
732 struct it82xx2_usb_ep_regs *ep_regs = usb_regs->usb_ep_regs; in it82xx2_dc_reset()
733 struct it82xx2_usb_ep_fifo_regs *ff_regs = usb_regs->fifo_regs; in it82xx2_dc_reset()
742 usb_regs->dc_address = DC_ADDR_NULL; in it82xx2_dc_reset()
743 usb_regs->dc_interrupt_status = DC_NAK_SENT_INT | DC_SOF_RECEIVED; in it82xx2_dc_reset()
745 atomic_clear_bit(&priv->out_fifo_state, IT82xx2_STATE_OUT_SHARED_FIFO_BUSY); in it82xx2_dc_reset()
747 k_sem_give(&priv->fifo_sem[0]); in it82xx2_dc_reset()
748 k_sem_give(&priv->fifo_sem[1]); in it82xx2_dc_reset()
749 k_sem_give(&priv->fifo_sem[2]); in it82xx2_dc_reset()
755 const struct usb_it82xx2_config *config = dev->config; in it82xx2_xfer_in_data()
756 struct usb_it82xx2_regs *const usb_regs = config->base; in it82xx2_xfer_in_data()
757 struct it82xx2_usb_ep_fifo_regs *ff_regs = usb_regs->fifo_regs; in it82xx2_xfer_in_data()
768 k_sem_take(&priv->fifo_sem[fifo_idx - 1], K_FOREVER); in it82xx2_xfer_in_data()
773 len = MIN(buf->len, udc_mps_ep_size(ep_cfg)); in it82xx2_xfer_in_data()
776 ff_regs[fifo_idx].ep_tx_fifo_data = buf->data[i]; in it82xx2_xfer_in_data()
784 LOG_DBG("Writed %d packets to endpoint%d tx fifo", buf->len, ep_idx); in it82xx2_xfer_in_data()
791 const struct usb_it82xx2_config *config = dev->config; in it82xx2_xfer_out_data()
792 struct usb_it82xx2_regs *const usb_regs = config->base; in it82xx2_xfer_out_data()
793 struct it82xx2_usb_ep_regs *ep_regs = usb_regs->usb_ep_regs; in it82xx2_xfer_out_data()
794 struct it82xx2_usb_ep_fifo_regs *ff_regs = usb_regs->fifo_regs; in it82xx2_xfer_out_data()
802 return -EINVAL; in it82xx2_xfer_out_data()
822 const struct usb_it82xx2_config *config = dev->config; in get_fifo_ctrl()
823 struct usb_it82xx2_regs *const usb_regs = config->base; in get_fifo_ctrl()
824 volatile uint8_t *ep_fifo_ctrl = usb_regs->fifo_regs[EP_EXT_REGS_BX].fifo_ctrl.ep_fifo_ctrl; in get_fifo_ctrl()
832 fifon_ctrl = (fifo_idx - 1) * 2; in get_fifo_ctrl()
851 atomic_set_bit(&priv->out_fifo_state, IT82xx2_STATE_OUT_SHARED_FIFO_BUSY); in work_handler_xfer_continue()
870 return -ENODATA; in work_handler_xfer_next()
877 * Allocate buffer and initiate a new control OUT transfer,
887 return -ENOMEM; in it82xx2_ctrl_feed_dout()
902 if (((ep_idx - 4) / 3 == 0)) { in get_extend_enable_bit()
903 enable = (epn_ext_ctrl1->fields.epn0_enable_bit != 0); in get_extend_enable_bit()
904 } else if (((ep_idx - 4) / 3 == 1)) { in get_extend_enable_bit()
905 enable = (epn_ext_ctrl1->fields.epn3_enable_bit != 0); in get_extend_enable_bit()
906 } else if (((ep_idx - 4) / 3 == 2)) { in get_extend_enable_bit()
907 enable = (epn_ext_ctrl1->fields.epn6_enable_bit != 0); in get_extend_enable_bit()
909 enable = (epn_ext_ctrl1->fields.epn9_enable_bit != 0); in get_extend_enable_bit()
916 const struct usb_it82xx2_config *config = dev->config; in get_extend_ready_bit()
917 struct usb_it82xx2_regs *const usb_regs = config->base; in get_extend_ready_bit()
919 usb_regs->fifo_regs[EP_EXT_REGS_DX].ext_0_3.epn_ext_ctrl; in get_extend_ready_bit()
920 int idx = ((ep_idx - 4) % 3) + 1; in get_extend_ready_bit()
922 return ((ext_ctrl[idx].epn_ext_ctrl2 & BIT((ep_idx - 4) / 3)) != 0); in get_extend_ready_bit()
937 if (priv->stall_is_sent) { in it82xx2_fake_token()
954 if (!atomic_test_bit(&priv->out_fifo_state, in it82xx2_fake_token()
984 k_sem_give(&priv->fifo_sem[fifo_idx - 1]); in work_handler_in()
989 return -ENODATA; in work_handler_in()
993 net_buf_pull(buf, MIN(buf->len, udc_mps_ep_size(ep_cfg))); in work_handler_in()
997 if (buf->len) { in work_handler_in()
1010 return -ENODATA; in work_handler_in()
1027 * Feed control OUT buffer for status stage. in work_handler_in()
1045 /* out -> setup */ in work_handler_setup()
1054 /* in -> setup */ in work_handler_setup()
1061 return -ENOMEM; in work_handler_setup()
1066 if (buf->len != sizeof(struct usb_setup_packet)) { in work_handler_setup()
1067 LOG_DBG("buffer length %d read from chip", buf->len); in work_handler_setup()
1072 priv->stall_is_sent = false; in work_handler_setup()
1073 LOG_HEXDUMP_DBG(buf->data, buf->len, "setup:"); in work_handler_setup()
1080 /* Allocate and feed buffer for data OUT stage */ in work_handler_setup()
1081 LOG_DBG("s:%p|feed for -out-", buf); in work_handler_setup()
1083 if (err == -ENOMEM) { in work_handler_setup()
1100 const struct usb_it82xx2_config *config = dev->config; in work_handler_out()
1102 struct usb_it82xx2_regs *const usb_regs = config->base; in work_handler_out()
1103 struct it82xx2_usb_ep_fifo_regs *ff_regs = usb_regs->fifo_regs; in work_handler_out()
1114 return -ENODATA; in work_handler_out()
1136 return -ENOBUFS; in work_handler_out()
1141 LOG_DBG("Handle data OUT, %zu | %zu", len, net_buf_tailroom(buf)); in work_handler_out()
1153 return -ENODATA; in work_handler_out()
1172 atomic_clear_bit(&priv->out_fifo_state, IT82xx2_STATE_OUT_SHARED_FIFO_BUSY); in work_handler_out()
1201 err = -EINVAL; in xfer_work_handler()
1220 const struct usb_it82xx2_config *config = dev->config; in it82xx2_check_ep0_stall()
1221 struct usb_it82xx2_regs *const usb_regs = config->base; in it82xx2_check_ep0_stall()
1222 struct it82xx2_usb_ep_regs *ep_regs = usb_regs->usb_ep_regs; in it82xx2_check_ep0_stall()
1223 struct it82xx2_usb_ep_fifo_regs *ff_regs = usb_regs->fifo_regs; in it82xx2_check_ep0_stall()
1249 const struct usb_it82xx2_config *config = dev->config; in it82xx2_usb_xfer_done()
1250 struct usb_it82xx2_regs *const usb_regs = config->base; in it82xx2_usb_xfer_done()
1251 struct it82xx2_usb_ep_regs *ep_regs = usb_regs->usb_ep_regs; in it82xx2_usb_xfer_done()
1253 usb_regs->fifo_regs[EP_EXT_REGS_DX].ext_0_3.epn_ext_ctrl; in it82xx2_usb_xfer_done()
1306 /* OUT transaction done */ in it82xx2_usb_xfer_done()
1324 k_sem_give(&priv->suspended_sem); in emit_resume_event()
1331 const struct usb_it82xx2_config *config = dev->config; in it82xx2_usb_dc_isr()
1332 struct usb_it82xx2_regs *const usb_regs = config->base; in it82xx2_usb_dc_isr()
1335 uint8_t status = usb_regs->dc_interrupt_status & in it82xx2_usb_dc_isr()
1336 usb_regs->dc_interrupt_mask; /* mask non enable int */ in it82xx2_usb_dc_isr()
1340 if ((usb_regs->dc_line_status & RX_LINE_STATE_MASK) == RX_LINE_RESET) { in it82xx2_usb_dc_isr()
1342 usb_regs->dc_interrupt_status = DC_RESET_EVENT; in it82xx2_usb_dc_isr()
1347 usb_regs->dc_interrupt_status = DC_RESET_EVENT; in it82xx2_usb_dc_isr()
1355 usb_regs->dc_interrupt_status = DC_SOF_RECEIVED; in it82xx2_usb_dc_isr()
1360 k_work_cancel_delayable(&priv->suspended_work); in it82xx2_usb_dc_isr()
1361 k_work_reschedule(&priv->suspended_work, K_MSEC(5)); in it82xx2_usb_dc_isr()
1373 usb_regs->dc_interrupt_status = DC_TRANS_DONE; in it82xx2_usb_dc_isr()
1383 const struct device *dev = priv->dev; in suspended_handler()
1384 const struct usb_it82xx2_config *config = dev->config; in suspended_handler()
1385 struct usb_it82xx2_regs *const usb_regs = config->base; in suspended_handler()
1388 if (usb_regs->dc_interrupt_status & DC_SOF_RECEIVED) { in suspended_handler()
1389 usb_regs->dc_interrupt_status = DC_SOF_RECEIVED; in suspended_handler()
1390 k_work_reschedule(&priv->suspended_work, K_MSEC(5)); in suspended_handler()
1401 k_sem_reset(&priv->suspended_sem); in suspended_handler()
1415 const struct usb_it82xx2_config *config = dev->config; in it82xx2_enable()
1416 struct usb_it82xx2_regs *const usb_regs = config->base; in it82xx2_enable()
1419 k_sem_init(&priv->suspended_sem, 0, 1); in it82xx2_enable()
1420 k_work_init_delayable(&priv->suspended_work, suspended_handler); in it82xx2_enable()
1422 atomic_clear_bit(&priv->out_fifo_state, IT82xx2_STATE_OUT_SHARED_FIFO_BUSY); in it82xx2_enable()
1425 k_sem_init(&priv->fifo_sem[0], 1, 1); in it82xx2_enable()
1426 k_sem_init(&priv->fifo_sem[1], 1, 1); in it82xx2_enable()
1427 k_sem_init(&priv->fifo_sem[2], 1, 1); in it82xx2_enable()
1429 usb_regs->dc_control = DC_GLOBAL_ENABLE | DC_FULL_SPEED_LINE_POLARITY | in it82xx2_enable()
1434 irq_enable(config->usb_irq); in it82xx2_enable()
1441 const struct usb_it82xx2_config *config = dev->config; in it82xx2_disable()
1442 struct usb_it82xx2_regs *const usb_regs = config->base; in it82xx2_disable()
1444 irq_disable(config->usb_irq); in it82xx2_disable()
1446 /* stop pull-up D+ D-*/ in it82xx2_disable()
1447 usb_regs->dc_control &= ~DC_CONNECT_TO_HOST; in it82xx2_disable()
1454 const struct usb_it82xx2_config *config = dev->config; in it82xx2_init()
1462 gctrl_regs->GCTRL_MCCR &= ~(IT8XXX2_GCTRL_MCCR_USB_EN); in it82xx2_init()
1463 gctrl_regs->gctrl_pmer2 |= IT8XXX2_GCTRL_PMER2_USB_PAD_EN; in it82xx2_init()
1468 config->ep_cfg_out[0].caps.mps, 0); in it82xx2_init()
1475 config->ep_cfg_in[0].caps.mps, 0); in it82xx2_init()
1487 return -EIO; in it82xx2_shutdown()
1492 return -EIO; in it82xx2_shutdown()
1528 const struct usb_it82xx2_config *config = dev->config; in it82xx2_usb_driver_preinit()
1529 struct udc_data *data = dev->data; in it82xx2_usb_driver_preinit()
1533 k_mutex_init(&data->mutex); in it82xx2_usb_driver_preinit()
1534 k_fifo_init(&priv->fifo); in it82xx2_usb_driver_preinit()
1536 err = pinctrl_apply_state(config->pcfg, PINCTRL_STATE_DEFAULT); in it82xx2_usb_driver_preinit()
1543 config->ep_cfg_out[i].caps.out = 1; in it82xx2_usb_driver_preinit()
1545 config->ep_cfg_out[i].caps.control = 1; in it82xx2_usb_driver_preinit()
1546 config->ep_cfg_out[i].caps.mps = USB_CONTROL_EP_MPS; in it82xx2_usb_driver_preinit()
1548 config->ep_cfg_out[i].caps.bulk = 1; in it82xx2_usb_driver_preinit()
1549 config->ep_cfg_out[i].caps.interrupt = 1; in it82xx2_usb_driver_preinit()
1550 config->ep_cfg_out[i].caps.iso = 1; in it82xx2_usb_driver_preinit()
1551 config->ep_cfg_out[i].caps.mps = 64; in it82xx2_usb_driver_preinit()
1554 config->ep_cfg_out[i].addr = USB_EP_DIR_OUT | i; in it82xx2_usb_driver_preinit()
1555 err = udc_register_ep(dev, &config->ep_cfg_out[i]); in it82xx2_usb_driver_preinit()
1563 config->ep_cfg_in[i].caps.in = 1; in it82xx2_usb_driver_preinit()
1565 config->ep_cfg_in[i].caps.control = 1; in it82xx2_usb_driver_preinit()
1566 config->ep_cfg_in[i].caps.mps = USB_CONTROL_EP_MPS; in it82xx2_usb_driver_preinit()
1568 config->ep_cfg_in[i].caps.bulk = 1; in it82xx2_usb_driver_preinit()
1569 config->ep_cfg_in[i].caps.interrupt = 1; in it82xx2_usb_driver_preinit()
1570 config->ep_cfg_in[i].caps.iso = 1; in it82xx2_usb_driver_preinit()
1571 config->ep_cfg_in[i].caps.mps = 64; in it82xx2_usb_driver_preinit()
1574 config->ep_cfg_in[i].addr = USB_EP_DIR_IN | i; in it82xx2_usb_driver_preinit()
1575 err = udc_register_ep(dev, &config->ep_cfg_in[i]); in it82xx2_usb_driver_preinit()
1582 data->caps.rwup = true; in it82xx2_usb_driver_preinit()
1583 data->caps.mps0 = UDC_MPS0_64; in it82xx2_usb_driver_preinit()
1585 priv->dev = dev; in it82xx2_usb_driver_preinit()
1587 config->make_thread(dev); in it82xx2_usb_driver_preinit()
1593 irq_connect_dynamic(config->usb_irq, 0, it82xx2_usb_dc_isr, dev, 0); in it82xx2_usb_driver_preinit()
1612 k_thread_create(&priv->thread_data, udc_it82xx2_stack_##n, \
1616 k_thread_name_set(&priv->thread_data, dev->name); \