xref: /openbmc/u-boot/include/linux/mtd/omap_elm.h (revision e8f80a5a)
1*83d290c5STom Rini /* SPDX-License-Identifier: GPL-2.0+ */
22eda892fSpekon gupta /*
32eda892fSpekon gupta  * (C) Copyright 2010-2011 Texas Instruments, <www.ti.com>
42eda892fSpekon gupta  * Mansoor Ahamed <mansoor.ahamed@ti.com>
52eda892fSpekon gupta  *
62eda892fSpekon gupta  * Derived from work done by Rohit Choraria <rohitkc@ti.com> for omap3
72eda892fSpekon gupta  */
82eda892fSpekon gupta #ifndef __ASM_ARCH_ELM_H
92eda892fSpekon gupta #define __ASM_ARCH_ELM_H
102eda892fSpekon gupta /*
112eda892fSpekon gupta  * ELM Module Registers
122eda892fSpekon gupta  */
132eda892fSpekon gupta 
142eda892fSpekon gupta /* ELM registers bit fields */
152eda892fSpekon gupta #define ELM_SYSCONFIG_SOFTRESET_MASK			(0x2)
162eda892fSpekon gupta #define ELM_SYSCONFIG_SOFTRESET			(0x2)
172eda892fSpekon gupta #define ELM_SYSSTATUS_RESETDONE_MASK			(0x1)
182eda892fSpekon gupta #define ELM_SYSSTATUS_RESETDONE			(0x1)
192eda892fSpekon gupta #define ELM_LOCATION_CONFIG_ECC_BCH_LEVEL_MASK		(0x3)
202eda892fSpekon gupta #define ELM_LOCATION_CONFIG_ECC_SIZE_MASK		(0x7FF0000)
212eda892fSpekon gupta #define ELM_LOCATION_CONFIG_ECC_SIZE_POS		(16)
222eda892fSpekon gupta #define ELM_SYNDROME_FRAGMENT_6_SYNDROME_VALID		(0x00010000)
232eda892fSpekon gupta #define ELM_LOCATION_STATUS_ECC_CORRECTABLE_MASK	(0x100)
242eda892fSpekon gupta #define ELM_LOCATION_STATUS_ECC_NB_ERRORS_MASK		(0x1F)
252eda892fSpekon gupta 
260439d752Spekon gupta #define ELM_MAX_CHANNELS				8
270439d752Spekon gupta #define ELM_MAX_ERROR_COUNT				16
280439d752Spekon gupta 
292eda892fSpekon gupta #ifndef __ASSEMBLY__
302eda892fSpekon gupta 
312eda892fSpekon gupta enum bch_level {
322eda892fSpekon gupta 	BCH_4_BIT = 0,
332eda892fSpekon gupta 	BCH_8_BIT,
342eda892fSpekon gupta 	BCH_16_BIT
352eda892fSpekon gupta };
362eda892fSpekon gupta 
372eda892fSpekon gupta 
382eda892fSpekon gupta /* BCH syndrome registers */
392eda892fSpekon gupta struct syndrome {
402eda892fSpekon gupta 	u32 syndrome_fragment_x[7];	/* 0x400, 0x404.... 0x418 */
412eda892fSpekon gupta 	u8 res1[36];			/* 0x41c */
422eda892fSpekon gupta };
432eda892fSpekon gupta 
442eda892fSpekon gupta /* BCH error status & location register */
452eda892fSpekon gupta struct location {
462eda892fSpekon gupta 	u32 location_status;		/* 0x800 */
472eda892fSpekon gupta 	u8 res1[124];			/* 0x804 */
480439d752Spekon gupta 	u32 error_location_x[ELM_MAX_ERROR_COUNT]; /* 0x880, 0x980, .. */
492eda892fSpekon gupta 	u8 res2[64];			/* 0x8c0 */
502eda892fSpekon gupta };
512eda892fSpekon gupta 
522eda892fSpekon gupta /* BCH ELM register map - do not try to allocate memmory for this structure.
532eda892fSpekon gupta  * We have used plenty of reserved variables to fill the slots in the ELM
542eda892fSpekon gupta  * register memory map.
552eda892fSpekon gupta  * Directly initialize the struct pointer to ELM base address.
562eda892fSpekon gupta  */
572eda892fSpekon gupta struct elm {
582eda892fSpekon gupta 	u32 rev;				/* 0x000 */
592eda892fSpekon gupta 	u8 res1[12];				/* 0x004 */
602eda892fSpekon gupta 	u32 sysconfig;				/* 0x010 */
612eda892fSpekon gupta 	u32 sysstatus;				/* 0x014 */
622eda892fSpekon gupta 	u32 irqstatus;				/* 0x018 */
632eda892fSpekon gupta 	u32 irqenable;				/* 0x01c */
642eda892fSpekon gupta 	u32 location_config;			/* 0x020 */
652eda892fSpekon gupta 	u8 res2[92];				/* 0x024 */
662eda892fSpekon gupta 	u32 page_ctrl;				/* 0x080 */
672eda892fSpekon gupta 	u8 res3[892];				/* 0x084 */
680439d752Spekon gupta 	struct  syndrome syndrome_fragments[ELM_MAX_CHANNELS]; /* 0x400,0x420 */
692eda892fSpekon gupta 	u8 res4[512];				/* 0x600 */
700439d752Spekon gupta 	struct location  error_location[ELM_MAX_CHANNELS]; /* 0x800,0x900 ... */
712eda892fSpekon gupta };
722eda892fSpekon gupta 
7341bbe4ddSpekon gupta int elm_check_error(u8 *syndrome, enum bch_level bch_type, u32 *error_count,
742eda892fSpekon gupta 		u32 *error_locations);
752eda892fSpekon gupta int elm_config(enum bch_level level);
762eda892fSpekon gupta void elm_reset(void);
772eda892fSpekon gupta void elm_init(void);
782eda892fSpekon gupta #endif /* __ASSEMBLY__ */
792eda892fSpekon gupta #endif /* __ASM_ARCH_ELM_H */
80