Mansoor Ahamed | 59e38b4 | 2012-11-06 13:06:32 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2010-2011 Texas Instruments, <www.ti.com> |
| 3 | * Mansoor Ahamed <mansoor.ahamed@ti.com> |
| 4 | * |
| 5 | * Derived from work done by Rohit Choraria <rohitkc@ti.com> for omap3 |
| 6 | * |
| 7 | * See file CREDITS for list of people who contributed to this |
| 8 | * project. |
| 9 | * |
| 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. |
| 14 | * |
| 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. |
| 19 | * |
| 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, |
| 23 | * MA 02111-1307 USA |
| 24 | */ |
| 25 | #ifndef __ASM_ARCH_ELM_H |
| 26 | #define __ASM_ARCH_ELM_H |
| 27 | /* |
| 28 | * ELM Module Registers |
| 29 | */ |
| 30 | |
| 31 | /* ELM registers bit fields */ |
| 32 | #define ELM_SYSCONFIG_SOFTRESET_MASK (0x2) |
| 33 | #define ELM_SYSCONFIG_SOFTRESET (0x2) |
| 34 | #define ELM_SYSSTATUS_RESETDONE_MASK (0x1) |
| 35 | #define ELM_SYSSTATUS_RESETDONE (0x1) |
| 36 | #define ELM_LOCATION_CONFIG_ECC_BCH_LEVEL_MASK (0x3) |
| 37 | #define ELM_LOCATION_CONFIG_ECC_SIZE_MASK (0x7FF0000) |
| 38 | #define ELM_LOCATION_CONFIG_ECC_SIZE_POS (16) |
| 39 | #define ELM_SYNDROME_FRAGMENT_6_SYNDROME_VALID (0x00010000) |
| 40 | #define ELM_LOCATION_STATUS_ECC_CORRECTABLE_MASK (0x100) |
| 41 | #define ELM_LOCATION_STATUS_ECC_NB_ERRORS_MASK (0x1F) |
| 42 | |
| 43 | #ifndef __ASSEMBLY__ |
| 44 | |
| 45 | enum bch_level { |
| 46 | BCH_4_BIT = 0, |
| 47 | BCH_8_BIT, |
| 48 | BCH_16_BIT |
| 49 | }; |
| 50 | |
| 51 | |
| 52 | /* BCH syndrome registers */ |
| 53 | struct syndrome { |
| 54 | u32 syndrome_fragment_x[7]; /* 0x400, 0x404.... 0x418 */ |
| 55 | u8 res1[36]; /* 0x41c */ |
| 56 | }; |
| 57 | |
| 58 | /* BCH error status & location register */ |
| 59 | struct location { |
| 60 | u32 location_status; /* 0x800 */ |
| 61 | u8 res1[124]; /* 0x804 */ |
| 62 | u32 error_location_x[16]; /* 0x880.... */ |
| 63 | u8 res2[64]; /* 0x8c0 */ |
| 64 | }; |
| 65 | |
| 66 | /* BCH ELM register map - do not try to allocate memmory for this structure. |
| 67 | * We have used plenty of reserved variables to fill the slots in the ELM |
| 68 | * register memory map. |
| 69 | * Directly initialize the struct pointer to ELM base address. |
| 70 | */ |
| 71 | struct elm { |
| 72 | u32 rev; /* 0x000 */ |
| 73 | u8 res1[12]; /* 0x004 */ |
| 74 | u32 sysconfig; /* 0x010 */ |
| 75 | u32 sysstatus; /* 0x014 */ |
| 76 | u32 irqstatus; /* 0x018 */ |
| 77 | u32 irqenable; /* 0x01c */ |
| 78 | u32 location_config; /* 0x020 */ |
| 79 | u8 res2[92]; /* 0x024 */ |
| 80 | u32 page_ctrl; /* 0x080 */ |
| 81 | u8 res3[892]; /* 0x084 */ |
| 82 | struct syndrome syndrome_fragments[8]; /* 0x400 */ |
| 83 | u8 res4[512]; /* 0x600 */ |
| 84 | struct location error_location[8]; /* 0x800 */ |
| 85 | }; |
| 86 | |
| 87 | int elm_check_error(u8 *syndrome, u32 nibbles, u32 *error_count, |
| 88 | u32 *error_locations); |
| 89 | int elm_config(enum bch_level level); |
| 90 | void elm_reset(void); |
| 91 | void elm_init(void); |
| 92 | #endif /* __ASSEMBLY__ */ |
| 93 | #endif /* __ASM_ARCH_ELM_H */ |