summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2011-08-11 14:06:46 -0700
committerSimon Glass <sjg@chromium.org>2011-09-09 16:04:00 -0700
commitec657dae4ff8328e2fda9c8fbe336b605c33e801 (patch)
treef853ebbf3662a96aa0e39c7f839b942723f38d3d /common
parentacc6caf0f9d618659b5803e57bafc7f0b3083bd8 (diff)
fdt: Add NAND decode functions
BUG=chromium-os:17062 TEST=build and boot on Seaboard Change-Id: I7aa667fc608d3c42b4e16b0b9af3ef34df425cd0 Reviewed-on: http://gerrit.chromium.org/gerrit/6070 Reviewed-by: Simon Glass <sjg@chromium.org> Tested-by: Simon Glass <sjg@chromium.org> Reviewed-on: http://gerrit.chromium.org/gerrit/7453
Diffstat (limited to 'common')
-rw-r--r--common/fdt_decode.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/common/fdt_decode.c b/common/fdt_decode.c
index df267e4e00c..272b47390c0 100644
--- a/common/fdt_decode.c
+++ b/common/fdt_decode.c
@@ -643,3 +643,34 @@ int fdt_decode_i2c(const void *blob, int node, struct fdt_i2c *config)
return 0;
}
+
+int fdt_decode_nand(const void *blob, int node, struct fdt_nand *config)
+{
+ int err;
+
+ config->page_data_bytes = get_int(blob, node, "page-data-bytes", -1);
+ config->tag_ecc_bytes = get_int(blob, node, "tag-ecc-bytes", -1);
+ config->tag_bytes = get_int(blob, node, "tag-bytes", -1);
+ config->data_ecc_bytes = get_int(blob, node, "data-ecc-bytes", -1);
+ config->skipped_spare_bytes = get_int(blob, node,
+ "skipped-spare-bytes", -1);
+ config->page_spare_bytes = get_int(blob, node, "page-spare-bytes", -1);
+ if (config->page_data_bytes == -1 || config->tag_ecc_bytes == -1 ||
+ config->tag_bytes == -1 || config->data_ecc_bytes == -1 ||
+ config->skipped_spare_bytes == -1 ||
+ config->page_spare_bytes == -1)
+ return -FDT_ERR_MISSING;
+ err = get_int_array(blob, node, "timing", config->timing,
+ FDT_NAND_TIMING_COUNT);
+ if (err < 0)
+ return err;
+
+ /* Now look up the controller and decode that */
+ node = lookup_phandle(blob, node, "controller");
+ if (node < 0)
+ return node;
+ config->reg = (struct nand_ctlr *)get_addr(blob, node, "reg");
+ config->enabled = get_is_enabled(blob, node, 1);
+ config->width = get_int(blob, node, "width", 8);
+ return fdt_decode_gpio(blob, node, "wp-gpio", &config->wp_gpio);
+}