//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
//
// Use of this source code is subject to the terms of the Microsoft end-user
// license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
// If you did not accept the terms of the EULA, you are not authorized to use
// this source code. For a copy of the EULA, please see the LICENSE.RTF on your
// install media.
//
//------------------------------------------------------------------------------
//
//  Copyright (C) 2004-2007, Freescale Semiconductor, Inc. All Rights Reserved.
//  THIS SOURCE CODE, AND ITS USE AND DISTRIBUTION, IS SUBJECT TO THE TERMS
//  AND CONDITIONS OF THE APPLICABLE LICENSE AGREEMENT
//
//------------------------------------------------------------------------------
//
//  File:  K9F1G08U0A.h
//
//  Contains definitions for FMD impletation of the Samsung K9F1G08U0A NAND
//  flash memory device.
//
//------------------------------------------------------------------------------
#ifndef __K9F1G08U0A_H__
#define __K9F1G08U0A_H__

#define NAND_LARGE_PAGE

#define CMD_READID              0x90        // Read ID
#define CMD_READ                0x00        // Read data field
#define CMD_READ_2CYCLE         0x30        // Read data 2nd cycle
#define CMD_RESET               0xFF        // Reset
#define CMD_ERASE               0x60        // Erase setup
#define CMD_ERASE2              0xD0        // Erase 
#define CMD_WRITE               0x80        // Sequential data input
#define CMD_WRITE2              0x10        // Program
#define CMD_STATUS              0x70        // Read status

#define NAND_BLOCK_CNT          (1024)       // 1024 blocks
#define NAND_PAGE_CNT           (64)        // Each Block has 64 Pages
#define NAND_PAGE_SIZE          (2048)      // Each Page has 2048 Bytes
#define NAND_BLOCK_SIZE         (NAND_PAGE_CNT * NAND_PAGE_SIZE)
#define NAND_BBI_OFFSET         5           // Bad block info spare offset
#define NAND_BUS_WIDTH          8           // 8-bit bus

#define NAND_MAKER_CODE         0xEC        // Samsung
#define NAND_DEVICE_CODE        0xF1        // K9F1G08U0A

#define NAND_STATUS_MASK_ERROR  (1U << 0)   // Status Bit0 indicates error

#define NAND_ID_CODE            ((NAND_DEVICE_CODE << 8) | NAND_MAKER_CODE)

// K9LAG08U0M address is sent in 5-cycles
//      1st Cycle:  Column address A[7:0]
//      2nd Cycle:  Column address A[11:8]
//      3rd Cycle:  Page address A[19:12]
//      4th Cycle:  Page address A[27:20]
//
// notes:
//     when translate address into col & page
//      Column  address[10..0]
//      Page      address[31..11]  
//
#define NF_ADDR_COL(addr)       { NF_ADDR((addr) & 0xFF);  \
                                 NF_ADDR(((addr) >> 8) & 0x07); }

#define NF_ADDR_PAGE(addr)      { NF_ADDR(((addr) >>  11) & 0xFF);    \
                                  NF_ADDR(((addr) >> 19) & 0xFF); }

// sequential read operation is not supported by K9F1G08U0A
#define NF_READ_SEQ(sectAddr)   (FALSE)

#endif    // __K9F1G08U0A_H__

