summaryrefslogtreecommitdiff
path: root/Board/Flash/LPC/LpcSst2MblFlashWrite.c
blob: 954eaba70f71f2bf6899c2006d49fa1caa1f3e49 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
//*************************************************************************
//*************************************************************************
//**                                                                     **
//**        (C)Copyright 1985-2009, American Megatrends, Inc.            **
//**                                                                     **
//**                       All Rights Reserved.                          **
//**                                                                     **
//**      5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093           **
//**                                                                     **
//**                       Phone: (770)-246-8600                         **
//**                                                                     **
//*************************************************************************
//*************************************************************************

//**********************************************************************
// $Header: /Alaska/SOURCE/Flash_Combined_2/Core/LPC/LpcSst2MblFlashWrite.c 15    12/23/09 6:12a Calvinchen $
//
// $Revision: 15 $
//
// $Date: 12/23/09 6:12a $
//**********************************************************************
// Revision History
// ----------------
// $Log: /Alaska/SOURCE/Flash_Combined_2/Core/LPC/LpcSst2MblFlashWrite.c $
// 
// 15    12/23/09 6:12a Calvinchen
// Improvement:
// 1.Added FWH/LPC/STD Flash Device Number support.
// 2.Changed for SMIFlash module Label "4.6.3.6_SMIFLASH_12" or later
// 
// 14    12/15/09 5:47a Calvinchen
// Modified for adding Flash chip name support.
// 
// 13    6/24/09 3:13a Calvinchen
// (EIP22177) Updated for Aptio Source Enhancement. 
//
// 12    11/13/08 1:33a Calvinchen
// Fixed Boot Block recovery and re-flash BIOS failed with using SST
// 49LF160C.
//
// 11    6/26/08 7:00a Calvinchen
// Generic bug fixed.
//
// 9     5/09/08 3:34a Calvinchen
// Added support for Winbond 39V080AP and STM M50LPW080.
//
// 8     1/07/08 3:28p Robert
// Updated for coding standard
//
// 7     12/07/07 1:45p Stacyh
// Updated to differentiate between LPC and FWH SST parts.
//
// 6     11/09/07 4:17p Alexp
// Added dummy FlashRead function. Not supported by this type of flash
// module
//
// 5     10/25/07 1:14p Fasihm
// Removed the directive AmiCspLib.h as it is not needed and is causing
// other Build Errors.
//
// 4     10/19/07 6:29p Robert
//
// 3     8/20/07 4:13p Radhikav
// Flash Part Data structure for SST 49LF160C changed.
//
// 2     7/09/07 10:05a Radhikav
// modified flashdevicewriteenable and disable functions.
//
// 1     5/16/07 1:00p Radhikav
//
//
//
//
//**********************************************************************
//<AMI_FHDR_START>
//
// Name:    LpcSst2MblFlashWrite.c
//
// Description: Support routines for the LPC Sst 2Mb part
//
//<AMI_FHDR_END>
//**********************************************************************

//----------------------------------------------------------------------
// Includes
#include <efi.h>
#include <FlashPart.h>
#include <AmiDxeLib.h>
#include "token.h"

//----------------------------------------------------------------------
// define local MACROS

//Flash Part Specific Tokens
#define SST_MANUFACTURER_ID         0xbf    // SST manufacturer  ID
#define SST49LF160C_DEVICE_ID       0x4c    // 2MB LPC
#define SST49LF160C                 0x4cbf  // SST 49LF160C
#define SST49LF016C			        0x5cbf
#define STM50LPW080                 0x2f20  // ST M50LPW080


#define READ_ARRAY_CMD              0xff
#define RD_STATUS_CMD               0x70
#define CLR_STATUS_CMD              0x50
#define ERASE_SET_CMD               0x20
#define ERASE_CNF_CMD               0xd0
#define PRG_SETUP_CMD               0x40
#define SECTOR_ERASE_SET_CMD        0x30 // SST 49LF160C only

#define RD_ID_CODE                  0x90

