18c2ecf20Sopenharmony_ciAtmel NAND flash controller bindings
28c2ecf20Sopenharmony_ci
38c2ecf20Sopenharmony_ciThe NAND flash controller node should be defined under the EBI bus (see
48c2ecf20Sopenharmony_ciDocumentation/devicetree/bindings/memory-controllers/atmel,ebi.txt).
58c2ecf20Sopenharmony_ciOne or several NAND devices can be defined under this NAND controller.
68c2ecf20Sopenharmony_ciThe NAND controller might be connected to an ECC engine.
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci* NAND controller bindings:
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ciRequired properties:
118c2ecf20Sopenharmony_ci- compatible: should be one of the following
128c2ecf20Sopenharmony_ci	"atmel,at91rm9200-nand-controller"
138c2ecf20Sopenharmony_ci	"atmel,at91sam9260-nand-controller"
148c2ecf20Sopenharmony_ci	"atmel,at91sam9261-nand-controller"
158c2ecf20Sopenharmony_ci	"atmel,at91sam9g45-nand-controller"
168c2ecf20Sopenharmony_ci	"atmel,sama5d3-nand-controller"
178c2ecf20Sopenharmony_ci	"microchip,sam9x60-nand-controller"
188c2ecf20Sopenharmony_ci- ranges: empty ranges property to forward EBI ranges definitions.
198c2ecf20Sopenharmony_ci- #address-cells: should be set to 2.
208c2ecf20Sopenharmony_ci- #size-cells: should be set to 1.
218c2ecf20Sopenharmony_ci- atmel,nfc-io: phandle to the NFC IO block. Only required for sama5d3
228c2ecf20Sopenharmony_ci		controllers.
238c2ecf20Sopenharmony_ci- atmel,nfc-sram: phandle to the NFC SRAM block. Only required for sama5d3
248c2ecf20Sopenharmony_ci		  controllers.
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ciOptional properties:
278c2ecf20Sopenharmony_ci- ecc-engine: phandle to the PMECC block. Only meaningful if the SoC embeds
288c2ecf20Sopenharmony_ci	      a PMECC engine.
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ci* NAND device/chip bindings:
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_ciRequired properties:
338c2ecf20Sopenharmony_ci- reg: describes the CS lines assigned to the NAND device. If the NAND device
348c2ecf20Sopenharmony_ci       exposes multiple CS lines (multi-dies chips), your reg property will
358c2ecf20Sopenharmony_ci       contain X tuples of 3 entries.
368c2ecf20Sopenharmony_ci       1st entry: the CS line this NAND chip is connected to
378c2ecf20Sopenharmony_ci       2nd entry: the base offset of the memory region assigned to this
388c2ecf20Sopenharmony_ci		  device (always 0)
398c2ecf20Sopenharmony_ci       3rd entry: the memory region size (always 0x800000)
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_ciOptional properties:
428c2ecf20Sopenharmony_ci- rb-gpios: the GPIO(s) used to check the Ready/Busy status of the NAND.
438c2ecf20Sopenharmony_ci- cs-gpios: the GPIO(s) used to control the CS line.
448c2ecf20Sopenharmony_ci- det-gpios: the GPIO used to detect if a Smartmedia Card is present.
458c2ecf20Sopenharmony_ci- atmel,rb: an integer identifying the native Ready/Busy pin. Only meaningful
468c2ecf20Sopenharmony_ci	    on sama5 SoCs.
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_ciAll generic properties described in
498c2ecf20Sopenharmony_ciDocumentation/devicetree/bindings/mtd/{common,nand}.txt also apply to the NAND
508c2ecf20Sopenharmony_cidevice node, and NAND partitions should be defined under the NAND node as
518c2ecf20Sopenharmony_cidescribed in Documentation/devicetree/bindings/mtd/partition.txt.
528c2ecf20Sopenharmony_ci
538c2ecf20Sopenharmony_ci* ECC engine (PMECC) bindings:
548c2ecf20Sopenharmony_ci
558c2ecf20Sopenharmony_ciRequired properties:
568c2ecf20Sopenharmony_ci- compatible: should be one of the following
578c2ecf20Sopenharmony_ci	"atmel,at91sam9g45-pmecc"
588c2ecf20Sopenharmony_ci	"atmel,sama5d4-pmecc"
598c2ecf20Sopenharmony_ci	"atmel,sama5d2-pmecc"
608c2ecf20Sopenharmony_ci	"microchip,sam9x60-pmecc"
618c2ecf20Sopenharmony_ci- reg: should contain 2 register ranges. The first one is pointing to the PMECC
628c2ecf20Sopenharmony_ci       block, and the second one to the PMECC_ERRLOC block.
638c2ecf20Sopenharmony_ci
648c2ecf20Sopenharmony_ci* SAMA5 NFC I/O bindings:
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_ciSAMA5 SoCs embed an advanced NAND controller logic to automate READ/WRITE page
678c2ecf20Sopenharmony_cioperations. This interface to this logic is placed in a separate I/O range and
688c2ecf20Sopenharmony_cishould thus have its own DT node.
698c2ecf20Sopenharmony_ci
708c2ecf20Sopenharmony_ci- compatible: should be "atmel,sama5d3-nfc-io", "syscon".
718c2ecf20Sopenharmony_ci- reg: should contain the I/O range used to interact with the NFC logic.
728c2ecf20Sopenharmony_ci
738c2ecf20Sopenharmony_ciExample:
748c2ecf20Sopenharmony_ci
758c2ecf20Sopenharmony_ci	nfc_io: nfc-io@70000000 {
768c2ecf20Sopenharmony_ci		compatible = "atmel,sama5d3-nfc-io", "syscon";
778c2ecf20Sopenharmony_ci		reg = <0x70000000 0x8000000>;
788c2ecf20Sopenharmony_ci	};
798c2ecf20Sopenharmony_ci
808c2ecf20Sopenharmony_ci	pmecc: ecc-engine@ffffc070 {
818c2ecf20Sopenharmony_ci		compatible = "atmel,at91sam9g45-pmecc";
828c2ecf20Sopenharmony_ci                reg = <0xffffc070 0x490>,
838c2ecf20Sopenharmony_ci                      <0xffffc500 0x100>;
848c2ecf20Sopenharmony_ci	};
858c2ecf20Sopenharmony_ci
868c2ecf20Sopenharmony_ci	ebi: ebi@10000000 {
878c2ecf20Sopenharmony_ci		compatible = "atmel,sama5d3-ebi";
888c2ecf20Sopenharmony_ci		#address-cells = <2>;
898c2ecf20Sopenharmony_ci		#size-cells = <1>;
908c2ecf20Sopenharmony_ci		atmel,smc = <&hsmc>;
918c2ecf20Sopenharmony_ci		reg = <0x10000000 0x10000000
928c2ecf20Sopenharmony_ci		       0x40000000 0x30000000>;
938c2ecf20Sopenharmony_ci		ranges = <0x0 0x0 0x10000000 0x10000000
948c2ecf20Sopenharmony_ci			  0x1 0x0 0x40000000 0x10000000
958c2ecf20Sopenharmony_ci			  0x2 0x0 0x50000000 0x10000000
968c2ecf20Sopenharmony_ci			  0x3 0x0 0x60000000 0x10000000>;
978c2ecf20Sopenharmony_ci		clocks = <&mck>;
988c2ecf20Sopenharmony_ci
998c2ecf20Sopenharmony_ci                nand_controller: nand-controller {
1008c2ecf20Sopenharmony_ci			compatible = "atmel,sama5d3-nand-controller";
1018c2ecf20Sopenharmony_ci			atmel,nfc-sram = <&nfc_sram>;
1028c2ecf20Sopenharmony_ci			atmel,nfc-io = <&nfc_io>;
1038c2ecf20Sopenharmony_ci			ecc-engine = <&pmecc>;
1048c2ecf20Sopenharmony_ci			#address-cells = <2>;
1058c2ecf20Sopenharmony_ci			#size-cells = <1>;
1068c2ecf20Sopenharmony_ci			ranges;
1078c2ecf20Sopenharmony_ci
1088c2ecf20Sopenharmony_ci			nand@3 {
1098c2ecf20Sopenharmony_ci				reg = <0x3 0x0 0x800000>;
1108c2ecf20Sopenharmony_ci				atmel,rb = <0>;
1118c2ecf20Sopenharmony_ci
1128c2ecf20Sopenharmony_ci				/*
1138c2ecf20Sopenharmony_ci				 * Put generic NAND/MTD properties and
1148c2ecf20Sopenharmony_ci				 * subnodes here.
1158c2ecf20Sopenharmony_ci				 */
1168c2ecf20Sopenharmony_ci			};
1178c2ecf20Sopenharmony_ci		};
1188c2ecf20Sopenharmony_ci	};
1198c2ecf20Sopenharmony_ci
1208c2ecf20Sopenharmony_ci-----------------------------------------------------------------------
1218c2ecf20Sopenharmony_ci
1228c2ecf20Sopenharmony_ciDeprecated bindings (should not be used in new device trees):
1238c2ecf20Sopenharmony_ci
1248c2ecf20Sopenharmony_ciRequired properties:
1258c2ecf20Sopenharmony_ci- compatible: The possible values are:
1268c2ecf20Sopenharmony_ci	"atmel,at91rm9200-nand"
1278c2ecf20Sopenharmony_ci	"atmel,sama5d2-nand"
1288c2ecf20Sopenharmony_ci	"atmel,sama5d4-nand"
1298c2ecf20Sopenharmony_ci- reg : should specify localbus address and size used for the chip,
1308c2ecf20Sopenharmony_ci	and hardware ECC controller if available.
1318c2ecf20Sopenharmony_ci	If the hardware ECC is PMECC, it should contain address and size for
1328c2ecf20Sopenharmony_ci	PMECC and PMECC Error Location controller.
1338c2ecf20Sopenharmony_ci	The PMECC lookup table address and size in ROM is optional. If not
1348c2ecf20Sopenharmony_ci	specified, driver will build it in runtime.
1358c2ecf20Sopenharmony_ci- atmel,nand-addr-offset : offset for the address latch.
1368c2ecf20Sopenharmony_ci- atmel,nand-cmd-offset : offset for the command latch.
1378c2ecf20Sopenharmony_ci- #address-cells, #size-cells : Must be present if the device has sub-nodes
1388c2ecf20Sopenharmony_ci  representing partitions.
1398c2ecf20Sopenharmony_ci
1408c2ecf20Sopenharmony_ci- gpios : specifies the gpio pins to control the NAND device. detect is an
1418c2ecf20Sopenharmony_ci  optional gpio and may be set to 0 if not present.
1428c2ecf20Sopenharmony_ci
1438c2ecf20Sopenharmony_ciOptional properties:
1448c2ecf20Sopenharmony_ci- atmel,nand-has-dma : boolean to support dma transfer for nand read/write.
1458c2ecf20Sopenharmony_ci- nand-ecc-mode : String, operation mode of the NAND ecc mode, soft by default.
1468c2ecf20Sopenharmony_ci  Supported values are: "none", "soft", "hw", "hw_syndrome", "hw_oob_first",
1478c2ecf20Sopenharmony_ci  "soft_bch".
1488c2ecf20Sopenharmony_ci- atmel,has-pmecc : boolean to enable Programmable Multibit ECC hardware,
1498c2ecf20Sopenharmony_ci  capable of BCH encoding and decoding, on devices where it is present.
1508c2ecf20Sopenharmony_ci- atmel,pmecc-cap : error correct capability for Programmable Multibit ECC
1518c2ecf20Sopenharmony_ci  Controller. Supported values are: 2, 4, 8, 12, 24. If the compatible string
1528c2ecf20Sopenharmony_ci  is "atmel,sama5d2-nand", 32 is also valid.
1538c2ecf20Sopenharmony_ci- atmel,pmecc-sector-size : sector size for ECC computation. Supported values
1548c2ecf20Sopenharmony_ci  are: 512, 1024.
1558c2ecf20Sopenharmony_ci- atmel,pmecc-lookup-table-offset : includes two offsets of lookup table in ROM
1568c2ecf20Sopenharmony_ci  for different sector size. First one is for sector size 512, the next is for
1578c2ecf20Sopenharmony_ci  sector size 1024. If not specified, driver will build the table in runtime.
1588c2ecf20Sopenharmony_ci- nand-bus-width : 8 or 16 bus width if not present 8
1598c2ecf20Sopenharmony_ci- nand-on-flash-bbt: boolean to enable on flash bbt option if not present false
1608c2ecf20Sopenharmony_ci
1618c2ecf20Sopenharmony_ciNand Flash Controller(NFC) is an optional sub-node
1628c2ecf20Sopenharmony_ciRequired properties:
1638c2ecf20Sopenharmony_ci- compatible : "atmel,sama5d3-nfc".
1648c2ecf20Sopenharmony_ci- reg : should specify the address and size used for NFC command registers,
1658c2ecf20Sopenharmony_ci        NFC registers and NFC SRAM. NFC SRAM address and size can be absent
1668c2ecf20Sopenharmony_ci        if don't want to use it.
1678c2ecf20Sopenharmony_ci- clocks: phandle to the peripheral clock
1688c2ecf20Sopenharmony_ciOptional properties:
1698c2ecf20Sopenharmony_ci- atmel,write-by-sram: boolean to enable NFC write by SRAM.
1708c2ecf20Sopenharmony_ci
1718c2ecf20Sopenharmony_ciExamples:
1728c2ecf20Sopenharmony_cinand0: nand@40000000,0 {
1738c2ecf20Sopenharmony_ci	compatible = "atmel,at91rm9200-nand";
1748c2ecf20Sopenharmony_ci	#address-cells = <1>;
1758c2ecf20Sopenharmony_ci	#size-cells = <1>;
1768c2ecf20Sopenharmony_ci	reg = <0x40000000 0x10000000
1778c2ecf20Sopenharmony_ci	       0xffffe800 0x200
1788c2ecf20Sopenharmony_ci	      >;
1798c2ecf20Sopenharmony_ci	atmel,nand-addr-offset = <21>;	/* ale */
1808c2ecf20Sopenharmony_ci	atmel,nand-cmd-offset = <22>;	/* cle */
1818c2ecf20Sopenharmony_ci	nand-on-flash-bbt;
1828c2ecf20Sopenharmony_ci	nand-ecc-mode = "soft";
1838c2ecf20Sopenharmony_ci	gpios = <&pioC 13 0	/* rdy */
1848c2ecf20Sopenharmony_ci		 &pioC 14 0 	/* nce */
1858c2ecf20Sopenharmony_ci		 0		/* cd */
1868c2ecf20Sopenharmony_ci		>;
1878c2ecf20Sopenharmony_ci	partition@0 {
1888c2ecf20Sopenharmony_ci		...
1898c2ecf20Sopenharmony_ci	};
1908c2ecf20Sopenharmony_ci};
1918c2ecf20Sopenharmony_ci
1928c2ecf20Sopenharmony_ci/* for PMECC supported chips */
1938c2ecf20Sopenharmony_cinand0: nand@40000000 {
1948c2ecf20Sopenharmony_ci	compatible = "atmel,at91rm9200-nand";
1958c2ecf20Sopenharmony_ci	#address-cells = <1>;
1968c2ecf20Sopenharmony_ci	#size-cells = <1>;
1978c2ecf20Sopenharmony_ci	reg = < 0x40000000 0x10000000	/* bus addr & size */
1988c2ecf20Sopenharmony_ci		0xffffe000 0x00000600	/* PMECC addr & size */
1998c2ecf20Sopenharmony_ci		0xffffe600 0x00000200	/* PMECC ERRLOC addr & size */
2008c2ecf20Sopenharmony_ci		0x00100000 0x00100000	/* ROM addr & size */
2018c2ecf20Sopenharmony_ci		>;
2028c2ecf20Sopenharmony_ci	atmel,nand-addr-offset = <21>;	/* ale */
2038c2ecf20Sopenharmony_ci	atmel,nand-cmd-offset = <22>;	/* cle */
2048c2ecf20Sopenharmony_ci	nand-on-flash-bbt;
2058c2ecf20Sopenharmony_ci	nand-ecc-mode = "hw";
2068c2ecf20Sopenharmony_ci	atmel,has-pmecc;	/* enable PMECC */
2078c2ecf20Sopenharmony_ci	atmel,pmecc-cap = <2>;
2088c2ecf20Sopenharmony_ci	atmel,pmecc-sector-size = <512>;
2098c2ecf20Sopenharmony_ci	atmel,pmecc-lookup-table-offset = <0x8000 0x10000>;
2108c2ecf20Sopenharmony_ci	gpios = <&pioD 5 0	/* rdy */
2118c2ecf20Sopenharmony_ci		 &pioD 4 0	/* nce */
2128c2ecf20Sopenharmony_ci		 0		/* cd */
2138c2ecf20Sopenharmony_ci		>;
2148c2ecf20Sopenharmony_ci	partition@0 {
2158c2ecf20Sopenharmony_ci		...
2168c2ecf20Sopenharmony_ci	};
2178c2ecf20Sopenharmony_ci};
2188c2ecf20Sopenharmony_ci
2198c2ecf20Sopenharmony_ci/* for NFC supported chips */
2208c2ecf20Sopenharmony_cinand0: nand@40000000 {
2218c2ecf20Sopenharmony_ci	compatible = "atmel,at91rm9200-nand";
2228c2ecf20Sopenharmony_ci	#address-cells = <1>;
2238c2ecf20Sopenharmony_ci	#size-cells = <1>;
2248c2ecf20Sopenharmony_ci	ranges;
2258c2ecf20Sopenharmony_ci        ...
2268c2ecf20Sopenharmony_ci        nfc@70000000 {
2278c2ecf20Sopenharmony_ci		compatible = "atmel,sama5d3-nfc";
2288c2ecf20Sopenharmony_ci		#address-cells = <1>;
2298c2ecf20Sopenharmony_ci		#size-cells = <1>;
2308c2ecf20Sopenharmony_ci		clocks = <&hsmc_clk>
2318c2ecf20Sopenharmony_ci		reg = <
2328c2ecf20Sopenharmony_ci			0x70000000 0x10000000	/* NFC Command Registers */
2338c2ecf20Sopenharmony_ci			0xffffc000 0x00000070	/* NFC HSMC regs */
2348c2ecf20Sopenharmony_ci			0x00200000 0x00100000	/* NFC SRAM banks */
2358c2ecf20Sopenharmony_ci		>;
2368c2ecf20Sopenharmony_ci	};
2378c2ecf20Sopenharmony_ci};
238