Add MediaTek MT7986 SPI NAND and ECC support
Subsystems (6)
v2 cover Add MediaTek MT7986 SPI NAND and ECC support
This patch series add MediaTek MT7986 SPI NAND and ECC controller support, split ECC engine with rawnand controller in bindings and hange to YAML schema.
Changes since V1:
- Use existing sample delay property.
- Add restricting for optional nfi_hclk.
- Improve and perfect dt-bindings documentation.
- Change existing node name to match NAND controller DT bingings.
- Fix issues reported by dt_binding_check.
- Fix issues reported by dtbs_check.
Xiangsheng Hou (9):
spi: mtk-snfi: Add snfi support for MT7986 IC
spi: mtk-snfi: Change default page format to setup default setting
spi: mtk-snfi: Add optional nfi_hclk which needed for MT7986
mtd: nand: ecc-mtk: Add ECC support fot MT7986 IC
dt-bindings: spi: mtk-snfi: Add compatible for MT7986
spi: mtk-snfi: Add snfi sample delay and read latency adjustment
dt-bindings: spi: mtk-snfi: Add read latch latency property
dt-bindings: mtd: Split ECC engine with rawnand controller
dt-bindings: mtd: ecc-mtk: Add compatible for MT7986
.../bindings/mtd/mediatek,mtk-nfc.yaml | 171 +++++++++++++++++ .../mtd/mediatek,nand-ecc-engine.yaml | 63 +++++++ .../devicetree/bindings/mtd/mtk-nand.txt | 176 ------------------ .../bindings/spi/mediatek,spi-mtk-snfi.yaml | 58 +++++- arch/arm/boot/dts/mt2701.dtsi | 2 +- arch/arm64/boot/dts/mediatek/mt2712e.dtsi | 2 +- arch/arm64/boot/dts/mediatek/mt7622.dtsi | 2 +- drivers/mtd/nand/ecc-mtk.c | 18 ++ drivers/spi/spi-mtk-snfi.c | 66 ++++++- 9 files changed, 366 insertions(+), 192 deletions(-) create mode 100644 Documentation/devicetree/bindings/mtd/mediatek,mtk-nfc.yaml create mode 100644 Documentation/devicetree/bindings/mtd/mediatek,nand-ecc-engine.yaml delete mode 100644 Documentation/devicetree/bindings/mtd/mtk-nand.txt
Signature · 1 line
2.25.1
PATCH v2 1/9 spi: mtk-snfi: Add snfi support for MT7986 IC
Add snfi support for MT7986 IC.
--- drivers/spi/spi-mtk-snfi.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-)
drivers/spi/spi-mtk-snfi.c +27 -2
@@ -126,7 +126,8 @@#define STR_DATA BIT(0)#define NFI_STA 0x060 -#define NFI_NAND_FSM GENMASK(28, 24) +#define NFI_NAND_FSM_7622 GENMASK(28, 24) +#define NFI_NAND_FSM_7986 GENMASK(29, 23)#define NFI_FSM GENMASK(19, 16)#define READ_EMPTY BIT(12)
@@ -158,6 +159,7 @@#define MAS_WR GENMASK(5, 3)#define MAS_RDDLY GENMASK(2, 0)#define NFI_MASTERSTA_MASK_7622 (MAS_ADDR | MAS_RD | MAS_WR | MAS_RDDLY) +#define NFI_MASTERSTA_MASK_7986 3// SNFI registers #define SNF_MAC_CTL 0x500
@@ -220,6 +222,11 @@static const u8 mt7622_spare_sizes[] = {16 ,26 ,27 ,28 }; +static const u8 mt7986_spare_sizes[] = { +16 ,26 ,27 ,28 ,32 ,36 ,40 ,44 ,48 ,49 ,50 ,51 ,52 ,62 ,61 ,63 ,64 ,67 , +74 +}; +struct mtk_snand_caps {u16 sector_size;u16 max_sectors;
@@ -230,6 +237,7 @@ struct mtk_snand_caps {bool bbm_swap;bool empty_page_check;u32 mastersta_mask; +u32 nandfsm_mask;const u8 *spare_sizes;u32 num_spare_size;
@@ -244,6 +252,7 @@ static const struct mtk_snand_caps mt7622_snand_caps = { .bbm_swap = false, .empty_page_check = false, .mastersta_mask = NFI_MASTERSTA_MASK_7622, + .nandfsm_mask = NFI_NAND_FSM_7622, .spare_sizes = mt7622_spare_sizes, .num_spare_size = ARRAY_SIZE(mt7622_spare_sizes) };
@@ -257,10 +266,25 @@ static const struct mtk_snand_caps mt7629_snand_caps = { .bbm_swap = true, .empty_page_check = false, .mastersta_mask = NFI_MASTERSTA_MASK_7622, + .nandfsm_mask = NFI_NAND_FSM_7622, .spare_sizes = mt7622_spare_sizes, .num_spare_size = ARRAY_SIZE(mt7622_spare_sizes) }; +static const struct mtk_snand_caps mt7986_snand_caps = { + .sector_size =1024 , + .max_sectors =8 , + .fdm_size =8 , + .fdm_ecc_size =1 , + .fifo_size =64 , + .bbm_swap = true, + .empty_page_check = true, + .mastersta_mask =NFI_MASTERSTA_MASK_7986 , + .nandfsm_mask =NFI_NAND_FSM_7986 , + .spare_sizes = mt7986_spare_sizes, + .num_spare_size =ARRAY_SIZE (mt7986_spare_sizes) +}; +struct mtk_snand_conf {size_t page_size;size_t oob_size;
@@ -360,7 +384,7 @@ static int mtk_nfi_reset(struct mtk_snand *snf) } ret =readl_poll_timeout (snf->nfi_base +NFI_STA , val, - !(val & (NFI_FSM |NFI_NAND_FSM )),0 , + !(val & (NFI_FSM | snf->caps->nandfsm_mask)),0 ,SNFI_POLL_INTERVAL );if (ret) {dev_err (snf->dev,"Failed to reset NFI\n" );
@@ -1295,6 +1319,7 @@ static irqreturn_t mtk_snand_irq(int irq, void *id)static const struct of_device_id mtk_snand_ids[] = { { .compatible ="mediatek,mt7622-snand" , .data = &mt7622_snand_caps }, { .compatible ="mediatek,mt7629-snand" , .data = &mt7629_snand_caps }, + { .compatible ="mediatek,mt7986-snand" , .data = &mt7986_snand_caps }, {}, };
Signature · 1 line
2.25.1
Re: [PATCH v2 1/9] spi: mtk-snfi: Add snfi support for MT7986 IC
Il 05/12/22 07:57, Xiangsheng Hou ha scritto:
Quoted 3 lines
Add snfi support for MT7986 IC.
Signed-off-by Xiangsheng Hou <[email protected]>
PATCH v2 2/9 spi: mtk-snfi: Change default page format to setup default setting
In reply to Xiangsheng HouChange default page format to setup default setting since the sector size 1024 on MT7986 will lead to probe fail.
--- drivers/spi/spi-mtk-snfi.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/spi/spi-mtk-snfi.c +1 -2
@@ -1430,8 +1430,7 @@ static int mtk_snand_probe(struct platform_device *pdev)// setup an initial page format for ops matching page_cache_op template // before ECC is called. - ret =mtk_snand_setup_pagefmt (ms, ms->caps->sector_size, - ms->caps->spare_sizes[0 ]); + ret =mtk_snand_setup_pagefmt (ms,SZ_2K ,SZ_64 );if (ret) {dev_err (ms->dev,"failed to set initial page format\n" ); goto disable_clk;
Signature · 1 line
2.25.1
PATCH v2 3/9 spi: mtk-snfi: Add optional nfi_hclk which needed for MT7986
In reply to Xiangsheng HouAdd optional nfi_hclk which needed for MT7986.
--- drivers/spi/spi-mtk-snfi.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
drivers/spi/spi-mtk-snfi.c +18 -0
@@ -297,6 +297,7 @@ struct mtk_snand {struct device *dev;struct clk *nfi_clk;struct clk *pad_clk; +struct clk *nfi_hclk;void __iomem *nfi_base;int irq;struct completion op_done;
@@ -1339,7 +1340,16 @@ static int mtk_snand_enable_clk(struct mtk_snand *ms)dev_err (ms->dev,"unable to enable pad clk\n" ); goto err1; } + ret =clk_prepare_enable (ms->nfi_hclk); +if (ret) { +dev_err (ms->dev,"unable to enable nfi hclk\n" ); + goto err2; + } +return 0 ; + +err2: +clk_disable_unprepare (ms->pad_clk); err1:clk_disable_unprepare (ms->nfi_clk);return ret;
@@ -1347,6 +1357,7 @@ static int mtk_snand_enable_clk(struct mtk_snand *ms)static void mtk_snand_disable_clk (struct mtk_snand *ms) { +clk_disable_unprepare (ms->nfi_hclk);clk_disable_unprepare (ms->pad_clk);clk_disable_unprepare (ms->nfi_clk); }
@@ -1401,6 +1412,13 @@ static int mtk_snand_probe(struct platform_device *pdev) goto release_ecc; } + ms->nfi_hclk =devm_clk_get_optional (&pdev->dev,"nfi_hclk" ); +if (IS_ERR (ms->nfi_hclk)) { + ret =PTR_ERR (ms->nfi_hclk); +dev_err (&pdev->dev,"unable to get nfi_hclk, err = %d\n" , ret); + goto release_ecc; + } + ret =mtk_snand_enable_clk (ms);if (ret) goto release_ecc;
Signature · 1 line
2.25.1
AngeloGioacchino Del Regno
maintainerRe: [PATCH v2 3/9] spi: mtk-snfi: Add optional nfi_hclk which needed for MT7986
Il 05/12/22 07:57, Xiangsheng Hou ha scritto:
Quoted 3 lines
Add optional
nfi_hclkwhich needed for MT7986.Signed-off-by Xiangsheng Hou <[email protected]>
Is there any operation for which you need NFI_HCLK enabled, but at the same time PAD_CLK and/or NFI_CLK can be disabled?
If NFI_HCLK and NFI_CLK must always be ON at the same time, adding this clock to spi-mtk-snfi.c is *not* an optimal way of doing things: you can, at this point, set NFI_HCLK as parent of NFI_CLK in the MT7986 clock driver instead, without making any addition to this driver at all.
Regards,
Angelo
Re: [PATCH v2 3/9] spi: mtk-snfi: Add optional nfi_hclk which needed for MT7986
Hi Angelo,
Quoted 8 lines · AngeloGioacchino Del Regno
Il 05/12/22 07:57, Xiangsheng Hou ha scritto:
Quoted 3 lines
Add optional
nfi_hclkwhich needed for MT7986.Signed-off-by Xiangsheng Hou <[email protected]>Is there any operation for which you need
NFI_HCLKenabled, but at the same timePAD_CLKand/orNFI_CLKcan be disabled?
No, for the new IP design on MT7986, will need the PAD_CLK/NFI_CLK/NFI_HCLK enabled at the same time.
Quoted 7 lines
If
NFI_HCLKandNFI_CLKmust always be ON at the same time, adding this clock tospi-mtk-snfi.cis *not* an optimal way of doing things: you can, at this point,
setNFI_HCLKas parent ofNFI_CLKin the MT7986 clock driver instead, without
making any addition to this driver at all.
For some IC, there may have only NFI_CLK/PAD_CLK, and have no NFI_HCLK, this rely on IC design.
Thanks
Xiangsheng Hou
Re: [PATCH v2 3/9] spi: mtk-snfi: Add optional nfi_hclk which needed for MT7986
Il 07/12/22 02:42, Xiangsheng Hou (侯祥胜) ha scritto:
Quoted 23 lines
Hi Angelo,
Quoted 8 lines · AngeloGioacchino Del Regno
Il 05/12/22 07:57, Xiangsheng Hou ha scritto:
Quoted 3 lines
Add optional
nfi_hclkwhich needed for MT7986.Signed-off-by Xiangsheng Hou <[email protected]>Is there any operation for which you need
NFI_HCLKenabled, but at the same timePAD_CLKand/orNFI_CLKcan be disabled?No, for the new IP design on MT7986, will need the PAD_CLK/NFI_CLK/NFI_HCLK enabled at the same time.
Quoted 7 lines
If
NFI_HCLKandNFI_CLKmust always be ON at the same time, adding this clock tospi-mtk-snfi.cis *not* an optimal way of doing things: you can, at this point,
setNFI_HCLKas parent ofNFI_CLKin the MT7986 clock driver instead, without
making any addition to this driver at all.
Quoted 3 lines
For some IC, there may have only NFI_CLK/PAD_CLK, and have no
NFI_HCLK, this rely on IC design.
I've just checked clk-mt7986-infracfg and we can't reparent NFI1_CK, nor SPINFI1_CK as they have xxxx_sel parents already, which are not common with the HCK.
You're right, the addition of the nfi_hclk clock is needed, which means that for this commit, you get my
P.S.: Thanks for clarifying!
Regards,
Angelo
PATCH v2 4/9 mtd: nand: ecc-mtk: Add ECC support fot MT7986 IC
In reply to Xiangsheng HouAdd ECC support fot MT7986 IC.
--- drivers/mtd/nand/ecc-mtk.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
drivers/mtd/nand/ecc-mtk.c +18 -0
@@ -79,6 +79,10 @@ static const u8 ecc_strength_mt7622[] = {4 ,6 ,8 ,10 ,12 }; +static const u8 ecc_strength_mt7986[] = { +4 ,6 ,8 ,10 ,12 ,14 ,16 ,18 ,20 ,22 ,24 +}; +enum mtk_ecc_regs {ECC_ENCPAR00 , ECC_ENCIRQ_EN,
@@ -483,6 +487,17 @@ static const struct mtk_ecc_caps mtk_ecc_caps_mt7622 = { .pg_irq_sel = 0, }; +static const struct mtk_ecc_caps mtk_ecc_caps_mt7986 = { + .err_mask =0x1f , + .err_shift =8 , + .ecc_strength = ecc_strength_mt7986, + .ecc_regs = mt2712_ecc_regs, + .num_ecc_strength =11 , + .ecc_mode_shift =5 , + .parity_bits =14 , + .pg_irq_sel =1 , +}; +static const struct of_device_id mtk_ecc_dt_match[] = { { .compatible ="mediatek,mt2701-ecc" ,
@@ -493,6 +508,9 @@ static const struct of_device_id mtk_ecc_dt_match[] = { }, { .compatible = "mediatek,mt7622-ecc", .data = &mtk_ecc_caps_mt7622, + }, { + .compatible = "mediatek,mt7986-ecc", + .data = &mtk_ecc_caps_mt7986, }, {}, };
Signature · 1 line
2.25.1
AngeloGioacchino Del Regno
maintainerRe: [PATCH v2 4/9] mtd: nand: ecc-mtk: Add ECC support fot MT7986 IC
Il 05/12/22 07:57, Xiangsheng Hou ha scritto:
Quoted 23 lines
Add ECC support fot MT7986 IC.
Signed-off-by Xiangsheng Hou <[email protected]>--- drivers/mtd/nand/ecc-mtk.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)drivers/mtd/nand/ecc-mtk.c +4
-0@@ -79,6 +79,10 @@ static const u8 ecc_strength_mt7622[] = {4 ,6 ,8 ,10 ,12 }; +static const u8 ecc_strength_mt7986[] = { +4 ,6 ,8 ,10 ,12 ,14 ,16 ,18 ,20 ,22 ,24 +}; +enum mtk_ecc_regs {ECC_ENCPAR00 , ECC_ENCIRQ_EN,
drivers/mtd/nand/ecc-mtk.c static const struct mtk_ecc_caps mtk_ecc_caps_mt7622 = { · line 491
Quoted 5 lines
drivers/mtd/nand/ecc-mtk.c +2
-0@@ -483,6 +487,17 @@ static const struct mtk_ecc_caps mtk_ecc_caps_mt7622 = { .pg_irq_sel = 0, }; +static const struct mtk_ecc_caps mtk_ecc_caps_mt7986 = { + .err_mask =0x1f ,
Can't we use GENMASK() to define err_mask instead?
#define MT7986_ERRNUM GENMASK(4, 0)
P.S.: Did I get that right? Is that referred to the ERRNUM(x) bits?
Regards,
Angelo
Re: [PATCH v2 4/9] mtd: nand: ecc-mtk: Add ECC support fot MT7986 IC
Hi Angelo,
Quoted 29 lines · AngeloGioacchino Del Regno
Il 05/12/22 07:57, Xiangsheng Hou ha scritto:
Quoted 28 lines
Add ECC support fot MT7986 IC.
Signed-off-by Xiangsheng Hou <[email protected]>--- drivers/mtd/nand/ecc-mtk.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)drivers/mtd/nand/ecc- renamed from drivers/mtd/nand/ecc-mtk.c +0
-0
mtk.c
index9f9b201fe706..c2f6cfa76a04100644drivers/mtd/nand/ecc-mtk.c +4
-0@@ -79,6 +79,10 @@ static const u8 ecc_strength_mt7622[] = {4 ,6 ,8 ,10 ,12 }; +static const u8 ecc_strength_mt7986[] = { +4 ,6 ,8 ,10 ,12 ,14 ,16 ,18 ,20 ,22 ,24 +}; +enum mtk_ecc_regs {ECC_ENCPAR00 , ECC_ENCIRQ_EN,@@ -483,6 +487,17 @@ static const struct mtk_ecc_caps mtk_ecc_caps_mt7622 = { .pg_irq_sel = 0, };
Quoted 8 lines
drivers/mtd/nand/ecc-mtk.c static const struct mtk_ecc_caps mtk_ecc_caps_mt7622 = { · line 491
Quoted 2 lines
drivers/mtd/nand/ecc-mtk.c +2
-0+static const struct mtk_ecc_caps mtk_ecc_caps_mt7986 = { + .err_mask =0x1f ,Can't we use
GENMASK()to defineerr_maskinstead?#define
MT7986_ERRNUMGENMASK(4, 0)
P.S.: Did I get that right? Is that referred to the ERRNUM(x) bits
Yes, you are right.
I will change like
#define ECC_ERRMASK(x) GENMASK(x, 0),
since other IC driver data will use 0x3f and 0x7f err_mask.
Thanks
Xiangsheng Hou
AngeloGioacchino Del Regno
maintainerRe: [PATCH v2 4/9] mtd: nand: ecc-mtk: Add ECC support fot MT7986 IC
Il 06/12/22 10:04, Xiangsheng Hou (侯祥胜) ha scritto:
Quoted 37 lines
Hi Angelo,
Quoted 34 lines · AngeloGioacchino Del Regno
Il 05/12/22 07:57, Xiangsheng Hou ha scritto:
Quoted 24 lines
Add ECC support fot MT7986 IC.
Signed-off-by Xiangsheng Hou <[email protected]>--- drivers/mtd/nand/ecc-mtk.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)drivers/mtd/nand/ecc- renamed from drivers/mtd/nand/ecc-mtk.c +0
-0
mtk.c
index9f9b201fe706..c2f6cfa76a04100644drivers/mtd/nand/ecc-mtk.c +4
-0@@ -79,6 +79,10 @@ static const u8 ecc_strength_mt7622[] = {4 ,6 ,8 ,10 ,12 }; +static const u8 ecc_strength_mt7986[] = { +4 ,6 ,8 ,10 ,12 ,14 ,16 ,18 ,20 ,22 ,24 +}; +enum mtk_ecc_regs {ECC_ENCPAR00 , ECC_ENCIRQ_EN,drivers/mtd/nand/ecc-mtk.c static const struct mtk_ecc_caps · line 492
Quoted 6 lines
drivers/mtd/nand/ecc-mtk.c +2
-0@@ -483,6 +487,17 @@ static const struct mtk_ecc_caps mtk_ecc_caps_mt7622 = { .pg_irq_sel = 0, }; +static const struct mtk_ecc_caps mtk_ecc_caps_mt7986 = { + .err_mask =0x1f ,Can't we use
GENMASK()to defineerr_maskinstead?
Quoted 9 lines
Quoted 3 lines
#define
MT7986_ERRNUMGENMASK(4, 0)
P.S.: Did I get that right? Is that referred to the ERRNUM(x) bitsYes, you are right.
I will change like
#defineECC_ERRMASK(x)GENMASK(x, 0),
since other IC driver data will use0x3fand0x7ferr_mask.
I would prefer, instead, something like
#define MT7986_ERRNUM GENMASK(....)
#define MT7622_ERRNUM GENMASK(....)
#define MT.... (etc)
instead of a macro calling another macro.
Regards,
Angelo
Re: [PATCH v2 4/9] mtd: nand: ecc-mtk: Add ECC support fot MT7986 IC
Quoted 50 lines · AngeloGioacchino Del Regno
Il 06/12/22 10:04, Xiangsheng Hou (侯祥胜) ha scritto:
Quoted 40 lines
Hi Angelo,
Quoted 36 lines · AngeloGioacchino Del Regno
Il 05/12/22 07:57, Xiangsheng Hou ha scritto:
Quoted 24 lines
Add ECC support fot MT7986 IC.
Signed-off-by Xiangsheng Hou <[email protected]>--- drivers/mtd/nand/ecc-mtk.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)drivers/mtd/nand/ecc- renamed from drivers/mtd/nand/ecc-mtk.c +0
-0
mtk.c
index9f9b201fe706..c2f6cfa76a04100644drivers/mtd/nand/ecc-mtk.c +4
-0@@ -79,6 +79,10 @@ static const u8 ecc_strength_mt7622[] = {4 ,6 ,8 ,10 ,12 }; +static const u8 ecc_strength_mt7986[] = { +4 ,6 ,8 ,10 ,12 ,14 ,16 ,18 ,20 ,22 ,24 +}; +enum mtk_ecc_regs {ECC_ENCPAR00 , ECC_ENCIRQ_EN,drivers/mtd/nand/ecc-mtk.c static const struct mtk_ecc_caps · line 492
Quoted 6 lines
drivers/mtd/nand/ecc-mtk.c +2
-0@@ -483,6 +487,17 @@ static const struct mtk_ecc_caps mtk_ecc_caps_mt7622 = { .pg_irq_sel = 0, }; +static const struct mtk_ecc_caps mtk_ecc_caps_mt7986 = { + .err_mask =0x1f ,Can't we use
GENMASK()to defineerr_maskinstead?#define
MT7986_ERRNUMGENMASK(4, 0)Quoted 8 lines
Quoted 2 lines
P.S.: Did I get that right? Is that referred to the ERRNUM(x) bitsYes, you are right.
I will change like
#defineECC_ERRMASK(x)GENMASK(x, 0),
since other IC driver data will use0x3fand0x7ferr_mask.
Quoted 7 lines
I would prefer, instead, something like
#define
MT7986_ERRNUMGENMASK(....)
#defineMT7622_ERRNUMGENMASK(....)
#define MT.... (etc)instead of a macro calling another macro.
Will do.
Thanks
Xiangsheng Hou
PATCH v2 5/9 dt-bindings: spi: mtk-snfi: Add compatible for MT7986
In reply to Xiangsheng Hou1. Add dt-bindings documentation of SPI NAND controller for MediaTek MT7986 SoC platform.
2. Add optional nfi_hclk property which needed for MT7986.
--- .../bindings/spi/mediatek,spi-mtk-snfi.yaml | 51 +++++++++++++++---- 1 file changed, 42 insertions(+), 9 deletions(-)
Documentation/devicetree/bindings/spi/mediatek,spi-mtk-snfi.yaml +42 -9
@@ -18,14 +18,12 @@ description: | using the accompanying ECC engine. There should be only one spi slave device following generic spi bindings. -allOf: - - $ref: /schemas/spi/spi-controller.yaml# - properties: compatible: enum: - mediatek,mt7622-snand - mediatek,mt7629-snand + - mediatek,mt7986-snand reg: items:
@@ -36,14 +34,12 @@ properties: - description: NFI interrupt clocks: - items: - - description: clock used for the controller - - description: clock used for the SPI bus + minItems: 2 + maxItems: 3 clock-names: - items: - - const: nfi_clk - - const: pad_clk + minItems: 2 + maxItems: 3 nand-ecc-engine: description: device-tree node of the accompanying ECC engine.
@@ -57,6 +53,43 @@ required: - clock-names - nand-ecc-engine +allOf: + - $ref: /schemas/spi/spi-controller.yaml# + - if: + properties: + compatible: + enum: + - mediatek,mt7622-snand + - mediatek,mt7629-snand + then: + properties: + clocks: + items: + - description: clock used for the controller + - description: clock used for the SPI bus + clock-names: + items: + - const: nfi_clk + - const: pad_clk + + - if: + properties: + compatible: + enum: + - mediatek,mt7986-snand + then: + properties: + clocks: + items: + - description: clock used for the controller + - description: clock used for the SPI bus + - description: clock used for the AHB bus + clock-names: + items: + - const: nfi_clk + - const: pad_clk + - const: nfi_hclk + unevaluatedProperties: false examples:
Signature · 1 line
2.25.1
Re: [PATCH v2 5/9] dt-bindings: spi: mtk-snfi: Add compatible for MT7986
Quoted 6 lines · Xiangsheng Hou
1. Add dt-bindings documentation of SPI NAND controller for MediaTek MT7986 SoC platform.
2. Add optionalnfi_hclkproperty which needed for MT7986.Signed-off-by Xiangsheng Hou <[email protected]>---
Best regards,
Krzysztof
PATCH v2 6/9 spi: mtk-snfi: Add snfi sample delay and read latency adjustment
In reply to Xiangsheng HouAdd snfi sample delay and read latency adjustment which can get from dts property.
--- drivers/spi/spi-mtk-snfi.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
drivers/spi/spi-mtk-snfi.c +16 -0
@@ -195,6 +195,8 @@#define DATA_READ_MODE_X4 2#define DATA_READ_MODE_DUAL 5#define DATA_READ_MODE_QUAD 6 +#define DATA_READ_LATCH_LAT GENMASK(9, 8) +#define DATA_READ_LATCH_LAT_S 8#define PG_LOAD_CUSTOM_EN BIT(7)#define DATARD_CUSTOM_EN BIT(6)#define CS_DESELECT_CYC_S 0
@@ -205,6 +207,9 @@#define SNF_DLY_CTL3 0x548#define SFCK_SAM_DLY_S 0 +#define SFCK_SAM_DLY GENMASK(5, 0) +#define SFCK_SAM_DLY_TOTAL 9 +#define SFCK_SAM_DLY_RANGE 47#define SNF_STA_CTL1 0x550#define CUS_PG_DONE BIT(28)
@@ -1368,6 +1373,7 @@ static int mtk_snand_probe(struct platform_device *pdev)const struct of_device_id *dev_id;struct spi_controller *ctlr;struct mtk_snand *ms; +u32 val =0 ;int ret; dev_id =of_match_node (mtk_snand_ids, np);
@@ -1446,6 +1452,16 @@ static int mtk_snand_probe(struct platform_device *pdev)// switch to SNFI mode nfi_write32 (ms,SNF_CFG ,SPI_MODE ); + ret =of_property_read_u32 (np,"rx-sample-delay-ns" , &val); +if (!ret) +nfi_rmw32 (ms,SNF_DLY_CTL3 ,SFCK_SAM_DLY , + val *SFCK_SAM_DLY_RANGE /SFCK_SAM_DLY_TOTAL ); + + ret =of_property_read_u32 (np,"mediatek,rx-latch-latency" , &val); +if (!ret) +nfi_rmw32 (ms,SNF_MISC_CTL ,DATA_READ_LATCH_LAT , + val <<DATA_READ_LATCH_LAT_S ); +// setup an initial page format for ops matching page_cache_op template // before ECC is called. ret =mtk_snand_setup_pagefmt (ms,SZ_2K ,SZ_64 );
Signature · 1 line
2.25.1
Re: [PATCH v2 6/9] spi: mtk-snfi: Add snfi sample delay and read latency adjustment
Il 05/12/22 07:57, Xiangsheng Hou ha scritto:
Quoted 4 lines
Add snfi sample delay and read latency adjustment which can get from dts property.
Signed-off-by Xiangsheng Hou <[email protected]>
PATCH v2 7/9 dt-bindings: spi: mtk-snfi: Add read latch latency property
In reply to Xiangsheng HouAdd mediatek,rx-latch-latency property which adjust read delay in the unit of clock cycle.
--- .../devicetree/bindings/spi/mediatek,spi-mtk-snfi.yaml | 7 +++++++ 1 file changed, 7 insertions(+)
Documentation/devicetree/bindings/spi/mediatek,spi-mtk-snfi.yaml +7 -0
@@ -45,6 +45,13 @@ properties: description: device-tree node of the accompanying ECC engine. $ref: /schemas/types.yaml#/definitions/phandle + mediatek,rx-latch-latency: + description: Rx delay to sample data with this value, the value + unit is clock cycle. + $ref: /schemas/types.yaml#/definitions/uint32 + enum: [0, 1, 2, 3] + default: 0 + required: - compatible - reg
Signature · 1 line
2.25.1
Re: [PATCH v2 7/9] dt-bindings: spi: mtk-snfi: Add read latch latency property
Quoted 4 lines · Xiangsheng Hou
Add mediatek,rx-latch-latency property which adjust read delay in the unit of clock cycle.
Signed-off-by Xiangsheng Hou <[email protected]>
Best regards,
Krzysztof
AngeloGioacchino Del Regno
maintainerRe: [PATCH v2 7/9] dt-bindings: spi: mtk-snfi: Add read latch latency property
In reply to Xiangsheng HouIl 05/12/22 07:57, Xiangsheng Hou ha scritto:
Quoted 14 lines
Add mediatek,rx-latch-latency property which adjust read delay in the unit of clock cycle.
Signed-off-by Xiangsheng Hou <[email protected]>--- .../devicetree/bindings/spi/mediatek,spi-mtk-snfi.yaml | 7 +++++++ 1 file changed, 7 insertions(+)Documentation/devicetree/bindings/spi/mediatek,spi-mtk-snfi.yaml +0
-0
Documentation/devicetree/bindings/spi/mediatek,spi-mtk-snfi.yaml properties: · line 50
Quoted 6 lines
Documentation/devicetree/bindings/spi/mediatek,spi-mtk-snfi.yaml +3
-0@@ -45,6 +45,13 @@ properties: description: device-tree node of the accompanying ECC engine. $ref: /schemas/types.yaml#/definitions/phandle + mediatek,rx-latch-latency: + description: Rx delay to sample data with this value, the value + unit is clock cycle.
Can't we use nanoseconds or microseconds as a unit here, instead of clock cycles?
Regards,
Angelo
Re: [PATCH v2 7/9] dt-bindings: spi: mtk-snfi: Add read latch latency property
Hi Angelo,
Quoted 24 lines · AngeloGioacchino Del Regno
Il 05/12/22 07:57, Xiangsheng Hou ha scritto:
Quoted 23 lines
Add mediatek,rx-latch-latency property which adjust read delay in the
unit of clock cycle.Signed-off-by Xiangsheng Hou <[email protected]>--- .../devicetree/bindings/spi/mediatek,spi-mtk-snfi.yaml | 7 +++++++ 1 file changed, 7 insertions(+)(quoted diff) +0
-0
mtk-snfi.yamlb/Documentation/devicetree/bindings/spi/mediatek,spi-mtk-snfi.yaml
indexbab23f1b11fd..6e6ff8d73fcd100644
--- a/Documentation/devicetree/bindings/spi/mediatek,spi-mtk-snfi.yaml
+++ b/Documentation/devicetree/bindings/spi/mediatek,spi-mtk-snfi.yamlDocumentation/devicetree/bindings/spi/mediatek,spi-mtk-snfi.yaml +0
-0@@ -45,6 +45,13 @@ properties: description: device-tree node of the accompanying ECC engine. $ref: /schemas/types.yaml#/definitions/phandle
Quoted 7 lines
Quoted 4 lines
(quoted diff) +2
-0+ mediatek,rx-latch-latency: + description: Rx delay to sample data with this value, thevalue
+ unit is clock cycle.Can't we use nanoseconds or microseconds as a unit here, instead of clock cycles?
The clock cycle will be various with MediaTek SPI NAND controller which clock frequency can support 26/52/68/81/104MHz...
It`s may be easy to configure and understand with clock cycle in unit.
Thanks
Xiangsheng Hou
AngeloGioacchino Del Regno
maintainerRe: [PATCH v2 7/9] dt-bindings: spi: mtk-snfi: Add read latch latency property
Il 06/12/22 10:04, Xiangsheng Hou (侯祥胜) ha scritto:
Quoted 35 lines
Hi Angelo,
Quoted 24 lines · AngeloGioacchino Del Regno
Il 05/12/22 07:57, Xiangsheng Hou ha scritto:
Quoted 23 lines
Add mediatek,rx-latch-latency property which adjust read delay in the
unit of clock cycle.Signed-off-by Xiangsheng Hou <[email protected]>--- .../devicetree/bindings/spi/mediatek,spi-mtk-snfi.yaml | 7 +++++++ 1 file changed, 7 insertions(+)(quoted diff) +0
-0
mtk-snfi.yamlb/Documentation/devicetree/bindings/spi/mediatek,spi-mtk-snfi.yaml
indexbab23f1b11fd..6e6ff8d73fcd100644
--- a/Documentation/devicetree/bindings/spi/mediatek,spi-mtk-snfi.yaml
+++ b/Documentation/devicetree/bindings/spi/mediatek,spi-mtk-snfi.yamlDocumentation/devicetree/bindings/spi/mediatek,spi-mtk-snfi.yaml +0
-0@@ -45,6 +45,13 @@ properties: description: device-tree node of the accompanying ECC engine. $ref: /schemas/types.yaml#/definitions/phandleQuoted 7 lines
Quoted 4 lines
(quoted diff) +2
-0+ mediatek,rx-latch-latency: + description: Rx delay to sample data with this value, thevalue
+ unit is clock cycle.Can't we use nanoseconds or microseconds as a unit here, instead of clock cycles?
Quoted 4 lines
The clock cycle will be various with MediaTek SPI NAND controller which clock frequency can support 26/52/68/81/104MHz...
It`s may be easy to configure and understand with clock cycle in unit.
Yes, but whatever clock frequency we use, the target is to always wait for X nanoseconds, right?
Waiting for 5 clock cycles at 104MHz is obviously not the same as waiting for the same 5 clock cycles at 26MHz: in that case, expressing the value in nanoseconds or microseconds would make that independent from the controller's clock frequency as the calculation from time to cycles would be performed inside of the driver.
Regards,
Angelo
Re: [PATCH v2 7/9] dt-bindings: spi: mtk-snfi: Add read latch latency property
Hi Angelo,
Quoted 35 lines · AngeloGioacchino Del Regno
Quoted 24 lines
Quoted 15 lines
Quoted 15 lines
diff --git a/Documentation/devicetree/bindings/spi/mediatek,spi-
mtk-snfi.yamlb/Documentation/devicetree/bindings/spi/mediatek,spi-mtk-snfi.yaml
indexbab23f1b11fd..6e6ff8d73fcd100644
--- a/Documentation/devicetree/bindings/spi/mediatek,spi-mtk-snfi.yaml
+++ b/Documentation/devicetree/bindings/spi/mediatek,spi-mtk-snfi.yaml(quoted diff) +0
-0@@ -45,6 +45,13 @@ properties: description: device-tree node of the accompanying ECCengine.
$ref: /schemas/types.yaml#/definitions/phandleQuoted 8 lines
Quoted 4 lines
(quoted diff) +2
-0+ mediatek,rx-latch-latency: + description: Rx delay to sample data with this value, thevalue
+ unit is clock cycle.Can't we use nanoseconds or microseconds as a unit here, instead of
clock cycles?Quoted 6 lines
The clock cycle will be various with MediaTek SPI NAND controller which
clock frequency can support 26/52/68/81/104MHz...
It`s may be easy to configure and understand with clock cycle in unit.Yes, but whatever clock frequency we use, the target is to always wait for
X nanoseconds, right?
Quoted 8 lines
Waiting for 5 clock cycles at 104MHz is obviously not the same as waiting
for the same 5 clock cycles at 26MHz: in that case, expressing the value
in nanoseconds or microseconds would make that independent from the controller's clock frequency as the calculation fromtimetocycles
would be performed inside of the driver.
There have two rx related timing properties in spi-peripheral-props. The rx-sample-delay-ns have been used in Mediatek snfi driver to adjust controller sample delay.
However another spi-rx-delay-us is in microseconds. Take 52MHz for example, the clock cycle will be 19.23ns which lower than 1us. This may not easy to by one clock cycle.
Thanks
Xiangsheng Hou
AngeloGioacchino Del Regno
maintainerRe: [PATCH v2 7/9] dt-bindings: spi: mtk-snfi: Add read latch latency property
Il 07/12/22 03:00, Xiangsheng Hou (侯祥胜) ha scritto:
Quoted 47 lines
Hi Angelo,
Quoted 35 lines · AngeloGioacchino Del Regno
Quoted 24 lines
Quoted 15 lines
Quoted 15 lines
diff --git a/Documentation/devicetree/bindings/spi/mediatek,spi-
mtk-snfi.yamlb/Documentation/devicetree/bindings/spi/mediatek,spi-mtk-snfi.yaml
indexbab23f1b11fd..6e6ff8d73fcd100644
--- a/Documentation/devicetree/bindings/spi/mediatek,spi-mtk-snfi.yaml
+++ b/Documentation/devicetree/bindings/spi/mediatek,spi-mtk-snfi.yaml(quoted diff) +0
-0@@ -45,6 +45,13 @@ properties: description: device-tree node of the accompanying ECCengine.
$ref: /schemas/types.yaml#/definitions/phandleQuoted 8 lines
Quoted 4 lines
(quoted diff) +2
-0+ mediatek,rx-latch-latency: + description: Rx delay to sample data with this value, thevalue
+ unit is clock cycle.Can't we use nanoseconds or microseconds as a unit here, instead of
clock cycles?Quoted 6 lines
The clock cycle will be various with MediaTek SPI NAND controller which
clock frequency can support 26/52/68/81/104MHz...
It`s may be easy to configure and understand with clock cycle in unit.Yes, but whatever clock frequency we use, the target is to always wait for
X nanoseconds, right?Quoted 8 lines
Waiting for 5 clock cycles at 104MHz is obviously not the same as waiting
for the same 5 clock cycles at 26MHz: in that case, expressing the value
in nanoseconds or microseconds would make that independent from the controller's clock frequency as the calculation fromtimetocycles
would be performed inside of the driver.
Quoted 7 lines
There have two rx related timing properties in spi-peripheral-props. The rx-sample-delay-ns have been used in Mediatek snfi driver to adjust controller sample delay.
However another spi-rx-delay-us is in microseconds. Take 52MHz for example, the clock cycle will be 19.23ns which lower than 1us. This may not easy to by one clock cycle.
I agree, but nothing prevents you from adding your own property for that.
I propose "mediatek,rx-latch-latency-ns" or "mediatek,rx-latency-ns", so that we can specify the delay in nanoseconds: in that case, when we specify 19ns, the driver will safely round that resulting in 52MHz == 19.23ns => 19ns valid.
Regards,
Angelo
Re: [PATCH v2 7/9] dt-bindings: spi: mtk-snfi: Add read latch latency property
Quoted 72 lines · AngeloGioacchino Del Regno
Il 07/12/22 03:00, Xiangsheng Hou (侯祥胜) ha scritto:
Quoted 57 lines
Hi Angelo,
Quoted 42 lines · AngeloGioacchino Del Regno
Quoted 29 lines
Quoted 18 lines
Quoted 18 lines
diff --git a/Documentation/devicetree/bindings/spi/mediatek,spi-
mtk-snfi.yamlb/Documentation/devicetree/bindings/spi/mediatek,spi-mtk-snfi.yaml
indexbab23f1b11fd..6e6ff8d73fcd100644
--- a/Documentation/devicetree/bindings/spi/mediatek,spi- mtk-snfi.yaml
+++ b/Documentation/devicetree/bindings/spi/mediatek,spi- mtk-snfi.yaml(quoted diff) +0
-0@@ -45,6 +45,13 @@ properties: description: device-tree node of the accompanyingECC
engine.
$ref: /schemas/types.yaml#/definitions/phandleQuoted 10 lines
Quoted 5 lines
(quoted diff) +2
-0+ mediatek,rx-latch-latency: + description: Rx delay to sample data with this value,the
value
+ unit is clock cycle.Can't we use nanoseconds or microseconds as a unit here, instead
of
clock cycles?Quoted 8 lines
The clock cycle will be various with MediaTek SPI NAND controller
which
clock frequency can support 26/52/68/81/104MHz... It`s may be easy to configure and understand with clock cycle in
unit.Yes, but whatever clock frequency we use, the target is to always wait for
X nanoseconds, right?Quoted 10 lines
Waiting for 5 clock cycles at 104MHz is obviously not the same as waiting
for the same 5 clock cycles at 26MHz: in that case, expressing the
value
in nanoseconds or microseconds would make that independent from the
controller's clock frequency as the calculation fromtimetocycles
would be performed inside of the driver.Quoted 10 lines
There have two rx related timing properties in spi-peripheral- props.
The rx-sample-delay-ns have been used in Mediatek snfi driver to adjust
controller sample delay.
However another spi-rx-delay-us is in microseconds. Take 52MHz for example, the clock cycle will be 19.23ns which lower than 1us. This may
not easy to by one clock cycle.I agree, but nothing prevents you from adding your own property for that.
Quoted 6 lines
I propose "mediatek,rx-latch-latency-ns" or "mediatek,rx-latency-ns", so that
we can specify the delay in nanoseconds: in that case, when we specify 19ns,
the driver will safely round that resulting in 52MHz == 19.23ns => 19ns valid.
Will be fixed in next series.
Thanks
Xiangsheng Hou
Re: [PATCH v2 7/9] dt-bindings: spi: mtk-snfi: Add read latch latency property
Quoted 15 lines · Xiangsheng Hou (侯祥胜)
Quoted 15 lines
Quoted 11 lines
There have two rx related timing properties in spi-peripheral- props.
The rx-sample-delay-ns have been used in Mediatek snfi driver to adjust
controller sample delay.
However another spi-rx-delay-us is in microseconds. Take 52MHz for example, the clock cycle will be 19.23ns which lower than 1us. This may
not easy to by one clock cycle.I agree, but nothing prevents you from adding your own property for that.
Quoted 8 lines
Quoted 6 lines
I propose "mediatek,rx-latch-latency-ns" or "mediatek,rx-latency-ns", so that
we can specify the delay in nanoseconds: in that case, when we specify 19ns,
the driver will safely round that resulting in 52MHz == 19.23ns => 19ns valid.Will be fixed in next series.
I am fine with this approach, but after explanations I was also fine with clock cycles as unit. It's still quite specific unit and I think several timings on buses are clock-cycle dependent, not time dependent.
Best regards,
Krzysztof
PATCH v2 8/9 dt-bindings: mtd: Split ECC engine with rawnand controller
In reply to Xiangsheng Hou1. Split MediaTek ECC engine with rawnand controller and convert to YAML schema.
2. Change the existing node name in order to match NAND controller DT bindings.
--- .../bindings/mtd/mediatek,mtk-nfc.yaml | 171 +++++++++++++++++ .../mtd/mediatek,nand-ecc-engine.yaml | 62 ++++++ .../devicetree/bindings/mtd/mtk-nand.txt | 176 ------------------ arch/arm/boot/dts/mt2701.dtsi | 2 +- arch/arm64/boot/dts/mediatek/mt2712e.dtsi | 2 +- arch/arm64/boot/dts/mediatek/mt7622.dtsi | 2 +- 6 files changed, 236 insertions(+), 179 deletions(-) create mode 100644 Documentation/devicetree/bindings/mtd/mediatek,mtk-nfc.yaml create mode 100644 Documentation/devicetree/bindings/mtd/mediatek,nand-ecc-engine.yaml delete mode 100644 Documentation/devicetree/bindings/mtd/mtk-nand.txt
Documentation/devicetree/bindings/mtd/mediatek,mtk-nfc.yaml new file +171 -0
@@ -0,0 +1,171 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/mtd/mediatek,mtk-nfc.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: MediaTek(MTK) SoCs raw NAND FLASH controller (NFC) + +maintainers: + - Xiangsheng Hou <[email protected]> + +properties: + compatible: + enum: + - mediatek,mt2701-nfc + - mediatek,mt2712-nfc + - mediatek,mt7622-nfc + + reg: + items: + - description: Base physical address and size of NFI. + + interrupts: + items: + - description: NFI interrupt + + clocks: + items: + - description: clock used for the controller + - description: clock used for the pad + + clock-names: + items: + - const: nfi_clk + - const: pad_clk + + ecc-engine: true + + partitions: + $ref: mtd.yaml# + +allOf: + - $ref: nand-controller.yaml# + + - if: + properties: + compatible: + contains: + const: mediatek,mt2701-nfc + then: + patternProperties: + "^nand@[a-f0-9]$": + type: object + properties: + reg: + minimum: 0 + maximum: 1 + nand-ecc-mode: + const: hw + nand-ecc-step-size: + enum: [ 512, 1024 ] + nand-ecc-strength: + enum: [4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 28, 32, 36, + 40, 44, 48, 52, 56, 60] + + - if: + properties: + compatible: + contains: + const: mediatek,mt2712-nfc + then: + patternProperties: + "^nand@[a-f0-9]$": + type: object + properties: + reg: + minimum: 0 + maximum: 1 + nand-ecc-mode: + const: hw + nand-ecc-step-size: + enum: [ 512, 1024 ] + nand-ecc-strength: + enum: [4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 28, 32, 36, + 40, 44, 48, 52, 56, 60, 68, 72, 80] + + - if: + properties: + compatible: + contains: + const: mediatek,mt7622-nfc + then: + patternProperties: + "^nand@[a-f0-9]$": + type: object + properties: + reg: + minimum: 0 + maximum: 1 + nand-ecc-mode: + const: hw + nand-ecc-step-size: + const: 512 + nand-ecc-strength: + enum: [4, 6, 8, 10, 12] + +required: + - compatible + - reg + - interrupts + - clocks + - clock-names + - ecc-engine + +unevaluatedProperties: false + +examples: + - | + #include <dt-bindings/clock/mt2701-clk.h> + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/interrupt-controller/irq.h> + + soc { + #address-cells = <2>; + #size-cells = <2>; + + nand-controller@1100d000 { + compatible = "mediatek,mt2701-nfc"; + reg = <0 0x1100d000 0 0x1000>; + interrupts = <GIC_SPI 56 IRQ_TYPE_LEVEL_LOW>; + clocks = <&pericfg CLK_PERI_NFI>, + <&pericfg CLK_PERI_NFI_PAD>; + clock-names = "nfi_clk", "pad_clk"; + ecc-engine = <&bch>; + #address-cells = <1>; + #size-cells = <0>; + + nand@0 { + reg = <0>; + + nand-on-flash-bbt; + nand-ecc-mode = "hw"; + nand-ecc-step-size = <1024>; + nand-ecc-strength = <24>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + preloader@0 { + label = "pl"; + read-only; + reg = <0x0 0x400000>; + }; + android@400000 { + label = "android"; + reg = <0x400000 0x12c00000>; + }; + }; + }; + }; + + bch: ecc@1100e000 { + compatible = "mediatek,mt2701-ecc"; + reg = <0 0x1100e000 0 0x1000>; + interrupts = <GIC_SPI 55 IRQ_TYPE_LEVEL_LOW>; + clocks = <&pericfg CLK_PERI_NFI_ECC>; + clock-names = "nfiecc_clk"; + }; + };
Documentation/devicetree/bindings/mtd/mediatek,nand-ecc-engine.yaml new file +62 -0
62 lines not on this page · raw message
Documentation/devicetree/bindings/mtd/mtk-nand.txt deleted +0 -176
176 lines not on this page · raw message
arch/arm/boot/dts/mt2701.dtsi +1 -1
@@ -360,7 +360,7 @@ thermal: thermal@1100b000 { mediatek,apmixedsys = <&apmixedsys>; }; - nandc: nfi@1100d000 { + nandc: nand-controller@1100d000 { compatible = "mediatek,mt2701-nfc"; reg = <0 0x1100d000 0 0x1000>; interrupts = <GIC_SPI 56 IRQ_TYPE_LEVEL_LOW>;
arch/arm64/boot/dts/mediatek/mt2712e.dtsi +1 -1
@@ -560,7 +560,7 @@ spi0: spi@1100a000 { status = "disabled"; }; - nandc: nfi@1100e000 { + nandc: nand-controller@1100e000 { compatible = "mediatek,mt2712-nfc"; reg = <0 0x1100e000 0 0x1000>; interrupts = <GIC_SPI 96 IRQ_TYPE_LEVEL_LOW>;
arch/arm64/boot/dts/mediatek/mt7622.dtsi +1 -1
@@ -539,7 +539,7 @@ bluetooth { }; }; - nandc: nfi@1100d000 { + nandc: nand-controller@1100d000 { compatible = "mediatek,mt7622-nfc"; reg = <0 0x1100D000 0 0x1000>; interrupts = <GIC_SPI 96 IRQ_TYPE_LEVEL_LOW>;
Signature · 1 line
2.25.1
Re: [PATCH v2 8/9] dt-bindings: mtd: Split ECC engine with rawnand controller
Quoted 4 lines · Xiangsheng Hou
1. Split MediaTek ECC engine with rawnand controller and convert to YAML schema.
2. Change the existing node name in order to match NAND controller DT bindings.
One patch - one logical change. Not two. This applies to all your patches, so whenever you want to enumerate, please think twice.
Quoted 9 lines
Signed-off-by Xiangsheng Hou <[email protected]>--- .../bindings/mtd/mediatek,mtk-nfc.yaml | 171 +++++++++++++++++ .../mtd/mediatek,nand-ecc-engine.yaml | 62 ++++++ .../devicetree/bindings/mtd/mtk-nand.txt | 176 ------------------ arch/arm/boot/dts/mt2701.dtsi | 2 +- arch/arm64/boot/dts/mediatek/mt2712e.dtsi | 2 +- arch/arm64/boot/dts/mediatek/mt7622.dtsi | 2 +-
Do not combine bindings and DTS.
Quoted 38 lines
6 files changed, 236 insertions(+), 179 deletions(-) create mode 100644 Documentation/devicetree/bindings/mtd/mediatek,mtk-nfc.yaml create mode 100644 Documentation/devicetree/bindings/mtd/mediatek,nand-ecc-engine.yaml delete mode 100644 Documentation/devicetree/bindings/mtd/mtk-nand.txtDocumentation/devicetree/bindings/mtd/mediatek,mtk-nfc.yaml new file +27
-0@@ -0,0 +1,171 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/mtd/mediatek,mtk-nfc.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: MediaTek(MTK) SoCs raw NAND FLASH controller (NFC) + +maintainers: + - Xiangsheng Hou <[email protected]> + +properties: + compatible: + enum: + - mediatek,mt2701-nfc + - mediatek,mt2712-nfc + - mediatek,mt7622-nfc + + reg: + items: + - description: Base physical address and size of NFI. + + interrupts: + items: + - description: NFI interrupt + + clocks:
Documentation/devicetree/bindings/mtd/mediatek,mtk-nfc.yaml line 37
Quoted 10 lines
Documentation/devicetree/bindings/mtd/mediatek,mtk-nfc.yaml new file +10
-0+ items: + - description: clock used for the controller + - description: clock used for the pad + + clock-names: + items: + - const: nfi_clk + - const: pad_clk + + ecc-engine: true
I don't think this could be anything. You need to describe it, so $ref and description.
Documentation/devicetree/bindings/mtd/mediatek,mtk-nfc.yaml line 40
Quoted 3 lines
Documentation/devicetree/bindings/mtd/mediatek,mtk-nfc.yaml new file +3
-0+ + partitions: + $ref: mtd.yaml#
How the partitions are MTD device? Open that file and see how it should be defined... Anyway mtd.yaml is part of nand-chip, not nand-controller.
Documentation/devicetree/bindings/mtd/mediatek,mtk-nfc.yaml line 53
Quoted 13 lines
Documentation/devicetree/bindings/mtd/mediatek,mtk-nfc.yaml new file +13
-0+ +allOf: + - $ref: nand-controller.yaml# + + - if: + properties: + compatible: + contains: + const: mediatek,mt2701-nfc + then: + patternProperties: + "^nand@[a-f0-9]$": + type: object
No need for type, the definition is already there through nand-controller.yaml.
Documentation/devicetree/bindings/mtd/mediatek,mtk-nfc.yaml line 57
Quoted 4 lines
Documentation/devicetree/bindings/mtd/mediatek,mtk-nfc.yaml new file +4
-0+ properties: + reg: + minimum: 0 + maximum: 1
This is the same as other variant, so should be defined in top-level pattern properties.
Documentation/devicetree/bindings/mtd/mediatek,mtk-nfc.yaml line 59
Quoted 2 lines
Documentation/devicetree/bindings/mtd/mediatek,mtk-nfc.yaml new file +2
-0+ nand-ecc-mode: + const: hw
Ditto
Quoted 99 lines
Documentation/devicetree/bindings/mtd/mediatek,mtk-nfc.yaml new file +99
-0+ nand-ecc-step-size: + enum: [ 512, 1024 ]> + nand-ecc-strength: + enum: [4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 28, 32, 36, + 40, 44, 48, 52, 56, 60] + + - if: + properties: + compatible: + contains: + const: mediatek,mt2712-nfc + then: + patternProperties: + "^nand@[a-f0-9]$": + type: object + properties: + reg: + minimum: 0 + maximum: 1 + nand-ecc-mode: + const: hw + nand-ecc-step-size: + enum: [ 512, 1024 ] + nand-ecc-strength: + enum: [4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 28, 32, 36, + 40, 44, 48, 52, 56, 60, 68, 72, 80] + + - if: + properties: + compatible: + contains: + const: mediatek,mt7622-nfc + then: + patternProperties: + "^nand@[a-f0-9]$": + type: object + properties: + reg: + minimum: 0 + maximum: 1 + nand-ecc-mode: + const: hw + nand-ecc-step-size: + const: 512 + nand-ecc-strength: + enum: [4, 6, 8, 10, 12] + +required: + - compatible + - reg + - interrupts + - clocks + - clock-names + - ecc-engine + +unevaluatedProperties: false + +examples: + - | + #include <dt-bindings/clock/mt2701-clk.h> + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/interrupt-controller/irq.h> + + soc { + #address-cells = <2>; + #size-cells = <2>; + + nand-controller@1100d000 { + compatible = "mediatek,mt2701-nfc"; + reg = <0 0x1100d000 0 0x1000>; + interrupts = <GIC_SPI 56 IRQ_TYPE_LEVEL_LOW>; + clocks = <&pericfg CLK_PERI_NFI>, + <&pericfg CLK_PERI_NFI_PAD>; + clock-names = "nfi_clk", "pad_clk"; + ecc-engine = <&bch>; + #address-cells = <1>; + #size-cells = <0>; + + nand@0 { + reg = <0>; + + nand-on-flash-bbt; + nand-ecc-mode = "hw"; + nand-ecc-step-size = <1024>; + nand-ecc-strength = <24>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + preloader@0 { + label = "pl"; + read-only; + reg = <0x0 0x400000>; + }; + android@400000 { + label = "android"; + reg = <0x400000 0x12c00000>; + };
Documentation/devicetree/bindings/mtd/mediatek,mtk-nfc.yaml line 169
Quoted 10 lines
Documentation/devicetree/bindings/mtd/mediatek,mtk-nfc.yaml new file +10
-0+ }; + }; + }; + + bch: ecc@1100e000 { + compatible = "mediatek,mt2701-ecc"; + reg = <0 0x1100e000 0 0x1000>; + interrupts = <GIC_SPI 55 IRQ_TYPE_LEVEL_LOW>; + clocks = <&pericfg CLK_PERI_NFI_ECC>; + clock-names = "nfiecc_clk";
You already have example of ecc in other binding, so drop from this one.
Documentation/devicetree/bindings/mtd/mediatek,nand-ecc-engine.yaml
Quoted 6 lines
Documentation/devicetree/bindings/mtd/mediatek,mtk-nfc.yaml new file +2
-0+ }; + };Documentation/devicetree/bindings/mtd/mediatek,nand-ecc-engine.yaml new file +0
-1--- /dev/null
Best regards,
Krzysztof
Re: [PATCH v2 8/9] dt-bindings: mtd: Split ECC engine with rawnand controller
Hi Krzysztof,
Quoted 9 lines · Krzysztof Kozlowski
Quoted 5 lines · Xiangsheng Hou
1. Split MediaTek ECC engine with rawnand controller and convert to YAML schema.
2. Change the existing node name in order to match NAND controller DT
bindings.One patch - one logical change. Not two. This applies to all your patches, so whenever you want to enumerate, please think twice.
Will be corrected in next series.
Quoted 13 lines
Quoted 12 lines
Signed-off-by Xiangsheng Hou <[email protected]>--- .../bindings/mtd/mediatek,mtk-nfc.yaml | 171 +++++++++++++++++ .../mtd/mediatek,nand-ecc-engine.yaml | 62 ++++++ .../devicetree/bindings/mtd/mtk-nand.txt | 176 -------------- ---- arch/arm/boot/dts/mt2701.dtsi | 2 +- arch/arm64/boot/dts/mediatek/mt2712e.dtsi | 2 +- arch/arm64/boot/dts/mediatek/mt7622.dtsi | 2 +-
Quoted 1 line
Do not combine bindings and DTS.
The DTS modification will be separated.
Quoted 7 lines
Review
Quoted 3 lines
(quoted diff) +2
-0+ + ecc-engine: trueI don't think this could be anything. You need to describe it, so $ref
and description.
Will do.
Quoted 8 lines
Documentation/devicetree/bindings/mtd/mediatek,mtk-nfc.yaml line 40
Quoted 3 lines
Documentation/devicetree/bindings/mtd/mediatek,mtk-nfc.yaml new file +3
-0+ + partitions: + $ref: mtd.yaml#How the partitions are MTD device? Open that file and see how it should
be defined... Anywaymtd.yamlis part of nand-chip, not nand- controller.
This will be dropped in next series since nand-chip is part of nand- controller.
Quoted 22 lines
Documentation/devicetree/bindings/mtd/mediatek,mtk-nfc.yaml line 53
Quoted 13 lines
Documentation/devicetree/bindings/mtd/mediatek,mtk-nfc.yaml new file +13
-0+ +allOf: + - $ref: nand-controller.yaml# + + - if: + properties: + compatible: + contains: + const: mediatek,mt2701-nfc + then: + patternProperties: + "^nand@[a-f0-9]$": + type: objectNo need for type, the definition is already there through
nand-controller.yaml.Documentation/devicetree/bindings/mtd/mediatek,mtk-nfc.yaml line 57
Quoted 4 lines
Documentation/devicetree/bindings/mtd/mediatek,mtk-nfc.yaml new file +4
-0+ properties: + reg: + minimum: 0 + maximum: 1
Quoted 7 lines
This is the same as other variant, so should be defined in top-level pattern properties.
Review
Quoted 2 lines
(quoted diff) +2
-0+ nand-ecc-mode: + const: hwDitto
Will be fixed in next series.
Thanks
Xiangsheng Hou
PATCH v2 9/9 dt-bindings: mtd: ecc-mtk: Add compatible for MT7986
In reply to Xiangsheng HouAdd dt-bindings documentation of ECC for MediaTek MT7986 SoC platform.
--- .../devicetree/bindings/mtd/mediatek,nand-ecc-engine.yaml | 1 + 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/mtd/mediatek,nand-ecc-engine.yaml +1 -0
@@ -18,6 +18,7 @@ properties: - mediatek,mt2701-ecc - mediatek,mt2712-ecc - mediatek,mt7622-ecc + - mediatek,mt7986-ecc reg: items:
Signature · 1 line
2.25.1
Re: [PATCH v2 9/9] dt-bindings: mtd: ecc-mtk: Add compatible for MT7986
Quoted 3 lines · Xiangsheng Hou
Add dt-bindings documentation of ECC for MediaTek MT7986 SoC platform.
Now your subject prefix does not match file. Filename is "mediatek,nand-ecc-engine." so use it instead of "ecc-mtk".
Best regards,
Krzysztof
Mark Brown
maintainerRe: (subset) [PATCH v2 0/9] Add MediaTek MT7986 SPI NAND and ECC support
In reply to Xiangsheng HouQuoted 12 lines · Xiangsheng Hou
This patch series add MediaTek MT7986 SPI NAND and ECC controller support, split ECC engine with rawnand controller in bindings and hange to YAML schema.
Changes since V1:
- Use existing sample delay property.
- Add restricting for optionalnfi_hclk.
- Improve and perfect dt-bindings documentation.
- Change existing node name to match NAND controller DT bingings.
- Fix issues reported bydt_binding_check.
- Fix issues reported bydtbs_check.
Quoted 1 line
[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next
Thanks!
[1/9] spi: mtk-snfi: Add snfi support for MT7986 IC
commit: 7073888c86601389e17f3ee8ab15ab7aef148839
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark