rk: ion: resolve build err
[firefly-linux-kernel-4.4.55.git] / drivers / gpu / arm / t6xx / kbase / src / integration_kit / sim4_t760_run.c
1 /*----------------------------------------------------------------------------
2 *
3 * The confidential and proprietary information contained in this file may
4 * only be used by a person authorised under and to the extent permitted
5 * by a subsisting licensing agreement from ARM Limited.
6 *
7 *        (C) COPYRIGHT 2008-2009,2011-2013 ARM Limited.
8 *             ALL RIGHTS RESERVED
9 *             
10 * This entire notice must be reproduced on all copies of this file
11 * and copies of this file may only be made by a person if such person is
12 * permitted to do so under the terms of a subsisting license agreement
13 * from ARM Limited.
14 *
15 * Modified  : $Date: 2013-08-01 18:15:13 +0100 (Thu, 01 Aug 2013) $
16 * Revision  : $Revision: 66689 $
17 * Release   : $State: $
18 *-----------------------------------------------------------------------------*/
19
20 /* 
21
22 BRIEF DESCRIPTION, PURPOSE AND STRATEGY
23 =======================================
24
25 This test checks that the GPU's different power domains can be turned on and off.
26
27 It makes sure the power on or off status corresponds to the relevant domain's READY status.
28
29
30 DEBUG HINTS IN CASE OF FAILURE
31 ===========================
32 a) Check the APB bus connections as this is the bus that is used to communicate with the Job manager.
33 b) Check that the GPU's reset signal is not asserted.
34 c) Check that the GPU input clock is toggling as expected.
35 d) Check that the DFT signals are disabled.
36 e) Check that MBIST is disabled.
37
38 */
39
40 #include "MaliFns.h"
41 #include "MaliDefines-t760.h"
42
43 int RunMaliTest_sim4_t760_part0 (void);
44
45 static int mali_step;
46 static int Mali_test_reg(int unit, int core, int regnum, int read_mask, int write_mask, int reset_value, int access);
47
48 int RunMaliTest_sim4_t760 (int *base) {
49         
50         Mali_SetBase(base);
51         RunMaliTest_sim4_t760_part0();
52   
53 };
54 #define printf printk
55 int RunMaliTest_sim4_t760_part0 (void) {
56   int res = 0;
57
58   int gpuid, num_cores, l2_size, axi_width, i, as_present, js_present, core_bitmap;
59
60   printf("RUNNING TEST: sim4\n");
61   printf("  Purpose: Check APB register accesses\n");
62   printf("  Will check register read/write and reset value\n");
63
64   // Get current configuration to allow testing all registers
65   gpuid         = Mali_RdReg(0x20, 0, 0x0000);
66   core_bitmap   = Mali_RdReg(0x20, 0, 0x0100);
67   l2_size       = ((Mali_RdReg(0x20, 0, 0x0004) >> 16) & 0xFF);
68   axi_width     = (1 <<((Mali_RdReg(0x20, 0, 0x0004) >> 24) & 0xFF));
69   as_present    = Mali_RdReg(0x20, 0, 0x0018);
70   js_present    = Mali_RdReg(0x20, 0, 0x001c);
71
72   i = core_bitmap;
73   num_cores = 0;
74   while(i) {
75     num_cores++;
76     i >>= 1;
77   }
78   printf("Selected configuration:\n");
79   printf("  Bus width: %d\n", axi_width);
80   printf("  Number of shader cores: %d\n", num_cores);
81   printf("  L2 cache size: %d kB\n", ((1<<l2_size)/1024));
82
83   res |= Mali_test_reg(0, 0, 0x000, 0xffff0000, 0xffff0000, GPU_ID_VALUE, 1); /* GPU_ID */
84   res |= Mali_test_reg(0, 0, 0x100, 0xffffffff, 0xffffffff,  core_bitmap, 1); /* SHADER_PRESENT_LO */
85   res |= Mali_test_reg(0, 0, 0x110, 0xffffffff, 0xffffffff, 0x00000001, 1); /* TILER_PRESENT_LO */
86
87 #if MALI == t760
88   /* T760 has only one logical L2C */
89   res |= Mali_test_reg (0, 0, 0x120, 0xffffffff, 0xffffffff, 0x00000001, 1); /* L2_PRESENT_LO */
90 #else
91   if (num_cores>=6)
92   { /* T608 MP6 and T608 MP8 have two L2Cs*/
93     res |= Mali_test_reg (0, 0, 0x120, 0xffffffff, 0xffffffff, 0x00000011, 1); /* L2_PRESENT_LO */
94   }
95   else
96   {
97     res |= Mali_test_reg (0, 0, 0x120, 0xffffffff, 0xffffffff, 0x00000001, 1); /* L2_PRESENT_LO */
98   }
99 #endif
100
101   res |= Mali_test_reg(0, 0, 0x140, 0xffffffff, 0xffffffff, 0x00000000, 1); /* SHADER_READY_LO */
102   res |= Mali_test_reg(0, 0, 0x150, 0xffffffff, 0xffffffff, 0x00000000, 1); /* TILER_READY_LO */
103   res |= Mali_test_reg(0, 0, 0x160, 0xffffffff, 0xffffffff, 0x00000000, 1); /* L2_READY_LO */
104   for(i=0; i<num_cores; i++) {
105     printf("Power on/off shader core #%d\n", i);
106     Mali_WrReg(0, 0, 0x180, (1<<i)); /* SHADER_PWRON_LO */
107     while( Mali_RdReg(0, 0, 0x200) ) {}
108     res |= Mali_test_reg(0, 0, 0x140, 0xffffffff, 0xffffffff, (1<<i), 1); /* SHADER_READY_LO */
109     Mali_WrReg(0, 0, 0x1c0, (1<<i)); /* SHADER_PWROFF_LO */
110     while( Mali_RdReg(0, 0, 0x200) ) {}
111     res |= Mali_test_reg(0, 0, 0x140, 0xffffffff, 0xffffffff, 0, 1); /* SHADER_READY_LO */
112   }
113
114   printf("Power on/off tiler\n", i);
115   Mali_WrReg(0, 0, 0x190, 1); /* TILER_PWRON_LO */
116   while( Mali_RdReg(0, 0, 0x210) ) {}
117   res |= Mali_test_reg(0, 0, 0x150, 0xffffffff, 0xffffffff, 1, 1); /* TILER_READY_LO */
118   Mali_WrReg(0, 0, 0x1d0, 1); /* TILER_PWROFF_LO */
119   while( Mali_RdReg(0, 0, 0x210) ) {}
120   res |= Mali_test_reg(0, 0, 0x150, 0xffffffff, 0xffffffff, 0, 1); /* TILER_READY_LO */
121
122   printf("Power on/off L2\n", i);
123 #if MALI == t760
124   /* T760 has only one logical L2C */
125   Mali_WrReg(0, 0, 0x1a0, 1); /* L2_PWRON_LO */
126   while( Mali_RdReg(0, 0, 0x220) ) {}
127   res |= Mali_test_reg(0, 0, 0x160, 0xffffffff, 0xffffffff, 1, 1); /* L2_READY_LO */
128   Mali_WrReg(0, 0, 0x1e0, 1); /* L2_PWROFF_LO */
129   while( Mali_RdReg(0, 0, 0x220) ) {}
130   res |= Mali_test_reg(0, 0, 0x160, 0xffffffff, 0xffffffff, 0, 1); /* L2_READY_LO */
131 #else
132   if (num_cores>=6)
133   { /* T608 MP6 and T608 MP8 have two L2Cs*/
134     Mali_WrReg(0, 0, 0x1a0, 17); /* L2_PWRON_LO */
135     while( Mali_RdReg(0, 0, 0x220) ) {}
136     res |= Mali_test_reg(0, 0, 0x160, 0xffffffff, 0xffffffff, 17, 1); /* L2_READY_LO */
137     Mali_WrReg(0, 0, 0x1e0, 17); /* L2_PWROFF_LO */
138     while( Mali_RdReg(0, 0, 0x220) ) {}
139     res |= Mali_test_reg(0, 0, 0x160, 0xffffffff, 0xffffffff, 0, 1); /* L2_READY_LO */
140   }
141   else
142   {
143     Mali_WrReg(0, 0, 0x1a0, 1); /* L2_PWRON_LO */
144     while( Mali_RdReg(0, 0, 0x220) ) {}
145     res |= Mali_test_reg(0, 0, 0x160, 0xffffffff, 0xffffffff, 1, 1); /* L2_READY_LO */
146     Mali_WrReg(0, 0, 0x1e0, 1); /* L2_PWROFF_LO */
147     while( Mali_RdReg(0, 0, 0x220) ) {}
148     res |= Mali_test_reg(0, 0, 0x160, 0xffffffff, 0xffffffff, 0, 1); /* L2_READY_LO */
149   }
150 #endif
151
152
153   mali_step++;
154   return res;
155 }
156
157
158 /* Mali_test_reg
159    Test the register.
160    access: 0=RW, 1=RO
161 */
162 static int Mali_test_reg(int unit, int core, int regnum, int read_mask, int write_mask, int reset_value, int access) {
163   int value = Mali_RdReg(unit, core, regnum);
164   if( value != reset_value ) {
165     printf("FAILURE: Wrong reset value. Addr: 0x%08x Value: 0x%08x Expected: 0x%08x\n",
166            (unit<<28)+(core<<16)+regnum, value, reset_value);
167     return -1;
168   }
169   if( access == 0 ) {
170     Mali_WrReg(unit, core, regnum, (0xffffffff & write_mask));
171     value = Mali_RdReg(unit, core, regnum) & read_mask;
172     if( value != (0xffffffff & write_mask & read_mask) ) {
173       printf("FAILURE: Wrong value. Addr: 0x%08x Value: 0x%08x Expected: 0x%08x\n",
174              (unit<<28)+(core<<16)+regnum, value, (0xffffffff & write_mask & read_mask));
175       return -2;
176     }
177     Mali_WrReg(unit, core, regnum, (0x12345678 & write_mask));
178     value = Mali_RdReg(unit, core, regnum) & read_mask;
179     if( value != (0x12345678 & write_mask & read_mask) ) {
180       printf("FAILURE: Wrong value. Addr: 0x%08x Value: 0x%08x Expected: 0x%08x\n",
181              (unit<<28)+(core<<16)+regnum, value, (0x12345678 & write_mask & read_mask));
182       return -2;
183     }
184   }
185   printf("Register %08x: Success!\n", (unit<<28)+(core<<16)+regnum);
186   return 0;
187 }
188
189 #undef printf