2 * (C) Copyright 2010-2011 Texas Instruments, <www.ti.com>
3 * Mansoor Ahamed <mansoor.ahamed@ti.com>
5 * Derived from work done by Rohit Choraria <rohitkc@ti.com> for omap3
7 * See file CREDITS for list of people who contributed to this
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License as
12 * published by the Free Software Foundation; either version 2 of
13 * the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
25 #ifndef __ASM_ARCH_OMAP_GPMC_H
26 #define __ASM_ARCH_OMAP_GPMC_H
28 #include <linux/mtd/nand.h>
30 #define GPMC_BUF_EMPTY 0
31 #define GPMC_BUF_FULL 1
33 #define ECCCLEAR (0x1 << 8)
34 #define ECCRESULTREG1 (0x1 << 0)
35 #define ECCSIZE512BYTE 0xFF
36 #define ECCSIZE1 (ECCSIZE512BYTE << 22)
37 #define ECCSIZE0 (ECCSIZE512BYTE << 12)
38 #define ECCSIZE0SEL (0x000 << 0)
40 /* Generic ECC Layouts */
41 /* Large Page x8 NAND device Layout */
42 #ifdef GPMC_NAND_ECC_LP_x8_LAYOUT
43 #define GPMC_NAND_HW_ECC_LAYOUT {\
45 .eccpos = {1, 2, 3, 4, 5, 6, 7, 8,\
53 /* Large Page x16 NAND device Layout */
54 #ifdef GPMC_NAND_ECC_LP_x16_LAYOUT
55 #define GPMC_NAND_HW_ECC_LAYOUT {\
57 .eccpos = {2, 3, 4, 5, 6, 7, 8, 9,\
65 /* NAND device layout in synch with the kernel */
66 #ifdef GPMC_NAND_ECC_LP_x16_LAYOUT
67 #define GPMC_NAND_HW_ECC_LAYOUT_KERNEL {\
70 40, 41, 42, 43, 44, 45, 46, 47,\
78 /* Small Page x8 NAND device Layout */
79 #ifdef GPMC_NAND_ECC_SP_x8_LAYOUT
80 #define GPMC_NAND_HW_ECC_LAYOUT {\
89 /* Small Page x16 NAND device Layout */
90 #ifdef GPMC_NAND_ECC_SP_x16_LAYOUT
91 #define GPMC_NAND_HW_ECC_LAYOUT {\
100 #define GPMC_NAND_HW_BCH4_ECC_LAYOUT {\
102 .eccpos = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,\
103 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,\
104 28, 29, 30, 31, 32, 33},\
110 #define GPMC_NAND_HW_BCH8_ECC_LAYOUT {\
112 .eccpos = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,\
113 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,\
114 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,\
115 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,\
116 52, 53, 54, 55, 56, 57},\
122 #define GPMC_NAND_HW_BCH16_ECC_LAYOUT {\
124 .eccpos = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,\
125 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,\
126 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,\
127 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,\
128 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,\
129 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75,\
130 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87,\
131 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99,\
132 100, 101, 102, 103, 104, 105},\
139 * ELM Module Registers
142 /* ELM registers bit fields */
143 #define ELM_SYSCONFIG_SOFTRESET_MASK (0x2)
144 #define ELM_SYSCONFIG_SOFTRESET (0x2)
145 #define ELM_SYSSTATUS_RESETDONE_MASK (0x1)
146 #define ELM_SYSSTATUS_RESETDONE (0x1)
147 #define ELM_LOCATION_CONFIG_ECC_BCH_LEVEL_MASK (0x3)
148 #define ELM_LOCATION_CONFIG_ECC_SIZE_MASK (0x7FF0000)
149 #define ELM_LOCATION_CONFIG_ECC_SIZE_POS (16)
150 #define ELM_SYNDROME_FRAGMENT_6_SYNDROME_VALID (0x00010000)
151 #define ELM_LOCATION_STATUS_ECC_CORRECTABLE_MASK (0x100)
152 #define ELM_LOCATION_STATUS_ECC_NB_ERRORS_MASK (0x1F)
154 #ifndef __KERNEL_STRICT_NAMES
164 /* BCH syndrome registers */
166 u32 syndrome_fragment_x[7]; /* 0x400, 0x404.... 0x418 */
167 u8 res1[36]; /* 0x41c */
170 /* BCH error status & location register */
172 u32 location_status; /* 0x800 */
173 u8 res1[124]; /* 0x804 */
174 u32 error_location_x[16]; /* 0x880.... */
175 u8 res2[64]; /* 0x8c0 */
178 /* BCH ELM register map - do not try to allocate memmory for this structure.
179 * We have used plenty of reserved variables to fill the slots in the ELM
180 * register memory map.
181 * Directly initialize the struct pointer to ELM base address.
185 u8 res1[12]; /* 0x004 */
186 u32 sysconfig; /* 0x010 */
187 u32 sysstatus; /* 0x014 */
188 u32 irqstatus; /* 0x018 */
189 u32 irqenable; /* 0x01c */
190 u32 location_config; /* 0x020 */
191 u8 res2[92]; /* 0x024 */
192 u32 page_ctrl; /* 0x080 */
193 u8 res3[892]; /* 0x084 */
194 struct syndrome syndrome_fragments[8]; /* 0x400 */
195 u8 res4[512]; /* 0x600 */
196 struct location error_location[8]; /* 0x800 */
199 int elm_check_error(u8 *syndrome, u32 nibbles, u32 *error_count,
200 u32 *error_locations);
201 int elm_config(enum bch_level level);
202 void elm_reset(void);
204 void am33xx_nand_switch_ecc(nand_ecc_modes_t hardware, int32_t mode);
205 #endif /* __ASSEMBLY__ */
206 #endif /* __KERNEL_STRICT_NAMES */
209 #endif /* __ASM_ARCH_OMAP_GPMC_H */