blob: f3db00d55de30601aff0f07d89340d9fa0e4b0c2 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Mansoor Ahamed59e38b42012-11-06 13:06:32 +00002/*
3 * (C) Copyright 2010-2011 Texas Instruments, <www.ti.com>
4 * Mansoor Ahamed <mansoor.ahamed@ti.com>
5 *
6 * Derived from work done by Rohit Choraria <rohitkc@ti.com> for omap3
Mansoor Ahamed59e38b42012-11-06 13:06:32 +00007 */
8#ifndef __ASM_ARCH_ELM_H
9#define __ASM_ARCH_ELM_H
10/*
11 * ELM Module Registers
12 */
13
14/* ELM registers bit fields */
15#define ELM_SYSCONFIG_SOFTRESET_MASK (0x2)
16#define ELM_SYSCONFIG_SOFTRESET (0x2)
17#define ELM_SYSSTATUS_RESETDONE_MASK (0x1)
18#define ELM_SYSSTATUS_RESETDONE (0x1)
19#define ELM_LOCATION_CONFIG_ECC_BCH_LEVEL_MASK (0x3)
20#define ELM_LOCATION_CONFIG_ECC_SIZE_MASK (0x7FF0000)
21#define ELM_LOCATION_CONFIG_ECC_SIZE_POS (16)
22#define ELM_SYNDROME_FRAGMENT_6_SYNDROME_VALID (0x00010000)
23#define ELM_LOCATION_STATUS_ECC_CORRECTABLE_MASK (0x100)
24#define ELM_LOCATION_STATUS_ECC_NB_ERRORS_MASK (0x1F)
25
pekon gupta28bcab02014-04-11 12:55:31 +053026#define ELM_MAX_CHANNELS 8
27#define ELM_MAX_ERROR_COUNT 16
28
Mansoor Ahamed59e38b42012-11-06 13:06:32 +000029#ifndef __ASSEMBLY__
30
31enum bch_level {
32 BCH_4_BIT = 0,
33 BCH_8_BIT,
34 BCH_16_BIT
35};
36
37
38/* BCH syndrome registers */
39struct syndrome {
40 u32 syndrome_fragment_x[7]; /* 0x400, 0x404.... 0x418 */
41 u8 res1[36]; /* 0x41c */
42};
43
44/* BCH error status & location register */
45struct location {
46 u32 location_status; /* 0x800 */
47 u8 res1[124]; /* 0x804 */
pekon gupta28bcab02014-04-11 12:55:31 +053048 u32 error_location_x[ELM_MAX_ERROR_COUNT]; /* 0x880, 0x980, .. */
Mansoor Ahamed59e38b42012-11-06 13:06:32 +000049 u8 res2[64]; /* 0x8c0 */
50};
51
52/* BCH ELM register map - do not try to allocate memmory for this structure.
53 * We have used plenty of reserved variables to fill the slots in the ELM
54 * register memory map.
55 * Directly initialize the struct pointer to ELM base address.
56 */
57struct elm {
58 u32 rev; /* 0x000 */
59 u8 res1[12]; /* 0x004 */
60 u32 sysconfig; /* 0x010 */
61 u32 sysstatus; /* 0x014 */
62 u32 irqstatus; /* 0x018 */
63 u32 irqenable; /* 0x01c */
64 u32 location_config; /* 0x020 */
65 u8 res2[92]; /* 0x024 */
66 u32 page_ctrl; /* 0x080 */
67 u8 res3[892]; /* 0x084 */
pekon gupta28bcab02014-04-11 12:55:31 +053068 struct syndrome syndrome_fragments[ELM_MAX_CHANNELS]; /* 0x400,0x420 */
Mansoor Ahamed59e38b42012-11-06 13:06:32 +000069 u8 res4[512]; /* 0x600 */
pekon gupta28bcab02014-04-11 12:55:31 +053070 struct location error_location[ELM_MAX_CHANNELS]; /* 0x800,0x900 ... */
Mansoor Ahamed59e38b42012-11-06 13:06:32 +000071};
72
pekon guptadcd24112014-04-11 12:55:30 +053073int elm_check_error(u8 *syndrome, enum bch_level bch_type, u32 *error_count,
Mansoor Ahamed59e38b42012-11-06 13:06:32 +000074 u32 *error_locations);
75int elm_config(enum bch_level level);
76void elm_reset(void);
77void elm_init(void);
78#endif /* __ASSEMBLY__ */
79#endif /* __ASM_ARCH_ELM_H */