// SST49LF160C Status Register Bits

#define VPP_LOW                     0x08
#define PROGRAM_FAIL                0x10
#define ERASE_FAIL                  0x20
#define WSM_BUSY                    0x80

// Intel Lock Commands
#define UNLOCK                      0
#define WRITE_LOCK                  1

#define SECTOR_SIZE_4KB             0x1000  // Common 4kBytes sector size
#define SECTOR_SIZE_64KB            0x10000  // Common 64kBytes sector size

//----------------------------------------------------------------------------
// Module level global data
extern FLASH_PART   *FlashAPI;
extern UINT8        pFlashDeviceNumber[FLASH_PART_STRING_LENGTH];

//----------------------------------------------------------------------------
// Local Variable definitions

EFI_STATUS
InitSst2MbCheckId   (
    volatile UINT8*     pBlockAddress
    );
BOOLEAN
SstLpcIsEraseCompleted  (
    volatile UINT8      *pBlockAddress,
    BOOLEAN             *pError,
    UINTN               *pStatus
    );
BOOLEAN
SstLpcIsProgramCompleted    (
    volatile UINT8      *pByteAddress,
    UINT8               *Byte,
    UINT32              Length,
    BOOLEAN             *pError,
    UINTN               *pStatus
    );

static UINT8 gbEraseSetCmd = ERASE_SET_CMD;

//----------------------------------------------------------------------------
// Function Definitions

//<AMI_PHDR_START>
//----------------------------------------------------------------------------
// Procedure:   Sst2mLpcCmdDelay
//
// Description: This function resets the Sst flash part
//
// Input:   None
//
// Output:  None
//
// Return:  None
//
//----------------------------------------------------------------------------
//<AMI_PHDR_END>
VOID
Sst2mLpcCmdDelay (VOID)
{
    IoWrite8 ( 0xeb, 0x55 );
    IoWrite8 ( 0xeb, 0xaa );
}
//<AMI_PHDR_START>
//----------------------------------------------------------------------------
// Procedure:   Sst2mLpcResetFlash
//
// Description: This function resets the Sst flash part
//
// Input:   None
//
// Output:  None
//
// Return:  None
//
//----------------------------------------------------------------------------
//<AMI_PHDR_END>
static
VOID
Sst2mLpcResetFlash  (
    IN volatile UINT8*      pAddress
)
{
    *pAddress = READ_ARRAY_CMD;// Return to read mode
    Sst2mLpcCmdDelay ();
    *pAddress = CLR_STATUS_CMD;// clear status
    Sst2mLpcCmdDelay ();
}
//<AMI_PHDR_START>
//----------------------------------------------------------------------------
// Procedure:   Sst2mLpcOperationCompleted
//
// Description:
//      This function verifies whether the command sent to the FWH part
//      has completed and returns the status of the command
//
// Input:
//  IN volatile UINT8*  pAddress    Location to check the device status
//
// Output:
//      EFI_SUCCESS -
//      EFI_TIMEOUT -
//      EFI_DEVICE_ERROR -
//
//----------------------------------------------------------------------------
//<AMI_PHDR_END>
static
EFI_STATUS
Sst2mLpcOperationCompleted  (
    IN volatile UINT8*      pAddress
)
{
    UINT8                   bLpcStatus;
    UINT32                  dTimeout = FLASH_RETRIES * 0x10000;

    do {
        *pAddress = RD_STATUS_CMD;          // read status.
        Sst2mLpcCmdDelay ();
        bLpcStatus = *pAddress;
        if ( bLpcStatus & WSM_BUSY ) {
            if ( bLpcStatus & ( VPP_LOW + PROGRAM_FAIL + ERASE_FAIL ) )
                return EFI_DEVICE_ERROR;
            else return EFI_SUCCESS;
        }
        dTimeout--;
    } while ( dTimeout != 0 );
    return EFI_TIMEOUT;
}

