xref: /netbsd-src/sys/dev/nand/onfi.h (revision 001ca8836de22d811d5137823edcf6d12a4797a8)
1*001ca883Sandvar /*	$NetBSD: onfi.h,v 1.4 2022/06/03 12:10:51 andvar Exp $	*/
22b6ee221Sahoka 
32b6ee221Sahoka /*-
42b6ee221Sahoka  * Copyright (c) 2010 Department of Software Engineering,
52b6ee221Sahoka  *		      University of Szeged, Hungary
62b6ee221Sahoka  * Copyright (c) 2010 Adam Hoka <ahoka@NetBSD.org>
72b6ee221Sahoka  * All rights reserved.
82b6ee221Sahoka  *
92b6ee221Sahoka  * This code is derived from software contributed to The NetBSD Foundation
102b6ee221Sahoka  * by the Department of Software Engineering, University of Szeged, Hungary
112b6ee221Sahoka  *
122b6ee221Sahoka  * Redistribution and use in source and binary forms, with or without
132b6ee221Sahoka  * modification, are permitted provided that the following conditions
142b6ee221Sahoka  * are met:
152b6ee221Sahoka  * 1. Redistributions of source code must retain the above copyright
162b6ee221Sahoka  *    notice, this list of conditions and the following disclaimer.
172b6ee221Sahoka  * 2. Redistributions in binary form must reproduce the above copyright
182b6ee221Sahoka  *    notice, this list of conditions and the following disclaimer in the
192b6ee221Sahoka  *    documentation and/or other materials provided with the distribution.
202b6ee221Sahoka  *
212b6ee221Sahoka  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
222b6ee221Sahoka  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
232b6ee221Sahoka  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
242b6ee221Sahoka  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
252b6ee221Sahoka  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
262b6ee221Sahoka  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
272b6ee221Sahoka  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
282b6ee221Sahoka  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
292b6ee221Sahoka  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
302b6ee221Sahoka  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
312b6ee221Sahoka  * SUCH DAMAGE.
322b6ee221Sahoka  */
332b6ee221Sahoka 
342b6ee221Sahoka #ifndef _ONFI_H_
352b6ee221Sahoka #define _ONFI_H_
362b6ee221Sahoka 
372b6ee221Sahoka /**
382b6ee221Sahoka  * ONFI 2.2, Section 5.1: Command Set
392b6ee221Sahoka  *
402b6ee221Sahoka  * Indented ones are 2nd or 3rd cycle commands.
412b6ee221Sahoka  */
422b6ee221Sahoka 
432b6ee221Sahoka enum {
442b6ee221Sahoka 	ONFI_READ				= 0x00,	/* M */
452b6ee221Sahoka 	 ONFI_READ_START			= 0x30,	/* M */
462b6ee221Sahoka 	 ONFI_READ_INTERLEAVED			= 0x32,	/* O */
472b6ee221Sahoka 	 ONFI_READ_COPYBACK			= 0x35,	/* O */
482b6ee221Sahoka 	 ONFI_READ_CACHE_RANDOM			= 0x31,	/* O */
492b6ee221Sahoka 
502b6ee221Sahoka 	ONFI_CHANGE_READ_COLUMN			= 0x05,	/* M */
512b6ee221Sahoka 	ONFI_CHANGE_READ_COLUMN_ENHANCED	= 0x06,	/* O */
522b6ee221Sahoka 	 ONFI_CHANGE_READ_COLUMN_START		= 0xe0,	/* M */
532b6ee221Sahoka 
542b6ee221Sahoka 	ONFI_READ_CACHE_SEQUENTIAL		= 0x31,	/* O */
552b6ee221Sahoka 	ONFI_READ_CACHE_END			= 0x3f,	/* O */
562b6ee221Sahoka 
572b6ee221Sahoka 	ONFI_BLOCK_ERASE			= 0x60,	/* M */
582b6ee221Sahoka 	 ONFI_BLOCK_ERASE_START			= 0xd0,	/* M */
592b6ee221Sahoka 	 ONFI_BLOCK_ERASE_INTERLEAVED		= 0xd1,	/* O */
602b6ee221Sahoka 
612b6ee221Sahoka 	ONFI_READ_STATUS			= 0x70,	/* M */
622b6ee221Sahoka 	ONFI_READ_STATUS_ENHANCED		= 0x78,	/* O */
632b6ee221Sahoka 
642b6ee221Sahoka 	ONFI_PAGE_PROGRAM			= 0x80,	/* M */
652b6ee221Sahoka 	 ONFI_PAGE_PROGRAM_START		= 0x10,	/* M */
662b6ee221Sahoka 	 ONFI_PAGE_PROGRAM_INTERLEAVED		= 0x11,	/* O */
672b6ee221Sahoka 	 ONFI_PAGE_CACHE_PROGRAM		= 0x15,	/* O */
682b6ee221Sahoka 
692b6ee221Sahoka 	ONFI_COPYBACK_PROGRAM			= 0x85,	/* O */
702b6ee221Sahoka 	 ONFI_COPYBACK_PROGRAM_START		= 0x10,	/* O */
712b6ee221Sahoka 	 ONFI_COPYBACK_PROGRAM_INTERLEAVED	= 0x11,	/* O */
722b6ee221Sahoka /*-
732b6ee221Sahoka  * Small Data's first opcode may be 80h if the operation is a program only
742b6ee221Sahoka  * with no data output. For the last second cycle of a Small Data Move,
752b6ee221Sahoka  * it is a 10h command to confirm the Program or Copyback operation
762b6ee221Sahoka  */
772b6ee221Sahoka 	ONFI_SMALL_DATA_MOVE			= 0x85,	/* O */
782b6ee221Sahoka 	ONFI_SMALL_DATA_MOVE_START		= 0x11,	/* O */
792b6ee221Sahoka 
802b6ee221Sahoka 	ONFI_CHANGE_WRITE_COLUMN		= 0x85,	/* M */
812b6ee221Sahoka 	ONFI_CHANGE_ROW_ADDRESS			= 0x85,	/* O */
822b6ee221Sahoka 
832b6ee221Sahoka 	ONFI_READ_ID				= 0x90,	/* M */
842b6ee221Sahoka 	ONFI_READ_PARAMETER_PAGE		= 0xec,	/* M */
852b6ee221Sahoka 	ONFI_READ_UNIQUE_ID			= 0xed,	/* O */
862b6ee221Sahoka 	ONFI_GET_FEATURES			= 0xee,	/* O */
872b6ee221Sahoka 	ONFI_SET_FEATURES			= 0xef,	/* O */
882b6ee221Sahoka 	ONFI_RESET_LUN				= 0xfa,	/* O */
892b6ee221Sahoka 	ONFI_SYNCHRONOUS_RESET			= 0xfc,	/* O */
902b6ee221Sahoka 	ONFI_RESET				= 0xff	/* M */
912b6ee221Sahoka };
922b6ee221Sahoka 
932b6ee221Sahoka /**
942b6ee221Sahoka  * status codes from ONFI_READ_STATUS
952b6ee221Sahoka  */
962b6ee221Sahoka enum {
972b6ee221Sahoka 	ONFI_STATUS_FAIL			= (1<<0),
982b6ee221Sahoka 	ONFI_STATUS_FAILC			= (1<<1),
992b6ee221Sahoka 	ONFI_STATUS_R				= (1<<2),
1002b6ee221Sahoka 	ONFI_STATUS_CSP				= (1<<3),
1012b6ee221Sahoka 	ONFI_STATUS_VSP				= (1<<4),
1022b6ee221Sahoka 	ONFI_STATUS_ARDY			= (1<<5),
1032b6ee221Sahoka 	ONFI_STATUS_RDY				= (1<<6),
1042b6ee221Sahoka 	ONFI_STATUS_WP				= (1<<7)
1052b6ee221Sahoka };
1062b6ee221Sahoka 
1072b6ee221Sahoka enum {
1082b6ee221Sahoka 	ONFI_FEATURE_16BIT			= (1<<0),
1092b6ee221Sahoka 	ONFI_FEATURE_EXTENDED_PARAM		= (1<<7)
1102b6ee221Sahoka };
1112b6ee221Sahoka 
1122b6ee221Sahoka /* 5.7.1. Parameter Page Data Structure Definition */
1132b6ee221Sahoka struct onfi_parameter_page {
1142b6ee221Sahoka 	/* Revision information and features block */
1152b6ee221Sahoka 	uint32_t param_signature; /* M: onfi signature ({'O','N','F','I'}) */
1162b6ee221Sahoka 	uint16_t param_revision;  /* M: revision number */
1172b6ee221Sahoka 	uint16_t param_features;  /* M: features supported */
1182b6ee221Sahoka 	uint16_t param_optional_cmds; /* M: optional commands */
1192b6ee221Sahoka 	uint16_t param_reserved_1;    /* R: reserved */
12040064e24Smsaitoh 	uint16_t param_extended_len;  /* O: extended parameter page length */
1212b6ee221Sahoka 	uint8_t param_num_param_pg;  /* O: number of parameter pages */
1222b6ee221Sahoka 	uint8_t param_reserved_2[17]; /* R: reserved */
1232b6ee221Sahoka 	/* Manufacturer information block */
1242b6ee221Sahoka 	uint8_t param_manufacturer[12]; /* M: device manufacturer (ASCII) */
1252b6ee221Sahoka 	uint8_t param_model[20];	      /* M: device model (ASCII) */
1262b6ee221Sahoka 	uint8_t param_manufacturer_id;  /* M: JEDEC ID of manufacturer */
1272b6ee221Sahoka 	uint16_t param_date;	      /* O: date code (BCD) */
1282b6ee221Sahoka 	uint8_t param_reserved_3[13];   /* R: reserved */
1292b6ee221Sahoka 	/* Memory organization block */
1302b6ee221Sahoka 	uint32_t param_pagesize; /* M: number of data bytes per page */
1312b6ee221Sahoka 	uint16_t param_sparesize; /* M: number of spare bytes per page */
1322b6ee221Sahoka 	uint32_t param_part_pagesize; /* O: obsolete */
1332b6ee221Sahoka 	uint16_t param_part_sparesize; /* O: obsolete */
1342b6ee221Sahoka 	uint32_t param_blocksize;      /* M: number of pages per block */
1352b6ee221Sahoka 	uint32_t param_lunsize;       /* M: number of blocks per LUN */
1362b6ee221Sahoka 	uint8_t param_numluns;	      /* M: number of LUNs */
1372b6ee221Sahoka 	uint8_t param_addr_cycles;   /* M: address cycles:
1382b6ee221Sahoka 					col: 4-7 (high), row: 0-3 (low) */
1392b6ee221Sahoka 	uint8_t param_cellsize;   /* M: number of bits per cell */
1402b6ee221Sahoka 	uint16_t param_lun_maxbad; /* M: maximum badblocks per LUN */
1412b6ee221Sahoka 	uint16_t param_block_endurance; /* M: block endurance */
1422b6ee221Sahoka 	uint8_t param_guaranteed_blocks; /* M: guaranteed valid blocks at
143*001ca883Sandvar 					  beginning of target */
1442b6ee221Sahoka 	uint16_t param_guaranteed_endurance; /* M: block endurance of
14512301cc4Smsaitoh 					      guaranteed blocks */
1462b6ee221Sahoka 	uint8_t param_programs_per_page; /* M: number of programs per page */
1472b6ee221Sahoka 	uint8_t param_partial_programming_attr; /* O: obsolete */
1482b6ee221Sahoka 	uint8_t param_ecc_correctable_bits;     /* M: number of bits
1492b6ee221Sahoka 						 ECC correctability */
1502b6ee221Sahoka 	uint8_t param_interleaved_addr_bits; /* M: num of interleaved address
1512b6ee221Sahoka 					      bits (only low half is valid) */
1522b6ee221Sahoka 	uint8_t param_interleaved_op_attrs; /* O: obsolete */
1532b6ee221Sahoka 	uint8_t param_reserved_4[13];	  /* R: reserved */
1542b6ee221Sahoka 	/* Electrical parameters block */
1552b6ee221Sahoka 	uint8_t param_io_c_max; /* M: I/O pin capacitance, maximum */
1562b6ee221Sahoka 	uint16_t param_async_timing_mode; /* M: async timing mode support */
1572b6ee221Sahoka 	uint16_t param_async_progcache_timing_mode; /* O: obsolete */
1582b6ee221Sahoka 	uint16_t param_t_prog; /* M: maximum page program time (us) */
1592b6ee221Sahoka 	uint16_t param_t_bers; /* M: maximum block erase time (us) */
1602b6ee221Sahoka 	uint16_t param_t_r;    /* M: maximum page read time (us) */
1612b6ee221Sahoka 	uint16_t param_ccs;    /* M: minimum change column setup time (ns) */
1622b6ee221Sahoka 	uint16_t param_sync_timing_mode; /* source sync timing mode support */
1632b6ee221Sahoka 	uint8_t param_sync_features;     /* M: source sync features */
1642b6ee221Sahoka 	uint16_t param_clk_input_c;   /* O: CLK input pin cap., typical */
1652b6ee221Sahoka 	uint16_t param_io_c;	    /* O: I/O pin capacitance, typical */
1662b6ee221Sahoka 	uint16_t param_input_c;	    /* O: input pin capacitance, typical */
1672b6ee221Sahoka 	uint8_t param_input_c_max;    /* M: input pin capacitance, maximum */
1682b6ee221Sahoka 	uint8_t param_driver_strength; /* M: driver strength support */
1692b6ee221Sahoka 	uint16_t param_t_r_interleaved; /* O: maximum interleaved
1702b6ee221Sahoka 					 page read time (us) */
1712b6ee221Sahoka 	uint16_t param_t_adl;	/* O: program page register clear enhancement
1722b6ee221Sahoka 				 tADL value (ns) */
1732b6ee221Sahoka 	uint8_t param_reserved_5[8]; /* R: reserved */
1742b6ee221Sahoka 	/* Vendor block */
1752b6ee221Sahoka 	uint16_t param_vendor_revision; /* M: vendor specific rev number */
1762b6ee221Sahoka 	uint8_t param_vendor_specific[88]; /* vendor specific information */
1772b6ee221Sahoka 	uint16_t param_integrity_crc;	 /* M: integrity CRC */
1782b6ee221Sahoka } __packed;
1792b6ee221Sahoka 
1802b6ee221Sahoka #endif	/* _ONFI_H_ */
181