summaryrefslogtreecommitdiff
path: root/drivers/mtd/nand/nand_device_info.h
blob: a5f56e913ec6bdd1de36401f3b069874ed959ae0 (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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
/*
 * Copyright 2009 Freescale Semiconductor, Inc. All Rights Reserved.
 */

/*
 * The code contained herein is licensed under the GNU General Public
 * License. You may obtain a copy of the GNU General Public License
 * Version 2 or later at the following locations:
 *
 * http://www.opensource.org/licenses/gpl-license.html
 * http://www.gnu.org/copyleft/gpl.html
 */
#ifndef __DRIVERS_NAND_DEVICE_INFO_H
#define __DRIVERS_NAND_DEVICE_INFO_H

 /*
  * The number of ID bytes to read from the NAND Flash device and hand over to
  * the identification system.
  */

#define NAND_DEVICE_ID_BYTE_COUNT  (6)

 /*
  * The number of ID bytes to read from the NAND Flash device and hand over to
  * the identification system.
  */

enum nand_device_cell_technology {
	NAND_DEVICE_CELL_TECH_SLC = 0,
	NAND_DEVICE_CELL_TECH_MLC = 1,
};

/**
 * struct nand_device_info - Information about a single NAND Flash device.
 *
 * This structure contains all the *essential* information about a NAND Flash
 * device, derived from the device's data sheet. For each manufacturer, we have
 * an array of these structures.
 *
 * @end_of_table:              If true, marks the end of a table of device
 *                             information.
 * @manufacturer_code:         The manufacturer code (1st ID byte) reported by
 *                             the device.
 * @device_code:               The device code (2nd ID byte) reported by the
 *                             device.
 * @cell_technology:           The storage cell technology.
 * @chip_size_in_bytes:        The total size of the storage behind a single
 *                             chip select, in bytes. Notice that this is *not*
 *                             necessarily the total size of the storage in a
 *                             *package*, which may contain several chips.
 * @block_size_in_pages:       The number of pages in a block.
 * @page_total_size_in_bytes:  The total size of a page, in bytes, including
 *                             both the data and the OOB.
 * @ecc_strength_in_bits:      The strength of the ECC called for by the
 *                             manufacturer, in number of correctable bits.
 * @ecc_size_in_bytes:         The size of the data block over which the
 *                             manufacturer calls for the given ECC algorithm
 *                             and strength.
 * @data_setup_in_ns:          The data setup time, in nanoseconds. Usually the
 *                             maximum of tDS and tWP. A negative value
 *                             indicates this characteristic isn't known.
 * @data_hold_in_ns:           The data hold time, in nanoseconds. Usually the
 *                             maximum of tDH, tWH and tREH. A negative value
 *                             indicates this characteristic isn't known.
 * @address_setup_in_ns:       The address setup time, in nanoseconds. Usually
 *                             the maximum of tCLS, tCS and tALS. A negative
 *                             value indicates this characteristic isn't known.
 * @gpmi_sample_delay_in_ns:   A GPMI-specific timing parameter. A negative
 *                             value indicates this characteristic isn't known.
 * @tREA_in_ns:                tREA, in nanoseconds, from the data sheet. A
 *                             negative value indicates this characteristic
 *                             isn't known.
 * @tRLOH_in_ns:               tRLOH, in nanoseconds, from the data sheet. A
 *                             negative value indicates this characteristic
 *                             isn't known.
 * @tRHOH_in_ns:               tRHOH, in nanoseconds, from the data sheet. A
 *                             negative value indicates this characteristic
 *                             isn't known.
 */

struct nand_device_info {

	/* End of table marker */

	bool      end_of_table;

	/* Manufacturer and Device codes */

	uint8_t   manufacturer_code;
	uint8_t   device_code;

	/* Technology */

	enum nand_device_cell_technology  cell_technology;

	/* Geometry */

	uint64_t  chip_size_in_bytes;
	uint32_t  block_size_in_pages;
	uint16_t  page_total_size_in_bytes;

	/* ECC */

	uint8_t   ecc_strength_in_bits;
	uint16_t  ecc_size_in_bytes;

	/* Timing */

	int8_t    data_setup_in_ns;
	int8_t    data_hold_in_ns;
	int8_t    address_setup_in_ns;
	int8_t    gpmi_sample_delay_in_ns;
	int8_t    tREA_in_ns;
	int8_t    tRLOH_in_ns;
	int8_t    tRHOH_in_ns;

	/* Description */

	const char  *description;

};

/**
 * nand_device_get_info - Get info about a device based on ID bytes.
 *
 * @id_bytes:  An array of NAND_DEVICE_ID_BYTE_COUNT ID bytes retrieved from the
 *             NAND Flash device.
 */

struct nand_device_info *nand_device_get_info(const uint8_t id_bytes[]);

/**
 * nand_device_print_info - Prints information about a NAND Flash device.
 *
 * @info  A pointer to a NAND Flash device information structure.
 */

void nand_device_print_info(struct nand_device_info *info);

#endif