📄 dwc_otg_cil.h
字号:
int32_t dev_endpoints;#define dwc_param_dev_endpoints_default 6 /** * Specifies the type of PHY interface to use. By default, the driver * will automatically detect the phy_type. * * 0 - Full Speed PHY * 1 - UTMI+ (default) * 2 - ULPI */ int32_t phy_type;#define DWC_PHY_TYPE_PARAM_FS 0#define DWC_PHY_TYPE_PARAM_UTMI 1#define DWC_PHY_TYPE_PARAM_ULPI 2#define dwc_param_phy_type_default DWC_PHY_TYPE_PARAM_UTMI /** * Specifies the UTMI+ Data Width. This parameter is * applicable for a PHY_TYPE of UTMI+ or ULPI. (For a ULPI * PHY_TYPE, this parameter indicates the data width between * the MAC and the ULPI Wrapper.) Also, this parameter is * applicable only if the OTG_HSPHY_WIDTH cC parameter was set * to "8 and 16 bits", meaning that the core has been * configured to work at either data path width. * * 8 or 16 bits (default 16) */ int32_t phy_utmi_width;#define dwc_param_phy_utmi_width_default 16 /** * Specifies whether the ULPI operates at double or single * data rate. This parameter is only applicable if PHY_TYPE is * ULPI. * * 0 - single data rate ULPI interface with 8 bit wide data * bus (default) * 1 - double data rate ULPI interface with 4 bit wide data * bus */ int32_t phy_ulpi_ddr;#define dwc_param_phy_ulpi_ddr_default 0 /** * Specifies whether to use the internal or external supply to * drive the vbus with a ULPI phy. */ int32_t phy_ulpi_ext_vbus;#define DWC_PHY_ULPI_INTERNAL_VBUS 0#define DWC_PHY_ULPI_EXTERNAL_VBUS 1#define dwc_param_phy_ulpi_ext_vbus_default DWC_PHY_ULPI_INTERNAL_VBUS /** * Specifies whether to use the I2Cinterface for full speed PHY. This * parameter is only applicable if PHY_TYPE is FS. * 0 - No (default) * 1 - Yes */ int32_t i2c_enable;#define dwc_param_i2c_enable_default 0 int32_t ulpi_fs_ls;#define dwc_param_ulpi_fs_ls_default 0 int32_t ts_dline;#define dwc_param_ts_dline_default 0 /** * Specifies whether dedicated transmit FIFOs are * enabled for non periodic IN endpoints in device mode * 0 - No * 1 - Yes */ int32_t en_multiple_tx_fifo;#define dwc_param_en_multiple_tx_fifo_default 1 /** Number of 4-byte words in each of the Tx FIFOs in device * mode when dynamic FIFO sizing is enabled. * 4 to 768 (default 256) */ uint32_t dev_tx_fifo_size[MAX_TX_FIFOS];#define dwc_param_dev_tx_fifo_size_default 256 /** Thresholding enable flag- * bit 0 - enable non-ISO Tx thresholding * bit 1 - enable ISO Tx thresholding * bit 2 - enable Rx thresholding */ uint32_t thr_ctl;#define dwc_param_thr_ctl_default 0 /** Thresholding length for Tx * FIFOs in 32 bit DWORDs */ uint32_t tx_thr_length;#define dwc_param_tx_thr_length_default 64 /** Thresholding length for Rx * FIFOs in 32 bit DWORDs */ uint32_t rx_thr_length;#define dwc_param_rx_thr_length_default 64} dwc_otg_core_params_t;#ifdef DEBUGstruct dwc_otg_core_if;typedef struct hc_xfer_info{ struct dwc_otg_core_if *core_if; dwc_hc_t *hc;} hc_xfer_info_t;#endif/** * The <code>dwc_otg_core_if</code> structure contains information needed to manage * the DWC_otg controller acting in either host or device mode. It * represents the programming view of the controller as a whole. */typedef struct dwc_otg_core_if{ /** Parameters that define how the core should be configured.*/ dwc_otg_core_params_t *core_params; /** Core Global registers starting at offset 000h. */ dwc_otg_core_global_regs_t *core_global_regs; /** Device-specific information */ dwc_otg_dev_if_t *dev_if; /** Host-specific information */ dwc_otg_host_if_t *host_if; /* * Set to 1 if the core PHY interface bits in USBCFG have been * initialized. */ uint8_t phy_init_done; /* * SRP Success flag, set by srp success interrupt in FS I2C mode */ uint8_t srp_success; uint8_t srp_timer_started; /* Common configuration information */ /** Power and Clock Gating Control Register */ volatile uint32_t *pcgcctl;#define DWC_OTG_PCGCCTL_OFFSET 0xE00 /** Push/pop addresses for endpoints or host channels.*/ uint32_t *data_fifo[MAX_EPS_CHANNELS];#define DWC_OTG_DATA_FIFO_OFFSET 0x1000#define DWC_OTG_DATA_FIFO_SIZE 0x1000 /** Total RAM for FIFOs (Bytes) */ uint16_t total_fifo_size; /** Size of Rx FIFO (Bytes) */ uint16_t rx_fifo_size; /** Size of Non-periodic Tx FIFO (Bytes) */ uint16_t nperio_tx_fifo_size; /** 1 if DMA is enabled, 0 otherwise. */ uint8_t dma_enable; /** 1 if DMA descriptor is enabled, 0 otherwise. */ uint8_t dma_desc_enable; /** 1 if dedicated Tx FIFOs are enabled, 0 otherwise. */ uint8_t en_multiple_tx_fifo; /** Set to 1 if multiple packets of a high-bandwidth transfer is in * process of being queued */ uint8_t queuing_high_bandwidth; /** Hardware Configuration -- stored here for convenience.*/ hwcfg1_data_t hwcfg1; hwcfg2_data_t hwcfg2; hwcfg3_data_t hwcfg3; hwcfg4_data_t hwcfg4; /** Host and Device Configuration -- stored here for convenience.*/ hcfg_data_t hcfg; dcfg_data_t dcfg; /** The operational State, during transations * (a_host>>a_peripherial and b_device=>b_host) this may not * match the core but allows the software to determine * transitions. */ uint8_t op_state; /** * Set to 1 if the HCD needs to be restarted on a session request * interrupt. This is required if no connector ID status change has * occurred since the HCD was last disconnected. */ uint8_t restart_hcd_on_session_req; /** HCD callbacks */ /** A-Device is a_host */#define A_HOST (1) /** A-Device is a_suspend */#define A_SUSPEND (2) /** A-Device is a_peripherial */#define A_PERIPHERAL (3) /** B-Device is operating as a Peripheral. */#define B_PERIPHERAL (4) /** B-Device is operating as a Host. */#define B_HOST (5) /** HCD callbacks */ struct dwc_otg_cil_callbacks *hcd_cb; /** PCD callbacks */ struct dwc_otg_cil_callbacks *pcd_cb; /** Device mode Periodic Tx FIFO Mask */ uint32_t p_tx_msk; /** Device mode Periodic Tx FIFO Mask */ uint32_t tx_msk;#ifdef DEBUG uint32_t start_hcchar_val[MAX_EPS_CHANNELS]; hc_xfer_info_t hc_xfer_info[MAX_EPS_CHANNELS]; struct timer_list hc_xfer_timer[MAX_EPS_CHANNELS]; uint32_t hfnum_7_samples; uint64_t hfnum_7_frrem_accum; uint32_t hfnum_0_samples; uint64_t hfnum_0_frrem_accum; uint32_t hfnum_other_samples; uint64_t hfnum_other_frrem_accum;#endif uint irq_pat[10]; uint irq_hcd[12]; uint irq_hlt[12]; uint xfr_done[12]; uint split[2];} dwc_otg_core_if_t;/* * The following functions support initialization of the CIL driver component * and the DWC_otg controller. */extern dwc_otg_core_if_t *dwc_otg_cil_init(const uint32_t *_reg_base_addr, dwc_otg_core_params_t *_core_params);extern void dwc_otg_cil_remove(dwc_otg_core_if_t *_core_if);extern void dwc_otg_core_init(dwc_otg_core_if_t *_core_if);extern void dwc_otg_core_host_init(dwc_otg_core_if_t *_core_if);extern void dwc_otg_core_dev_init(dwc_otg_core_if_t *_core_if);extern void dwc_otg_enable_global_interrupts( dwc_otg_core_if_t *_core_if );extern void dwc_otg_disable_global_interrupts( dwc_otg_core_if_t *_core_if );/** @name Device CIL Functions * The following functions support managing the DWC_otg controller in device * mode. *//**@{*/extern void dwc_otg_wakeup(dwc_otg_core_if_t *_core_if);extern void dwc_otg_read_setup_packet (dwc_otg_core_if_t *_core_if, uint32_t *_dest);extern uint32_t dwc_otg_get_frame_number(dwc_otg_core_if_t *_core_if);extern void dwc_otg_ep0_activate(dwc_otg_core_if_t *_core_if, dwc_ep_t *_ep);extern void dwc_otg_ep_activate(dwc_otg_core_if_t *_core_if, dwc_ep_t *_ep);extern void dwc_otg_ep_deactivate(dwc_otg_core_if_t *_core_if, dwc_ep_t *_ep);extern void dwc_otg_ep_start_transfer(dwc_otg_core_if_t *_core_if, dwc_ep_t *_ep);extern void dwc_otg_ep0_start_transfer(dwc_otg_core_if_t *_core_if, dwc_ep_t *_ep);extern void dwc_otg_ep0_continue_transfer(dwc_otg_core_if_t *_core_if, dwc_ep_t *_ep);extern void dwc_otg_ep_write_packet(dwc_otg_core_if_t *_core_if, dwc_ep_t *_ep, int _dma);extern void dwc_otg_ep_set_stall(dwc_otg_core_if_t *_core_if, dwc_ep_t *_ep);extern void dwc_otg_ep_clear_stall(dwc_otg_core_if_t *_core_if, dwc_ep_t *_ep);extern void dwc_otg_enable_device_interrupts(dwc_otg_core_if_t *_core_if);extern void dwc_otg_dump_dev_registers(dwc_otg_core_if_t *_core_if);extern void dwc_otg_dump_spram(dwc_otg_core_if_t *_core_if);void dwc_otg_dump_ep0desc(dwc_otg_core_if_t* _core_if);/**@}*//** @name Host CIL Functions * The following functions support managing the DWC_otg controller in host * mode. *//**@{*/extern void dwc_otg_hc_init(dwc_otg_core_if_t *_core_if, dwc_hc_t *_hc);extern void dwc_otg_hc_halt(dwc_otg_core_if_t *_core_if, dwc_hc_t *_hc, dwc_otg_halt_status_e _halt_status);extern void dwc_otg_hc_cleanup(dwc_otg_core_if_t *_core_if, dwc_hc_t *_hc);extern void dwc_otg_hc_start_transfer(dwc_otg_core_if_t *_core_if, dwc_hc_t *_hc);extern int dwc_otg_hc_continue_transfer(dwc_otg_core_if_t *_core_if, dwc_hc_t *_hc);extern void dwc_otg_hc_do_ping(dwc_otg_core_if_t *_core_if, dwc_hc_t *_hc);extern void dwc_otg_hc_write_packet(dwc_otg_core_if_t *_core_if, dwc_hc_t *_hc);extern void dwc_otg_enable_host_interrupts(dwc_otg_core_if_t *_core_if);extern void dwc_otg_disable_host_interrupts(dwc_otg_core_if_t *_core_if);/** * This function Reads HPRT0 in preparation to modify. It keeps the * WC bits 0 so that if they are read as 1, they won't clear when you * write it back */static inline uint32_t dwc_otg_read_hprt0(dwc_otg_core_if_t *_core_if){ hprt0_data_t hprt0; hprt0.d32 = dwc_read_reg32(_core_if->host_if->hprt0); hprt0.b.prtena = 0; hprt0.b.prtconndet = 0; hprt0.b.prtenchng = 0; hprt0.b.prtovrcurrchng = 0; return hprt0.d32;}extern void dwc_otg_dump_host_registers(dwc_otg_core_if_t *_core_if);/**@}*//** @name Common CIL Functions * The following functions support managing the DWC_otg controller in either * device or host mode. *//**@{*/extern void dwc_otg_read_packet(dwc_otg_core_if_t *core_if, uint8_t *dest, uint16_t bytes);extern void dwc_otg_dump_global_registers(dwc_otg_core_if_t *_core_if);extern void dwc_otg_flush_tx_fifo( dwc_otg_core_if_t *_core_if, const int _num );extern void dwc_otg_flush_rx_fifo( dwc_otg_core_if_t *_core_if );extern void dwc_otg_core_reset( dwc_otg_core_if_t *_core_if );/** * This function returns the Core Interrupt register. */static inline uint32_t dwc_otg_read_core_intr(dwc_otg_core_if_t *_core_if){#if 0 return (dwc_read_reg32(&_core_if->core_global_regs->gintsts) & dwc_read_reg32(&_core_if->core_global_regs->gintmsk));#else return (readl(S3C_UDC_OTG_GINTSTS) & readl(S3C_UDC_OTG_GINTMSK));#endif}/** * This function returns the OTG Interrupt register. */static inline uint32_t dwc_otg_read_otg_intr (dwc_otg_core_if_t *_core_if){ return (dwc_read_reg32 (&_core_if->core_global_regs->gotgint));}/** * This function reads the Device All Endpoints Interrupt register and * returns the IN endpoint interrupt bits. */static inline uint32_t dwc_otg_read_dev_all_in_ep_intr(dwc_otg_core_if_t *_core_if){ uint32_t v; v = dwc_read_reg32(&_core_if->dev_if->dev_global_regs->daint) & dwc_read_reg32(&_core_if->dev_if->dev_global_regs->daintmsk); return (v & 0xffff);}/** * This function reads the Device All Endpoints Interrupt register and * returns the OUT endpoint interrupt bits. */static inline uint32_t dwc_otg_read_dev_all_out_ep_intr(dwc_otg_core_if_t *_core_if){ uint32_t v; v = dwc_read_reg32(&_core_if->dev_if->dev_global_regs->daint) & dwc_read_reg32(&_core_if->dev_if->dev_global_regs->daintmsk); return ((v & 0xffff0000) >> 16);}/** * This function returns the Device IN EP Interrupt register */static inline uint32_t dwc_otg_read_dev_in_ep_intr(dwc_otg_core_if_t *_core_if, dwc_ep_t *_ep){ dwc_otg_dev_if_t *dev_if = _core_if->dev_if; uint32_t v, msk, emp; msk = dwc_read_reg32(&dev_if->dev_global_regs->diepmsk); emp = dwc_read_reg32(&dev_if->dev_global_regs->dtknqr4_fifoemptymsk); msk |= ((emp >> _ep->num) & 0x1) << 7; v = dwc_read_reg32(&dev_if->in_ep_regs[_ep->num]->diepint) & msk;/* dwc_otg_dev_if_t *dev_if = _core_if->dev_if; uint32_t v; v = dwc_read_reg32(&dev_if->in_ep_regs[_ep->num]->diepint) & dwc_read_reg32(&dev_if->dev_global_regs->diepmsk);*/ return v;}/** * This function returns the Device OUT EP Interrupt register */static inline uint32_t dwc_otg_read_dev_out_ep_intr(dwc_otg_core_if_t *_core_if, dwc_ep_t *_ep){ dwc_otg_dev_if_t *dev_if = _core_if->dev_if; uint32_t v; v = dwc_read_reg32( &dev_if->out_ep_regs[_ep->num]->doepint) & dwc_read_reg32(&dev_if->dev_global_regs->doepmsk); return v;}/** * This function returns the Host All Channel Interrupt register */static inline uint32_t dwc_otg_read_host_all_channels_intr (dwc_otg_core_if_t *_core_if){ return (dwc_read_reg32 (&_core_if->host_if->host_global_regs->haint));}static inline uint32_t dwc_otg_read_host_channel_intr (dwc_otg_core_if_t *_core_if, dwc_hc_t *_hc){ return (dwc_read_reg32 (&_core_if->host_if->hc_regs[_hc->hc_num]->hcint));}/** * This function returns the mode of the operation, host or device. * * @return 0 - Device Mode, 1 - Host Mode */static inline uint32_t dwc_otg_mode(dwc_otg_core_if_t *_core_if){ return (dwc_read_reg32( &_core_if->core_global_regs->gintsts ) & 0x1);}static inline uint8_t dwc_otg_is_device_mode(dwc_otg_core_if_t *_core_if){ return (dwc_otg_mode(_core_if) != DWC_HOST_MODE);}static inline uint8_t dwc_otg_is_host_mode(dwc_otg_core_if_t *_core_if){ return (dwc_otg_mode(_core_if) == DWC_HOST_MODE);}extern int32_t dwc_otg_handle_common_intr( dwc_otg_core_if_t *_core_if, uint sts);/**@}*//** * DWC_otg CIL callback structure. This structure allows the HCD and * PCD to register functions used for starting and stopping the PCD * and HCD for role change on for a DRD. */typedef struct dwc_otg_cil_callbacks{ /** Start function for role change */ int (*start) (void *_p); /** Stop Function for role change */ int (*stop) (void *_p); /** Disconnect Function for role change */ int (*disconnect) (void *_p); /** Resume/Remote wakeup Function */ int (*resume_wakeup) (void *_p); /** Suspend function */ int (*suspend) (void *_p); /** Session Start (SRP) */ int (*session_start) (void *_p); /** Pointer passed to start() and stop() */ void *p;} dwc_otg_cil_callbacks_t;extern void dwc_otg_cil_register_pcd_callbacks( dwc_otg_core_if_t *_core_if, dwc_otg_cil_callbacks_t *_cb, void *_p);extern void dwc_otg_cil_register_hcd_callbacks( dwc_otg_core_if_t *_core_if, dwc_otg_cil_callbacks_t *_cb, void *_p);#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -