xref: /OK3568_Linux_fs/kernel/Documentation/devicetree/bindings/mtd/mtk-nand.txt (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593SmuzhiyunMTK SoCs NAND FLASH controller (NFC) DT binding
2*4882a593Smuzhiyun
3*4882a593SmuzhiyunThis file documents the device tree bindings for MTK SoCs NAND controllers.
4*4882a593SmuzhiyunThe functional split of the controller requires two drivers to operate:
5*4882a593Smuzhiyunthe nand controller interface driver and the ECC engine driver.
6*4882a593Smuzhiyun
7*4882a593SmuzhiyunThe hardware description for both devices must be captured as device
8*4882a593Smuzhiyuntree nodes.
9*4882a593Smuzhiyun
10*4882a593Smuzhiyun1) NFC NAND Controller Interface (NFI):
11*4882a593Smuzhiyun=======================================
12*4882a593Smuzhiyun
13*4882a593SmuzhiyunThe first part of NFC is NAND Controller Interface (NFI) HW.
14*4882a593SmuzhiyunRequired NFI properties:
15*4882a593Smuzhiyun- compatible:			Should be one of
16*4882a593Smuzhiyun				"mediatek,mt2701-nfc",
17*4882a593Smuzhiyun				"mediatek,mt2712-nfc",
18*4882a593Smuzhiyun				"mediatek,mt7622-nfc".
19*4882a593Smuzhiyun- reg:				Base physical address and size of NFI.
20*4882a593Smuzhiyun- interrupts:			Interrupts of NFI.
21*4882a593Smuzhiyun- clocks:			NFI required clocks.
22*4882a593Smuzhiyun- clock-names:			NFI clocks internal name.
23*4882a593Smuzhiyun- ecc-engine:			Required ECC Engine node.
24*4882a593Smuzhiyun- #address-cells:		NAND chip index, should be 1.
25*4882a593Smuzhiyun- #size-cells:			Should be 0.
26*4882a593Smuzhiyun
27*4882a593SmuzhiyunExample:
28*4882a593Smuzhiyun
29*4882a593Smuzhiyun	nandc: nfi@1100d000 {
30*4882a593Smuzhiyun		compatible = "mediatek,mt2701-nfc";
31*4882a593Smuzhiyun		reg = <0 0x1100d000 0 0x1000>;
32*4882a593Smuzhiyun		interrupts = <GIC_SPI 56 IRQ_TYPE_LEVEL_LOW>;
33*4882a593Smuzhiyun		clocks = <&pericfg CLK_PERI_NFI>,
34*4882a593Smuzhiyun			 <&pericfg CLK_PERI_NFI_PAD>;
35*4882a593Smuzhiyun		clock-names = "nfi_clk", "pad_clk";
36*4882a593Smuzhiyun		ecc-engine = <&bch>;
37*4882a593Smuzhiyun		#address-cells = <1>;
38*4882a593Smuzhiyun		#size-cells = <0>;
39*4882a593Smuzhiyun        };
40*4882a593Smuzhiyun
41*4882a593SmuzhiyunPlatform related properties, should be set in {platform_name}.dts:
42*4882a593Smuzhiyun- children nodes:	NAND chips.
43*4882a593Smuzhiyun
44*4882a593SmuzhiyunChildren nodes properties:
45*4882a593Smuzhiyun- reg:			Chip Select Signal, default 0.
46*4882a593Smuzhiyun			Set as reg = <0>, <1> when need 2 CS.
47*4882a593SmuzhiyunOptional:
48*4882a593Smuzhiyun- nand-on-flash-bbt:	Store BBT on NAND Flash.
49*4882a593Smuzhiyun- nand-ecc-mode:	the NAND ecc mode (check driver for supported modes)
50*4882a593Smuzhiyun- nand-ecc-step-size:	Number of data bytes covered by a single ECC step.
51*4882a593Smuzhiyun			valid values:
52*4882a593Smuzhiyun			512 and 1024 on mt2701 and mt2712.
53*4882a593Smuzhiyun			512 only on mt7622.
54*4882a593Smuzhiyun			1024 is recommended for large page NANDs.
55*4882a593Smuzhiyun- nand-ecc-strength:	Number of bits to correct per ECC step.
56*4882a593Smuzhiyun			The valid values that each controller supports:
57*4882a593Smuzhiyun			mt2701: 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 28,
58*4882a593Smuzhiyun				32, 36, 40, 44, 48, 52, 56, 60.
59*4882a593Smuzhiyun			mt2712: 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 28,
60*4882a593Smuzhiyun				32, 36, 40, 44, 48, 52, 56, 60, 68, 72, 80.
61*4882a593Smuzhiyun			mt7622: 4, 6, 8, 10, 12, 14, 16.
62*4882a593Smuzhiyun			The strength should be calculated as follows:
63*4882a593Smuzhiyun			E = (S - F) * 8 / B
64*4882a593Smuzhiyun			S = O / (P / Q)
65*4882a593Smuzhiyun				E :	nand-ecc-strength.
66*4882a593Smuzhiyun				S :	spare size per sector.
67*4882a593Smuzhiyun				F :	FDM size, should be in the range [1,8].
68*4882a593Smuzhiyun					It is used to store free oob data.
69*4882a593Smuzhiyun				O :	oob size.
70*4882a593Smuzhiyun				P :	page size.
71*4882a593Smuzhiyun				Q :	nand-ecc-step-size.
72*4882a593Smuzhiyun				B :	number of parity bits needed to correct
73*4882a593Smuzhiyun					1 bitflip.
74*4882a593Smuzhiyun					According to MTK NAND controller design,
75*4882a593Smuzhiyun					this number depends on max ecc step size
76*4882a593Smuzhiyun					that MTK NAND controller supports.
77*4882a593Smuzhiyun					If max ecc step size supported is 1024,
78*4882a593Smuzhiyun					then it should be always 14. And if max
79*4882a593Smuzhiyun					ecc step size is 512, then it should be
80*4882a593Smuzhiyun					always 13.
81*4882a593Smuzhiyun			If the result does not match any one of the listed
82*4882a593Smuzhiyun			choices above, please select the smaller valid value from
83*4882a593Smuzhiyun			the list.
84*4882a593Smuzhiyun			(otherwise the driver will do the adjustment at runtime)
85*4882a593Smuzhiyun- pinctrl-names:	Default NAND pin GPIO setting name.
86*4882a593Smuzhiyun- pinctrl-0:		GPIO setting node.
87*4882a593Smuzhiyun
88*4882a593SmuzhiyunExample:
89*4882a593Smuzhiyun	&pio {
90*4882a593Smuzhiyun		nand_pins_default: nanddefault {
91*4882a593Smuzhiyun			pins_dat {
92*4882a593Smuzhiyun				pinmux = <MT2701_PIN_111_MSDC0_DAT7__FUNC_NLD7>,
93*4882a593Smuzhiyun					 <MT2701_PIN_112_MSDC0_DAT6__FUNC_NLD6>,
94*4882a593Smuzhiyun					 <MT2701_PIN_114_MSDC0_DAT4__FUNC_NLD4>,
95*4882a593Smuzhiyun					 <MT2701_PIN_118_MSDC0_DAT3__FUNC_NLD3>,
96*4882a593Smuzhiyun					 <MT2701_PIN_121_MSDC0_DAT0__FUNC_NLD0>,
97*4882a593Smuzhiyun					 <MT2701_PIN_120_MSDC0_DAT1__FUNC_NLD1>,
98*4882a593Smuzhiyun					 <MT2701_PIN_113_MSDC0_DAT5__FUNC_NLD5>,
99*4882a593Smuzhiyun					 <MT2701_PIN_115_MSDC0_RSTB__FUNC_NLD8>,
100*4882a593Smuzhiyun					 <MT2701_PIN_119_MSDC0_DAT2__FUNC_NLD2>;
101*4882a593Smuzhiyun				input-enable;
102*4882a593Smuzhiyun				drive-strength = <MTK_DRIVE_8mA>;
103*4882a593Smuzhiyun				bias-pull-up;
104*4882a593Smuzhiyun			};
105*4882a593Smuzhiyun
106*4882a593Smuzhiyun			pins_we {
107*4882a593Smuzhiyun				pinmux = <MT2701_PIN_117_MSDC0_CLK__FUNC_NWEB>;
108*4882a593Smuzhiyun				drive-strength = <MTK_DRIVE_8mA>;
109*4882a593Smuzhiyun				bias-pull-up = <MTK_PUPD_SET_R1R0_10>;
110*4882a593Smuzhiyun			};
111*4882a593Smuzhiyun
112*4882a593Smuzhiyun			pins_ale {
113*4882a593Smuzhiyun				pinmux = <MT2701_PIN_116_MSDC0_CMD__FUNC_NALE>;
114*4882a593Smuzhiyun				drive-strength = <MTK_DRIVE_8mA>;
115*4882a593Smuzhiyun				bias-pull-down = <MTK_PUPD_SET_R1R0_10>;
116*4882a593Smuzhiyun			};
117*4882a593Smuzhiyun		};
118*4882a593Smuzhiyun	};
119*4882a593Smuzhiyun
120*4882a593Smuzhiyun	&nandc {
121*4882a593Smuzhiyun		status = "okay";
122*4882a593Smuzhiyun		pinctrl-names = "default";
123*4882a593Smuzhiyun		pinctrl-0 = <&nand_pins_default>;
124*4882a593Smuzhiyun		nand@0 {
125*4882a593Smuzhiyun			reg = <0>;
126*4882a593Smuzhiyun			nand-on-flash-bbt;
127*4882a593Smuzhiyun			nand-ecc-mode = "hw";
128*4882a593Smuzhiyun			nand-ecc-strength = <24>;
129*4882a593Smuzhiyun			nand-ecc-step-size = <1024>;
130*4882a593Smuzhiyun		};
131*4882a593Smuzhiyun	};
132*4882a593Smuzhiyun
133*4882a593SmuzhiyunNAND chip optional subnodes:
134*4882a593Smuzhiyun- Partitions, see Documentation/devicetree/bindings/mtd/partition.txt
135*4882a593Smuzhiyun
136*4882a593SmuzhiyunExample:
137*4882a593Smuzhiyun	nand@0 {
138*4882a593Smuzhiyun		partitions {
139*4882a593Smuzhiyun			compatible = "fixed-partitions";
140*4882a593Smuzhiyun			#address-cells = <1>;
141*4882a593Smuzhiyun			#size-cells = <1>;
142*4882a593Smuzhiyun
143*4882a593Smuzhiyun			preloader@0 {
144*4882a593Smuzhiyun				label = "pl";
145*4882a593Smuzhiyun				read-only;
146*4882a593Smuzhiyun				reg = <0x00000000 0x00400000>;
147*4882a593Smuzhiyun			};
148*4882a593Smuzhiyun			android@00400000 {
149*4882a593Smuzhiyun				label = "android";
150*4882a593Smuzhiyun				reg = <0x00400000 0x12c00000>;
151*4882a593Smuzhiyun			};
152*4882a593Smuzhiyun		};
153*4882a593Smuzhiyun	};
154*4882a593Smuzhiyun
155*4882a593Smuzhiyun2) ECC Engine:
156*4882a593Smuzhiyun==============
157*4882a593Smuzhiyun
158*4882a593SmuzhiyunRequired BCH properties:
159*4882a593Smuzhiyun- compatible:	Should be one of
160*4882a593Smuzhiyun		"mediatek,mt2701-ecc",
161*4882a593Smuzhiyun		"mediatek,mt2712-ecc",
162*4882a593Smuzhiyun		"mediatek,mt7622-ecc".
163*4882a593Smuzhiyun- reg:		Base physical address and size of ECC.
164*4882a593Smuzhiyun- interrupts:	Interrupts of ECC.
165*4882a593Smuzhiyun- clocks:	ECC required clocks.
166*4882a593Smuzhiyun- clock-names:	ECC clocks internal name.
167*4882a593Smuzhiyun
168*4882a593SmuzhiyunExample:
169*4882a593Smuzhiyun
170*4882a593Smuzhiyun	bch: ecc@1100e000 {
171*4882a593Smuzhiyun		compatible = "mediatek,mt2701-ecc";
172*4882a593Smuzhiyun		reg = <0 0x1100e000 0 0x1000>;
173*4882a593Smuzhiyun		interrupts = <GIC_SPI 55 IRQ_TYPE_LEVEL_LOW>;
174*4882a593Smuzhiyun		clocks = <&pericfg CLK_PERI_NFI_ECC>;
175*4882a593Smuzhiyun		clock-names = "nfiecc_clk";
176*4882a593Smuzhiyun	};
177