summaryrefslogtreecommitdiff
path: root/board/aspeed/ast2400/regtest.c
blob: 1cd75aea806e40636f3e7abfadcd9dac8f4552ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/*
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 * MA 02111-1307 USA
 */

/*
 * Diagnostics support
 */
#include <common.h>
#include <command.h>
#include <post.h>
#include "slt.h"

#if ((CFG_CMD_SLT & CFG_CMD_REGTEST) && defined(CONFIG_SLT))
#include "regtest.h"

int do_regtest (void)
{
	_SOCRegTestInfo	*pjSOCRegInfo;
	_SOCRegTestTbl *pjRegTable;
	unsigned long ulRegBase;
        unsigned long ulIndex, ulBack, ulAND, ulMask, ulData, ulTemp;
        unsigned long Flags = 0;
	
	/* unlock reg */
        *(unsigned long *) (0x1e600000) = 0xaeed1a03;	/* AHBC */
        *(unsigned long *) (0x1e6e0000) = 0xfc600309;	/* MMC */
        *(unsigned long *) (0x1e6e2000) = 0x1688a8a8;	/* SCU */

        /* SCU */

        /* do test */	
        pjSOCRegInfo = SOCRegTestInfo;
        while (strcmp(pjSOCRegInfo->jName, "END"))
        {
            /* Reg. Test Start */
            ulRegBase = pjSOCRegInfo->ulRegOffset;
            pjRegTable = pjSOCRegInfo->pjTblIndex;
            
            while (pjRegTable->ulIndex != 0xFFFFFFFF)
            {
                ulIndex = ulRegBase + pjRegTable->ulIndex;	

                ulBack = *(unsigned long *) (ulIndex);

                ulMask  = pjRegTable->ulMask;
                ulAND  = ~pjRegTable->ulMask;
       	        	    	
                ulData  = 0xFFFFFFFF & pjRegTable->ulMask;
                *(unsigned long *) (ulIndex) = ulData;                
                ulTemp = *(volatile unsigned long *) (ulIndex) & pjRegTable->ulMask;
                if (ulData != ulTemp)
                {
                    Flags |= pjSOCRegInfo->ulFlags;
                    printf("[DBG] RegTest: Failed Index:%x, Data:%x, Temp:%x \n", ulIndex, ulData, ulTemp);
                }
                
                ulData  = 0x00000000 & pjRegTable->ulMask;
                *(unsigned long *) (ulIndex) = ulData;                
                ulTemp = *(volatile unsigned long *) (ulIndex) & pjRegTable->ulMask;
                if (ulData != ulTemp)
                {
                    Flags |= pjSOCRegInfo->ulFlags;
                    printf("[DBG] RegTest: Failed Index:%x, Data:%x, Temp:%x \n", ulIndex, ulData, ulTemp);
                }
                             
                *(unsigned long *) (ulIndex) = ulBack;
       
                pjRegTable++;
          	
           } /* Individual Reg. Test */

           if (Flags & pjSOCRegInfo->ulFlags)
               printf("[INFO] RegTest: %s Failed \n", pjSOCRegInfo->jName);
           
           pjSOCRegInfo++;
           
        } /* Reg. Test */

	return Flags;
	
}

#endif /* CONFIG_SLT */