xref: /OK3568_Linux_fs/kernel/Documentation/devicetree/bindings/mtd/gpmc-nand.txt (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593SmuzhiyunDevice tree bindings for GPMC connected NANDs
2*4882a593Smuzhiyun
3*4882a593SmuzhiyunGPMC connected NAND (found on OMAP boards) are represented as child nodes of
4*4882a593Smuzhiyunthe GPMC controller with a name of "nand".
5*4882a593Smuzhiyun
6*4882a593SmuzhiyunAll timing relevant properties as well as generic gpmc child properties are
7*4882a593Smuzhiyunexplained in a separate documents - please refer to
8*4882a593SmuzhiyunDocumentation/devicetree/bindings/memory-controllers/omap-gpmc.txt
9*4882a593Smuzhiyun
10*4882a593SmuzhiyunFor NAND specific properties such as ECC modes or bus width, please refer to
11*4882a593SmuzhiyunDocumentation/devicetree/bindings/mtd/nand-controller.yaml
12*4882a593Smuzhiyun
13*4882a593Smuzhiyun
14*4882a593SmuzhiyunRequired properties:
15*4882a593Smuzhiyun
16*4882a593Smuzhiyun - compatible:	"ti,omap2-nand"
17*4882a593Smuzhiyun - reg:		range id (CS number), base offset and length of the
18*4882a593Smuzhiyun		NAND I/O space
19*4882a593Smuzhiyun - interrupts:	Two interrupt specifiers, one for fifoevent, one for termcount.
20*4882a593Smuzhiyun
21*4882a593SmuzhiyunOptional properties:
22*4882a593Smuzhiyun
23*4882a593Smuzhiyun - nand-bus-width: 		Set this numeric value to 16 if the hardware
24*4882a593Smuzhiyun				is wired that way. If not specified, a bus
25*4882a593Smuzhiyun				width of 8 is assumed.
26*4882a593Smuzhiyun
27*4882a593Smuzhiyun - ti,nand-ecc-opt:		A string setting the ECC layout to use. One of:
28*4882a593Smuzhiyun		"sw"		1-bit Hamming ecc code via software
29*4882a593Smuzhiyun		"hw"		<deprecated> use "ham1" instead
30*4882a593Smuzhiyun		"hw-romcode"	<deprecated> use "ham1" instead
31*4882a593Smuzhiyun		"ham1"		1-bit Hamming ecc code
32*4882a593Smuzhiyun		"bch4"		4-bit BCH ecc code
33*4882a593Smuzhiyun		"bch8"		8-bit BCH ecc code
34*4882a593Smuzhiyun		"bch16"		16-bit BCH ECC code
35*4882a593Smuzhiyun		Refer below "How to select correct ECC scheme for your device ?"
36*4882a593Smuzhiyun
37*4882a593Smuzhiyun - ti,nand-xfer-type:		A string setting the data transfer type. One of:
38*4882a593Smuzhiyun
39*4882a593Smuzhiyun		"prefetch-polled"	Prefetch polled mode (default)
40*4882a593Smuzhiyun		"polled"		Polled mode, without prefetch
41*4882a593Smuzhiyun		"prefetch-dma"		Prefetch enabled DMA mode
42*4882a593Smuzhiyun		"prefetch-irq"		Prefetch enabled irq mode
43*4882a593Smuzhiyun
44*4882a593Smuzhiyun - elm_id:	<deprecated> use "ti,elm-id" instead
45*4882a593Smuzhiyun - ti,elm-id:	Specifies phandle of the ELM devicetree node.
46*4882a593Smuzhiyun		ELM is an on-chip hardware engine on TI SoC which is used for
47*4882a593Smuzhiyun		locating ECC errors for BCHx algorithms. SoC devices which have
48*4882a593Smuzhiyun		ELM hardware engines should specify this device node in .dtsi
49*4882a593Smuzhiyun		Using ELM for ECC error correction frees some CPU cycles.
50*4882a593Smuzhiyun - rb-gpios:	GPIO specifier for the ready/busy# pin.
51*4882a593Smuzhiyun
52*4882a593SmuzhiyunFor inline partition table parsing (optional):
53*4882a593Smuzhiyun
54*4882a593Smuzhiyun - #address-cells: should be set to 1
55*4882a593Smuzhiyun - #size-cells: should be set to 1
56*4882a593Smuzhiyun
57*4882a593SmuzhiyunExample for an AM33xx board:
58*4882a593Smuzhiyun
59*4882a593Smuzhiyun	gpmc: gpmc@50000000 {
60*4882a593Smuzhiyun		compatible = "ti,am3352-gpmc";
61*4882a593Smuzhiyun		ti,hwmods = "gpmc";
62*4882a593Smuzhiyun		reg = <0x50000000 0x36c>;
63*4882a593Smuzhiyun		interrupts = <100>;
64*4882a593Smuzhiyun		gpmc,num-cs = <8>;
65*4882a593Smuzhiyun		gpmc,num-waitpins = <2>;
66*4882a593Smuzhiyun		#address-cells = <2>;
67*4882a593Smuzhiyun		#size-cells = <1>;
68*4882a593Smuzhiyun		ranges = <0 0 0x08000000 0x1000000>;	/* CS0 space, 16MB */
69*4882a593Smuzhiyun		elm_id = <&elm>;
70*4882a593Smuzhiyun		interrupt-controller;
71*4882a593Smuzhiyun		#interrupt-cells = <2>;
72*4882a593Smuzhiyun
73*4882a593Smuzhiyun		nand@0,0 {
74*4882a593Smuzhiyun			compatible = "ti,omap2-nand";
75*4882a593Smuzhiyun			reg = <0 0 4>;		/* CS0, offset 0, NAND I/O window 4 */
76*4882a593Smuzhiyun			interrupt-parent = <&gpmc>;
77*4882a593Smuzhiyun			interrupts = <0 IRQ_TYPE_NONE>, <1 IRQ_TYPE NONE>;
78*4882a593Smuzhiyun			nand-bus-width = <16>;
79*4882a593Smuzhiyun			ti,nand-ecc-opt = "bch8";
80*4882a593Smuzhiyun			ti,nand-xfer-type = "polled";
81*4882a593Smuzhiyun			rb-gpios = <&gpmc 0 GPIO_ACTIVE_HIGH>; /* gpmc_wait0 */
82*4882a593Smuzhiyun
83*4882a593Smuzhiyun			gpmc,sync-clk-ps = <0>;
84*4882a593Smuzhiyun			gpmc,cs-on-ns = <0>;
85*4882a593Smuzhiyun			gpmc,cs-rd-off-ns = <44>;
86*4882a593Smuzhiyun			gpmc,cs-wr-off-ns = <44>;
87*4882a593Smuzhiyun			gpmc,adv-on-ns = <6>;
88*4882a593Smuzhiyun			gpmc,adv-rd-off-ns = <34>;
89*4882a593Smuzhiyun			gpmc,adv-wr-off-ns = <44>;
90*4882a593Smuzhiyun			gpmc,we-off-ns = <40>;
91*4882a593Smuzhiyun			gpmc,oe-off-ns = <54>;
92*4882a593Smuzhiyun			gpmc,access-ns = <64>;
93*4882a593Smuzhiyun			gpmc,rd-cycle-ns = <82>;
94*4882a593Smuzhiyun			gpmc,wr-cycle-ns = <82>;
95*4882a593Smuzhiyun			gpmc,wr-access-ns = <40>;
96*4882a593Smuzhiyun			gpmc,wr-data-mux-bus-ns = <0>;
97*4882a593Smuzhiyun
98*4882a593Smuzhiyun			#address-cells = <1>;
99*4882a593Smuzhiyun			#size-cells = <1>;
100*4882a593Smuzhiyun
101*4882a593Smuzhiyun			/* partitions go here */
102*4882a593Smuzhiyun		};
103*4882a593Smuzhiyun	};
104*4882a593Smuzhiyun
105*4882a593SmuzhiyunHow to select correct ECC scheme for your device ?
106*4882a593Smuzhiyun--------------------------------------------------
107*4882a593SmuzhiyunHigher ECC scheme usually means better protection against bit-flips and
108*4882a593Smuzhiyunincreased system lifetime. However, selection of ECC scheme is dependent
109*4882a593Smuzhiyunon various other factors also like;
110*4882a593Smuzhiyun
111*4882a593Smuzhiyun(1) support of built in hardware engines.
112*4882a593Smuzhiyun	Some legacy OMAP SoC do not have ELM harware engine, so those SoC cannot
113*4882a593Smuzhiyun	support ecc-schemes with hardware error-correction (BCHx_HW). However
114*4882a593Smuzhiyun	such SoC can use ecc-schemes with software library for error-correction
115*4882a593Smuzhiyun	(BCHx_HW_DETECTION_SW). The error correction capability with software
116*4882a593Smuzhiyun	library remains equivalent to their hardware counter-part, but there is
117*4882a593Smuzhiyun	slight CPU penalty when too many bit-flips are detected during reads.
118*4882a593Smuzhiyun
119*4882a593Smuzhiyun(2) Device parameters like OOBSIZE.
120*4882a593Smuzhiyun	Other factor which governs the selection of ecc-scheme is oob-size.
121*4882a593Smuzhiyun	Higher ECC schemes require more OOB/Spare area to store ECC syndrome,
122*4882a593Smuzhiyun	so the device should have enough free bytes available its OOB/Spare
123*4882a593Smuzhiyun	area to accommodate ECC for entire page. In general following expression
124*4882a593Smuzhiyun	helps in determining if given device can accommodate ECC syndrome:
125*4882a593Smuzhiyun	"2 + (PAGESIZE / 512) * ECC_BYTES" <= OOBSIZE"
126*4882a593Smuzhiyun	where
127*4882a593Smuzhiyun		OOBSIZE		number of bytes in OOB/spare area
128*4882a593Smuzhiyun		PAGESIZE	number of bytes in main-area of device page
129*4882a593Smuzhiyun		ECC_BYTES	number of ECC bytes generated to protect
130*4882a593Smuzhiyun		                512 bytes of data, which is:
131*4882a593Smuzhiyun				'3' for HAM1_xx ecc schemes
132*4882a593Smuzhiyun				'7' for BCH4_xx ecc schemes
133*4882a593Smuzhiyun				'14' for BCH8_xx ecc schemes
134*4882a593Smuzhiyun				'26' for BCH16_xx ecc schemes
135*4882a593Smuzhiyun
136*4882a593Smuzhiyun	Example(a): For a device with PAGESIZE = 2048 and OOBSIZE = 64 and
137*4882a593Smuzhiyun		trying to use BCH16 (ECC_BYTES=26) ecc-scheme.
138*4882a593Smuzhiyun		Number of ECC bytes per page = (2 + (2048 / 512) * 26) = 106 B
139*4882a593Smuzhiyun		which is greater than capacity of NAND device (OOBSIZE=64)
140*4882a593Smuzhiyun		Hence, BCH16 cannot be supported on given device. But it can
141*4882a593Smuzhiyun		probably use lower ecc-schemes like BCH8.
142*4882a593Smuzhiyun
143*4882a593Smuzhiyun	Example(b): For a device with PAGESIZE = 2048 and OOBSIZE = 128 and
144*4882a593Smuzhiyun		trying to use BCH16 (ECC_BYTES=26) ecc-scheme.
145*4882a593Smuzhiyun		Number of ECC bytes per page = (2 + (2048 / 512) * 26) = 106 B
146*4882a593Smuzhiyun		which can be accommodated in the OOB/Spare area of this device
147*4882a593Smuzhiyun		(OOBSIZE=128). So this device can use BCH16 ecc-scheme.
148