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