summaryrefslogtreecommitdiff
path: root/tinyusb/host/ehci
diff options
context:
space:
mode:
authorhathach <[email protected]>2013-03-12 16:42:19 +0700
committerhathach <[email protected]>2013-03-12 16:42:19 +0700
commit80facf6f2ec06b3c0c6cb1061ea27d75c26557d2 (patch)
tree93fbddf37daab714b3f8913292883a6238506e64 /tinyusb/host/ehci
parentc6b220c32750042d3ae7dca379af24b274696b16 (diff)
add isr api for usbh_hcd
- void usbh_device_plugged_isr(uint8_t hostid, tusb_speed_t speed); - void usbh_device_unplugged_isr(uint8_t hostid); implement port_connect_status_isr
Diffstat (limited to 'tinyusb/host/ehci')
-rw-r--r--tinyusb/host/ehci/ehci.c65
-rw-r--r--tinyusb/host/ehci/ehci.h11
2 files changed, 61 insertions, 15 deletions
diff --git a/tinyusb/host/ehci/ehci.c b/tinyusb/host/ehci/ehci.c
index 2fefed23e..6caf1e71c 100644
--- a/tinyusb/host/ehci/ehci.c
+++ b/tinyusb/host/ehci/ehci.c
@@ -135,6 +135,32 @@ tusb_error_t hcd_init(void)
}
//--------------------------------------------------------------------+
+// PORT API
+//--------------------------------------------------------------------+
+void hcd_port_reset(uint8_t hostid)
+{
+ ehci_registers_t* const regs = get_operational_register(hostid);
+
+ regs->portsc_bit.port_enable = 0; // disable port before reset
+ regs->portsc_bit.port_reset = 1;
+
+#ifndef _TEST_
+ // NXP specific, port reset will automatically be 0 when reset sequence complete
+ while( regs->portsc_bit.port_reset || !regs->portsc_bit.port_enable){}
+#endif
+}
+
+bool hcd_port_connect_status(uint8_t hostid)
+{
+ return false;
+}
+
+tusb_speed_t hcd_port_speed(uint8_t hostid)
+{
+ return TUSB_SPEED_HIGH;
+}
+
+//--------------------------------------------------------------------+
// EHCI Interrupt Handler
//--------------------------------------------------------------------+
static inline uint8_t get_qhd_index(ehci_qhd_t * p_qhd) ATTR_ALWAYS_INLINE ATTR_PURE;
@@ -143,6 +169,22 @@ static inline uint8_t get_qhd_index(ehci_qhd_t * p_qhd)
return p_qhd - ehci_data.device[p_qhd->device_address].qhd;
}
+
+void port_connect_status_isr(uint8_t hostid)
+{
+ ehci_registers_t* const regs = get_operational_register(hostid);
+
+ if (regs->portsc_bit.current_connect_status) // device plugged
+ {
+ hcd_port_reset(hostid);
+ usbh_device_plugged_isr(hostid, regs->portsc_bit.nxp_port_speed); // NXP specific port speed
+ }else // device unplugged
+ {
+// usbh_device_
+ }
+
+}
+
void async_list_process_isr(ehci_qhd_t * const async_head, ehci_registers_t * const regs)
{
ehci_qhd_t *p_qhd = async_head;
@@ -183,7 +225,6 @@ void async_list_process_isr(ehci_qhd_t * const async_head, ehci_registers_t * co
}
//------------- Host Controller Driver's Interrupt Handler -------------//
-// TODO this isr is not properly go through TDD
void hcd_isr(uint8_t hostid)
{
ehci_registers_t* const regs = get_operational_register(hostid);
@@ -211,7 +252,14 @@ void hcd_isr(uint8_t hostid)
if (int_status & EHCI_INT_MASK_PORT_CHANGE)
{
-// port_status_change_isr(h)
+ printf("%s %d\n", __PRETTY_FUNCTION__, __LINE__);
+ if (regs->portsc_bit.connect_status_change)
+ {
+ printf("%s %d\n", __PRETTY_FUNCTION__, __LINE__);
+ port_connect_status_isr(hostid);
+ }
+
+ regs->portsc |= EHCI_PORTSC_MASK_ALL; // Acknowledge all the change bit in portsc
}
if (int_status & EHCI_INT_MASK_ASYNC_ADVANCE)
@@ -324,19 +372,6 @@ tusb_error_t hcd_controller_reset(uint8_t hostid)
}
//--------------------------------------------------------------------+
-// PORT API
-//--------------------------------------------------------------------+
-bool hcd_port_connect_status(uint8_t core_id)
-{
- return false;
-}
-
-tusb_speed_t hcd_port_speed(uint8_t core_id)
-{
- return TUSB_SPEED_HIGH;
-}
-
-//--------------------------------------------------------------------+
// PIPE API
//--------------------------------------------------------------------+
static void init_qhd(ehci_qhd_t *p_qhd, uint8_t dev_addr, uint16_t max_packet_size, uint8_t endpoint_addr, uint8_t xfer_type);
diff --git a/tinyusb/host/ehci/ehci.h b/tinyusb/host/ehci/ehci.h
index cd03c2b96..bceb78e74 100644
--- a/tinyusb/host/ehci/ehci.h
+++ b/tinyusb/host/ehci/ehci.h
@@ -327,6 +327,17 @@ enum ehci_usbcmd_pos_ {
EHCI_USBCMD_POS_INTERRUPT_THRESHOLD = 16
};
+enum ehci_portsc_change_mask_{
+ EHCI_PORTSC_MASK_CONNECT_STATUS_CHANGE = BIT_(1),
+ EHCI_PORTSC_MASK_PORT_ENABLE_CHAGNE = BIT_(3),
+ EHCI_PORTSC_MASK_OVER_CURRENT_CHANGE = BIT_(5),
+
+ EHCI_PORTSC_MASK_ALL =
+ EHCI_PORTSC_MASK_CONNECT_STATUS_CHANGE |
+ EHCI_PORTSC_MASK_PORT_ENABLE_CHAGNE |
+ EHCI_PORTSC_MASK_OVER_CURRENT_CHANGE
+};
+
typedef volatile struct {
union {
uint32_t usb_cmd ; ///< The Command Register indicates the command to be executed by the serial bus host controller. Writing to the register causes a command to be executed