//<AMI_PHDR_START>
//----------------------------------------------------------------------------
// Procedure:   SstLpcEraseCommand
//
// Description: This API function erases a block in the flash. Flash model
//              specific code will branch out from this routine
//
// Input:       pBlockAddress   Block that need to be erased
//
// Output:      Nothing
//----------------------------------------------------------------------------
//<AMI_PHDR_END>
static
VOID
SstLpcEraseCommand  (
    IN volatile UINT8*      pBlockAddress
)
{
    EFI_STATUS          Status;
    UINT8               bFlashRetry;
    UINTN               nSectorAddr;
    UINT16              wNumSectors, wSectorCount;

    Sst2mLpcResetFlash( pBlockAddress );
    wNumSectors = ( FlashBlockSize / FlashAPI->FlashSectorSize );
    for ( wSectorCount = 0; wSectorCount < wNumSectors; wSectorCount++ ) {
        nSectorAddr = (UINTN)( wSectorCount * FlashAPI->FlashSectorSize );
        for ( bFlashRetry = 0; bFlashRetry < FLASH_RETRIES; bFlashRetry++ ) {
            *(UINT8*)( (UINTN)pBlockAddress + nSectorAddr ) = gbEraseSetCmd;
            Sst2mLpcCmdDelay ();
            *(UINT8*)( (UINTN)pBlockAddress + nSectorAddr ) = ERASE_CNF_CMD;
            Sst2mLpcCmdDelay ();
            Status = Sst2mLpcOperationCompleted ( \
                            (UINT8*)((UINTN)pBlockAddress + nSectorAddr) );
            Sst2mLpcResetFlash( (UINT8*)((UINTN)pBlockAddress + nSectorAddr) );
            if ( Status != EFI_SUCCESS ) continue;
            if ( 0xFF == \
                    *(volatile UINT8*)((UINTN)pBlockAddress + nSectorAddr) ) {
                Status = EFI_SUCCESS;
                break;
            } else Status = EFI_DEVICE_ERROR;
        }
    }
//-    return Status;
}

//<AMI_PHDR_START>
//----------------------------------------------------------------------------
// Procedure:   SstLpcIsEraseCompleted
//
// Description: This function verifies whether the block erase
//              command is completed and returns the status of the command
//
// Input:       *pBlockAddress  Location of the block erase
//              *pError         True on error and false on success
//              *Status         Error status code (0 - Success)
//
// Output:      TRUE        If operation completed successfully
//                          *pError = FALSE, *pStatus = 0
//              FALSE       If operation failed
//                          *pError = TRUE, *pStatus = error status
//
//----------------------------------------------------------------------------
//<AMI_PHDR_END>
static
BOOLEAN
SstLpcIsEraseCompleted  (
    IN  volatile UINT8*     pBlockAddress,
    OUT BOOLEAN             *pError,
    OUT UINTN               *pStatus
)
{
    UINT32                      dNumBytes;

    for ( dNumBytes = 0; dNumBytes < FlashBlockSize; dNumBytes++ ) {
        if ( *(volatile UINT8*)( pBlockAddress + dNumBytes ) != 0xFF ) {
            if ( pError ) *pError = TRUE;
            if ( pStatus ) *pStatus = EFI_DEVICE_ERROR;
            return FALSE;
        }
    }
    if ( pError ) *pError = FALSE;
    if ( pStatus ) *pStatus = EFI_SUCCESS;
    return TRUE;
}

//<AMI_PHDR_START>
//----------------------------------------------------------------------------
// Procedure:   SstLpcReadCommand
//
// Description: This function programs a byte data to the specified location
//
// Input:   *pByteAddress   Location where the data to be written
//          Bytes - data to be written.
//          Length - number of bytes to write
//
// Output:  Length - number of bytes that were not written
//
// Return:  None
//
//----------------------------------------------------------------------------
//<AMI_PHDR_END>
static
VOID
SstLpcReadCommand   (
    IN      volatile UINT8* pByteAddress,
    IN OUT  UINT8           *Byte,
    IN OUT  UINT32          *Length
)
{
    UINT32              dNumBytes = 0;
    
    // Changes for SMIFlash module label "4.6.3.6_SMIFLASH_12" or later.
    for ( dNumBytes = 0; dNumBytes < *Length ; dNumBytes++ )
        *( Byte + dNumBytes ) = *(UINT8*)((UINT32)pByteAddress + dNumBytes );
    *Length = 0;
    return ;
}

