41 ast_io_write8(ast, 0x43, 0x01);
42 ast_io_write8(ast, 0x42, 0x01);
55 ch = ast_io_read8(ast, 0x43);
66 static const u8 extreginfo[] = { 0x0f, 0x04, 0x1c, 0xff };
67 static const u8 extreginfo_ast2300a0[] = { 0x0f, 0x04, 0x1c, 0xff };
68 static const u8 extreginfo_ast2300[] = { 0x0f, 0x04, 0x1f, 0xff };
75 const u8 *ext_reg_info;
78 for (i = 0x81; i <= 0x8f; i++)
82 if (dev->pdev->revision >= 0x20)
83 ext_reg_info = extreginfo_ast2300;
85 ext_reg_info = extreginfo_ast2300a0;
87 ext_reg_info = extreginfo;
90 while (*ext_reg_info != 0xff) {
112 ast_write32(ast, 0xf004, r & 0xffff0000);
113 ast_write32(ast, 0xf000, 0x1);
115 return ast_read32(ast, 0x10000 + (r & 0x0000ffff));
120 ast_write32(ast, 0xf004, r & 0xffff0000);
121 ast_write32(ast, 0xf000, 0x1);
122 ast_write32(ast, 0x10000 + (r & 0x0000ffff), v);
128 #define CBR_SIZE_AST2150 ((16 << 10) - 1)
129 #define CBR_PASSNUM_AST2150 5
130 #define CBR_THRESHOLD_AST2150 10
131 #define CBR_THRESHOLD2_AST2150 10
132 #define TIMEOUT_AST2150 5000000
134 #define CBR_PATNUM_AST2150 8
136 static const u32 pattern_AST2150[14] = {
157 moutdwm(ast, 0x1e6e0070, 0x00000000);
158 moutdwm(ast, 0x1e6e0070, 0x00000001 | (datagen << 3));
161 data = mindwm(ast, 0x1e6e0070) & 0x40;
163 moutdwm(ast, 0x1e6e0070, 0x00000000);
167 moutdwm(ast, 0x1e6e0070, 0x00000000);
168 moutdwm(ast, 0x1e6e0070, 0x00000003 | (datagen << 3));
171 data = mindwm(ast, 0x1e6e0070) & 0x40;
173 moutdwm(ast, 0x1e6e0070, 0x00000000);
177 data = (mindwm(ast, 0x1e6e0070) & 0x80) >> 7;
178 moutdwm(ast, 0x1e6e0070, 0x00000000);
187 moutdwm(ast, 0x1e6e0070, 0x00000000);
188 moutdwm(ast, 0x1e6e0070, 0x00000005 | (datagen << 3));
191 data = mindwm(ast, 0x1e6e0070) & 0x40;
193 moutdwm(ast, 0x1e6e0070, 0x00000000);
197 data = (mindwm(ast, 0x1e6e0070) & 0x80) >> 7;
198 moutdwm(ast, 0x1e6e0070, 0x00000000);
203 static int cbrtest_ast2150(
struct ast_private *ast)
207 for (i = 0; i < 8; i++)
208 if (mmctestburst2_ast2150(ast, i))
213 static int cbrscan_ast2150(
struct ast_private *ast,
int busw)
218 moutdwm(ast, 0x1e6e007c, pattern_AST2150[patcnt]);
220 if (cbrtest_ast2150(ast))
223 if (loop == CBR_PASSNUM_AST2150)
230 static void cbrdlli_ast2150(
struct ast_private *ast,
int busw)
232 u32 dll_min[4], dll_max[4], dlli,
data, passcnt;
235 dll_min[0] = dll_min[1] = dll_min[2] = dll_min[3] = 0xff;
236 dll_max[0] = dll_max[1] = dll_max[2] = dll_max[3] = 0x0;
239 for (dlli = 0; dlli < 100; dlli++) {
240 moutdwm(ast, 0x1e6e0068, dlli | (dlli << 8) | (dlli << 16) | (dlli << 24));
241 data = cbrscan_ast2150(ast, busw);
244 if (dll_min[0] > dlli)
246 if (dll_max[0] < dlli)
256 dlli = dll_min[0] + (((dll_max[0] - dll_min[0]) * 7) >> 4);
257 moutdwm(ast, 0x1e6e0068, dlli | (dlli << 8) | (dlli << 16) | (dlli << 24));
262 static void ast_init_dram_reg(
struct drm_device *dev)
271 if ((j & 0x80) == 0) {
273 dram_reg_info = ast2000_dram_table_data;
274 ast_write32(ast, 0xf004, 0x1e6e0000);
275 ast_write32(ast, 0xf000, 0x1);
276 ast_write32(ast, 0x10100, 0xa8);
280 }
while (ast_read32(ast, 0x10100) != 0xa8);
283 dram_reg_info = ast2100_dram_table_data;
285 dram_reg_info = ast1100_dram_table_data;
287 ast_write32(ast, 0xf004, 0x1e6e0000);
288 ast_write32(ast, 0xf000, 0x1);
289 ast_write32(ast, 0x12000, 0x1688A8A8);
292 }
while (ast_read32(ast, 0x12000) != 0x01);
294 ast_write32(ast, 0x10000, 0xfc600309);
297 }
while (ast_read32(ast, 0x10000) != 0x01);
300 while (dram_reg_info->
index != 0xffff) {
301 if (dram_reg_info->
index == 0xff00) {
302 for (i = 0; i < 15; i++)
305 data = dram_reg_info->
data;
311 temp = ast_read32(ast, 0x12070);
314 ast_write32(ast, 0x10000 + dram_reg_info->
index, data | temp);
316 ast_write32(ast, 0x10000 + dram_reg_info->
index, dram_reg_info->
data);
321 data = ast_read32(ast, 0x10120);
322 if (data == 0x5061) {
323 data = ast_read32(ast, 0x10004);
325 cbrdlli_ast2150(ast, 16);
327 cbrdlli_ast2150(ast, 32);
332 temp = ast_read32(ast, 0x10140);
333 ast_write32(ast, 0x10140, temp | 0x40);
339 temp = ast_read32(ast, 0x1200c);
340 ast_write32(ast, 0x1200c, temp & 0xfffffffd);
341 temp = ast_read32(ast, 0x12040);
342 ast_write32(ast, 0x12040, temp | 0x40);
352 }
while ((j & 0x40) == 0);
360 pci_read_config_dword(ast->
dev->pdev, 0x04, ®);
362 pci_write_config_dword(ast->
dev->pdev, 0x04, reg);
366 ast_set_def_ext_reg(dev);
369 ast_init_dram_2300(dev);
371 ast_init_dram_reg(dev);
406 #define CBR_SIZE1 ((4 << 10) - 1)
407 #define CBR_SIZE2 ((64 << 10) - 1)
408 #define CBR_PASSNUM 5
409 #define CBR_PASSNUM2 5
410 #define CBR_THRESHOLD 10
411 #define CBR_THRESHOLD2 10
412 #define TIMEOUT 5000000
431 moutdwm(ast, 0x1e6e0070, 0x00000000);
432 moutdwm(ast, 0x1e6e0070, 0x000000c1 | (datagen << 3));
435 data = mindwm(ast, 0x1e6e0070) & 0x3000;
440 moutdwm(ast, 0x1e6e0070, 0x00000000);
444 moutdwm(ast, 0x1e6e0070, 0x00000000);
453 moutdwm(ast, 0x1e6e0070, 0x00000000);
454 moutdwm(ast, 0x1e6e0070, 0x00000041 | (datagen << 3));
457 data = mindwm(ast, 0x1e6e0070) & 0x1000;
459 moutdwm(ast, 0x1e6e0070, 0x0);
463 data = mindwm(ast, 0x1e6e0078);
464 data = (data | (data >> 16)) & 0xffff;
465 moutdwm(ast, 0x1e6e0070, 0x0);
474 moutdwm(ast, 0x1e6e0070, 0x00000000);
475 moutdwm(ast, 0x1e6e0070, 0x000000c5 | (datagen << 3));
478 data = mindwm(ast, 0x1e6e0070) & 0x3000;
482 moutdwm(ast, 0x1e6e0070, 0x0);
486 moutdwm(ast, 0x1e6e0070, 0x0);
495 moutdwm(ast, 0x1e6e0070, 0x00000000);
496 moutdwm(ast, 0x1e6e0070, 0x00000005 | (datagen << 3));
499 data = mindwm(ast, 0x1e6e0070) & 0x1000;
501 moutdwm(ast, 0x1e6e0070, 0x0);
505 data = mindwm(ast, 0x1e6e0078);
506 data = (data | (data >> 16)) & 0xffff;
507 moutdwm(ast, 0x1e6e0070, 0x0);
515 data = mmc_test_single2(ast, 0);
516 if ((data & 0xff) && (data & 0xff00))
518 for (i = 0; i < 8; i++) {
519 data = mmc_test_burst2(ast, i);
520 if ((data & 0xff) && (data & 0xff00))
525 else if (data & 0xff)
535 for (patcnt = 0; patcnt <
CBR_PATNUM; patcnt++) {
536 moutdwm(ast, 0x1e6e007c, pattern[patcnt]);
538 if ((data = cbr_test(ast)) != 0) {
545 if (loop == CBR_PASSNUM2)
555 data = mmc_test_burst2(ast, 0);
558 data |= mmc_test_single2(ast, 0);
562 return ~data & 0xffff;
570 for (patcnt = 0; patcnt <
CBR_PATNUM; patcnt++) {
571 moutdwm(ast, 0x1e6e007c, pattern[patcnt]);
573 if ((data = cbr_test2(ast)) != 0) {
580 if (loop == CBR_PASSNUM2)
589 u32 gold_sadj[2], dllmin[16], dllmax[16], dlli,
data,
cnt,
mask, passcnt;
591 gold_sadj[0] = (mindwm(ast, 0x1E6E0024) >> 16) & 0xffff;
592 gold_sadj[1] = gold_sadj[0] >> 8;
593 gold_sadj[0] = gold_sadj[0] & 0xff;
594 gold_sadj[0] = (gold_sadj[0] + gold_sadj[1]) >> 1;
595 gold_sadj[1] = gold_sadj[0];
597 for (cnt = 0; cnt < 16; cnt++) {
602 for (dlli = 0; dlli < 76; dlli++) {
603 moutdwm(ast, 0x1E6E0068, 0x00001400 | (dlli << 16) | (dlli << 24));
605 moutdwm(ast, 0x1E6E0074, 0x00000010);
606 moutdwm(ast, 0x1E6E0070, 0x00000003);
608 data = mindwm(ast, 0x1E6E0070);
609 }
while (!(data & 0x00001000));
610 moutdwm(ast, 0x1E6E0070, 0x00000000);
613 data = cbr_scan2(ast);
616 for (cnt = 0; cnt < 16; cnt++) {
618 if (dllmin[cnt] > dlli) {
621 if (dllmax[cnt] < dlli) {
633 for (cnt = 0; cnt < 8; cnt++) {
635 if ((dllmax[cnt] > dllmin[cnt]) && ((dllmax[cnt] - dllmin[cnt]) >=
CBR_THRESHOLD)) {
636 dlli = (dllmin[
cnt] + dllmax[
cnt]) >> 1;
637 if (gold_sadj[0] >= dlli) {
638 dlli = (gold_sadj[0] - dlli) >> 1;
643 dlli = (dlli - gold_sadj[0]) >> 1;
647 dlli = (8 - dlli) & 0x7;
652 moutdwm(ast, 0x1E6E0080, data);
655 for (cnt = 8; cnt < 16; cnt++) {
657 if ((dllmax[cnt] > dllmin[cnt]) && ((dllmax[cnt] - dllmin[cnt]) >=
CBR_THRESHOLD)) {
658 dlli = (dllmin[
cnt] + dllmax[
cnt]) >> 1;
659 if (gold_sadj[1] >= dlli) {
660 dlli = (gold_sadj[1] - dlli) >> 1;
664 dlli = (dlli - 1) & 0x7;
667 dlli = (dlli - gold_sadj[1]) >> 1;
672 dlli = (8 - dlli) & 0x7;
677 moutdwm(ast, 0x1E6E0084, data);
684 u32 gold_sadj[2], dllmin[16], dllmax[16], dlli,
data,
cnt,
mask, passcnt;
687 for (cnt = 0; cnt < 16; cnt++) {
692 for (dlli = 0; dlli < 76; dlli++) {
693 moutdwm(ast, 0x1E6E0068, 0x00001400 | (dlli << 16) | (dlli << 24));
695 moutdwm(ast, 0x1E6E0074, 0x00000010);
696 moutdwm(ast, 0x1E6E0070, 0x00000003);
698 data = mindwm(ast, 0x1E6E0070);
699 }
while (!(data & 0x00001000));
700 moutdwm(ast, 0x1E6E0070, 0x00000000);
703 data = cbr_scan2(ast);
706 for (cnt = 0; cnt < 16; cnt++) {
708 if (dllmin[cnt] > dlli) {
711 if (dllmax[cnt] < dlli) {
724 for (cnt = 0; cnt < 16; cnt++) {
725 if ((dllmax[cnt] > dllmin[cnt]) && ((dllmax[cnt] - dllmin[cnt]) >=
CBR_THRESHOLD2)) {
726 gold_sadj[0] += dllmin[
cnt];
733 gold_sadj[0] = gold_sadj[0] >> 4;
734 gold_sadj[1] = gold_sadj[0];
737 for (cnt = 0; cnt < 8; cnt++) {
739 if ((dllmax[cnt] > dllmin[cnt]) && ((dllmax[cnt] - dllmin[cnt]) >=
CBR_THRESHOLD2)) {
741 if (gold_sadj[0] >= dlli) {
742 dlli = ((gold_sadj[0] - dlli) * 19) >> 5;
747 dlli = ((dlli - gold_sadj[0]) * 19) >> 5;
751 dlli = (8 - dlli) & 0x7;
756 moutdwm(ast, 0x1E6E0080, data);
759 for (cnt = 8; cnt < 16; cnt++) {
761 if ((dllmax[cnt] > dllmin[cnt]) && ((dllmax[cnt] - dllmin[cnt]) >=
CBR_THRESHOLD2)) {
763 if (gold_sadj[1] >= dlli) {
764 dlli = ((gold_sadj[1] - dlli) * 19) >> 5;
768 dlli = (dlli - 1) & 0x7;
771 dlli = ((dlli - gold_sadj[1]) * 19) >> 5;
776 dlli = (8 - dlli) & 0x7;
781 moutdwm(ast, 0x1E6E0084, data);
789 for (cnt = 0; cnt < 16; cnt++) {
794 for (dlli = 0; dlli < 76; dlli++) {
795 moutdwm(ast, 0x1E6E0068, 0x00001400 | (dlli << 16) | (dlli << 24));
797 moutdwm(ast, 0x1E6E0074, 0x00000010);
798 moutdwm(ast, 0x1E6E0070, 0x00000003);
800 data = mindwm(ast, 0x1E6E0070);
801 }
while (!(data & 0x00001000));
802 moutdwm(ast, 0x1E6E0070, 0x00000000);
805 data = cbr_scan2(ast);
808 for (cnt = 0; cnt < 16; cnt++) {
810 if (dllmin[cnt] > dlli) {
813 if (dllmax[cnt] < dlli) {
826 for (cnt = 0; cnt < 8; cnt++) {
827 if ((dllmax[cnt] > dllmin[cnt]) && ((dllmax[cnt] - dllmin[cnt]) >=
CBR_THRESHOLD2)) {
828 if (gold_sadj[0] < dllmin[cnt]) {
829 gold_sadj[0] = dllmin[
cnt];
831 if (gold_sadj[1] > dllmax[cnt]) {
832 gold_sadj[1] = dllmax[
cnt];
836 gold_sadj[0] = (gold_sadj[1] + gold_sadj[0]) >> 1;
837 gold_sadj[1] = mindwm(ast, 0x1E6E0080);
840 for (cnt = 0; cnt < 8; cnt++) {
842 data2 = gold_sadj[1] & 0x7;
844 if ((dllmax[cnt] > dllmin[cnt]) && ((dllmax[cnt] - dllmin[cnt]) >=
CBR_THRESHOLD2)) {
845 dlli = (dllmin[
cnt] + dllmax[
cnt]) >> 1;
846 if (gold_sadj[0] >= dlli) {
847 dlli = (gold_sadj[0] - dlli) >> 1;
852 data2 = (data2 + dlli) & 0x7;
855 dlli = (dlli - gold_sadj[0]) >> 1;
860 data2 = (data2 - dlli) & 0x7;
866 moutdwm(ast, 0x1E6E0080, data);
870 for (cnt = 8; cnt < 16; cnt++) {
871 if ((dllmax[cnt] > dllmin[cnt]) && ((dllmax[cnt] - dllmin[cnt]) >=
CBR_THRESHOLD2)) {
872 if (gold_sadj[0] < dllmin[cnt]) {
873 gold_sadj[0] = dllmin[
cnt];
875 if (gold_sadj[1] > dllmax[cnt]) {
876 gold_sadj[1] = dllmax[
cnt];
880 gold_sadj[0] = (gold_sadj[1] + gold_sadj[0]) >> 1;
881 gold_sadj[1] = mindwm(ast, 0x1E6E0084);
884 for (cnt = 8; cnt < 16; cnt++) {
886 data2 = gold_sadj[1] & 0x7;
888 if ((dllmax[cnt] > dllmin[cnt]) && ((dllmax[cnt] - dllmin[cnt]) >=
CBR_THRESHOLD2)) {
889 dlli = (dllmin[
cnt] + dllmax[
cnt]) >> 1;
890 if (gold_sadj[0] >= dlli) {
891 dlli = (gold_sadj[0] - dlli) >> 1;
896 data2 = (data2 + dlli) & 0x7;
899 dlli = (dlli - gold_sadj[0]) >> 1;
904 data2 = (data2 - dlli) & 0x7;
910 moutdwm(ast, 0x1E6E0084, data);
919 finetuneDQI_L(ast, param);
920 finetuneDQI_L2(ast, param);
923 dllmin[0] = dllmin[1] = 0xff;
924 dllmax[0] = dllmax[1] = 0x0;
926 for (dlli = 0; dlli < 76; dlli++) {
927 moutdwm(ast, 0x1E6E0068, 0x00001300 | (dlli << 16) | (dlli << 24));
929 moutdwm(ast, 0x1E6E0074, 0x00000010);
930 moutdwm(ast, 0x1E6E0070, 0x00000003);
932 data = mindwm(ast, 0x1E6E0070);
933 }
while (!(data & 0x00001000));
934 moutdwm(ast, 0x1E6E0070, 0x00000000);
937 data = cbr_scan(ast);
940 if (dllmin[0] > dlli) {
943 if (dllmax[0] < dlli) {
948 if (dllmin[1] > dlli) {
951 if (dllmax[1] < dlli) {
960 if (dllmax[0] == 0 || (dllmax[0]-dllmin[0]) <
CBR_THRESHOLD) {
963 if (dllmax[1] == 0 || (dllmax[1]-dllmin[1]) <
CBR_THRESHOLD) {
966 dlli = (dllmin[1] + dllmax[1]) >> 1;
968 dlli += (dllmin[0] + dllmax[0]) >> 1;
969 moutdwm(ast, 0x1E6E0068, (mindwm(ast, 0x1E6E0068) & 0xFFFF) | (dlli << 16));
971 data = (mindwm(ast, 0x1E6E0080) >> 24) & 0x1F;
972 data2 = (mindwm(ast, 0x1E6E0018) & 0xff80ffff) | (data << 16);
973 moutdwm(ast, 0x1E6E0018, data2);
977 moutdwm(ast, 0x1E6E0074, 0x00000010);
978 moutdwm(ast, 0x1E6E0070, 0x00000003);
980 data = mindwm(ast, 0x1E6E0070);
981 }
while (!(data & 0x00001000));
982 moutdwm(ast, 0x1E6E0070, 0x00000000);
983 moutdwm(ast, 0x1E6E0070, 0x00000003);
985 data = mindwm(ast, 0x1E6E0070);
986 }
while (!(data & 0x00001000));
987 moutdwm(ast, 0x1E6E0070, 0x00000000);
994 moutdwm(ast, 0x1E6E2000, 0x1688A8A8);
997 trap = (mindwm(ast, 0x1E6E2070) >> 25) & 0x3;
998 trap_AC2 = 0x00020000 + (trap << 16);
999 trap_AC2 |= 0x00300000 + ((trap & 0x2) << 19);
1000 trap_MRS = 0x00000010 + (trap << 4);
1001 trap_MRS |= ((trap & 0x2) << 18);
1011 moutdwm(ast, 0x1E6E2020, 0x0190);
1014 param->
reg_AC2 = 0xAA007613 | trap_AC2;
1016 param->
reg_MRS = 0x04001400 | trap_MRS;
1026 moutdwm(ast, 0x1E6E2020, 0x03F1);
1029 param->
reg_AC2 = 0xCC009617 | trap_AC2;
1031 param->
reg_MRS = 0x04001600 | trap_MRS;
1044 param->
reg_AC2 = 0xCC009617 | trap_AC2;
1047 param->
reg_AC2 = 0xCC009622 | trap_AC2;
1050 param->
reg_AC2 = 0xCC00963F | trap_AC2;
1056 moutdwm(ast, 0x1E6E2020, 0x01F0);
1059 param->
reg_AC2 = 0xCC009617 | trap_AC2;
1061 param->
reg_MRS = 0x04001600 | trap_MRS;
1074 param->
reg_AC2 = 0xCC009617 | trap_AC2;
1077 param->
reg_AC2 = 0xCC009622 | trap_AC2;
1080 param->
reg_AC2 = 0xCC00963F | trap_AC2;
1086 moutdwm(ast, 0x1E6E2020, 0x0230);
1100 moutdwm(ast, 0x1E6E2020, 0x0270);
1114 moutdwm(ast, 0x1E6E2020, 0x0290);
1130 moutdwm(ast, 0x1E6E2020, 0x0140);
1148 moutdwm(ast, 0x1E6E2020, 0x02E1);
1166 moutdwm(ast, 0x1E6E2020, 0x0160);
1223 moutdwm(ast, 0x1E6E0000, 0xFC600309);
1224 moutdwm(ast, 0x1E6E0018, 0x00000100);
1225 moutdwm(ast, 0x1E6E0024, 0x00000000);
1226 moutdwm(ast, 0x1E6E0034, 0x00000000);
1228 moutdwm(ast, 0x1E6E0064, param->
reg_MADJ);
1229 moutdwm(ast, 0x1E6E0068, param->
reg_SADJ);
1231 moutdwm(ast, 0x1E6E0064, param->
reg_MADJ | 0xC0000);
1235 moutdwm(ast, 0x1E6E0008, 0x90040f);
1236 moutdwm(ast, 0x1E6E0010, param->
reg_AC1);
1237 moutdwm(ast, 0x1E6E0014, param->
reg_AC2);
1238 moutdwm(ast, 0x1E6E0020, param->
reg_DQSIC);
1239 moutdwm(ast, 0x1E6E0080, 0x00000000);
1240 moutdwm(ast, 0x1E6E0084, 0x00000000);
1242 moutdwm(ast, 0x1E6E0018, 0x4040A170);
1243 moutdwm(ast, 0x1E6E0018, 0x20402370);
1244 moutdwm(ast, 0x1E6E0038, 0x00000000);
1245 moutdwm(ast, 0x1E6E0040, 0xFF444444);
1246 moutdwm(ast, 0x1E6E0044, 0x22222222);
1247 moutdwm(ast, 0x1E6E0048, 0x22222222);
1248 moutdwm(ast, 0x1E6E004C, 0x00000002);
1249 moutdwm(ast, 0x1E6E0050, 0x80000000);
1250 moutdwm(ast, 0x1E6E0050, 0x00000000);
1251 moutdwm(ast, 0x1E6E0054, 0);
1252 moutdwm(ast, 0x1E6E0060, param->
reg_DRV);
1253 moutdwm(ast, 0x1E6E006C, param->
reg_IOZ);
1254 moutdwm(ast, 0x1E6E0070, 0x00000000);
1255 moutdwm(ast, 0x1E6E0074, 0x00000000);
1256 moutdwm(ast, 0x1E6E0078, 0x00000000);
1257 moutdwm(ast, 0x1E6E007C, 0x00000000);
1260 data = mindwm(ast, 0x1E6E001C);
1261 }
while (!(data & 0x08000000));
1262 moutdwm(ast, 0x1E6E0034, 0x00000001);
1263 moutdwm(ast, 0x1E6E000C, 0x00005C04);
1265 moutdwm(ast, 0x1E6E000C, 0x00000000);
1266 moutdwm(ast, 0x1E6E0034, 0x00000000);
1267 data = mindwm(ast, 0x1E6E001C);
1268 data = (data >> 8) & 0xff;
1269 while ((data & 0x08) || ((data & 0x7) < 2) || (data < 4)) {
1270 data2 = (mindwm(ast, 0x1E6E0064) & 0xfff3ffff) + 4;
1271 if ((data2 & 0xff) > param->
madj_max) {
1274 moutdwm(ast, 0x1E6E0064, data2);
1275 if (data2 & 0x00100000) {
1276 data2 = ((data2 & 0xff) >> 3) + 3;
1278 data2 = ((data2 & 0xff) >> 2) + 5;
1280 data = mindwm(ast, 0x1E6E0068) & 0xffff00ff;
1281 data2 += data & 0xff;
1282 data = data | (data2 << 8);
1283 moutdwm(ast, 0x1E6E0068, data);
1285 moutdwm(ast, 0x1E6E0064, mindwm(ast, 0x1E6E0064) | 0xC0000);
1287 data = mindwm(ast, 0x1E6E0018) & 0xfffff1ff;
1288 moutdwm(ast, 0x1E6E0018, data);
1289 data = data | 0x200;
1290 moutdwm(ast, 0x1E6E0018, data);
1292 data = mindwm(ast, 0x1E6E001C);
1293 }
while (!(data & 0x08000000));
1295 moutdwm(ast, 0x1E6E0034, 0x00000001);
1296 moutdwm(ast, 0x1E6E000C, 0x00005C04);
1298 moutdwm(ast, 0x1E6E000C, 0x00000000);
1299 moutdwm(ast, 0x1E6E0034, 0x00000000);
1300 data = mindwm(ast, 0x1E6E001C);
1301 data = (data >> 8) & 0xff;
1303 data = mindwm(ast, 0x1E6E0018) | 0xC00;
1304 moutdwm(ast, 0x1E6E0018, data);
1306 moutdwm(ast, 0x1E6E0034, 0x00000001);
1307 moutdwm(ast, 0x1E6E000C, 0x00000040);
1310 moutdwm(ast, 0x1E6E002C, param->
reg_MRS | 0x100);
1311 moutdwm(ast, 0x1E6E0030, param->
reg_EMRS);
1312 moutdwm(ast, 0x1E6E0028, 0x00000005);
1313 moutdwm(ast, 0x1E6E0028, 0x00000007);
1314 moutdwm(ast, 0x1E6E0028, 0x00000003);
1315 moutdwm(ast, 0x1E6E0028, 0x00000001);
1316 moutdwm(ast, 0x1E6E002C, param->
reg_MRS);
1317 moutdwm(ast, 0x1E6E000C, 0x00005C08);
1318 moutdwm(ast, 0x1E6E0028, 0x00000001);
1320 moutdwm(ast, 0x1E6E000C, 0x7FFF5C01);
1326 data = data | 0x3000 | ((param->
reg_AC2 & 0x60000) >> 3);
1328 moutdwm(ast, 0x1E6E0034, data | 0x3);
1332 data = mindwm(ast, 0x1E6E0080);
1333 }
while (!(data & 0x40000000));
1336 data = mindwm(ast, 0x1E6E0020);
1337 }
while (!(data & 0x00000800));
1339 cbr_dll2(ast, param);
1341 moutdwm(ast, 0x1E6E0120, param->
reg_FREQ);
1344 moutdwm(ast, 0x1E6E007C, 0x00000000);
1345 moutdwm(ast, 0x1E6E0070, 0x221);
1347 data = mindwm(ast, 0x1E6E0070);
1348 }
while (!(data & 0x00001000));
1349 moutdwm(ast, 0x1E6E0070, 0x00000000);
1350 moutdwm(ast, 0x1E6E0050, 0x80000000);
1351 moutdwm(ast, 0x1E6E0050, 0x00000000);
1361 moutdwm(ast, 0x1E6E2000, 0x1688A8A8);
1364 trap = (mindwm(ast, 0x1E6E2070) >> 25) & 0x3;
1365 trap_AC2 = (trap << 20) | (trap << 16);
1366 trap_AC2 += 0x00110000;
1367 trap_MRS = 0x00000040 | (trap << 4);
1378 moutdwm(ast, 0x1E6E2020, 0x0130);
1393 moutdwm(ast, 0x1E6E2020, 0x0190);
1396 param->
reg_AC2 = 0xAA009016 | trap_AC2;
1398 param->
reg_MRS = 0x00000A02 | trap_MRS;
1409 moutdwm(ast, 0x1E6E2020, 0x03F1);
1413 param->
reg_AC2 = 0xCC00B01B | trap_AC2;
1415 param->
reg_MRS = 0x00000C02 | trap_MRS;
1426 param->
reg_AC2 = 0xCC00B016 | trap_AC2;
1430 param->
reg_AC2 = 0xCC00B01B | trap_AC2;
1433 param->
reg_AC2 = 0xCC00B02B | trap_AC2;
1436 param->
reg_AC2 = 0xCC00B03F | trap_AC2;
1443 moutdwm(ast, 0x1E6E2020, 0x01F0);
1447 param->
reg_AC2 = 0xCC00B01B | trap_AC2;
1449 param->
reg_MRS = 0x00000C02 | trap_MRS;
1460 param->
reg_AC2 = 0xCC00B016 | trap_AC2;
1464 param->
reg_AC2 = 0xCC00B01B | trap_AC2;
1467 param->
reg_AC2 = 0xCC00B02B | trap_AC2;
1470 param->
reg_AC2 = 0xCC00B03F | trap_AC2;
1476 moutdwm(ast, 0x1E6E2020, 0x0230);
1491 moutdwm(ast, 0x1E6E2020, 0x0261);
1507 moutdwm(ast, 0x1E6E2020, 0x0120);
1523 moutdwm(ast, 0x1E6E2020, 0x02A1);
1539 moutdwm(ast, 0x1E6E2020, 0x0140);
1593 moutdwm(ast, 0x1E6E0000, 0xFC600309);
1594 moutdwm(ast, 0x1E6E0018, 0x00000100);
1595 moutdwm(ast, 0x1E6E0024, 0x00000000);
1596 moutdwm(ast, 0x1E6E0064, param->
reg_MADJ);
1597 moutdwm(ast, 0x1E6E0068, param->
reg_SADJ);
1599 moutdwm(ast, 0x1E6E0064, param->
reg_MADJ | 0xC0000);
1603 moutdwm(ast, 0x1E6E0008, 0x90040f);
1604 moutdwm(ast, 0x1E6E0010, param->
reg_AC1);
1605 moutdwm(ast, 0x1E6E0014, param->
reg_AC2);
1606 moutdwm(ast, 0x1E6E0020, param->
reg_DQSIC);
1607 moutdwm(ast, 0x1E6E0080, 0x00000000);
1608 moutdwm(ast, 0x1E6E0084, 0x00000000);
1610 moutdwm(ast, 0x1E6E0018, 0x4040A130);
1611 moutdwm(ast, 0x1E6E0018, 0x20402330);
1612 moutdwm(ast, 0x1E6E0038, 0x00000000);
1613 moutdwm(ast, 0x1E6E0040, 0xFF808000);
1614 moutdwm(ast, 0x1E6E0044, 0x88848466);
1615 moutdwm(ast, 0x1E6E0048, 0x44440008);
1616 moutdwm(ast, 0x1E6E004C, 0x00000000);
1617 moutdwm(ast, 0x1E6E0050, 0x80000000);
1618 moutdwm(ast, 0x1E6E0050, 0x00000000);
1619 moutdwm(ast, 0x1E6E0054, 0);
1620 moutdwm(ast, 0x1E6E0060, param->
reg_DRV);
1621 moutdwm(ast, 0x1E6E006C, param->
reg_IOZ);
1622 moutdwm(ast, 0x1E6E0070, 0x00000000);
1623 moutdwm(ast, 0x1E6E0074, 0x00000000);
1624 moutdwm(ast, 0x1E6E0078, 0x00000000);
1625 moutdwm(ast, 0x1E6E007C, 0x00000000);
1629 data = mindwm(ast, 0x1E6E001C);
1630 }
while (!(data & 0x08000000));
1631 moutdwm(ast, 0x1E6E0034, 0x00000001);
1632 moutdwm(ast, 0x1E6E000C, 0x00005C04);
1634 moutdwm(ast, 0x1E6E000C, 0x00000000);
1635 moutdwm(ast, 0x1E6E0034, 0x00000000);
1636 data = mindwm(ast, 0x1E6E001C);
1637 data = (data >> 8) & 0xff;
1638 while ((data & 0x08) || ((data & 0x7) < 2) || (data < 4)) {
1639 data2 = (mindwm(ast, 0x1E6E0064) & 0xfff3ffff) + 4;
1640 if ((data2 & 0xff) > param->
madj_max) {
1643 moutdwm(ast, 0x1E6E0064, data2);
1644 if (data2 & 0x00100000) {
1645 data2 = ((data2 & 0xff) >> 3) + 3;
1647 data2 = ((data2 & 0xff) >> 2) + 5;
1649 data = mindwm(ast, 0x1E6E0068) & 0xffff00ff;
1650 data2 += data & 0xff;
1651 data = data | (data2 << 8);
1652 moutdwm(ast, 0x1E6E0068, data);
1654 moutdwm(ast, 0x1E6E0064, mindwm(ast, 0x1E6E0064) | 0xC0000);
1656 data = mindwm(ast, 0x1E6E0018) & 0xfffff1ff;
1657 moutdwm(ast, 0x1E6E0018, data);
1658 data = data | 0x200;
1659 moutdwm(ast, 0x1E6E0018, data);
1661 data = mindwm(ast, 0x1E6E001C);
1662 }
while (!(data & 0x08000000));
1664 moutdwm(ast, 0x1E6E0034, 0x00000001);
1665 moutdwm(ast, 0x1E6E000C, 0x00005C04);
1667 moutdwm(ast, 0x1E6E000C, 0x00000000);
1668 moutdwm(ast, 0x1E6E0034, 0x00000000);
1669 data = mindwm(ast, 0x1E6E001C);
1670 data = (data >> 8) & 0xff;
1672 data = mindwm(ast, 0x1E6E0018) | 0xC00;
1673 moutdwm(ast, 0x1E6E0018, data);
1675 moutdwm(ast, 0x1E6E0034, 0x00000001);
1676 moutdwm(ast, 0x1E6E000C, 0x00000000);
1679 moutdwm(ast, 0x1E6E002C, param->
reg_MRS | 0x100);
1680 moutdwm(ast, 0x1E6E0030, param->
reg_EMRS);
1681 moutdwm(ast, 0x1E6E0028, 0x00000005);
1682 moutdwm(ast, 0x1E6E0028, 0x00000007);
1683 moutdwm(ast, 0x1E6E0028, 0x00000003);
1684 moutdwm(ast, 0x1E6E0028, 0x00000001);
1686 moutdwm(ast, 0x1E6E000C, 0x00005C08);
1687 moutdwm(ast, 0x1E6E002C, param->
reg_MRS);
1688 moutdwm(ast, 0x1E6E0028, 0x00000001);
1689 moutdwm(ast, 0x1E6E0030, param->
reg_EMRS | 0x380);
1690 moutdwm(ast, 0x1E6E0028, 0x00000003);
1691 moutdwm(ast, 0x1E6E0030, param->
reg_EMRS);
1692 moutdwm(ast, 0x1E6E0028, 0x00000003);
1694 moutdwm(ast, 0x1E6E000C, 0x7FFF5C01);
1700 data = data | 0x3000 | ((param->
reg_AC2 & 0x60000) >> 3);
1702 moutdwm(ast, 0x1E6E0034, data | 0x3);
1703 moutdwm(ast, 0x1E6E0120, param->
reg_FREQ);
1707 data = mindwm(ast, 0x1E6E0080);
1708 }
while (!(data & 0x40000000));
1711 data = mindwm(ast, 0x1E6E0020);
1712 }
while (!(data & 0x00000800));
1714 cbr_dll2(ast, param);
1718 moutdwm(ast, 0x1E6E007C, 0x00000000);
1719 moutdwm(ast, 0x1E6E0070, 0x221);
1721 data = mindwm(ast, 0x1E6E0070);
1722 }
while (!(data & 0x00001000));
1723 moutdwm(ast, 0x1E6E0070, 0x00000000);
1724 moutdwm(ast, 0x1E6E0050, 0x80000000);
1725 moutdwm(ast, 0x1E6E0050, 0x00000000);
1730 static void ast_init_dram_2300(
struct drm_device *dev)
1738 if ((reg & 0x80) == 0) {
1739 ast_write32(ast, 0xf004, 0x1e6e0000);
1740 ast_write32(ast, 0xf000, 0x1);
1741 ast_write32(ast, 0x12000, 0x1688a8a8);
1744 }
while (ast_read32(ast, 0x12000) != 0x1);
1746 ast_write32(ast, 0x10000, 0xfc600309);
1749 }
while (ast_read32(ast, 0x10000) != 0x1);
1752 temp = ast_read32(ast, 0x12008);
1754 ast_write32(ast, 0x12008, temp);
1757 if (temp & 0x01000000)
1764 get_ddr3_info(ast, ¶m);
1765 ddr3_init(ast, ¶m);
1767 get_ddr2_info(ast, ¶m);
1768 ddr2_init(ast, ¶m);
1771 temp = mindwm(ast, 0x1e6e2040);
1772 moutdwm(ast, 0x1e6e2040, temp | 0x40);
1778 }
while ((reg & 0x40) == 0);