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