Home | History | Annotate | Download | only in Protocol
      1 /*******************************************************************************
      2 Copyright (C) 2016 Marvell International Ltd.
      3 
      4 Marvell BSD License Option
      5 
      6 If you received this File from Marvell, you may opt to use, redistribute and/or
      7 modify this File under the following licensing terms.
      8 Redistribution and use in source and binary forms, with or without modification,
      9 are permitted provided that the following conditions are met:
     10 
     11 * Redistributions of source code must retain the above copyright notice,
     12   this list of conditions and the following disclaimer.
     13 
     14 * Redistributions in binary form must reproduce the above copyright
     15   notice, this list of conditions and the following disclaimer in the
     16   documentation and/or other materials provided with the distribution.
     17 
     18 * Neither the name of Marvell nor the names of its contributors may be
     19   used to endorse or promote products derived from this software without
     20   specific prior written permission.
     21 
     22 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
     23 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
     24 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
     25 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
     26 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     27 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
     28 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
     29 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     30 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
     31 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     32 
     33 *******************************************************************************/
     34 #ifndef __MARVELL_SPI_MASTER_PROTOCOL_H__
     35 #define __MARVELL_SPI_MASTER_PROTOCOL_H__
     36 
     37 extern EFI_GUID gMarvellSpiMasterProtocolGuid;
     38 
     39 typedef struct _MARVELL_SPI_MASTER_PROTOCOL MARVELL_SPI_MASTER_PROTOCOL;
     40 
     41 typedef enum {
     42   SPI_MODE0, // CPOL = 0 & CPHA = 0
     43   SPI_MODE1, // CPOL = 0 & CPHA = 1
     44   SPI_MODE2, // CPOL = 1 & CPHA = 0
     45   SPI_MODE3  // CPOL = 1 & CPHA = 1
     46 } SPI_MODE;
     47 
     48 typedef struct {
     49   INTN Cs;
     50   INTN MaxFreq;
     51   SPI_MODE Mode;
     52 } SPI_DEVICE;
     53 
     54 typedef
     55 EFI_STATUS
     56 (EFIAPI *MV_SPI_INIT) (
     57   IN MARVELL_SPI_MASTER_PROTOCOL *This
     58   );
     59 
     60 typedef
     61 EFI_STATUS
     62 (EFIAPI *MV_SPI_TRANSFER) (
     63   IN MARVELL_SPI_MASTER_PROTOCOL *This,
     64   IN SPI_DEVICE *Slave,
     65   IN UINTN DataByteCount,
     66   IN VOID *DataOut,
     67   IN VOID *DataIn,
     68   IN UINTN Flag
     69   );
     70 
     71 typedef
     72 EFI_STATUS
     73 (EFIAPI * MV_SPI_READ_WRITE) (
     74   IN  MARVELL_SPI_MASTER_PROTOCOL *This,
     75   IN  SPI_DEVICE *Slave,
     76   IN  UINT8 *Cmd,
     77   IN  UINTN CmdSize,
     78   IN  UINT8 *DataOut,
     79   OUT UINT8 *DataIn,
     80   IN  UINTN DataSize
     81   );
     82 
     83 typedef
     84 SPI_DEVICE *
     85 (EFIAPI *MV_SPI_SETUP_DEVICE) (
     86   IN MARVELL_SPI_MASTER_PROTOCOL *This,
     87   IN UINTN    Cs,
     88   IN SPI_MODE Mode
     89   );
     90 
     91 typedef
     92 EFI_STATUS
     93 (EFIAPI *MV_SPI_FREE_DEVICE) (
     94   IN SPI_DEVICE *SpiDev
     95   );
     96 
     97 struct _MARVELL_SPI_MASTER_PROTOCOL {
     98   MV_SPI_INIT         Init;
     99   MV_SPI_READ_WRITE   ReadWrite;
    100   MV_SPI_TRANSFER     Transfer;
    101   MV_SPI_SETUP_DEVICE SetupDevice;
    102   MV_SPI_FREE_DEVICE  FreeDevice;
    103 };
    104 
    105 #endif // __MARVELL_SPI_MASTER_PROTOCOL_H__
    106