//<AMI_PHDR_START>
//----------------------------------------------------------------------------
// Procedure:   SstLpcProgramCommand
//
// Description: This function programs a byte data to the specified location
//
// Input:       *pByteAddress   Location where the data to be written
//              Data            Byte to be written
//
// Output:      None
//
//----------------------------------------------------------------------------
//<AMI_PHDR_END>
static
VOID
SstLpcProgramCommand    (
    IN  volatile UINT8*     pByteAddress,
    OUT UINT8               *Byte,
    OUT UINT32              *Length
)
{
    EFI_STATUS          Status;
    UINT8               bFlashRetry;

    if ( *pByteAddress != *Byte ) {

        Sst2mLpcResetFlash( pByteAddress );
        for ( bFlashRetry = 0; bFlashRetry < FLASH_RETRIES; bFlashRetry++ ) {
            *pByteAddress = PRG_SETUP_CMD; // Issue program command
            Sst2mLpcCmdDelay ();
            *pByteAddress = *Byte; // Program a byte
            Sst2mLpcCmdDelay ();
            // Check for completion of the program operation
            Status = Sst2mLpcOperationCompleted( pByteAddress );
            Sst2mLpcResetFlash( pByteAddress );
            if ( Status != EFI_SUCCESS ) continue;
            if ( *pByteAddress != *Byte ) Status = EFI_DEVICE_ERROR;
            else {
                Status = EFI_SUCCESS;
                break;
            }
        }
    } else Status = EFI_SUCCESS;
    *Length = *Length - 1;
//-    return Status;
}

//<AMI_PHDR_START>
//----------------------------------------------------------------------------
// Procedure:   SstLpcIsProgramCompleted
//
// Description: This function verifies whether the program (page or byte)
//              command is completed and returns the status of the command
//
// Input:       *pByteAddress   Location of the program command
//              Byte            Last data byte written
//              *pError         True on error and false on success
//              *Status         Error status code (0 - Success)
//
// Output:      TRUE        If operation completed successfully
//                          *pError = FALSE, *pStatus = 0
//              FALSE       If operation failed
//                          *pError = TRUE, *pStatus = error status
//
//----------------------------------------------------------------------------
//<AMI_PHDR_END>
static
BOOLEAN
SstLpcIsProgramCompleted    (
    IN  volatile UINT8*     pByteAddress,
    IN  UINT8               *Byte,
    IN  UINT32              Length,
    OUT BOOLEAN             *pError,
    OUT UINTN               *pStatus
)
{
    UINT32                      dNumBytes;
    UINT8                       bByte;

    for ( dNumBytes = 0; dNumBytes < Length; dNumBytes++ ) {
        bByte = * ( Byte + dNumBytes );
        if ( bByte != *(volatile UINT8*)( pByteAddress + dNumBytes ) ) {
            if ( pError ) *pError = TRUE;
            if ( pStatus ) *pStatus = EFI_DEVICE_ERROR;
            return FALSE;
        }
    }
    if ( pError ) *pError = FALSE;
    if ( pStatus ) *pStatus = EFI_SUCCESS;
    return TRUE;
}


