• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 __MV_SPI_FLASH__
35 #define __MV_SPI_FLASH__
36 
37 #include <Protocol/Spi.h>
38 
39 #define CMD_READ_ID                     0x9f
40 #define READ_STATUS_REG_CMD             0x0b
41 #define CMD_WRITE_ENABLE                0x06
42 #define CMD_FLAG_STATUS                 0x70
43 #define CMD_WRITE_STATUS_REG            0x01
44 #define CMD_READ_ARRAY_FAST             0x0b
45 #define CMD_PAGE_PROGRAM                0x02
46 #define CMD_BANK_WRITE                  0xc5
47 #define CMD_ERASE_64K                   0xd8
48 #define CMD_4B_ADDR_ENABLE              0xb7
49 
50 extern EFI_GUID gMarvellSpiFlashProtocolGuid;
51 
52 typedef struct _MARVELL_SPI_FLASH_PROTOCOL MARVELL_SPI_FLASH_PROTOCOL;
53 
54 typedef
55 EFI_STATUS
56 (EFIAPI *MV_SPI_FLASH_INIT) (
57   IN MARVELL_SPI_FLASH_PROTOCOL *This,
58   IN SPI_DEVICE             *SpiDev
59   );
60 
61 typedef
62 EFI_STATUS
63 (EFIAPI *MV_SPI_FLASH_READ_ID) (
64   IN     SPI_DEVICE *SpiDev,
65   IN     UINT32     DataByteCount,
66   IN OUT UINT8      *Buffer
67   );
68 
69 typedef
70 EFI_STATUS
71 (EFIAPI *MV_SPI_FLASH_READ) (
72   IN SPI_DEVICE *SpiDev,
73   IN UINT32     Address,
74   IN UINTN      DataByteCount,
75   IN VOID       *Buffer
76   );
77 
78 typedef
79 EFI_STATUS
80 (EFIAPI *MV_SPI_FLASH_WRITE) (
81   IN SPI_DEVICE *SpiDev,
82   IN UINT32     Address,
83   IN UINTN      DataByteCount,
84   IN VOID       *Buffer
85   );
86 
87 typedef
88 EFI_STATUS
89 (EFIAPI *MV_SPI_FLASH_ERASE) (
90   IN SPI_DEVICE *SpiDev,
91   IN UINTN      Address,
92   IN UINTN      DataByteCount
93   );
94 
95 typedef
96 EFI_STATUS
97 (EFIAPI *MV_SPI_FLASH_UPDATE) (
98   IN SPI_DEVICE *SpiDev,
99   IN UINT32     Address,
100   IN UINTN      DataByteCount,
101   IN UINT8      *Buffer
102   );
103 
104 struct _MARVELL_SPI_FLASH_PROTOCOL {
105   MV_SPI_FLASH_INIT    Init;
106   MV_SPI_FLASH_READ_ID ReadId;
107   MV_SPI_FLASH_READ    Read;
108   MV_SPI_FLASH_WRITE   Write;
109   MV_SPI_FLASH_ERASE   Erase;
110   MV_SPI_FLASH_UPDATE  Update;
111 };
112 
113 #endif // __MV_SPI_FLASH__
114