From: Boris BREZILLON <b.brezillon.dev@gmail.com>
To: David Woodhouse <dwmw2@infradead.org>,
Brian Norris <computersforpeace@gmail.com>
Cc: Boris BREZILLON <b.brezillon.dev@gmail.com>,
linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org,
Ezequiel Garcia <ezequiel.garcia@free-electrons.com>,
Gupta Pekon <pekon@ti.com>
Subject: [RFC PATCH v2 4/4] mtd: nand: add NAND partition support to the sunxi driver
Date: Tue, 11 Feb 2014 22:46:49 +0100 [thread overview]
Message-ID: <1392155209-14495-5-git-send-email-b.brezillon.dev@gmail.com> (raw)
In-Reply-To: <1392155209-14495-1-git-send-email-b.brezillon.dev@gmail.com>
Signed-off-by: Boris BREZILLON <b.brezillon.dev@gmail.com>
---
drivers/mtd/nand/sunxi_nand.c | 69 +++++++++++++++++++++++++++++++++++++++--
1 file changed, 66 insertions(+), 3 deletions(-)
diff --git a/drivers/mtd/nand/sunxi_nand.c b/drivers/mtd/nand/sunxi_nand.c
index f24ad8b..4693d9f 100644
--- a/drivers/mtd/nand/sunxi_nand.c
+++ b/drivers/mtd/nand/sunxi_nand.c
@@ -168,6 +168,17 @@ struct sunxi_nand_hw_ecc {
struct nand_ecclayout layout;
};
+struct sunxi_nand_part {
+ struct nand_part part;
+ struct nand_ecc_ctrl ecc;
+};
+
+static inline struct sunxi_nand_part *
+to_sunxi_nand_part(struct nand_part *part)
+{
+ return container_of(part, struct sunxi_nand_part, part);
+}
+
struct sunxi_nand_chip {
struct list_head node;
struct nand_chip nand;
@@ -780,12 +791,58 @@ static int sunxi_nand_chip_ecc_init(struct device *dev,
return 0;
}
+static void sunxi_nand_part_release(struct nand_part *part)
+{
+ kfree(to_sunxi_nand_part(part));
+}
+
+struct nand_part *sunxi_ofnandpart_parse(void *priv, struct mtd_info *master,
+ struct device_node *pp)
+{
+ int mode = of_get_nand_ecc_mode(pp);
+ struct sunxi_nand_part *part;
+ struct nand_chip *chip = master->priv;
+ u32 strength;
+ u32 blk_size;
+
+ if (mode < 0)
+ return nandpart_alloc();
+
+ part = kzalloc(sizeof(*part), GFP_KERNEL);
+ part->part.release = sunxi_nand_part_release;
+
+ part->ecc.size = chip->ecc_step_ds;
+ part->ecc.strength = chip->ecc_strength_ds;
+ if (!of_get_nand_ecc_level(pp, &strength, &blk_size)) {
+ part->ecc.size = blk_size;
+ part->ecc.strength = strength;
+ }
+
+ part->ecc.mode = mode;
+ switch (mode) {
+ case NAND_ECC_SOFT_BCH:
+ part->ecc.bytes = ((part->ecc.strength *
+ fls(8 * part->ecc.size)) + 7) / 8;
+ break;
+ case NAND_ECC_HW:
+ break;
+ case NAND_ECC_NONE:
+ break;
+ default:
+ break;
+ }
+
+ part->part.ecc = &part->ecc;
+
+ return &part->part;
+}
+
static int sunxi_nand_chip_init(struct device *dev, struct sunxi_nfc *nfc,
struct device_node *np)
{
const struct nand_sdr_timings *timings;
struct sunxi_nand_chip *chip;
- struct mtd_part_parser_data ppdata;
+ struct ofnandpart_data ppdata;
struct mtd_info *mtd;
struct nand_chip *nand;
int nsels;
@@ -889,9 +946,15 @@ static int sunxi_nand_chip_init(struct device *dev, struct sunxi_nfc *nfc,
mtd->name = chip->default_name;
}
- ppdata.of_node = np;
- ret = mtd_device_parse_register(mtd, NULL, &ppdata, NULL, 0);
+ ppdata.node = np;
+ ppdata.parse = sunxi_ofnandpart_parse;
+ ret = ofnandpart_parse(mtd, &ppdata);
if (!ret)
+ ret = mtd_device_register(mtd, NULL, 0);
+ else if (ret > 0)
+ ret = 0;
+
+ if (ret)
return ret;
list_add_tail(&chip->node, &nfc->chips);
--
1.7.9.5
WARNING: multiple messages have this Message-ID (diff)
From: Boris BREZILLON <b.brezillon.dev@gmail.com>
To: David Woodhouse <dwmw2@infradead.org>,
Brian Norris <computersforpeace@gmail.com>
Cc: linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org,
Gupta Pekon <pekon@ti.com>,
Ezequiel Garcia <ezequiel.garcia@free-electrons.com>,
Boris BREZILLON <b.brezillon.dev@gmail.com>
Subject: [RFC PATCH v2 4/4] mtd: nand: add NAND partition support to the sunxi driver
Date: Tue, 11 Feb 2014 22:46:49 +0100 [thread overview]
Message-ID: <1392155209-14495-5-git-send-email-b.brezillon.dev@gmail.com> (raw)
In-Reply-To: <1392155209-14495-1-git-send-email-b.brezillon.dev@gmail.com>
Signed-off-by: Boris BREZILLON <b.brezillon.dev@gmail.com>
---
drivers/mtd/nand/sunxi_nand.c | 69 +++++++++++++++++++++++++++++++++++++++--
1 file changed, 66 insertions(+), 3 deletions(-)
diff --git a/drivers/mtd/nand/sunxi_nand.c b/drivers/mtd/nand/sunxi_nand.c
index f24ad8b..4693d9f 100644
--- a/drivers/mtd/nand/sunxi_nand.c
+++ b/drivers/mtd/nand/sunxi_nand.c
@@ -168,6 +168,17 @@ struct sunxi_nand_hw_ecc {
struct nand_ecclayout layout;
};
+struct sunxi_nand_part {
+ struct nand_part part;
+ struct nand_ecc_ctrl ecc;
+};
+
+static inline struct sunxi_nand_part *
+to_sunxi_nand_part(struct nand_part *part)
+{
+ return container_of(part, struct sunxi_nand_part, part);
+}
+
struct sunxi_nand_chip {
struct list_head node;
struct nand_chip nand;
@@ -780,12 +791,58 @@ static int sunxi_nand_chip_ecc_init(struct device *dev,
return 0;
}
+static void sunxi_nand_part_release(struct nand_part *part)
+{
+ kfree(to_sunxi_nand_part(part));
+}
+
+struct nand_part *sunxi_ofnandpart_parse(void *priv, struct mtd_info *master,
+ struct device_node *pp)
+{
+ int mode = of_get_nand_ecc_mode(pp);
+ struct sunxi_nand_part *part;
+ struct nand_chip *chip = master->priv;
+ u32 strength;
+ u32 blk_size;
+
+ if (mode < 0)
+ return nandpart_alloc();
+
+ part = kzalloc(sizeof(*part), GFP_KERNEL);
+ part->part.release = sunxi_nand_part_release;
+
+ part->ecc.size = chip->ecc_step_ds;
+ part->ecc.strength = chip->ecc_strength_ds;
+ if (!of_get_nand_ecc_level(pp, &strength, &blk_size)) {
+ part->ecc.size = blk_size;
+ part->ecc.strength = strength;
+ }
+
+ part->ecc.mode = mode;
+ switch (mode) {
+ case NAND_ECC_SOFT_BCH:
+ part->ecc.bytes = ((part->ecc.strength *
+ fls(8 * part->ecc.size)) + 7) / 8;
+ break;
+ case NAND_ECC_HW:
+ break;
+ case NAND_ECC_NONE:
+ break;
+ default:
+ break;
+ }
+
+ part->part.ecc = &part->ecc;
+
+ return &part->part;
+}
+
static int sunxi_nand_chip_init(struct device *dev, struct sunxi_nfc *nfc,
struct device_node *np)
{
const struct nand_sdr_timings *timings;
struct sunxi_nand_chip *chip;
- struct mtd_part_parser_data ppdata;
+ struct ofnandpart_data ppdata;
struct mtd_info *mtd;
struct nand_chip *nand;
int nsels;
@@ -889,9 +946,15 @@ static int sunxi_nand_chip_init(struct device *dev, struct sunxi_nfc *nfc,
mtd->name = chip->default_name;
}
- ppdata.of_node = np;
- ret = mtd_device_parse_register(mtd, NULL, &ppdata, NULL, 0);
+ ppdata.node = np;
+ ppdata.parse = sunxi_ofnandpart_parse;
+ ret = ofnandpart_parse(mtd, &ppdata);
if (!ret)
+ ret = mtd_device_register(mtd, NULL, 0);
+ else if (ret > 0)
+ ret = 0;
+
+ if (ret)
return ret;
list_add_tail(&chip->node, &nfc->chips);
--
1.7.9.5
next prev parent reply other threads:[~2014-02-11 21:47 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-11 21:46 [RFC PATCH v2 0/4] mtd: nand: add per partition ECC config Boris BREZILLON
2014-02-11 21:46 ` Boris BREZILLON
2014-02-11 21:46 ` [RFC PATCH v2 1/4] mtd: nand: take nand_ecc_ctrl initialization out of nand_scan_tail Boris BREZILLON
2014-02-11 21:46 ` Boris BREZILLON
2014-02-11 21:46 ` [RFC PATCH v2 2/4] mtd: nand: add support for NAND partitions Boris BREZILLON
2014-02-11 21:46 ` Boris BREZILLON
2014-02-11 21:46 ` [RFC PATCH v2 3/4] mtd: nand: add DT NAND partition parser Boris BREZILLON
2014-02-11 21:46 ` Boris BREZILLON
2014-02-11 21:46 ` Boris BREZILLON [this message]
2014-02-11 21:46 ` [RFC PATCH v2 4/4] mtd: nand: add NAND partition support to the sunxi driver Boris BREZILLON
2014-02-12 14:38 ` [RFC PATCH pre-v3 2/4] mtd: nand: add support for NAND partitions Boris BREZILLON
2014-02-12 14:38 ` Boris BREZILLON
2014-02-12 19:49 ` [RFC PATCH v2 0/4] mtd: nand: add per partition ECC config Florian Fainelli
2014-02-12 19:49 ` Florian Fainelli
2014-02-12 21:20 ` Boris BREZILLON
2014-02-12 21:20 ` Boris BREZILLON
2014-02-12 21:40 ` Boris BREZILLON
2014-02-12 21:40 ` Boris BREZILLON
2014-02-12 22:43 ` Florian Fainelli
2014-02-12 22:43 ` Florian Fainelli
2014-02-13 9:06 ` Boris BREZILLON
2014-02-13 9:06 ` Boris BREZILLON
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1392155209-14495-5-git-send-email-b.brezillon.dev@gmail.com \
--to=b.brezillon.dev@gmail.com \
--cc=computersforpeace@gmail.com \
--cc=dwmw2@infradead.org \
--cc=ezequiel.garcia@free-electrons.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=pekon@ti.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.