blob: b8096b02e37319039059e857ce04fe50f075c72b [file] [log] [blame]
Mansoor Ahamed04c37572012-11-06 13:06:32 +00001/*
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 *
Wolfgang Denk1a459662013-07-08 09:37:19 +02007 * SPDX-License-Identifier: GPL-2.0+
Mansoor Ahamed04c37572012-11-06 13:06:32 +00008 */
9#ifndef __ASM_ARCH_ELM_H
10#define __ASM_ARCH_ELM_H
11/*
12 * ELM Module Registers
13 */
14
15/* ELM registers bit fields */
16#define ELM_SYSCONFIG_SOFTRESET_MASK (0x2)
17#define ELM_SYSCONFIG_SOFTRESET (0x2)
18#define ELM_SYSSTATUS_RESETDONE_MASK (0x1)
19#define ELM_SYSSTATUS_RESETDONE (0x1)
20#define ELM_LOCATION_CONFIG_ECC_BCH_LEVEL_MASK (0x3)
21#define ELM_LOCATION_CONFIG_ECC_SIZE_MASK (0x7FF0000)
22#define ELM_LOCATION_CONFIG_ECC_SIZE_POS (16)
23#define ELM_SYNDROME_FRAGMENT_6_SYNDROME_VALID (0x00010000)
24#define ELM_LOCATION_STATUS_ECC_CORRECTABLE_MASK (0x100)
25#define ELM_LOCATION_STATUS_ECC_NB_ERRORS_MASK (0x1F)
26
pekon gupta0439d752014-04-11 12:55:31 +053027#define ELM_MAX_CHANNELS 8
28#define ELM_MAX_ERROR_COUNT 16
29
Mansoor Ahamed04c37572012-11-06 13:06:32 +000030#ifndef __ASSEMBLY__
31
32enum bch_level {
33 BCH_4_BIT = 0,
34 BCH_8_BIT,
35 BCH_16_BIT
36};
37
38
39/* BCH syndrome registers */
40struct syndrome {
41 u32 syndrome_fragment_x[7]; /* 0x400, 0x404.... 0x418 */
42 u8 res1[36]; /* 0x41c */
43};
44
45/* BCH error status & location register */
46struct location {
47 u32 location_status; /* 0x800 */
48 u8 res1[124]; /* 0x804 */
pekon gupta0439d752014-04-11 12:55:31 +053049 u32 error_location_x[ELM_MAX_ERROR_COUNT]; /* 0x880, 0x980, .. */
Mansoor Ahamed04c37572012-11-06 13:06:32 +000050 u8 res2[64]; /* 0x8c0 */
51};
52
53/* BCH ELM register map - do not try to allocate memmory for this structure.
54 * We have used plenty of reserved variables to fill the slots in the ELM
55 * register memory map.
56 * Directly initialize the struct pointer to ELM base address.
57 */
58struct elm {
59 u32 rev; /* 0x000 */
60 u8 res1[12]; /* 0x004 */
61 u32 sysconfig; /* 0x010 */
62 u32 sysstatus; /* 0x014 */
63 u32 irqstatus; /* 0x018 */
64 u32 irqenable; /* 0x01c */
65 u32 location_config; /* 0x020 */
66 u8 res2[92]; /* 0x024 */
67 u32 page_ctrl; /* 0x080 */
68 u8 res3[892]; /* 0x084 */
pekon gupta0439d752014-04-11 12:55:31 +053069 struct syndrome syndrome_fragments[ELM_MAX_CHANNELS]; /* 0x400,0x420 */
Mansoor Ahamed04c37572012-11-06 13:06:32 +000070 u8 res4[512]; /* 0x600 */
pekon gupta0439d752014-04-11 12:55:31 +053071 struct location error_location[ELM_MAX_CHANNELS]; /* 0x800,0x900 ... */
Mansoor Ahamed04c37572012-11-06 13:06:32 +000072};
73
pekon gupta41bbe4d2014-04-11 12:55:30 +053074int elm_check_error(u8 *syndrome, enum bch_level bch_type, u32 *error_count,
Mansoor Ahamed04c37572012-11-06 13:06:32 +000075 u32 *error_locations);
76int elm_config(enum bch_level level);
77void elm_reset(void);
78void elm_init(void);
79#endif /* __ASSEMBLY__ */
80#endif /* __ASM_ARCH_ELM_H */