#define ATMEL_PMC_UHP          AT91SAM926x_PMC_UHP
 #define ATMEL_ID_UHP           ATMEL_ID_UHPHS
 
+/*
+ * PMECC table in ROM
+ */
+#define ATMEL_PMECC_INDEX_OFFSET_512   0x8000
+#define ATMEL_PMECC_INDEX_OFFSET_1024  0x10000
+
 /*
  * at91sam9x5 specific prototypes
  */
 
           It can be 2, 4, 8, 12 or 24.
        2. The PMECC sector size: CONFIG_PMECC_SECTOR_SIZE.
           It only can be 512 or 1024.
-       3. The PMECC index lookup table's offsets in ROM code: CONFIG_PMECC_INDEX_TABLE_OFFSET.
-          In the chip datasheet section "Boot Stragegies", you can find
-          two Galois Field Table in the ROM code. One table is for 512-bytes
-          sector. Another is for 1024-byte sector. Each Galois Field includes
-          two sub-table: indext table & alpha table.
-          In the beginning of each Galois Field Table is the index table,
-          Alpha table is in the following.
-          So the index table's offset is same as the Galois Field Table.
-
-          Please set CONFIG_PMECC_INDEX_TABLE_OFFSET correctly according the
-          Galois Field Table's offset base on the sector size you used.
 
 Take AT91SAM9X5EK as an example, the board definition file likes:
 
 #define CONFIG_ATMEL_NAND_HW_PMECC     1
 #define CONFIG_PMECC_CAP               2
 #define CONFIG_PMECC_SECTOR_SIZE       512
-#define CONFIG_PMECC_INDEX_TABLE_OFFSET        0x8000
 
-NOTE: If you use 1024 as the sector size, then need set 0x10000 as the
- CONFIG_PMECC_INDEX_TABLE_OFFSET
 
 
        cap = host->pmecc_corr_cap = CONFIG_PMECC_CAP;
        sector_size = host->pmecc_sector_size = CONFIG_PMECC_SECTOR_SIZE;
-       host->pmecc_index_table_offset = CONFIG_PMECC_INDEX_TABLE_OFFSET;
+       if (host->pmecc_sector_size == 512)
+               host->pmecc_index_table_offset = ATMEL_PMECC_INDEX_OFFSET_512;
+       else
+               host->pmecc_index_table_offset = ATMEL_PMECC_INDEX_OFFSET_1024;
 
        MTDDEBUG(MTD_DEBUG_LEVEL1,
                "Initialize PMECC params, cap: %d, sector: %d\n",
 
 #define CONFIG_ATMEL_NAND_HW_PMECC     1
 #define CONFIG_PMECC_CAP               2
 #define CONFIG_PMECC_SECTOR_SIZE       512
-#define CONFIG_PMECC_INDEX_TABLE_OFFSET        0x8000
 
 #define CONFIG_CMD_NAND_TRIMFFS
 
 
 #define CONFIG_ATMEL_NAND_HW_PMECC
 #define CONFIG_PMECC_CAP               4
 #define CONFIG_PMECC_SECTOR_SIZE       512
-#define CONFIG_PMECC_INDEX_TABLE_OFFSET        ATMEL_PMECC_INDEX_OFFSET_512
 #define CONFIG_CMD_NAND_TRIMFFS
 #endif