17 #define bioslog(lvl, fmt, args...) do { \
18 nv_printk(init->bios, lvl, "0x%04x[%c]: "fmt, init->offset, \
19 init_exec(init) ? '0' + (init->nested - 1) : ' ', ##args); \
21 #define cont(fmt, args...) do { \
22 if (nv_subdev(init->bios)->debug >= NV_DBG_TRACE) \
23 printk(fmt, ##args); \
25 #define trace(fmt, args...) bioslog(TRACE, fmt, ##args)
26 #define warn(fmt, args...) bioslog(WARN, fmt, ##args)
27 #define error(fmt, args...) bioslog(ERROR, fmt, ##args)
42 if (exec) init->
execute &= 0xfd;
53 init_exec_force(
struct nvbios_init *init,
bool exec)
55 if (exec) init->
execute |= 0x04;
68 error(
"script needs OR!!\n");
76 return !(init->
outp->sorconf.link & 1);
77 error(
"script needs OR link\n");
86 error(
"script needs crtc\n");
99 return nv_ro08(bios, conn);
102 error(
"script needs connector type\n");
120 if (nv_device(init->
bios)->card_type >= NV_50) {
121 if (reg & 0x80000000) {
122 reg += init_crtc(init) * 0x800;
126 if (reg & 0x40000000) {
127 reg += init_or(init) * 0x800;
129 if (reg & 0x20000000) {
130 reg += init_link(init) * 0x80;
136 if (reg & ~0x00fffffc)
137 warn(
"unknown bits in register 0x%08x\n", reg);
144 reg = init_nvreg(init, reg);
146 return nv_rd32(init->
subdev, reg);
153 reg = init_nvreg(init, reg);
155 nv_wr32(init->
subdev, reg, val);
161 reg = init_nvreg(init, reg);
164 nv_wr32(init->
subdev, reg, (tmp & ~mask) | val);
191 return nv_rdvgai(subdev, head, port, index);
200 if (nv_device(init->
subdev)->card_type < NV_50) {
201 if (port == 0x03d4 && index == 0x44)
211 if (nv_device(init->
subdev)->card_type < NV_50) {
212 if (port == 0x03d4 && index == 0x44 && value == 3)
224 if (init->
outp && init->
outp->i2c_upper_default)
229 error(
"script needs output for i2c\n");
233 index = init->
outp->i2c_index;
236 return i2c->
find(i2c, index);
278 return nv_wraux(port, addr, &data, 1);
289 warn(
"failed to prog pll 0x%08x to %dkHz\n",
id, freq);
307 if (bmp_version(bios) >= 0x0510) {
321 if (len >= offset + 2) {
322 data = nv_ro16(bios, data + offset);
326 warn(
"%s pointer invalid\n", name);
330 warn(
"init data too short for %s pointer", name);
334 warn(
"init data not found\n");
338 #define init_script_table(b) init_table_((b), 0x00, "script table")
339 #define init_macro_index_table(b) init_table_((b), 0x02, "macro index table")
340 #define init_macro_table(b) init_table_((b), 0x04, "macro table")
341 #define init_condition_table(b) init_table_((b), 0x06, "condition table")
342 #define init_io_condition_table(b) init_table_((b), 0x08, "io condition table")
343 #define init_io_flag_condition_table(b) init_table_((b), 0x0a, "io flag conditon table")
344 #define init_function_table(b) init_table_((b), 0x0c, "function table")
345 #define init_xlat_table(b) init_table_((b), 0x10, "xlat table");
353 if (bmp_version(bios) && bmp_version(bios) < 0x0510) {
358 return nv_ro16(bios, data + (index * 2));
363 return nv_ro16(bios, data + (index * 2));
372 if (data && len >= 16)
373 return nv_ro16(bios, data + 14);
385 if (bit_M.version == 1 && bit_M.length >= 5)
386 data = nv_ro16(bios, bit_M.offset + 3);
387 if (bit_M.version == 2 && bit_M.length >= 3)
388 data = nv_ro16(bios, bit_M.offset + 1);
392 warn(
"ram restrict table not found\n");
397 init_ram_restrict_group_count(
struct nvbios_init *init)
403 if (bit_M.version == 1 && bit_M.length >= 5)
404 return nv_ro08(bios, bit_M.offset + 2);
405 if (bit_M.version == 2 && bit_M.length >= 3)
406 return nv_ro08(bios, bit_M.offset + 0);
415 u32 strap = (init_rd32(init, 0x101000) & 0x0000003c) >> 2;
416 u16 table = init_ram_restrict_table(init);
418 return nv_ro08(init->
bios, table + strap);
428 u16 data = nv_ro16(bios, table + (index * 2));
430 return nv_ro08(bios, data + offset);
431 warn(
"xlat table pointer %d invalid\n", index);
446 u32 reg = nv_ro32(bios, table + (cond * 12) + 0);
447 u32 msk = nv_ro32(bios, table + (cond * 12) + 4);
448 u32 val = nv_ro32(bios, table + (cond * 12) + 8);
449 trace(
"\t[0x%02x] (R[0x%06x] & 0x%08x) == 0x%08x\n",
450 cond, reg, msk, val);
451 return (init_rd32(init, reg) & msk) ==
val;
462 u16 port = nv_ro16(bios, table + (cond * 5) + 0);
463 u8 index = nv_ro08(bios, table + (cond * 5) + 2);
464 u8 mask = nv_ro08(bios, table + (cond * 5) + 3);
465 u8 value = nv_ro08(bios, table + (cond * 5) + 4);
466 trace(
"\t[0x%02x] (0x%04x[0x%02x] & 0x%02x) == 0x%02x\n",
467 cond, port, index, mask, value);
468 return (init_rdvgai(init, port, index) & mask) ==
value;
474 init_io_flag_condition_met(
struct nvbios_init *init,
u8 cond)
479 u16 port = nv_ro16(bios, table + (cond * 9) + 0);
480 u8 index = nv_ro08(bios, table + (cond * 9) + 2);
481 u8 mask = nv_ro08(bios, table + (cond * 9) + 3);
482 u8 shift = nv_ro08(bios, table + (cond * 9) + 4);
483 u16 data = nv_ro16(bios, table + (cond * 9) + 5);
484 u8 dmask = nv_ro08(bios, table + (cond * 9) + 7);
485 u8 value = nv_ro08(bios, table + (cond * 9) + 8);
486 u8 ioval = (init_rdvgai(init, port, index) &
mask) >> shift;
487 return (nv_ro08(bios, data + ioval) & dmask) == value;
493 init_shift(
u32 data,
u8 shift)
496 return data >> shift;
497 return data << (0x100 - shift);
512 const int pramdac_offset[13] = {
513 0, 0, 0x8, 0, 0x2000, 0, 0, 0, 0x2008, 0, 0, 0, 0x2000 };
514 const u32 pramdac_table[4] = {
515 0x6808b0, 0x6808b8, 0x6828b0, 0x6828b8 };
519 u32 dacoffset = pramdac_offset[init->
outp->or];
522 return 0x6808b0 + dacoffset;
525 error(
"tmds opcodes need dcb\n");
528 return pramdac_table[tmds];
530 error(
"tmds selector 0x%02x unknown\n", tmds);
548 trace(
"RESERVED\t0x%02x\n", opcode);
571 u16 port = nv_ro16(bios, init->
offset + 1);
572 u8 index = nv_ro08(bios, init->
offset + 3);
573 u8 mask = nv_ro08(bios, init->
offset + 4);
574 u8 shift = nv_ro08(bios, init->
offset + 5);
576 u32 reg = nv_ro32(bios, init->
offset + 7);
579 trace(
"IO_RESTRICT_PROG\tR[0x%06x] = "
580 "((0x%04x[0x%02x] & 0x%02x) >> %d) [{\n",
581 reg, port, index, mask, shift);
584 conf = (init_rdvgai(init, port, index) &
mask) >> shift;
585 for (i = 0; i <
count; i++) {
589 trace(
"\t0x%08x *\n", data);
590 init_wr32(init, reg, data);
592 trace(
"\t0x%08x\n", data);
608 u8 count = nv_ro08(bios, init->
offset + 1);
611 trace(
"REPEAT\t0x%02x\n", count);
620 trace(
"REPEAT\t0x%02x\n", count);
634 u16 port = nv_ro16(bios, init->
offset + 1);
635 u8 index = nv_ro08(bios, init->
offset + 3);
636 u8 mask = nv_ro08(bios, init->
offset + 4);
637 u8 shift = nv_ro08(bios, init->
offset + 5);
638 s8 iofc = nv_ro08(bios, init->
offset + 6);
639 u8 count = nv_ro08(bios, init->
offset + 7);
640 u32 reg = nv_ro32(bios, init->
offset + 8);
643 trace(
"IO_RESTRICT_PLL\tR[0x%06x] =PLL= "
644 "((0x%04x[0x%02x] & 0x%02x) >> 0x%02x) IOFCOND 0x%02x [{\n",
645 reg, port, index, mask, shift, iofc);
648 conf = (init_rdvgai(init, port, index) &
mask) >> shift;
649 for (i = 0; i <
count; i++) {
650 u32 freq = nv_ro16(bios, init->
offset) * 10;
653 trace(
"\t%dkHz *\n", freq);
654 if (iofc > 0 && init_io_flag_condition_met(init, iofc))
656 init_prog_pll(init, reg, freq);
658 trace(
"\t%dkHz\n", freq);
673 trace(
"END_REPEAT\n");
690 u32 reg = nv_ro32(bios, init->
offset + 1);
691 u8 shift = nv_ro08(bios, init->
offset + 5);
693 u16 port = nv_ro16(bios, init->
offset + 7);
694 u8 index = nv_ro08(bios, init->
offset + 9);
695 u8 mask = nv_ro08(bios, init->
offset + 10);
698 trace(
"COPY\t0x%04x[0x%02x] &= 0x%02x |= "
699 "((R[0x%06x] %s 0x%02x) & 0x%02x)\n",
700 port, index, mask, reg, (shift & 0x80) ?
"<<" :
">>",
701 (shift & 0x80) ? (0x100 - shift) : shift, smask);
704 data = init_rdvgai(init, port, index) &
mask;
705 data |= init_shift(init_rd32(init, reg), shift) &
smask;
706 init_wrvgai(init, port, index, data);
729 u8 cond = nv_ro08(bios, init->
offset + 1);
731 trace(
"IO_FLAG_CONDITION\t0x%02x\n", cond);
734 if (!init_io_flag_condition_met(init, cond))
735 init_exec_set(init,
false);
746 u8 cond = nv_ro08(bios, init->
offset + 1);
747 u8 unkn = nv_ro08(bios, init->
offset + 2);
751 trace(
"DP_CONDITION\t0x%02x 0x%02x\n", cond, unkn);
757 init_exec_set(init,
false);
763 if (ver <= 0x40 && !(nv_ro08(bios, data + 5) & cond))
764 init_exec_set(init,
false);
765 if (ver == 0x40 && !(nv_ro08(bios, data + 4) & cond))
766 init_exec_set(init,
false);
770 warn(
"script needs dp output table data\n");
773 if (!(init_rdauxr(init, 0x0d) & 1))
774 init_exec_set(init,
false);
777 warn(
"unknown dp condition 0x%02x\n", cond);
790 u8 index = nv_ro08(bios, init->
offset + 1);
791 u8 or = init_or(init);
794 trace(
"IO_MASK_OR\t0x03d4[0x%02x] &= ~(1 << 0x%02x)", index, or);
797 data = init_rdvgai(init, 0x03d4, index);
798 init_wrvgai(init, 0x03d4, index, data &= ~(1 << or));
809 u8 index = nv_ro08(bios, init->
offset + 1);
810 u8 or = init_or(init);
813 trace(
"IO_OR\t0x03d4[0x%02x] |= (1 << 0x%02x)", index, or);
816 data = init_rdvgai(init, 0x03d4, index);
817 init_wrvgai(init, 0x03d4, index, data | (1 << or));
829 u32 dreg = nv_ro32(bios, init->
offset + 5);
830 u32 mask = nv_ro32(bios, init->
offset + 9);
831 u32 data = nv_ro32(bios, init->
offset + 13);
832 u8 count = nv_ro08(bios, init->
offset + 17);
834 trace(
"INDEX_ADDRESS_LATCHED\t"
835 "R[0x%06x] : R[0x%06x]\n\tCTRL &= 0x%08x |= 0x%08x\n",
836 creg, dreg, mask, data);
840 u8 iaddr = nv_ro08(bios, init->
offset + 0);
841 u8 idata = nv_ro08(bios, init->
offset + 1);
843 trace(
"\t[0x%02x] = 0x%02x\n", iaddr, idata);
846 init_wr32(init, dreg, idata);
847 init_mask(init, creg, ~mask, data | idata);
859 u16 port = nv_ro16(bios, init->
offset + 1);
860 u8 index = nv_ro08(bios, init->
offset + 3);
861 u8 mask = nv_ro08(bios, init->
offset + 4);
862 u8 shift = nv_ro08(bios, init->
offset + 5);
863 u8 count = nv_ro08(bios, init->
offset + 6);
864 u32 reg = nv_ro32(bios, init->
offset + 7);
867 trace(
"IO_RESTRICT_PLL2\t"
868 "R[0x%06x] =PLL= ((0x%04x[0x%02x] & 0x%02x) >> 0x%02x) [{\n",
869 reg, port, index, mask, shift);
872 conf = (init_rdvgai(init, port, index) &
mask) >> shift;
873 for (i = 0; i <
count; i++) {
876 trace(
"\t%dkHz *\n", freq);
877 init_prog_pll(init, reg, freq);
879 trace(
"\t%dkHz\n", freq);
894 u32 reg = nv_ro32(bios, init->
offset + 1);
895 u32 freq = nv_ro32(bios, init->
offset + 5);
897 trace(
"PLL2\tR[0x%06x] =PLL= %dkHz\n", reg, freq);
900 init_prog_pll(init, reg, freq);
911 u8 index = nv_ro08(bios, init->
offset + 1);
912 u8 addr = nv_ro08(bios, init->
offset + 2) >> 1;
913 u8 count = nv_ro08(bios, init->
offset + 3);
915 trace(
"I2C_BYTE\tI2C[0x%02x][0x%02x]\n", index, addr);
919 u8 reg = nv_ro08(bios, init->
offset + 0);
920 u8 mask = nv_ro08(bios, init->
offset + 1);
921 u8 data = nv_ro08(bios, init->
offset + 2);
924 trace(
"\t[0x%02x] &= 0x%02x |= 0x%02x\n", reg, mask, data);
927 val = init_rdi2cr(init, index, addr, reg);
930 init_wri2cr(init, index, addr, reg, (val & mask) | data);
942 u8 index = nv_ro08(bios, init->
offset + 1);
943 u8 addr = nv_ro08(bios, init->
offset + 2) >> 1;
944 u8 count = nv_ro08(bios, init->
offset + 3);
946 trace(
"ZM_I2C_BYTE\tI2C[0x%02x][0x%02x]\n", index, addr);
950 u8 reg = nv_ro08(bios, init->
offset + 0);
951 u8 data = nv_ro08(bios, init->
offset + 1);
953 trace(
"\t[0x%02x] = 0x%02x\n", reg, data);
956 init_wri2cr(init, index, addr, reg, data);
969 u8 index = nv_ro08(bios, init->
offset + 1);
970 u8 addr = nv_ro08(bios, init->
offset + 2) >> 1;
971 u8 count = nv_ro08(bios, init->
offset + 3);
974 trace(
"ZM_I2C\tI2C[0x%02x][0x%02x]\n", index, addr);
977 for (i = 0; i <
count; i++) {
978 data[
i] = nv_ro08(bios, init->
offset);
979 trace(
"\t0x%02x\n", data[i]);
991 warn(
"i2c wr failed, %d\n", ret);
1003 u8 tmds = nv_ro08(bios, init->
offset + 1);
1004 u8 addr = nv_ro08(bios, init->
offset + 2);
1005 u8 mask = nv_ro08(bios, init->
offset + 3);
1006 u8 data = nv_ro08(bios, init->
offset + 4);
1007 u32 reg = init_tmds_reg(init, tmds);
1009 trace(
"TMDS\tT[0x%02x][0x%02x] &= 0x%02x |= 0x%02x\n",
1010 tmds, addr, mask, data);
1016 init_wr32(init, reg + 0, addr | 0x00010000);
1017 init_wr32(init, reg + 4, data | (init_rd32(init, reg + 4) & mask));
1018 init_wr32(init, reg + 0, addr);
1029 u8 tmds = nv_ro08(bios, init->
offset + 1);
1030 u8 count = nv_ro08(bios, init->
offset + 2);
1031 u32 reg = init_tmds_reg(init, tmds);
1033 trace(
"TMDS_ZM_GROUP\tT[0x%02x]\n", tmds);
1037 u8 addr = nv_ro08(bios, init->
offset + 0);
1038 u8 data = nv_ro08(bios, init->
offset + 1);
1040 trace(
"\t[0x%02x] = 0x%02x\n", addr, data);
1043 init_wr32(init, reg + 4, data);
1044 init_wr32(init, reg + 0, addr);
1056 u8 addr0 = nv_ro08(bios, init->
offset + 1);
1059 u8 count = nv_ro08(bios, init->
offset + 4);
1062 trace(
"CR_INDEX_ADDR C[%02x] C[%02x]\n", addr0, addr1);
1065 save0 = init_rdvgai(init, 0x03d4, addr0);
1067 u8 data = nv_ro08(bios, init->
offset);
1069 trace(
"\t\t[0x%02x] = 0x%02x\n", base, data);
1072 init_wrvgai(init, 0x03d4, addr0, base++);
1073 init_wrvgai(init, 0x03d4, addr1, data);
1075 init_wrvgai(init, 0x03d4, addr0, save0);
1086 u8 addr = nv_ro08(bios, init->
offset + 1);
1087 u8 mask = nv_ro08(bios, init->
offset + 2);
1088 u8 data = nv_ro08(bios, init->
offset + 3);
1091 trace(
"CR\t\tC[0x%02x] &= 0x%02x |= 0x%02x\n", addr, mask, data);
1094 val = init_rdvgai(init, 0x03d4, addr) &
mask;
1095 init_wrvgai(init, 0x03d4, addr, val | data);
1106 u8 addr = nv_ro08(bios, init->
offset + 1);
1107 u8 data = nv_ro08(bios, init->
offset + 2);
1109 trace(
"ZM_CR\tC[0x%02x] = 0x%02x\n", addr, data);
1112 init_wrvgai(init, 0x03d4, addr, data);
1123 u8 count = nv_ro08(bios, init->
offset + 1);
1125 trace(
"ZM_CR_GROUP\n");
1129 u8 addr = nv_ro08(bios, init->
offset + 0);
1130 u8 data = nv_ro08(bios, init->
offset + 1);
1132 trace(
"\t\tC[0x%02x] = 0x%02x\n", addr, data);
1135 init_wrvgai(init, 0x03d4, addr, data);
1147 u8 cond = nv_ro08(bios, init->
offset + 1);
1151 trace(
"CONDITION_TIME\t0x%02x 0x%02x\n", cond, retry);
1158 if (init_condition_met(init, cond))
1163 init_exec_set(init,
false);
1176 trace(
"LTIME\t0x%04x\n", msec);
1191 u32 base = nv_ro32(bios, init->
offset + 1);
1192 u8 count = nv_ro08(bios, init->
offset + 5);
1194 trace(
"ZM_REG_SEQUENCE\t0x%02x\n", count);
1200 trace(
"\t\tR[0x%06x] = 0x%08x\n", base, data);
1203 init_wr32(init, base, data);
1216 u16 addr = nv_ro16(bios, init->
offset + 1);
1219 trace(
"SUB_DIRECT\t0x%04x\n", addr);
1225 error(
"error parsing sub-table\n");
1242 u16 offset = nv_ro16(bios, init->
offset + 1);
1244 trace(
"JUMP\t0x%04x\n", offset);
1256 u8 index = nv_ro08(bios, init->
offset + 1);
1257 u8 addr = nv_ro08(bios, init->
offset + 2);
1258 u8 reg = nv_ro08(bios, init->
offset + 3);
1259 u8 mask = nv_ro08(bios, init->
offset + 4);
1260 u8 data = nv_ro08(bios, init->
offset + 5);
1263 trace(
"I2C_IF\tI2C[0x%02x][0x%02x][0x%02x] & 0x%02x == 0x%02x\n",
1264 index, addr, reg, mask, data);
1266 init_exec_force(init,
true);
1268 value = init_rdi2cr(init, index, addr, reg);
1269 if ((value & mask) != data)
1270 init_exec_set(init,
false);
1272 init_exec_force(init,
false);
1284 u8 shift = nv_ro08(bios, init->
offset + 5);
1285 u32 smask = nv_ro32(bios, init->
offset + 6);
1286 u32 sxor = nv_ro32(bios, init->
offset + 10);
1287 u32 dreg = nv_ro32(bios, init->
offset + 14);
1288 u32 dmask = nv_ro32(bios, init->
offset + 18);
1291 trace(
"COPY_NV_REG\tR[0x%06x] &= 0x%08x |= "
1292 "((R[0x%06x] %s 0x%02x) & 0x%08x ^ 0x%08x)\n",
1293 dreg, dmask, sreg, (shift & 0x80) ?
"<<" :
">>",
1294 (shift & 0x80) ? (0x100 - shift) : shift, smask, sxor);
1297 data = init_shift(init_rd32(init, sreg), shift);
1298 init_mask(init, dreg, ~dmask, (data & smask) ^ sxor);
1309 u16 port = nv_ro16(bios, init->
offset + 1);
1310 u8 index = nv_ro08(bios, init->
offset + 3);
1311 u8 data = nv_ro08(bios, init->
offset + 4);
1313 trace(
"ZM_INDEX_IO\tI[0x%04x][0x%02x] = 0x%02x\n", port, index, data);
1316 init_wrvgai(init, port, index, data);
1328 trace(
"COMPUTE_MEM\n");
1331 init_exec_force(init,
true);
1334 init_exec_force(init,
false);
1345 u32 reg = nv_ro32(bios, init->
offset + 1);
1350 trace(
"RESET\tR[0x%08x] = 0x%08x, 0x%08x", reg, data1, data2);
1352 init_exec_force(init,
true);
1354 savepci19 = init_mask(init, 0x00184c, 0x00000f00, 0x00000000);
1355 init_wr32(init, reg, data1);
1357 init_wr32(init, reg, data2);
1358 init_wr32(init, 0x00184c, savepci19);
1359 init_mask(init, 0x001850, 0x00000001, 0x00000000);
1361 init_exec_force(init,
false);
1371 u16 mdata = bmp_mem_init_table(init->
bios);
1373 mdata += (init_rdvgai(init, 0x03d4, 0x3c) >> 4) * 66;
1384 trace(
"CONFIGURE_MEM\n");
1387 if (bios->
version.major > 2) {
1391 init_exec_force(init,
true);
1393 mdata = init_configure_mem_clk(init);
1394 sdata = bmp_sdr_seq_table(bios);
1395 if (nv_ro08(bios, mdata) & 0x01)
1396 sdata = bmp_ddr_seq_table(bios);
1399 data = init_rdvgai(init, 0x03c4, 0x01);
1400 init_wrvgai(init, 0x03c4, 0x01, data | 0x20);
1402 while ((addr = nv_ro32(bios, sdata)) != 0xffffffff) {
1410 data = nv_ro32(bios, mdata);
1412 if (data == 0xffffffff)
1417 init_wr32(init, addr, data);
1420 init_exec_force(init,
false);
1433 trace(
"CONFIGURE_CLK\n");
1436 if (bios->
version.major > 2) {
1440 init_exec_force(init,
true);
1442 mdata = init_configure_mem_clk(init);
1445 clock = nv_ro16(bios, mdata + 4) * 10;
1446 init_prog_pll(init, 0x680500, clock);
1449 clock = nv_ro16(bios, mdata + 2) * 10;
1450 if (nv_ro08(bios, mdata) & 0x01)
1452 init_prog_pll(init, 0x680504, clock);
1454 init_exec_force(init,
false);
1467 trace(
"CONFIGURE_PREINIT\n");
1470 if (bios->
version.major > 2) {
1474 init_exec_force(init,
true);
1476 strap = init_rd32(init, 0x101000);
1477 strap = ((strap << 2) & 0xf0) | ((strap & 0x40) >> 6);
1478 init_wrvgai(init, 0x03d4, 0x3c, strap);
1480 init_exec_force(init,
false);
1491 u16 port = nv_ro16(bios, init->
offset + 1);
1492 u8 mask = nv_ro16(bios, init->
offset + 3);
1493 u8 data = nv_ro16(bios, init->
offset + 4);
1496 trace(
"IO\t\tI[0x%04x] &= 0x%02x |= 0x%02x\n", port, mask, data);
1503 if (nv_device(init->
bios)->card_type >= NV_50 &&
1504 port == 0x03c3 && data == 0x01) {
1505 init_mask(init, 0x614100, 0xf0800000, 0x00800000);
1506 init_mask(init, 0x00e18c, 0x00020000, 0x00020000);
1507 init_mask(init, 0x614900, 0xf0800000, 0x00800000);
1508 init_mask(init, 0x000200, 0x40000000, 0x00000000);
1510 init_mask(init, 0x00e18c, 0x00020000, 0x00000000);
1511 init_mask(init, 0x000200, 0x40000000, 0x40000000);
1512 init_wr32(init, 0x614100, 0x00800018);
1513 init_wr32(init, 0x614900, 0x00800018);
1515 init_wr32(init, 0x614100, 0x10000018);
1516 init_wr32(init, 0x614900, 0x10000018);
1520 value = init_rdport(init, port) &
mask;
1521 init_wrport(init, port, data | value);
1532 u8 index = nv_ro08(bios, init->
offset + 1);
1535 trace(
"SUB\t0x%02x\n", index);
1537 addr = init_script(bios, index);
1542 error(
"error parsing sub-table\n");
1559 u8 mask = nv_ro08(bios, init->
offset + 1);
1560 u8 value = nv_ro08(bios, init->
offset + 2);
1562 trace(
"RAM_CONDITION\t"
1563 "(R[0x100000] & 0x%02x) == 0x%02x\n", mask, value);
1566 if ((init_rd32(init, 0x100000) & mask) != value)
1567 init_exec_set(init,
false);
1578 u32 reg = nv_ro32(bios, init->
offset + 1);
1579 u32 mask = nv_ro32(bios, init->
offset + 5);
1580 u32 data = nv_ro32(bios, init->
offset + 9);
1582 trace(
"NV_REG\tR[0x%06x] &= 0x%08x |= 0x%08x\n", reg, mask, data);
1585 init_mask(init, reg, ~mask, data);
1596 u8 macro = nv_ro08(bios, init->
offset + 1);
1599 trace(
"MACRO\t0x%02x\n", macro);
1603 u32 addr = nv_ro32(bios, table + (macro * 8) + 0);
1604 u32 data = nv_ro32(bios, table + (macro * 8) + 4);
1605 trace(
"\t\tR[0x%06x] = 0x%08x\n", addr, data);
1606 init_wr32(init, addr, data);
1621 init_exec_set(init,
true);
1632 u16 usec = nv_ro16(bios, init->
offset + 1);
1634 trace(
"TIME\t0x%04x\n", usec);
1641 mdelay((usec + 900) / 1000);
1653 u8 cond = nv_ro08(bios, init->
offset + 1);
1655 trace(
"CONDITION\t0x%02x\n", cond);
1658 if (!init_condition_met(init, cond))
1659 init_exec_set(init,
false);
1670 u8 cond = nv_ro08(bios, init->
offset + 1);
1672 trace(
"IO_CONDITION\t0x%02x\n", cond);
1675 if (!init_io_condition_met(init, cond))
1676 init_exec_set(init,
false);
1687 u16 port = nv_ro16(bios, init->
offset + 1);
1688 u8 index = nv_ro16(bios, init->
offset + 3);
1689 u8 mask = nv_ro08(bios, init->
offset + 4);
1690 u8 data = nv_ro08(bios, init->
offset + 5);
1693 trace(
"INDEX_IO\tI[0x%04x][0x%02x] &= 0x%02x |= 0x%02x\n",
1694 port, index, mask, data);
1697 value = init_rdvgai(init, port, index) &
mask;
1698 init_wrvgai(init, port, index, data | value);
1709 u32 reg = nv_ro32(bios, init->
offset + 1);
1710 u32 freq = nv_ro16(bios, init->
offset + 5) * 10;
1712 trace(
"PLL\tR[0x%06x] =PLL= %dkHz\n", reg, freq);
1715 init_prog_pll(init, reg, freq);
1726 u32 addr = nv_ro32(bios, init->
offset + 1);
1727 u32 data = nv_ro32(bios, init->
offset + 5);
1729 trace(
"ZM_REG\tR[0x%06x] = 0x%08x\n", addr, data);
1732 if (addr == 0x000200)
1735 init_wr32(init, addr, data);
1747 u8 count = init_ram_restrict_group_count(init);
1748 u8 strap = init_ram_restrict(init);
1751 trace(
"RAM_RESTRICT_PLL\t0x%02x\n", type);
1754 for (cconf = 0; cconf <
count; cconf++) {
1757 if (cconf == strap) {
1758 trace(
"%dkHz *\n", freq);
1759 init_prog_pll(init, type, freq);
1761 trace(
"%dkHz\n", freq);
1789 init_ram_restrict_zm_reg_group(
struct nvbios_init *init)
1792 u32 addr = nv_ro32(bios, init->
offset + 1);
1793 u8 incr = nv_ro08(bios, init->
offset + 5);
1795 u8 count = init_ram_restrict_group_count(init);
1796 u8 index = init_ram_restrict(init);
1799 trace(
"RAM_RESTRICT_ZM_REG_GROUP\t"
1800 "R[%08x] 0x%02x 0x%02x\n", addr, incr, num);
1803 for (i = 0; i < num; i++) {
1804 trace(
"\tR[0x%06x] = {\n", addr);
1805 for (j = 0; j <
count; j++) {
1809 trace(
"\t\t0x%08x *\n", data);
1810 init_wr32(init, addr, data);
1812 trace(
"\t\t0x%08x\n", data);
1830 u32 sreg = nv_ro32(bios, init->
offset + 1);
1831 u32 dreg = nv_ro32(bios, init->
offset + 5);
1833 trace(
"COPY_ZM_REG\tR[0x%06x] = R[0x%06x]\n", sreg, dreg);
1836 init_wr32(init, dreg, init_rd32(init, sreg));
1847 u32 addr = nv_ro32(bios, init->
offset + 1);
1848 u8 count = nv_ro08(bios, init->
offset + 5);
1850 trace(
"ZM_REG_GROUP\tR[0x%06x] =\n");
1855 trace(
"\t0x%08x\n", data);
1856 init_wr32(init, addr, data);
1870 u8 sshift = nv_ro08(bios, init->
offset + 5);
1871 u8 smask = nv_ro08(bios, init->
offset + 6);
1872 u8 index = nv_ro08(bios, init->
offset + 7);
1874 u32 dmask = nv_ro32(bios, init->
offset + 12);
1875 u8 shift = nv_ro08(bios, init->
offset + 16);
1878 trace(
"INIT_XLAT\tR[0x%06x] &= 0x%08x |= "
1879 "(X%02x((R[0x%06x] %s 0x%02x) & 0x%02x) << 0x%02x)\n",
1880 daddr, dmask, index, saddr, (sshift & 0x80) ?
"<<" :
">>",
1881 (sshift & 0x80) ? (0x100 - sshift) : sshift, smask, shift);
1884 data = init_shift(init_rd32(init, saddr), sshift) &
smask;
1885 data = init_xlat_(init, index, data) << shift;
1886 init_mask(init, daddr, ~dmask, data);
1897 u32 addr = nv_ro32(bios, init->
offset + 1);
1898 u32 mask = nv_ro32(bios, init->
offset + 5);
1902 trace(
"ZM_MASK_ADD\tR[0x%06x] &= 0x%08x += 0x%08x\n", addr, mask, add);
1905 data = init_rd32(init, addr) &
mask;
1906 data |= ((data +
add) & ~mask);
1907 init_wr32(init, addr, data);
1918 u32 addr = nv_ro32(bios, init->
offset + 1);
1919 u8 count = nv_ro08(bios, init->
offset + 5);
1921 trace(
"AUXCH\tAUX[0x%08x] 0x%02x\n", addr, count);
1925 u8 mask = nv_ro08(bios, init->
offset + 0);
1926 u8 data = nv_ro08(bios, init->
offset + 1);
1927 trace(
"\tAUX[0x%08x] &= 0x%02x |= 0x%02x\n", addr, mask, data);
1928 mask = init_rdauxr(init, addr) &
mask;
1929 init_wrauxr(init, addr, mask | data);
1942 u32 addr = nv_ro32(bios, init->
offset + 1);
1943 u8 count = nv_ro08(bios, init->
offset + 5);
1945 trace(
"ZM_AUXCH\tAUX[0x%08x] 0x%02x\n", addr, count);
1949 u8 data = nv_ro08(bios, init->
offset + 0);
1950 trace(
"\tAUX[0x%08x] = 0x%02x\n", addr, data);
1951 init_wrauxr(init, addr, data);
1964 u8 index = nv_ro08(bios, init->
offset + 1);
1965 u8 addr = nv_ro08(bios, init->
offset + 2) >> 1;
1966 u8 reglo = nv_ro08(bios, init->
offset + 3);
1967 u8 reghi = nv_ro08(bios, init->
offset + 4);
1968 u8 mask = nv_ro08(bios, init->
offset + 5);
1969 u8 data = nv_ro08(bios, init->
offset + 6);
1972 trace(
"I2C_LONG_IF\t"
1973 "I2C[0x%02x][0x%02x][0x%02x%02x] & 0x%02x == 0x%02x\n",
1974 index, addr, reglo, reghi, mask, data);
1977 port = init_i2c(init, index);
1979 u8 i[2] = { reghi, reglo };
1982 { .
addr =
addr, .flags = 0, .len = 2, .buf = i },
1988 if (ret == 2 && ((o[0] & mask) == data))
1992 init_exec_set(init,
false);
1995 static struct nvbios_init_opcode {
1998 [0x32] = { init_io_restrict_prog },
1999 [0x33] = { init_repeat },
2000 [0x34] = { init_io_restrict_pll },
2001 [0x36] = { init_end_repeat },
2002 [0x37] = { init_copy },
2003 [0x38] = { init_not },
2004 [0x39] = { init_io_flag_condition },
2005 [0x3a] = { init_dp_condition },
2006 [0x3b] = { init_io_mask_or },
2007 [0x3c] = { init_io_or },
2008 [0x49] = { init_idx_addr_latched },
2009 [0x4a] = { init_io_restrict_pll2 },
2010 [0x4b] = { init_pll2 },
2011 [0x4c] = { init_i2c_byte },
2012 [0x4d] = { init_zm_i2c_byte },
2013 [0x4e] = { init_zm_i2c },
2014 [0x4f] = { init_tmds },
2015 [0x50] = { init_zm_tmds_group },
2016 [0x51] = { init_cr_idx_adr_latch },
2017 [0x52] = { init_cr },
2018 [0x53] = { init_zm_cr },
2019 [0x54] = { init_zm_cr_group },
2020 [0x56] = { init_condition_time },
2021 [0x57] = { init_ltime },
2022 [0x58] = { init_zm_reg_sequence },
2023 [0x5b] = { init_sub_direct },
2024 [0x5c] = { init_jump },
2025 [0x5e] = { init_i2c_if },
2026 [0x5f] = { init_copy_nv_reg },
2027 [0x62] = { init_zm_index_io },
2028 [0x63] = { init_compute_mem },
2029 [0x65] = { init_reset },
2030 [0x66] = { init_configure_mem },
2031 [0x67] = { init_configure_clk },
2032 [0x68] = { init_configure_preinit },
2033 [0x69] = { init_io },
2034 [0x6b] = { init_sub },
2035 [0x6d] = { init_ram_condition },
2036 [0x6e] = { init_nv_reg },
2037 [0x6f] = { init_macro },
2038 [0x71] = { init_done },
2039 [0x72] = { init_resume },
2040 [0x74] = { init_time },
2041 [0x75] = { init_condition },
2042 [0x76] = { init_io_condition },
2043 [0x78] = { init_index_io },
2044 [0x79] = { init_pll },
2045 [0x7a] = { init_zm_reg },
2046 [0x87] = { init_ram_restrict_pll },
2047 [0x8c] = { init_reserved },
2048 [0x8d] = { init_reserved },
2049 [0x8e] = { init_gpio },
2050 [0x8f] = { init_ram_restrict_zm_reg_group },
2051 [0x90] = { init_copy_zm_reg },
2052 [0x91] = { init_zm_reg_group },
2053 [0x92] = { init_reserved },
2054 [0x96] = { init_xlat },
2055 [0x97] = { init_zm_mask_add },
2056 [0x98] = { init_auxch },
2057 [0x99] = { init_zm_auxch },
2058 [0x9a] = { init_i2c_long_if },
2061 #define init_opcode_nr (sizeof(init_opcode) / sizeof(init_opcode[0]))
2070 error(
"unknown opcode 0x%02x\n", opcode);
2074 init_opcode[
opcode].exec(init);
2089 nv_info(bios,
"running init tables\n");
2090 while (!ret && (data = (init_script(bios, ++i)))) {
2097 .execute = execute ? 1 : 0,
2106 if (!ret && (data = init_unknown_script(bios))) {
2113 .execute = execute ? 1 : 0,