Export the ecc step size to user applications
Subsystems (2)
cover Export the ecc step size to user applications
In order to implement the NAND boot for some Freescale's chips, such as imx23/imx28/imx50/imx6, we use a tool (called kobs-ng) to burn the uboot and some metadata to nand chip. And the ROM code will use the metadata to configrate the BCH, and to find the uboot.
The ECC information(ecc step size, ecc strength) which is used to configrate the BCH is part of the metadata. The kobs-ng can gets the ecc strength from the sys node /sys/*/mtdX/ecc_strength now. But it can't gets the ecc step size.
This patch set is used to export the ecc step size to user applications. With this patch set, the kobs-ng can gets the ecc step size now.
Huang Shijie (4):
mtd: add a new field to mtd_info{}
mtd: add a new sys node to show the ecc step size
mtd: set the ecc step size for master/slave mtd_info
mtd: gpmi: update the ecc step size for mtd_info{}
drivers/mtd/mtdcore.c | 11 +++++++++++ drivers/mtd/mtdpart.c | 1 + drivers/mtd/nand/gpmi-nand/gpmi-nand.c | 1 + drivers/mtd/nand/nand_base.c | 1 + include/linux/mtd/mtd.h | 3 +++ 5 files changed, 17 insertions(+), 0 deletions(-)
PATCH 1/4 mtd: add a new field to mtd_info{}
In order to implement the NAND boot for some Freescale's chips, such as imx23/imx28/imx50/imx6, we use a tool (called kobs-ng) to burn the uboot and some metadata to nand chip. And the ROM code will use the metadata to configrate the BCH, and to find the uboot.
The ECC information(ecc step size, ecc strength) which is used to configrate the BCH is part of the metadata. The kobs-ng can gets the ecc strength from the sys node /sys/*/ecc_strength now. But it can not gets the ecc step size.
This patch adds a new field to store the ecc step size in mtd_info{}, and it makes preparation for the next patches.
--- include/linux/mtd/mtd.h | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
include/linux/mtd/mtd.h +3 -0
@@ -173,6 +173,9 @@ struct mtd_info {/* ECC layout structure pointer - read only! */ struct nand_ecclayout *ecclayout; +/* the ecc step size. */ +unsigned int ecc_size; +/* max number of correctible bit errors per ecc step */ unsigned int ecc_strength;
Signature · 1 line
1.7.1
Re: [PATCH 1/4] mtd: add a new field to mtd_info{}
Quoted 22 lines · Huang Shijie
In order to implement the NAND boot for some Freescale's chips, such as imx23/imx28/imx50/imx6, we use a tool (called kobs-ng) to burn the uboot and some metadata to nand chip. And the ROM code will use the metadata to configrate the BCH, and to find the uboot.
The ECC
information(ecc step size, ecc strength)which is used to configrate the BCH is part of the metadata. The kobs-ng can gets the ecc strength from the sys node/sys/*/ecc_strengthnow. But it can not gets the ecc step size.This patch adds a new field to store the ecc step size in mtd_info{}, and it makes preparation for the next patches.
Signed-off-by Huang Shijie <[email protected]>--- include/linux/mtd/mtd.h | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)include/linux/mtd/mtd.h +0
-0
include/linux/mtd/mtd.h struct mtd_info { · line 177
Quoted 5 lines
include/linux/mtd/mtd.h +2
-0@@ -173,6 +173,9 @@ struct mtd_info {/* ECC layout structure pointer - read only! */ struct nand_ecclayout *ecclayout; +/* the ecc step size. */ +unsigned int ecc_size;
It would really be nice to harmonize the naming and probably stick to ecc_step everywhere. To me things looks confusing, because ecc_size is actually ECC step size, and not the size of ECC codes.
Signature · 2 lines
Best Regards, Artem Bityutskiy
Re: [PATCH 1/4] mtd: add a new field to mtd_info{}
Quoted 26 lines · Artem Bityutskiy
Quoted 25 lines · Huang Shijie
In order to implement the NAND boot for some Freescale's chips, such as imx23/imx28/imx50/imx6, we use a tool (called kobs-ng) to burn the uboot and some metadata to nand chip. And the ROM code will use the metadata to configrate the BCH, and to find the uboot.
The ECC
information(ecc step size, ecc strength)which is used to configrate the BCH is part of the metadata. The kobs-ng can gets the ecc strength from the sys node/sys/*/ecc_strengthnow. But it can not gets the ecc step size.This patch adds a new field to store the ecc step size in mtd_info{}, and it makes preparation for the next patches.
Signed-off-by Huang Shijie<[email protected]>--- include/linux/mtd/mtd.h | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)include/linux/mtd/mtd.h +0
-0@@ -173,6 +173,9 @@ struct mtd_info {/* ECC layout structure pointer - read only! */ struct nand_ecclayout *ecclayout;
Quoted 6 lines
include/linux/mtd/mtd.h struct mtd_info { · line 177
Quoted 2 lines
include/linux/mtd/mtd.h +2
-0+/* the ecc step size. */ +unsigned int ecc_size;It would really be nice to harmonize the naming and probably stick to
ecc_stepeverywhere. To me things looks confusing, becauseecc_sizeis actually ECC step size, and not the size of ECC codes.
ok. I will use ecc_step as the name.
thanks
Huang Shijie
PATCH 2/4 mtd: add a new sys node to show the ecc step size
In reply to Huang ShijieAdd a new sys node to show the ecc step size.
The application then can uses this node to get the ecc step size.
--- drivers/mtd/mtdcore.c | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-)
drivers/mtd/mtdcore.c +11 -0
@@ -287,6 +287,16 @@ static DEVICE_ATTR(bitflip_threshold, S_IRUGO | S_IWUSR, mtd_bitflip_threshold_show, mtd_bitflip_threshold_store); +static ssize_t mtd_ecc_size_show (struct device *dev, +struct device_attribute *attr,char *buf) +{ +struct mtd_info *mtd =dev_get_drvdata (dev); + +return snprintf (buf,PAGE_SIZE ,"%lu\n" , (unsigned long )mtd->ecc_size); + +} +static DEVICE_ATTR(ecc_size, S_IRUGO, mtd_ecc_size_show, NULL); +static struct attribute *mtd_attrs[] = { &dev_attr_type.attr, &dev_attr_flags.attr,
@@ -298,6 +308,7 @@ static struct attribute *mtd_attrs[] = { &dev_attr_numeraseregions.attr, &dev_attr_name.attr, &dev_attr_ecc_strength.attr, + &dev_attr_ecc_size.attr, &dev_attr_bitflip_threshold.attr, NULL, };
Signature · 1 line
1.7.1
PATCH 3/4 mtd: set the ecc step size for master/slave mtd_info
In reply to Huang ShijieSet the ecc step size for master/slave mtd_info{}.
--- drivers/mtd/mtdpart.c | 1 + drivers/mtd/nand/nand_base.c | 1 + 2 files changed, 2 insertions(+), 0 deletions(-)
drivers/mtd/mtdpart.c +1 -0
@@ -516,6 +516,7 @@ static struct mtd_part *allocate_partition(struct mtd_info *master, } slave->mtd.ecclayout = master->ecclayout; + slave->mtd.ecc_size = master->ecc_size; slave->mtd.ecc_strength = master->ecc_strength; slave->mtd.bitflip_threshold = master->bitflip_threshold;
drivers/mtd/nand/nand_base.c +1 -0
@@ -3760,6 +3760,7 @@ int nand_scan_tail(struct mtd_info *mtd)/* propagate ecc info to mtd_info */ mtd->ecclayout = chip->ecc.layout; mtd->ecc_strength = chip->ecc.strength; + mtd->ecc_size = chip->ecc.size;/* * Initialize bitflip_threshold to its default prior scan_bbt() call. * scan_bbt() might invoke mtd_read(), thus bitflip_threshold must be
Signature · 1 line
1.7.1
PATCH 4/4 mtd: gpmi: update the ecc step size for mtd_info{}
In reply to Huang Shijieupdate the ecc step size when we have already get the right value.
--- drivers/mtd/nand/gpmi-nand/gpmi-nand.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/mtd/nand/gpmi-nand/gpmi-nand.c +1 -0
@@ -1644,6 +1644,7 @@ static int gpmi_pre_bbt_scan(struct gpmi_nand_data *this)/* Adjust the ECC strength according to the chip. */ this->nand.ecc.strength = this->bch_geometry.ecc_strength; this->mtd.ecc_strength = this->bch_geometry.ecc_strength; + this->mtd.ecc_size = this->bch_geometry.ecc_chunk_size; this->mtd.bitflip_threshold = this->bch_geometry.ecc_strength;/* NAND boot init, depends on the gpmi_set_geometry(). */
Signature · 1 line
1.7.1