LCOV - code coverage report
Current view: top level - drivers/usb/host/dwc_otg - dwc_otg_cil.h (source / functions) Hit Total Coverage
Test: gcov_data_raspi2_real_modules_combined.info Lines: 8 78 10.3 %
Date: 2020-09-30 20:25:40 Functions: 1 6 16.7 %
Branches: 0 124 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* ==========================================================================
       2                 :            :  * $File: //dwh/usb_iip/dev/software/otg/linux/drivers/dwc_otg_cil.h $
       3                 :            :  * $Revision: #123 $
       4                 :            :  * $Date: 2012/08/10 $
       5                 :            :  * $Change: 2047372 $
       6                 :            :  *
       7                 :            :  * Synopsys HS OTG Linux Software Driver and documentation (hereinafter,
       8                 :            :  * "Software") is an Unsupported proprietary work of Synopsys, Inc. unless
       9                 :            :  * otherwise expressly agreed to in writing between Synopsys and you.
      10                 :            :  *
      11                 :            :  * The Software IS NOT an item of Licensed Software or Licensed Product under
      12                 :            :  * any End User Software License Agreement or Agreement for Licensed Product
      13                 :            :  * with Synopsys or any supplement thereto. You are permitted to use and
      14                 :            :  * redistribute this Software in source and binary forms, with or without
      15                 :            :  * modification, provided that redistributions of source code must retain this
      16                 :            :  * notice. You may not view, use, disclose, copy or distribute this file or
      17                 :            :  * any information contained herein except pursuant to this license grant from
      18                 :            :  * Synopsys. If you do not agree with this notice, including the disclaimer
      19                 :            :  * below, then you are not authorized to use the Software.
      20                 :            :  *
      21                 :            :  * THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS" BASIS
      22                 :            :  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
      23                 :            :  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
      24                 :            :  * ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS BE LIABLE FOR ANY DIRECT,
      25                 :            :  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
      26                 :            :  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
      27                 :            :  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
      28                 :            :  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
      29                 :            :  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
      30                 :            :  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
      31                 :            :  * DAMAGE.
      32                 :            :  * ========================================================================== */
      33                 :            : 
      34                 :            : #if !defined(__DWC_CIL_H__)
      35                 :            : #define __DWC_CIL_H__
      36                 :            : 
      37                 :            : #include "dwc_list.h"
      38                 :            : #include "dwc_otg_dbg.h"
      39                 :            : #include "dwc_otg_regs.h"
      40                 :            : 
      41                 :            : #include "dwc_otg_core_if.h"
      42                 :            : #include "dwc_otg_adp.h"
      43                 :            : 
      44                 :            : /**
      45                 :            :  * @file
      46                 :            :  * This file contains the interface to the Core Interface Layer.
      47                 :            :  */
      48                 :            : 
      49                 :            : #ifdef DWC_UTE_CFI
      50                 :            : 
      51                 :            : #define MAX_DMA_DESCS_PER_EP    256
      52                 :            : 
      53                 :            : /**
      54                 :            :  * Enumeration for the data buffer mode
      55                 :            :  */
      56                 :            : typedef enum _data_buffer_mode {
      57                 :            :         BM_STANDARD = 0,        /* data buffer is in normal mode */
      58                 :            :         BM_SG = 1,              /* data buffer uses the scatter/gather mode */
      59                 :            :         BM_CONCAT = 2,          /* data buffer uses the concatenation mode */
      60                 :            :         BM_CIRCULAR = 3,        /* data buffer uses the circular DMA mode */
      61                 :            :         BM_ALIGN = 4            /* data buffer is in buffer alignment mode */
      62                 :            : } data_buffer_mode_e;
      63                 :            : #endif //DWC_UTE_CFI
      64                 :            : 
      65                 :            : /** Macros defined for DWC OTG HW Release version */
      66                 :            : 
      67                 :            : #define OTG_CORE_REV_2_60a      0x4F54260A
      68                 :            : #define OTG_CORE_REV_2_71a      0x4F54271A
      69                 :            : #define OTG_CORE_REV_2_72a      0x4F54272A
      70                 :            : #define OTG_CORE_REV_2_80a      0x4F54280A
      71                 :            : #define OTG_CORE_REV_2_81a      0x4F54281A
      72                 :            : #define OTG_CORE_REV_2_90a      0x4F54290A
      73                 :            : #define OTG_CORE_REV_2_91a      0x4F54291A
      74                 :            : #define OTG_CORE_REV_2_92a      0x4F54292A
      75                 :            : #define OTG_CORE_REV_2_93a      0x4F54293A
      76                 :            : #define OTG_CORE_REV_2_94a      0x4F54294A
      77                 :            : #define OTG_CORE_REV_3_00a      0x4F54300A
      78                 :            : 
      79                 :            : /**
      80                 :            :  * Information for each ISOC packet.
      81                 :            :  */
      82                 :            : typedef struct iso_pkt_info {
      83                 :            :         uint32_t offset;
      84                 :            :         uint32_t length;
      85                 :            :         int32_t status;
      86                 :            : } iso_pkt_info_t;
      87                 :            : 
      88                 :            : /**
      89                 :            :  * The <code>dwc_ep</code> structure represents the state of a single
      90                 :            :  * endpoint when acting in device mode. It contains the data items
      91                 :            :  * needed for an endpoint to be activated and transfer packets.
      92                 :            :  */
      93                 :            : typedef struct dwc_ep {
      94                 :            :         /** EP number used for register address lookup */
      95                 :            :         uint8_t num;
      96                 :            :         /** EP direction 0 = OUT */
      97                 :            :         unsigned is_in:1;
      98                 :            :         /** EP active. */
      99                 :            :         unsigned active:1;
     100                 :            : 
     101                 :            :         /**
     102                 :            :          * Periodic Tx FIFO # for IN EPs For INTR EP set to 0 to use non-periodic
     103                 :            :          * Tx FIFO. If dedicated Tx FIFOs are enabled Tx FIFO # FOR IN EPs*/
     104                 :            :         unsigned tx_fifo_num:4;
     105                 :            :         /** EP type: 0 - Control, 1 - ISOC,      2 - BULK,      3 - INTR */
     106                 :            :         unsigned type:2;
     107                 :            : #define DWC_OTG_EP_TYPE_CONTROL    0
     108                 :            : #define DWC_OTG_EP_TYPE_ISOC       1
     109                 :            : #define DWC_OTG_EP_TYPE_BULK       2
     110                 :            : #define DWC_OTG_EP_TYPE_INTR       3
     111                 :            : 
     112                 :            :         /** DATA start PID for INTR and BULK EP */
     113                 :            :         unsigned data_pid_start:1;
     114                 :            :         /** Frame (even/odd) for ISOC EP */
     115                 :            :         unsigned even_odd_frame:1;
     116                 :            :         /** Max Packet bytes */
     117                 :            :         unsigned maxpacket:11;
     118                 :            : 
     119                 :            :         /** Max Transfer size */
     120                 :            :         uint32_t maxxfer;
     121                 :            : 
     122                 :            :         /** @name Transfer state */
     123                 :            :         /** @{ */
     124                 :            : 
     125                 :            :         /**
     126                 :            :          * Pointer to the beginning of the transfer buffer -- do not modify
     127                 :            :          * during transfer.
     128                 :            :          */
     129                 :            : 
     130                 :            :         dwc_dma_t dma_addr;
     131                 :            : 
     132                 :            :         dwc_dma_t dma_desc_addr;
     133                 :            :         dwc_otg_dev_dma_desc_t *desc_addr;
     134                 :            : 
     135                 :            :         uint8_t *start_xfer_buff;
     136                 :            :         /** pointer to the transfer buffer */
     137                 :            :         uint8_t *xfer_buff;
     138                 :            :         /** Number of bytes to transfer */
     139                 :            :         unsigned xfer_len:19;
     140                 :            :         /** Number of bytes transferred. */
     141                 :            :         unsigned xfer_count:19;
     142                 :            :         /** Sent ZLP */
     143                 :            :         unsigned sent_zlp:1;
     144                 :            :         /** Total len for control transfer */
     145                 :            :         unsigned total_len:19;
     146                 :            : 
     147                 :            :         /** stall clear flag */
     148                 :            :         unsigned stall_clear_flag:1;
     149                 :            : 
     150                 :            :         /** SETUP pkt cnt rollover flag for EP0 out*/
     151                 :            :         unsigned stp_rollover;
     152                 :            : 
     153                 :            : #ifdef DWC_UTE_CFI
     154                 :            :         /* The buffer mode */
     155                 :            :         data_buffer_mode_e buff_mode;
     156                 :            : 
     157                 :            :         /* The chain of DMA descriptors.
     158                 :            :          * MAX_DMA_DESCS_PER_EP will be allocated for each active EP.
     159                 :            :          */
     160                 :            :         dwc_otg_dma_desc_t *descs;
     161                 :            : 
     162                 :            :         /* The DMA address of the descriptors chain start */
     163                 :            :         dma_addr_t descs_dma_addr;
     164                 :            :         /** This variable stores the length of the last enqueued request */
     165                 :            :         uint32_t cfi_req_len;
     166                 :            : #endif                          //DWC_UTE_CFI
     167                 :            : 
     168                 :            : /** Max DMA Descriptor count for any EP */
     169                 :            : #define MAX_DMA_DESC_CNT 256
     170                 :            :         /** Allocated DMA Desc count */
     171                 :            :         uint32_t desc_cnt;
     172                 :            : 
     173                 :            :         /** bInterval */
     174                 :            :         uint32_t bInterval;
     175                 :            :         /** Next frame num to setup next ISOC transfer */
     176                 :            :         uint32_t frame_num;
     177                 :            :         /** Indicates SOF number overrun in DSTS */
     178                 :            :         uint8_t frm_overrun;
     179                 :            : 
     180                 :            : #ifdef DWC_UTE_PER_IO
     181                 :            :         /** Next frame num for which will be setup DMA Desc */
     182                 :            :         uint32_t xiso_frame_num;
     183                 :            :         /** bInterval */
     184                 :            :         uint32_t xiso_bInterval;
     185                 :            :         /** Count of currently active transfers - shall be either 0 or 1 */
     186                 :            :         int xiso_active_xfers;
     187                 :            :         int xiso_queued_xfers;
     188                 :            : #endif
     189                 :            : #ifdef DWC_EN_ISOC
     190                 :            :         /**
     191                 :            :          * Variables specific for ISOC EPs
     192                 :            :          *
     193                 :            :          */
     194                 :            :         /** DMA addresses of ISOC buffers */
     195                 :            :         dwc_dma_t dma_addr0;
     196                 :            :         dwc_dma_t dma_addr1;
     197                 :            : 
     198                 :            :         dwc_dma_t iso_dma_desc_addr;
     199                 :            :         dwc_otg_dev_dma_desc_t *iso_desc_addr;
     200                 :            : 
     201                 :            :         /** pointer to the transfer buffers */
     202                 :            :         uint8_t *xfer_buff0;
     203                 :            :         uint8_t *xfer_buff1;
     204                 :            : 
     205                 :            :         /** number of ISOC Buffer is processing */
     206                 :            :         uint32_t proc_buf_num;
     207                 :            :         /** Interval of ISOC Buffer processing */
     208                 :            :         uint32_t buf_proc_intrvl;
     209                 :            :         /** Data size for regular frame */
     210                 :            :         uint32_t data_per_frame;
     211                 :            : 
     212                 :            :         /* todo - pattern data support is to be implemented in the future */
     213                 :            :         /** Data size for pattern frame */
     214                 :            :         uint32_t data_pattern_frame;
     215                 :            :         /** Frame number of pattern data */
     216                 :            :         uint32_t sync_frame;
     217                 :            : 
     218                 :            :         /** bInterval */
     219                 :            :         uint32_t bInterval;
     220                 :            :         /** ISO Packet number per frame */
     221                 :            :         uint32_t pkt_per_frm;
     222                 :            :         /** Next frame num for which will be setup DMA Desc */
     223                 :            :         uint32_t next_frame;
     224                 :            :         /** Number of packets per buffer processing */
     225                 :            :         uint32_t pkt_cnt;
     226                 :            :         /** Info for all isoc packets */
     227                 :            :         iso_pkt_info_t *pkt_info;
     228                 :            :         /** current pkt number */
     229                 :            :         uint32_t cur_pkt;
     230                 :            :         /** current pkt number */
     231                 :            :         uint8_t *cur_pkt_addr;
     232                 :            :         /** current pkt number */
     233                 :            :         uint32_t cur_pkt_dma_addr;
     234                 :            : #endif                          /* DWC_EN_ISOC */
     235                 :            : 
     236                 :            : /** @} */
     237                 :            : } dwc_ep_t;
     238                 :            : 
     239                 :            : /*
     240                 :            :  * Reasons for halting a host channel.
     241                 :            :  */
     242                 :            : typedef enum dwc_otg_halt_status {
     243                 :            :         DWC_OTG_HC_XFER_NO_HALT_STATUS,
     244                 :            :         DWC_OTG_HC_XFER_COMPLETE,
     245                 :            :         DWC_OTG_HC_XFER_URB_COMPLETE,
     246                 :            :         DWC_OTG_HC_XFER_ACK,
     247                 :            :         DWC_OTG_HC_XFER_NAK,
     248                 :            :         DWC_OTG_HC_XFER_NYET,
     249                 :            :         DWC_OTG_HC_XFER_STALL,
     250                 :            :         DWC_OTG_HC_XFER_XACT_ERR,
     251                 :            :         DWC_OTG_HC_XFER_FRAME_OVERRUN,
     252                 :            :         DWC_OTG_HC_XFER_BABBLE_ERR,
     253                 :            :         DWC_OTG_HC_XFER_DATA_TOGGLE_ERR,
     254                 :            :         DWC_OTG_HC_XFER_AHB_ERR,
     255                 :            :         DWC_OTG_HC_XFER_PERIODIC_INCOMPLETE,
     256                 :            :         DWC_OTG_HC_XFER_URB_DEQUEUE
     257                 :            : } dwc_otg_halt_status_e;
     258                 :            : 
     259                 :            : /**
     260                 :            :  * Host channel descriptor. This structure represents the state of a single
     261                 :            :  * host channel when acting in host mode. It contains the data items needed to
     262                 :            :  * transfer packets to an endpoint via a host channel.
     263                 :            :  */
     264                 :            : typedef struct dwc_hc {
     265                 :            :         /** Host channel number used for register address lookup */
     266                 :            :         uint8_t hc_num;
     267                 :            : 
     268                 :            :         /** Device to access */
     269                 :            :         unsigned dev_addr:7;
     270                 :            : 
     271                 :            :         /** EP to access */
     272                 :            :         unsigned ep_num:4;
     273                 :            : 
     274                 :            :         /** EP direction. 0: OUT, 1: IN */
     275                 :            :         unsigned ep_is_in:1;
     276                 :            : 
     277                 :            :         /**
     278                 :            :          * EP speed.
     279                 :            :          * One of the following values:
     280                 :            :          *      - DWC_OTG_EP_SPEED_LOW
     281                 :            :          *      - DWC_OTG_EP_SPEED_FULL
     282                 :            :          *      - DWC_OTG_EP_SPEED_HIGH
     283                 :            :          */
     284                 :            :         unsigned speed:2;
     285                 :            : #define DWC_OTG_EP_SPEED_LOW    0
     286                 :            : #define DWC_OTG_EP_SPEED_FULL   1
     287                 :            : #define DWC_OTG_EP_SPEED_HIGH   2
     288                 :            : 
     289                 :            :         /**
     290                 :            :          * Endpoint type.
     291                 :            :          * One of the following values:
     292                 :            :          *      - DWC_OTG_EP_TYPE_CONTROL: 0
     293                 :            :          *      - DWC_OTG_EP_TYPE_ISOC: 1
     294                 :            :          *      - DWC_OTG_EP_TYPE_BULK: 2
     295                 :            :          *      - DWC_OTG_EP_TYPE_INTR: 3
     296                 :            :          */
     297                 :            :         unsigned ep_type:2;
     298                 :            : 
     299                 :            :         /** Max packet size in bytes */
     300                 :            :         unsigned max_packet:11;
     301                 :            : 
     302                 :            :         /**
     303                 :            :          * PID for initial transaction.
     304                 :            :          * 0: DATA0,<br>
     305                 :            :          * 1: DATA2,<br>
     306                 :            :          * 2: DATA1,<br>
     307                 :            :          * 3: MDATA (non-Control EP),
     308                 :            :          *        SETUP (Control EP)
     309                 :            :          */
     310                 :            :         unsigned data_pid_start:2;
     311                 :            : #define DWC_OTG_HC_PID_DATA0 0
     312                 :            : #define DWC_OTG_HC_PID_DATA2 1
     313                 :            : #define DWC_OTG_HC_PID_DATA1 2
     314                 :            : #define DWC_OTG_HC_PID_MDATA 3
     315                 :            : #define DWC_OTG_HC_PID_SETUP 3
     316                 :            : 
     317                 :            :         /** Number of periodic transactions per (micro)frame */
     318                 :            :         unsigned multi_count:2;
     319                 :            : 
     320                 :            :         /** @name Transfer State */
     321                 :            :         /** @{ */
     322                 :            : 
     323                 :            :         /** Pointer to the current transfer buffer position. */
     324                 :            :         uint8_t *xfer_buff;
     325                 :            :         /**
     326                 :            :          * In Buffer DMA mode this buffer will be used
     327                 :            :          * if xfer_buff is not DWORD aligned.
     328                 :            :          */
     329                 :            :         dwc_dma_t align_buff;
     330                 :            :         /** Total number of bytes to transfer. */
     331                 :            :         uint32_t xfer_len;
     332                 :            :         /** Number of bytes transferred so far. */
     333                 :            :         uint32_t xfer_count;
     334                 :            :         /** Packet count at start of transfer.*/
     335                 :            :         uint16_t start_pkt_count;
     336                 :            : 
     337                 :            :         /**
     338                 :            :          * Flag to indicate whether the transfer has been started. Set to 1 if
     339                 :            :          * it has been started, 0 otherwise.
     340                 :            :          */
     341                 :            :         uint8_t xfer_started;
     342                 :            : 
     343                 :            :         /**
     344                 :            :          * Set to 1 to indicate that a PING request should be issued on this
     345                 :            :          * channel. If 0, process normally.
     346                 :            :          */
     347                 :            :         uint8_t do_ping;
     348                 :            : 
     349                 :            :         /**
     350                 :            :          * Set to 1 to indicate that the error count for this transaction is
     351                 :            :          * non-zero. Set to 0 if the error count is 0.
     352                 :            :          */
     353                 :            :         uint8_t error_state;
     354                 :            : 
     355                 :            :         /**
     356                 :            :          * Set to 1 to indicate that this channel should be halted the next
     357                 :            :          * time a request is queued for the channel. This is necessary in
     358                 :            :          * slave mode if no request queue space is available when an attempt
     359                 :            :          * is made to halt the channel.
     360                 :            :          */
     361                 :            :         uint8_t halt_on_queue;
     362                 :            : 
     363                 :            :         /**
     364                 :            :          * Set to 1 if the host channel has been halted, but the core is not
     365                 :            :          * finished flushing queued requests. Otherwise 0.
     366                 :            :          */
     367                 :            :         uint8_t halt_pending;
     368                 :            : 
     369                 :            :         /**
     370                 :            :          * Reason for halting the host channel.
     371                 :            :          */
     372                 :            :         dwc_otg_halt_status_e halt_status;
     373                 :            : 
     374                 :            :         /*
     375                 :            :          * Split settings for the host channel
     376                 :            :          */
     377                 :            :         uint8_t do_split;                  /**< Enable split for the channel */
     378                 :            :         uint8_t complete_split;    /**< Enable complete split */
     379                 :            :         uint8_t hub_addr;                  /**< Address of high speed hub */
     380                 :            : 
     381                 :            :         uint8_t port_addr;                 /**< Port of the low/full speed device */
     382                 :            :         /** Split transaction position
     383                 :            :          * One of the following values:
     384                 :            :          *        - DWC_HCSPLIT_XACTPOS_MID
     385                 :            :          *        - DWC_HCSPLIT_XACTPOS_BEGIN
     386                 :            :          *        - DWC_HCSPLIT_XACTPOS_END
     387                 :            :          *        - DWC_HCSPLIT_XACTPOS_ALL */
     388                 :            :         uint8_t xact_pos;
     389                 :            : 
     390                 :            :         /** Set when the host channel does a short read. */
     391                 :            :         uint8_t short_read;
     392                 :            : 
     393                 :            :         /**
     394                 :            :          * Number of requests issued for this channel since it was assigned to
     395                 :            :          * the current transfer (not counting PINGs).
     396                 :            :          */
     397                 :            :         uint8_t requests;
     398                 :            : 
     399                 :            :         /**
     400                 :            :          * Queue Head for the transfer being processed by this channel.
     401                 :            :          */
     402                 :            :         struct dwc_otg_qh *qh;
     403                 :            : 
     404                 :            :         /** @} */
     405                 :            : 
     406                 :            :         /** Entry in list of host channels. */
     407                 :            :          DWC_CIRCLEQ_ENTRY(dwc_hc) hc_list_entry;
     408                 :            : 
     409                 :            :         /** @name Descriptor DMA support */
     410                 :            :         /** @{ */
     411                 :            : 
     412                 :            :         /** Number of Transfer Descriptors */
     413                 :            :         uint16_t ntd;
     414                 :            : 
     415                 :            :         /** Descriptor List DMA address */
     416                 :            :         dwc_dma_t desc_list_addr;
     417                 :            : 
     418                 :            :         /** Scheduling micro-frame bitmap. */
     419                 :            :         uint8_t schinfo;
     420                 :            : 
     421                 :            :         /** @} */
     422                 :            : } dwc_hc_t;
     423                 :            : 
     424                 :            : /**
     425                 :            :  * The following parameters may be specified when starting the module. These
     426                 :            :  * parameters define how the DWC_otg controller should be configured.
     427                 :            :  */
     428                 :            : typedef struct dwc_otg_core_params {
     429                 :            :         int32_t opt;
     430                 :            : 
     431                 :            :         /**
     432                 :            :          * Specifies the OTG capabilities. The driver will automatically
     433                 :            :          * detect the value for this parameter if none is specified.
     434                 :            :          * 0 - HNP and SRP capable (default)
     435                 :            :          * 1 - SRP Only capable
     436                 :            :          * 2 - No HNP/SRP capable
     437                 :            :          */
     438                 :            :         int32_t otg_cap;
     439                 :            : 
     440                 :            :         /**
     441                 :            :          * Specifies whether to use slave or DMA mode for accessing the data
     442                 :            :          * FIFOs. The driver will automatically detect the value for this
     443                 :            :          * parameter if none is specified.
     444                 :            :          * 0 - Slave
     445                 :            :          * 1 - DMA (default, if available)
     446                 :            :          */
     447                 :            :         int32_t dma_enable;
     448                 :            : 
     449                 :            :         /**
     450                 :            :          * When DMA mode is enabled specifies whether to use address DMA or DMA
     451                 :            :          * Descriptor mode for accessing the data FIFOs in device mode. The driver
     452                 :            :          * will automatically detect the value for this if none is specified.
     453                 :            :          * 0 - address DMA
     454                 :            :          * 1 - DMA Descriptor(default, if available)
     455                 :            :          */
     456                 :            :         int32_t dma_desc_enable;
     457                 :            :         /** The DMA Burst size (applicable only for External DMA
     458                 :            :          * Mode). 1, 4, 8 16, 32, 64, 128, 256 (default 32)
     459                 :            :          */
     460                 :            :         int32_t dma_burst_size; /* Translate this to GAHBCFG values */
     461                 :            : 
     462                 :            :         /**
     463                 :            :          * Specifies the maximum speed of operation in host and device mode.
     464                 :            :          * The actual speed depends on the speed of the attached device and
     465                 :            :          * the value of phy_type. The actual speed depends on the speed of the
     466                 :            :          * attached device.
     467                 :            :          * 0 - High Speed (default)
     468                 :            :          * 1 - Full Speed
     469                 :            :          */
     470                 :            :         int32_t speed;
     471                 :            :         /** Specifies whether low power mode is supported when attached
     472                 :            :          *      to a Full Speed or Low Speed device in host mode.
     473                 :            :          * 0 - Don't support low power mode (default)
     474                 :            :          * 1 - Support low power mode
     475                 :            :          */
     476                 :            :         int32_t host_support_fs_ls_low_power;
     477                 :            : 
     478                 :            :         /** Specifies the PHY clock rate in low power mode when connected to a
     479                 :            :          * Low Speed device in host mode. This parameter is applicable only if
     480                 :            :          * HOST_SUPPORT_FS_LS_LOW_POWER is enabled. If PHY_TYPE is set to FS
     481                 :            :          * then defaults to 6 MHZ otherwise 48 MHZ.
     482                 :            :          *
     483                 :            :          * 0 - 48 MHz
     484                 :            :          * 1 - 6 MHz
     485                 :            :          */
     486                 :            :         int32_t host_ls_low_power_phy_clk;
     487                 :            : 
     488                 :            :         /**
     489                 :            :          * 0 - Use cC FIFO size parameters
     490                 :            :          * 1 - Allow dynamic FIFO sizing (default)
     491                 :            :          */
     492                 :            :         int32_t enable_dynamic_fifo;
     493                 :            : 
     494                 :            :         /** Total number of 4-byte words in the data FIFO memory. This
     495                 :            :          * memory includes the Rx FIFO, non-periodic Tx FIFO, and periodic
     496                 :            :          * Tx FIFOs.
     497                 :            :          * 32 to 32768 (default 8192)
     498                 :            :          * Note: The total FIFO memory depth in the FPGA configuration is 8192.
     499                 :            :          */
     500                 :            :         int32_t data_fifo_size;
     501                 :            : 
     502                 :            :         /** Number of 4-byte words in the Rx FIFO in device mode when dynamic
     503                 :            :          * FIFO sizing is enabled.
     504                 :            :          * 16 to 32768 (default 1064)
     505                 :            :          */
     506                 :            :         int32_t dev_rx_fifo_size;
     507                 :            : 
     508                 :            :         /** Number of 4-byte words in the non-periodic Tx FIFO in device mode
     509                 :            :          * when dynamic FIFO sizing is enabled.
     510                 :            :          * 16 to 32768 (default 1024)
     511                 :            :          */
     512                 :            :         int32_t dev_nperio_tx_fifo_size;
     513                 :            : 
     514                 :            :         /** Number of 4-byte words in each of the periodic Tx FIFOs in device
     515                 :            :          * mode when dynamic FIFO sizing is enabled.
     516                 :            :          * 4 to 768 (default 256)
     517                 :            :          */
     518                 :            :         uint32_t dev_perio_tx_fifo_size[MAX_PERIO_FIFOS];
     519                 :            : 
     520                 :            :         /** Number of 4-byte words in the Rx FIFO in host mode when dynamic
     521                 :            :          * FIFO sizing is enabled.
     522                 :            :          * 16 to 32768 (default 1024)
     523                 :            :          */
     524                 :            :         int32_t host_rx_fifo_size;
     525                 :            : 
     526                 :            :         /** Number of 4-byte words in the non-periodic Tx FIFO in host mode
     527                 :            :          * when Dynamic FIFO sizing is enabled in the core.
     528                 :            :          * 16 to 32768 (default 1024)
     529                 :            :          */
     530                 :            :         int32_t host_nperio_tx_fifo_size;
     531                 :            : 
     532                 :            :         /** Number of 4-byte words in the host periodic Tx FIFO when dynamic
     533                 :            :          * FIFO sizing is enabled.
     534                 :            :          * 16 to 32768 (default 1024)
     535                 :            :          */
     536                 :            :         int32_t host_perio_tx_fifo_size;
     537                 :            : 
     538                 :            :         /** The maximum transfer size supported in bytes.
     539                 :            :          * 2047 to 65,535  (default 65,535)
     540                 :            :          */
     541                 :            :         int32_t max_transfer_size;
     542                 :            : 
     543                 :            :         /** The maximum number of packets in a transfer.
     544                 :            :          * 15 to 511  (default 511)
     545                 :            :          */
     546                 :            :         int32_t max_packet_count;
     547                 :            : 
     548                 :            :         /** The number of host channel registers to use.
     549                 :            :          * 1 to 16 (default 12)
     550                 :            :          * Note: The FPGA configuration supports a maximum of 12 host channels.
     551                 :            :          */
     552                 :            :         int32_t host_channels;
     553                 :            : 
     554                 :            :         /** The number of endpoints in addition to EP0 available for device
     555                 :            :          * mode operations.
     556                 :            :          * 1 to 15 (default 6 IN and OUT)
     557                 :            :          * Note: The FPGA configuration supports a maximum of 6 IN and OUT
     558                 :            :          * endpoints in addition to EP0.
     559                 :            :          */
     560                 :            :         int32_t dev_endpoints;
     561                 :            : 
     562                 :            :                 /**
     563                 :            :                  * Specifies the type of PHY interface to use. By default, the driver
     564                 :            :                  * will automatically detect the phy_type.
     565                 :            :                  *
     566                 :            :                  * 0 - Full Speed PHY
     567                 :            :                  * 1 - UTMI+ (default)
     568                 :            :                  * 2 - ULPI
     569                 :            :                  */
     570                 :            :         int32_t phy_type;
     571                 :            : 
     572                 :            :         /**
     573                 :            :          * Specifies the UTMI+ Data Width. This parameter is
     574                 :            :          * applicable for a PHY_TYPE of UTMI+ or ULPI. (For a ULPI
     575                 :            :          * PHY_TYPE, this parameter indicates the data width between
     576                 :            :          * the MAC and the ULPI Wrapper.) Also, this parameter is
     577                 :            :          * applicable only if the OTG_HSPHY_WIDTH cC parameter was set
     578                 :            :          * to "8 and 16 bits", meaning that the core has been
     579                 :            :          * configured to work at either data path width.
     580                 :            :          *
     581                 :            :          * 8 or 16 bits (default 16)
     582                 :            :          */
     583                 :            :         int32_t phy_utmi_width;
     584                 :            : 
     585                 :            :         /**
     586                 :            :          * Specifies whether the ULPI operates at double or single
     587                 :            :          * data rate. This parameter is only applicable if PHY_TYPE is
     588                 :            :          * ULPI.
     589                 :            :          *
     590                 :            :          * 0 - single data rate ULPI interface with 8 bit wide data
     591                 :            :          * bus (default)
     592                 :            :          * 1 - double data rate ULPI interface with 4 bit wide data
     593                 :            :          * bus
     594                 :            :          */
     595                 :            :         int32_t phy_ulpi_ddr;
     596                 :            : 
     597                 :            :         /**
     598                 :            :          * Specifies whether to use the internal or external supply to
     599                 :            :          * drive the vbus with a ULPI phy.
     600                 :            :          */
     601                 :            :         int32_t phy_ulpi_ext_vbus;
     602                 :            : 
     603                 :            :         /**
     604                 :            :          * Specifies whether to use the I2Cinterface for full speed PHY. This
     605                 :            :          * parameter is only applicable if PHY_TYPE is FS.
     606                 :            :          * 0 - No (default)
     607                 :            :          * 1 - Yes
     608                 :            :          */
     609                 :            :         int32_t i2c_enable;
     610                 :            : 
     611                 :            :         int32_t ulpi_fs_ls;
     612                 :            : 
     613                 :            :         int32_t ts_dline;
     614                 :            : 
     615                 :            :         /**
     616                 :            :          * Specifies whether dedicated transmit FIFOs are
     617                 :            :          * enabled for non periodic IN endpoints in device mode
     618                 :            :          * 0 - No
     619                 :            :          * 1 - Yes
     620                 :            :          */
     621                 :            :         int32_t en_multiple_tx_fifo;
     622                 :            : 
     623                 :            :         /** Number of 4-byte words in each of the Tx FIFOs in device
     624                 :            :          * mode when dynamic FIFO sizing is enabled.
     625                 :            :          * 4 to 768 (default 256)
     626                 :            :          */
     627                 :            :         uint32_t dev_tx_fifo_size[MAX_TX_FIFOS];
     628                 :            : 
     629                 :            :         /** Thresholding enable flag-
     630                 :            :          * bit 0 - enable non-ISO Tx thresholding
     631                 :            :          * bit 1 - enable ISO Tx thresholding
     632                 :            :          * bit 2 - enable Rx thresholding
     633                 :            :          */
     634                 :            :         uint32_t thr_ctl;
     635                 :            : 
     636                 :            :         /** Thresholding length for Tx
     637                 :            :          *      FIFOs in 32 bit DWORDs
     638                 :            :          */
     639                 :            :         uint32_t tx_thr_length;
     640                 :            : 
     641                 :            :         /** Thresholding length for Rx
     642                 :            :          *      FIFOs in 32 bit DWORDs
     643                 :            :          */
     644                 :            :         uint32_t rx_thr_length;
     645                 :            : 
     646                 :            :         /**
     647                 :            :          * Specifies whether LPM (Link Power Management) support is enabled
     648                 :            :          */
     649                 :            :         int32_t lpm_enable;
     650                 :            : 
     651                 :            :         /** Per Transfer Interrupt
     652                 :            :          *      mode enable flag
     653                 :            :          * 1 - Enabled
     654                 :            :          * 0 - Disabled
     655                 :            :          */
     656                 :            :         int32_t pti_enable;
     657                 :            : 
     658                 :            :         /** Multi Processor Interrupt
     659                 :            :          *      mode enable flag
     660                 :            :          * 1 - Enabled
     661                 :            :          * 0 - Disabled
     662                 :            :          */
     663                 :            :         int32_t mpi_enable;
     664                 :            : 
     665                 :            :         /** IS_USB Capability
     666                 :            :          * 1 - Enabled
     667                 :            :          * 0 - Disabled
     668                 :            :          */
     669                 :            :         int32_t ic_usb_cap;
     670                 :            : 
     671                 :            :         /** AHB Threshold Ratio
     672                 :            :          * 2'b00 AHB Threshold =        MAC Threshold
     673                 :            :          * 2'b01 AHB Threshold = 1/2    MAC Threshold
     674                 :            :          * 2'b10 AHB Threshold = 1/4    MAC Threshold
     675                 :            :          * 2'b11 AHB Threshold = 1/8    MAC Threshold
     676                 :            :          */
     677                 :            :         int32_t ahb_thr_ratio;
     678                 :            : 
     679                 :            :         /** ADP Support
     680                 :            :          * 1 - Enabled
     681                 :            :          * 0 - Disabled
     682                 :            :          */
     683                 :            :         int32_t adp_supp_enable;
     684                 :            : 
     685                 :            :         /** HFIR Reload Control
     686                 :            :          * 0 - The HFIR cannot be reloaded dynamically.
     687                 :            :          * 1 - Allow dynamic reloading of the HFIR register during runtime.
     688                 :            :          */
     689                 :            :         int32_t reload_ctl;
     690                 :            : 
     691                 :            :         /** DCFG: Enable device Out NAK
     692                 :            :          * 0 - The core does not set NAK after Bulk Out transfer complete.
     693                 :            :          * 1 - The core sets NAK after Bulk OUT transfer complete.
     694                 :            :          */
     695                 :            :         int32_t dev_out_nak;
     696                 :            : 
     697                 :            :         /** DCFG: Enable Continue on BNA
     698                 :            :          * After receiving BNA interrupt the core disables the endpoint,when the
     699                 :            :          * endpoint is re-enabled by the application the core starts processing
     700                 :            :          * 0 - from the DOEPDMA descriptor
     701                 :            :          * 1 - from the descriptor which received the BNA.
     702                 :            :          */
     703                 :            :         int32_t cont_on_bna;
     704                 :            : 
     705                 :            :         /** GAHBCFG: AHB Single Support
     706                 :            :          * This bit when programmed supports SINGLE transfers for remainder
     707                 :            :          * data in a transfer for DMA mode of operation.
     708                 :            :          * 0 - in this case the remainder data will be sent using INCR burst size.
     709                 :            :          * 1 - in this case the remainder data will be sent using SINGLE burst size.
     710                 :            :          */
     711                 :            :         int32_t ahb_single;
     712                 :            : 
     713                 :            :         /** Core Power down mode
     714                 :            :          * 0 - No Power Down is enabled
     715                 :            :          * 1 - Reserved
     716                 :            :          * 2 - Complete Power Down (Hibernation)
     717                 :            :          */
     718                 :            :         int32_t power_down;
     719                 :            : 
     720                 :            :         /** OTG revision supported
     721                 :            :          * 0 - OTG 1.3 revision
     722                 :            :          * 1 - OTG 2.0 revision
     723                 :            :          */
     724                 :            :         int32_t otg_ver;
     725                 :            : 
     726                 :            : } dwc_otg_core_params_t;
     727                 :            : 
     728                 :            : #ifdef DEBUG
     729                 :            : struct dwc_otg_core_if;
     730                 :            : typedef struct hc_xfer_info {
     731                 :            :         struct dwc_otg_core_if *core_if;
     732                 :            :         dwc_hc_t *hc;
     733                 :            : } hc_xfer_info_t;
     734                 :            : #endif
     735                 :            : 
     736                 :            : typedef struct ep_xfer_info {
     737                 :            :         struct dwc_otg_core_if *core_if;
     738                 :            :         dwc_ep_t *ep;
     739                 :            :         uint8_t state;
     740                 :            : } ep_xfer_info_t;
     741                 :            : /*
     742                 :            :  * Device States
     743                 :            :  */
     744                 :            : typedef enum dwc_otg_lx_state {
     745                 :            :         /** On state */
     746                 :            :         DWC_OTG_L0,
     747                 :            :         /** LPM sleep state*/
     748                 :            :         DWC_OTG_L1,
     749                 :            :         /** USB suspend state*/
     750                 :            :         DWC_OTG_L2,
     751                 :            :         /** Off state*/
     752                 :            :         DWC_OTG_L3
     753                 :            : } dwc_otg_lx_state_e;
     754                 :            : 
     755                 :            : struct dwc_otg_global_regs_backup {
     756                 :            :         uint32_t gotgctl_local;
     757                 :            :         uint32_t gintmsk_local;
     758                 :            :         uint32_t gahbcfg_local;
     759                 :            :         uint32_t gusbcfg_local;
     760                 :            :         uint32_t grxfsiz_local;
     761                 :            :         uint32_t gnptxfsiz_local;
     762                 :            : #ifdef CONFIG_USB_DWC_OTG_LPM
     763                 :            :         uint32_t glpmcfg_local;
     764                 :            : #endif
     765                 :            :         uint32_t gi2cctl_local;
     766                 :            :         uint32_t hptxfsiz_local;
     767                 :            :         uint32_t pcgcctl_local;
     768                 :            :         uint32_t gdfifocfg_local;
     769                 :            :         uint32_t dtxfsiz_local[MAX_EPS_CHANNELS];
     770                 :            :         uint32_t gpwrdn_local;
     771                 :            :         uint32_t xhib_pcgcctl;
     772                 :            :         uint32_t xhib_gpwrdn;
     773                 :            : };
     774                 :            : 
     775                 :            : struct dwc_otg_host_regs_backup {
     776                 :            :         uint32_t hcfg_local;
     777                 :            :         uint32_t haintmsk_local;
     778                 :            :         uint32_t hcintmsk_local[MAX_EPS_CHANNELS];
     779                 :            :         uint32_t hprt0_local;
     780                 :            :         uint32_t hfir_local;
     781                 :            : };
     782                 :            : 
     783                 :            : struct dwc_otg_dev_regs_backup {
     784                 :            :         uint32_t dcfg;
     785                 :            :         uint32_t dctl;
     786                 :            :         uint32_t daintmsk;
     787                 :            :         uint32_t diepmsk;
     788                 :            :         uint32_t doepmsk;
     789                 :            :         uint32_t diepctl[MAX_EPS_CHANNELS];
     790                 :            :         uint32_t dieptsiz[MAX_EPS_CHANNELS];
     791                 :            :         uint32_t diepdma[MAX_EPS_CHANNELS];
     792                 :            : };
     793                 :            : /**
     794                 :            :  * The <code>dwc_otg_core_if</code> structure contains information needed to manage
     795                 :            :  * the DWC_otg controller acting in either host or device mode. It
     796                 :            :  * represents the programming view of the controller as a whole.
     797                 :            :  */
     798                 :            : struct dwc_otg_core_if {
     799                 :            :         /** Parameters that define how the core should be configured.*/
     800                 :            :         dwc_otg_core_params_t *core_params;
     801                 :            : 
     802                 :            :         /** Core Global registers starting at offset 000h. */
     803                 :            :         dwc_otg_core_global_regs_t *core_global_regs;
     804                 :            : 
     805                 :            :         /** Device-specific information */
     806                 :            :         dwc_otg_dev_if_t *dev_if;
     807                 :            :         /** Host-specific information */
     808                 :            :         dwc_otg_host_if_t *host_if;
     809                 :            : 
     810                 :            :         /** Value from SNPSID register */
     811                 :            :         uint32_t snpsid;
     812                 :            : 
     813                 :            :         /*
     814                 :            :          * Set to 1 if the core PHY interface bits in USBCFG have been
     815                 :            :          * initialized.
     816                 :            :          */
     817                 :            :         uint8_t phy_init_done;
     818                 :            : 
     819                 :            :         /*
     820                 :            :          * SRP Success flag, set by srp success interrupt in FS I2C mode
     821                 :            :          */
     822                 :            :         uint8_t srp_success;
     823                 :            :         uint8_t srp_timer_started;
     824                 :            :         /** Timer for SRP. If it expires before SRP is successful
     825                 :            :          * clear the SRP. */
     826                 :            :         dwc_timer_t *srp_timer;
     827                 :            : 
     828                 :            : #ifdef DWC_DEV_SRPCAP
     829                 :            :         /* This timer is needed to power on the hibernated host core if SRP is not
     830                 :            :          * initiated on connected SRP capable device for limited period of time
     831                 :            :          */
     832                 :            :         uint8_t pwron_timer_started;
     833                 :            :         dwc_timer_t *pwron_timer;
     834                 :            : #endif
     835                 :            :         /* Common configuration information */
     836                 :            :         /** Power and Clock Gating Control Register */
     837                 :            :         volatile uint32_t *pcgcctl;
     838                 :            : #define DWC_OTG_PCGCCTL_OFFSET 0xE00
     839                 :            : 
     840                 :            :         /** Push/pop addresses for endpoints or host channels.*/
     841                 :            :         uint32_t *data_fifo[MAX_EPS_CHANNELS];
     842                 :            : #define DWC_OTG_DATA_FIFO_OFFSET 0x1000
     843                 :            : #define DWC_OTG_DATA_FIFO_SIZE 0x1000
     844                 :            : 
     845                 :            :         /** Total RAM for FIFOs (Bytes) */
     846                 :            :         uint16_t total_fifo_size;
     847                 :            :         /** Size of Rx FIFO (Bytes) */
     848                 :            :         uint16_t rx_fifo_size;
     849                 :            :         /** Size of Non-periodic Tx FIFO (Bytes) */
     850                 :            :         uint16_t nperio_tx_fifo_size;
     851                 :            : 
     852                 :            :         /** 1 if DMA is enabled, 0 otherwise. */
     853                 :            :         uint8_t dma_enable;
     854                 :            : 
     855                 :            :         /** 1 if DMA descriptor is enabled, 0 otherwise. */
     856                 :            :         uint8_t dma_desc_enable;
     857                 :            : 
     858                 :            :         /** 1 if PTI Enhancement mode is enabled, 0 otherwise. */
     859                 :            :         uint8_t pti_enh_enable;
     860                 :            : 
     861                 :            :         /** 1 if MPI Enhancement mode is enabled, 0 otherwise. */
     862                 :            :         uint8_t multiproc_int_enable;
     863                 :            : 
     864                 :            :         /** 1 if dedicated Tx FIFOs are enabled, 0 otherwise. */
     865                 :            :         uint8_t en_multiple_tx_fifo;
     866                 :            : 
     867                 :            :         /** Set to 1 if multiple packets of a high-bandwidth transfer is in
     868                 :            :          * process of being queued */
     869                 :            :         uint8_t queuing_high_bandwidth;
     870                 :            : 
     871                 :            :         /** Hardware Configuration -- stored here for convenience.*/
     872                 :            :         hwcfg1_data_t hwcfg1;
     873                 :            :         hwcfg2_data_t hwcfg2;
     874                 :            :         hwcfg3_data_t hwcfg3;
     875                 :            :         hwcfg4_data_t hwcfg4;
     876                 :            :         fifosize_data_t hptxfsiz;
     877                 :            : 
     878                 :            :         /** Host and Device Configuration -- stored here for convenience.*/
     879                 :            :         hcfg_data_t hcfg;
     880                 :            :         dcfg_data_t dcfg;
     881                 :            : 
     882                 :            :         /** The operational State, during transations
     883                 :            :          * (a_host>>a_peripherial and b_device=>b_host) this may not
     884                 :            :          * match the core but allows the software to determine
     885                 :            :          * transitions.
     886                 :            :          */
     887                 :            :         uint8_t op_state;
     888                 :            : 
     889                 :            :         /**
     890                 :            :          * Set to 1 if the HCD needs to be restarted on a session request
     891                 :            :          * interrupt. This is required if no connector ID status change has
     892                 :            :          * occurred since the HCD was last disconnected.
     893                 :            :          */
     894                 :            :         uint8_t restart_hcd_on_session_req;
     895                 :            : 
     896                 :            :         /** HCD callbacks */
     897                 :            :         /** A-Device is a_host */
     898                 :            : #define A_HOST          (1)
     899                 :            :         /** A-Device is a_suspend */
     900                 :            : #define A_SUSPEND       (2)
     901                 :            :         /** A-Device is a_peripherial */
     902                 :            : #define A_PERIPHERAL    (3)
     903                 :            :         /** B-Device is operating as a Peripheral. */
     904                 :            : #define B_PERIPHERAL    (4)
     905                 :            :         /** B-Device is operating as a Host. */
     906                 :            : #define B_HOST          (5)
     907                 :            : 
     908                 :            :         /** HCD callbacks */
     909                 :            :         struct dwc_otg_cil_callbacks *hcd_cb;
     910                 :            :         /** PCD callbacks */
     911                 :            :         struct dwc_otg_cil_callbacks *pcd_cb;
     912                 :            : 
     913                 :            :         /** Device mode Periodic Tx FIFO Mask */
     914                 :            :         uint32_t p_tx_msk;
     915                 :            :         /** Device mode Periodic Tx FIFO Mask */
     916                 :            :         uint32_t tx_msk;
     917                 :            : 
     918                 :            :         /** Workqueue object used for handling several interrupts */
     919                 :            :         dwc_workq_t *wq_otg;
     920                 :            : 
     921                 :            :         /** Timer object used for handling "Wakeup Detected" Interrupt */
     922                 :            :         dwc_timer_t *wkp_timer;
     923                 :            :         /** This arrays used for debug purposes for DEV OUT NAK enhancement */
     924                 :            :         uint32_t start_doeptsiz_val[MAX_EPS_CHANNELS];
     925                 :            :         ep_xfer_info_t ep_xfer_info[MAX_EPS_CHANNELS];
     926                 :            :         dwc_timer_t *ep_xfer_timer[MAX_EPS_CHANNELS];
     927                 :            : #ifdef DEBUG
     928                 :            :         uint32_t start_hcchar_val[MAX_EPS_CHANNELS];
     929                 :            : 
     930                 :            :         hc_xfer_info_t hc_xfer_info[MAX_EPS_CHANNELS];
     931                 :            :         dwc_timer_t *hc_xfer_timer[MAX_EPS_CHANNELS];
     932                 :            : 
     933                 :            :         uint32_t hfnum_7_samples;
     934                 :            :         uint64_t hfnum_7_frrem_accum;
     935                 :            :         uint32_t hfnum_0_samples;
     936                 :            :         uint64_t hfnum_0_frrem_accum;
     937                 :            :         uint32_t hfnum_other_samples;
     938                 :            :         uint64_t hfnum_other_frrem_accum;
     939                 :            : #endif
     940                 :            : 
     941                 :            : #ifdef DWC_UTE_CFI
     942                 :            :         uint16_t pwron_rxfsiz;
     943                 :            :         uint16_t pwron_gnptxfsiz;
     944                 :            :         uint16_t pwron_txfsiz[15];
     945                 :            : 
     946                 :            :         uint16_t init_rxfsiz;
     947                 :            :         uint16_t init_gnptxfsiz;
     948                 :            :         uint16_t init_txfsiz[15];
     949                 :            : #endif
     950                 :            : 
     951                 :            :         /** Lx state of device */
     952                 :            :         dwc_otg_lx_state_e lx_state;
     953                 :            : 
     954                 :            :         /** Saved Core Global registers */
     955                 :            :         struct dwc_otg_global_regs_backup *gr_backup;
     956                 :            :         /** Saved Host registers */
     957                 :            :         struct dwc_otg_host_regs_backup *hr_backup;
     958                 :            :         /** Saved Device registers */
     959                 :            :         struct dwc_otg_dev_regs_backup *dr_backup;
     960                 :            : 
     961                 :            :         /** Power Down Enable */
     962                 :            :         uint32_t power_down;
     963                 :            : 
     964                 :            :         /** ADP support Enable */
     965                 :            :         uint32_t adp_enable;
     966                 :            : 
     967                 :            :         /** ADP structure object */
     968                 :            :         dwc_otg_adp_t adp;
     969                 :            : 
     970                 :            :         /** hibernation/suspend flag */
     971                 :            :         int hibernation_suspend;
     972                 :            : 
     973                 :            :         /** Device mode extended hibernation flag */
     974                 :            :         int xhib;
     975                 :            : 
     976                 :            :         /** OTG revision supported */
     977                 :            :         uint32_t otg_ver;
     978                 :            : 
     979                 :            :         /** OTG status flag used for HNP polling */
     980                 :            :         uint8_t otg_sts;
     981                 :            : 
     982                 :            :         /** Pointer to either hcd->lock or pcd->lock */
     983                 :            :         dwc_spinlock_t *lock;
     984                 :            : 
     985                 :            :         /** Start predict NextEP based on Learning Queue if equal 1,
     986                 :            :          * also used as counter of disabled NP IN EP's */
     987                 :            :         uint8_t start_predict;
     988                 :            : 
     989                 :            :         /** NextEp sequence, including EP0: nextep_seq[] = EP if non-periodic and
     990                 :            :          * active, 0xff otherwise */
     991                 :            :         uint8_t nextep_seq[MAX_EPS_CHANNELS];
     992                 :            : 
     993                 :            :         /** Index of fisrt EP in nextep_seq array which should be re-enabled **/
     994                 :            :         uint8_t first_in_nextep_seq;
     995                 :            : 
     996                 :            :         /** Frame number while entering to ISR - needed for ISOCs **/
     997                 :            :         uint32_t frame_num;
     998                 :            : 
     999                 :            : };
    1000                 :            : 
    1001                 :            : #ifdef DEBUG
    1002                 :            : /*
    1003                 :            :  * This function is called when transfer is timed out.
    1004                 :            :  */
    1005                 :            : extern void hc_xfer_timeout(void *ptr);
    1006                 :            : #endif
    1007                 :            : 
    1008                 :            : /*
    1009                 :            :  * This function is called when transfer is timed out on endpoint.
    1010                 :            :  */
    1011                 :            : extern void ep_xfer_timeout(void *ptr);
    1012                 :            : 
    1013                 :            : /*
    1014                 :            :  * The following functions are functions for works
    1015                 :            :  * using during handling some interrupts
    1016                 :            :  */
    1017                 :            : extern void w_conn_id_status_change(void *p);
    1018                 :            : 
    1019                 :            : extern void w_wakeup_detected(void *p);
    1020                 :            : 
    1021                 :            : /** Saves global register values into system memory. */
    1022                 :            : extern int dwc_otg_save_global_regs(dwc_otg_core_if_t * core_if);
    1023                 :            : /** Saves device register values into system memory. */
    1024                 :            : extern int dwc_otg_save_dev_regs(dwc_otg_core_if_t * core_if);
    1025                 :            : /** Saves host register values into system memory. */
    1026                 :            : extern int dwc_otg_save_host_regs(dwc_otg_core_if_t * core_if);
    1027                 :            : /** Restore global register values. */
    1028                 :            : extern int dwc_otg_restore_global_regs(dwc_otg_core_if_t * core_if);
    1029                 :            : /** Restore host register values. */
    1030                 :            : extern int dwc_otg_restore_host_regs(dwc_otg_core_if_t * core_if, int reset);
    1031                 :            : /** Restore device register values. */
    1032                 :            : extern int dwc_otg_restore_dev_regs(dwc_otg_core_if_t * core_if,
    1033                 :            :                                     int rem_wakeup);
    1034                 :            : extern int restore_lpm_i2c_regs(dwc_otg_core_if_t * core_if);
    1035                 :            : extern int restore_essential_regs(dwc_otg_core_if_t * core_if, int rmode,
    1036                 :            :                                   int is_host);
    1037                 :            : 
    1038                 :            : extern int dwc_otg_host_hibernation_restore(dwc_otg_core_if_t * core_if,
    1039                 :            :                                             int restore_mode, int reset);
    1040                 :            : extern int dwc_otg_device_hibernation_restore(dwc_otg_core_if_t * core_if,
    1041                 :            :                                               int rem_wakeup, int reset);
    1042                 :            : 
    1043                 :            : /*
    1044                 :            :  * The following functions support initialization of the CIL driver component
    1045                 :            :  * and the DWC_otg controller.
    1046                 :            :  */
    1047                 :            : extern void dwc_otg_core_host_init(dwc_otg_core_if_t * _core_if);
    1048                 :            : extern void dwc_otg_core_dev_init(dwc_otg_core_if_t * _core_if);
    1049                 :            : 
    1050                 :            : /** @name Device CIL Functions
    1051                 :            :  * The following functions support managing the DWC_otg controller in device
    1052                 :            :  * mode.
    1053                 :            :  */
    1054                 :            : /**@{*/
    1055                 :            : extern void dwc_otg_wakeup(dwc_otg_core_if_t * _core_if);
    1056                 :            : extern void dwc_otg_read_setup_packet(dwc_otg_core_if_t * _core_if,
    1057                 :            :                                       uint32_t * _dest);
    1058                 :            : extern uint32_t dwc_otg_get_frame_number(dwc_otg_core_if_t * _core_if);
    1059                 :            : extern void dwc_otg_ep0_activate(dwc_otg_core_if_t * _core_if, dwc_ep_t * _ep);
    1060                 :            : extern void dwc_otg_ep_activate(dwc_otg_core_if_t * _core_if, dwc_ep_t * _ep);
    1061                 :            : extern void dwc_otg_ep_deactivate(dwc_otg_core_if_t * _core_if, dwc_ep_t * _ep);
    1062                 :            : extern void dwc_otg_ep_start_transfer(dwc_otg_core_if_t * _core_if,
    1063                 :            :                                       dwc_ep_t * _ep);
    1064                 :            : extern void dwc_otg_ep_start_zl_transfer(dwc_otg_core_if_t * _core_if,
    1065                 :            :                                          dwc_ep_t * _ep);
    1066                 :            : extern void dwc_otg_ep0_start_transfer(dwc_otg_core_if_t * _core_if,
    1067                 :            :                                        dwc_ep_t * _ep);
    1068                 :            : extern void dwc_otg_ep0_continue_transfer(dwc_otg_core_if_t * _core_if,
    1069                 :            :                                           dwc_ep_t * _ep);
    1070                 :            : extern void dwc_otg_ep_write_packet(dwc_otg_core_if_t * _core_if,
    1071                 :            :                                     dwc_ep_t * _ep, int _dma);
    1072                 :            : extern void dwc_otg_ep_set_stall(dwc_otg_core_if_t * _core_if, dwc_ep_t * _ep);
    1073                 :            : extern void dwc_otg_ep_clear_stall(dwc_otg_core_if_t * _core_if,
    1074                 :            :                                    dwc_ep_t * _ep);
    1075                 :            : extern void dwc_otg_enable_device_interrupts(dwc_otg_core_if_t * _core_if);
    1076                 :            : 
    1077                 :            : #ifdef DWC_EN_ISOC
    1078                 :            : extern void dwc_otg_iso_ep_start_frm_transfer(dwc_otg_core_if_t * core_if,
    1079                 :            :                                               dwc_ep_t * ep);
    1080                 :            : extern void dwc_otg_iso_ep_start_buf_transfer(dwc_otg_core_if_t * core_if,
    1081                 :            :                                               dwc_ep_t * ep);
    1082                 :            : #endif /* DWC_EN_ISOC */
    1083                 :            : /**@}*/
    1084                 :            : 
    1085                 :            : /** @name Host CIL Functions
    1086                 :            :  * The following functions support managing the DWC_otg controller in host
    1087                 :            :  * mode.
    1088                 :            :  */
    1089                 :            : /**@{*/
    1090                 :            : extern void dwc_otg_hc_init(dwc_otg_core_if_t * _core_if, dwc_hc_t * _hc);
    1091                 :            : extern void dwc_otg_hc_halt(dwc_otg_core_if_t * _core_if,
    1092                 :            :                             dwc_hc_t * _hc, dwc_otg_halt_status_e _halt_status);
    1093                 :            : extern void dwc_otg_hc_cleanup(dwc_otg_core_if_t * _core_if, dwc_hc_t * _hc);
    1094                 :            : extern void dwc_otg_hc_start_transfer(dwc_otg_core_if_t * _core_if,
    1095                 :            :                                       dwc_hc_t * _hc);
    1096                 :            : extern int dwc_otg_hc_continue_transfer(dwc_otg_core_if_t * _core_if,
    1097                 :            :                                         dwc_hc_t * _hc);
    1098                 :            : extern void dwc_otg_hc_do_ping(dwc_otg_core_if_t * _core_if, dwc_hc_t * _hc);
    1099                 :            : extern void dwc_otg_hc_write_packet(dwc_otg_core_if_t * _core_if,
    1100                 :            :                                     dwc_hc_t * _hc);
    1101                 :            : extern void dwc_otg_enable_host_interrupts(dwc_otg_core_if_t * _core_if);
    1102                 :            : extern void dwc_otg_disable_host_interrupts(dwc_otg_core_if_t * _core_if);
    1103                 :            : 
    1104                 :            : extern void dwc_otg_hc_start_transfer_ddma(dwc_otg_core_if_t * core_if,
    1105                 :            :                                            dwc_hc_t * hc);
    1106                 :            : 
    1107                 :            : extern uint32_t calc_frame_interval(dwc_otg_core_if_t * core_if);
    1108                 :            : 
    1109                 :            : /* Macro used to clear one channel interrupt */
    1110                 :            : #define clear_hc_int(_hc_regs_, _intr_) \
    1111                 :            : do { \
    1112                 :            :         hcint_data_t hcint_clear = {.d32 = 0}; \
    1113                 :            :         hcint_clear.b._intr_ = 1; \
    1114                 :            :         DWC_WRITE_REG32(&(_hc_regs_)->hcint, hcint_clear.d32); \
    1115                 :            : } while (0)
    1116                 :            : 
    1117                 :            : /*
    1118                 :            :  * Macro used to disable one channel interrupt. Channel interrupts are
    1119                 :            :  * disabled when the channel is halted or released by the interrupt handler.
    1120                 :            :  * There is no need to handle further interrupts of that type until the
    1121                 :            :  * channel is re-assigned. In fact, subsequent handling may cause crashes
    1122                 :            :  * because the channel structures are cleaned up when the channel is released.
    1123                 :            :  */
    1124                 :            : #define disable_hc_int(_hc_regs_, _intr_) \
    1125                 :            : do { \
    1126                 :            :         hcintmsk_data_t hcintmsk = {.d32 = 0}; \
    1127                 :            :         hcintmsk.b._intr_ = 1; \
    1128                 :            :         DWC_MODIFY_REG32(&(_hc_regs_)->hcintmsk, hcintmsk.d32, 0); \
    1129                 :            : } while (0)
    1130                 :            : 
    1131                 :            : /**
    1132                 :            :  * This function Reads HPRT0 in preparation to modify. It keeps the
    1133                 :            :  * WC bits 0 so that if they are read as 1, they won't clear when you
    1134                 :            :  * write it back
    1135                 :            :  */
    1136                 :       1035 : static inline uint32_t dwc_otg_read_hprt0(dwc_otg_core_if_t * _core_if)
    1137                 :            : {
    1138                 :            :         hprt0_data_t hprt0;
    1139                 :       1035 :         hprt0.d32 = DWC_READ_REG32(_core_if->host_if->hprt0);
    1140                 :       1035 :         hprt0.b.prtena = 0;
    1141                 :       1035 :         hprt0.b.prtconndet = 0;
    1142                 :       1035 :         hprt0.b.prtenchng = 0;
    1143                 :       1035 :         hprt0.b.prtovrcurrchng = 0;
    1144                 :       1035 :         return hprt0.d32;
    1145                 :            : }
    1146                 :            : 
    1147                 :            : /**@}*/
    1148                 :            : 
    1149                 :            : /** @name Common CIL Functions
    1150                 :            :  * The following functions support managing the DWC_otg controller in either
    1151                 :            :  * device or host mode.
    1152                 :            :  */
    1153                 :            : /**@{*/
    1154                 :            : 
    1155                 :            : extern void dwc_otg_read_packet(dwc_otg_core_if_t * core_if,
    1156                 :            :                                 uint8_t * dest, uint16_t bytes);
    1157                 :            : 
    1158                 :            : extern void dwc_otg_flush_tx_fifo(dwc_otg_core_if_t * _core_if, const int _num);
    1159                 :            : extern void dwc_otg_flush_rx_fifo(dwc_otg_core_if_t * _core_if);
    1160                 :            : extern void dwc_otg_core_reset(dwc_otg_core_if_t * _core_if);
    1161                 :            : 
    1162                 :            : /**
    1163                 :            :  * This function returns the Core Interrupt register.
    1164                 :            :  */
    1165                 :          0 : static inline uint32_t dwc_otg_read_core_intr(dwc_otg_core_if_t * core_if)
    1166                 :            : {
    1167                 :          0 :         return (DWC_READ_REG32(&core_if->core_global_regs->gintsts) &
    1168                 :          0 :                 DWC_READ_REG32(&core_if->core_global_regs->gintmsk));
    1169                 :            : }
    1170                 :            : 
    1171                 :            : /**
    1172                 :            :  * This function returns the OTG Interrupt register.
    1173                 :            :  */
    1174                 :            : static inline uint32_t dwc_otg_read_otg_intr(dwc_otg_core_if_t * core_if)
    1175                 :            : {
    1176                 :            :         return (DWC_READ_REG32(&core_if->core_global_regs->gotgint));
    1177                 :            : }
    1178                 :            : 
    1179                 :            : /**
    1180                 :            :  * This function reads the Device All Endpoints Interrupt register and
    1181                 :            :  * returns the IN endpoint interrupt bits.
    1182                 :            :  */
    1183                 :          0 : static inline uint32_t dwc_otg_read_dev_all_in_ep_intr(dwc_otg_core_if_t *
    1184                 :            :                                                        core_if)
    1185                 :            : {
    1186                 :            : 
    1187                 :            :         uint32_t v;
    1188                 :            : 
    1189         [ #  # ]:          0 :         if (core_if->multiproc_int_enable) {
    1190                 :          0 :                 v = DWC_READ_REG32(&core_if->dev_if->
    1191                 :            :                                    dev_global_regs->deachint) &
    1192                 :          0 :                     DWC_READ_REG32(&core_if->
    1193                 :          0 :                                    dev_if->dev_global_regs->deachintmsk);
    1194                 :            :         } else {
    1195                 :          0 :                 v = DWC_READ_REG32(&core_if->dev_if->dev_global_regs->daint) &
    1196                 :          0 :                     DWC_READ_REG32(&core_if->dev_if->dev_global_regs->daintmsk);
    1197                 :            :         }
    1198                 :          0 :         return (v & 0xffff);
    1199                 :            : }
    1200                 :            : 
    1201                 :            : /**
    1202                 :            :  * This function reads the Device All Endpoints Interrupt register and
    1203                 :            :  * returns the OUT endpoint interrupt bits.
    1204                 :            :  */
    1205                 :          0 : static inline uint32_t dwc_otg_read_dev_all_out_ep_intr(dwc_otg_core_if_t *
    1206                 :            :                                                         core_if)
    1207                 :            : {
    1208                 :            :         uint32_t v;
    1209                 :            : 
    1210         [ #  # ]:          0 :         if (core_if->multiproc_int_enable) {
    1211                 :          0 :                 v = DWC_READ_REG32(&core_if->dev_if->
    1212                 :            :                                    dev_global_regs->deachint) &
    1213                 :          0 :                     DWC_READ_REG32(&core_if->
    1214                 :          0 :                                    dev_if->dev_global_regs->deachintmsk);
    1215                 :            :         } else {
    1216                 :          0 :                 v = DWC_READ_REG32(&core_if->dev_if->dev_global_regs->daint) &
    1217                 :          0 :                     DWC_READ_REG32(&core_if->dev_if->dev_global_regs->daintmsk);
    1218                 :            :         }
    1219                 :            : 
    1220                 :          0 :         return ((v & 0xffff0000) >> 16);
    1221                 :            : }
    1222                 :            : 
    1223                 :            : /**
    1224                 :            :  * This function returns the Device IN EP Interrupt register
    1225                 :            :  */
    1226                 :          0 : static inline uint32_t dwc_otg_read_dev_in_ep_intr(dwc_otg_core_if_t * core_if,
    1227                 :            :                                                    dwc_ep_t * ep)
    1228                 :            : {
    1229                 :          0 :         dwc_otg_dev_if_t *dev_if = core_if->dev_if;
    1230                 :            :         uint32_t v, msk, emp;
    1231                 :            : 
    1232         [ #  # ]:          0 :         if (core_if->multiproc_int_enable) {
    1233                 :          0 :                 msk =
    1234                 :          0 :                     DWC_READ_REG32(&dev_if->
    1235                 :          0 :                                    dev_global_regs->diepeachintmsk[ep->num]);
    1236                 :          0 :                 emp =
    1237                 :          0 :                     DWC_READ_REG32(&dev_if->
    1238                 :            :                                    dev_global_regs->dtknqr4_fifoemptymsk);
    1239                 :          0 :                 msk |= ((emp >> ep->num) & 0x1) << 7;
    1240                 :          0 :                 v = DWC_READ_REG32(&dev_if->in_ep_regs[ep->num]->diepint) & msk;
    1241                 :            :         } else {
    1242                 :          0 :                 msk = DWC_READ_REG32(&dev_if->dev_global_regs->diepmsk);
    1243                 :          0 :                 emp =
    1244                 :          0 :                     DWC_READ_REG32(&dev_if->
    1245                 :            :                                    dev_global_regs->dtknqr4_fifoemptymsk);
    1246                 :          0 :                 msk |= ((emp >> ep->num) & 0x1) << 7;
    1247                 :          0 :                 v = DWC_READ_REG32(&dev_if->in_ep_regs[ep->num]->diepint) & msk;
    1248                 :            :         }
    1249                 :            : 
    1250                 :          0 :         return v;
    1251                 :            : }
    1252                 :            : 
    1253                 :            : /**
    1254                 :            :  * This function returns the Device OUT EP Interrupt register
    1255                 :            :  */
    1256                 :          0 : static inline uint32_t dwc_otg_read_dev_out_ep_intr(dwc_otg_core_if_t *
    1257                 :            :                                                     _core_if, dwc_ep_t * _ep)
    1258                 :            : {
    1259                 :          0 :         dwc_otg_dev_if_t *dev_if = _core_if->dev_if;
    1260                 :            :         uint32_t v;
    1261                 :            :         doepmsk_data_t msk = {.d32 = 0 };
    1262                 :            : 
    1263         [ #  # ]:          0 :         if (_core_if->multiproc_int_enable) {
    1264                 :          0 :                 msk.d32 =
    1265                 :          0 :                     DWC_READ_REG32(&dev_if->
    1266                 :          0 :                                    dev_global_regs->doepeachintmsk[_ep->num]);
    1267         [ #  # ]:          0 :                 if (_core_if->pti_enh_enable) {
    1268                 :          0 :                         msk.b.pktdrpsts = 1;
    1269                 :            :                 }
    1270                 :          0 :                 v = DWC_READ_REG32(&dev_if->
    1271                 :          0 :                                    out_ep_regs[_ep->num]->doepint) & msk.d32;
    1272                 :            :         } else {
    1273                 :          0 :                 msk.d32 = DWC_READ_REG32(&dev_if->dev_global_regs->doepmsk);
    1274         [ #  # ]:          0 :                 if (_core_if->pti_enh_enable) {
    1275                 :          0 :                         msk.b.pktdrpsts = 1;
    1276                 :            :                 }
    1277                 :          0 :                 v = DWC_READ_REG32(&dev_if->
    1278                 :          0 :                                    out_ep_regs[_ep->num]->doepint) & msk.d32;
    1279                 :            :         }
    1280                 :          0 :         return v;
    1281                 :            : }
    1282                 :            : 
    1283                 :            : /**
    1284                 :            :  * This function returns the Host All Channel Interrupt register
    1285                 :            :  */
    1286                 :            : static inline uint32_t dwc_otg_read_host_all_channels_intr(dwc_otg_core_if_t *
    1287                 :            :                                                            _core_if)
    1288                 :            : {
    1289                 :          0 :         return (DWC_READ_REG32(&_core_if->host_if->host_global_regs->haint));
    1290                 :            : }
    1291                 :            : 
    1292                 :            : static inline uint32_t dwc_otg_read_host_channel_intr(dwc_otg_core_if_t *
    1293                 :            :                                                       _core_if, dwc_hc_t * _hc)
    1294                 :            : {
    1295                 :            :         return (DWC_READ_REG32
    1296                 :            :                 (&_core_if->host_if->hc_regs[_hc->hc_num]->hcint));
    1297                 :            : }
    1298                 :            : 
    1299                 :            : /**
    1300                 :            :  * This function returns the mode of the operation, host or device.
    1301                 :            :  *
    1302                 :            :  * @return 0 - Device Mode, 1 - Host Mode
    1303                 :            :  */
    1304                 :            : static inline uint32_t dwc_otg_mode(dwc_otg_core_if_t * _core_if)
    1305                 :            : {
    1306                 :   55095826 :         return (DWC_READ_REG32(&_core_if->core_global_regs->gintsts) & 0x1);
    1307                 :            : }
    1308                 :            : 
    1309                 :            : /**@}*/
    1310                 :            : 
    1311                 :            : /**
    1312                 :            :  * DWC_otg CIL callback structure. This structure allows the HCD and
    1313                 :            :  * PCD to register functions used for starting and stopping the PCD
    1314                 :            :  * and HCD for role change on for a DRD.
    1315                 :            :  */
    1316                 :            : typedef struct dwc_otg_cil_callbacks {
    1317                 :            :         /** Start function for role change */
    1318                 :            :         int (*start) (void *_p);
    1319                 :            :         /** Stop Function for role change */
    1320                 :            :         int (*stop) (void *_p);
    1321                 :            :         /** Disconnect Function for role change */
    1322                 :            :         int (*disconnect) (void *_p);
    1323                 :            :         /** Resume/Remote wakeup Function */
    1324                 :            :         int (*resume_wakeup) (void *_p);
    1325                 :            :         /** Suspend function */
    1326                 :            :         int (*suspend) (void *_p);
    1327                 :            :         /** Session Start (SRP) */
    1328                 :            :         int (*session_start) (void *_p);
    1329                 :            : #ifdef CONFIG_USB_DWC_OTG_LPM
    1330                 :            :         /** Sleep (switch to L0 state) */
    1331                 :            :         int (*sleep) (void *_p);
    1332                 :            : #endif
    1333                 :            :         /** Pointer passed to start() and stop() */
    1334                 :            :         void *p;
    1335                 :            : } dwc_otg_cil_callbacks_t;
    1336                 :            : 
    1337                 :            : extern void dwc_otg_cil_register_pcd_callbacks(dwc_otg_core_if_t * _core_if,
    1338                 :            :                                                dwc_otg_cil_callbacks_t * _cb,
    1339                 :            :                                                void *_p);
    1340                 :            : extern void dwc_otg_cil_register_hcd_callbacks(dwc_otg_core_if_t * _core_if,
    1341                 :            :                                                dwc_otg_cil_callbacks_t * _cb,
    1342                 :            :                                                void *_p);
    1343                 :            : 
    1344                 :            : void dwc_otg_initiate_srp(dwc_otg_core_if_t * core_if);
    1345                 :            : 
    1346                 :            : //////////////////////////////////////////////////////////////////////
    1347                 :            : /** Start the HCD.  Helper function for using the HCD callbacks.
    1348                 :            :  *
    1349                 :            :  * @param core_if Programming view of DWC_otg controller.
    1350                 :            :  */
    1351                 :            : static inline void cil_hcd_start(dwc_otg_core_if_t * core_if)
    1352                 :            : {
    1353   [ #  #  #  #  :          0 :         if (core_if->hcd_cb && core_if->hcd_cb->start) {
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
             #  #  #  # ]
    1354                 :          0 :                 core_if->hcd_cb->start(core_if->hcd_cb->p);
    1355                 :            :         }
    1356                 :            : }
    1357                 :            : 
    1358                 :            : /** Stop the HCD.  Helper function for using the HCD callbacks.
    1359                 :            :  *
    1360                 :            :  * @param core_if Programming view of DWC_otg controller.
    1361                 :            :  */
    1362                 :            : static inline void cil_hcd_stop(dwc_otg_core_if_t * core_if)
    1363                 :            : {
    1364   [ #  #  #  # ]:          0 :         if (core_if->hcd_cb && core_if->hcd_cb->stop) {
    1365                 :          0 :                 core_if->hcd_cb->stop(core_if->hcd_cb->p);
    1366                 :            :         }
    1367                 :            : }
    1368                 :            : 
    1369                 :            : /** Disconnect the HCD.  Helper function for using the HCD callbacks.
    1370                 :            :  *
    1371                 :            :  * @param core_if Programming view of DWC_otg controller.
    1372                 :            :  */
    1373                 :            : static inline void cil_hcd_disconnect(dwc_otg_core_if_t * core_if)
    1374                 :            : {
    1375   [ #  #  #  #  :          0 :         if (core_if->hcd_cb && core_if->hcd_cb->disconnect) {
          #  #  #  #  #  
          #  #  #  #  #  
                   #  # ]
    1376                 :          0 :                 core_if->hcd_cb->disconnect(core_if->hcd_cb->p);
    1377                 :            :         }
    1378                 :            : }
    1379                 :            : 
    1380                 :            : /** Inform the HCD the a New Session has begun.  Helper function for
    1381                 :            :  * using the HCD callbacks.
    1382                 :            :  *
    1383                 :            :  * @param core_if Programming view of DWC_otg controller.
    1384                 :            :  */
    1385                 :            : static inline void cil_hcd_session_start(dwc_otg_core_if_t * core_if)
    1386                 :            : {
    1387   [ #  #  #  # ]:          0 :         if (core_if->hcd_cb && core_if->hcd_cb->session_start) {
    1388                 :          0 :                 core_if->hcd_cb->session_start(core_if->hcd_cb->p);
    1389                 :            :         }
    1390                 :            : }
    1391                 :            : 
    1392                 :            : #ifdef CONFIG_USB_DWC_OTG_LPM
    1393                 :            : /**
    1394                 :            :  * Inform the HCD about LPM sleep.
    1395                 :            :  * Helper function for using the HCD callbacks.
    1396                 :            :  *
    1397                 :            :  * @param core_if Programming view of DWC_otg controller.
    1398                 :            :  */
    1399                 :            : static inline void cil_hcd_sleep(dwc_otg_core_if_t * core_if)
    1400                 :            : {
    1401                 :            :         if (core_if->hcd_cb && core_if->hcd_cb->sleep) {
    1402                 :            :                 core_if->hcd_cb->sleep(core_if->hcd_cb->p);
    1403                 :            :         }
    1404                 :            : }
    1405                 :            : #endif
    1406                 :            : 
    1407                 :            : /** Resume the HCD.  Helper function for using the HCD callbacks.
    1408                 :            :  *
    1409                 :            :  * @param core_if Programming view of DWC_otg controller.
    1410                 :            :  */
    1411                 :            : static inline void cil_hcd_resume(dwc_otg_core_if_t * core_if)
    1412                 :            : {
    1413   [ #  #  #  # ]:          0 :         if (core_if->hcd_cb && core_if->hcd_cb->resume_wakeup) {
    1414                 :          0 :                 core_if->hcd_cb->resume_wakeup(core_if->hcd_cb->p);
    1415                 :            :         }
    1416                 :            : }
    1417                 :            : 
    1418                 :            : /** Start the PCD.  Helper function for using the PCD callbacks.
    1419                 :            :  *
    1420                 :            :  * @param core_if Programming view of DWC_otg controller.
    1421                 :            :  */
    1422                 :            : static inline void cil_pcd_start(dwc_otg_core_if_t * core_if)
    1423                 :            : {
    1424   [ #  #  #  #  :          0 :         if (core_if->pcd_cb && core_if->pcd_cb->start) {
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
                #  #  # ]
    1425                 :          0 :                 core_if->pcd_cb->start(core_if->pcd_cb->p);
    1426                 :            :         }
    1427                 :            : }
    1428                 :            : 
    1429                 :            : /** Stop the PCD.  Helper function for using the PCD callbacks.
    1430                 :            :  *
    1431                 :            :  * @param core_if Programming view of DWC_otg controller.
    1432                 :            :  */
    1433                 :            : static inline void cil_pcd_stop(dwc_otg_core_if_t * core_if)
    1434                 :            : {
    1435   [ #  #  #  #  :          0 :         if (core_if->pcd_cb && core_if->pcd_cb->stop) {
          #  #  #  #  #  
          #  #  #  #  #  
                   #  # ]
    1436                 :          0 :                 core_if->pcd_cb->stop(core_if->pcd_cb->p);
    1437                 :            :         }
    1438                 :            : }
    1439                 :            : 
    1440                 :            : /** Suspend the PCD.  Helper function for using the PCD callbacks.
    1441                 :            :  *
    1442                 :            :  * @param core_if Programming view of DWC_otg controller.
    1443                 :            :  */
    1444                 :            : static inline void cil_pcd_suspend(dwc_otg_core_if_t * core_if)
    1445                 :            : {
    1446   [ #  #  #  # ]:          0 :         if (core_if->pcd_cb && core_if->pcd_cb->suspend) {
    1447                 :          0 :                 core_if->pcd_cb->suspend(core_if->pcd_cb->p);
    1448                 :            :         }
    1449                 :            : }
    1450                 :            : 
    1451                 :            : /** Resume the PCD.  Helper function for using the PCD callbacks.
    1452                 :            :  *
    1453                 :            :  * @param core_if Programming view of DWC_otg controller.
    1454                 :            :  */
    1455                 :            : static inline void cil_pcd_resume(dwc_otg_core_if_t * core_if)
    1456                 :            : {
    1457   [ #  #  #  # ]:          0 :         if (core_if->pcd_cb && core_if->pcd_cb->resume_wakeup) {
    1458                 :          0 :                 core_if->pcd_cb->resume_wakeup(core_if->pcd_cb->p);
    1459                 :            :         }
    1460                 :            : }
    1461                 :            : 
    1462                 :            : //////////////////////////////////////////////////////////////////////
    1463                 :            : 
    1464                 :            : #endif

Generated by: LCOV version 1.14