refacor(port/hpmicro): move hpmicro glue into hpmicro directory
Signed-off-by: sakumisu <1203593632@qq.com>
This commit is contained in:
@@ -3,6 +3,8 @@ cmake_minimum_required(VERSION 3.15)
|
|||||||
if(CONFIG_CHERRYUSB)
|
if(CONFIG_CHERRYUSB)
|
||||||
|
|
||||||
if(BL_SDK_BASE)
|
if(BL_SDK_BASE)
|
||||||
|
message(STATUS "enable cherryusb in bouffalo_sdk")
|
||||||
|
|
||||||
set(CONFIG_CHERRYUSB_DEVICE_CDC_ACM 1)
|
set(CONFIG_CHERRYUSB_DEVICE_CDC_ACM 1)
|
||||||
set(CONFIG_CHERRYUSB_DEVICE_HID 1)
|
set(CONFIG_CHERRYUSB_DEVICE_HID 1)
|
||||||
set(CONFIG_CHERRYUSB_DEVICE_MSC 1)
|
set(CONFIG_CHERRYUSB_DEVICE_MSC 1)
|
||||||
@@ -30,16 +32,22 @@ if(BL_SDK_BASE)
|
|||||||
set(CONFIG_CHERRYUSB_OSAL "freertos")
|
set(CONFIG_CHERRYUSB_OSAL "freertos")
|
||||||
|
|
||||||
include(${CMAKE_CURRENT_LIST_DIR}/cherryusb.cmake)
|
include(${CMAKE_CURRENT_LIST_DIR}/cherryusb.cmake)
|
||||||
|
list(REMOVE_DUPLICATES cherryusb_srcs)
|
||||||
|
list(REMOVE_DUPLICATES cherryusb_incs)
|
||||||
|
|
||||||
sdk_generate_library(cherryusb)
|
sdk_generate_library(cherryusb)
|
||||||
sdk_add_include_directories(${cherryusb_incs})
|
sdk_add_include_directories(${cherryusb_incs})
|
||||||
sdk_library_add_sources(${cherryusb_srcs})
|
sdk_library_add_sources(${cherryusb_srcs})
|
||||||
elseif(ESP_PLATFORM)
|
elseif(ESP_PLATFORM)
|
||||||
|
message(STATUS "enable cherryusb in esp-idf")
|
||||||
|
|
||||||
set(CONFIG_CHERRYUSB_DEVICE_DWC2_ESP 1)
|
set(CONFIG_CHERRYUSB_DEVICE_DWC2_ESP 1)
|
||||||
set(CONFIG_CHERRYUSB_HOST_DWC2_ESP 1)
|
set(CONFIG_CHERRYUSB_HOST_DWC2_ESP 1)
|
||||||
set(CONFIG_CHERRYUSB_OSAL "idf")
|
set(CONFIG_CHERRYUSB_OSAL "idf")
|
||||||
|
|
||||||
include(${CMAKE_CURRENT_LIST_DIR}/cherryusb.cmake)
|
include(${CMAKE_CURRENT_LIST_DIR}/cherryusb.cmake)
|
||||||
|
list(REMOVE_DUPLICATES cherryusb_srcs)
|
||||||
|
list(REMOVE_DUPLICATES cherryusb_incs)
|
||||||
|
|
||||||
set(ldfragments "osal/idf/linker.lf")
|
set(ldfragments "osal/idf/linker.lf")
|
||||||
|
|
||||||
@@ -130,8 +138,12 @@ elseif(ESP_PLATFORM)
|
|||||||
set_source_files_properties("class/audio/usbd_audio.c" PROPERTIES COMPILE_FLAGS -Wno-maybe-uninitialized)
|
set_source_files_properties("class/audio/usbd_audio.c" PROPERTIES COMPILE_FLAGS -Wno-maybe-uninitialized)
|
||||||
endif()
|
endif()
|
||||||
elseif(ZEPHYR_BASE)
|
elseif(ZEPHYR_BASE)
|
||||||
|
message(STATUS "enable cherryusb in zephyr")
|
||||||
|
|
||||||
set(CONFIG_CHERRYUSB_OSAL "zephyr")
|
set(CONFIG_CHERRYUSB_OSAL "zephyr")
|
||||||
include(${CMAKE_CURRENT_LIST_DIR}/cherryusb.cmake)
|
include(${CMAKE_CURRENT_LIST_DIR}/cherryusb.cmake)
|
||||||
|
list(REMOVE_DUPLICATES cherryusb_srcs)
|
||||||
|
list(REMOVE_DUPLICATES cherryusb_incs)
|
||||||
|
|
||||||
if (CONFIG_SHELL)
|
if (CONFIG_SHELL)
|
||||||
list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/platform/zephyr/usb_cmd.c)
|
list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/platform/zephyr/usb_cmd.c)
|
||||||
@@ -149,6 +161,8 @@ elseif(ZEPHYR_BASE)
|
|||||||
zephyr_linker_sources(SECTIONS zephyr/usbh_class_info.ld)
|
zephyr_linker_sources(SECTIONS zephyr/usbh_class_info.ld)
|
||||||
endif()
|
endif()
|
||||||
elseif(HPM_SDK_BASE)
|
elseif(HPM_SDK_BASE)
|
||||||
|
message(STATUS "enable cherryusb in hpm_sdk")
|
||||||
|
|
||||||
set(CONFIG_CHERRYUSB_DEVICE_CDC_ACM 1)
|
set(CONFIG_CHERRYUSB_DEVICE_CDC_ACM 1)
|
||||||
set(CONFIG_CHERRYUSB_DEVICE_HID 1)
|
set(CONFIG_CHERRYUSB_DEVICE_HID 1)
|
||||||
set(CONFIG_CHERRYUSB_DEVICE_MSC 1)
|
set(CONFIG_CHERRYUSB_DEVICE_MSC 1)
|
||||||
@@ -177,6 +191,8 @@ elseif(HPM_SDK_BASE)
|
|||||||
set(CONFIG_CHERRYUSB_OSAL "freertos")
|
set(CONFIG_CHERRYUSB_OSAL "freertos")
|
||||||
|
|
||||||
include(${CMAKE_CURRENT_LIST_DIR}/cherryusb.cmake)
|
include(${CMAKE_CURRENT_LIST_DIR}/cherryusb.cmake)
|
||||||
|
list(REMOVE_DUPLICATES cherryusb_srcs)
|
||||||
|
list(REMOVE_DUPLICATES cherryusb_incs)
|
||||||
|
|
||||||
sdk_inc(${cherryusb_incs})
|
sdk_inc(${cherryusb_incs})
|
||||||
sdk_src(${cherryusb_srcs})
|
sdk_src(${cherryusb_srcs})
|
||||||
|
|||||||
@@ -85,7 +85,8 @@ if GetDepend(['PKG_CHERRYUSB_DEVICE']):
|
|||||||
if GetDepend(['PKG_CHERRYUSB_DEVICE_BL']):
|
if GetDepend(['PKG_CHERRYUSB_DEVICE_BL']):
|
||||||
src += Glob('port/bouffalolab/usb_dc_bl.c')
|
src += Glob('port/bouffalolab/usb_dc_bl.c')
|
||||||
if GetDepend(['PKG_CHERRYUSB_DEVICE_HPM']):
|
if GetDepend(['PKG_CHERRYUSB_DEVICE_HPM']):
|
||||||
src += Glob('port/hpm/usb_dc_hpm.c')
|
src += Glob('port/hpmicro/usb_dc_hpm.c')
|
||||||
|
src += Glob('port/hpmicro/usb_glue_hpm.c')
|
||||||
if GetDepend(['PKG_CHERRYUSB_DEVICE_AIC']):
|
if GetDepend(['PKG_CHERRYUSB_DEVICE_AIC']):
|
||||||
src += Glob('port/aic/usb_dc_aic.c')
|
src += Glob('port/aic/usb_dc_aic.c')
|
||||||
src += Glob('port/aic/usb_dc_aic_ll.c')
|
src += Glob('port/aic/usb_dc_aic_ll.c')
|
||||||
@@ -169,7 +170,8 @@ if GetDepend(['PKG_CHERRYUSB_HOST']):
|
|||||||
src += Glob('port/ehci/usb_glue_bouffalo.c')
|
src += Glob('port/ehci/usb_glue_bouffalo.c')
|
||||||
if GetDepend(['PKG_CHERRYUSB_HOST_EHCI_HPM']):
|
if GetDepend(['PKG_CHERRYUSB_HOST_EHCI_HPM']):
|
||||||
src += Glob('port/ehci/usb_hc_ehci.c')
|
src += Glob('port/ehci/usb_hc_ehci.c')
|
||||||
src += Glob('port/ehci/usb_glue_hpm.c')
|
src += Glob('port/hpmicro/usb_hc_hpm.c')
|
||||||
|
src += Glob('port/hpmicro/usb_glue_hpm.c')
|
||||||
if GetDepend(['PKG_CHERRYUSB_HOST_EHCI_AIC']):
|
if GetDepend(['PKG_CHERRYUSB_HOST_EHCI_AIC']):
|
||||||
path += [cwd + '/port/ehci']
|
path += [cwd + '/port/ehci']
|
||||||
path += [cwd + '/port/ohci']
|
path += [cwd + '/port/ohci']
|
||||||
|
|||||||
@@ -131,7 +131,8 @@ if(CONFIG_CHERRYUSB_DEVICE)
|
|||||||
elseif(CONFIG_CHERRYUSB_DEVICE_CHIPIDEA_CUSTOM)
|
elseif(CONFIG_CHERRYUSB_DEVICE_CHIPIDEA_CUSTOM)
|
||||||
list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/chipidea/usb_dc_chipidea.c)
|
list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/chipidea/usb_dc_chipidea.c)
|
||||||
elseif(CONFIG_CHERRYUSB_DEVICE_HPM)
|
elseif(CONFIG_CHERRYUSB_DEVICE_HPM)
|
||||||
list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/hpm/usb_dc_hpm.c)
|
list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/hpmicro/usb_dc_hpm.c)
|
||||||
|
list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/hpmicro/usb_glue_hpm.c)
|
||||||
elseif(CONFIG_CHERRYUSB_DEVICE_BL)
|
elseif(CONFIG_CHERRYUSB_DEVICE_BL)
|
||||||
list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/bouffalolab/usb_dc_bl.c)
|
list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/bouffalolab/usb_dc_bl.c)
|
||||||
elseif(CONFIG_CHERRYUSB_DEVICE_AIC)
|
elseif(CONFIG_CHERRYUSB_DEVICE_AIC)
|
||||||
@@ -264,7 +265,8 @@ if(CONFIG_CHERRYUSB_HOST)
|
|||||||
elseif(CONFIG_CHERRYUSB_HOST_EHCI_HPM)
|
elseif(CONFIG_CHERRYUSB_HOST_EHCI_HPM)
|
||||||
list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/ehci/usb_hc_ehci.c)
|
list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/ehci/usb_hc_ehci.c)
|
||||||
# list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/ehci/usb_hc_ehci_iso.c)
|
# list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/ehci/usb_hc_ehci_iso.c)
|
||||||
list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/ehci/usb_glue_hpm.c)
|
list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/hpmicro/usb_hc_hpm.c)
|
||||||
|
list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/hpmicro/usb_glue_hpm.c)
|
||||||
list(APPEND cherryusb_incs ${CMAKE_CURRENT_LIST_DIR}/port/ehci)
|
list(APPEND cherryusb_incs ${CMAKE_CURRENT_LIST_DIR}/port/ehci)
|
||||||
elseif(CONFIG_CHERRYUSB_HOST_EHCI_AIC)
|
elseif(CONFIG_CHERRYUSB_HOST_EHCI_AIC)
|
||||||
list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/ehci/usb_hc_ehci.c)
|
list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/ehci/usb_hc_ehci.c)
|
||||||
|
|||||||
@@ -4,11 +4,11 @@
|
|||||||
|
|
||||||
### BouffaloLab
|
### BouffaloLab
|
||||||
|
|
||||||
- BouffaloLab BL616/BL808
|
- BouffaloLab BL616/BL808 (bouffalolab + EHCI)
|
||||||
|
|
||||||
### HPMicro
|
### HPMicro
|
||||||
|
|
||||||
- HPM all series
|
- HPM all series (hpmicro + EHCI)
|
||||||
|
|
||||||
### AllwinnerTech
|
### AllwinnerTech
|
||||||
|
|
||||||
@@ -30,8 +30,8 @@ Modify USB_NOCACHE_RAM_SECTION
|
|||||||
#define USB_NOCACHE_RAM_SECTION __attribute__((section(".NonCacheable")))
|
#define USB_NOCACHE_RAM_SECTION __attribute__((section(".NonCacheable")))
|
||||||
```
|
```
|
||||||
|
|
||||||
- IMRT10XX/IMRT11XX
|
- IMRT10XX/IMRT11XX (chipidea + EHCI)
|
||||||
- MCXN9XX/MCXN236
|
- MCXN9XX/MCXN236 (chipidea + EHCI)
|
||||||
|
|
||||||
### Intel
|
### Intel
|
||||||
|
|
||||||
|
|||||||
5
port/hpmicro/README.md
Normal file
5
port/hpmicro/README.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
# Note
|
||||||
|
|
||||||
|
## Support Chip List
|
||||||
|
|
||||||
|
- HPM all series (hpmicro + EHCI)
|
||||||
@@ -47,8 +47,9 @@ struct hpm_udc {
|
|||||||
static USB_NOCACHE_RAM_SECTION ATTR_ALIGN(USB_SOC_DCD_DATA_RAM_ADDRESS_ALIGNMENT)
|
static USB_NOCACHE_RAM_SECTION ATTR_ALIGN(USB_SOC_DCD_DATA_RAM_ADDRESS_ALIGNMENT)
|
||||||
uint8_t _dcd_data[CONFIG_USBDEV_MAX_BUS][HPM_ALIGN_UP(sizeof(dcd_data_t), USB_SOC_DCD_DATA_RAM_ADDRESS_ALIGNMENT)];
|
uint8_t _dcd_data[CONFIG_USBDEV_MAX_BUS][HPM_ALIGN_UP(sizeof(dcd_data_t), USB_SOC_DCD_DATA_RAM_ADDRESS_ALIGNMENT)];
|
||||||
static USB_NOCACHE_RAM_SECTION usb_device_handle_t usb_device_handle[CONFIG_USBDEV_MAX_BUS];
|
static USB_NOCACHE_RAM_SECTION usb_device_handle_t usb_device_handle[CONFIG_USBDEV_MAX_BUS];
|
||||||
static uint32_t _dcd_irqnum[CONFIG_USBDEV_MAX_BUS];
|
|
||||||
static uint8_t _dcd_busid[CONFIG_USBDEV_MAX_BUS];
|
extern void (*g_usb_hpm_irq[2])(uint8_t busid);
|
||||||
|
extern uint8_t g_usb_hpm_busid[2];
|
||||||
|
|
||||||
/* Index to bit position in register */
|
/* Index to bit position in register */
|
||||||
static inline uint8_t ep_idx2bit(uint8_t ep_idx)
|
static inline uint8_t ep_idx2bit(uint8_t ep_idx)
|
||||||
@@ -61,25 +62,49 @@ void usbd_execute_test_mode(uint8_t busid, uint8_t test_mode)
|
|||||||
usb_set_port_test_mode(g_hpm_udc[busid].handle->regs, test_mode);
|
usb_set_port_test_mode(g_hpm_udc[busid].handle->regs, test_mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void usb_dc_low_level_init(uint8_t busid)
|
||||||
|
{
|
||||||
|
if (g_usbdev_bus[busid].reg_base == HPM_USB0_BASE) {
|
||||||
|
g_usb_hpm_busid[0] = busid;
|
||||||
|
g_usb_hpm_irq[0] = USBD_IRQHandler;
|
||||||
|
|
||||||
|
intc_m_enable_irq(IRQn_USB0);
|
||||||
|
} else {
|
||||||
|
#ifdef HPM_USB1_BASE
|
||||||
|
g_usb_hpm_busid[1] = busid;
|
||||||
|
g_usb_hpm_irq[1] = USBD_IRQHandler;
|
||||||
|
|
||||||
|
intc_m_enable_irq(IRQn_USB1);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void usb_dc_low_level_deinit(uint8_t busid)
|
||||||
|
{
|
||||||
|
if (g_usbdev_bus[busid].reg_base == HPM_USB0_BASE) {
|
||||||
|
intc_m_disable_irq(IRQn_USB0);
|
||||||
|
|
||||||
|
g_usb_hpm_busid[0] = 0;
|
||||||
|
g_usb_hpm_irq[0] = NULL;
|
||||||
|
} else {
|
||||||
|
#ifdef HPM_USB1_BASE
|
||||||
|
intc_m_disable_irq(IRQn_USB1);
|
||||||
|
|
||||||
|
g_usb_hpm_busid[1] = 0;
|
||||||
|
g_usb_hpm_irq[1] = NULL;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int usb_dc_init(uint8_t busid)
|
int usb_dc_init(uint8_t busid)
|
||||||
{
|
{
|
||||||
|
usb_dc_low_level_init(busid);
|
||||||
|
|
||||||
memset(&g_hpm_udc[busid], 0, sizeof(struct hpm_udc));
|
memset(&g_hpm_udc[busid], 0, sizeof(struct hpm_udc));
|
||||||
g_hpm_udc[busid].handle = &usb_device_handle[busid];
|
g_hpm_udc[busid].handle = &usb_device_handle[busid];
|
||||||
g_hpm_udc[busid].handle->regs = (USB_Type *)g_usbdev_bus[busid].reg_base;
|
g_hpm_udc[busid].handle->regs = (USB_Type *)g_usbdev_bus[busid].reg_base;
|
||||||
g_hpm_udc[busid].handle->dcd_data = (dcd_data_t *)&_dcd_data[busid][0];
|
g_hpm_udc[busid].handle->dcd_data = (dcd_data_t *)&_dcd_data[busid][0];
|
||||||
|
|
||||||
if (g_usbdev_bus[busid].reg_base == HPM_USB0_BASE) {
|
|
||||||
_dcd_irqnum[busid] = IRQn_USB0;
|
|
||||||
_dcd_busid[0] = busid;
|
|
||||||
} else {
|
|
||||||
#ifdef HPM_USB1_BASE
|
|
||||||
if (g_usbdev_bus[busid].reg_base == HPM_USB1_BASE) {
|
|
||||||
_dcd_irqnum[busid] = IRQn_USB1;
|
|
||||||
_dcd_busid[1] = busid;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t int_mask;
|
uint32_t int_mask;
|
||||||
int_mask = (intr_usb | intr_error |intr_port_change | intr_reset | intr_suspend);
|
int_mask = (intr_usb | intr_error |intr_port_change | intr_reset | intr_suspend);
|
||||||
|
|
||||||
@@ -88,16 +113,13 @@ int usb_dc_init(uint8_t busid)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
usb_device_init(g_hpm_udc[busid].handle, int_mask);
|
usb_device_init(g_hpm_udc[busid].handle, int_mask);
|
||||||
|
|
||||||
intc_m_enable_irq(_dcd_irqnum[busid]);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int usb_dc_deinit(uint8_t busid)
|
int usb_dc_deinit(uint8_t busid)
|
||||||
{
|
{
|
||||||
intc_m_disable_irq(_dcd_irqnum[busid]);
|
|
||||||
|
|
||||||
usb_device_deinit(g_hpm_udc[busid].handle);
|
usb_device_deinit(g_hpm_udc[busid].handle);
|
||||||
|
usb_dc_low_level_deinit(busid);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -357,21 +379,3 @@ void USBD_IRQHandler(uint8_t busid)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(USBD_USE_CUSTOM_ISR) || !USBD_USE_CUSTOM_ISR
|
|
||||||
|
|
||||||
SDK_DECLARE_EXT_ISR_M(IRQn_USB0, isr_usbd0)
|
|
||||||
void isr_usbd0(void)
|
|
||||||
{
|
|
||||||
USBD_IRQHandler(_dcd_busid[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef HPM_USB1_BASE
|
|
||||||
SDK_DECLARE_EXT_ISR_M(IRQn_USB1, isr_usbd1)
|
|
||||||
void isr_usbd1(void)
|
|
||||||
{
|
|
||||||
USBD_IRQHandler(_dcd_busid[1]);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
25
port/hpmicro/usb_glue_hpm.c
Normal file
25
port/hpmicro/usb_glue_hpm.c
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2022-2025 HPMicro
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#include "hpm_common.h"
|
||||||
|
#include "hpm_soc.h"
|
||||||
|
|
||||||
|
void (*g_usb_hpm_irq[2])(uint8_t busid);
|
||||||
|
uint8_t g_usb_hpm_busid[2] = { 0, 0 };
|
||||||
|
|
||||||
|
SDK_DECLARE_EXT_ISR_M(IRQn_USB0, isr_usbh0)
|
||||||
|
void isr_usbh0(void)
|
||||||
|
{
|
||||||
|
g_usb_hpm_irq[0](g_usb_hpm_busid[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HPM_USB1_BASE
|
||||||
|
SDK_DECLARE_EXT_ISR_M(IRQn_USB1, isr_usbh1)
|
||||||
|
void isr_usbh1(void)
|
||||||
|
{
|
||||||
|
g_usb_hpm_irq[1](g_usb_hpm_busid[1]);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2022-2024 HPMicro
|
* Copyright (c) 2022-2025 HPMicro
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-3-Clause
|
* SPDX-License-Identifier: BSD-3-Clause
|
||||||
*
|
*
|
||||||
@@ -17,8 +17,8 @@
|
|||||||
#error "hpm ehci must config CONFIG_USB_EHCI_HCCR_OFFSET to 0x100"
|
#error "hpm ehci must config CONFIG_USB_EHCI_HCCR_OFFSET to 0x100"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static uint32_t _hcd_irqnum[CONFIG_USBHOST_MAX_BUS];
|
extern void (*g_usb_hpm_irq[2])(uint8_t busid);
|
||||||
static uint8_t _hcd_busid[CONFIG_USBHOST_MAX_BUS];
|
extern uint8_t g_usb_hpm_busid[2];
|
||||||
|
|
||||||
static void usb_host_mode_init(USB_Type *ptr)
|
static void usb_host_mode_init(USB_Type *ptr)
|
||||||
{
|
{
|
||||||
@@ -47,19 +47,19 @@ static void usb_host_mode_init(USB_Type *ptr)
|
|||||||
void usb_hc_low_level_init(struct usbh_bus *bus)
|
void usb_hc_low_level_init(struct usbh_bus *bus)
|
||||||
{
|
{
|
||||||
if (bus->hcd.reg_base == HPM_USB0_BASE) {
|
if (bus->hcd.reg_base == HPM_USB0_BASE) {
|
||||||
_hcd_irqnum[bus->hcd.hcd_id] = IRQn_USB0;
|
g_usb_hpm_busid[0] = bus->hcd.hcd_id;
|
||||||
_hcd_busid[0] = bus->hcd.hcd_id;
|
g_usb_hpm_irq[0] = USBH_IRQHandler;
|
||||||
|
|
||||||
|
intc_m_enable_irq(IRQn_USB0);
|
||||||
} else {
|
} else {
|
||||||
#ifdef HPM_USB1_BASE
|
#ifdef HPM_USB1_BASE
|
||||||
if (bus->hcd.reg_base == HPM_USB1_BASE) {
|
g_usb_hpm_busid[1] = bus->hcd.hcd_id;
|
||||||
_hcd_irqnum[bus->hcd.hcd_id] = IRQn_USB1;
|
g_usb_hpm_irq[1] = USBH_IRQHandler;
|
||||||
_hcd_busid[1] = bus->hcd.hcd_id;
|
|
||||||
}
|
intc_m_enable_irq(IRQn_USB1);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
usb_phy_init((USB_Type *)(bus->hcd.reg_base), true);
|
usb_phy_init((USB_Type *)(bus->hcd.reg_base), true);
|
||||||
intc_m_enable_irq(_hcd_irqnum[bus->hcd.hcd_id]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void usb_hc_low_level2_init(struct usbh_bus *bus)
|
void usb_hc_low_level2_init(struct usbh_bus *bus)
|
||||||
@@ -67,6 +67,25 @@ void usb_hc_low_level2_init(struct usbh_bus *bus)
|
|||||||
usb_host_mode_init((USB_Type *)(bus->hcd.reg_base));
|
usb_host_mode_init((USB_Type *)(bus->hcd.reg_base));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void usb_hc_low_level_deinit(struct usbh_bus *bus)
|
||||||
|
{
|
||||||
|
usb_phy_deinit((USB_Type *)(bus->hcd.reg_base));
|
||||||
|
|
||||||
|
if (bus->hcd.reg_base == HPM_USB0_BASE) {
|
||||||
|
intc_m_disable_irq(IRQn_USB0);
|
||||||
|
|
||||||
|
g_usb_hpm_busid[0] = 0;
|
||||||
|
g_usb_hpm_irq[0] = NULL;
|
||||||
|
} else {
|
||||||
|
#ifdef HPM_USB1_BASE
|
||||||
|
intc_m_disable_irq(IRQn_USB1);
|
||||||
|
|
||||||
|
g_usb_hpm_busid[1] = 0;
|
||||||
|
g_usb_hpm_irq[1] = NULL;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
uint8_t usbh_get_port_speed(struct usbh_bus *bus, const uint8_t port)
|
uint8_t usbh_get_port_speed(struct usbh_bus *bus, const uint8_t port)
|
||||||
{
|
{
|
||||||
(void)port;
|
(void)port;
|
||||||
@@ -86,23 +105,3 @@ uint8_t usbh_get_port_speed(struct usbh_bus *bus, const uint8_t port)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(USBH_USE_CUSTOM_ISR) || !USBH_USE_CUSTOM_ISR
|
|
||||||
|
|
||||||
extern void USBH_IRQHandler(uint8_t busid);
|
|
||||||
|
|
||||||
SDK_DECLARE_EXT_ISR_M(IRQn_USB0, isr_usbh0)
|
|
||||||
void isr_usbh0(void)
|
|
||||||
{
|
|
||||||
USBH_IRQHandler(_hcd_busid[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef HPM_USB1_BASE
|
|
||||||
SDK_DECLARE_EXT_ISR_M(IRQn_USB1, isr_usbh1)
|
|
||||||
void isr_usbh1(void)
|
|
||||||
{
|
|
||||||
USBH_IRQHandler(_hcd_busid[1]);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
Reference in New Issue
Block a user