summaryrefslogtreecommitdiffstats
path: root/sys/dev/cfi/cfi_reg.h
blob: fe4d73059748f9253ce75e2362dd36be12508cfb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/*-
 * 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_ */
OpenPOWER on IntegriCloud