//<AMI_PHDR_START>
//----------------------------------------------------------------------------
// Procedure:   SetBlockLock
//
// Description: This function programs a page of data at a time
//
// Input:      volatile UINT8* pBlockAddress - This is location where the data
//                  is to be written
//              UINT8 LockState - Value to use to set the Lock register for the
//                  block defined by pBlockAddress
//
// Output:      None
//
// Modified:
//
// Referrals:
//
// Notes:
//----------------------------------------------------------------------------
//<AMI_PHDR_END>
static
void
SetBlockLock    (
    IN volatile UINT8*  pBlockAddress,
    IN UINT8            LockState
)
{
    // Update the block lock register
    ((UINT8*)((UINTN)pBlockAddress - FlashDeviceBase + \
                            FwhFeatureSpaceBase))[2] = LockState;
    ((UINT8 *)((UINTN)pBlockAddress - FlashDeviceBase + \
                            FwhFeatureSpaceBase + 0x8000))[2] = LockState;
    ((UINT8 *)((UINTN)pBlockAddress - FlashDeviceBase + \
                            FwhFeatureSpaceBase + 0xA000))[2] = LockState;
    ((UINT8 *)((UINTN)pBlockAddress - FlashDeviceBase + \
                            FwhFeatureSpaceBase + 0xC000))[2] = LockState;
}

//<AMI_PHDR_START>
//----------------------------------------------------------------------------
// Procedure:   SstLpcBlockWriteEnable
//
// Description: This function contains any flash specific code need to
//              enable a particular flash block write
//
// Input:       None
//
// Output:      None
//
//----------------------------------------------------------------------------
//<AMI_PHDR_END>
static
VOID
SstLpcBlockWriteEnable  (
    IN UINT8*               pBlockAddress
)
{
    SetBlockLock(pBlockAddress, UNLOCK);
//-    return EFI_SUCCESS;
}

//<AMI_PHDR_START>
//----------------------------------------------------------------------------
// Procedure:   SstLpcBlockWriteDisable
//
// Description: This function contains any flash specific code need to
//              disable a particular flash block write
//
// Input:       None
//
// Output:      None
//
//----------------------------------------------------------------------------
//<AMI_PHDR_END>
static
VOID
SstLpcBlockWriteDisable (
    IN UINT8*               pBlockAddress
)
{
    SetBlockLock(pBlockAddress, WRITE_LOCK);
//-    return EFI_SUCCESS;
}

//<AMI_PHDR_START>
//----------------------------------------------------------------------------
// Procedure:   SstLpcDeviceWriteEnable
//
// Description: This function contains any flash specific code need to
//              enable flash write
//
// Input:       None
//
// Output:      None
//
//----------------------------------------------------------------------------
//<AMI_PHDR_END>
static
VOID
SstLpcDeviceWriteEnable (VOID)
{
    //We don't have to do anything here because
    //Flash Device is write enabled by the South Bridge driver
}

//<AMI_PHDR_START>
//----------------------------------------------------------------------------
// Procedure:   SstLpcDeviceWriteDisable
//
// Description: This function contains any flash specific code need to
//              disable flash write
//
// Input:       None
//
// Output:      None
//
//----------------------------------------------------------------------------
//<AMI_PHDR_END>
static
VOID
SstLpcDeviceWriteDisable (VOID)
{
    //We don't have to do anything here because
    //we always keep flash device in the write enabled state
}


//<AMI_PHDR_START>
//----------------------------------------------------------------------------
// Procedure:   SstLpcVirtualFixup
//
// Description: This function will be invoked by the core to convert
//              runtime pointers to virtual address
//
// Input:       *pRS    Pointer to runtime services
//
// Output:      None
//
//----------------------------------------------------------------------------
//<AMI_PHDR_END>

static
VOID
SstLpcVirtualFixup  (
    IN EFI_RUNTIME_SERVICES *pRS
)
{
//  // Following is an example code for virtual address conversion
//  pRS->ConvertPointer(0, (VOID**)&FlashDeviceBase);

    return;
}



// Flash Part Data structure for SST 49LF160C

FLASH_PART mSstLpc2Mb =
    {
        SstLpcReadCommand,
        SstLpcEraseCommand,
        SstLpcProgramCommand,
        SstLpcIsEraseCompleted,
        SstLpcIsProgramCompleted,
        SstLpcBlockWriteEnable,
        SstLpcBlockWriteDisable,
        SstLpcDeviceWriteEnable,
        SstLpcDeviceWriteDisable,
        SstLpcVirtualFixup,
        1,                              // Number of bytes to program to the
        SECTOR_SIZE_64KB,               // Dummy value to hold place -
        NULL                            // Flash Part Number Pointer                           
    };                                  // Flash part in each program command


