2 * Error Corrected Code Controller (ECC) - System peripherals regsters.
3 * Based on AT91SAM9260 datasheet revision B.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version.
11 #ifndef ATMEL_NAND_ECC_H
12 #define ATMEL_NAND_ECC_H
14 #define ATMEL_ECC_CR 0x00 /* Control register */
15 #define ATMEL_ECC_RST (1 << 0) /* Reset parity */
17 #define ATMEL_ECC_MR 0x04 /* Mode register */
18 #define ATMEL_ECC_PAGESIZE (3 << 0) /* Page Size */
19 #define ATMEL_ECC_PAGESIZE_528 (0)
20 #define ATMEL_ECC_PAGESIZE_1056 (1)
21 #define ATMEL_ECC_PAGESIZE_2112 (2)
22 #define ATMEL_ECC_PAGESIZE_4224 (3)
24 #define ATMEL_ECC_SR 0x08 /* Status register */
25 #define ATMEL_ECC_RECERR (1 << 0) /* Recoverable Error */
26 #define ATMEL_ECC_ECCERR (1 << 1) /* ECC Single Bit Error */
27 #define ATMEL_ECC_MULERR (1 << 2) /* Multiple Errors */
29 #define ATMEL_ECC_PR 0x0c /* Parity register */
30 #define ATMEL_ECC_BITADDR (0xf << 0) /* Bit Error Address */
31 #define ATMEL_ECC_WORDADDR (0xfff << 4) /* Word Error Address */
33 #define ATMEL_ECC_NPR 0x10 /* NParity register */
34 #define ATMEL_ECC_NPARITY (0xffff << 0) /* NParity */
36 /* Register access macros for PMECC */
37 #define pmecc_readl(addr, reg) \
40 #define pmecc_writel(addr, reg, value) \
41 writel((value), &addr->reg)
43 /* PMECC Register Definitions */
44 #define PMECC_MAX_SECTOR_NUM 8
46 u32 cfg; /* 0x00 PMECC Configuration Register */
47 u32 sarea; /* 0x04 PMECC Spare Area Size Register */
48 u32 saddr; /* 0x08 PMECC Start Address Register */
49 u32 eaddr; /* 0x0C PMECC End Address Register */
50 u32 clk; /* 0x10 PMECC Clock Control Register */
51 u32 ctrl; /* 0x14 PMECC Control Register */
52 u32 sr; /* 0x18 PMECC Status Register */
53 u32 ier; /* 0x1C PMECC Interrupt Enable Register */
54 u32 idr; /* 0x20 PMECC Interrupt Disable Register */
55 u32 imr; /* 0x24 PMECC Interrupt Mask Register */
56 u32 isr; /* 0x28 PMECC Interrupt Status Register */
57 u32 reserved0[5]; /* 0x2C-0x3C Reserved */
59 /* 0x40 + sector_num * (0x40), Redundancy Registers */
61 u8 ecc[44]; /* PMECC Generated Redundancy Byte Per Sector */
63 } ecc_port[PMECC_MAX_SECTOR_NUM];
65 /* 0x240 + sector_num * (0x40) Remainder Registers */
69 } rem_port[PMECC_MAX_SECTOR_NUM];
70 u32 reserved3[16]; /* 0x440-0x47C Reserved */
73 /* For PMECC Configuration Register */
74 #define PMECC_CFG_BCH_ERR2 (0 << 0)
75 #define PMECC_CFG_BCH_ERR4 (1 << 0)
76 #define PMECC_CFG_BCH_ERR8 (2 << 0)
77 #define PMECC_CFG_BCH_ERR12 (3 << 0)
78 #define PMECC_CFG_BCH_ERR24 (4 << 0)
80 #define PMECC_CFG_SECTOR512 (0 << 4)
81 #define PMECC_CFG_SECTOR1024 (1 << 4)
83 #define PMECC_CFG_PAGE_1SECTOR (0 << 8)
84 #define PMECC_CFG_PAGE_2SECTORS (1 << 8)
85 #define PMECC_CFG_PAGE_4SECTORS (2 << 8)
86 #define PMECC_CFG_PAGE_8SECTORS (3 << 8)
88 #define PMECC_CFG_READ_OP (0 << 12)
89 #define PMECC_CFG_WRITE_OP (1 << 12)
91 #define PMECC_CFG_SPARE_ENABLE (1 << 16)
92 #define PMECC_CFG_SPARE_DISABLE (0 << 16)
94 #define PMECC_CFG_AUTO_ENABLE (1 << 20)
95 #define PMECC_CFG_AUTO_DISABLE (0 << 20)
97 /* For PMECC Clock Control Register */
98 #define PMECC_CLK_133MHZ (2 << 0)
100 /* For PMECC Control Register */
101 #define PMECC_CTRL_RST (1 << 0)
102 #define PMECC_CTRL_DATA (1 << 1)
103 #define PMECC_CTRL_USER (1 << 2)
104 #define PMECC_CTRL_ENABLE (1 << 4)
105 #define PMECC_CTRL_DISABLE (1 << 5)
107 /* For PMECC Status Register */
108 #define PMECC_SR_BUSY (1 << 0)
109 #define PMECC_SR_ENABLE (1 << 4)
111 /* PMERRLOC Register Definitions */
112 struct pmecc_errloc_regs {
113 u32 elcfg; /* 0x00 Error Location Configuration Register */
114 u32 elprim; /* 0x04 Error Location Primitive Register */
115 u32 elen; /* 0x08 Error Location Enable Register */
116 u32 eldis; /* 0x0C Error Location Disable Register */
117 u32 elsr; /* 0x10 Error Location Status Register */
118 u32 elier; /* 0x14 Error Location Interrupt Enable Register */
119 u32 elidr; /* 0x08 Error Location Interrupt Disable Register */
120 u32 elimr; /* 0x0C Error Location Interrupt Mask Register */
121 u32 elisr; /* 0x20 Error Location Interrupt Status Register */
122 u32 reserved0; /* 0x24 Reserved */
123 u32 sigma[25]; /* 0x28-0x88 Error Location Sigma Registers */
124 u32 el[24]; /* 0x8C-0xE8 Error Location Registers */
125 u32 reserved1[5]; /* 0xEC-0xFC Reserved */
128 /* For Error Location Configuration Register */
129 #define PMERRLOC_ELCFG_SECTOR_512 (0 << 0)
130 #define PMERRLOC_ELCFG_SECTOR_1024 (1 << 0)
131 #define PMERRLOC_ELCFG_NUM_ERRORS(n) ((n) << 16)
133 /* For Error Location Disable Register */
134 #define PMERRLOC_DISABLE (1 << 0)
136 /* For Error Location Interrupt Status Register */
137 #define PMERRLOC_ERR_NUM_MASK (0x1f << 8)
138 #define PMERRLOC_CALC_DONE (1 << 0)
140 /* Galois field dimension */
141 #define PMECC_GF_DIMENSION_13 13
142 #define PMECC_GF_DIMENSION_14 14
144 #define PMECC_INDEX_TABLE_SIZE_512 0x2000
145 #define PMECC_INDEX_TABLE_SIZE_1024 0x4000
147 #define PMECC_MAX_TIMEOUT_US (100 * 1000)