aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPekon Gupta <pekon@ti.com>2013-10-24 08:50:17 -0400
committerBrian Norris <computersforpeace@gmail.com>2013-11-07 02:33:07 -0500
commitac65caf514ec3e55e8d3d510ee37f80dd97418fe (patch)
tree68a56895371738d7ce6b3f005bf6bce04beafda2
parentdc525ff4705cee2291b1637a650489aca86ac937 (diff)
ARM: OMAP2+: cleaned-up DT support of various ECC schemes
OMAP NAND driver support multiple ECC scheme, which can used in different flavours, depending on in-build Hardware engines present on SoC. This patch updates following in DT bindings related to sectionion of ecc-schemes - ti,elm-id: replaces elm_id (maintains backward compatibility) - ti,nand-ecc-opts: selection of h/w or s/w implementation of an ecc-scheme depends on ti,elm-id. (supported values ham1, bch4, and bch8) - maintain backward compatibility to deprecated DT bindings (sw, hw, hw-romcode) Below table shows different flavours of ecc-schemes supported by OMAP devices +---------------------------------------+---------------+---------------+ | ECC scheme |ECC calculation|Error detection| +---------------------------------------+---------------+---------------+ |OMAP_ECC_HAM1_CODE_HW |H/W (GPMC) |S/W | +---------------------------------------+---------------+---------------+ |OMAP_ECC_BCH8_CODE_HW_DETECTION_SW |H/W (GPMC) |S/W | |(requires CONFIG_MTD_NAND_ECC_BCH) | | | +---------------------------------------+---------------+---------------+ |OMAP_ECC_BCH8_CODE_HW |H/W (GPMC) |H/W (ELM) | |(requires CONFIG_MTD_NAND_OMAP_BCH && | | | | ti,elm-id in DT) | | | +---------------------------------------+---------------+---------------+ To optimize footprint of omap2-nand driver, selection of some ECC schemes also require enabling following Kconfigs, in addition to setting appropriate DT bindings - Kconfig:CONFIG_MTD_NAND_ECC_BCH error detection done in software - Kconfig:CONFIG_MTD_NAND_OMAP_BCH error detection done by h/w engine Signed-off-by: Pekon Gupta <pekon@ti.com> Reviewed-by: Felipe Balbi <balbi@ti.com> Acked-by: Tony Lindgren <tony@atomide.com> Tested-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
-rw-r--r--Documentation/devicetree/bindings/mtd/gpmc-nand.txt8
-rw-r--r--arch/arm/mach-omap2/gpmc.c48
-rw-r--r--include/linux/platform_data/mtd-nand-omap2.h13
3 files changed, 51 insertions, 18 deletions
diff --git a/Documentation/devicetree/bindings/mtd/gpmc-nand.txt b/Documentation/devicetree/bindings/mtd/gpmc-nand.txt
index df338cb5059c..bfe07e152738 100644
--- a/Documentation/devicetree/bindings/mtd/gpmc-nand.txt
+++ b/Documentation/devicetree/bindings/mtd/gpmc-nand.txt
@@ -36,8 +36,12 @@ Optional properties:
36 "prefetch-dma" Prefetch enabled sDMA mode 36 "prefetch-dma" Prefetch enabled sDMA mode
37 "prefetch-irq" Prefetch enabled irq mode 37 "prefetch-irq" Prefetch enabled irq mode
38 38
39 - elm_id: Specifies elm device node. This is required to support BCH 39 - elm_id: <deprecated> use "ti,elm-id" instead
40 error correction using ELM module. 40 - ti,elm-id: Specifies phandle of the ELM devicetree node.
41 ELM is an on-chip hardware engine on TI SoC which is used for
42 locating ECC errors for BCHx algorithms. SoC devices which have
43 ELM hardware engines should specify this device node in .dtsi
44 Using ELM for ECC error correction frees some CPU cycles.
41 45
42For inline partiton table parsing (optional): 46For inline partiton table parsing (optional):
43 47
diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
index 579697adaae7..c877129142ba 100644
--- a/arch/arm/mach-omap2/gpmc.c
+++ b/arch/arm/mach-omap2/gpmc.c
@@ -1341,14 +1341,6 @@ static void __maybe_unused gpmc_read_timings_dt(struct device_node *np,
1341 1341
1342#ifdef CONFIG_MTD_NAND 1342#ifdef CONFIG_MTD_NAND
1343 1343
1344static const char * const nand_ecc_opts[] = {
1345 [OMAP_ECC_HAMMING_CODE_DEFAULT] = "sw",
1346 [OMAP_ECC_HAMMING_CODE_HW] = "hw",
1347 [OMAP_ECC_HAMMING_CODE_HW_ROMCODE] = "hw-romcode",
1348 [OMAP_ECC_BCH4_CODE_HW] = "bch4",
1349 [OMAP_ECC_BCH8_CODE_HW] = "bch8",
1350};
1351
1352static const char * const nand_xfer_types[] = { 1344static const char * const nand_xfer_types[] = {
1353 [NAND_OMAP_PREFETCH_POLLED] = "prefetch-polled", 1345 [NAND_OMAP_PREFETCH_POLLED] = "prefetch-polled",
1354 [NAND_OMAP_POLLED] = "polled", 1346 [NAND_OMAP_POLLED] = "polled",
@@ -1378,13 +1370,41 @@ static int gpmc_probe_nand_child(struct platform_device *pdev,
1378 gpmc_nand_data->cs = val; 1370 gpmc_nand_data->cs = val;
1379 gpmc_nand_data->of_node = child; 1371 gpmc_nand_data->of_node = child;
1380 1372
1381 if (!of_property_read_string(child, "ti,nand-ecc-opt", &s)) 1373 /* Detect availability of ELM module */
1382 for (val = 0; val < ARRAY_SIZE(nand_ecc_opts); val++) 1374 gpmc_nand_data->elm_of_node = of_parse_phandle(child, "ti,elm-id", 0);
1383 if (!strcasecmp(s, nand_ecc_opts[val])) { 1375 if (gpmc_nand_data->elm_of_node == NULL)
1384 gpmc_nand_data->ecc_opt = val; 1376 gpmc_nand_data->elm_of_node =
1385 break; 1377 of_parse_phandle(child, "elm_id", 0);
1386 } 1378 if (gpmc_nand_data->elm_of_node == NULL)
1379 pr_warn("%s: ti,elm-id property not found\n", __func__);
1380
1381 /* select ecc-scheme for NAND */
1382 if (of_property_read_string(child, "ti,nand-ecc-opt", &s)) {
1383 pr_err("%s: ti,nand-ecc-opt not found\n", __func__);
1384 return -ENODEV;
1385 }
1386 if (!strcmp(s, "ham1") || !strcmp(s, "sw") ||
1387 !strcmp(s, "hw") || !strcmp(s, "hw-romcode"))
1388 gpmc_nand_data->ecc_opt =
1389 OMAP_ECC_HAM1_CODE_HW;
1390 else if (!strcmp(s, "bch4"))
1391 if (gpmc_nand_data->elm_of_node)
1392 gpmc_nand_data->ecc_opt =
1393 OMAP_ECC_BCH4_CODE_HW;
1394 else
1395 gpmc_nand_data->ecc_opt =
1396 OMAP_ECC_BCH4_CODE_HW_DETECTION_SW;
1397 else if (!strcmp(s, "bch8"))
1398 if (gpmc_nand_data->elm_of_node)
1399 gpmc_nand_data->ecc_opt =
1400 OMAP_ECC_BCH8_CODE_HW;
1401 else
1402 gpmc_nand_data->ecc_opt =
1403 OMAP_ECC_BCH8_CODE_HW_DETECTION_SW;
1404 else
1405 pr_err("%s: ti,nand-ecc-opt invalid value\n", __func__);
1387 1406
1407 /* select data transfer mode for NAND controller */
1388 if (!of_property_read_string(child, "ti,nand-xfer-type", &s)) 1408 if (!of_property_read_string(child, "ti,nand-xfer-type", &s))
1389 for (val = 0; val < ARRAY_SIZE(nand_xfer_types); val++) 1409 for (val = 0; val < ARRAY_SIZE(nand_xfer_types); val++)
1390 if (!strcasecmp(s, nand_xfer_types[val])) { 1410 if (!strcasecmp(s, nand_xfer_types[val])) {
diff --git a/include/linux/platform_data/mtd-nand-omap2.h b/include/linux/platform_data/mtd-nand-omap2.h
index 6bf9ef43ddb1..e4128f1510bf 100644
--- a/include/linux/platform_data/mtd-nand-omap2.h
+++ b/include/linux/platform_data/mtd-nand-omap2.h
@@ -28,8 +28,16 @@ enum omap_ecc {
28 OMAP_ECC_HAMMING_CODE_HW, /* gpmc to detect the error */ 28 OMAP_ECC_HAMMING_CODE_HW, /* gpmc to detect the error */
29 /* 1-bit ecc: stored at beginning of spare area as romcode */ 29 /* 1-bit ecc: stored at beginning of spare area as romcode */
30 OMAP_ECC_HAMMING_CODE_HW_ROMCODE, /* gpmc method & romcode layout */ 30 OMAP_ECC_HAMMING_CODE_HW_ROMCODE, /* gpmc method & romcode layout */
31 OMAP_ECC_BCH4_CODE_HW, /* 4-bit BCH ecc code */ 31 /* 1-bit ECC calculation by GPMC, Error detection by Software */
32 OMAP_ECC_BCH8_CODE_HW, /* 8-bit BCH ecc code */ 32 OMAP_ECC_HAM1_CODE_HW,
33 /* 4-bit ECC calculation by GPMC, Error detection by Software */
34 OMAP_ECC_BCH4_CODE_HW_DETECTION_SW,
35 /* 4-bit ECC calculation by GPMC, Error detection by ELM */
36 OMAP_ECC_BCH4_CODE_HW,
37 /* 8-bit ECC calculation by GPMC, Error detection by Software */
38 OMAP_ECC_BCH8_CODE_HW_DETECTION_SW,
39 /* 8-bit ECC calculation by GPMC, Error detection by ELM */
40 OMAP_ECC_BCH8_CODE_HW,
33}; 41};
34 42
35struct gpmc_nand_regs { 43struct gpmc_nand_regs {
@@ -63,5 +71,6 @@ struct omap_nand_platform_data {
63 71
64 /* for passing the partitions */ 72 /* for passing the partitions */
65 struct device_node *of_node; 73 struct device_node *of_node;
74 struct device_node *elm_of_node;
66}; 75};
67#endif 76#endif