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