Lines Matching +full:tx +full:- +full:pwr +full:- +full:min
3 * Copyright (c) 2017, I-SENSE group of ICCS
5 * SPDX-License-Identifier: Apache-2.0
41 * pin(s) in the device tree. E.g: pinctrl-0 = <&usb_otg_fs_vbus_pa9 ...>;
130 /* We need n TX IN FIFOs */
133 /* We need a minimum size for RX FIFO - exact number seemingly determined through trial and error */
136 /* Allocate FIFO memory evenly between the TX FIFOs */
137 /* except the first TX endpoint need only 64 bytes */
139 #define TX_FIFO_WORDS (USB_RAM_SIZE / 4 - RX_FIFO_EP_WORDS - TX_FIFO_EP_0_WORDS)
140 /* Number of words for each remaining TX endpoint FIFO */
141 #define TX_FIFO_EP_WORDS (TX_FIFO_WORDS / (TX_FIFO_NUM - 1))
234 return -EIO; in usb_dc_stm32u5_phy_clock_select()
246 return -EINVAL; in usb_dc_stm32u5_phy_clock_select()
256 return -EIO; in usb_dc_stm32u5_phy_clock_enable()
262 return -EIO; in usb_dc_stm32u5_phy_clock_enable()
282 return -EIO; in usb_dc_stm32_phy_specific_clock_enable()
293 /* Leave the PWR clock in its initial position */ in usb_dc_stm32_phy_specific_clock_enable()
311 return -EIO; in usb_dc_stm32_phy_specific_clock_enable()
323 * VDDUSB independent USB supply (PWR clock is on) in usb_dc_stm32_phy_specific_clock_enable()
333 return -EIO; in usb_dc_stm32_phy_specific_clock_enable()
339 return -EIO; in usb_dc_stm32_phy_specific_clock_enable()
349 return -EIO; in usb_dc_stm32_phy_specific_clock_enable()
354 return -ENOTSUP; in usb_dc_stm32_phy_specific_clock_enable()
370 return -ENODEV; in usb_dc_stm32_clock_enable()
395 /* Disable ULPI interface (for external high-speed PHY) clock in sleep/low-power mode. in usb_dc_stm32_clock_enable()
423 return -EIO; in usb_dc_stm32_clock_disable()
436 * If max-speed is not passed via DT, set it to USB controller's in usb_dc_stm32_get_maximum_speed()
447 if (!strncmp(USB_MAXIMUM_SPEED, "high-speed", 10)) { in usb_dc_stm32_get_maximum_speed()
449 } else if (!strncmp(USB_MAXIMUM_SPEED, "full-speed", 10)) { in usb_dc_stm32_get_maximum_speed()
527 LOG_INF("PWR not active yet"); in usb_dc_stm32_init()
543 return -EIO; in usb_dc_stm32_init()
547 * so the USB connection can get re-initialized in usb_dc_stm32_init()
553 return -EIO; in usb_dc_stm32_init()
560 return -EIO; in usb_dc_stm32_init()
624 return -EINVAL; in usb_dc_attach()
628 return -EIO; in usb_dc_attach()
673 return -EINVAL; in usb_dc_ep_set_callback()
676 ep_state->cb = cb; in usb_dc_ep_set_callback()
698 return -EIO; in usb_dc_set_address()
713 return -EINVAL; in usb_dc_ep_start_read()
726 return -EIO; in usb_dc_ep_start_read()
736 return -EINVAL; in usb_dc_ep_get_read_count()
746 uint8_t ep_idx = USB_EP_GET_IDX(cfg->ep_addr); in usb_dc_ep_check_cap()
748 LOG_DBG("ep %x, mps %d, type %d", cfg->ep_addr, cfg->ep_mps, in usb_dc_ep_check_cap()
749 cfg->ep_type); in usb_dc_ep_check_cap()
751 if ((cfg->ep_type == USB_DC_EP_CONTROL) && ep_idx) { in usb_dc_ep_check_cap()
753 return -1; in usb_dc_ep_check_cap()
756 if (ep_idx > (USB_NUM_BIDIR_ENDPOINTS - 1)) { in usb_dc_ep_check_cap()
758 return -1; in usb_dc_ep_check_cap()
766 uint8_t ep = ep_cfg->ep_addr; in usb_dc_ep_configure()
770 return -EINVAL; in usb_dc_ep_configure()
774 ep_cfg->ep_addr, ep_state->ep_mps, ep_cfg->ep_mps, in usb_dc_ep_configure()
775 ep_cfg->ep_type); in usb_dc_ep_configure()
777 if (ep_cfg->ep_mps > ep_state->ep_pma_buf_len) { in usb_dc_ep_configure()
778 if (ep_cfg->ep_type == USB_DC_EP_ISOCHRONOUS) { in usb_dc_ep_configure()
780 (usb_dc_stm32_state.pma_offset + ep_cfg->ep_mps*2)) { in usb_dc_ep_configure()
781 return -EINVAL; in usb_dc_ep_configure()
784 (usb_dc_stm32_state.pma_offset + ep_cfg->ep_mps)) { in usb_dc_ep_configure()
785 return -EINVAL; in usb_dc_ep_configure()
788 if (ep_cfg->ep_type == USB_DC_EP_ISOCHRONOUS) { in usb_dc_ep_configure()
791 ((usb_dc_stm32_state.pma_offset + ep_cfg->ep_mps) << 16)); in usb_dc_ep_configure()
792 ep_state->ep_pma_buf_len = ep_cfg->ep_mps*2; in usb_dc_ep_configure()
793 usb_dc_stm32_state.pma_offset += ep_cfg->ep_mps*2; in usb_dc_ep_configure()
797 ep_state->ep_pma_buf_len = ep_cfg->ep_mps; in usb_dc_ep_configure()
798 usb_dc_stm32_state.pma_offset += ep_cfg->ep_mps; in usb_dc_ep_configure()
801 if (ep_cfg->ep_type == USB_DC_EP_ISOCHRONOUS) { in usb_dc_ep_configure()
802 ep_state->ep_mps = ep_cfg->ep_mps*2; in usb_dc_ep_configure()
804 ep_state->ep_mps = ep_cfg->ep_mps; in usb_dc_ep_configure()
807 ep_state->ep_mps = ep_cfg->ep_mps; in usb_dc_ep_configure()
810 switch (ep_cfg->ep_type) { in usb_dc_ep_configure()
812 ep_state->ep_type = EP_TYPE_CTRL; in usb_dc_ep_configure()
815 ep_state->ep_type = EP_TYPE_ISOC; in usb_dc_ep_configure()
818 ep_state->ep_type = EP_TYPE_BULK; in usb_dc_ep_configure()
821 ep_state->ep_type = EP_TYPE_INTR; in usb_dc_ep_configure()
824 return -EINVAL; in usb_dc_ep_configure()
838 return -EINVAL; in usb_dc_ep_set_stall()
845 return -EIO; in usb_dc_ep_set_stall()
848 ep_state->ep_stalled = 1U; in usb_dc_ep_set_stall()
861 return -EINVAL; in usb_dc_ep_clear_stall()
868 return -EIO; in usb_dc_ep_clear_stall()
871 ep_state->ep_stalled = 0U; in usb_dc_ep_clear_stall()
872 ep_state->read_count = 0U; in usb_dc_ep_clear_stall()
884 return -EINVAL; in usb_dc_ep_is_stalled()
887 *stalled = ep_state->ep_stalled; in usb_dc_ep_is_stalled()
900 return -EINVAL; in usb_dc_ep_enable()
903 LOG_DBG("HAL_PCD_EP_Open(0x%02x, %u, %u)", ep, ep_state->ep_mps, in usb_dc_ep_enable()
904 ep_state->ep_type); in usb_dc_ep_enable()
907 ep_state->ep_mps, ep_state->ep_type); in usb_dc_ep_enable()
911 return -EIO; in usb_dc_ep_enable()
917 ep_state->ep_mps); in usb_dc_ep_enable()
931 return -EINVAL; in usb_dc_ep_disable()
938 return -EIO; in usb_dc_ep_disable()
956 return -EINVAL; in usb_dc_ep_write()
959 ret = k_sem_take(&ep_state->write_sem, K_NO_WAIT); in usb_dc_ep_write()
962 return -EAGAIN; in usb_dc_ep_write()
978 k_sem_give(&ep_state->write_sem); in usb_dc_ep_write()
979 ret = -EIO; in usb_dc_ep_write()
984 * This also flushes the TX FIFO to the host. in usb_dc_ep_write()
1008 return -EINVAL; in usb_dc_ep_read_wait()
1011 read_count = ep_state->read_count; in usb_dc_ep_read_wait()
1014 ep_state->read_offset, read_count, (void *)data); in usb_dc_ep_read_wait()
1018 return -EINVAL; in usb_dc_ep_read_wait()
1026 read_count = MIN(read_count, max_data_len); in usb_dc_ep_read_wait()
1028 ep_state->read_offset, read_count); in usb_dc_ep_read_wait()
1029 ep_state->read_count -= read_count; in usb_dc_ep_read_wait()
1030 ep_state->read_offset += read_count; in usb_dc_ep_read_wait()
1048 return -EINVAL; in usb_dc_ep_read_continue()
1054 if (!ep_state->read_count) { in usb_dc_ep_read_continue()
1056 ep_state->ep_mps); in usb_dc_ep_read_continue()
1066 return -EINVAL; in usb_dc_ep_read()
1070 return -EINVAL; in usb_dc_ep_read()
1086 return -EINVAL; in usb_dc_ep_flush()
1099 return -EINVAL; in usb_dc_ep_mps()
1102 return ep_state->ep_mps; in usb_dc_ep_mps()
1111 return -EAGAIN; in usb_dc_wakeup_request()
1119 return -EAGAIN; in usb_dc_wakeup_request()
1134 return -EIO; in usb_dc_detach()
1226 ep_state->read_count = SETUP_SIZE; in HAL_PCD_SetupStageCallback()
1227 ep_state->read_offset = 0U; in HAL_PCD_SetupStageCallback()
1229 usb_dc_stm32_state.pcd.Setup, ep_state->read_count); in HAL_PCD_SetupStageCallback()
1231 if (ep_state->cb) { in HAL_PCD_SetupStageCallback()
1232 ep_state->cb(EP0_OUT, USB_DC_EP_SETUP); in HAL_PCD_SetupStageCallback()
1234 if (!(setup->wLength == 0U) && in HAL_PCD_SetupStageCallback()
1238 setup->wLength); in HAL_PCD_SetupStageCallback()
1255 usb_dc_ep_get_read_count(ep, &ep_state->read_count); in HAL_PCD_DataOutStageCallback()
1256 ep_state->read_offset = 0U; in HAL_PCD_DataOutStageCallback()
1258 if (ep_state->cb) { in HAL_PCD_DataOutStageCallback()
1259 ep_state->cb(ep, USB_DC_EP_DATA_OUT); in HAL_PCD_DataOutStageCallback()
1273 k_sem_give(&ep_state->write_sem); in HAL_PCD_DataInStageCallback()
1275 if (ep_state->cb) { in HAL_PCD_DataInStageCallback()
1276 ep_state->cb(ep, USB_DC_EP_DATA_IN); in HAL_PCD_DataInStageCallback()