mtd: rawnand: fsl_elbc: Device tree support
Subsystems (3)
cover mtd: rawnand: fsl_elbc: Device tree support
This patch series adds device tree support for P2020 NAND controller in SW ECC mode.
Pali Rohár (5):
mtd: rawnand: fsl_elbc: Implement RNDOUT command
mtd: rawnand: fsl_elbc: Add device tree support
mtd: rawnand: fsl_elbc: Use ECC configuration from device tree
mtd: nand: raw: Add support for DT property nand-ecc-algo=bch
powerpc: dts: p2020: Add localbus node
arch/powerpc/dts/p2020-post.dtsi | 7 ++ arch/powerpc/dts/p2020rdb-pc.dts | 4 ++ arch/powerpc/dts/p2020rdb-pc_36b.dts | 4 ++ drivers/mtd/nand/raw/Kconfig | 4 ++ drivers/mtd/nand/raw/fsl_elbc_nand.c | 99 +++++++++++++++++++++------- drivers/mtd/nand/raw/nand_base.c | 6 ++ 6 files changed, 99 insertions(+), 25 deletions(-)
Signature · 1 line
2.20.1
PATCH 1/5 mtd: rawnand: fsl_elbc: Implement RNDOUT command
This is needed for SW ECC.
--- drivers/mtd/nand/raw/fsl_elbc_nand.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/mtd/nand/raw/fsl_elbc_nand.c +8 -0
@@ -312,6 +312,14 @@ static void fsl_elbc_cmdfunc(struct mtd_info *mtd, unsigned int command,fsl_elbc_run_command (mtd);return ; +/* RNDOUT moves the pointer inside the page */ +case NAND_CMD_RNDOUT : +vdbg ("fsl_elbc_cmdfunc: NAND_CMD_RNDOUT, column: 0x%x.\n" , + column); + + ctrl->index = column; +return ; +/* READOOB reads only the OOB because no ECC is performed. */ case NAND_CMD_READOOB : vdbg("fsl_elbc_cmdfunc: NAND_CMD_READOOB, page_addr:"
Signature · 1 line
2.20.1
PATCH 2/5 mtd: rawnand: fsl_elbc: Add device tree support
In reply to Pali RohárThis allows boards to specify NAND settings via standard DT properties.
--- drivers/mtd/nand/raw/Kconfig | 4 +++ drivers/mtd/nand/raw/fsl_elbc_nand.c | 42 ++++++++++++++++++++++++++-- 2 files changed, 44 insertions(+), 2 deletions(-)
drivers/mtd/nand/raw/Kconfig +4 -0
@@ -152,6 +152,10 @@ config NAND_FSL_ELBC help Enable the Freescale Enhanced Local Bus Controller FCM NAND driver. +config NAND_FSL_ELBC_DT + bool "Support Freescale Enhanced Local Bus Controller FCM NAND driver (DT mode)" + depends on NAND_FSL_ELBC + config NAND_FSL_IFC bool "Support Freescale Integrated Flash Controller NAND driver" select TPL_SYS_NAND_SELF_INIT if TPL_NAND_SUPPORT
drivers/mtd/nand/raw/fsl_elbc_nand.c +40 -2
70 lines not on this page · raw message
Signature · 1 line
2.20.1
PATCH 3/5 mtd: rawnand: fsl_elbc: Use ECC configuration from device tree
In reply to Pali RohárInitialize ECC configuration after nand_scan_ident() call and only in case nand_scan_ident() have not done it. nand_scan_ident() fills ECC configuration from device tree.
Fixes usage of NAND_ECC_SOFT_BCH when it is specified in device tree.
--- drivers/mtd/nand/raw/fsl_elbc_nand.c | 49 +++++++++++++++------------- 1 file changed, 26 insertions(+), 23 deletions(-)
drivers/mtd/nand/raw/fsl_elbc_nand.c +26 -23
@@ -737,36 +737,39 @@ static int fsl_elbc_chip_init(int devnum, u8 *addr, ofnode flash_node) nand->controller = &elbc_ctrl->controller;nand_set_controller_data (nand, priv); - nand->ecc.read_page = fsl_elbc_read_page; - nand->ecc.write_page = fsl_elbc_write_page; - nand->ecc.write_subpage = fsl_elbc_write_subpage; - priv->fmr = (15 <<FMR_CWTO_SHIFT ) | (2 <<FMR_AL_SHIFT ); -/* If CS Base Register selects full hardware ECC then use it */ -if ((br &BR_DECC ) ==BR_DECC_CHK_GEN ) { - nand->ecc.mode =NAND_ECC_HW ; - - nand->ecc.layout = (priv->fmr &FMR_ECCM ) ? - &fsl_elbc_oob_sp_eccm1 : - &fsl_elbc_oob_sp_eccm0; + ret =nand_scan_ident (mtd,1 ,NULL ); +if (ret) +return ret; - nand->ecc.size =512 ; - nand->ecc.bytes =3 ; - nand->ecc.steps =1 ; - nand->ecc.strength =1 ; - }else { -/* otherwise fall back to software ECC */ +/* If nand_scan_ident() has not selected ecc.mode, do it now */ +if (nand->ecc.mode ==NAND_ECC_NONE ) { +/* If CS Base Register selects full hardware ECC then use it */ +if ((br &BR_DECC ) ==BR_DECC_CHK_GEN ) { + nand->ecc.mode =NAND_ECC_HW ; + nand->ecc.layout = (priv->fmr &FMR_ECCM ) ? + &fsl_elbc_oob_sp_eccm1 : + &fsl_elbc_oob_sp_eccm0; + nand->ecc.size =512 ; + nand->ecc.bytes =3 ; + nand->ecc.steps =1 ; + nand->ecc.strength =1 ; + }else { +/* otherwise fall back to software ECC */ #if defined(CONFIG_NAND_ECC_BCH ) - nand->ecc.mode =NAND_ECC_SOFT_BCH ; + nand->ecc.mode =NAND_ECC_SOFT_BCH ;#else - nand->ecc.mode =NAND_ECC_SOFT ; + nand->ecc.mode =NAND_ECC_SOFT ;#endif + } } - ret =nand_scan_ident (mtd,1 ,NULL ); -if (ret) -return ret; +if (nand->ecc.mode ==NAND_ECC_HW ) { + nand->ecc.read_page = fsl_elbc_read_page; + nand->ecc.write_page = fsl_elbc_write_page; + nand->ecc.write_subpage = fsl_elbc_write_subpage; + }/* Large-page-specific setup */ if (mtd->writesize ==2048 ) {
@@ -785,7 +788,7 @@ static int fsl_elbc_chip_init(int devnum, u8 *addr, ofnode flash_node) priv->fmr |=FMR_ECCM ;/* adjust ecc setup if needed */ -if ((br &BR_DECC ) ==BR_DECC_CHK_GEN ) { +if (nand->ecc.mode ==NAND_ECC_HW ) { nand->ecc.steps =4 ; nand->ecc.layout = (priv->fmr &FMR_ECCM ) ? &fsl_elbc_oob_lp_eccm1 :
Signature · 1 line
2.20.1
PATCH 4/5 mtd: nand: raw: Add support for DT property nand-ecc-algo=bch
In reply to Pali RohárAccording to Linux kernel DT schema nand-controller.yaml, using DT property nand-ecc-algo=bch is the correct way for specifying BCH as ECC algorithm.
--- drivers/mtd/nand/raw/nand_base.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/mtd/nand/raw/nand_base.c +6 -0
@@ -4598,6 +4598,12 @@ static int nand_dt_init(struct mtd_info *mtd, struct nand_chip *chip, ofnode nod ecc_mode =NAND_ECC_SOFT_BCH ; } +if (ecc_mode ==NAND_ECC_SOFT ) { + str =ofnode_read_string (node,"nand-ecc-algo" ); +if (str && !strcmp (str,"bch" )) + ecc_mode =NAND_ECC_SOFT_BCH ; + } + ecc_strength =ofnode_read_s32_default (node,"nand-ecc-strength" ,-1 ); ecc_step = ofnode_read_s32_default(node,
Signature · 1 line
2.20.1
PATCH 5/5 powerpc: dts: p2020: Add localbus node
In reply to Pali RohárThis node is required for NAND and NOR support. Node is taken from the upstream Linux kernel DTS file.
--- arch/powerpc/dts/p2020-post.dtsi | 7 +++++++ arch/powerpc/dts/p2020rdb-pc.dts | 4 ++++ arch/powerpc/dts/p2020rdb-pc_36b.dts | 4 ++++ 3 files changed, 15 insertions(+)
arch/powerpc/dts/p2020-post.dtsi +7 -0
@@ -85,3 +85,10 @@ device_type = "pci"; bus-range = <0x0 0xff>; }; + +&lbc { + #address-cells = <2>; + #size-cells = <1>; + compatible = "fsl,p2020-elbc", "fsl,elbc", "simple-bus"; + interrupts = <19 2 0 0>; +};
arch/powerpc/dts/p2020rdb-pc.dts +4 -0
@@ -15,6 +15,10 @@ #size-cells = <2>; interrupt-parent = <&mpic>; + lbc: localbus@ffe05000 { + reg = <0 0xffe05000 0 0x1000>; + }; + soc: soc@ffe00000 { ranges = <0x0 0x0 0xffe00000 0x100000>; };
arch/powerpc/dts/p2020rdb-pc_36b.dts +4 -0
@@ -15,6 +15,10 @@ #size-cells = <2>; interrupt-parent = <&mpic>; + lbc: localbus@fffe05000 { + reg = <0 0xfffe05000 0 0x1000>; + }; + soc: soc@fffe00000 { ranges = <0x0 0xf 0xffe00000 0x100000>; };
Signature · 1 line
2.20.1
PATCH v2 1/1 powerpc: dts: p2020: Add localbus node
This node is required for NAND and NOR support. Node is taken from the upstream Linux kernel DTS file.
---
Changes in v2:
* Fix copy/paste definition error in p2020rdb-pc_36b.dts
--- arch/powerpc/dts/p2020-post.dtsi | 7 +++++++ arch/powerpc/dts/p2020rdb-pc.dts | 4 ++++ arch/powerpc/dts/p2020rdb-pc_36b.dts | 4 ++++ 3 files changed, 15 insertions(+)
arch/powerpc/dts/p2020-post.dtsi +7 -0
@@ -85,3 +85,10 @@ device_type = "pci"; bus-range = <0x0 0xff>; }; + +&lbc { + #address-cells = <2>; + #size-cells = <1>; + compatible = "fsl,p2020-elbc", "fsl,elbc", "simple-bus"; + interrupts = <19 2 0 0>; +};
arch/powerpc/dts/p2020rdb-pc.dts +4 -0
@@ -15,6 +15,10 @@ #size-cells = <2>; interrupt-parent = <&mpic>; + lbc: localbus@ffe05000 { + reg = <0 0xffe05000 0 0x1000>; + }; + soc: soc@ffe00000 { ranges = <0x0 0x0 0xffe00000 0x100000>; };
arch/powerpc/dts/p2020rdb-pc_36b.dts +4 -0
@@ -15,6 +15,10 @@ #size-cells = <2>; interrupt-parent = <&mpic>; + lbc: localbus@fffe05000 { + reg = <0xf 0xffe05000 0 0x1000>; + }; + soc: soc@fffe00000 { ranges = <0x0 0xf 0xffe00000 0x100000>; };
Signature · 1 line
2.20.1