/*
 *               Copyright (C) 2005, BroadOn Communications Corp.
 *
 *  These coded instructions, statements, and computer programs contain
 *  unpublished proprietary information of BroadOn Communications Corp.,
 *  and are protected by federal copyright law. They may not be disclosed
 *  to third parties or copied or duplicated in any form, in whole or in
 *  part, without the prior written consent of BroadOn Communications Corp.
 *
 *  Description:
 *      This file contains the public declarations for the flash device
 *      driver
 *
 */


#ifndef __FLASH_H__
#define __FLASH_H__


#include <sktypes.h>


/* Flash device capabilities */
typedef struct {
    u32     totalSzShift;
    u32     erasableBlockSzShift;
    u32     pageSzShift;
    u32     pageSpareSzShift;
    u32     userSpareSzShift;
    u16     numPlanes;
    u16     supportCopy;
} FLDevCap;


/*
 *  Description:
 *      Flash device driver statistics information
 *
 */
#define FL_FAILED_ENTRIES           32
#define FL_FAILED_ENTRIES_SHIFT     7

#define FL_OP_ERASE                 0
#define FL_OP_WRITE                 1
#define FL_OP_READ                  2
#define FL_OP_COPY                  3

/* Statistics records */
typedef struct {
    u32         blockIndex;
    u32         opType;
    SKError     reason;
} FLFailRecord;

typedef struct {
    u32                 numErasesSinceInit;
    u32                 numWritesSinceInit;
    u32                 numReadsSinceInit;
    u32                 numCopiesSinceInit;
    u32                 failRecordStart;
    u32                 failRecordNum;
    FLFailRecord        failRecord[FL_FAILED_ENTRIES];
} FLStats;


/*
 *  Description:
 *      Flash logical block data and spare size
 *
 */
#define FL_LOGI_BLOCK_SIZE          (16 * 1024) /* Flash logical block size */
#define FL_LOGI_BLOCK_SIZE_SHIFT    14

#define FL_VIRT_SPARE_SIZE          64          /* Spare for a logical block */
#define FL_VIRT_SPARE_SIZE_SHIFT    6

/*
 *  Description:
 *      Flash device driver manufacturing ID
 *
 */
#define FL_SAMSUNG_ID               0xEC
#define FL_SAMSUNG_64MB_ID          0x76
#define FL_SAMSUNG_128MB_ID         0xF1
#define FL_SAMSUNG_256MB_ID         0xDA
#define FL_SAMSUNG_512MB_ID         0xDC

#define FL_TOSHIBA_ID               0x98
#define FL_TOSHIBA_16MB_ID          0x73
#define FL_TOSHIBA_32MB_ID          0x75
#define FL_TOSHIBA_64MB_ID          0x76
#define FL_TOSHIBA_128MB_ID         0xF1
#define FL_TOSHIBA_256MB_ID         0xDA


#endif /* __FLASH_H__ */
