/*-1* SPDX-License-Identifier: BSD-3-Clause2*3* Copyright (c) 2007, Juniper Networks, Inc.4* Copyright (c) 2012-2013, SRI International5* All rights reserved.6*7* Portions of this software were developed by SRI International and the8* University of Cambridge Computer Laboratory under DARPA/AFRL contract9* (FA8750-10-C-0237) ("CTSRD"), as part of the DARPA CRASH research10* programme.11*12* Redistribution and use in source and binary forms, with or without13* modification, are permitted provided that the following conditions14* are met:15* 1. Redistributions of source code must retain the above copyright16* notice, this list of conditions and the following disclaimer.17* 2. Redistributions in binary form must reproduce the above copyright18* notice, this list of conditions and the following disclaimer in the19* documentation and/or other materials provided with the distribution.20* 3. Neither the name of the author nor the names of any co-contributors21* may be used to endorse or promote products derived from this software22* without specific prior written permission.23*24* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR25* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES26* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.27* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,28* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,29* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;30* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED31* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,32* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY33* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF34* SUCH DAMAGE.35*/3637#ifndef _DEV_CFI_REG_H_38#define _DEV_CFI_REG_H_3940struct cfi_qry {41u_char reserved[16];42u_char ident[3]; /* "QRY" */43u_char pri_vend[2];44u_char pri_vend_eqt[2];45u_char alt_vend[2];46u_char alt_vend_eqt[2];47/* System Interface Information. */48u_char min_vcc;49u_char max_vcc;50u_char min_vpp;51u_char max_vpp;52u_char tto_byte_write; /* 2**n microseconds. */53u_char tto_buf_write; /* 2**n microseconds. */54u_char tto_block_erase; /* 2**n milliseconds. */55u_char tto_chip_erase; /* 2**n milliseconds. */56u_char mto_byte_write; /* 2**n times typical t/o. */57u_char mto_buf_write; /* 2**n times typical t/o. */58u_char mto_block_erase; /* 2**n times typical t/o. */59u_char mto_chip_erase; /* 2**n times typical t/o. */60/* Device Geometry Definition. */61u_char size; /* 2**n bytes. */62u_char iface[2];63u_char max_buf_write_size[2]; /* 2**n. */64u_char nregions; /* Number of erase regions. */65u_char region[4]; /* Single entry. */66/* Additional entries follow. */67/* Primary Vendor-specific Extended Query table follows. */68/* Alternate Vendor-specific Extended Query table follows. */69};7071#define CFI_QRY_CMD_ADDR 0x5572#define CFI_QRY_CMD_DATA 0x987374#define CFI_QRY_IDENT offsetof(struct cfi_qry, ident)75#define CFI_QRY_VEND offsetof(struct cfi_qry, pri_vend)7677#define CFI_QRY_TTO_WRITE offsetof(struct cfi_qry, tto_byte_write)78#define CFI_QRY_TTO_BUFWRITE offsetof(struct cfi_qry, tto_buf_write)79#define CFI_QRY_TTO_ERASE offsetof(struct cfi_qry, tto_block_erase)80#define CFI_QRY_MTO_WRITE offsetof(struct cfi_qry, mto_byte_write)81#define CFI_QRY_MTO_BUFWRITE offsetof(struct cfi_qry, mto_buf_write)82#define CFI_QRY_MTO_ERASE offsetof(struct cfi_qry, mto_block_erase)8384#define CFI_QRY_SIZE offsetof(struct cfi_qry, size)85#define CFI_QRY_IFACE offsetof(struct cfi_qry, iface)86#define CFI_QRY_MAXBUF offsetof(struct cfi_qry, max_buf_write_size)87#define CFI_QRY_NREGIONS offsetof(struct cfi_qry, nregions)88#define CFI_QRY_REGION0 offsetof(struct cfi_qry, region)89#define CFI_QRY_REGION(x) (CFI_QRY_REGION0 + (x) * 4)9091#define CFI_VEND_NONE 0x000092#define CFI_VEND_INTEL_ECS 0x000193#define CFI_VEND_AMD_SCS 0x000294#define CFI_VEND_INTEL_SCS 0x000395#define CFI_VEND_AMD_ECS 0x000496#define CFI_VEND_MITSUBISHI_SCS 0x010097#define CFI_VEND_MITSUBISHI_ECS 0x01019899#define CFI_IFACE_X8 0x0000100#define CFI_IFACE_X16 0x0001101#define CFI_IFACE_X8X16 0x0002102#define CFI_IFACE_X32 0x0003103#define CFI_IFACE_X16X32 0x0005104105/* Standard Command Set (aka Basic Command Set) */106#define CFI_BCS_BLOCK_ERASE 0x20107#define CFI_BCS_PROGRAM 0x40108#define CFI_BCS_CLEAR_STATUS 0x50109#define CFI_BCS_READ_STATUS 0x70110#define CFI_BCS_ERASE_SUSPEND 0xb0111#define CFI_BCS_ERASE_RESUME 0xd0 /* Equals CONFIRM */112#define CFI_BCS_CONFIRM 0xd0113#define CFI_BCS_BUF_PROG_SETUP 0xe8114#define CFI_BCS_READ_ARRAY 0xff115#define CFI_BCS_READ_ARRAY2 0xf0116117/* Intel commands. */118#define CFI_INTEL_LB 0x01 /* Lock Block */119#define CFI_INTEL_LBS 0x60 /* Lock Block Setup */120#define CFI_INTEL_READ_ID 0x90 /* Read Identifier */121#define CFI_INTEL_PP_SETUP 0xc0 /* Protection Program Setup */122#define CFI_INTEL_UB 0xd0 /* Unlock Block */123124/* NB: these are addresses for 16-bit accesses */125#define CFI_INTEL_PLR 0x80 /* Protection Lock Register */126#define CFI_INTEL_PR(n) (0x81+(n)) /* Protection Register */127128/* Status register definitions */129#define CFI_INTEL_STATUS_WSMS 0x0080 /* Write Machine Status */130#define CFI_INTEL_STATUS_ESS 0x0040 /* Erase Suspend Status */131#define CFI_INTEL_STATUS_ECLBS 0x0020 /* Erase and Clear Lock-Bit Status */132#define CFI_INTEL_STATUS_PSLBS 0x0010 /* Program and Set Lock-Bit Status */133#define CFI_INTEL_STATUS_VPENS 0x0008 /* Programming Voltage Status */134#define CFI_INTEL_STATUS_PSS 0x0004 /* Program Suspend Status */135#define CFI_INTEL_STATUS_DPS 0x0002 /* Device Protect Status */136#define CFI_INTEL_STATUS_RSVD 0x0001 /* reserved */137138/* eXtended Status register definitions */139#define CFI_INTEL_XSTATUS_WBS 0x8000 /* Write Buffer Status */140#define CFI_INTEL_XSTATUS_RSVD 0x7f00 /* reserved */141142/* AMD commands. */143#define CFI_AMD_BLOCK_ERASE 0x30144#define CFI_AMD_UNLOCK_ACK 0x55145#define CFI_AMD_ERASE_SECTOR 0x80146#define CFI_AMD_AUTO_SELECT 0x90147#define CFI_AMD_PROGRAM 0xa0148#define CFI_AMD_UNLOCK 0xaa149150#define AMD_ADDR_START 0xaaa151#define AMD_ADDR_ACK 0x555152153#define CFI_AMD_MAXCHK 0x10000154155#endif /* _DEV_CFI_REG_H_ */156157158