Main Page | Data Structures | File List | Data Fields | Globals | Related Pages

dwc_otg_cil.h

Go to the documentation of this file.
00001 /* ==========================================================================
00002  * $File: //dwh/usb_iip/dev/software/otg/linux/drivers/dwc_otg_cil.h $
00003  * $Revision: #122 $
00004  * $Date: 2011/10/24 $
00005  * $Change: 1871160 $
00006  *
00007  * Synopsys HS OTG Linux Software Driver and documentation (hereinafter,
00008  * "Software") is an Unsupported proprietary work of Synopsys, Inc. unless
00009  * otherwise expressly agreed to in writing between Synopsys and you.
00010  *
00011  * The Software IS NOT an item of Licensed Software or Licensed Product under
00012  * any End User Software License Agreement or Agreement for Licensed Product
00013  * with Synopsys or any supplement thereto. You are permitted to use and
00014  * redistribute this Software in source and binary forms, with or without
00015  * modification, provided that redistributions of source code must retain this
00016  * notice. You may not view, use, disclose, copy or distribute this file or
00017  * any information contained herein except pursuant to this license grant from
00018  * Synopsys. If you do not agree with this notice, including the disclaimer
00019  * below, then you are not authorized to use the Software.
00020  *
00021  * THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS" BASIS
00022  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00023  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00024  * ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS BE LIABLE FOR ANY DIRECT,
00025  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00026  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00027  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00028  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00029  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00030  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
00031  * DAMAGE.
00032  * ========================================================================== */
00033 
00034 #if !defined(__DWC_CIL_H__)
00035 #define __DWC_CIL_H__
00036 
00037 #include "dwc_list.h"
00038 #include "dwc_otg_dbg.h"
00039 #include "dwc_otg_regs.h"
00040 
00041 #include "dwc_otg_core_if.h"
00042 #include "dwc_otg_adp.h"
00043 
00049 #ifdef DWC_UTE_CFI
00050 
00051 #define MAX_DMA_DESCS_PER_EP    256
00052 
00056 typedef enum _data_buffer_mode {
00057         BM_STANDARD = 0,        /* data buffer is in normal mode */
00058         BM_SG = 1,              /* data buffer uses the scatter/gather mode */
00059         BM_CONCAT = 2,          /* data buffer uses the concatenation mode */
00060         BM_CIRCULAR = 3,        /* data buffer uses the circular DMA mode */
00061         BM_ALIGN = 4            /* data buffer is in buffer alignment mode */
00062 } data_buffer_mode_e;
00063 #endif //DWC_UTE_CFI
00064 
00067 #define OTG_CORE_REV_2_60a      0x4F54260A
00068 #define OTG_CORE_REV_2_71a      0x4F54271A
00069 #define OTG_CORE_REV_2_72a      0x4F54272A
00070 #define OTG_CORE_REV_2_80a      0x4F54280A
00071 #define OTG_CORE_REV_2_81a      0x4F54281A
00072 #define OTG_CORE_REV_2_90a      0x4F54290A
00073 #define OTG_CORE_REV_2_91a      0x4F54291A
00074 #define OTG_CORE_REV_2_92a      0x4F54292A
00075 #define OTG_CORE_REV_2_93a      0x4F54293A
00076 #define OTG_CORE_REV_2_94a      0x4F54294A
00077 
00081 typedef struct iso_pkt_info {
00082         uint32_t offset;
00083         uint32_t length;
00084         int32_t status;
00085 } iso_pkt_info_t;
00086 
00092 typedef struct dwc_ep {
00094         uint8_t num;
00096         unsigned is_in:1;
00098         unsigned active:1;
00099 
00103         unsigned tx_fifo_num:4;
00105         unsigned type:2;
00106 #define DWC_OTG_EP_TYPE_CONTROL    0
00107 #define DWC_OTG_EP_TYPE_ISOC       1
00108 #define DWC_OTG_EP_TYPE_BULK       2
00109 #define DWC_OTG_EP_TYPE_INTR       3
00110 
00112         unsigned data_pid_start:1;
00114         unsigned even_odd_frame:1;
00116         unsigned maxpacket:11;
00117 
00119         uint32_t maxxfer;
00120 
00129         dwc_dma_t dma_addr;
00130 
00131         dwc_dma_t dma_desc_addr;
00132         dwc_otg_dev_dma_desc_t *desc_addr;
00133 
00134         uint8_t *start_xfer_buff;
00136         uint8_t *xfer_buff;
00138         unsigned xfer_len:19;
00140         unsigned xfer_count:19;
00142         unsigned sent_zlp:1;
00144         unsigned total_len:19;
00145 
00147         unsigned stall_clear_flag:1;
00148 
00149 #ifdef DWC_UTE_CFI
00150         /* The buffer mode */
00151         data_buffer_mode_e buff_mode;
00152 
00153         /* The chain of DMA descriptors.
00154          * MAX_DMA_DESCS_PER_EP will be allocated for each active EP.
00155          */
00156         dwc_otg_dma_desc_t *descs;
00157 
00158         /* The DMA address of the descriptors chain start */
00159         dma_addr_t descs_dma_addr;
00161         uint32_t cfi_req_len;
00162 #endif                          //DWC_UTE_CFI
00163 
00165 #define MAX_DMA_DESC_CNT 256
00166 
00167         uint32_t desc_cnt;
00168         
00170         uint32_t bInterval;
00172         uint32_t frame_num;
00174         uint8_t frm_overrun;
00175 
00176 #ifdef DWC_UTE_PER_IO
00177 
00178         uint32_t xiso_frame_num;
00180         uint32_t xiso_bInterval;
00182         int xiso_active_xfers;
00183         int xiso_queued_xfers;
00184 #endif
00185 #ifdef DWC_EN_ISOC
00186 
00191         dwc_dma_t dma_addr0;
00192         dwc_dma_t dma_addr1;
00193 
00194         dwc_dma_t iso_dma_desc_addr;
00195         dwc_otg_dev_dma_desc_t *iso_desc_addr;
00196 
00198         uint8_t *xfer_buff0;
00199         uint8_t *xfer_buff1;
00200 
00202         uint32_t proc_buf_num;
00204         uint32_t buf_proc_intrvl;
00206         uint32_t data_per_frame;
00207 
00208         /* todo - pattern data support is to be implemented in the future */
00210         uint32_t data_pattern_frame;
00212         uint32_t sync_frame;
00213 
00215         uint32_t bInterval;
00217         uint32_t pkt_per_frm;
00219         uint32_t next_frame;
00221         uint32_t pkt_cnt;
00223         iso_pkt_info_t *pkt_info;
00225         uint32_t cur_pkt;
00227         uint8_t *cur_pkt_addr;
00229         uint32_t cur_pkt_dma_addr;
00230 #endif                          /* DWC_EN_ISOC */
00231 
00233 } dwc_ep_t;
00234 
00235 /*
00236  * Reasons for halting a host channel.
00237  */
00238 typedef enum dwc_otg_halt_status {
00239         DWC_OTG_HC_XFER_NO_HALT_STATUS,
00240         DWC_OTG_HC_XFER_COMPLETE,
00241         DWC_OTG_HC_XFER_URB_COMPLETE,
00242         DWC_OTG_HC_XFER_ACK,
00243         DWC_OTG_HC_XFER_NAK,
00244         DWC_OTG_HC_XFER_NYET,
00245         DWC_OTG_HC_XFER_STALL,
00246         DWC_OTG_HC_XFER_XACT_ERR,
00247         DWC_OTG_HC_XFER_FRAME_OVERRUN,
00248         DWC_OTG_HC_XFER_BABBLE_ERR,
00249         DWC_OTG_HC_XFER_DATA_TOGGLE_ERR,
00250         DWC_OTG_HC_XFER_AHB_ERR,
00251         DWC_OTG_HC_XFER_PERIODIC_INCOMPLETE,
00252         DWC_OTG_HC_XFER_URB_DEQUEUE
00253 } dwc_otg_halt_status_e;
00254 
00260 typedef struct dwc_hc {
00262         uint8_t hc_num;
00263 
00265         unsigned dev_addr:7;
00266 
00268         unsigned ep_num:4;
00269 
00271         unsigned ep_is_in:1;
00272 
00280         unsigned speed:2;
00281 #define DWC_OTG_EP_SPEED_LOW    0
00282 #define DWC_OTG_EP_SPEED_FULL   1
00283 #define DWC_OTG_EP_SPEED_HIGH   2
00284 
00293         unsigned ep_type:2;
00294 
00296         unsigned max_packet:11;
00297 
00306         unsigned data_pid_start:2;
00307 #define DWC_OTG_HC_PID_DATA0 0
00308 #define DWC_OTG_HC_PID_DATA2 1
00309 #define DWC_OTG_HC_PID_DATA1 2
00310 #define DWC_OTG_HC_PID_MDATA 3
00311 #define DWC_OTG_HC_PID_SETUP 3
00312 
00314         unsigned multi_count:2;
00315 
00320         uint8_t *xfer_buff;
00325         dwc_dma_t align_buff;
00327         uint32_t xfer_len;
00329         uint32_t xfer_count;
00331         uint16_t start_pkt_count;
00332 
00337         uint8_t xfer_started;
00338 
00343         uint8_t do_ping;
00344 
00349         uint8_t error_state;
00350 
00357         uint8_t halt_on_queue;
00358 
00363         uint8_t halt_pending;
00364 
00368         dwc_otg_halt_status_e halt_status;
00369 
00370         /*
00371          * Split settings for the host channel
00372          */
00373         uint8_t do_split;                  
00374         uint8_t complete_split;    
00375         uint8_t hub_addr;                  
00377         uint8_t port_addr;                 
00384         uint8_t xact_pos;
00385 
00387         uint8_t short_read;
00388 
00393         uint8_t requests;
00394 
00398         struct dwc_otg_qh *qh;
00399 
00403          DWC_CIRCLEQ_ENTRY(dwc_hc) hc_list_entry;
00404 
00409         uint16_t ntd;
00410 
00412         dwc_dma_t desc_list_addr;
00413 
00415         uint8_t schinfo;
00416 
00418 } dwc_hc_t;
00419 
00424 typedef struct dwc_otg_core_params {
00425         int32_t opt;
00426 
00434         int32_t otg_cap;
00435 
00443         int32_t dma_enable;
00444 
00452         int32_t dma_desc_enable;
00456         int32_t dma_burst_size; /* Translate this to GAHBCFG values */
00457 
00466         int32_t speed;
00472         int32_t host_support_fs_ls_low_power;
00473 
00482         int32_t host_ls_low_power_phy_clk;
00483 
00488         int32_t enable_dynamic_fifo;
00489 
00496         int32_t data_fifo_size;
00497 
00502         int32_t dev_rx_fifo_size;
00503 
00508         int32_t dev_nperio_tx_fifo_size;
00509 
00514         uint32_t dev_perio_tx_fifo_size[MAX_PERIO_FIFOS];
00515 
00520         int32_t host_rx_fifo_size;
00521 
00526         int32_t host_nperio_tx_fifo_size;
00527 
00532         int32_t host_perio_tx_fifo_size;
00533 
00537         int32_t max_transfer_size;
00538 
00542         int32_t max_packet_count;
00543 
00548         int32_t host_channels;
00549 
00556         int32_t dev_endpoints;
00557 
00566         int32_t phy_type;
00567 
00579         int32_t phy_utmi_width;
00580 
00591         int32_t phy_ulpi_ddr;
00592 
00597         int32_t phy_ulpi_ext_vbus;
00598 
00605         int32_t i2c_enable;
00606 
00607         int32_t ulpi_fs_ls;
00608 
00609         int32_t ts_dline;
00610 
00617         int32_t en_multiple_tx_fifo;
00618 
00623         uint32_t dev_tx_fifo_size[MAX_TX_FIFOS];
00624 
00630         uint32_t thr_ctl;
00631 
00635         uint32_t tx_thr_length;
00636 
00640         uint32_t rx_thr_length;
00641 
00645         int32_t lpm_enable;
00646 
00652         int32_t pti_enable;
00653 
00659         int32_t mpi_enable;
00660 
00665         int32_t ic_usb_cap;
00666 
00673         int32_t ahb_thr_ratio;
00674 
00679         int32_t adp_supp_enable;
00680 
00685         int32_t reload_ctl;
00686 
00691         int32_t dev_out_nak;
00692 
00699         int32_t cont_on_bna;
00700 
00707         int32_t ahb_single;
00708 
00714         int32_t power_down;
00715 
00720         int32_t otg_ver;
00721 
00722 } dwc_otg_core_params_t;
00723 
00724 #ifdef DEBUG
00725 struct dwc_otg_core_if;
00726 typedef struct hc_xfer_info {
00727         struct dwc_otg_core_if *core_if;
00728         dwc_hc_t *hc;
00729 } hc_xfer_info_t;
00730 #endif
00731 
00732 typedef struct ep_xfer_info {
00733         struct dwc_otg_core_if *core_if;
00734         dwc_ep_t *ep;
00735         uint8_t state;
00736 } ep_xfer_info_t;
00737 /*
00738  * Device States
00739  */
00740 typedef enum dwc_otg_lx_state {
00742         DWC_OTG_L0,
00744         DWC_OTG_L1,
00746         DWC_OTG_L2,
00748         DWC_OTG_L3
00749 } dwc_otg_lx_state_e;
00750 
00751 struct dwc_otg_global_regs_backup {
00752         uint32_t gotgctl_local;
00753         uint32_t gintmsk_local;
00754         uint32_t gahbcfg_local;
00755         uint32_t gusbcfg_local;
00756         uint32_t grxfsiz_local;
00757         uint32_t gnptxfsiz_local;
00758 #ifdef CONFIG_USB_DWC_OTG_LPM
00759         uint32_t glpmcfg_local;
00760 #endif
00761         uint32_t gi2cctl_local;
00762         uint32_t hptxfsiz_local;
00763         uint32_t pcgcctl_local;
00764         uint32_t gdfifocfg_local;
00765         uint32_t dtxfsiz_local[MAX_EPS_CHANNELS];
00766         uint32_t gpwrdn_local;
00767 };
00768 
00769 struct dwc_otg_host_regs_backup {
00770         uint32_t hcfg_local;
00771         uint32_t haintmsk_local;
00772         uint32_t hcintmsk_local[MAX_EPS_CHANNELS];
00773         uint32_t hprt0_local;
00774         uint32_t hfir_local;
00775 };
00776 
00777 struct dwc_otg_dev_regs_backup {
00778         uint32_t dcfg;
00779         uint32_t dctl;
00780         uint32_t daintmsk;
00781         uint32_t diepmsk;
00782         uint32_t doepmsk;
00783         uint32_t diepctl[MAX_EPS_CHANNELS];
00784         uint32_t dieptsiz[MAX_EPS_CHANNELS];
00785         uint32_t diepdma[MAX_EPS_CHANNELS];
00786 };
00792 struct dwc_otg_core_if {
00794         dwc_otg_core_params_t *core_params;
00795 
00797         dwc_otg_core_global_regs_t *core_global_regs;
00798 
00800         dwc_otg_dev_if_t *dev_if;
00802         dwc_otg_host_if_t *host_if;
00803 
00805         uint32_t snpsid;
00806 
00807         /*
00808          * Set to 1 if the core PHY interface bits in USBCFG have been
00809          * initialized.
00810          */
00811         uint8_t phy_init_done;
00812 
00813         /*
00814          * SRP Success flag, set by srp success interrupt in FS I2C mode
00815          */
00816         uint8_t srp_success;
00817         uint8_t srp_timer_started;
00820         dwc_timer_t *srp_timer;
00821 
00822 #ifdef DWC_DEV_SRPCAP
00823         /* This timer is needed to power on the hibernated host core if SRP is not
00824          * initiated on connected SRP capable device for limited period of time
00825          */
00826         uint8_t pwron_timer_started;
00827         dwc_timer_t *pwron_timer;
00828 #endif
00829         /* Common configuration information */
00831         volatile uint32_t *pcgcctl;
00832 #define DWC_OTG_PCGCCTL_OFFSET 0xE00
00833 
00835         uint32_t *data_fifo[MAX_EPS_CHANNELS];
00836 #define DWC_OTG_DATA_FIFO_OFFSET 0x1000
00837 #define DWC_OTG_DATA_FIFO_SIZE 0x1000
00838 
00840         uint16_t total_fifo_size;
00842         uint16_t rx_fifo_size;
00844         uint16_t nperio_tx_fifo_size;
00845 
00847         uint8_t dma_enable;
00848 
00850         uint8_t dma_desc_enable;
00851 
00853         uint8_t pti_enh_enable;
00854 
00856         uint8_t multiproc_int_enable;
00857 
00859         uint8_t en_multiple_tx_fifo;
00860 
00863         uint8_t queuing_high_bandwidth;
00864 
00866         hwcfg1_data_t hwcfg1;
00867         hwcfg2_data_t hwcfg2;
00868         hwcfg3_data_t hwcfg3;
00869         hwcfg4_data_t hwcfg4;
00870         fifosize_data_t hptxfsiz;
00871 
00873         hcfg_data_t hcfg;
00874         dcfg_data_t dcfg;
00875 
00881         uint8_t op_state;
00882 
00888         uint8_t restart_hcd_on_session_req;
00889 
00892 #define A_HOST          (1)
00893 
00894 #define A_SUSPEND       (2)
00895 
00896 #define A_PERIPHERAL    (3)
00897 
00898 #define B_PERIPHERAL    (4)
00899 
00900 #define B_HOST          (5)
00901 
00903         struct dwc_otg_cil_callbacks *hcd_cb;
00905         struct dwc_otg_cil_callbacks *pcd_cb;
00906 
00908         uint32_t p_tx_msk;
00910         uint32_t tx_msk;
00911 
00913         dwc_workq_t *wq_otg;
00914 
00916         dwc_timer_t *wkp_timer;
00918         uint32_t start_doeptsiz_val[MAX_EPS_CHANNELS];
00919         ep_xfer_info_t ep_xfer_info[MAX_EPS_CHANNELS];
00920         dwc_timer_t *ep_xfer_timer[MAX_EPS_CHANNELS];
00921 #ifdef DEBUG
00922         uint32_t start_hcchar_val[MAX_EPS_CHANNELS];
00923 
00924         hc_xfer_info_t hc_xfer_info[MAX_EPS_CHANNELS];
00925         dwc_timer_t *hc_xfer_timer[MAX_EPS_CHANNELS];
00926 
00927         uint32_t hfnum_7_samples;
00928         uint64_t hfnum_7_frrem_accum;
00929         uint32_t hfnum_0_samples;
00930         uint64_t hfnum_0_frrem_accum;
00931         uint32_t hfnum_other_samples;
00932         uint64_t hfnum_other_frrem_accum;
00933 #endif
00934 
00935 #ifdef DWC_UTE_CFI
00936         uint16_t pwron_rxfsiz;
00937         uint16_t pwron_gnptxfsiz;
00938         uint16_t pwron_txfsiz[15];
00939 
00940         uint16_t init_rxfsiz;
00941         uint16_t init_gnptxfsiz;
00942         uint16_t init_txfsiz[15];
00943 #endif
00944 
00946         dwc_otg_lx_state_e lx_state;
00947 
00949         struct dwc_otg_global_regs_backup *gr_backup;
00951         struct dwc_otg_host_regs_backup *hr_backup;
00953         struct dwc_otg_dev_regs_backup *dr_backup;
00954 
00956         uint32_t power_down;
00957 
00959         uint32_t adp_enable;
00960 
00962         dwc_otg_adp_t adp;
00963 
00965         int hibernation_suspend;
00966 
00968         uint32_t otg_ver;
00969 
00971         uint8_t otg_sts;
00972 
00974         dwc_spinlock_t *lock;
00975 
00978         uint8_t start_predict;
00979 
00982         uint8_t nextep_seq[MAX_EPS_CHANNELS];
00983 
00985         uint8_t first_in_nextep_seq;
00986 
00988         uint32_t frame_num; 
00989 
00990 };
00991 
00992 #ifdef DEBUG
00993 /*
00994  * This function is called when transfer is timed out.
00995  */
00996 extern void hc_xfer_timeout(void *ptr);
00997 #endif
00998 
00999 /*
01000  * This function is called when transfer is timed out on endpoint.
01001  */
01002 extern void ep_xfer_timeout(void *ptr);
01003 
01004 /*
01005  * The following functions are functions for works
01006  * using during handling some interrupts
01007  */
01008 extern void w_conn_id_status_change(void *p);
01009 
01010 extern void w_wakeup_detected(void *p);
01011 
01013 extern int dwc_otg_save_global_regs(dwc_otg_core_if_t * core_if);
01015 extern int dwc_otg_save_dev_regs(dwc_otg_core_if_t * core_if);
01017 extern int dwc_otg_save_host_regs(dwc_otg_core_if_t * core_if);
01019 extern int dwc_otg_restore_global_regs(dwc_otg_core_if_t * core_if);
01021 extern int dwc_otg_restore_host_regs(dwc_otg_core_if_t * core_if, int reset);
01023 extern int dwc_otg_restore_dev_regs(dwc_otg_core_if_t * core_if,
01024                                     int rem_wakeup);
01025 extern int restore_lpm_i2c_regs(dwc_otg_core_if_t * core_if);
01026 extern int restore_essential_regs(dwc_otg_core_if_t * core_if, int rmode,
01027                                   int is_host);
01028 
01029 extern int dwc_otg_host_hibernation_restore(dwc_otg_core_if_t * core_if,
01030                                             int restore_mode, int reset);
01031 extern int dwc_otg_device_hibernation_restore(dwc_otg_core_if_t * core_if,
01032                                               int rem_wakeup, int reset);
01033 
01034 /*
01035  * The following functions support initialization of the CIL driver component
01036  * and the DWC_otg controller.
01037  */
01038 extern void dwc_otg_core_host_init(dwc_otg_core_if_t * _core_if);
01039 extern void dwc_otg_core_dev_init(dwc_otg_core_if_t * _core_if);
01040 
01046 extern void dwc_otg_wakeup(dwc_otg_core_if_t * _core_if);
01047 extern void dwc_otg_read_setup_packet(dwc_otg_core_if_t * _core_if,
01048                                       uint32_t * _dest);
01049 extern uint32_t dwc_otg_get_frame_number(dwc_otg_core_if_t * _core_if);
01050 extern void dwc_otg_ep0_activate(dwc_otg_core_if_t * _core_if, dwc_ep_t * _ep);
01051 extern void dwc_otg_ep_activate(dwc_otg_core_if_t * _core_if, dwc_ep_t * _ep);
01052 extern void dwc_otg_ep_deactivate(dwc_otg_core_if_t * _core_if, dwc_ep_t * _ep);
01053 extern void dwc_otg_ep_start_transfer(dwc_otg_core_if_t * _core_if,
01054                                       dwc_ep_t * _ep);
01055 extern void dwc_otg_ep_start_zl_transfer(dwc_otg_core_if_t * _core_if,
01056                                          dwc_ep_t * _ep);
01057 extern void dwc_otg_ep0_start_transfer(dwc_otg_core_if_t * _core_if,
01058                                        dwc_ep_t * _ep);
01059 extern void dwc_otg_ep0_continue_transfer(dwc_otg_core_if_t * _core_if,
01060                                           dwc_ep_t * _ep);
01061 extern void dwc_otg_ep_write_packet(dwc_otg_core_if_t * _core_if,
01062                                     dwc_ep_t * _ep, int _dma);
01063 extern void dwc_otg_ep_set_stall(dwc_otg_core_if_t * _core_if, dwc_ep_t * _ep);
01064 extern void dwc_otg_ep_clear_stall(dwc_otg_core_if_t * _core_if,
01065                                    dwc_ep_t * _ep);
01066 extern void dwc_otg_enable_device_interrupts(dwc_otg_core_if_t * _core_if);
01067 
01068 #ifdef DWC_EN_ISOC
01069 extern void dwc_otg_iso_ep_start_frm_transfer(dwc_otg_core_if_t * core_if,
01070                                               dwc_ep_t * ep);
01071 extern void dwc_otg_iso_ep_start_buf_transfer(dwc_otg_core_if_t * core_if,
01072                                               dwc_ep_t * ep);
01073 #endif /* DWC_EN_ISOC */
01074 
01081 extern void dwc_otg_hc_init(dwc_otg_core_if_t * _core_if, dwc_hc_t * _hc);
01082 extern void dwc_otg_hc_halt(dwc_otg_core_if_t * _core_if,
01083                             dwc_hc_t * _hc, dwc_otg_halt_status_e _halt_status);
01084 extern void dwc_otg_hc_cleanup(dwc_otg_core_if_t * _core_if, dwc_hc_t * _hc);
01085 extern void dwc_otg_hc_start_transfer(dwc_otg_core_if_t * _core_if,
01086                                       dwc_hc_t * _hc);
01087 extern int dwc_otg_hc_continue_transfer(dwc_otg_core_if_t * _core_if,
01088                                         dwc_hc_t * _hc);
01089 extern void dwc_otg_hc_do_ping(dwc_otg_core_if_t * _core_if, dwc_hc_t * _hc);
01090 extern void dwc_otg_hc_write_packet(dwc_otg_core_if_t * _core_if,
01091                                     dwc_hc_t * _hc);
01092 extern void dwc_otg_enable_host_interrupts(dwc_otg_core_if_t * _core_if);
01093 extern void dwc_otg_disable_host_interrupts(dwc_otg_core_if_t * _core_if);
01094 
01095 extern void dwc_otg_hc_start_transfer_ddma(dwc_otg_core_if_t * core_if,
01096                                            dwc_hc_t * hc);
01097 
01098 extern uint32_t calc_frame_interval(dwc_otg_core_if_t * core_if);
01099 
01100 /* Macro used to clear one channel interrupt */
01101 #define clear_hc_int(_hc_regs_, _intr_) \
01102 do { \
01103         hcint_data_t hcint_clear = {.d32 = 0}; \
01104         hcint_clear.b._intr_ = 1; \
01105         DWC_WRITE_REG32(&(_hc_regs_)->hcint, hcint_clear.d32); \
01106 } while (0)
01107 
01108 /*
01109  * Macro used to disable one channel interrupt. Channel interrupts are
01110  * disabled when the channel is halted or released by the interrupt handler.
01111  * There is no need to handle further interrupts of that type until the
01112  * channel is re-assigned. In fact, subsequent handling may cause crashes
01113  * because the channel structures are cleaned up when the channel is released.
01114  */
01115 #define disable_hc_int(_hc_regs_, _intr_) \
01116 do { \
01117         hcintmsk_data_t hcintmsk = {.d32 = 0}; \
01118         hcintmsk.b._intr_ = 1; \
01119         DWC_MODIFY_REG32(&(_hc_regs_)->hcintmsk, hcintmsk.d32, 0); \
01120 } while (0)
01121 
01127 static inline uint32_t dwc_otg_read_hprt0(dwc_otg_core_if_t * _core_if)
01128 {
01129         hprt0_data_t hprt0;
01130         hprt0.d32 = DWC_READ_REG32(_core_if->host_if->hprt0);
01131         hprt0.b.prtena = 0;
01132         hprt0.b.prtconndet = 0;
01133         hprt0.b.prtenchng = 0;
01134         hprt0.b.prtovrcurrchng = 0;
01135         return hprt0.d32;
01136 }
01137 
01146 extern void dwc_otg_read_packet(dwc_otg_core_if_t * core_if,
01147                                 uint8_t * dest, uint16_t bytes);
01148 
01149 extern void dwc_otg_flush_tx_fifo(dwc_otg_core_if_t * _core_if, const int _num);
01150 extern void dwc_otg_flush_rx_fifo(dwc_otg_core_if_t * _core_if);
01151 extern void dwc_otg_core_reset(dwc_otg_core_if_t * _core_if);
01152 
01156 static inline uint32_t dwc_otg_read_core_intr(dwc_otg_core_if_t * core_if)
01157 {
01158         return (DWC_READ_REG32(&core_if->core_global_regs->gintsts) &
01159                 DWC_READ_REG32(&core_if->core_global_regs->gintmsk));
01160 }
01161 
01165 static inline uint32_t dwc_otg_read_otg_intr(dwc_otg_core_if_t * core_if)
01166 {
01167         return (DWC_READ_REG32(&core_if->core_global_regs->gotgint));
01168 }
01169 
01174 static inline uint32_t dwc_otg_read_dev_all_in_ep_intr(dwc_otg_core_if_t *
01175                                                        core_if)
01176 {
01177 
01178         uint32_t v;
01179 
01180         if (core_if->multiproc_int_enable) {
01181                 v = DWC_READ_REG32(&core_if->dev_if->
01182                                    dev_global_regs->deachint) &
01183                     DWC_READ_REG32(&core_if->
01184                                    dev_if->dev_global_regs->deachintmsk);
01185         } else {
01186                 v = DWC_READ_REG32(&core_if->dev_if->dev_global_regs->daint) &
01187                     DWC_READ_REG32(&core_if->dev_if->dev_global_regs->daintmsk);
01188         }
01189         return (v & 0xffff);
01190 }
01191 
01196 static inline uint32_t dwc_otg_read_dev_all_out_ep_intr(dwc_otg_core_if_t *
01197                                                         core_if)
01198 {
01199         uint32_t v;
01200 
01201         if (core_if->multiproc_int_enable) {
01202                 v = DWC_READ_REG32(&core_if->dev_if->
01203                                    dev_global_regs->deachint) &
01204                     DWC_READ_REG32(&core_if->
01205                                    dev_if->dev_global_regs->deachintmsk);
01206         } else {
01207                 v = DWC_READ_REG32(&core_if->dev_if->dev_global_regs->daint) &
01208                     DWC_READ_REG32(&core_if->dev_if->dev_global_regs->daintmsk);
01209         }
01210 
01211         return ((v & 0xffff0000) >> 16);
01212 }
01213 
01217 static inline uint32_t dwc_otg_read_dev_in_ep_intr(dwc_otg_core_if_t * core_if,
01218                                                    dwc_ep_t * ep)
01219 {
01220         dwc_otg_dev_if_t *dev_if = core_if->dev_if;
01221         uint32_t v, msk, emp;
01222 
01223         if (core_if->multiproc_int_enable) {
01224                 msk =
01225                     DWC_READ_REG32(&dev_if->
01226                                    dev_global_regs->diepeachintmsk[ep->num]);
01227                 emp =
01228                     DWC_READ_REG32(&dev_if->
01229                                    dev_global_regs->dtknqr4_fifoemptymsk);
01230                 msk |= ((emp >> ep->num) & 0x1) << 7;
01231                 v = DWC_READ_REG32(&dev_if->in_ep_regs[ep->num]->diepint) & msk;
01232         } else {
01233                 msk = DWC_READ_REG32(&dev_if->dev_global_regs->diepmsk);
01234                 emp =
01235                     DWC_READ_REG32(&dev_if->
01236                                    dev_global_regs->dtknqr4_fifoemptymsk);
01237                 msk |= ((emp >> ep->num) & 0x1) << 7;
01238                 v = DWC_READ_REG32(&dev_if->in_ep_regs[ep->num]->diepint) & msk;
01239         }
01240 
01241         return v;
01242 }
01243 
01247 static inline uint32_t dwc_otg_read_dev_out_ep_intr(dwc_otg_core_if_t *
01248                                                     _core_if, dwc_ep_t * _ep)
01249 {
01250         dwc_otg_dev_if_t *dev_if = _core_if->dev_if;
01251         uint32_t v;
01252         doepmsk_data_t msk = {.d32 = 0 };
01253 
01254         if (_core_if->multiproc_int_enable) {
01255                 msk.d32 =
01256                     DWC_READ_REG32(&dev_if->
01257                                    dev_global_regs->doepeachintmsk[_ep->num]);
01258                 if (_core_if->pti_enh_enable) {
01259                         msk.b.pktdrpsts = 1;
01260                 }
01261                 v = DWC_READ_REG32(&dev_if->
01262                                    out_ep_regs[_ep->num]->doepint) & msk.d32;
01263         } else {
01264                 msk.d32 = DWC_READ_REG32(&dev_if->dev_global_regs->doepmsk);
01265                 if (_core_if->pti_enh_enable) {
01266                         msk.b.pktdrpsts = 1;
01267                 }
01268                 v = DWC_READ_REG32(&dev_if->
01269                                    out_ep_regs[_ep->num]->doepint) & msk.d32;
01270         }
01271         return v;
01272 }
01273 
01277 static inline uint32_t dwc_otg_read_host_all_channels_intr(dwc_otg_core_if_t *
01278                                                            _core_if)
01279 {
01280         return (DWC_READ_REG32(&_core_if->host_if->host_global_regs->haint));
01281 }
01282 
01283 static inline uint32_t dwc_otg_read_host_channel_intr(dwc_otg_core_if_t *
01284                                                       _core_if, dwc_hc_t * _hc)
01285 {
01286         return (DWC_READ_REG32
01287                 (&_core_if->host_if->hc_regs[_hc->hc_num]->hcint));
01288 }
01289 
01295 static inline uint32_t dwc_otg_mode(dwc_otg_core_if_t * _core_if)
01296 {
01297         return (DWC_READ_REG32(&_core_if->core_global_regs->gintsts) & 0x1);
01298 }
01299 
01307 typedef struct dwc_otg_cil_callbacks {
01309         int (*start) (void *_p);
01311         int (*stop) (void *_p);
01313         int (*disconnect) (void *_p);
01315         int (*resume_wakeup) (void *_p);
01317         int (*suspend) (void *_p);
01319         int (*session_start) (void *_p);
01320 #ifdef CONFIG_USB_DWC_OTG_LPM
01321 
01322         int (*sleep) (void *_p);
01323 #endif
01324 
01325         void *p;
01326 } dwc_otg_cil_callbacks_t;
01327 
01328 extern void dwc_otg_cil_register_pcd_callbacks(dwc_otg_core_if_t * _core_if,
01329                                                dwc_otg_cil_callbacks_t * _cb,
01330                                                void *_p);
01331 extern void dwc_otg_cil_register_hcd_callbacks(dwc_otg_core_if_t * _core_if,
01332                                                dwc_otg_cil_callbacks_t * _cb,
01333                                                void *_p);
01334 
01335 void dwc_otg_initiate_srp(dwc_otg_core_if_t * core_if);
01336 
01338 
01342 static inline void cil_hcd_start(dwc_otg_core_if_t * core_if)
01343 {
01344         if (core_if->hcd_cb && core_if->hcd_cb->start) {
01345                 core_if->hcd_cb->start(core_if->hcd_cb->p);
01346         }
01347 }
01348 
01353 static inline void cil_hcd_stop(dwc_otg_core_if_t * core_if)
01354 {
01355         if (core_if->hcd_cb && core_if->hcd_cb->stop) {
01356                 core_if->hcd_cb->stop(core_if->hcd_cb->p);
01357         }
01358 }
01359 
01364 static inline void cil_hcd_disconnect(dwc_otg_core_if_t * core_if)
01365 {
01366         if (core_if->hcd_cb && core_if->hcd_cb->disconnect) {
01367                 core_if->hcd_cb->disconnect(core_if->hcd_cb->p);
01368         }
01369 }
01370 
01376 static inline void cil_hcd_session_start(dwc_otg_core_if_t * core_if)
01377 {
01378         if (core_if->hcd_cb && core_if->hcd_cb->session_start) {
01379                 core_if->hcd_cb->session_start(core_if->hcd_cb->p);
01380         }
01381 }
01382 
01383 #ifdef CONFIG_USB_DWC_OTG_LPM
01384 
01390 static inline void cil_hcd_sleep(dwc_otg_core_if_t * core_if)
01391 {
01392         if (core_if->hcd_cb && core_if->hcd_cb->sleep) {
01393                 core_if->hcd_cb->sleep(core_if->hcd_cb->p);
01394         }
01395 }
01396 #endif
01397 
01402 static inline void cil_hcd_resume(dwc_otg_core_if_t * core_if)
01403 {
01404         if (core_if->hcd_cb && core_if->hcd_cb->resume_wakeup) {
01405                 core_if->hcd_cb->resume_wakeup(core_if->hcd_cb->p);
01406         }
01407 }
01408 
01413 static inline void cil_pcd_start(dwc_otg_core_if_t * core_if)
01414 {
01415         if (core_if->pcd_cb && core_if->pcd_cb->start) {
01416                 core_if->pcd_cb->start(core_if->pcd_cb->p);
01417         }
01418 }
01419 
01424 static inline void cil_pcd_stop(dwc_otg_core_if_t * core_if)
01425 {
01426         if (core_if->pcd_cb && core_if->pcd_cb->stop) {
01427                 core_if->pcd_cb->stop(core_if->pcd_cb->p);
01428         }
01429 }
01430 
01435 static inline void cil_pcd_suspend(dwc_otg_core_if_t * core_if)
01436 {
01437         if (core_if->pcd_cb && core_if->pcd_cb->suspend) {
01438                 core_if->pcd_cb->suspend(core_if->pcd_cb->p);
01439         }
01440 }
01441 
01446 static inline void cil_pcd_resume(dwc_otg_core_if_t * core_if)
01447 {
01448         if (core_if->pcd_cb && core_if->pcd_cb->resume_wakeup) {
01449                 core_if->pcd_cb->resume_wakeup(core_if->pcd_cb->p);
01450         }
01451 }
01452 
01454 
01455 #endif

Generated on Thu Oct 27 03:56:37 2011 for DesignWare USB 2.0 OTG Controller (DWC_otg) Device Driver by  doxygen 1.3.9.1