/******************************************************************************
 *                                                                            *
 * Project: DOC Driver for Linux 2.6 Block device driver for mDOC H3  family  *
 * of devices under Linux kernel 2.6.                                         *
 *                                                                            *
 *   Version: 1.0                                                             *
 *   Email questions to: oemsupport@sandisk.com                               *
 *   Copyright (C) SanDisk IL Ltd. 1995 - 2007                                *
 *   SanDisk IL Ltd., 7 Atir Yeda Street, Kfar Saba 44425, Israel             *
 *                                                                            *
 ******************************************************************************
 *                                                                            *
 * This program is free software; you can redistribute it and/or modify it    *
 * under the terms of the GNU General Public License as published by the Free *
 * Software Foundation; either version 2 of the License, or any later version.*
 * This program is distributed in the hope that it will be useful, but WITHOUT*
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or      *
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for  *
 * more details, which is set forth in the readme.txt file.                   *
 * You should have received a copy of the GNU General Public License along    *
 * with this program; if not, write to the Free Software Foundation, Inc., 51 *
 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA                    *
 *                                                                            *
 * This License does not grant you any right to use the trademarks, service   *
 * marks or logos of SanDisk IL Ltd. or SanDisk Corporation.                  *
 * Subject to the foregoing, SanDisk IL Ltd., for itself and on behalf of its *
 * licensors, hereby reserves all intellectual property rights in the program,*
 * except for the rights expressly granted in this License.                   *
 *                                                                            *
 ******************************************************************************/

/*
 * $Log$
 */



#ifndef FLCUSTOM_H
#define FLCUSTOM_H


/* Driver & TrueFFS Version numbers (Previously named OSAK)
 *
 * The string must not be greater than 10 characters.
 *
 * Note: Other then being returned by the the flVolumeInfo() routine this
 * value has no actual affect on the TrueFFS software.
 */
#define driverVersion "1.1.0"
#define OSAKVersion   "1.1.0"


#define TFFS_SUPPORTED_DEVICE "H3"


/* 
 * debug/diagnostic messages
 */
#define TFFS_DEBUG_DRIVER

#ifdef TFFS_DEBUG_DRIVER

/* EXT filter debug messages */
# define TFFS_DEBUG_EXTFILTER

/* enable TFFS debug messages and fl_debug insmod argument */
# define TFFS_MESSAGES_ENABLED

/* default for fl_debug parameter: 0 - no messages, 1 - errors, 2 - warnings, 4 - flow */
# define FL_DEBUG_DEF	2

/* #define TFFS_COUNT_REQ_SECTORS */

#endif /* TFFS_DEBUG_DRIVER */


/* 
 * Collect various driver statistics
 */
#define TFFS_STATISTIC


/* 
 * comment out this macro if you want to get "MTD-style"
 */
#define TFFS_PARTITIONABLE


/* 
 * Scatter/gather of read/write requests in tffsdrv<ver>.c
 */
#define TFFS_REQ_CACHE_SIZE (4096 * 16)


#define DEV2PART_SHIFT                4  /* at most 15 file system partitions per disk */
#define TFFS_DEVICE_NAME             "tffs"
#define TFFS_MAXHW_SECTOR_SIZE_BITS   0


/* 
 * allow using of unformatted DiskOnChip devices
 */
#define TFFS_ALLOW_UNFORMATTED


/*
 * allow yielding CPU during flash write/erase operations
 */
#define TFFS_USE_SLEEP


/* Number of sockets
 *
 * Defines the maximum number of supported physical DiskOnChip devices.
 *
 * The actual number of sockets depends on which socket controllers are
 * actually registered and the number of physical devices in the system.
 */
#define FL_SOCKETS  1


/* Number of volumes
 *
 * Defines the maximum number of supported Disk (BDTL) partitions.
 *
 * The actual number of drives depends on which socket controllers are
 * actually registered, the amount of devices in the system and the
 * flash format placed on each device.
 */
#define FL_VOLUMES (14 * FL_SOCKETS)


/* Environment Variables
 *
 * Enable environment variables control of the TrueFFS features.
 *
 */
#define FL_ENVIRONMENT_VARS


/* #define DOCH_ACCESS_LAYER_NOR */
/* #define DOCH_ACCESS_LAYER_SPI */


/* If you are using two cascaded DiskOnChip H3 devices, uncomment
 * line below; otherwise keep it commented out.
 */
/* #define ATA_MAX_NUM_OF_DEVICES 2 */  /* only when using casacded devices */


/* Forces the device into the deep power down mode after every driver operation */
/* Compile the auto DPD code
 *
 * TrueFFS supports a mode, where TrueFFS automatically enters and exit DPD
 * after every operation. 
 *
 * The compilation bellow compiles that code. Note that it's operation is 
 * also under the affect of the dedicated environment variable.
 */
#define FL_BD_AUTO_DPD_MODE
#define FL_DEFAULT_BD_DPD_MODE(socket)  tffs_auto_dpd
extern int tffs_auto_dpd;


/* Upon completion of every read/write access, DiskOnChip H3 devices
 * immediately switch from the normal mode into the idle mode, and stay
 * in the idle mode for 'DOCH_DPD_DEFAULT_DPD_TIMEOUT' milliseconds before
 * switching into deep-power-down mode.
 */
#define DOCH_DPD_DEFAULT_DPD_TIMEOUT  tffs_dpd_timeout
extern int tffs_dpd_timeout;


