* [PATCH 1/2] imx-bbu-nand-fcb: split up read_fcb
@ 2016-12-14 8:00 Jan Remmet
2016-12-14 8:00 ` [PATCH] i.MX habv4: add RVT address for i.MX6UL Jan Remmet
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Jan Remmet @ 2016-12-14 8:00 UTC (permalink / raw)
To: barebox
There are other ecc modes for the fcb out there.
Signed-off-by: Jan Remmet <j.remmet@phytec.de>
---
common/imx-bbu-nand-fcb.c | 83 +++++++++++++++++++++++++++--------------------
1 file changed, 47 insertions(+), 36 deletions(-)
diff --git a/common/imx-bbu-nand-fcb.c b/common/imx-bbu-nand-fcb.c
index 1db4c5a..34a5f83 100644
--- a/common/imx-bbu-nand-fcb.c
+++ b/common/imx-bbu-nand-fcb.c
@@ -167,6 +167,46 @@ static uint32_t calc_chksum(void *buf, size_t size)
return ~chksum;
}
+struct fcb_block *read_fcb_hamming_13_8(void *rawpage)
+{
+ int i;
+ int bitflips = 0, bit_to_flip;
+ u8 parity, np, syndrome;
+ u8 *fcb, *ecc;
+
+ fcb = rawpage + 12;
+ ecc = rawpage + 512 + 12;
+
+ for (i = 0; i < 512; i++) {
+ parity = ecc[i];
+ np = calculate_parity_13_8(fcb[i]);
+
+ syndrome = np ^ parity;
+ if (syndrome == 0)
+ continue;
+
+ if (!(hweight8(syndrome) & 1)) {
+ pr_err("Uncorrectable error at offset %d\n", i);
+ return ERR_PTR(-EIO);
+ }
+
+ bit_to_flip = lookup_single_error_13_8(syndrome);
+ if (bit_to_flip < 0) {
+ pr_err("Uncorrectable error at offset %d\n", i);
+ return ERR_PTR(-EIO);
+ }
+
+ bitflips++;
+
+ if (bit_to_flip > 7)
+ ecc[i] ^= 1 << (bit_to_flip - 8);
+ else
+ fcb[i] ^= 1 << bit_to_flip;
+ }
+
+ return xmemdup(rawpage + 12, 512);
+}
+
static __maybe_unused void dump_fcb(void *buf)
{
struct fcb_block *fcb = buf;
@@ -258,11 +298,8 @@ static ssize_t raw_write_page(struct mtd_info *mtd, void *buf, loff_t offset)
static int read_fcb(struct mtd_info *mtd, int num, struct fcb_block **retfcb)
{
- int i;
- int bitflips = 0, bit_to_flip;
- u8 parity, np, syndrome;
- u8 *fcb, *ecc;
int ret;
+ struct fcb_block *fcb;
void *rawpage;
*retfcb = NULL;
@@ -275,40 +312,14 @@ static int read_fcb(struct mtd_info *mtd, int num, struct fcb_block **retfcb)
goto err;
}
- fcb = rawpage + 12;
- ecc = rawpage + 512 + 12;
-
- for (i = 0; i < 512; i++) {
- parity = ecc[i];
- np = calculate_parity_13_8(fcb[i]);
-
- syndrome = np ^ parity;
- if (syndrome == 0)
- continue;
-
- if (!(hweight8(syndrome) & 1)) {
- pr_err("Uncorrectable error at offset %d\n", i);
- ret = -EIO;
- goto err;
- }
-
- bit_to_flip = lookup_single_error_13_8(syndrome);
- if (bit_to_flip < 0) {
- pr_err("Uncorrectable error at offset %d\n", i);
- ret = -EIO;
- goto err;
- }
-
- bitflips++;
-
- if (bit_to_flip > 7)
- ecc[i] ^= 1 << (bit_to_flip - 8);
- else
- fcb[i] ^= 1 << bit_to_flip;
+ fcb = read_fcb_hamming_13_8(rawpage);
+ if (IS_ERR(fcb)) {
+ pr_err("Cannot read fcb\n");
+ ret = PTR_ERR(fcb);
+ goto err;
}
- *retfcb = xmemdup(rawpage + 12, 512);
-
+ *retfcb = fcb;
ret = 0;
err:
free(rawpage);
--
2.7.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] i.MX habv4: add RVT address for i.MX6UL
2016-12-14 8:00 [PATCH 1/2] imx-bbu-nand-fcb: split up read_fcb Jan Remmet
@ 2016-12-14 8:00 ` Jan Remmet
2016-12-14 8:05 ` [PATCH 1/2] imx-bbu-nand-fcb: split up read_fcb Jan Remmet
2017-01-09 10:45 ` Sascha Hauer
2 siblings, 0 replies; 4+ messages in thread
From: Jan Remmet @ 2016-12-14 8:00 UTC (permalink / raw)
To: barebox
The RVT table contains the pointers to the HAB API functions and is
located at 0x00000100.
Signed-off-by: Jan Remmet <j.remmet@phytec.de>
---
drivers/hab/habv4.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/hab/habv4.c b/drivers/hab/habv4.c
index 91dbb7a..ae43bdf 100644
--- a/drivers/hab/habv4.c
+++ b/drivers/hab/habv4.c
@@ -27,6 +27,7 @@
#define HABV4_RVT_IMX28 0xffff8af8
#define HABV4_RVT_IMX6_OLD 0x00000094
#define HABV4_RVT_IMX6_NEW 0x00000098
+#define HABV4_RVT_IMX6UL 0x00000100
enum hab_tag {
HAB_TAG_IVT = 0xd1, /* Image Vector Table */
@@ -227,6 +228,10 @@ int imx6_hab_get_status(void)
if (rvt->header.tag == HAB_TAG_RVT)
return habv4_get_status(rvt);
+ rvt = (void *)HABV4_RVT_IMX6UL;
+ if (rvt->header.tag == HAB_TAG_RVT)
+ return habv4_get_status(rvt);
+
pr_err("ERROR - RVT not found!\n");
return -EINVAL;
@@ -237,4 +242,4 @@ int imx28_hab_get_status(void)
const struct habv4_rvt *rvt = (void *)HABV4_RVT_IMX28;
return habv4_get_status(rvt);
-}
\ No newline at end of file
+}
--
2.7.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] imx-bbu-nand-fcb: split up read_fcb
2016-12-14 8:00 [PATCH 1/2] imx-bbu-nand-fcb: split up read_fcb Jan Remmet
2016-12-14 8:00 ` [PATCH] i.MX habv4: add RVT address for i.MX6UL Jan Remmet
@ 2016-12-14 8:05 ` Jan Remmet
2017-01-09 10:45 ` Sascha Hauer
2 siblings, 0 replies; 4+ messages in thread
From: Jan Remmet @ 2016-12-14 8:05 UTC (permalink / raw)
To: barebox
On Wed, Dec 14, 2016 at 09:00:03AM +0100, Jan Remmet wrote:
> There are other ecc modes for the fcb out there.
sorry double post :(
Jan
>
> Signed-off-by: Jan Remmet <j.remmet@phytec.de>
> ---
> common/imx-bbu-nand-fcb.c | 83 +++++++++++++++++++++++++++--------------------
> 1 file changed, 47 insertions(+), 36 deletions(-)
>
> diff --git a/common/imx-bbu-nand-fcb.c b/common/imx-bbu-nand-fcb.c
> index 1db4c5a..34a5f83 100644
> --- a/common/imx-bbu-nand-fcb.c
> +++ b/common/imx-bbu-nand-fcb.c
> @@ -167,6 +167,46 @@ static uint32_t calc_chksum(void *buf, size_t size)
> return ~chksum;
> }
>
> +struct fcb_block *read_fcb_hamming_13_8(void *rawpage)
> +{
> + int i;
> + int bitflips = 0, bit_to_flip;
> + u8 parity, np, syndrome;
> + u8 *fcb, *ecc;
> +
> + fcb = rawpage + 12;
> + ecc = rawpage + 512 + 12;
> +
> + for (i = 0; i < 512; i++) {
> + parity = ecc[i];
> + np = calculate_parity_13_8(fcb[i]);
> +
> + syndrome = np ^ parity;
> + if (syndrome == 0)
> + continue;
> +
> + if (!(hweight8(syndrome) & 1)) {
> + pr_err("Uncorrectable error at offset %d\n", i);
> + return ERR_PTR(-EIO);
> + }
> +
> + bit_to_flip = lookup_single_error_13_8(syndrome);
> + if (bit_to_flip < 0) {
> + pr_err("Uncorrectable error at offset %d\n", i);
> + return ERR_PTR(-EIO);
> + }
> +
> + bitflips++;
> +
> + if (bit_to_flip > 7)
> + ecc[i] ^= 1 << (bit_to_flip - 8);
> + else
> + fcb[i] ^= 1 << bit_to_flip;
> + }
> +
> + return xmemdup(rawpage + 12, 512);
> +}
> +
> static __maybe_unused void dump_fcb(void *buf)
> {
> struct fcb_block *fcb = buf;
> @@ -258,11 +298,8 @@ static ssize_t raw_write_page(struct mtd_info *mtd, void *buf, loff_t offset)
>
> static int read_fcb(struct mtd_info *mtd, int num, struct fcb_block **retfcb)
> {
> - int i;
> - int bitflips = 0, bit_to_flip;
> - u8 parity, np, syndrome;
> - u8 *fcb, *ecc;
> int ret;
> + struct fcb_block *fcb;
> void *rawpage;
>
> *retfcb = NULL;
> @@ -275,40 +312,14 @@ static int read_fcb(struct mtd_info *mtd, int num, struct fcb_block **retfcb)
> goto err;
> }
>
> - fcb = rawpage + 12;
> - ecc = rawpage + 512 + 12;
> -
> - for (i = 0; i < 512; i++) {
> - parity = ecc[i];
> - np = calculate_parity_13_8(fcb[i]);
> -
> - syndrome = np ^ parity;
> - if (syndrome == 0)
> - continue;
> -
> - if (!(hweight8(syndrome) & 1)) {
> - pr_err("Uncorrectable error at offset %d\n", i);
> - ret = -EIO;
> - goto err;
> - }
> -
> - bit_to_flip = lookup_single_error_13_8(syndrome);
> - if (bit_to_flip < 0) {
> - pr_err("Uncorrectable error at offset %d\n", i);
> - ret = -EIO;
> - goto err;
> - }
> -
> - bitflips++;
> -
> - if (bit_to_flip > 7)
> - ecc[i] ^= 1 << (bit_to_flip - 8);
> - else
> - fcb[i] ^= 1 << bit_to_flip;
> + fcb = read_fcb_hamming_13_8(rawpage);
> + if (IS_ERR(fcb)) {
> + pr_err("Cannot read fcb\n");
> + ret = PTR_ERR(fcb);
> + goto err;
> }
>
> - *retfcb = xmemdup(rawpage + 12, 512);
> -
> + *retfcb = fcb;
> ret = 0;
> err:
> free(rawpage);
> --
> 2.7.4
>
>
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] imx-bbu-nand-fcb: split up read_fcb
2016-12-14 8:00 [PATCH 1/2] imx-bbu-nand-fcb: split up read_fcb Jan Remmet
2016-12-14 8:00 ` [PATCH] i.MX habv4: add RVT address for i.MX6UL Jan Remmet
2016-12-14 8:05 ` [PATCH 1/2] imx-bbu-nand-fcb: split up read_fcb Jan Remmet
@ 2017-01-09 10:45 ` Sascha Hauer
2 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2017-01-09 10:45 UTC (permalink / raw)
To: Jan Remmet; +Cc: barebox
On Wed, Dec 14, 2016 at 09:00:03AM +0100, Jan Remmet wrote:
> There are other ecc modes for the fcb out there.
>
> Signed-off-by: Jan Remmet <j.remmet@phytec.de>
> ---
> common/imx-bbu-nand-fcb.c | 83 +++++++++++++++++++++++++++--------------------
> 1 file changed, 47 insertions(+), 36 deletions(-)
Applied, thanks
Sascha
>
> diff --git a/common/imx-bbu-nand-fcb.c b/common/imx-bbu-nand-fcb.c
> index 1db4c5a..34a5f83 100644
> --- a/common/imx-bbu-nand-fcb.c
> +++ b/common/imx-bbu-nand-fcb.c
> @@ -167,6 +167,46 @@ static uint32_t calc_chksum(void *buf, size_t size)
> return ~chksum;
> }
>
> +struct fcb_block *read_fcb_hamming_13_8(void *rawpage)
> +{
> + int i;
> + int bitflips = 0, bit_to_flip;
> + u8 parity, np, syndrome;
> + u8 *fcb, *ecc;
> +
> + fcb = rawpage + 12;
> + ecc = rawpage + 512 + 12;
> +
> + for (i = 0; i < 512; i++) {
> + parity = ecc[i];
> + np = calculate_parity_13_8(fcb[i]);
> +
> + syndrome = np ^ parity;
> + if (syndrome == 0)
> + continue;
> +
> + if (!(hweight8(syndrome) & 1)) {
> + pr_err("Uncorrectable error at offset %d\n", i);
> + return ERR_PTR(-EIO);
> + }
> +
> + bit_to_flip = lookup_single_error_13_8(syndrome);
> + if (bit_to_flip < 0) {
> + pr_err("Uncorrectable error at offset %d\n", i);
> + return ERR_PTR(-EIO);
> + }
> +
> + bitflips++;
> +
> + if (bit_to_flip > 7)
> + ecc[i] ^= 1 << (bit_to_flip - 8);
> + else
> + fcb[i] ^= 1 << bit_to_flip;
> + }
> +
> + return xmemdup(rawpage + 12, 512);
> +}
> +
> static __maybe_unused void dump_fcb(void *buf)
> {
> struct fcb_block *fcb = buf;
> @@ -258,11 +298,8 @@ static ssize_t raw_write_page(struct mtd_info *mtd, void *buf, loff_t offset)
>
> static int read_fcb(struct mtd_info *mtd, int num, struct fcb_block **retfcb)
> {
> - int i;
> - int bitflips = 0, bit_to_flip;
> - u8 parity, np, syndrome;
> - u8 *fcb, *ecc;
> int ret;
> + struct fcb_block *fcb;
> void *rawpage;
>
> *retfcb = NULL;
> @@ -275,40 +312,14 @@ static int read_fcb(struct mtd_info *mtd, int num, struct fcb_block **retfcb)
> goto err;
> }
>
> - fcb = rawpage + 12;
> - ecc = rawpage + 512 + 12;
> -
> - for (i = 0; i < 512; i++) {
> - parity = ecc[i];
> - np = calculate_parity_13_8(fcb[i]);
> -
> - syndrome = np ^ parity;
> - if (syndrome == 0)
> - continue;
> -
> - if (!(hweight8(syndrome) & 1)) {
> - pr_err("Uncorrectable error at offset %d\n", i);
> - ret = -EIO;
> - goto err;
> - }
> -
> - bit_to_flip = lookup_single_error_13_8(syndrome);
> - if (bit_to_flip < 0) {
> - pr_err("Uncorrectable error at offset %d\n", i);
> - ret = -EIO;
> - goto err;
> - }
> -
> - bitflips++;
> -
> - if (bit_to_flip > 7)
> - ecc[i] ^= 1 << (bit_to_flip - 8);
> - else
> - fcb[i] ^= 1 << bit_to_flip;
> + fcb = read_fcb_hamming_13_8(rawpage);
> + if (IS_ERR(fcb)) {
> + pr_err("Cannot read fcb\n");
> + ret = PTR_ERR(fcb);
> + goto err;
> }
>
> - *retfcb = xmemdup(rawpage + 12, 512);
> -
> + *retfcb = fcb;
> ret = 0;
> err:
> free(rawpage);
> --
> 2.7.4
>
>
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
>
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-01-09 10:45 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-14 8:00 [PATCH 1/2] imx-bbu-nand-fcb: split up read_fcb Jan Remmet
2016-12-14 8:00 ` [PATCH] i.MX habv4: add RVT address for i.MX6UL Jan Remmet
2016-12-14 8:05 ` [PATCH 1/2] imx-bbu-nand-fcb: split up read_fcb Jan Remmet
2017-01-09 10:45 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox