* [PATCH 0/3] at91: PMECC: enable PMECC in dt for at91sam9x5ek, at91sam9n12ek
@ 2012-12-19 10:27 Josh Wu
2012-12-19 10:27 ` [PATCH 1/3] MTD: at91: atmel_nand: for PMECC, add code to choose the ecc bits and sector size according to the ONFI parameter ECC requirement Josh Wu
` (3 more replies)
0 siblings, 4 replies; 9+ messages in thread
From: Josh Wu @ 2012-12-19 10:27 UTC (permalink / raw)
To: linux-arm-kernel
Those patches will enable PMECC in dt parameters for at91sam9x5ek, at91sam9n12ek.
Josh Wu (3):
MTD: at91: atmel_nand: for PMECC, add code to choose the ecc bits and
sector size according to the ONFI parameter ECC requirement.
at91: 9x5: add DT parameters to enable PMECC
at91: at91sam9n12: add DT parameters to enable PMECC
arch/arm/boot/dts/at91sam9n12.dtsi | 1 +
arch/arm/boot/dts/at91sam9n12ek.dts | 5 +-
arch/arm/boot/dts/at91sam9x5.dtsi | 4 ++
arch/arm/boot/dts/at91sam9x5cm.dtsi | 5 +-
drivers/mtd/nand/atmel_nand.c | 89 +++++++++++++++++++++++++++++++++++
5 files changed, 102 insertions(+), 2 deletions(-)
--
1.7.9.5
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/3] MTD: at91: atmel_nand: for PMECC, add code to choose the ecc bits and sector size according to the ONFI parameter ECC requirement.
2012-12-19 10:27 [PATCH 0/3] at91: PMECC: enable PMECC in dt for at91sam9x5ek, at91sam9n12ek Josh Wu
@ 2012-12-19 10:27 ` Josh Wu
2013-01-15 12:26 ` Artem Bityutskiy
2012-12-19 10:27 ` [PATCH 2/3] at91: 9x5: add DT parameters to enable PMECC Josh Wu
` (2 subsequent siblings)
3 siblings, 1 reply; 9+ messages in thread
From: Josh Wu @ 2012-12-19 10:27 UTC (permalink / raw)
To: linux-arm-kernel
This patch will check NAND flash's ecc minimum requirement in ONFI parameter. If it is equal or smaller than pmecc-cap in dtsi, then use ecc_bits in ONFI. otherwise, return an error since pmecc-cap in dtsi don't meet the ecc minimum reqirement.
This patch also check sector size (codeword) requirement in ONFI. If it is equal or bigger than sector_size in dtsi, then use the one of ONFI. otherwise return error.
Currently we don't support to read the ECC parameter in ONFI extended parameter page. So in that case we just use the value specified in dts.
For non-ONFI nand flash, we assume the minimum ecc requirement is 2bits in 512 bytes.
Signed-off-by: Josh Wu <josh.wu@atmel.com>
---
drivers/mtd/nand/atmel_nand.c | 89 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 89 insertions(+)
diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c
index 9144557..7855ccd 100644
--- a/drivers/mtd/nand/atmel_nand.c
+++ b/drivers/mtd/nand/atmel_nand.c
@@ -901,6 +901,84 @@ static void atmel_pmecc_core_init(struct mtd_info *mtd)
pmecc_writel(host->ecc, CTRL, PMECC_CTRL_ENABLE);
}
+/*
+ * Get ECC requirement in ONFI parameters, returns -1 if ONFI
+ * parameters is not supported.
+ * return 0 if success to get the ECC requirement.
+ */
+static int get_onfi_ecc_param(struct nand_chip *chip,
+ int *ecc_bits, int *sector_size)
+{
+ *ecc_bits = *sector_size = 0;
+
+ if (chip->onfi_params.ecc_bits == 0xff)
+ /* TODO: the sector_size and ecc_bits need to be find in
+ * extended ecc parameter, currently we don't support it.
+ */
+ return -1;
+
+ *ecc_bits = chip->onfi_params.ecc_bits;
+
+ /* The default sector size (ecc codeword size) is 512 */
+ *sector_size = 512;
+
+ return 0;
+}
+
+/*
+ * Choose ecc cap and sector size in atmel_nand_host according to ONFI
+ * parameters ecc requirement.
+ * return 0 if success. otherwise return error code.
+ */
+static int pmecc_choose_ecc_bits(struct atmel_nand_host *host,
+ struct nand_chip *chip)
+{
+ int ecc_bits, sector_size;
+
+ if (!get_onfi_ecc_param(chip, &ecc_bits, §or_size)) {
+ dev_info(host->dev, "ONFI params, minimum required ECC: %dbits in %d bytes\n",
+ ecc_bits, sector_size);
+
+ if (ecc_bits > host->pmecc_corr_cap) {
+ dev_err(host->dev, "Error: Need to set a bigger pmecc-cap in dts. Current is: %d\n",
+ host->pmecc_corr_cap);
+ return -EINVAL;
+ }
+ if (sector_size < host->pmecc_sector_size) {
+ dev_err(host->dev, "Error: Need to set a smaller pmecc-sector-size in dts. Current is: %d\n",
+ host->pmecc_sector_size);
+ return -EINVAL;
+ }
+
+ /* use the most fitable ecc bits (the near bigger one ) */
+ if (ecc_bits <= 2)
+ host->pmecc_corr_cap = 2;
+ else if (ecc_bits <= 4)
+ host->pmecc_corr_cap = 4;
+ else if (ecc_bits < 8)
+ host->pmecc_corr_cap = 8;
+ else if (ecc_bits < 12)
+ host->pmecc_corr_cap = 12;
+ else if (ecc_bits < 24)
+ host->pmecc_corr_cap = 24;
+ else
+ return -EINVAL;
+
+ /* use the most fitable sector size (the near smaller one ) */
+ if (sector_size >= 1024)
+ host->pmecc_sector_size = 1024;
+ else if (sector_size >= 512)
+ host->pmecc_sector_size = 512;
+ else
+ return -EINVAL;
+ } else {
+ dev_info(host->dev,
+ "NAND chip ECC reqirement is in Extended ONFI parameter, we don't support yet. So use default setting in dts\n");
+ }
+
+ return 0;
+}
+
static int __init atmel_pmecc_nand_init_params(struct platform_device *pdev,
struct atmel_nand_host *host)
{
@@ -909,8 +987,19 @@ static int __init atmel_pmecc_nand_init_params(struct platform_device *pdev,
struct resource *regs, *regs_pmerr, *regs_rom;
int cap, sector_size, err_no;
+ if (nand_chip->onfi_version) {
+ /* Choose ecc cap and sector size base on ONFI parameters */
+ err_no = pmecc_choose_ecc_bits(host, nand_chip);
+ if (err_no)
+ return err_no;
+ } else {
+ dev_info(host->dev, "NAND chip is not ONFI compliant, assume ecc_bits is 2");
+ host->pmecc_corr_cap = 2;
+ }
+
cap = host->pmecc_corr_cap;
sector_size = host->pmecc_sector_size;
+
dev_info(host->dev, "Initialize PMECC params, cap: %d, sector: %d\n",
cap, sector_size);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 2/3] at91: 9x5: add DT parameters to enable PMECC
2012-12-19 10:27 [PATCH 0/3] at91: PMECC: enable PMECC in dt for at91sam9x5ek, at91sam9n12ek Josh Wu
2012-12-19 10:27 ` [PATCH 1/3] MTD: at91: atmel_nand: for PMECC, add code to choose the ecc bits and sector size according to the ONFI parameter ECC requirement Josh Wu
@ 2012-12-19 10:27 ` Josh Wu
2012-12-19 10:27 ` [PATCH 3/3] at91: at91sam9n12: " Josh Wu
2013-01-14 9:01 ` [PATCH 0/3] at91: PMECC: enable PMECC in dt for at91sam9x5ek, at91sam9n12ek Josh Wu
3 siblings, 0 replies; 9+ messages in thread
From: Josh Wu @ 2012-12-19 10:27 UTC (permalink / raw)
To: linux-arm-kernel
Default ecc correctable setting is 2bits in 512 bytes.
Signed-off-by: Josh Wu <josh.wu@atmel.com>
---
arch/arm/boot/dts/at91sam9x5.dtsi | 4 ++++
arch/arm/boot/dts/at91sam9x5cm.dtsi | 5 ++++-
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/arch/arm/boot/dts/at91sam9x5.dtsi b/arch/arm/boot/dts/at91sam9x5.dtsi
index 03fc136..590f225 100644
--- a/arch/arm/boot/dts/at91sam9x5.dtsi
+++ b/arch/arm/boot/dts/at91sam9x5.dtsi
@@ -270,7 +270,11 @@
#address-cells = <1>;
#size-cells = <1>;
reg = <0x40000000 0x10000000
+ 0xffffe000 0x600 /* PMECC Registers */
+ 0xffffe600 0x200 /* PMECC Error Location Registers */
+ 0x00100000 0x100000 /* ROM code */
>;
+ atmel,pmecc-lookup-table-offset = <0x8000 0x10000>;
atmel,nand-addr-offset = <21>;
atmel,nand-cmd-offset = <22>;
gpios = <&pioD 5 0
diff --git a/arch/arm/boot/dts/at91sam9x5cm.dtsi b/arch/arm/boot/dts/at91sam9x5cm.dtsi
index 31e7be2..4027ac7 100644
--- a/arch/arm/boot/dts/at91sam9x5cm.dtsi
+++ b/arch/arm/boot/dts/at91sam9x5cm.dtsi
@@ -26,7 +26,10 @@
ahb {
nand0: nand@40000000 {
nand-bus-width = <8>;
- nand-ecc-mode = "soft";
+ nand-ecc-mode = "hw";
+ atmel,has-pmecc; /* Enable PMECC */
+ atmel,pmecc-cap = <2>;
+ atmel,pmecc-sector-size = <512>;
nand-on-flash-bbt;
status = "okay";
--
1.7.9.5
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 3/3] at91: at91sam9n12: add DT parameters to enable PMECC
2012-12-19 10:27 [PATCH 0/3] at91: PMECC: enable PMECC in dt for at91sam9x5ek, at91sam9n12ek Josh Wu
2012-12-19 10:27 ` [PATCH 1/3] MTD: at91: atmel_nand: for PMECC, add code to choose the ecc bits and sector size according to the ONFI parameter ECC requirement Josh Wu
2012-12-19 10:27 ` [PATCH 2/3] at91: 9x5: add DT parameters to enable PMECC Josh Wu
@ 2012-12-19 10:27 ` Josh Wu
2013-01-14 9:01 ` [PATCH 0/3] at91: PMECC: enable PMECC in dt for at91sam9x5ek, at91sam9n12ek Josh Wu
3 siblings, 0 replies; 9+ messages in thread
From: Josh Wu @ 2012-12-19 10:27 UTC (permalink / raw)
To: linux-arm-kernel
Default ecc correctable setting is 2bits in 512 bytes.
Signed-off-by: Josh Wu <josh.wu@atmel.com>
---
arch/arm/boot/dts/at91sam9n12.dtsi | 1 +
arch/arm/boot/dts/at91sam9n12ek.dts | 5 ++++-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/arch/arm/boot/dts/at91sam9n12.dtsi b/arch/arm/boot/dts/at91sam9n12.dtsi
index 82508d6..c9719ce 100644
--- a/arch/arm/boot/dts/at91sam9n12.dtsi
+++ b/arch/arm/boot/dts/at91sam9n12.dtsi
@@ -213,6 +213,7 @@
0xffffe600 0x00000200
0x00100000 0x00100000
>;
+ atmel,pmecc-lookup-table-offset = <0x8000 0x10000>;
atmel,nand-addr-offset = <21>;
atmel,nand-cmd-offset = <22>;
gpios = <&pioD 5 0
diff --git a/arch/arm/boot/dts/at91sam9n12ek.dts b/arch/arm/boot/dts/at91sam9n12ek.dts
index 912b2c2..88ee0da 100644
--- a/arch/arm/boot/dts/at91sam9n12ek.dts
+++ b/arch/arm/boot/dts/at91sam9n12ek.dts
@@ -49,7 +49,10 @@
nand0: nand@40000000 {
nand-bus-width = <8>;
- nand-ecc-mode = "soft";
+ nand-ecc-mode = "hw";
+ atmel,has-pmecc;
+ atmel,pmecc-cap = <2>;
+ atmel,pmecc-sector-size = <512>;
nand-on-flash-bbt;
status = "okay";
};
--
1.7.9.5
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 0/3] at91: PMECC: enable PMECC in dt for at91sam9x5ek, at91sam9n12ek
2012-12-19 10:27 [PATCH 0/3] at91: PMECC: enable PMECC in dt for at91sam9x5ek, at91sam9n12ek Josh Wu
` (2 preceding siblings ...)
2012-12-19 10:27 ` [PATCH 3/3] at91: at91sam9n12: " Josh Wu
@ 2013-01-14 9:01 ` Josh Wu
3 siblings, 0 replies; 9+ messages in thread
From: Josh Wu @ 2013-01-14 9:01 UTC (permalink / raw)
To: linux-arm-kernel
Ping? Any feedback for these patches?
On 12/19/2012 6:27 PM, Josh Wu wrote:
> Those patches will enable PMECC in dt parameters for at91sam9x5ek, at91sam9n12ek.
>
> Josh Wu (3):
> MTD: at91: atmel_nand: for PMECC, add code to choose the ecc bits and
> sector size according to the ONFI parameter ECC requirement.
> at91: 9x5: add DT parameters to enable PMECC
> at91: at91sam9n12: add DT parameters to enable PMECC
>
> arch/arm/boot/dts/at91sam9n12.dtsi | 1 +
> arch/arm/boot/dts/at91sam9n12ek.dts | 5 +-
> arch/arm/boot/dts/at91sam9x5.dtsi | 4 ++
> arch/arm/boot/dts/at91sam9x5cm.dtsi | 5 +-
> drivers/mtd/nand/atmel_nand.c | 89 +++++++++++++++++++++++++++++++++++
> 5 files changed, 102 insertions(+), 2 deletions(-)
>
Best Regards,
Josh Wu
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/3] MTD: at91: atmel_nand: for PMECC, add code to choose the ecc bits and sector size according to the ONFI parameter ECC requirement.
2012-12-19 10:27 ` [PATCH 1/3] MTD: at91: atmel_nand: for PMECC, add code to choose the ecc bits and sector size according to the ONFI parameter ECC requirement Josh Wu
@ 2013-01-15 12:26 ` Artem Bityutskiy
2013-01-16 1:50 ` Bo Shen
2013-01-16 8:28 ` Josh Wu
0 siblings, 2 replies; 9+ messages in thread
From: Artem Bityutskiy @ 2013-01-15 12:26 UTC (permalink / raw)
To: linux-arm-kernel
I cannot compile this patch:
ERROR (phandle_references): Reference to non-existent node or label "pinctrl_ssc0_tx"
ERROR: Input tree has errors, aborting (use -f to force output)
make[2]: *** [arch/arm/boot/dts/at91sam9g20ek.dtb] Error 2
On Wed, 2012-12-19 at 18:27 +0800, Josh Wu wrote:
> This patch will check NAND flash's ecc minimum requirement in ONFI parameter. If it is equal or smaller than pmecc-cap in dtsi, then use ecc_bits in ONFI. otherwise, return an error since pmecc-cap in dtsi don't meet the ecc minimum reqirement.
>
> This patch also check sector size (codeword) requirement in ONFI. If it is equal or bigger than sector_size in dtsi, then use the one of ONFI. otherwise return error.
>
> Currently we don't support to read the ECC parameter in ONFI extended parameter page. So in that case we just use the value specified in dts.
>
> For non-ONFI nand flash, we assume the minimum ecc requirement is 2bits in 512 bytes.
>
> Signed-off-by: Josh Wu <josh.wu@atmel.com>
Please, wrap the lines like kernel developers usually do.
--
Best Regards,
Artem Bityutskiy
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20130115/49c8872d/attachment.sig>
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/3] MTD: at91: atmel_nand: for PMECC, add code to choose the ecc bits and sector size according to the ONFI parameter ECC requirement.
2013-01-15 12:26 ` Artem Bityutskiy
@ 2013-01-16 1:50 ` Bo Shen
2013-01-16 8:28 ` Josh Wu
1 sibling, 0 replies; 9+ messages in thread
From: Bo Shen @ 2013-01-16 1:50 UTC (permalink / raw)
To: linux-arm-kernel
Hi Artem Bityutskiy,
On 1/15/2013 20:26, Artem Bityutskiy wrote:
> I cannot compile this patch:
>
> ERROR (phandle_references): Reference to non-existent node or label "pinctrl_ssc0_tx"
>
> ERROR: Input tree has errors, aborting (use -f to force output)
> make[2]: *** [arch/arm/boot/dts/at91sam9g20ek.dtb] Error 2
Sorry for this inconvenience.
There are patches doesn't go to mainline in time which cause this issue.
[1] https://patchwork.kernel.org/patch/1966321/
[2] https://patchwork.kernel.org/patch/1966341/
Best Regards,
Bo Shen
>
> On Wed, 2012-12-19 at 18:27 +0800, Josh Wu wrote:
>> This patch will check NAND flash's ecc minimum requirement in ONFI parameter. If it is equal or smaller than pmecc-cap in dtsi, then use ecc_bits in ONFI. otherwise, return an error since pmecc-cap in dtsi don't meet the ecc minimum reqirement.
>>
>> This patch also check sector size (codeword) requirement in ONFI. If it is equal or bigger than sector_size in dtsi, then use the one of ONFI. otherwise return error.
>>
>> Currently we don't support to read the ECC parameter in ONFI extended parameter page. So in that case we just use the value specified in dts.
>>
>> For non-ONFI nand flash, we assume the minimum ecc requirement is 2bits in 512 bytes.
>>
>> Signed-off-by: Josh Wu <josh.wu@atmel.com>
>
> Please, wrap the lines like kernel developers usually do.
>
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/3] MTD: at91: atmel_nand: for PMECC, add code to choose the ecc bits and sector size according to the ONFI parameter ECC requirement.
2013-01-15 12:26 ` Artem Bityutskiy
2013-01-16 1:50 ` Bo Shen
@ 2013-01-16 8:28 ` Josh Wu
2013-01-17 11:54 ` Artem Bityutskiy
1 sibling, 1 reply; 9+ messages in thread
From: Josh Wu @ 2013-01-16 8:28 UTC (permalink / raw)
To: linux-arm-kernel
Hi, Artem
On 1/15/2013 8:26 PM, Artem Bityutskiy wrote:
> I cannot compile this patch:
>
> ERROR (phandle_references): Reference to non-existent node or label "pinctrl_ssc0_tx"
>
> ERROR: Input tree has errors, aborting (use -f to force output)
> make[2]: *** [arch/arm/boot/dts/at91sam9g20ek.dtb] Error 2
As Bo Shen already mentioned, they are caused by ssc pinctrl patches. it
will be merged in next rc or late.
>
> On Wed, 2012-12-19 at 18:27 +0800, Josh Wu wrote:
>> This patch will check NAND flash's ecc minimum requirement in ONFI parameter. If it is equal or smaller than pmecc-cap in dtsi, then use ecc_bits in ONFI. otherwise, return an error since pmecc-cap in dtsi don't meet the ecc minimum reqirement.
>>
>> This patch also check sector size (codeword) requirement in ONFI. If it is equal or bigger than sector_size in dtsi, then use the one of ONFI. otherwise return error.
>>
>> Currently we don't support to read the ECC parameter in ONFI extended parameter page. So in that case we just use the value specified in dts.
>>
>> For non-ONFI nand flash, we assume the minimum ecc requirement is 2bits in 512 bytes.
>>
>> Signed-off-by: Josh Wu <josh.wu@atmel.com>
> Please, wrap the lines like kernel developers usually do.
OK. I will resend the whole patch series with wrapped commit message.
thanks.
Best Regards,
Josh Wu
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/3] MTD: at91: atmel_nand: for PMECC, add code to choose the ecc bits and sector size according to the ONFI parameter ECC requirement.
2013-01-16 8:28 ` Josh Wu
@ 2013-01-17 11:54 ` Artem Bityutskiy
0 siblings, 0 replies; 9+ messages in thread
From: Artem Bityutskiy @ 2013-01-17 11:54 UTC (permalink / raw)
To: linux-arm-kernel
On Wed, 2013-01-16 at 16:28 +0800, Josh Wu wrote:
> Hi, Artem
>
> On 1/15/2013 8:26 PM, Artem Bityutskiy wrote:
> > I cannot compile this patch:
> >
> > ERROR (phandle_references): Reference to non-existent node or label "pinctrl_ssc0_tx"
> >
> > ERROR: Input tree has errors, aborting (use -f to force output)
> > make[2]: *** [arch/arm/boot/dts/at91sam9g20ek.dtb] Error 2
>
> As Bo Shen already mentioned, they are caused by ssc pinctrl patches. it
> will be merged in next rc or late.
Then ping me when the patches are ready to go, please.
--
Best Regards,
Artem Bityutskiy
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20130117/18bb67c3/attachment.sig>
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2013-01-17 11:54 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-19 10:27 [PATCH 0/3] at91: PMECC: enable PMECC in dt for at91sam9x5ek, at91sam9n12ek Josh Wu
2012-12-19 10:27 ` [PATCH 1/3] MTD: at91: atmel_nand: for PMECC, add code to choose the ecc bits and sector size according to the ONFI parameter ECC requirement Josh Wu
2013-01-15 12:26 ` Artem Bityutskiy
2013-01-16 1:50 ` Bo Shen
2013-01-16 8:28 ` Josh Wu
2013-01-17 11:54 ` Artem Bityutskiy
2012-12-19 10:27 ` [PATCH 2/3] at91: 9x5: add DT parameters to enable PMECC Josh Wu
2012-12-19 10:27 ` [PATCH 3/3] at91: at91sam9n12: " Josh Wu
2013-01-14 9:01 ` [PATCH 0/3] at91: PMECC: enable PMECC in dt for at91sam9x5ek, at91sam9n12ek Josh Wu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).