⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hal_nor.c

📁 H3 M-system NAND flash driver in Linux OS, M-DOC driver
💻 C
📖 第 1 页 / 共 2 页
字号:
/****************************************************************************** *                                                                            * * Project: DOC Driver for Linux 2.4 Block device driver for mDOC H3  family  * * of devices under Linux kernel 2.4.                                         * *                                                                            * *   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:   V:/PVCSDB/DiskOnChip/archives/Test for 7.x/src/H3/hal_nor.c-arc  $
 * 
 *    Rev 1.23   Sep 11 2006 13:45:26   yaniv.iarovici
 * Legal header added
 * 
 *    Rev 1.22   Aug 09 2006 17:26:56   Polina.Marimont
 * initial for DOC Driver 1.0
 * 
 */

/*
 * includes
 */
#include "flbase.h"
#include "hal_nor.h"
#include "doch_sys.h"
#include "doch_ata.h"

#ifdef FL_MIGRATION_VERSION
#include "docsys.h"
#endif /*FL_MIGRATION_VERSION*/

#ifdef __cplusplus
extern "C" {
#endif

/*
 * Externals
 */
extern FLDword gAccessLayerType;

#ifdef __cplusplus
}
#endif


#ifdef DOCH_USE_FUNC

#ifdef __cplusplus
extern "C" {
#endif

/*
 * Externals
 */
extern FLDword gAccessLayerType;

/*
 * global vars
 */

/****************************************************************************** 
 *                                                                            * 
 *                        d o c h _ s y s _ i n i t                           * 
 *                                                                            * 
 *  Initialize BSP specific part of DOCH driver.                              * 
 *                                                                            * 
 *  Parameters :                                                              *
 *      socketNo            : Socket # (0...DOCH_MAX_SOCKETS-1)               *
 *                                                                            * 
 *  Returns :                                                                 * 
 *      0 if success, otherwise respective error code.                        *
 *                                                                            * 
 ******************************************************************************/

DOCH_Error hal_init_nor ( FLSNative socketNo)
{
	DOCH_Socket* pdev;
	DOCH_get_socket(pdev, socketNo);

	/*If socket is not registered, return error*/
	if(pdev == NULL)
		return DOCH_DiskNotFound;

	/*Register access layer routines*/
	pdev->halRoutines.hal_get_ata_reg	= hal_get_ata_reg_nor;
	pdev->halRoutines.hal_set_ata_reg	= hal_set_ata_reg_nor;
	pdev->halRoutines.hal_get_ctrl_reg	= hal_get_ctrl_reg_nor;
	pdev->halRoutines.hal_set_ctrl_reg	= hal_set_ctrl_reg_nor;
	pdev->halRoutines.hal_blk_read		= hal_blk_read_nor;
	pdev->halRoutines.hal_blk_write		= hal_blk_write_nor;
	pdev->halRoutines.hal_doch_release	= doch_sys_release_nor;

	gAccessLayerType = DOCH_AL_NOR;

	return DOCH_OK;
}

/*********************************************************/
/* Function name	: doch_sys_release_nor*/
/* Description	    : */
/* Return type		: */
/* Argument         : int socketNo*/
/*********************************************************/
FLSNative doch_sys_release_nor(int socketNo)
{	
	return flOK;
}

/****************************************************************************** 
 *                                                                            * 
 *                   d o c h_ s y s _ g e t _ r e g X                         * 
 *                                                                            * 
 *  Reads DOCH register.                                                      * 
 *                                                                            * 
 *  Parameters :                                                              *
 *      base                 : pointer to the base of DOCH register set       *
 *      reg                  : ATA register number						      *
 *                                                                            * 
 *  Returns :                                                                 * 
 *      value of specified register                                           *
 *                                                                            * 
 ******************************************************************************/
FLByte hal_get_ata_reg_nor(volatile FLByte *base, FLSNative  reg)
{
	volatile FLWord* vPtr = (volatile FLWord*)addToFarPointer(base, (reg<<1) + DOCH_CONT_REG_AREA);
	FLWord val = DOCHREAD_IO_WORD(vPtr);

#ifdef DOCH_BIG_ENDIAN
	return (FLByte)(val>>8);	/*Value is returned in the higher byte*/
#else /*DOCH_BIG_ENDIAN*/
	return (FLByte)(val);
#endif /*DOCH_BIG_ENDIAN*/
}

FLWord hal_get_ctrl_reg_nor ( volatile FLByte * base, 
							  FLSNative         reg )
{
	volatile FLWord* vPtr = (volatile FLWord*)addToFarPointer(base, reg);
	FLWord			 regVal = DOCHREAD_IO_WORD(vPtr);

#ifdef DOCH_BIG_ENDIAN
	return ((regVal<<8) | (regVal>>8));	/*Swap high/low bytes*/
#else /*DOCH_BIG_ENDIAN*/
	return regVal;
#endif /*DOCH_BIG_ENDIAN*/
}

/****************************************************************************** 
 *                                                                            * 
 *                  d o c h _ s y s _ s e t _ r e g X                         * 
 *                                                                            * 
 *  Writes DOCH register.                                                     * 
 *                                                                            * 
 *  Parameters :                                                              *
 *      base                 : pointer to the base of DOCH register set       *
 *      reg                  : ATA register number						      *
 *      val                  : value to write to register                     *
 *                                                                            * 
 *  Returns :                                                                 * 
 *      value of specified register                                           *
 *                                                                            * 
 ******************************************************************************/

void hal_set_ata_reg_nor( volatile FLByte * base, 
					   FLSNative			reg,
					   FLNative				val )
{
	volatile FLWord* vPtr = (volatile FLWord*)addToFarPointer(base, (reg<<1) + DOCH_CONT_REG_AREA);

#ifdef DOCH_BIG_ENDIAN
	val = ((val>>8) | (val<<8));
#endif /*DOCH_BIG_ENDIAN*/

	DOCHWRITE_IO_WORD((FLWord)val, vPtr);
}

void hal_set_ctrl_reg_nor ( volatile FLByte *   base, 
                         FLSNative				reg,
                         FLNative				val )
{
#ifdef DOCH_BIG_ENDIAN
	val = ((val>>8) | (val<<8));
#endif /*DOCH_BIG_ENDIAN*/

	DOCHWRITE_IO_WORD((FLWord)val, (base + reg));
}

/****************************************************************************** 
 *                                                                            * 
 *            b l k _ r e a d_ u s i n g _ d a t a _ r e g					  * 
 *                                                                            * 
 *  Read specified # of bytes through the ATA data register					  *
 *                                                                            * 
 *  Parameters :                                                              *
 *      base                 : pointer to the base of DOCH register set       *
 *      buf                  : buffer to write from                           *

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -