aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/mediatek/patches-4.19/0307-spi-mem-Mediatek-Add-SPI-Nand-support-for-MT7629.patch
blob: b8cb416b3ebe61270f767ab12720220ad7ac55d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
From c813fbe806257c574240770ef716fbee19f7dbfa Mon Sep 17 00:00:00 2001
From: Xiangsheng Hou <xiangsheng.hou@mediatek.com>
Date: Thu, 6 Jun 2019 16:29:04 +0800
Subject: [PATCH] spi: spi-mem: Mediatek: Add SPI Nand support for MT7629

Signed-off-by: Xiangsheng Hou <xiangsheng.hou@mediatek.com>
---
 arch/arm/boot/dts/mt7629-rfb.dts | 45 ++++++++++++++++++++++++++++++++
 arch/arm/boot/dts/mt7629.dtsi    | 22 ++++++++++++++++
 drivers/spi/spi-mtk-snfi.c       | 12 +++++++++
 3 files changed, 79 insertions(+)

--- a/arch/arm/boot/dts/mt7629.dtsi
+++ b/arch/arm/boot/dts/mt7629.dtsi
@@ -259,6 +259,28 @@
 			status = "disabled";
 		};
 
+		bch: ecc@1100e000 {
+			compatible = "mediatek,mt7622-ecc";
+			reg = <0x1100e000 0x1000>;
+			interrupts = <GIC_SPI 95 IRQ_TYPE_LEVEL_LOW>;
+			clocks = <&pericfg CLK_PERI_NFIECC_PD>;
+			clock-names = "nfiecc_clk";
+			status = "disabled";
+		};
+
+		snfi: spi@1100d000 {
+			compatible = "mediatek,mt7629-snfi";
+			reg = <0x1100d000 0x1000>;
+			interrupts = <GIC_SPI 96 IRQ_TYPE_LEVEL_LOW>;
+			clocks = <&pericfg CLK_PERI_NFI_PD>,
+				 <&pericfg CLK_PERI_SNFI_PD>;
+			clock-names = "nfi_clk", "spi_clk";
+			ecc-engine = <&bch>;
+			#address-cells = <1>;
+			#size-cells = <0>;
+			status = "disabled";
+		};
+
 		spi: spi@1100a000 {
 			compatible = "mediatek,mt7629-spi",
 				     "mediatek,mt7622-spi";
--- a/drivers/spi/spi-mtk-snfi.c
+++ b/drivers/spi/spi-mtk-snfi.c
@@ -1029,8 +1029,20 @@ static const struct mtk_snfi_caps snfi_m
 	.bad_mark_swap = 0,
 };
 
+static const struct mtk_snfi_caps snfi_mt7629 = {
+	.spare_size = spare_size_mt7622,
+	.num_spare_size = 4,
+	.nand_sec_size = 512,
+	.nand_fdm_size = 8,
+	.nand_fdm_ecc_size = 1,
+	.ecc_parity_bits = 13,
+	.pageformat_spare_shift = 4,
+	.bad_mark_swap = 1,
+};
+
 static const struct of_device_id mtk_snfi_id_table[] = {
 	{ .compatible = "mediatek,mt7622-snfi", .data = &snfi_mt7622, },
+	{ .compatible = "mediatek,mt7629-snfi", .data = &snfi_mt7629, },
 	{  /* sentinel */ }
 };
 
--- a/arch/arm/boot/dts/mt7629-rfb.dts
+++ b/arch/arm/boot/dts/mt7629-rfb.dts
@@ -281,6 +281,52 @@
 	};
 };
 
+&bch {
+	status = "okay";
+};
+
+&snfi {
+	pinctrl-names = "default";
+	pinctrl-0 = <&serial_nand_pins>;
+	status = "okay";
+
+	spi_nand@0 {
+		#address-cells = <1>;
+		#size-cells = <1>;
+		compatible = "spi-nand";
+		spi-max-frequency = <104000000>;
+		reg = <0>;
+
+		partitions {
+		compatible = "fixed-partitions";
+		#address-cells = <1>;
+		#size-cells = <1>;
+
+		partition@0 {
+			label = "Bootloader";
+			reg = <0x00000 0x0100000>;
+			read-only;
+		};
+
+		partition@100000 {
+			label = "Config";
+			reg = <0x100000 0x0040000>;
+		};
+
+		partition@140000 {
+			label = "factory";
+			reg = <0x140000 0x0080000>;
+		};
+
+		partition@1c0000 {
+			label = "firmware";
+			reg = <0x1c0000 0x1000000>;
+		};
+
+		};
+	};
+};
+
 &spi {
 	pinctrl-names = "default";
 	pinctrl-0 = <&spi_pins>;