/* 
 * Remove all flash write functionalities from the code. 
 *
 * When this option is selected, only API functions that do not involve write
 * operations to the media can be called. 
 * 
 * This option can be used to create read-only applications with low RAM/ROM
 * requirements.
 */
/* #define TFFS_RO */
#ifdef TFFS_RO
# define FL_READ_ONLY
#endif

/* IO Controll Interface
 *
 * Support standard IOCTL interface.
 *
 */
#define FL_IOCTL_INTERFACE


#ifdef FL_IOCTL_INTERFACE

/* Low level operations
 *
 * Uncomment the following line if you want to do low level operations
 * (i.e. read from a physical address, write to a physical address,
 * erase a unit according to its physical unit number, OTP and unique ID
 * operations.
 */
# define FL_LOW_LEVEL

/* Flash Formatting (Block device format)
 *
 * Uncomment the following line if you need to prepare a virgin DiskOnChip
 * for work or in case you want to re-partition your existing device. 
 *
 * This routine compiles the following 3 API routines:
 *    flFlashFormat(), flEraseBD() and flUnformat()
 */

# ifndef TFFS_RO
#  define FL_FORMAT_VOLUME
# endif

/* H/W OTP
 *
 * Enable H/W One Time Programing capability including unique ID
 *
 */
# define HW_OTP

#endif /* FL_IOCTL_INTERFACE */


/* Application exit
 *
 * If the FLite application ever exits, it needs to call flEXit before
 * exiting. Uncomment the following line to enable this.
 */
#define FL_EXIT 


/* H/W Protection
 *
 * Enable H/W protection of the device.
 *
 */
#define HW_PROTECTION


/* Compile the code for reading after write
 *
 * Compiles the code and buffers for reading after every write operation
 * This mode is used for debugging when you are still debugging the platform's 
 * H/W.
 */
#define FL_VERIFY_WRITE


/* Verify entire volume
 *
 * Compile the flVerifyVolume() routine - this routine scans the entire disk
 * partition for power failures symptoms and correct them while initializing 
 * the TL cache.
 *
 */
/* #define VERIFY_VOLUME */


#ifdef FL_IOCTL_INTERFACE

/* Binary Partition
 *
 * Enables access to the Binary partition.
 *
 */
# define BDK_ACCESS

#endif


#ifdef BDK_ACCESS

/* Number of Binary partitions on the DiskOnChip.
 *
 * Defines Maximum Number of Binary partitions on the DiskOnChip.
 * The actual number of partitions depends on the format placed
 * on each device.
 */
# define FL_BINARY_PARTITIONS (3 * FL_SOCKETS)

#endif /* BDK_ACCESS */


/* Remove runtime controll over memory access routines 
 *
 * If defined memory access routines will be set at compile time using 
 * dedicated defintions in flsystem.h
 * Note : when compile time customization is chosen, you must sepcify
 * the bus width even when working with DiskOnChip Millennium Plus.
 * Refer to Trueffs manual for more infromation.
 */
/* #define FL_NO_USE_FUNC */


/*
 * Removes the code used for writing and reading the IPL code.
 *
 */
#ifndef FL_IOCTL_INTERFACE
# define NO_IPL_CODE
#endif


/* Little-endian/big-endian
 *
 * FAT and translation layer structures use the little-endian (Intel)
 * format for integers.
 * If your machine uses the big-endian (Motorola) format, uncomment the
 * following line.
 * Note that even on big-endian machines you may omit the BIG_ENDIAN
 * definition for smaller code size and better performance, but your media
 * will not be compatible with standard FAT and FTL.
 */
/* #define FL_BIG_ENDIAN */


/* #define FL_NO_INIT_MMU_PAGES */


/* Compile the extended Disk information routine
 *
 * TrueFFS 6.0 and up provide an extended information routine for internal
 * M-Systems utilities named flGetExtendedDiskInfo(). 
 * To compile its code define
 */
#define FL_EXTENDED_DISK_INFO


/* #define FL_NO_QUICK_MOUNT_FEATURE */


/* Disable the automatic argument check
 *
 * You can remove code and even slightly improve the overall performance by
 * allowing TrueFFS to skip its internal argument check by defining
 *
 */
/* #define FL_SKIP_ARGS_CHECK */


/* Absolute read & write
 *
 * Uncomment the following line if you want to be able to read & write
 * sectors by absolute sector number (i.e. without regard to files and
 * directories).
 */
#define FL_ABS_READ_WRITE


/* 
 * Include code related to DiskOnChip H3 burst mode
 */
#define DOCH_USE_BURST_MODE_READ
/* #define DOCH_USE_BURST_MODE_WRITE */

# if defined(DOCH_USE_BURST_MODE_READ) || defined(DOCH_USE_BURST_MODE_WRITE)

#  define BURST_LENGTH      tffs_burst_length
#  define BURST_LATENCY     tffs_burst_latency
#  define BURST_HOLD        tffs_burst_hold
#  define BURST_WAIT_STATE  tffs_burst_ws

#  ifdef DOCH_USE_BURST_MODE_READ
#   define FL_USE_BURST_MODE_READ
#  endif

#  ifdef DOCH_USE_BURST_MODE_WRITE
#   define FL_USE_BURST_MODE_WRITE
#  endif 

   extern int tffs_burst_length, tffs_burst_latency, tffs_burst_hold, tffs_burst_ws;
   extern int tffs_burst_enabled;

# endif /* DOCH_USE_BURST_MODE_READ || DOCH_USE_BURST_MODE_WRITE */


extern unsigned int profiling[];


#endif /* FLCUSTOM_H */
