e00251b7ed
Memory Interface (CFI). The flash memory can be read and written to through /dev/cfi# and an ioctl() exists so processes can read the query information. The driver supports the AMD and Intel command set, though only the AMD command has been tested. Obtained from: Juniper Networks, Inc.
118 lines
4.3 KiB
C
118 lines
4.3 KiB
C
/*-
|
|
* Copyright (c) 2007, Juniper Networks, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* Redistribution and use in source and binary forms, with or without
|
|
* modification, are permitted provided that the following conditions
|
|
* are met:
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
* notice, this list of conditions and the following disclaimer.
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
* documentation and/or other materials provided with the distribution.
|
|
* 3. Neither the name of the author nor the names of any co-contributors
|
|
* may be used to endorse or promote products derived from this software
|
|
* without specific prior written permission.
|
|
*
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
* SUCH DAMAGE.
|
|
*
|
|
* $FreeBSD$
|
|
*/
|
|
|
|
#ifndef _DEV_CFI_REG_H_
|
|
#define _DEV_CFI_REG_H_
|
|
|
|
struct cfi_qry {
|
|
u_char reserved[16];
|
|
u_char ident[3]; /* "QRY" */
|
|
u_char pri_vend[2];
|
|
u_char pri_vend_eqt[2];
|
|
u_char alt_vend[2];
|
|
u_char alt_vend_eqt[2];
|
|
/* System Interface Information. */
|
|
u_char min_vcc;
|
|
u_char max_vcc;
|
|
u_char min_vpp;
|
|
u_char max_vpp;
|
|
u_char tto_byte_write; /* 2**n milliseconds. */
|
|
u_char tto_buf_write; /* 2**n milliseconds. */
|
|
u_char tto_block_erase; /* 2**n milliseconds. */
|
|
u_char tto_chip_erase; /* 2**n milliseconds. */
|
|
u_char mto_byte_write; /* 2**n times typical t/o. */
|
|
u_char mto_buf_write; /* 2**n times typical t/o. */
|
|
u_char mto_block_erase; /* 2**n times typical t/o. */
|
|
u_char mto_chip_erase; /* 2**n times typical t/o. */
|
|
/* Device Geometry Definition. */
|
|
u_char size; /* 2**n bytes. */
|
|
u_char iface[2];
|
|
u_char max_buf_write_size[2]; /* 2**n. */
|
|
u_char nregions; /* Number of erase regions. */
|
|
u_char region[4]; /* Single entry. */
|
|
/* Additional entries follow. */
|
|
/* Primary Vendor-specific Extended Query table follows. */
|
|
/* Alternate Vendor-specific Extended Query table follows. */
|
|
};
|
|
|
|
#define CFI_QRY_CMD_ADDR 0x55
|
|
#define CFI_QRY_CMD_DATA 0x98
|
|
|
|
#define CFI_QRY_IDENT offsetof(struct cfi_qry, ident)
|
|
#define CFI_QRY_VEND offsetof(struct cfi_qry, pri_vend)
|
|
|
|
#define CFI_QRY_TTO_WRITE offsetof(struct cfi_qry, tto_byte_write)
|
|
#define CFI_QRY_TTO_ERASE offsetof(struct cfi_qry, tto_block_erase)
|
|
#define CFI_QRY_MTO_WRITE offsetof(struct cfi_qry, mto_byte_write)
|
|
#define CFI_QRY_MTO_ERASE offsetof(struct cfi_qry, mto_block_erase)
|
|
|
|
#define CFI_QRY_SIZE offsetof(struct cfi_qry, size)
|
|
#define CFI_QRY_IFACE offsetof(struct cfi_qry, iface)
|
|
#define CFI_QRY_NREGIONS offsetof(struct cfi_qry, nregions)
|
|
#define CFI_QRY_REGION0 offsetof(struct cfi_qry, region)
|
|
#define CFI_QRY_REGION(x) (CFI_QRY_REGION0 + (x) * 4)
|
|
|
|
#define CFI_VEND_NONE 0x0000
|
|
#define CFI_VEND_INTEL_ECS 0x0001
|
|
#define CFI_VEND_AMD_SCS 0x0002
|
|
#define CFI_VEND_INTEL_SCS 0x0003
|
|
#define CFI_VEND_AMD_ECS 0x0004
|
|
#define CFI_VEND_MITSUBISHI_SCS 0x0100
|
|
#define CFI_VEND_MITSUBISHI_ECS 0x0101
|
|
|
|
#define CFI_IFACE_X8 0x0000
|
|
#define CFI_IFACE_X16 0x0001
|
|
#define CFI_IFACE_X8X16 0x0002
|
|
#define CFI_IFACE_X32 0x0003
|
|
#define CFI_IFACE_X16X32 0x0005
|
|
|
|
/* Standard Command Set (aka Basic Command Set) */
|
|
#define CFI_BCS_BLOCK_ERASE 0x20
|
|
#define CFI_BCS_PROGRAM 0x40
|
|
#define CFI_BCS_CLEAR_STATUS 0x50
|
|
#define CFI_BCS_READ_STATUS 0x70
|
|
#define CFI_BCS_ERASE_SUSPEND 0xb0
|
|
#define CFI_BCS_ERASE_RESUME 0xd0 /* Equals CONFIRM */
|
|
#define CFI_BCS_CONFIRM 0xd0
|
|
#define CFI_BCS_READ_ARRAY 0xff
|
|
|
|
/* AMD commands. */
|
|
#define CFI_AMD_BLOCK_ERASE 0x30
|
|
#define CFI_AMD_UNLOCK_ACK 0x55
|
|
#define CFI_AMD_ERASE_SECTOR 0x80
|
|
#define CFI_AMD_PROGRAM 0xa0
|
|
#define CFI_AMD_UNLOCK 0xaa
|
|
|
|
#define AMD_ADDR_START 0xaaa
|
|
#define AMD_ADDR_ACK 0x555
|
|
|
|
#endif /* _DEV_CFI_REG_H_ */
|