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