"prefetch-dma"          Prefetch enabled sDMA mode
                "prefetch-irq"          Prefetch enabled irq mode
 
- - elm_id:     Specifies elm device node. This is required to support BCH
-               error correction using ELM module.
+ - elm_id:     <deprecated> use "ti,elm-id" instead
+ - ti,elm-id:  Specifies phandle of the ELM devicetree node.
+               ELM is an on-chip hardware engine on TI SoC which is used for
+               locating ECC errors for BCHx algorithms. SoC devices which have
+               ELM hardware engines should specify this device node in .dtsi
+               Using ELM for ECC error correction frees some CPU cycles.
 
 For inline partiton table parsing (optional):
 
 
 
 #ifdef CONFIG_MTD_NAND
 
-static const char * const nand_ecc_opts[] = {
-       [OMAP_ECC_HAMMING_CODE_DEFAULT]         = "sw",
-       [OMAP_ECC_HAMMING_CODE_HW]              = "hw",
-       [OMAP_ECC_HAMMING_CODE_HW_ROMCODE]      = "hw-romcode",
-       [OMAP_ECC_BCH4_CODE_HW]                 = "bch4",
-       [OMAP_ECC_BCH8_CODE_HW]                 = "bch8",
-};
-
 static const char * const nand_xfer_types[] = {
        [NAND_OMAP_PREFETCH_POLLED]             = "prefetch-polled",
        [NAND_OMAP_POLLED]                      = "polled",
        gpmc_nand_data->cs = val;
        gpmc_nand_data->of_node = child;
 
-       if (!of_property_read_string(child, "ti,nand-ecc-opt", &s))
-               for (val = 0; val < ARRAY_SIZE(nand_ecc_opts); val++)
-                       if (!strcasecmp(s, nand_ecc_opts[val])) {
-                               gpmc_nand_data->ecc_opt = val;
-                               break;
-                       }
+       /* Detect availability of ELM module */
+       gpmc_nand_data->elm_of_node = of_parse_phandle(child, "ti,elm-id", 0);
+       if (gpmc_nand_data->elm_of_node == NULL)
+               gpmc_nand_data->elm_of_node =
+                                       of_parse_phandle(child, "elm_id", 0);
+       if (gpmc_nand_data->elm_of_node == NULL)
+               pr_warn("%s: ti,elm-id property not found\n", __func__);
+
+       /* select ecc-scheme for NAND */
+       if (of_property_read_string(child, "ti,nand-ecc-opt", &s)) {
+               pr_err("%s: ti,nand-ecc-opt not found\n", __func__);
+               return -ENODEV;
+       }
+       if (!strcmp(s, "ham1") || !strcmp(s, "sw") ||
+               !strcmp(s, "hw") || !strcmp(s, "hw-romcode"))
+               gpmc_nand_data->ecc_opt =
+                               OMAP_ECC_HAM1_CODE_HW;
+       else if (!strcmp(s, "bch4"))
+               if (gpmc_nand_data->elm_of_node)
+                       gpmc_nand_data->ecc_opt =
+                               OMAP_ECC_BCH4_CODE_HW;
+               else
+                       gpmc_nand_data->ecc_opt =
+                               OMAP_ECC_BCH4_CODE_HW_DETECTION_SW;
+       else if (!strcmp(s, "bch8"))
+               if (gpmc_nand_data->elm_of_node)
+                       gpmc_nand_data->ecc_opt =
+                               OMAP_ECC_BCH8_CODE_HW;
+               else
+                       gpmc_nand_data->ecc_opt =
+                               OMAP_ECC_BCH8_CODE_HW_DETECTION_SW;
+       else
+               pr_err("%s: ti,nand-ecc-opt invalid value\n", __func__);
 
+       /* select data transfer mode for NAND controller */
        if (!of_property_read_string(child, "ti,nand-xfer-type", &s))
                for (val = 0; val < ARRAY_SIZE(nand_xfer_types); val++)
                        if (!strcasecmp(s, nand_xfer_types[val])) {
 
        OMAP_ECC_HAMMING_CODE_HW, /* gpmc to detect the error */
                /* 1-bit ecc: stored at beginning of spare area as romcode */
        OMAP_ECC_HAMMING_CODE_HW_ROMCODE, /* gpmc method & romcode layout */
-       OMAP_ECC_BCH4_CODE_HW, /* 4-bit BCH ecc code */
-       OMAP_ECC_BCH8_CODE_HW, /* 8-bit BCH ecc code */
+       /* 1-bit  ECC calculation by GPMC, Error detection by Software */
+       OMAP_ECC_HAM1_CODE_HW,
+       /* 4-bit  ECC calculation by GPMC, Error detection by Software */
+       OMAP_ECC_BCH4_CODE_HW_DETECTION_SW,
+       /* 4-bit  ECC calculation by GPMC, Error detection by ELM */
+       OMAP_ECC_BCH4_CODE_HW,
+       /* 8-bit  ECC calculation by GPMC, Error detection by Software */
+       OMAP_ECC_BCH8_CODE_HW_DETECTION_SW,
+       /* 8-bit  ECC calculation by GPMC, Error detection by ELM */
+       OMAP_ECC_BCH8_CODE_HW,
 };
 
 struct gpmc_nand_regs {
 
        /* for passing the partitions */
        struct device_node      *of_node;
+       struct device_node      *elm_of_node;
 };
 #endif