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

           Branch data     Line data    Source code
       1                 :            : /* ==========================================================================
       2                 :            :  * $File: //dwh/usb_iip/dev/software/otg/linux/drivers/dwc_otg_pcd.h $
       3                 :            :  * $Revision: #48 $
       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                 :            : #ifndef DWC_HOST_ONLY
      34                 :            : #if !defined(__DWC_PCD_H__)
      35                 :            : #define __DWC_PCD_H__
      36                 :            : 
      37                 :            : #include "dwc_otg_os_dep.h"
      38                 :            : #include "usb.h"
      39                 :            : #include "dwc_otg_cil.h"
      40                 :            : #include "dwc_otg_pcd_if.h"
      41                 :            : #include "dwc_otg_driver.h"
      42                 :            : 
      43                 :            : struct cfiobject;
      44                 :            : 
      45                 :            : /**
      46                 :            :  * @file
      47                 :            :  *
      48                 :            :  * This file contains the structures, constants, and interfaces for
      49                 :            :  * the Perpherial Contoller Driver (PCD).
      50                 :            :  *
      51                 :            :  * The Peripheral Controller Driver (PCD) for Linux will implement the
      52                 :            :  * Gadget API, so that the existing Gadget drivers can be used. For
      53                 :            :  * the Mass Storage Function driver the File-backed USB Storage Gadget
      54                 :            :  * (FBS) driver will be used.  The FBS driver supports the
      55                 :            :  * Control-Bulk (CB), Control-Bulk-Interrupt (CBI), and Bulk-Only
      56                 :            :  * transports.
      57                 :            :  *
      58                 :            :  */
      59                 :            : 
      60                 :            : /** Invalid DMA Address */
      61                 :            : #define DWC_DMA_ADDR_INVALID    (~(dwc_dma_t)0)
      62                 :            : 
      63                 :            : /** Max Transfer size for any EP */
      64                 :            : #define DDMA_MAX_TRANSFER_SIZE 65535
      65                 :            : 
      66                 :            : /**
      67                 :            :  * Get the pointer to the core_if from the pcd pointer.
      68                 :            :  */
      69                 :            : #define GET_CORE_IF( _pcd ) (_pcd->core_if)
      70                 :            : 
      71                 :            : /**
      72                 :            :  * States of EP0.
      73                 :            :  */
      74                 :            : typedef enum ep0_state {
      75                 :            :         EP0_DISCONNECT,         /* no host */
      76                 :            :         EP0_IDLE,
      77                 :            :         EP0_IN_DATA_PHASE,
      78                 :            :         EP0_OUT_DATA_PHASE,
      79                 :            :         EP0_IN_STATUS_PHASE,
      80                 :            :         EP0_OUT_STATUS_PHASE,
      81                 :            :         EP0_STALL,
      82                 :            : } ep0state_e;
      83                 :            : 
      84                 :            : /** Fordward declaration.*/
      85                 :            : struct dwc_otg_pcd;
      86                 :            : 
      87                 :            : /** DWC_otg iso request structure.
      88                 :            :  *
      89                 :            :  */
      90                 :            : typedef struct usb_iso_request dwc_otg_pcd_iso_request_t;
      91                 :            : 
      92                 :            : #ifdef DWC_UTE_PER_IO
      93                 :            : 
      94                 :            : /**
      95                 :            :  * This shall be the exact analogy of the same type structure defined in the
      96                 :            :  * usb_gadget.h. Each descriptor contains
      97                 :            :  */
      98                 :            : struct dwc_iso_pkt_desc_port {
      99                 :            :         uint32_t offset;
     100                 :            :         uint32_t length;        /* expected length */
     101                 :            :         uint32_t actual_length;
     102                 :            :         uint32_t status;
     103                 :            : };
     104                 :            : 
     105                 :            : struct dwc_iso_xreq_port {
     106                 :            :         /** transfer/submission flag */
     107                 :            :         uint32_t tr_sub_flags;
     108                 :            :         /** Start the request ASAP */
     109                 :            : #define DWC_EREQ_TF_ASAP                0x00000002
     110                 :            :         /** Just enqueue the request w/o initiating a transfer */
     111                 :            : #define DWC_EREQ_TF_ENQUEUE             0x00000004
     112                 :            : 
     113                 :            :         /**
     114                 :            :         * count of ISO packets attached to this request - shall
     115                 :            :         * not exceed the pio_alloc_pkt_count
     116                 :            :         */
     117                 :            :         uint32_t pio_pkt_count;
     118                 :            :         /** count of ISO packets allocated for this request */
     119                 :            :         uint32_t pio_alloc_pkt_count;
     120                 :            :         /** number of ISO packet errors */
     121                 :            :         uint32_t error_count;
     122                 :            :         /** reserved for future extension */
     123                 :            :         uint32_t res;
     124                 :            :         /** Will be allocated and freed in the UTE gadget and based on the CFC value */
     125                 :            :         struct dwc_iso_pkt_desc_port *per_io_frame_descs;
     126                 :            : };
     127                 :            : #endif
     128                 :            : /** DWC_otg request structure.
     129                 :            :  * This structure is a list of requests.
     130                 :            :  */
     131                 :            : typedef struct dwc_otg_pcd_request {
     132                 :            :         void *priv;
     133                 :            :         void *buf;
     134                 :            :         dwc_dma_t dma;
     135                 :            :         uint32_t length;
     136                 :            :         uint32_t actual;
     137                 :            :         unsigned sent_zlp:1;
     138                 :            :     /**
     139                 :            :      * Used instead of original buffer if
     140                 :            :      * it(physical address) is not dword-aligned.
     141                 :            :      **/
     142                 :            :      uint8_t *dw_align_buf;
     143                 :            :      dwc_dma_t dw_align_buf_dma;
     144                 :            : 
     145                 :            :          DWC_CIRCLEQ_ENTRY(dwc_otg_pcd_request) queue_entry;
     146                 :            : #ifdef DWC_UTE_PER_IO
     147                 :            :         struct dwc_iso_xreq_port ext_req;
     148                 :            :         //void *priv_ereq_nport; /*  */
     149                 :            : #endif
     150                 :            : } dwc_otg_pcd_request_t;
     151                 :            : 
     152                 :            : DWC_CIRCLEQ_HEAD(req_list, dwc_otg_pcd_request);
     153                 :            : 
     154                 :            : /**       PCD EP structure.
     155                 :            :  * This structure describes an EP, there is an array of EPs in the PCD
     156                 :            :  * structure.
     157                 :            :  */
     158                 :            : typedef struct dwc_otg_pcd_ep {
     159                 :            :         /** USB EP Descriptor */
     160                 :            :         const usb_endpoint_descriptor_t *desc;
     161                 :            : 
     162                 :            :         /** queue of dwc_otg_pcd_requests. */
     163                 :            :         struct req_list queue;
     164                 :            :         unsigned stopped:1;
     165                 :            :         unsigned disabling:1;
     166                 :            :         unsigned dma:1;
     167                 :            :         unsigned queue_sof:1;
     168                 :            : 
     169                 :            : #ifdef DWC_EN_ISOC
     170                 :            :         /** ISOC req handle passed */
     171                 :            :         void *iso_req_handle;
     172                 :            : #endif                          //_EN_ISOC_
     173                 :            : 
     174                 :            :         /** DWC_otg ep data. */
     175                 :            :         dwc_ep_t dwc_ep;
     176                 :            : 
     177                 :            :         /** Pointer to PCD */
     178                 :            :         struct dwc_otg_pcd *pcd;
     179                 :            : 
     180                 :            :         void *priv;
     181                 :            : } dwc_otg_pcd_ep_t;
     182                 :            : 
     183                 :            : /** DWC_otg PCD Structure.
     184                 :            :  * This structure encapsulates the data for the dwc_otg PCD.
     185                 :            :  */
     186                 :            : struct dwc_otg_pcd {
     187                 :            :         const struct dwc_otg_pcd_function_ops *fops;
     188                 :            :         /** The DWC otg device pointer */
     189                 :            :         struct dwc_otg_device *otg_dev;
     190                 :            :         /** Core Interface */
     191                 :            :         dwc_otg_core_if_t *core_if;
     192                 :            :         /** State of EP0 */
     193                 :            :         ep0state_e ep0state;
     194                 :            :         /** EP0 Request is pending */
     195                 :            :         unsigned ep0_pending:1;
     196                 :            :         /** Indicates when SET CONFIGURATION Request is in process */
     197                 :            :         unsigned request_config:1;
     198                 :            :         /** The state of the Remote Wakeup Enable. */
     199                 :            :         unsigned remote_wakeup_enable:1;
     200                 :            :         /** The state of the B-Device HNP Enable. */
     201                 :            :         unsigned b_hnp_enable:1;
     202                 :            :         /** The state of A-Device HNP Support. */
     203                 :            :         unsigned a_hnp_support:1;
     204                 :            :         /** The state of the A-Device Alt HNP support. */
     205                 :            :         unsigned a_alt_hnp_support:1;
     206                 :            :         /** Count of pending Requests */
     207                 :            :         unsigned request_pending;
     208                 :            : 
     209                 :            :         /** SETUP packet for EP0
     210                 :            :          * This structure is allocated as a DMA buffer on PCD initialization
     211                 :            :          * with enough space for up to 3 setup packets.
     212                 :            :          */
     213                 :            :         union {
     214                 :            :                 usb_device_request_t req;
     215                 :            :                 uint32_t d32[2];
     216                 :            :         } *setup_pkt;
     217                 :            : 
     218                 :            :         dwc_dma_t setup_pkt_dma_handle;
     219                 :            : 
     220                 :            :         /* Additional buffer and flag for CTRL_WR premature case */
     221                 :            :         uint8_t *backup_buf;
     222                 :            :         unsigned data_terminated;
     223                 :            : 
     224                 :            :         /** 2-byte dma buffer used to return status from GET_STATUS */
     225                 :            :         uint16_t *status_buf;
     226                 :            :         dwc_dma_t status_buf_dma_handle;
     227                 :            : 
     228                 :            :         /** EP0 */
     229                 :            :         dwc_otg_pcd_ep_t ep0;
     230                 :            : 
     231                 :            :         /** Array of IN EPs. */
     232                 :            :         dwc_otg_pcd_ep_t in_ep[MAX_EPS_CHANNELS - 1];
     233                 :            :         /** Array of OUT EPs. */
     234                 :            :         dwc_otg_pcd_ep_t out_ep[MAX_EPS_CHANNELS - 1];
     235                 :            :         /** number of valid EPs in the above array. */
     236                 :            : //        unsigned      num_eps : 4;
     237                 :            :         dwc_spinlock_t *lock;
     238                 :            : 
     239                 :            :         /** Tasklet to defer starting of TEST mode transmissions until
     240                 :            :          *      Status Phase has been completed.
     241                 :            :          */
     242                 :            :         dwc_tasklet_t *test_mode_tasklet;
     243                 :            : 
     244                 :            :         /** Tasklet to delay starting of xfer in DMA mode */
     245                 :            :         dwc_tasklet_t *start_xfer_tasklet;
     246                 :            : 
     247                 :            :         /** The test mode to enter when the tasklet is executed. */
     248                 :            :         unsigned test_mode;
     249                 :            :         /** The cfi_api structure that implements most of the CFI API
     250                 :            :          * and OTG specific core configuration functionality
     251                 :            :          */
     252                 :            : #ifdef DWC_UTE_CFI
     253                 :            :         struct cfiobject *cfi;
     254                 :            : #endif
     255                 :            : 
     256                 :            : };
     257                 :            : 
     258                 :            : static inline struct device *dwc_otg_pcd_to_dev(struct dwc_otg_pcd *pcd)
     259                 :            : {
     260                 :        207 :         return &pcd->otg_dev->os_dep.platformdev->dev;
     261                 :            : }
     262                 :            : 
     263                 :            : //FIXME this functions should be static, and this prototypes should be removed
     264                 :            : extern void dwc_otg_request_nuke(dwc_otg_pcd_ep_t * ep);
     265                 :            : extern void dwc_otg_request_done(dwc_otg_pcd_ep_t * ep,
     266                 :            :                                  dwc_otg_pcd_request_t * req, int32_t status);
     267                 :            : 
     268                 :            : void dwc_otg_iso_buffer_done(dwc_otg_pcd_t * pcd, dwc_otg_pcd_ep_t * ep,
     269                 :            :                              void *req_handle);
     270                 :            : 
     271                 :            : extern void do_test_mode(void *data);
     272                 :            : #endif
     273                 :            : #endif /* DWC_HOST_ONLY */

Generated by: LCOV version 1.14