aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/ast/ast_main.c
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2017-02-22 21:10:12 -0500
committerDave Airlie <airlied@redhat.com>2017-02-22 21:10:12 -0500
commit94000cc32988a0674923309d35ab9c2405c4b39b (patch)
treeef9d58ea9ad614bfdf6d0c7c6293f05dbd989475 /drivers/gpu/drm/ast/ast_main.c
parenta5eb76d9c892b8bd7d3505f8897cf126a54860bd (diff)
parent7089db84e356562f8ba737c29e472cc42d530dbc (diff)
Merge tag 'v4.10-rc8' into drm-next
Linux 4.10-rc8 Backmerge Linus rc8 to fix some conflicts, but also to avoid pulling it in via a fixes pull from someone.
Diffstat (limited to 'drivers/gpu/drm/ast/ast_main.c')
-rw-r--r--drivers/gpu/drm/ast/ast_main.c157
1 files changed, 83 insertions, 74 deletions
diff --git a/drivers/gpu/drm/ast/ast_main.c b/drivers/gpu/drm/ast/ast_main.c
index 5992ed2166ec..993909430736 100644
--- a/drivers/gpu/drm/ast/ast_main.c
+++ b/drivers/gpu/drm/ast/ast_main.c
@@ -124,6 +124,12 @@ static int ast_detect_chip(struct drm_device *dev, bool *need_post)
124 } else 124 } else
125 *need_post = false; 125 *need_post = false;
126 126
127 /* Check P2A Access */
128 ast->DisableP2A = true;
129 data = ast_read32(ast, 0xf004);
130 if (data != 0xFFFFFFFF)
131 ast->DisableP2A = false;
132
127 /* Check if we support wide screen */ 133 /* Check if we support wide screen */
128 switch (ast->chip) { 134 switch (ast->chip) {
129 case AST1180: 135 case AST1180:
@@ -140,15 +146,17 @@ static int ast_detect_chip(struct drm_device *dev, bool *need_post)
140 ast->support_wide_screen = true; 146 ast->support_wide_screen = true;
141 else { 147 else {
142 ast->support_wide_screen = false; 148 ast->support_wide_screen = false;
143 /* Read SCU7c (silicon revision register) */ 149 if (ast->DisableP2A == false) {
144 ast_write32(ast, 0xf004, 0x1e6e0000); 150 /* Read SCU7c (silicon revision register) */
145 ast_write32(ast, 0xf000, 0x1); 151 ast_write32(ast, 0xf004, 0x1e6e0000);
146 data = ast_read32(ast, 0x1207c); 152 ast_write32(ast, 0xf000, 0x1);
147 data &= 0x300; 153 data = ast_read32(ast, 0x1207c);
148 if (ast->chip == AST2300 && data == 0x0) /* ast1300 */ 154 data &= 0x300;
149 ast->support_wide_screen = true; 155 if (ast->chip == AST2300 && data == 0x0) /* ast1300 */
150 if (ast->chip == AST2400 && data == 0x100) /* ast1400 */ 156 ast->support_wide_screen = true;
151 ast->support_wide_screen = true; 157 if (ast->chip == AST2400 && data == 0x100) /* ast1400 */
158 ast->support_wide_screen = true;
159 }
152 } 160 }
153 break; 161 break;
154 } 162 }
@@ -216,80 +224,81 @@ static int ast_get_dram_info(struct drm_device *dev)
216 uint32_t data, data2; 224 uint32_t data, data2;
217 uint32_t denum, num, div, ref_pll; 225 uint32_t denum, num, div, ref_pll;
218 226
219 ast_write32(ast, 0xf004, 0x1e6e0000); 227 if (ast->DisableP2A)
220 ast_write32(ast, 0xf000, 0x1); 228 {
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)
232 ast->dram_bus_width = 16; 229 ast->dram_bus_width = 16;
230 ast->dram_type = AST_DRAM_1Gx16;
231 ast->mclk = 396;
232 }
233 else 233 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 }
235 277
236 if (ast->chip == AST2300 || ast->chip == AST2400) { 278 data = ast_read32(ast, 0x10120);
237 switch (data & 0x03) { 279 data2 = ast_read32(ast, 0x10170);
238 case 0: 280 if (data2 & 0x2000)
239 ast->dram_type = AST_DRAM_512Mx16; 281 ref_pll = 14318;
240 break; 282 else
241 default: 283 ref_pll = 12000;
242 case 1: 284
243 ast->dram_type = AST_DRAM_1Gx16; 285 denum = data & 0x1f;
244 break; 286 num = (data & 0x3fe0) >> 5;
245 case 2: 287 data = (data & 0xc000) >> 14;
246 ast->dram_type = AST_DRAM_2Gx16; 288 switch (data) {
247 break;
248 case 3: 289 case 3:
249 ast->dram_type = AST_DRAM_4Gx16; 290 div = 0x4;
250 break;
251 }
252 } else {
253 switch (data & 0x0c) {
254 case 0:
255 case 4:
256 ast->dram_type = AST_DRAM_512Mx16;
257 break; 291 break;
258 case 8: 292 case 2:
259 if (data & 0x40) 293 case 1:
260 ast->dram_type = AST_DRAM_1Gx16; 294 div = 0x2;
261 else
262 ast->dram_type = AST_DRAM_512Mx32;
263 break; 295 break;
264 case 0xc: 296 default:
265 ast->dram_type = AST_DRAM_1Gx32; 297 div = 0x1;
266 break; 298 break;
267 } 299 }
300 ast->mclk = ref_pll * (num + 2) / (denum + 2) * (div * 1000);
268 } 301 }
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);
293 return 0; 302 return 0;
294} 303}
295 304