[update] port: hpmicro: update port files
Signed-off-by: Zhihong Chen <zhihong.chen@hpmicro.com>
This commit is contained in:
@@ -135,6 +135,7 @@ if(CONFIG_CHERRYUSB_DEVICE)
|
||||
elseif(CONFIG_CHERRYUSB_DEVICE_HPM)
|
||||
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)
|
||||
list(APPEND cherryusb_incs ${CMAKE_CURRENT_LIST_DIR}/port/hpmicro)
|
||||
elseif(CONFIG_CHERRYUSB_DEVICE_BL)
|
||||
list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/bouffalolab/usb_dc_bl.c)
|
||||
elseif(CONFIG_CHERRYUSB_DEVICE_AIC)
|
||||
@@ -269,6 +270,7 @@ if(CONFIG_CHERRYUSB_HOST)
|
||||
# list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/ehci/usb_hc_ehci_iso.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/hpmicro)
|
||||
list(APPEND cherryusb_incs ${CMAKE_CURRENT_LIST_DIR}/port/ehci)
|
||||
elseif(CONFIG_CHERRYUSB_HOST_EHCI_AIC)
|
||||
list(APPEND cherryusb_srcs ${CMAKE_CURRENT_LIST_DIR}/port/ehci/usb_hc_ehci.c)
|
||||
|
||||
@@ -852,11 +852,11 @@ int usb_hc_init(struct usbh_bus *bus)
|
||||
}
|
||||
}
|
||||
|
||||
usb_hc_low_level2_init(bus);
|
||||
|
||||
EHCI_HCOR->usbintr = 0;
|
||||
EHCI_HCOR->usbsts = EHCI_HCOR->usbsts;
|
||||
|
||||
usb_hc_low_level2_init(bus);
|
||||
|
||||
/* Set the Current Asynchronous List Address. */
|
||||
EHCI_HCOR->asynclistaddr = EHCI_PTR2ADDR(&g_async_qh_head[bus->hcd.hcd_id]);
|
||||
/* Set the Periodic Frame List Base Address. */
|
||||
|
||||
@@ -2,4 +2,4 @@
|
||||
|
||||
## Support Chip List
|
||||
|
||||
- HPM all series (hpmicro + EHCI)
|
||||
- HPM all series (HPMicro + EHCI)
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
#include "usbd_core.h"
|
||||
#include "hpm_usb_device.h"
|
||||
#include "usb_glue_hpm.h"
|
||||
|
||||
#ifndef USB_NUM_BIDIR_ENDPOINTS
|
||||
#define USB_NUM_BIDIR_ENDPOINTS CONFIG_USBDEV_EP_NUM
|
||||
@@ -48,47 +49,39 @@ 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)];
|
||||
static USB_NOCACHE_RAM_SECTION usb_device_handle_t usb_device_handle[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 */
|
||||
static inline uint8_t ep_idx2bit(uint8_t ep_idx)
|
||||
{
|
||||
return ep_idx / 2 + ((ep_idx % 2) ? 16 : 0);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
void usb_dc_low_level_init(uint8_t busid)
|
||||
static void usb_dc_isr_connect(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);
|
||||
hpm_usb_isr_enable(HPM_USB0_BASE);
|
||||
} else {
|
||||
#ifdef HPM_USB1_BASE
|
||||
g_usb_hpm_busid[1] = busid;
|
||||
g_usb_hpm_irq[1] = USBD_IRQHandler;
|
||||
|
||||
intc_m_enable_irq(IRQn_USB1);
|
||||
hpm_usb_isr_enable(HPM_USB1_BASE);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void usb_dc_low_level_deinit(uint8_t busid)
|
||||
static void usb_dc_isr_disconnect(uint8_t busid)
|
||||
{
|
||||
if (g_usbdev_bus[busid].reg_base == HPM_USB0_BASE) {
|
||||
intc_m_disable_irq(IRQn_USB0);
|
||||
hpm_usb_isr_disable(HPM_USB0_BASE);
|
||||
|
||||
g_usb_hpm_busid[0] = 0;
|
||||
g_usb_hpm_irq[0] = NULL;
|
||||
} else {
|
||||
#ifdef HPM_USB1_BASE
|
||||
intc_m_disable_irq(IRQn_USB1);
|
||||
hpm_usb_isr_disable(HPM_USB1_BASE);
|
||||
|
||||
g_usb_hpm_busid[1] = 0;
|
||||
g_usb_hpm_irq[1] = NULL;
|
||||
@@ -98,8 +91,6 @@ void usb_dc_low_level_deinit(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));
|
||||
g_hpm_udc[busid].handle = &usb_device_handle[busid];
|
||||
g_hpm_udc[busid].handle->regs = (USB_Type *)g_usbdev_bus[busid].reg_base;
|
||||
@@ -113,13 +104,17 @@ int usb_dc_init(uint8_t busid)
|
||||
#endif
|
||||
|
||||
usb_device_init(g_hpm_udc[busid].handle, int_mask);
|
||||
|
||||
usb_dc_isr_connect(busid);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int usb_dc_deinit(uint8_t busid)
|
||||
{
|
||||
usb_dc_isr_disconnect(busid);
|
||||
|
||||
usb_device_deinit(g_hpm_udc[busid].handle);
|
||||
usb_dc_low_level_deinit(busid);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -146,6 +141,11 @@ int usbd_set_remote_wakeup(uint8_t busid)
|
||||
return 0;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
uint8_t usbd_get_port_speed(uint8_t busid)
|
||||
{
|
||||
uint8_t speed;
|
||||
|
||||
@@ -8,17 +8,43 @@
|
||||
#include "hpm_soc.h"
|
||||
|
||||
void (*g_usb_hpm_irq[2])(uint8_t busid);
|
||||
uint8_t g_usb_hpm_busid[2] = { 0, 0 };
|
||||
uint8_t g_usb_hpm_busid[2];
|
||||
|
||||
SDK_DECLARE_EXT_ISR_M(IRQn_USB0, isr_usbh0)
|
||||
void isr_usbh0(void)
|
||||
ATTR_WEAK void hpm_usb_isr_enable(uint32_t base)
|
||||
{
|
||||
if (base == HPM_USB0_BASE) {
|
||||
intc_m_enable_irq(IRQn_USB0);
|
||||
} else {
|
||||
#ifdef HPM_USB1_BASE
|
||||
intc_m_enable_irq(IRQn_USB1);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
ATTR_WEAK void hpm_usb_isr_disable(uint32_t base)
|
||||
{
|
||||
if (base == HPM_USB0_BASE) {
|
||||
intc_m_disable_irq(IRQn_USB0);
|
||||
} else {
|
||||
#ifdef HPM_USB1_BASE
|
||||
intc_m_disable_irq(IRQn_USB1);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef CONFIG_CHERRYUSB_CUSTOM_IRQ_HANDLER
|
||||
SDK_DECLARE_EXT_ISR_M(IRQn_USB0, hpm_isr_usb0)
|
||||
#endif
|
||||
void hpm_isr_usb0(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)
|
||||
#ifndef CONFIG_CHERRYUSB_CUSTOM_IRQ_HANDLER
|
||||
SDK_DECLARE_EXT_ISR_M(IRQn_USB1, hpm_isr_usb1)
|
||||
#endif
|
||||
void hpm_isr_usb1(void)
|
||||
{
|
||||
g_usb_hpm_irq[1](g_usb_hpm_busid[1]);
|
||||
}
|
||||
|
||||
19
port/hpmicro/usb_glue_hpm.h
Normal file
19
port/hpmicro/usb_glue_hpm.h
Normal file
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright (c) 2022-2025 HPMicro
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _HPM_USB_GLUE_HPM_H_
|
||||
#define _HPM_USB_GLUE_HPM_H_
|
||||
|
||||
extern void (*g_usb_hpm_irq[2])(uint8_t busid);
|
||||
extern uint8_t g_usb_hpm_busid[2];
|
||||
|
||||
void hpm_usb_isr_enable(uint32_t base);
|
||||
void hpm_usb_isr_disable(uint32_t base);
|
||||
void hpm_isr_usb0(void);
|
||||
void hpm_isr_usb1(void);
|
||||
|
||||
#endif /* _HPM_USB_GLUE_HPM_H_ */
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "hpm_common.h"
|
||||
#include "hpm_soc.h"
|
||||
#include "hpm_usb_drv.h"
|
||||
#include "usb_glue_hpm.h"
|
||||
|
||||
#if !defined(CONFIG_USB_EHCI_HPMICRO) || !CONFIG_USB_EHCI_HPMICRO
|
||||
#error "hpm ehci must set CONFIG_USB_EHCI_HPMICRO=1"
|
||||
@@ -46,25 +47,26 @@ static void usb_host_mode_init(USB_Type *ptr)
|
||||
|
||||
void usb_hc_low_level_init(struct usbh_bus *bus)
|
||||
{
|
||||
if (bus->hcd.reg_base == HPM_USB0_BASE) {
|
||||
g_usb_hpm_busid[0] = bus->hcd.hcd_id;
|
||||
g_usb_hpm_irq[0] = USBH_IRQHandler;
|
||||
|
||||
intc_m_enable_irq(IRQn_USB0);
|
||||
} else {
|
||||
#ifdef HPM_USB1_BASE
|
||||
g_usb_hpm_busid[1] = bus->hcd.hcd_id;
|
||||
g_usb_hpm_irq[1] = USBH_IRQHandler;
|
||||
|
||||
intc_m_enable_irq(IRQn_USB1);
|
||||
#endif
|
||||
}
|
||||
usb_phy_init((USB_Type *)(bus->hcd.reg_base), true);
|
||||
}
|
||||
|
||||
void usb_hc_low_level2_init(struct usbh_bus *bus)
|
||||
{
|
||||
usb_host_mode_init((USB_Type *)(bus->hcd.reg_base));
|
||||
|
||||
if (bus->hcd.reg_base == HPM_USB0_BASE) {
|
||||
g_usb_hpm_busid[0] = bus->hcd.hcd_id;
|
||||
g_usb_hpm_irq[0] = USBH_IRQHandler;
|
||||
|
||||
hpm_usb_isr_enable(HPM_USB0_BASE);
|
||||
} else {
|
||||
#ifdef HPM_USB1_BASE
|
||||
g_usb_hpm_busid[1] = bus->hcd.hcd_id;
|
||||
g_usb_hpm_irq[1] = USBH_IRQHandler;
|
||||
|
||||
hpm_usb_isr_enable(HPM_USB1_BASE);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void usb_hc_low_level_deinit(struct usbh_bus *bus)
|
||||
@@ -72,13 +74,13 @@ 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);
|
||||
hpm_usb_isr_disable(HPM_USB0_BASE);
|
||||
|
||||
g_usb_hpm_busid[0] = 0;
|
||||
g_usb_hpm_irq[0] = NULL;
|
||||
} else {
|
||||
#ifdef HPM_USB1_BASE
|
||||
intc_m_disable_irq(IRQn_USB1);
|
||||
hpm_usb_isr_disable(HPM_USB1_BASE);
|
||||
|
||||
g_usb_hpm_busid[1] = 0;
|
||||
g_usb_hpm_irq[1] = NULL;
|
||||
|
||||
Reference in New Issue
Block a user