ohci: Support configurable number of roothub ports
This commit is contained in:
@@ -55,6 +55,7 @@
|
|||||||
#elif TU_CHECK_MCU(OPT_MCU_LPC175X_6X, OPT_MCU_LPC177X_8X, OPT_MCU_LPC40XX)
|
#elif TU_CHECK_MCU(OPT_MCU_LPC175X_6X, OPT_MCU_LPC177X_8X, OPT_MCU_LPC40XX)
|
||||||
#define TUP_DCD_ENDPOINT_MAX 16
|
#define TUP_DCD_ENDPOINT_MAX 16
|
||||||
#define TUP_USBIP_OHCI
|
#define TUP_USBIP_OHCI
|
||||||
|
#define OHCI_RHPORTS 2
|
||||||
|
|
||||||
#elif TU_CHECK_MCU(OPT_MCU_LPC18XX, OPT_MCU_LPC43XX)
|
#elif TU_CHECK_MCU(OPT_MCU_LPC18XX, OPT_MCU_LPC43XX)
|
||||||
// TODO USB0 has 6, USB1 has 4
|
// TODO USB0 has 6, USB1 has 4
|
||||||
|
|||||||
@@ -28,6 +28,10 @@
|
|||||||
|
|
||||||
#if CFG_TUH_ENABLED && defined(TUP_USBIP_OHCI)
|
#if CFG_TUH_ENABLED && defined(TUP_USBIP_OHCI)
|
||||||
|
|
||||||
|
#ifndef OHCI_RHPORTS
|
||||||
|
#error OHCI is enabled, but OHCI_RHPORTS is not defined.
|
||||||
|
#endif
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// INCLUDE
|
// INCLUDE
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
@@ -620,29 +624,30 @@ void hcd_int_handler(uint8_t hostid)
|
|||||||
//------------- RootHub status -------------//
|
//------------- RootHub status -------------//
|
||||||
if ( int_status & OHCI_INT_RHPORT_STATUS_CHANGE_MASK )
|
if ( int_status & OHCI_INT_RHPORT_STATUS_CHANGE_MASK )
|
||||||
{
|
{
|
||||||
uint32_t const rhport_status = OHCI_REG->rhport_status[0] & RHPORT_ALL_CHANGE_MASK;
|
for (int i = 0; i < OHCI_RHPORTS; i++)
|
||||||
|
|
||||||
// TODO dual port is not yet supported
|
|
||||||
if ( rhport_status & RHPORT_CONNECT_STATUS_CHANGE_MASK )
|
|
||||||
{
|
{
|
||||||
// TODO check if remote wake-up
|
uint32_t const rhport_status = OHCI_REG->rhport_status[i] & RHPORT_ALL_CHANGE_MASK;
|
||||||
if ( OHCI_REG->rhport_status_bit[0].current_connect_status )
|
if ( rhport_status & RHPORT_CONNECT_STATUS_CHANGE_MASK )
|
||||||
{
|
{
|
||||||
// TODO reset port immediately, without this controller will got 2-3 (debouncing connection status change)
|
// TODO check if remote wake-up
|
||||||
OHCI_REG->rhport_status[0] = RHPORT_PORT_RESET_STATUS_MASK;
|
if ( OHCI_REG->rhport_status_bit[i].current_connect_status )
|
||||||
hcd_event_device_attach(hostid, true);
|
{
|
||||||
}else
|
// TODO reset port immediately, without this controller will got 2-3 (debouncing connection status change)
|
||||||
{
|
OHCI_REG->rhport_status[i] = RHPORT_PORT_RESET_STATUS_MASK;
|
||||||
hcd_event_device_remove(hostid, true);
|
hcd_event_device_attach(i, true);
|
||||||
|
}else
|
||||||
|
{
|
||||||
|
hcd_event_device_remove(i, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( rhport_status & RHPORT_PORT_SUSPEND_CHANGE_MASK)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
OHCI_REG->rhport_status[i] = rhport_status; // acknowledge all interrupt
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( rhport_status & RHPORT_PORT_SUSPEND_CHANGE_MASK)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
OHCI_REG->rhport_status[0] = rhport_status; // acknowledge all interrupt
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------- Transfer Complete -------------//
|
//------------- Transfer Complete -------------//
|
||||||
|
|||||||
@@ -267,7 +267,7 @@ typedef volatile struct
|
|||||||
};
|
};
|
||||||
|
|
||||||
union {
|
union {
|
||||||
uint32_t rhport_status[2]; // TODO NXP OHCI controller only has 2 ports
|
uint32_t rhport_status[OHCI_RHPORTS];
|
||||||
struct {
|
struct {
|
||||||
uint32_t current_connect_status : 1;
|
uint32_t current_connect_status : 1;
|
||||||
uint32_t port_enable_status : 1;
|
uint32_t port_enable_status : 1;
|
||||||
@@ -284,11 +284,11 @@ typedef volatile struct
|
|||||||
uint32_t port_over_current_indicator_change : 1;
|
uint32_t port_over_current_indicator_change : 1;
|
||||||
uint32_t port_reset_status_change : 1;
|
uint32_t port_reset_status_change : 1;
|
||||||
uint32_t TU_RESERVED : 11;
|
uint32_t TU_RESERVED : 11;
|
||||||
}rhport_status_bit[2];
|
}rhport_status_bit[OHCI_RHPORTS];
|
||||||
};
|
};
|
||||||
}ohci_registers_t;
|
}ohci_registers_t;
|
||||||
|
|
||||||
TU_VERIFY_STATIC( sizeof(ohci_registers_t) == 0x5c, "size is not correct");
|
TU_VERIFY_STATIC( sizeof(ohci_registers_t) == (0x54 + (4 * OHCI_RHPORTS)), "size is not correct");
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user