//<AMI_PHDR_START>
//----------------------------------------------------------------------------
// Procedure:   mSstLpcIdentify
//
// Description: This function identifies the supported LPC flash parts and
//              returns appropriate flash device API pointer. If flash part is
//              not supported by this module it will return FALSE.
//
//
// Input:       pBlockAddress   Block address of the flash part. Can be used to
//                              send ID command
//              **FlashApi      Pointer to hold the returned flash API
//
// Output:      TRUE            If flash part is supported, FlashApi contains
//                              routines to handle the flash requests
//              FALSe           Flash part is not supported
//
// Note:        This routine is part of the global flash init list. Make sure
//              it is properly linked to the init list "FlashList" (in SDL file)
//----------------------------------------------------------------------------
//<AMI_PHDR_END>
BOOLEAN
mSstLpcIdentify (
    IN volatile UINT8*      pBlockAddress,
    IN FLASH_PART           **Struct
)
{
    EFI_STATUS  Status = EFI_NOT_FOUND;

    Status = InitSst2MbCheckId( pBlockAddress );
    if ( Status != EFI_SUCCESS ) return FALSE;
    else {
        mSstLpc2Mb.FlashPartNumber = pFlashDeviceNumber;
        *Struct = &mSstLpc2Mb;
    }
    return TRUE;
}

//<AMI_PHDR_START>
//----------------------------------------------------------------------------
//
// Procedure:   InitSst2MbCheckId
//
// Description: This function identifies the supported LPC flash parts.
//
// Input:       pBlockAddress   Block address of the flash part. Can be used to
//                              send ID command
//
// Output:      EFI_SUCCESS     If flash part is supported
//              EFI_NOT_FOUND   Flash part is not supported
//
//----------------------------------------------------------------------------
//<AMI_PHDR_END>
EFI_STATUS
InitSst2MbCheckId   (
    IN volatile UINT8*      pBlockAddress
)
{
    UINT8           VID, DID;
    EFI_STATUS      Status = EFI_NOT_FOUND;

    *pBlockAddress = READ_ARRAY_CMD;// Return to read mode
    Sst2mLpcCmdDelay ();

    *pBlockAddress = RD_ID_CODE;// Set to read ID code mode
    Sst2mLpcCmdDelay ();

    VID = *pBlockAddress;
    DID = *(pBlockAddress + 1);

    *pBlockAddress = READ_ARRAY_CMD;// Return to read mode

    switch ( ( DID << 8 ) + VID ) {
        case SST49LF160C :
        case SST49LF016C :
            gbEraseSetCmd = SECTOR_ERASE_SET_CMD;
            mSstLpc2Mb.FlashSectorSize = SECTOR_SIZE_4KB;
            MemCpy ( pFlashDeviceNumber, "SST 49LF016/160C", 16 );
            Status = EFI_SUCCESS;
            break;
        case STM50LPW080 :
            gbEraseSetCmd = ERASE_SET_CMD;
            mSstLpc2Mb.FlashSectorSize = SECTOR_SIZE_64KB;
            MemCpy ( pFlashDeviceNumber, "ST M50LPW080", 12 );
            Status = EFI_SUCCESS;
            break;
        default :
            Status = EFI_NOT_FOUND;
    }
    return Status;
}
//*************************************************************************
//*************************************************************************
//**                                                                     **
//**        (C)Copyright 1985-2009, American Megatrends, Inc.            **
//**                                                                     **
//**                       All Rights Reserved.                          **
//**                                                                     **
//**      5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093           **
//**                                                                     **
//**                       Phone: (770)-246-8600                         **
//**                                                                     **
//*************************************************************************
//*************************************************************************