Lines Matching refs:priv

231 	struct udc_dwc2_data *const priv = udc_get_private(dev);  in dwc2_get_iept_pktctn()  local
236 return priv->max_pktcnt; in dwc2_get_iept_pktctn()
242 struct udc_dwc2_data *const priv = udc_get_private(dev); in dwc2_get_iept_xfersize() local
247 return priv->max_xfersize; in dwc2_get_iept_xfersize()
372 struct udc_dwc2_data *const priv = udc_get_private(dev); in dwc2_tx_fifo_write() local
401 if (!priv->bufferdma) { in dwc2_tx_fifo_write()
456 priv->tx_len[ep_idx] = len; in dwc2_tx_fifo_write()
466 if (priv->bufferdma) { in dwc2_tx_fifo_write()
495 if (priv->sof_num & 1) { in dwc2_tx_fifo_write()
509 if (!priv->bufferdma) { in dwc2_tx_fifo_write()
579 struct udc_dwc2_data *const priv = udc_get_private(dev); in dwc2_prep_rx() local
602 if (priv->sof_num & 1) { in dwc2_prep_rx()
611 if (xfersize > priv->max_xfersize) { in dwc2_prep_rx()
612 xfersize = ROUND_DOWN(priv->max_xfersize, USB_MPS_TO_TPL(cfg->mps)); in dwc2_prep_rx()
626 priv->rx_siz[ep_idx] = doeptsiz; in dwc2_prep_rx()
629 if (priv->bufferdma) { in dwc2_prep_rx()
698 struct udc_dwc2_data *const priv = udc_get_private(dev); in dwc2_handle_evt_setup() local
708 net_buf_add_mem(buf, priv->setup, sizeof(priv->setup)); in dwc2_handle_evt_setup()
857 struct udc_dwc2_data *const priv = udc_get_private(dev); in dwc2_backup_registers() local
858 struct dwc2_reg_backup *backup = &priv->backup; in dwc2_backup_registers()
870 for (uint8_t i = 1U; i < priv->ineps; i++) { in dwc2_backup_registers()
881 uint32_t epdir = usb_dwc2_get_ghwcfg1_epdir(priv->ghwcfg1, i); in dwc2_backup_registers()
914 struct udc_dwc2_data *const priv = udc_get_private(dev); in dwc2_restore_essential_registers() local
915 struct dwc2_reg_backup *backup = &priv->backup; in dwc2_restore_essential_registers()
949 struct udc_dwc2_data *const priv = udc_get_private(dev); in dwc2_restore_device_registers() local
950 struct dwc2_reg_backup *backup = &priv->backup; in dwc2_restore_device_registers()
960 for (uint8_t i = 1U; i < priv->ineps; i++) { in dwc2_restore_device_registers()
973 uint32_t epdir = usb_dwc2_get_ghwcfg1_epdir(priv->ghwcfg1, i); in dwc2_restore_device_registers()
993 struct udc_dwc2_data *const priv = udc_get_private(dev); in dwc2_enter_hibernation() local
1032 priv->hibernated = 1; in dwc2_enter_hibernation()
1041 struct udc_dwc2_data *const priv = udc_get_private(dev); in dwc2_exit_hibernation() local
1063 if (priv->syncrst) { in dwc2_exit_hibernation()
1097 sys_write32(priv->backup.gusbcfg, (mem_addr_t)&base->gusbcfg); in dwc2_exit_hibernation()
1098 sys_write32(priv->backup.dcfg, (mem_addr_t)&base->dcfg); in dwc2_exit_hibernation()
1099 sys_write32(priv->backup.dctl, (mem_addr_t)&base->dctl); in dwc2_exit_hibernation()
1108 sys_write32(USB_DWC2_DCTL_RMTWKUPSIG | priv->backup.dctl, in dwc2_exit_hibernation()
1116 static void cancel_hibernation_request(struct udc_dwc2_data *const priv) in cancel_hibernation_request() argument
1118 k_event_clear(&priv->drv_evt, BIT(DWC2_DRV_EVT_ENTER_HIBERNATION)); in cancel_hibernation_request()
1121 static void request_hibernation(struct udc_dwc2_data *const priv) in request_hibernation() argument
1123 if (priv->suspend_type == DWC2_SUSPEND_HIBERNATION) { in request_hibernation()
1124 k_event_post(&priv->drv_evt, BIT(DWC2_DRV_EVT_ENTER_HIBERNATION)); in request_hibernation()
1130 struct udc_dwc2_data *const priv = udc_get_private(dev); in dwc2_unset_unused_fifo() local
1133 for (uint8_t i = priv->ineps - 1U; i > 0; i--) { in dwc2_unset_unused_fifo()
1136 if (tmp->stat.enabled && (priv->txf_set & BIT(i))) { in dwc2_unset_unused_fifo()
1140 if (!tmp->stat.enabled && (priv->txf_set & BIT(i))) { in dwc2_unset_unused_fifo()
1141 priv->txf_set &= ~BIT(i); in dwc2_unset_unused_fifo()
1155 struct udc_dwc2_data *const priv = udc_get_private(dev); in dwc2_set_dedicated_fifo() local
1167 if (priv->bufferdma) { in dwc2_set_dedicated_fifo()
1174 if (priv->dynfifosizing) { in dwc2_set_dedicated_fifo()
1175 if (priv->txf_set & ~BIT_MASK(ep_idx)) { in dwc2_set_dedicated_fifo()
1179 if (priv->txf_set & ~BIT_MASK(ep_idx)) { in dwc2_set_dedicated_fifo()
1181 ep_idx, priv->txf_set & ~BIT_MASK(ep_idx)); in dwc2_set_dedicated_fifo()
1189 txfaddr = priv->rxfifo_depth + in dwc2_set_dedicated_fifo()
1190 MIN(UDC_DWC2_FIFO0_DEPTH, priv->max_txfifo_depth[0]); in dwc2_set_dedicated_fifo()
1195 if (txfdep > priv->max_txfifo_depth[ep_idx]) { in dwc2_set_dedicated_fifo()
1200 if (txfaddr + txfdep > priv->dfifodepth) { in dwc2_set_dedicated_fifo()
1219 priv->txf_set |= BIT(ep_idx); in dwc2_set_dedicated_fifo()
1279 struct udc_dwc2_data *const priv = udc_get_private(dev); in udc_dwc2_ep_activate() local
1294 if (priv->ineps > 0U && ep_idx > (priv->ineps - 1U)) { in udc_dwc2_ep_activate()
1343 for (uint8_t i = 1U; i < priv->ineps; i++) { in udc_dwc2_ep_activate()
1355 struct udc_dwc2_data *const priv = udc_get_private(dev); in dwc2_unset_dedicated_fifo() local
1361 if (priv->dynfifosizing) { in dwc2_unset_dedicated_fifo()
1362 if (priv->txf_set & ~BIT_MASK(ep_idx)) { in dwc2_unset_dedicated_fifo()
1364 ep_idx, priv->txf_set & ~BIT_MASK(ep_idx)); in dwc2_unset_dedicated_fifo()
1371 priv->txf_set &= ~BIT(ep_idx); in dwc2_unset_dedicated_fifo()
1557 struct udc_dwc2_data *const priv = udc_get_private(dev); in udc_dwc2_ep_clear_halt() local
1579 k_event_post(&priv->xfer_new, ep_bit); in udc_dwc2_ep_clear_halt()
1580 k_event_post(&priv->drv_evt, BIT(DWC2_DRV_EVT_XFER)); in udc_dwc2_ep_clear_halt()
1590 struct udc_dwc2_data *const priv = udc_get_private(dev); in udc_dwc2_ep_enqueue() local
1604 k_event_post(&priv->xfer_new, ep_bit); in udc_dwc2_ep_enqueue()
1605 k_event_post(&priv->drv_evt, BIT(DWC2_DRV_EVT_XFER)); in udc_dwc2_ep_enqueue()
1679 struct udc_dwc2_data *const priv = udc_get_private(dev); in udc_dwc2_host_wakeup() local
1683 k_event_post(&priv->drv_evt, BIT(DWC2_DRV_EVT_REMOTE_WAKEUP)); in udc_dwc2_host_wakeup()
1691 struct udc_dwc2_data *const priv = udc_get_private(dev); in udc_dwc2_device_speed() local
1693 switch (priv->enumspd) { in udc_dwc2_device_speed()
1749 struct udc_dwc2_data *const priv = udc_get_private(dev); in udc_dwc2_init_controller() local
1770 priv->ghwcfg1 = sys_read32((mem_addr_t)&base->ghwcfg1); in udc_dwc2_init_controller()
1791 priv->bufferdma = (usb_dwc2_get_ghwcfg2_otgarch(ghwcfg2) == in udc_dwc2_init_controller()
1795 priv->bufferdma = 0; in udc_dwc2_init_controller()
1796 } else if (priv->bufferdma) { in udc_dwc2_init_controller()
1802 priv->dynfifosizing = true; in udc_dwc2_init_controller()
1808 priv->suspend_type = DWC2_SUSPEND_HIBERNATION; in udc_dwc2_init_controller()
1810 priv->suspend_type = DWC2_SUSPEND_NO_POWER_SAVING; in udc_dwc2_init_controller()
1814 priv->numdeveps = usb_dwc2_get_ghwcfg2_numdeveps(ghwcfg2) + 1U; in udc_dwc2_init_controller()
1815 priv->ineps = usb_dwc2_get_ghwcfg4_ineps(ghwcfg4) + 1U; in udc_dwc2_init_controller()
1816 LOG_DBG("Number of endpoints (NUMDEVEPS + 1) %u", priv->numdeveps); in udc_dwc2_init_controller()
1817 LOG_DBG("Number of IN endpoints (INEPS + 1) %u", priv->ineps); in udc_dwc2_init_controller()
1828 priv->dfifodepth = usb_dwc2_get_ghwcfg3_dfifodepth(ghwcfg3); in udc_dwc2_init_controller()
1829 LOG_DBG("DFIFO depth (DFIFODEPTH) %u bytes", priv->dfifodepth * 4); in udc_dwc2_init_controller()
1831 priv->max_pktcnt = GHWCFG3_PKTCOUNT(usb_dwc2_get_ghwcfg3_pktsizewidth(ghwcfg3)); in udc_dwc2_init_controller()
1832 priv->max_xfersize = GHWCFG3_XFERSIZE(usb_dwc2_get_ghwcfg3_xfersizewidth(ghwcfg3)); in udc_dwc2_init_controller()
1834 priv->max_pktcnt, priv->max_xfersize); in udc_dwc2_init_controller()
1848 priv->syncrst = 1; in udc_dwc2_init_controller()
1854 if (priv->bufferdma) { in udc_dwc2_init_controller()
1906 priv->outeps = 0U; in udc_dwc2_init_controller()
1907 for (uint8_t i = 0U; i < priv->numdeveps; i++) { in udc_dwc2_init_controller()
1908 uint32_t epdir = usb_dwc2_get_ghwcfg1_epdir(priv->ghwcfg1, i); in udc_dwc2_init_controller()
1915 priv->outeps++; in udc_dwc2_init_controller()
1919 LOG_DBG("Number of OUT endpoints %u", priv->outeps); in udc_dwc2_init_controller()
1925 priv->max_txfifo_depth[0] = usb_dwc2_get_gnptxfsiz_nptxfdep(val); in udc_dwc2_init_controller()
1926 for (uint8_t i = 1; i < priv->ineps; i++) { in udc_dwc2_init_controller()
1927 priv->max_txfifo_depth[i] = dwc2_get_txfdep(dev, i - 1); in udc_dwc2_init_controller()
1930 priv->rxfifo_depth = usb_dwc2_get_grxfsiz(sys_read32(grxfsiz_reg)); in udc_dwc2_init_controller()
1932 if (priv->dynfifosizing) { in udc_dwc2_init_controller()
1949 default_depth += priv->outeps * 2U; in udc_dwc2_init_controller()
1955 priv->rxfifo_depth = MIN(priv->rxfifo_depth, default_depth); in udc_dwc2_init_controller()
1956 sys_write32(usb_dwc2_set_grxfsiz(priv->rxfifo_depth), grxfsiz_reg); in udc_dwc2_init_controller()
1959 val = MIN(UDC_DWC2_FIFO0_DEPTH, priv->max_txfifo_depth[0]); in udc_dwc2_init_controller()
1961 usb_dwc2_set_gnptxfsiz_nptxfstaddr(priv->rxfifo_depth); in udc_dwc2_init_controller()
1966 LOG_DBG("RX FIFO size %u bytes", priv->rxfifo_depth * 4); in udc_dwc2_init_controller()
1967 for (uint8_t i = 1U; i < priv->ineps; i++) { in udc_dwc2_init_controller()
1969 i, priv->max_txfifo_depth[i], dwc2_get_txfaddr(dev, i)); in udc_dwc2_init_controller()
2032 struct udc_dwc2_data *const priv = udc_get_private(dev); in udc_dwc2_disable() local
2053 if (priv->hibernated) { in udc_dwc2_disable()
2055 priv->hibernated = 0; in udc_dwc2_disable()
2098 struct udc_dwc2_data *const priv = udc_get_private(dev); in dwc2_driver_preinit() local
2107 k_event_init(&priv->drv_evt); in dwc2_driver_preinit()
2108 k_event_init(&priv->xfer_new); in dwc2_driver_preinit()
2109 k_event_init(&priv->xfer_finished); in dwc2_driver_preinit()
2223 struct udc_dwc2_data *const priv = udc_get_private(dev); in dwc2_on_bus_reset() local
2227 for (uint8_t i = 0U; i < priv->numdeveps; i++) { in dwc2_on_bus_reset()
2228 uint32_t epdir = usb_dwc2_get_ghwcfg1_epdir(priv->ghwcfg1, i); in dwc2_on_bus_reset()
2240 if (priv->bufferdma) { in dwc2_on_bus_reset()
2248 if (!priv->bufferdma) { in dwc2_on_bus_reset()
2257 priv->enumdone = 0; in dwc2_on_bus_reset()
2263 struct udc_dwc2_data *const priv = udc_get_private(dev); in dwc2_handle_enumdone() local
2267 priv->enumspd = usb_dwc2_get_dsts_enumspd(dsts); in dwc2_handle_enumdone()
2268 priv->enumdone = 1; in dwc2_handle_enumdone()
2275 struct udc_dwc2_data *const priv = udc_get_private(dev); in dwc2_read_fifo_setup() local
2293 &priv->setup[offset]); in dwc2_read_fifo_setup()
2350 struct udc_dwc2_data *const priv = udc_get_private(dev); in dwc2_handle_in_xfercompl() local
2361 net_buf_pull(buf, priv->tx_len[ep_idx]); in dwc2_handle_in_xfercompl()
2366 k_event_post(&priv->xfer_finished, BIT(ep_idx)); in dwc2_handle_in_xfercompl()
2367 k_event_post(&priv->drv_evt, BIT(DWC2_DRV_EVT_EP_FINISHED)); in dwc2_handle_in_xfercompl()
2409 struct udc_dwc2_data *const priv = udc_get_private(dev); in dwc2_handle_out_xfercompl() local
2428 bcnt = usb_dwc2_get_doeptsizn_xfersize(priv->rx_siz[ep_idx]) - in dwc2_handle_out_xfercompl()
2435 pkts = usb_dwc2_get_doeptsizn_pktcnt(priv->rx_siz[ep_idx]) - in dwc2_handle_out_xfercompl()
2454 if (!priv->bufferdma) { in dwc2_handle_out_xfercompl()
2463 if (priv->bufferdma && bcnt) { in dwc2_handle_out_xfercompl()
2472 k_event_post(&priv->xfer_finished, BIT(16 + ep_idx)); in dwc2_handle_out_xfercompl()
2473 k_event_post(&priv->drv_evt, BIT(DWC2_DRV_EVT_EP_FINISHED)); in dwc2_handle_out_xfercompl()
2480 struct udc_dwc2_data *const priv = udc_get_private(dev); in dwc2_handle_oepint() local
2507 if (priv->bufferdma && (status & USB_DWC2_DOEPINT_XFERCOMPL) && in dwc2_handle_oepint()
2521 memcpy(priv->setup, (void *)(addr - 8), sizeof(priv->setup)); in dwc2_handle_oepint()
2525 k_event_post(&priv->drv_evt, BIT(DWC2_DRV_EVT_SETUP)); in dwc2_handle_oepint()
2555 struct udc_dwc2_data *const priv = udc_get_private(dev); in dwc2_handle_incompisoin() local
2565 for (uint8_t i = 1U; i < priv->numdeveps; i++) { in dwc2_handle_incompisoin()
2566 uint32_t epdir = usb_dwc2_get_ghwcfg1_epdir(priv->ghwcfg1, i); in dwc2_handle_incompisoin()
2609 struct udc_dwc2_data *const priv = udc_get_private(dev); in dwc2_handle_incompisoout() local
2617 ((priv->sof_num & 1) ? USB_DWC2_DEPCTL_DPID : 0) | in dwc2_handle_incompisoout()
2620 for (uint8_t i = 1U; i < priv->numdeveps; i++) { in dwc2_handle_incompisoout()
2621 uint32_t epdir = usb_dwc2_get_ghwcfg1_epdir(priv->ghwcfg1, i); in dwc2_handle_incompisoout()
2656 struct udc_dwc2_data *const priv = udc_get_private(dev); in udc_dwc2_isr_handler() local
2661 if (priv->hibernated) { in udc_dwc2_isr_handler()
2676 k_event_post(&priv->drv_evt, in udc_dwc2_isr_handler()
2681 k_event_post(&priv->drv_evt, BIT(DWC2_DRV_EVT_HIBERNATION_EXIT_BUS_RESET)); in udc_dwc2_isr_handler()
2702 priv->sof_num = usb_dwc2_get_dsts_soffn(dsts); in udc_dwc2_isr_handler()
2712 cancel_hibernation_request(priv); in udc_dwc2_isr_handler()
2728 cancel_hibernation_request(priv); in udc_dwc2_isr_handler()
2762 request_hibernation(priv); in udc_dwc2_isr_handler()
2773 struct udc_dwc2_data *const priv = udc_get_private(dev); in dwc2_handle_hibernation_exit() local
2778 priv->hibernated = 0; in dwc2_handle_hibernation_exit()
2802 k_event_clear(&priv->xfer_new, UINT32_MAX); in dwc2_handle_hibernation_exit()
2803 k_event_clear(&priv->xfer_finished, UINT32_MAX); in dwc2_handle_hibernation_exit()
2807 if (k_event_test(&priv->xfer_new, UINT32_MAX)) { in dwc2_handle_hibernation_exit()
2808 k_event_post(&priv->drv_evt, BIT(DWC2_DRV_EVT_XFER)); in dwc2_handle_hibernation_exit()
2811 if (k_event_test(&priv->xfer_finished, UINT32_MAX)) { in dwc2_handle_hibernation_exit()
2812 k_event_post(&priv->drv_evt, BIT(DWC2_DRV_EVT_EP_FINISHED)); in dwc2_handle_hibernation_exit()
2837 struct udc_dwc2_data *const priv = udc_get_private(dev); in dwc2_thread_handler() local
2850 evt = k_event_wait(&priv->drv_evt, UINT32_MAX, false, K_FOREVER); in dwc2_thread_handler()
2855 k_event_clear(&priv->drv_evt, BIT(DWC2_DRV_EVT_XFER)); in dwc2_thread_handler()
2857 if (!priv->hibernated) { in dwc2_thread_handler()
2859 eps = k_event_test(&priv->xfer_new, UINT32_MAX); in dwc2_thread_handler()
2860 k_event_clear(&priv->xfer_new, eps); in dwc2_thread_handler()
2879 k_event_clear(&priv->drv_evt, BIT(DWC2_DRV_EVT_EP_FINISHED)); in dwc2_thread_handler()
2881 if (!priv->hibernated) { in dwc2_thread_handler()
2882 eps = k_event_test(&priv->xfer_finished, UINT32_MAX); in dwc2_thread_handler()
2883 k_event_clear(&priv->xfer_finished, eps); in dwc2_thread_handler()
2910 k_event_clear(&priv->drv_evt, BIT(DWC2_DRV_EVT_SETUP)); in dwc2_thread_handler()
2917 k_event_clear(&priv->drv_evt, BIT(DWC2_DRV_EVT_REMOTE_WAKEUP) | in dwc2_thread_handler()
2920 if (priv->hibernated) { in dwc2_thread_handler()
2942 prev = k_event_clear(&priv->drv_evt, BIT(DWC2_DRV_EVT_ENTER_HIBERNATION)); in dwc2_thread_handler()
2958 prev = k_event_clear(&priv->drv_evt, hibernation_exit_events); in dwc2_thread_handler()
2961 if (priv->hibernated) { in dwc2_thread_handler()
3032 struct udc_dwc2_data *priv = udc_get_private(dev); \
3034 k_thread_create(&priv->thread_data, \
3042 k_thread_name_set(&priv->thread_data, dev->name); \
3085 .priv = &udc_priv_##n, \