aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2017-02-17 22:19:10 -0500
committerDave Airlie <airlied@redhat.com>2017-02-27 22:17:30 -0500
commitb368e53aae7694e0fb2bdec9667c9acc5108b629 (patch)
tree344dd5903548929f4afa999196fa12362f459138
parentbad09da6deab157440a3f0dd5e6c03cdc60c0a91 (diff)
drm/ast: Factor mmc_test code in POST code
There's a some duplication for what's essentially copies of two loops, so factor it. The upcoming AST2500 POST code adds more of them. Also cleanup return types for the test functions, most of them return a boolean, some return a u32. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Acked-by: Joel Stanley <joel@jms.id.au> Tested-by: Y.C. Chen <yc_chen@aspeedtech.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
-rw-r--r--drivers/gpu/drm/ast/ast_post.c82
1 files changed, 31 insertions, 51 deletions
diff --git a/drivers/gpu/drm/ast/ast_post.c b/drivers/gpu/drm/ast/ast_post.c
index e8024502e749..c55067ccb0b1 100644
--- a/drivers/gpu/drm/ast/ast_post.c
+++ b/drivers/gpu/drm/ast/ast_post.c
@@ -445,85 +445,65 @@ static const u32 pattern[8] = {
445 0x7C61D253 445 0x7C61D253
446}; 446};
447 447
448static int mmc_test_burst(struct ast_private *ast, u32 datagen) 448static bool mmc_test(struct ast_private *ast, u32 datagen, u8 test_ctl)
449{ 449{
450 u32 data, timeout; 450 u32 data, timeout;
451 451
452 ast_moutdwm(ast, 0x1e6e0070, 0x00000000); 452 ast_moutdwm(ast, 0x1e6e0070, 0x00000000);
453 ast_moutdwm(ast, 0x1e6e0070, 0x000000c1 | (datagen << 3)); 453 ast_moutdwm(ast, 0x1e6e0070, (datagen << 3) | test_ctl);
454 timeout = 0; 454 timeout = 0;
455 do { 455 do {
456 data = ast_mindwm(ast, 0x1e6e0070) & 0x3000; 456 data = ast_mindwm(ast, 0x1e6e0070) & 0x3000;
457 if (data & 0x2000) { 457 if (data & 0x2000)
458 return 0; 458 return false;
459 }
460 if (++timeout > TIMEOUT) { 459 if (++timeout > TIMEOUT) {
461 ast_moutdwm(ast, 0x1e6e0070, 0x00000000); 460 ast_moutdwm(ast, 0x1e6e0070, 0x00000000);
462 return 0; 461 return false;
463 } 462 }
464 } while (!data); 463 } while (!data);
465 ast_moutdwm(ast, 0x1e6e0070, 0x00000000); 464 ast_moutdwm(ast, 0x1e6e0070, 0x0);
466 return 1; 465 return true;
467} 466}
468 467
469static int mmc_test_burst2(struct ast_private *ast, u32 datagen) 468static u32 mmc_test2(struct ast_private *ast, u32 datagen, u8 test_ctl)
470{ 469{
471 u32 data, timeout; 470 u32 data, timeout;
472 471
473 ast_moutdwm(ast, 0x1e6e0070, 0x00000000); 472 ast_moutdwm(ast, 0x1e6e0070, 0x00000000);
474 ast_moutdwm(ast, 0x1e6e0070, 0x00000041 | (datagen << 3)); 473 ast_moutdwm(ast, 0x1e6e0070, (datagen << 3) | test_ctl);
475 timeout = 0; 474 timeout = 0;
476 do { 475 do {
477 data = ast_mindwm(ast, 0x1e6e0070) & 0x1000; 476 data = ast_mindwm(ast, 0x1e6e0070) & 0x1000;
478 if (++timeout > TIMEOUT) { 477 if (++timeout > TIMEOUT) {
479 ast_moutdwm(ast, 0x1e6e0070, 0x0); 478 ast_moutdwm(ast, 0x1e6e0070, 0x0);
480 return -1; 479 return 0xffffffff;
481 } 480 }
482 } while (!data); 481 } while (!data);
483 data = ast_mindwm(ast, 0x1e6e0078); 482 data = ast_mindwm(ast, 0x1e6e0078);
484 data = (data | (data >> 16)) & 0xffff; 483 data = (data | (data >> 16)) & 0xffff;
485 ast_moutdwm(ast, 0x1e6e0070, 0x0); 484 ast_moutdwm(ast, 0x1e6e0070, 0x00000000);
486 return data; 485 return data;
487} 486}
488 487
489static int mmc_test_single(struct ast_private *ast, u32 datagen) 488
489static bool mmc_test_burst(struct ast_private *ast, u32 datagen)
490{ 490{
491 u32 data, timeout; 491 return mmc_test(ast, datagen, 0xc1);
492}
492 493
493 ast_moutdwm(ast, 0x1e6e0070, 0x00000000); 494static u32 mmc_test_burst2(struct ast_private *ast, u32 datagen)
494 ast_moutdwm(ast, 0x1e6e0070, 0x000000c5 | (datagen << 3)); 495{
495 timeout = 0; 496 return mmc_test2(ast, datagen, 0x41);
496 do {
497 data = ast_mindwm(ast, 0x1e6e0070) & 0x3000;
498 if (data & 0x2000)
499 return 0;
500 if (++timeout > TIMEOUT) {
501 ast_moutdwm(ast, 0x1e6e0070, 0x0);
502 return 0;
503 }
504 } while (!data);
505 ast_moutdwm(ast, 0x1e6e0070, 0x0);
506 return 1;
507} 497}
508 498
509static int mmc_test_single2(struct ast_private *ast, u32 datagen) 499static bool mmc_test_single(struct ast_private *ast, u32 datagen)
510{ 500{
511 u32 data, timeout; 501 return mmc_test(ast, datagen, 0xc5);
502}
512 503
513 ast_moutdwm(ast, 0x1e6e0070, 0x00000000); 504static u32 mmc_test_single2(struct ast_private *ast, u32 datagen)
514 ast_moutdwm(ast, 0x1e6e0070, 0x00000005 | (datagen << 3)); 505{
515 timeout = 0; 506 return mmc_test2(ast, datagen, 0x05);
516 do {
517 data = ast_mindwm(ast, 0x1e6e0070) & 0x1000;
518 if (++timeout > TIMEOUT) {
519 ast_moutdwm(ast, 0x1e6e0070, 0x0);
520 return -1;
521 }
522 } while (!data);
523 data = ast_mindwm(ast, 0x1e6e0078);
524 data = (data | (data >> 16)) & 0xffff;
525 ast_moutdwm(ast, 0x1e6e0070, 0x0);
526 return data;
527} 507}
528 508
529static int cbr_test(struct ast_private *ast) 509static int cbr_test(struct ast_private *ast)
@@ -601,16 +581,16 @@ static u32 cbr_scan2(struct ast_private *ast)
601 return data2; 581 return data2;
602} 582}
603 583
604static u32 cbr_test3(struct ast_private *ast) 584static bool cbr_test3(struct ast_private *ast)
605{ 585{
606 if (!mmc_test_burst(ast, 0)) 586 if (!mmc_test_burst(ast, 0))
607 return 0; 587 return false;
608 if (!mmc_test_single(ast, 0)) 588 if (!mmc_test_single(ast, 0))
609 return 0; 589 return false;
610 return 1; 590 return true;
611} 591}
612 592
613static u32 cbr_scan3(struct ast_private *ast) 593static bool cbr_scan3(struct ast_private *ast)
614{ 594{
615 u32 patcnt, loop; 595 u32 patcnt, loop;
616 596
@@ -621,9 +601,9 @@ static u32 cbr_scan3(struct ast_private *ast)
621 break; 601 break;
622 } 602 }
623 if (loop == 2) 603 if (loop == 2)
624 return 0; 604 return false;
625 } 605 }
626 return 1; 606 return true;
627} 607}
628 608
629static bool finetuneDQI_L(struct ast_private *ast, struct ast2300_dram_param *param) 609static bool finetuneDQI_L(struct ast_private *ast, struct ast2300_dram_param *param)