@@ -124,6 +124,12 @@ static int ast_detect_chip(struct drm_device *dev, bool *need_post)
124124 } else
125125 * need_post = false;
126126
127+ /* Check P2A Access */
128+ ast -> DisableP2A = true;
129+ data = ast_read32 (ast , 0xf004 );
130+ if (data != 0xFFFFFFFF )
131+ ast -> DisableP2A = false;
132+
127133 /* Check if we support wide screen */
128134 switch (ast -> chip ) {
129135 case AST1180 :
@@ -140,15 +146,17 @@ static int ast_detect_chip(struct drm_device *dev, bool *need_post)
140146 ast -> support_wide_screen = true;
141147 else {
142148 ast -> support_wide_screen = false;
143- /* Read SCU7c (silicon revision register) */
144- ast_write32 (ast , 0xf004 , 0x1e6e0000 );
145- ast_write32 (ast , 0xf000 , 0x1 );
146- data = ast_read32 (ast , 0x1207c );
147- data &= 0x300 ;
148- if (ast -> chip == AST2300 && data == 0x0 ) /* ast1300 */
149- ast -> support_wide_screen = true;
150- if (ast -> chip == AST2400 && data == 0x100 ) /* ast1400 */
151- ast -> support_wide_screen = true;
149+ if (ast -> DisableP2A == false) {
150+ /* Read SCU7c (silicon revision register) */
151+ ast_write32 (ast , 0xf004 , 0x1e6e0000 );
152+ ast_write32 (ast , 0xf000 , 0x1 );
153+ data = ast_read32 (ast , 0x1207c );
154+ data &= 0x300 ;
155+ if (ast -> chip == AST2300 && data == 0x0 ) /* ast1300 */
156+ ast -> support_wide_screen = true;
157+ if (ast -> chip == AST2400 && data == 0x100 ) /* ast1400 */
158+ ast -> support_wide_screen = true;
159+ }
152160 }
153161 break ;
154162 }
@@ -216,80 +224,81 @@ static int ast_get_dram_info(struct drm_device *dev)
216224 uint32_t data , data2 ;
217225 uint32_t denum , num , div , ref_pll ;
218226
219- ast_write32 (ast , 0xf004 , 0x1e6e0000 );
220- ast_write32 (ast , 0xf000 , 0x1 );
221-
222-
223- ast_write32 (ast , 0x10000 , 0xfc600309 );
224-
225- do {
226- if (pci_channel_offline (dev -> pdev ))
227- return - EIO ;
228- } while (ast_read32 (ast , 0x10000 ) != 0x01 );
229- data = ast_read32 (ast , 0x10004 );
230-
231- if (data & 0x40 )
227+ if (ast -> DisableP2A )
228+ {
232229 ast -> dram_bus_width = 16 ;
230+ ast -> dram_type = AST_DRAM_1Gx16 ;
231+ ast -> mclk = 396 ;
232+ }
233233 else
234- ast -> dram_bus_width = 32 ;
234+ {
235+ ast_write32 (ast , 0xf004 , 0x1e6e0000 );
236+ ast_write32 (ast , 0xf000 , 0x1 );
237+ data = ast_read32 (ast , 0x10004 );
238+
239+ if (data & 0x40 )
240+ ast -> dram_bus_width = 16 ;
241+ else
242+ ast -> dram_bus_width = 32 ;
243+
244+ if (ast -> chip == AST2300 || ast -> chip == AST2400 ) {
245+ switch (data & 0x03 ) {
246+ case 0 :
247+ ast -> dram_type = AST_DRAM_512Mx16 ;
248+ break ;
249+ default :
250+ case 1 :
251+ ast -> dram_type = AST_DRAM_1Gx16 ;
252+ break ;
253+ case 2 :
254+ ast -> dram_type = AST_DRAM_2Gx16 ;
255+ break ;
256+ case 3 :
257+ ast -> dram_type = AST_DRAM_4Gx16 ;
258+ break ;
259+ }
260+ } else {
261+ switch (data & 0x0c ) {
262+ case 0 :
263+ case 4 :
264+ ast -> dram_type = AST_DRAM_512Mx16 ;
265+ break ;
266+ case 8 :
267+ if (data & 0x40 )
268+ ast -> dram_type = AST_DRAM_1Gx16 ;
269+ else
270+ ast -> dram_type = AST_DRAM_512Mx32 ;
271+ break ;
272+ case 0xc :
273+ ast -> dram_type = AST_DRAM_1Gx32 ;
274+ break ;
275+ }
276+ }
235277
236- if (ast -> chip == AST2300 || ast -> chip == AST2400 ) {
237- switch (data & 0x03 ) {
238- case 0 :
239- ast -> dram_type = AST_DRAM_512Mx16 ;
240- break ;
241- default :
242- case 1 :
243- ast -> dram_type = AST_DRAM_1Gx16 ;
244- break ;
245- case 2 :
246- ast -> dram_type = AST_DRAM_2Gx16 ;
247- break ;
278+ data = ast_read32 (ast , 0x10120 );
279+ data2 = ast_read32 (ast , 0x10170 );
280+ if (data2 & 0x2000 )
281+ ref_pll = 14318 ;
282+ else
283+ ref_pll = 12000 ;
284+
285+ denum = data & 0x1f ;
286+ num = (data & 0x3fe0 ) >> 5 ;
287+ data = (data & 0xc000 ) >> 14 ;
288+ switch (data ) {
248289 case 3 :
249- ast -> dram_type = AST_DRAM_4Gx16 ;
250- break ;
251- }
252- } else {
253- switch (data & 0x0c ) {
254- case 0 :
255- case 4 :
256- ast -> dram_type = AST_DRAM_512Mx16 ;
290+ div = 0x4 ;
257291 break ;
258- case 8 :
259- if (data & 0x40 )
260- ast -> dram_type = AST_DRAM_1Gx16 ;
261- else
262- ast -> dram_type = AST_DRAM_512Mx32 ;
292+ case 2 :
293+ case 1 :
294+ div = 0x2 ;
263295 break ;
264- case 0xc :
265- ast -> dram_type = AST_DRAM_1Gx32 ;
296+ default :
297+ div = 0x1 ;
266298 break ;
267299 }
300+ ast -> mclk = ref_pll * (num + 2 ) / (denum + 2 ) * (div * 1000 );
268301 }
269-
270- data = ast_read32 (ast , 0x10120 );
271- data2 = ast_read32 (ast , 0x10170 );
272- if (data2 & 0x2000 )
273- ref_pll = 14318 ;
274- else
275- ref_pll = 12000 ;
276-
277- denum = data & 0x1f ;
278- num = (data & 0x3fe0 ) >> 5 ;
279- data = (data & 0xc000 ) >> 14 ;
280- switch (data ) {
281- case 3 :
282- div = 0x4 ;
283- break ;
284- case 2 :
285- case 1 :
286- div = 0x2 ;
287- break ;
288- default :
289- div = 0x1 ;
290- break ;
291- }
292- ast -> mclk = ref_pll * (num + 2 ) / (denum + 2 ) * (div * 1000 );
293302 return 0 ;
294303}
295304
0 commit comments