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

📄 a29f040_ident.c

📁 qnx powerpc MPC8245的 BSP源文件
💻 C
字号:
/* * $QNXLicenseC:  * Copyright 2007, QNX Software Systems.   *   * Licensed under the Apache License, Version 2.0 (the "License"). You   * may not reproduce, modify or distribute this software except in   * compliance with the License. You may obtain a copy of the License   * at: http://www.apache.org/licenses/LICENSE-2.0   *   * Unless required by applicable law or agreed to in writing, software   * distributed under the License is distributed on an "AS IS" basis,   * WITHOUT WARRANTIES OF ANY KIND, either express or implied.  *  * This file may contain contributions from others, either as   * contributors under the License or as licensors under other terms.    * Please review this entire file for other proprietary rights or license   * notices, as well as the QNX Development Suite License Guide at   * http://licensing.qnx.com/license-guide/ for other information.  * $  */#include <sys/f3s_mtd.h>/* * Summary * * Method:      "JEDEC" ID only * MTD Version: 1 and 2 * Bus Width:   8-bit only * Boot-Block?: No * * Description * * This ident callout uses the "JEDEC" ID code to recognize chips with * uniform block sizes (aka boot-block flash). It is also assumed that the * data bus to the chip is 16-bits. * * Use this for really old legacy AMD flash chips. If the ID for your chip is * not listed, copy this file into your driver's source directory and add an * entry for your chip. */int32_t f3s_a29f040_ident(f3s_dbase_t *dbase,                          f3s_access_t *access,                          uint32_t flags,                          uint32_t offset){	volatile uint8_t *	memory;	uintptr_t			amd_cmd1, amd_cmd2;	F3S_BASETYPE		jedec_hi, jedec_lo;	int32_t				size;	static f3s_dbase_t *probe;	static f3s_dbase_t virtual[] =	{		{sizeof(f3s_dbase_t), 0xffff, 0x01, 0x20, "Am29F010A",		F3S_ERASE_FOR_ALL,		1, 1, 10000, 1000000000, 5000, 5000,		1, 1000000, 0, 0, 0, 1, {{8, 14}}},		{sizeof(f3s_dbase_t), 0xffff, 0x01, 0x6e, "Am29LV010B",		F3S_ERASE_FOR_ALL,		1, 1, 10000, 1000000000, 3000, 3000,		1, 1000000, 0, 0, 0, 1, {{8, 14}}},		{sizeof(f3s_dbase_t), 0xffff, 0x01, 0xa4, "Am29F040B",		F3S_ERASE_FOR_ALL,		1, 1, 10000, 1000000000, 5000, 5000,		1, 1000000, 0, 0, 0, 1, {{8, 16}}},		{sizeof(f3s_dbase_t), 0xffff, 0x01, 0x4f, "Am29LV040B",		F3S_ERASE_FOR_ALL,		1, 1, 10000, 1000000000, 3000, 3000,		1, 1000000, 0, 0, 0, 1, {{8, 16}}},		{sizeof(f3s_dbase_t), 0xffff, 0x01, 0xd5, "Am29F080B",		F3S_ERASE_FOR_ALL,		1, 1, 10000, 1000000000, 5000, 5000,		1, 1000000, 0, 0, 0, 1, {{16, 16}}},		{sizeof(f3s_dbase_t), 0xffff, 0x01, 0x38, "Am29LV081B",		F3S_ERASE_FOR_ALL,		1, 1, 10000, 1000000000, 3000, 3000,		1, 1000000, 0, 0, 0, 1, {{16, 16}}},		{sizeof(f3s_dbase_t), 0xffff, 0x01, 0xad, "Am29F016B",		F3S_ERASE_FOR_ALL,		1, 1, 10000, 1000000000, 5000, 5000,		1, 1000000, 0, 0, 0, 1, {{32, 16}}},		{sizeof(f3s_dbase_t), 0xffff, 0x01, 0x3d, "Am29F017B",		F3S_ERASE_FOR_ALL,		1, 1, 10000, 1000000000, 5000, 5000,		1, 1000000, 0, 0, 0, 1, {{32, 16}}},		{sizeof(f3s_dbase_t), 0xffff, 0x01, 0x41, "Am29F032B",		F3S_ERASE_FOR_ALL,		1, 1, 10000, 1000000000, 5000, 5000,		1, 1000000, 0, 0, 0, 1, {{64, 16}}},		{0, 0xffff, 0, 0, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}	};	/* This ident function only supports 8-bit flash */	if (flashcfg.device_width != 1) return (ENOTSUP);	/* Using the 16-bit commands for 8-bit flash is correct in this case */	amd_cmd1 = AMD_CMD_ADDR1_W16;	amd_cmd2 = AMD_CMD_ADDR2_W16;	amd_cmd1 *= flashcfg.bus_width;	amd_cmd2 *= flashcfg.bus_width;	/* Check listing flag */	if (flags & F3S_LIST_ALL)	{		/* If first pass */		if (!probe) probe = virtual;		/* If dbase is valid */		if (!probe->struct_size) return (ENOENT);		*dbase = *probe;		probe++;		return (EOK);	}	/* Set necessary ident size */	size = amd_cmd1 + flashcfg.bus_width;	/* Set proper page on socket */	memory = access->service->page(&access->socket, F3S_POWER_ALL, offset & amd_command_mask, &size);	if (memory == NULL) return (ERANGE);	/* If size is ok */	if (size < (amd_cmd1 + flashcfg.bus_width)) return (ENOTSUP);	/* Issue unlock cycles */	send_command(memory + amd_cmd1, AMD_UNLOCK_CMD1);	send_command(memory + amd_cmd2, AMD_UNLOCK_CMD2);	/* Issue read ident command */	send_command(memory + amd_cmd1, AMD_AUTOSELECT);	probe = virtual;	/* While there are dbase entries */	while (probe->struct_size) {		/* Read jedecs */		jedec_hi = probe->jedec_hi * flashcfg.device_mult;		jedec_lo = probe->jedec_lo * flashcfg.device_mult;		/* Compare jedecs */		if ((jedec_hi == readmem(memory)) &&		    (jedec_lo == readmem(memory + flashcfg.bus_width)))		{			*dbase = *probe;			dbase->chip_inter = flashcfg.chip_inter;			/* Fixed unit size, multiply it by interleave */			dbase->geo_vect[0].unit_pow2 += (flashcfg.chip_inter >> 1);			return (EOK);		}		/* Go to next dbase entry */		probe++;	}	/* Flash type is not amd */	return (ENOTSUP);}

⌨️ 快捷键说明

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