18c2ecf20Sopenharmony_ciMTK SoCs NAND FLASH controller (NFC) DT binding
28c2ecf20Sopenharmony_ci
38c2ecf20Sopenharmony_ciThis file documents the device tree bindings for MTK SoCs NAND controllers.
48c2ecf20Sopenharmony_ciThe functional split of the controller requires two drivers to operate:
58c2ecf20Sopenharmony_cithe nand controller interface driver and the ECC engine driver.
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ciThe hardware description for both devices must be captured as device
88c2ecf20Sopenharmony_citree nodes.
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci1) NFC NAND Controller Interface (NFI):
118c2ecf20Sopenharmony_ci=======================================
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ciThe first part of NFC is NAND Controller Interface (NFI) HW.
148c2ecf20Sopenharmony_ciRequired NFI properties:
158c2ecf20Sopenharmony_ci- compatible:			Should be one of
168c2ecf20Sopenharmony_ci				"mediatek,mt2701-nfc",
178c2ecf20Sopenharmony_ci				"mediatek,mt2712-nfc",
188c2ecf20Sopenharmony_ci				"mediatek,mt7622-nfc".
198c2ecf20Sopenharmony_ci- reg:				Base physical address and size of NFI.
208c2ecf20Sopenharmony_ci- interrupts:			Interrupts of NFI.
218c2ecf20Sopenharmony_ci- clocks:			NFI required clocks.
228c2ecf20Sopenharmony_ci- clock-names:			NFI clocks internal name.
238c2ecf20Sopenharmony_ci- ecc-engine:			Required ECC Engine node.
248c2ecf20Sopenharmony_ci- #address-cells:		NAND chip index, should be 1.
258c2ecf20Sopenharmony_ci- #size-cells:			Should be 0.
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ciExample:
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_ci	nandc: nfi@1100d000 {
308c2ecf20Sopenharmony_ci		compatible = "mediatek,mt2701-nfc";
318c2ecf20Sopenharmony_ci		reg = <0 0x1100d000 0 0x1000>;
328c2ecf20Sopenharmony_ci		interrupts = <GIC_SPI 56 IRQ_TYPE_LEVEL_LOW>;
338c2ecf20Sopenharmony_ci		clocks = <&pericfg CLK_PERI_NFI>,
348c2ecf20Sopenharmony_ci			 <&pericfg CLK_PERI_NFI_PAD>;
358c2ecf20Sopenharmony_ci		clock-names = "nfi_clk", "pad_clk";
368c2ecf20Sopenharmony_ci		ecc-engine = <&bch>;
378c2ecf20Sopenharmony_ci		#address-cells = <1>;
388c2ecf20Sopenharmony_ci		#size-cells = <0>;
398c2ecf20Sopenharmony_ci        };
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_ciPlatform related properties, should be set in {platform_name}.dts:
428c2ecf20Sopenharmony_ci- children nodes:	NAND chips.
438c2ecf20Sopenharmony_ci
448c2ecf20Sopenharmony_ciChildren nodes properties:
458c2ecf20Sopenharmony_ci- reg:			Chip Select Signal, default 0.
468c2ecf20Sopenharmony_ci			Set as reg = <0>, <1> when need 2 CS.
478c2ecf20Sopenharmony_ciOptional:
488c2ecf20Sopenharmony_ci- nand-on-flash-bbt:	Store BBT on NAND Flash.
498c2ecf20Sopenharmony_ci- nand-ecc-mode:	the NAND ecc mode (check driver for supported modes)
508c2ecf20Sopenharmony_ci- nand-ecc-step-size:	Number of data bytes covered by a single ECC step.
518c2ecf20Sopenharmony_ci			valid values:
528c2ecf20Sopenharmony_ci			512 and 1024 on mt2701 and mt2712.
538c2ecf20Sopenharmony_ci			512 only on mt7622.
548c2ecf20Sopenharmony_ci			1024 is recommended for large page NANDs.
558c2ecf20Sopenharmony_ci- nand-ecc-strength:	Number of bits to correct per ECC step.
568c2ecf20Sopenharmony_ci			The valid values that each controller supports:
578c2ecf20Sopenharmony_ci			mt2701: 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 28,
588c2ecf20Sopenharmony_ci				32, 36, 40, 44, 48, 52, 56, 60.
598c2ecf20Sopenharmony_ci			mt2712: 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 28,
608c2ecf20Sopenharmony_ci				32, 36, 40, 44, 48, 52, 56, 60, 68, 72, 80.
618c2ecf20Sopenharmony_ci			mt7622: 4, 6, 8, 10, 12, 14, 16.
628c2ecf20Sopenharmony_ci			The strength should be calculated as follows:
638c2ecf20Sopenharmony_ci			E = (S - F) * 8 / B
648c2ecf20Sopenharmony_ci			S = O / (P / Q)
658c2ecf20Sopenharmony_ci				E :	nand-ecc-strength.
668c2ecf20Sopenharmony_ci				S :	spare size per sector.
678c2ecf20Sopenharmony_ci				F :	FDM size, should be in the range [1,8].
688c2ecf20Sopenharmony_ci					It is used to store free oob data.
698c2ecf20Sopenharmony_ci				O :	oob size.
708c2ecf20Sopenharmony_ci				P :	page size.
718c2ecf20Sopenharmony_ci				Q :	nand-ecc-step-size.
728c2ecf20Sopenharmony_ci				B :	number of parity bits needed to correct
738c2ecf20Sopenharmony_ci					1 bitflip.
748c2ecf20Sopenharmony_ci					According to MTK NAND controller design,
758c2ecf20Sopenharmony_ci					this number depends on max ecc step size
768c2ecf20Sopenharmony_ci					that MTK NAND controller supports.
778c2ecf20Sopenharmony_ci					If max ecc step size supported is 1024,
788c2ecf20Sopenharmony_ci					then it should be always 14. And if max
798c2ecf20Sopenharmony_ci					ecc step size is 512, then it should be
808c2ecf20Sopenharmony_ci					always 13.
818c2ecf20Sopenharmony_ci			If the result does not match any one of the listed
828c2ecf20Sopenharmony_ci			choices above, please select the smaller valid value from
838c2ecf20Sopenharmony_ci			the list.
848c2ecf20Sopenharmony_ci			(otherwise the driver will do the adjustment at runtime)
858c2ecf20Sopenharmony_ci- pinctrl-names:	Default NAND pin GPIO setting name.
868c2ecf20Sopenharmony_ci- pinctrl-0:		GPIO setting node.
878c2ecf20Sopenharmony_ci
888c2ecf20Sopenharmony_ciExample:
898c2ecf20Sopenharmony_ci	&pio {
908c2ecf20Sopenharmony_ci		nand_pins_default: nanddefault {
918c2ecf20Sopenharmony_ci			pins_dat {
928c2ecf20Sopenharmony_ci				pinmux = <MT2701_PIN_111_MSDC0_DAT7__FUNC_NLD7>,
938c2ecf20Sopenharmony_ci					 <MT2701_PIN_112_MSDC0_DAT6__FUNC_NLD6>,
948c2ecf20Sopenharmony_ci					 <MT2701_PIN_114_MSDC0_DAT4__FUNC_NLD4>,
958c2ecf20Sopenharmony_ci					 <MT2701_PIN_118_MSDC0_DAT3__FUNC_NLD3>,
968c2ecf20Sopenharmony_ci					 <MT2701_PIN_121_MSDC0_DAT0__FUNC_NLD0>,
978c2ecf20Sopenharmony_ci					 <MT2701_PIN_120_MSDC0_DAT1__FUNC_NLD1>,
988c2ecf20Sopenharmony_ci					 <MT2701_PIN_113_MSDC0_DAT5__FUNC_NLD5>,
998c2ecf20Sopenharmony_ci					 <MT2701_PIN_115_MSDC0_RSTB__FUNC_NLD8>,
1008c2ecf20Sopenharmony_ci					 <MT2701_PIN_119_MSDC0_DAT2__FUNC_NLD2>;
1018c2ecf20Sopenharmony_ci				input-enable;
1028c2ecf20Sopenharmony_ci				drive-strength = <MTK_DRIVE_8mA>;
1038c2ecf20Sopenharmony_ci				bias-pull-up;
1048c2ecf20Sopenharmony_ci			};
1058c2ecf20Sopenharmony_ci
1068c2ecf20Sopenharmony_ci			pins_we {
1078c2ecf20Sopenharmony_ci				pinmux = <MT2701_PIN_117_MSDC0_CLK__FUNC_NWEB>;
1088c2ecf20Sopenharmony_ci				drive-strength = <MTK_DRIVE_8mA>;
1098c2ecf20Sopenharmony_ci				bias-pull-up = <MTK_PUPD_SET_R1R0_10>;
1108c2ecf20Sopenharmony_ci			};
1118c2ecf20Sopenharmony_ci
1128c2ecf20Sopenharmony_ci			pins_ale {
1138c2ecf20Sopenharmony_ci				pinmux = <MT2701_PIN_116_MSDC0_CMD__FUNC_NALE>;
1148c2ecf20Sopenharmony_ci				drive-strength = <MTK_DRIVE_8mA>;
1158c2ecf20Sopenharmony_ci				bias-pull-down = <MTK_PUPD_SET_R1R0_10>;
1168c2ecf20Sopenharmony_ci			};
1178c2ecf20Sopenharmony_ci		};
1188c2ecf20Sopenharmony_ci	};
1198c2ecf20Sopenharmony_ci
1208c2ecf20Sopenharmony_ci	&nandc {
1218c2ecf20Sopenharmony_ci		status = "okay";
1228c2ecf20Sopenharmony_ci		pinctrl-names = "default";
1238c2ecf20Sopenharmony_ci		pinctrl-0 = <&nand_pins_default>;
1248c2ecf20Sopenharmony_ci		nand@0 {
1258c2ecf20Sopenharmony_ci			reg = <0>;
1268c2ecf20Sopenharmony_ci			nand-on-flash-bbt;
1278c2ecf20Sopenharmony_ci			nand-ecc-mode = "hw";
1288c2ecf20Sopenharmony_ci			nand-ecc-strength = <24>;
1298c2ecf20Sopenharmony_ci			nand-ecc-step-size = <1024>;
1308c2ecf20Sopenharmony_ci		};
1318c2ecf20Sopenharmony_ci	};
1328c2ecf20Sopenharmony_ci
1338c2ecf20Sopenharmony_ciNAND chip optional subnodes:
1348c2ecf20Sopenharmony_ci- Partitions, see Documentation/devicetree/bindings/mtd/partition.txt
1358c2ecf20Sopenharmony_ci
1368c2ecf20Sopenharmony_ciExample:
1378c2ecf20Sopenharmony_ci	nand@0 {
1388c2ecf20Sopenharmony_ci		partitions {
1398c2ecf20Sopenharmony_ci			compatible = "fixed-partitions";
1408c2ecf20Sopenharmony_ci			#address-cells = <1>;
1418c2ecf20Sopenharmony_ci			#size-cells = <1>;
1428c2ecf20Sopenharmony_ci
1438c2ecf20Sopenharmony_ci			preloader@0 {
1448c2ecf20Sopenharmony_ci				label = "pl";
1458c2ecf20Sopenharmony_ci				read-only;
1468c2ecf20Sopenharmony_ci				reg = <0x00000000 0x00400000>;
1478c2ecf20Sopenharmony_ci			};
1488c2ecf20Sopenharmony_ci			android@00400000 {
1498c2ecf20Sopenharmony_ci				label = "android";
1508c2ecf20Sopenharmony_ci				reg = <0x00400000 0x12c00000>;
1518c2ecf20Sopenharmony_ci			};
1528c2ecf20Sopenharmony_ci		};
1538c2ecf20Sopenharmony_ci	};
1548c2ecf20Sopenharmony_ci
1558c2ecf20Sopenharmony_ci2) ECC Engine:
1568c2ecf20Sopenharmony_ci==============
1578c2ecf20Sopenharmony_ci
1588c2ecf20Sopenharmony_ciRequired BCH properties:
1598c2ecf20Sopenharmony_ci- compatible:	Should be one of
1608c2ecf20Sopenharmony_ci		"mediatek,mt2701-ecc",
1618c2ecf20Sopenharmony_ci		"mediatek,mt2712-ecc",
1628c2ecf20Sopenharmony_ci		"mediatek,mt7622-ecc".
1638c2ecf20Sopenharmony_ci- reg:		Base physical address and size of ECC.
1648c2ecf20Sopenharmony_ci- interrupts:	Interrupts of ECC.
1658c2ecf20Sopenharmony_ci- clocks:	ECC required clocks.
1668c2ecf20Sopenharmony_ci- clock-names:	ECC clocks internal name.
1678c2ecf20Sopenharmony_ci
1688c2ecf20Sopenharmony_ciExample:
1698c2ecf20Sopenharmony_ci
1708c2ecf20Sopenharmony_ci	bch: ecc@1100e000 {
1718c2ecf20Sopenharmony_ci		compatible = "mediatek,mt2701-ecc";
1728c2ecf20Sopenharmony_ci		reg = <0 0x1100e000 0 0x1000>;
1738c2ecf20Sopenharmony_ci		interrupts = <GIC_SPI 55 IRQ_TYPE_LEVEL_LOW>;
1748c2ecf20Sopenharmony_ci		clocks = <&pericfg CLK_PERI_NFI_ECC>;
1758c2ecf20Sopenharmony_ci		clock-names = "nfiecc_clk";
1768c2ecf20Sopenharmony_ci	};
177