1 /* 2 * Interface for HCD 3 * 4 * This file holds prototypes that must be implemented by HCD 5 * and call that should be used for asynchronous events 6 * (interrupts, UBR submits, hub events, ...) 7 */ 8 9 #ifndef _HCD_INTERFACE_H_ 10 #define _HCD_INTERFACE_H_ 11 12 #include <usbd/hcd_common.h> 13 14 15 /*===========================================================================* 16 * HCD additional defines * 17 *===========================================================================*/ 18 /* Can be returned by 'read_data' to indicate error */ 19 #define HCD_READ_ERR -1 20 21 /* Possible states of USB device address */ 22 typedef enum { 23 24 HCD_ADDR_AVAILABLE = 0, /* Default for reset */ 25 HCD_ADDR_USED 26 } 27 hcd_addr_state; 28 29 30 /*===========================================================================* 31 * HCD driver structure to be filled * 32 *===========================================================================*/ 33 struct hcd_driver_state { 34 /* Standard USB controller procedures */ 35 void (*setup_device) (void *, hcd_reg1, hcd_reg1, 36 hcd_datatog *, hcd_datatog *); 37 int (*reset_device) (void *, hcd_speed *); 38 void (*setup_stage) (void *, hcd_ctrlrequest *); 39 void (*rx_stage) (void *, hcd_datarequest *); 40 void (*tx_stage) (void *, hcd_datarequest *); 41 void (*in_data_stage) (void *); 42 void (*out_data_stage) (void *); 43 void (*in_status_stage) (void *); 44 void (*out_status_stage) (void *); 45 int (*read_data) (void *, hcd_reg1 *, hcd_reg1); 46 int (*check_error) (void *, hcd_transfer, hcd_reg1, 47 hcd_direction); 48 49 /* Controller's private data (like mapped registers) */ 50 void * private_data; 51 52 /* TODO: Only one port for each driver */ 53 /* Represents device attached to USB port handled by this driver */ 54 hcd_device_state * port_device; 55 56 /* Array to hold information of unused device addresses */ 57 hcd_addr_state dev_addr[HCD_TOTAL_ADDR]; 58 }; 59 60 61 /*===========================================================================* 62 * HCD event handling routine * 63 *===========================================================================*/ 64 /* Handle asynchronous event */ 65 void hcd_handle_event(hcd_device_state *, hcd_event, hcd_reg1); 66 67 /* This resolves port's device structure for given driver and event */ 68 void hcd_update_port(hcd_driver_state *, hcd_event); 69 70 71 #endif /* !_HCD_INTERFACE_H_ */ 72