base.c 66.4 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
/*
 * Copyright 2012 Red Hat Inc.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 * OTHER DEALINGS IN THE SOFTWARE.
 *
 * Authors: Ben Skeggs
 */
24 25
#include "priv.h"
#include "acpi.h"
26

27
#include <core/notify.h>
28
#include <core/option.h>
29

30
#include <subdev/bios.h>
31 32 33 34

static DEFINE_MUTEX(nv_devices_mutex);
static LIST_HEAD(nv_devices);

35 36
static struct nvkm_device *
nvkm_device_find_locked(u64 handle)
37
{
38
	struct nvkm_device *device;
39
	list_for_each_entry(device, &nv_devices, head) {
40 41
		if (device->handle == handle)
			return device;
42
	}
43 44 45 46 47 48 49 50 51
	return NULL;
}

struct nvkm_device *
nvkm_device_find(u64 handle)
{
	struct nvkm_device *device;
	mutex_lock(&nv_devices_mutex);
	device = nvkm_device_find_locked(handle);
52
	mutex_unlock(&nv_devices_mutex);
53
	return device;
54 55
}

56
int
57
nvkm_device_list(u64 *name, int size)
58
{
59
	struct nvkm_device *device;
60 61 62 63 64 65 66 67 68 69
	int nr = 0;
	mutex_lock(&nv_devices_mutex);
	list_for_each_entry(device, &nv_devices, head) {
		if (nr++ < size)
			name[nr - 1] = device->handle;
	}
	mutex_unlock(&nv_devices_mutex);
	return nr;
}

70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979
static const struct nvkm_device_chip
null_chipset = {
	.name = "NULL",
//	.bios = nvkm_bios_new,
};

static const struct nvkm_device_chip
nv4_chipset = {
	.name = "NV04",
//	.bios = nvkm_bios_new,
//	.bus = nv04_bus_new,
//	.clk = nv04_clk_new,
//	.devinit = nv04_devinit_new,
//	.fb = nv04_fb_new,
//	.i2c = nv04_i2c_new,
//	.imem = nv04_instmem_new,
//	.mc = nv04_mc_new,
//	.mmu = nv04_mmu_new,
//	.timer = nv04_timer_new,
//	.disp = nv04_disp_new,
//	.dma = nv04_dma_new,
//	.fifo = nv04_fifo_new,
//	.gr = nv04_gr_new,
//	.sw = nv04_sw_new,
};

static const struct nvkm_device_chip
nv5_chipset = {
	.name = "NV05",
//	.bios = nvkm_bios_new,
//	.bus = nv04_bus_new,
//	.clk = nv04_clk_new,
//	.devinit = nv05_devinit_new,
//	.fb = nv04_fb_new,
//	.i2c = nv04_i2c_new,
//	.imem = nv04_instmem_new,
//	.mc = nv04_mc_new,
//	.mmu = nv04_mmu_new,
//	.timer = nv04_timer_new,
//	.disp = nv04_disp_new,
//	.dma = nv04_dma_new,
//	.fifo = nv04_fifo_new,
//	.gr = nv04_gr_new,
//	.sw = nv04_sw_new,
};

static const struct nvkm_device_chip
nv10_chipset = {
	.name = "NV10",
//	.bios = nvkm_bios_new,
//	.bus = nv04_bus_new,
//	.clk = nv04_clk_new,
//	.devinit = nv10_devinit_new,
//	.fb = nv10_fb_new,
//	.gpio = nv10_gpio_new,
//	.i2c = nv04_i2c_new,
//	.imem = nv04_instmem_new,
//	.mc = nv04_mc_new,
//	.mmu = nv04_mmu_new,
//	.timer = nv04_timer_new,
//	.disp = nv04_disp_new,
//	.dma = nv04_dma_new,
//	.gr = nv10_gr_new,
};

static const struct nvkm_device_chip
nv11_chipset = {
	.name = "NV11",
//	.bios = nvkm_bios_new,
//	.bus = nv04_bus_new,
//	.clk = nv04_clk_new,
//	.devinit = nv10_devinit_new,
//	.fb = nv10_fb_new,
//	.gpio = nv10_gpio_new,
//	.i2c = nv04_i2c_new,
//	.imem = nv04_instmem_new,
//	.mc = nv04_mc_new,
//	.mmu = nv04_mmu_new,
//	.timer = nv04_timer_new,
//	.disp = nv04_disp_new,
//	.dma = nv04_dma_new,
//	.fifo = nv10_fifo_new,
//	.gr = nv10_gr_new,
//	.sw = nv10_sw_new,
};

static const struct nvkm_device_chip
nv15_chipset = {
	.name = "NV15",
//	.bios = nvkm_bios_new,
//	.bus = nv04_bus_new,
//	.clk = nv04_clk_new,
//	.devinit = nv10_devinit_new,
//	.fb = nv10_fb_new,
//	.gpio = nv10_gpio_new,
//	.i2c = nv04_i2c_new,
//	.imem = nv04_instmem_new,
//	.mc = nv04_mc_new,
//	.mmu = nv04_mmu_new,
//	.timer = nv04_timer_new,
//	.disp = nv04_disp_new,
//	.dma = nv04_dma_new,
//	.fifo = nv10_fifo_new,
//	.gr = nv10_gr_new,
//	.sw = nv10_sw_new,
};

static const struct nvkm_device_chip
nv17_chipset = {
	.name = "NV17",
//	.bios = nvkm_bios_new,
//	.bus = nv04_bus_new,
//	.clk = nv04_clk_new,
//	.devinit = nv10_devinit_new,
//	.fb = nv10_fb_new,
//	.gpio = nv10_gpio_new,
//	.i2c = nv04_i2c_new,
//	.imem = nv04_instmem_new,
//	.mc = nv04_mc_new,
//	.mmu = nv04_mmu_new,
//	.timer = nv04_timer_new,
//	.disp = nv04_disp_new,
//	.dma = nv04_dma_new,
//	.fifo = nv17_fifo_new,
//	.gr = nv10_gr_new,
//	.sw = nv10_sw_new,
};

static const struct nvkm_device_chip
nv18_chipset = {
	.name = "NV18",
//	.bios = nvkm_bios_new,
//	.bus = nv04_bus_new,
//	.clk = nv04_clk_new,
//	.devinit = nv10_devinit_new,
//	.fb = nv10_fb_new,
//	.gpio = nv10_gpio_new,
//	.i2c = nv04_i2c_new,
//	.imem = nv04_instmem_new,
//	.mc = nv04_mc_new,
//	.mmu = nv04_mmu_new,
//	.timer = nv04_timer_new,
//	.disp = nv04_disp_new,
//	.dma = nv04_dma_new,
//	.fifo = nv17_fifo_new,
//	.gr = nv10_gr_new,
//	.sw = nv10_sw_new,
};

static const struct nvkm_device_chip
nv1a_chipset = {
	.name = "nForce",
//	.bios = nvkm_bios_new,
//	.bus = nv04_bus_new,
//	.clk = nv04_clk_new,
//	.devinit = nv1a_devinit_new,
//	.fb = nv1a_fb_new,
//	.gpio = nv10_gpio_new,
//	.i2c = nv04_i2c_new,
//	.imem = nv04_instmem_new,
//	.mc = nv04_mc_new,
//	.mmu = nv04_mmu_new,
//	.timer = nv04_timer_new,
//	.disp = nv04_disp_new,
//	.dma = nv04_dma_new,
//	.fifo = nv10_fifo_new,
//	.gr = nv10_gr_new,
//	.sw = nv10_sw_new,
};

static const struct nvkm_device_chip
nv1f_chipset = {
	.name = "nForce2",
//	.bios = nvkm_bios_new,
//	.bus = nv04_bus_new,
//	.clk = nv04_clk_new,
//	.devinit = nv1a_devinit_new,
//	.fb = nv1a_fb_new,
//	.gpio = nv10_gpio_new,
//	.i2c = nv04_i2c_new,
//	.imem = nv04_instmem_new,
//	.mc = nv04_mc_new,
//	.mmu = nv04_mmu_new,
//	.timer = nv04_timer_new,
//	.disp = nv04_disp_new,
//	.dma = nv04_dma_new,
//	.fifo = nv17_fifo_new,
//	.gr = nv10_gr_new,
//	.sw = nv10_sw_new,
};

static const struct nvkm_device_chip
nv20_chipset = {
	.name = "NV20",
//	.bios = nvkm_bios_new,
//	.bus = nv04_bus_new,
//	.clk = nv04_clk_new,
//	.devinit = nv20_devinit_new,
//	.fb = nv20_fb_new,
//	.gpio = nv10_gpio_new,
//	.i2c = nv04_i2c_new,
//	.imem = nv04_instmem_new,
//	.mc = nv04_mc_new,
//	.mmu = nv04_mmu_new,
//	.timer = nv04_timer_new,
//	.disp = nv04_disp_new,
//	.dma = nv04_dma_new,
//	.fifo = nv17_fifo_new,
//	.gr = nv20_gr_new,
//	.sw = nv10_sw_new,
};

static const struct nvkm_device_chip
nv25_chipset = {
	.name = "NV25",
//	.bios = nvkm_bios_new,
//	.bus = nv04_bus_new,
//	.clk = nv04_clk_new,
//	.devinit = nv20_devinit_new,
//	.fb = nv25_fb_new,
//	.gpio = nv10_gpio_new,
//	.i2c = nv04_i2c_new,
//	.imem = nv04_instmem_new,
//	.mc = nv04_mc_new,
//	.mmu = nv04_mmu_new,
//	.timer = nv04_timer_new,
//	.disp = nv04_disp_new,
//	.dma = nv04_dma_new,
//	.fifo = nv17_fifo_new,
//	.gr = nv25_gr_new,
//	.sw = nv10_sw_new,
};

static const struct nvkm_device_chip
nv28_chipset = {
	.name = "NV28",
//	.bios = nvkm_bios_new,
//	.bus = nv04_bus_new,
//	.clk = nv04_clk_new,
//	.devinit = nv20_devinit_new,
//	.fb = nv25_fb_new,
//	.gpio = nv10_gpio_new,
//	.i2c = nv04_i2c_new,
//	.imem = nv04_instmem_new,
//	.mc = nv04_mc_new,
//	.mmu = nv04_mmu_new,
//	.timer = nv04_timer_new,
//	.disp = nv04_disp_new,
//	.dma = nv04_dma_new,
//	.fifo = nv17_fifo_new,
//	.gr = nv25_gr_new,
//	.sw = nv10_sw_new,
};

static const struct nvkm_device_chip
nv2a_chipset = {
	.name = "NV2A",
//	.bios = nvkm_bios_new,
//	.bus = nv04_bus_new,
//	.clk = nv04_clk_new,
//	.devinit = nv20_devinit_new,
//	.fb = nv25_fb_new,
//	.gpio = nv10_gpio_new,
//	.i2c = nv04_i2c_new,
//	.imem = nv04_instmem_new,
//	.mc = nv04_mc_new,
//	.mmu = nv04_mmu_new,
//	.timer = nv04_timer_new,
//	.disp = nv04_disp_new,
//	.dma = nv04_dma_new,
//	.fifo = nv17_fifo_new,
//	.gr = nv2a_gr_new,
//	.sw = nv10_sw_new,
};

static const struct nvkm_device_chip
nv30_chipset = {
	.name = "NV30",
//	.bios = nvkm_bios_new,
//	.bus = nv04_bus_new,
//	.clk = nv04_clk_new,
//	.devinit = nv20_devinit_new,
//	.fb = nv30_fb_new,
//	.gpio = nv10_gpio_new,
//	.i2c = nv04_i2c_new,
//	.imem = nv04_instmem_new,
//	.mc = nv04_mc_new,
//	.mmu = nv04_mmu_new,
//	.timer = nv04_timer_new,
//	.disp = nv04_disp_new,
//	.dma = nv04_dma_new,
//	.fifo = nv17_fifo_new,
//	.gr = nv30_gr_new,
//	.sw = nv10_sw_new,
};

static const struct nvkm_device_chip
nv31_chipset = {
	.name = "NV31",
//	.bios = nvkm_bios_new,
//	.bus = nv31_bus_new,
//	.clk = nv04_clk_new,
//	.devinit = nv20_devinit_new,
//	.fb = nv30_fb_new,
//	.gpio = nv10_gpio_new,
//	.i2c = nv04_i2c_new,
//	.imem = nv04_instmem_new,
//	.mc = nv04_mc_new,
//	.mmu = nv04_mmu_new,
//	.timer = nv04_timer_new,
//	.disp = nv04_disp_new,
//	.dma = nv04_dma_new,
//	.fifo = nv17_fifo_new,
//	.gr = nv30_gr_new,
//	.mpeg = nv31_mpeg_new,
//	.sw = nv10_sw_new,
};

static const struct nvkm_device_chip
nv34_chipset = {
	.name = "NV34",
//	.bios = nvkm_bios_new,
//	.bus = nv31_bus_new,
//	.clk = nv04_clk_new,
//	.devinit = nv10_devinit_new,
//	.fb = nv10_fb_new,
//	.gpio = nv10_gpio_new,
//	.i2c = nv04_i2c_new,
//	.imem = nv04_instmem_new,
//	.mc = nv04_mc_new,
//	.mmu = nv04_mmu_new,
//	.timer = nv04_timer_new,
//	.disp = nv04_disp_new,
//	.dma = nv04_dma_new,
//	.fifo = nv17_fifo_new,
//	.gr = nv34_gr_new,
//	.mpeg = nv31_mpeg_new,
//	.sw = nv10_sw_new,
};

static const struct nvkm_device_chip
nv35_chipset = {
	.name = "NV35",
//	.bios = nvkm_bios_new,
//	.bus = nv04_bus_new,
//	.clk = nv04_clk_new,
//	.devinit = nv20_devinit_new,
//	.fb = nv35_fb_new,
//	.gpio = nv10_gpio_new,
//	.i2c = nv04_i2c_new,
//	.imem = nv04_instmem_new,
//	.mc = nv04_mc_new,
//	.mmu = nv04_mmu_new,
//	.timer = nv04_timer_new,
//	.disp = nv04_disp_new,
//	.dma = nv04_dma_new,
//	.fifo = nv17_fifo_new,
//	.gr = nv35_gr_new,
//	.sw = nv10_sw_new,
};

static const struct nvkm_device_chip
nv36_chipset = {
	.name = "NV36",
//	.bios = nvkm_bios_new,
//	.bus = nv31_bus_new,
//	.clk = nv04_clk_new,
//	.devinit = nv20_devinit_new,
//	.fb = nv36_fb_new,
//	.gpio = nv10_gpio_new,
//	.i2c = nv04_i2c_new,
//	.imem = nv04_instmem_new,
//	.mc = nv04_mc_new,
//	.mmu = nv04_mmu_new,
//	.timer = nv04_timer_new,
//	.disp = nv04_disp_new,
//	.dma = nv04_dma_new,
//	.fifo = nv17_fifo_new,
//	.gr = nv35_gr_new,
//	.mpeg = nv31_mpeg_new,
//	.sw = nv10_sw_new,
};

static const struct nvkm_device_chip
nv40_chipset = {
	.name = "NV40",
//	.bios = nvkm_bios_new,
//	.bus = nv31_bus_new,
//	.clk = nv40_clk_new,
//	.devinit = nv1a_devinit_new,
//	.fb = nv40_fb_new,
//	.gpio = nv10_gpio_new,
//	.i2c = nv04_i2c_new,
//	.imem = nv40_instmem_new,
//	.mc = nv40_mc_new,
//	.mmu = nv04_mmu_new,
//	.therm = nv40_therm_new,
//	.timer = nv04_timer_new,
//	.volt = nv40_volt_new,
//	.disp = nv04_disp_new,
//	.dma = nv04_dma_new,
//	.fifo = nv40_fifo_new,
//	.gr = nv40_gr_new,
//	.mpeg = nv40_mpeg_new,
//	.pm = nv40_pm_new,
//	.sw = nv10_sw_new,
};

static const struct nvkm_device_chip
nv41_chipset = {
	.name = "NV41",
//	.bios = nvkm_bios_new,
//	.bus = nv31_bus_new,
//	.clk = nv40_clk_new,
//	.devinit = nv1a_devinit_new,
//	.fb = nv41_fb_new,
//	.gpio = nv10_gpio_new,
//	.i2c = nv04_i2c_new,
//	.imem = nv40_instmem_new,
//	.mc = nv40_mc_new,
//	.mmu = nv41_mmu_new,
//	.therm = nv40_therm_new,
//	.timer = nv04_timer_new,
//	.volt = nv40_volt_new,
//	.disp = nv04_disp_new,
//	.dma = nv04_dma_new,
//	.fifo = nv40_fifo_new,
//	.gr = nv40_gr_new,
//	.mpeg = nv40_mpeg_new,
//	.pm = nv40_pm_new,
//	.sw = nv10_sw_new,
};

static const struct nvkm_device_chip
nv42_chipset = {
	.name = "NV42",
//	.bios = nvkm_bios_new,
//	.bus = nv31_bus_new,
//	.clk = nv40_clk_new,
//	.devinit = nv1a_devinit_new,
//	.fb = nv41_fb_new,
//	.gpio = nv10_gpio_new,
//	.i2c = nv04_i2c_new,
//	.imem = nv40_instmem_new,
//	.mc = nv40_mc_new,
//	.mmu = nv41_mmu_new,
//	.therm = nv40_therm_new,
//	.timer = nv04_timer_new,
//	.volt = nv40_volt_new,
//	.disp = nv04_disp_new,
//	.dma = nv04_dma_new,
//	.fifo = nv40_fifo_new,
//	.gr = nv40_gr_new,
//	.mpeg = nv40_mpeg_new,
//	.pm = nv40_pm_new,
//	.sw = nv10_sw_new,
};

static const struct nvkm_device_chip
nv43_chipset = {
	.name = "NV43",
//	.bios = nvkm_bios_new,
//	.bus = nv31_bus_new,
//	.clk = nv40_clk_new,
//	.devinit = nv1a_devinit_new,
//	.fb = nv41_fb_new,
//	.gpio = nv10_gpio_new,
//	.i2c = nv04_i2c_new,
//	.imem = nv40_instmem_new,
//	.mc = nv40_mc_new,
//	.mmu = nv41_mmu_new,
//	.therm = nv40_therm_new,
//	.timer = nv04_timer_new,
//	.volt = nv40_volt_new,
//	.disp = nv04_disp_new,
//	.dma = nv04_dma_new,
//	.fifo = nv40_fifo_new,
//	.gr = nv40_gr_new,
//	.mpeg = nv40_mpeg_new,
//	.pm = nv40_pm_new,
//	.sw = nv10_sw_new,
};

static const struct nvkm_device_chip
nv44_chipset = {
	.name = "NV44",
//	.bios = nvkm_bios_new,
//	.bus = nv31_bus_new,
//	.clk = nv40_clk_new,
//	.devinit = nv1a_devinit_new,
//	.fb = nv44_fb_new,
//	.gpio = nv10_gpio_new,
//	.i2c = nv04_i2c_new,
//	.imem = nv40_instmem_new,
//	.mc = nv44_mc_new,
//	.mmu = nv44_mmu_new,
//	.therm = nv40_therm_new,
//	.timer = nv04_timer_new,
//	.volt = nv40_volt_new,
//	.disp = nv04_disp_new,
//	.dma = nv04_dma_new,
//	.fifo = nv40_fifo_new,
//	.gr = nv40_gr_new,
//	.mpeg = nv44_mpeg_new,
//	.pm = nv40_pm_new,
//	.sw = nv10_sw_new,
};

static const struct nvkm_device_chip
nv45_chipset = {
	.name = "NV45",
//	.bios = nvkm_bios_new,
//	.bus = nv31_bus_new,
//	.clk = nv40_clk_new,
//	.devinit = nv1a_devinit_new,
//	.fb = nv40_fb_new,
//	.gpio = nv10_gpio_new,
//	.i2c = nv04_i2c_new,
//	.imem = nv40_instmem_new,
//	.mc = nv40_mc_new,
//	.mmu = nv04_mmu_new,
//	.therm = nv40_therm_new,
//	.timer = nv04_timer_new,
//	.volt = nv40_volt_new,
//	.disp = nv04_disp_new,
//	.dma = nv04_dma_new,
//	.fifo = nv40_fifo_new,
//	.gr = nv40_gr_new,
//	.mpeg = nv44_mpeg_new,
//	.pm = nv40_pm_new,
//	.sw = nv10_sw_new,
};

static const struct nvkm_device_chip
nv46_chipset = {
	.name = "G72",
//	.bios = nvkm_bios_new,
//	.bus = nv31_bus_new,
//	.clk = nv40_clk_new,
//	.devinit = nv1a_devinit_new,
//	.fb = nv46_fb_new,
//	.gpio = nv10_gpio_new,
//	.i2c = nv04_i2c_new,
//	.imem = nv40_instmem_new,
//	.mc = nv44_mc_new,
//	.mmu = nv44_mmu_new,
//	.therm = nv40_therm_new,
//	.timer = nv04_timer_new,
//	.volt = nv40_volt_new,
//	.disp = nv04_disp_new,
//	.dma = nv04_dma_new,
//	.fifo = nv40_fifo_new,
//	.gr = nv40_gr_new,
//	.mpeg = nv44_mpeg_new,
//	.pm = nv40_pm_new,
//	.sw = nv10_sw_new,
};

static const struct nvkm_device_chip
nv47_chipset = {
	.name = "G70",
//	.bios = nvkm_bios_new,
//	.bus = nv31_bus_new,
//	.clk = nv40_clk_new,
//	.devinit = nv1a_devinit_new,
//	.fb = nv47_fb_new,
//	.gpio = nv10_gpio_new,
//	.i2c = nv04_i2c_new,
//	.imem = nv40_instmem_new,
//	.mc = nv40_mc_new,
//	.mmu = nv41_mmu_new,
//	.therm = nv40_therm_new,
//	.timer = nv04_timer_new,
//	.volt = nv40_volt_new,
//	.disp = nv04_disp_new,
//	.dma = nv04_dma_new,
//	.fifo = nv40_fifo_new,
//	.gr = nv40_gr_new,
//	.mpeg = nv44_mpeg_new,
//	.pm = nv40_pm_new,
//	.sw = nv10_sw_new,
};

static const struct nvkm_device_chip
nv49_chipset = {
	.name = "G71",
//	.bios = nvkm_bios_new,
//	.bus = nv31_bus_new,
//	.clk = nv40_clk_new,
//	.devinit = nv1a_devinit_new,
//	.fb = nv49_fb_new,
//	.gpio = nv10_gpio_new,
//	.i2c = nv04_i2c_new,
//	.imem = nv40_instmem_new,
//	.mc = nv40_mc_new,
//	.mmu = nv41_mmu_new,
//	.therm = nv40_therm_new,
//	.timer = nv04_timer_new,
//	.volt = nv40_volt_new,
//	.disp = nv04_disp_new,
//	.dma = nv04_dma_new,
//	.fifo = nv40_fifo_new,
//	.gr = nv40_gr_new,
//	.mpeg = nv44_mpeg_new,
//	.pm = nv40_pm_new,
//	.sw = nv10_sw_new,
};

static const struct nvkm_device_chip
nv4a_chipset = {
	.name = "NV44A",
//	.bios = nvkm_bios_new,
//	.bus = nv31_bus_new,
//	.clk = nv40_clk_new,
//	.devinit = nv1a_devinit_new,
//	.fb = nv44_fb_new,
//	.gpio = nv10_gpio_new,
//	.i2c = nv04_i2c_new,
//	.imem = nv40_instmem_new,
//	.mc = nv44_mc_new,
//	.mmu = nv44_mmu_new,
//	.therm = nv40_therm_new,
//	.timer = nv04_timer_new,
//	.volt = nv40_volt_new,
//	.disp = nv04_disp_new,
//	.dma = nv04_dma_new,
//	.fifo = nv40_fifo_new,
//	.gr = nv40_gr_new,
//	.mpeg = nv44_mpeg_new,
//	.pm = nv40_pm_new,
//	.sw = nv10_sw_new,
};

static const struct nvkm_device_chip
nv4b_chipset = {
	.name = "G73",
//	.bios = nvkm_bios_new,
//	.bus = nv31_bus_new,
//	.clk = nv40_clk_new,
//	.devinit = nv1a_devinit_new,
//	.fb = nv49_fb_new,
//	.gpio = nv10_gpio_new,
//	.i2c = nv04_i2c_new,
//	.imem = nv40_instmem_new,
//	.mc = nv40_mc_new,
//	.mmu = nv41_mmu_new,
//	.therm = nv40_therm_new,
//	.timer = nv04_timer_new,
//	.volt = nv40_volt_new,
//	.disp = nv04_disp_new,
//	.dma = nv04_dma_new,
//	.fifo = nv40_fifo_new,
//	.gr = nv40_gr_new,
//	.mpeg = nv44_mpeg_new,
//	.pm = nv40_pm_new,
//	.sw = nv10_sw_new,
};

static const struct nvkm_device_chip
nv4c_chipset = {
	.name = "C61",
//	.bios = nvkm_bios_new,
//	.bus = nv31_bus_new,
//	.clk = nv40_clk_new,
//	.devinit = nv1a_devinit_new,
//	.fb = nv46_fb_new,
//	.gpio = nv10_gpio_new,
//	.i2c = nv04_i2c_new,
//	.imem = nv40_instmem_new,
//	.mc = nv4c_mc_new,
//	.mmu = nv44_mmu_new,
//	.therm = nv40_therm_new,
//	.timer = nv04_timer_new,
//	.volt = nv40_volt_new,
//	.disp = nv04_disp_new,
//	.dma = nv04_dma_new,
//	.fifo = nv40_fifo_new,
//	.gr = nv40_gr_new,
//	.mpeg = nv44_mpeg_new,
//	.pm = nv40_pm_new,
//	.sw = nv10_sw_new,
};

static const struct nvkm_device_chip
nv4e_chipset = {
	.name = "C51",
//	.bios = nvkm_bios_new,
//	.bus = nv31_bus_new,
//	.clk = nv40_clk_new,
//	.devinit = nv1a_devinit_new,
//	.fb = nv4e_fb_new,
//	.gpio = nv10_gpio_new,
//	.i2c = nv4e_i2c_new,
//	.imem = nv40_instmem_new,
//	.mc = nv4c_mc_new,
//	.mmu = nv44_mmu_new,
//	.therm = nv40_therm_new,
//	.timer = nv04_timer_new,
//	.volt = nv40_volt_new,
//	.disp = nv04_disp_new,
//	.dma = nv04_dma_new,
//	.fifo = nv40_fifo_new,
//	.gr = nv40_gr_new,
//	.mpeg = nv44_mpeg_new,
//	.pm = nv40_pm_new,
//	.sw = nv10_sw_new,
};

static const struct nvkm_device_chip
nv50_chipset = {
	.name = "G80",
//	.bar = nv50_bar_new,
//	.bios = nvkm_bios_new,
//	.bus = nv50_bus_new,
//	.clk = nv50_clk_new,
//	.devinit = nv50_devinit_new,
//	.fb = nv50_fb_new,
//	.fuse = nv50_fuse_new,
//	.gpio = nv50_gpio_new,
//	.i2c = nv50_i2c_new,
//	.imem = nv50_instmem_new,
//	.mc = nv50_mc_new,
//	.mmu = nv50_mmu_new,
//	.mxm = nv50_mxm_new,
//	.therm = nv50_therm_new,
//	.timer = nv04_timer_new,
//	.volt = nv40_volt_new,
//	.disp = nv50_disp_new,
//	.dma = nv50_dma_new,
//	.fifo = nv50_fifo_new,
//	.gr = nv50_gr_new,
//	.mpeg = nv50_mpeg_new,
//	.pm = nv50_pm_new,
//	.sw = nv50_sw_new,
};

static const struct nvkm_device_chip
nv63_chipset = {
	.name = "C73",
//	.bios = nvkm_bios_new,
//	.bus = nv31_bus_new,
//	.clk = nv40_clk_new,
//	.devinit = nv1a_devinit_new,
//	.fb = nv46_fb_new,
//	.gpio = nv10_gpio_new,
//	.i2c = nv04_i2c_new,
//	.imem = nv40_instmem_new,
//	.mc = nv4c_mc_new,
//	.mmu = nv44_mmu_new,
//	.therm = nv40_therm_new,
//	.timer = nv04_timer_new,
//	.volt = nv40_volt_new,
//	.disp = nv04_disp_new,
//	.dma = nv04_dma_new,
//	.fifo = nv40_fifo_new,
//	.gr = nv40_gr_new,
//	.mpeg = nv44_mpeg_new,
//	.pm = nv40_pm_new,
//	.sw = nv10_sw_new,
};

static const struct nvkm_device_chip
nv67_chipset = {
	.name = "C67",
//	.bios = nvkm_bios_new,
//	.bus = nv31_bus_new,
//	.clk = nv40_clk_new,
//	.devinit = nv1a_devinit_new,
//	.fb = nv46_fb_new,
//	.gpio = nv10_gpio_new,
//	.i2c = nv04_i2c_new,
//	.imem = nv40_instmem_new,
//	.mc = nv4c_mc_new,
//	.mmu = nv44_mmu_new,
//	.therm = nv40_therm_new,
//	.timer = nv04_timer_new,
//	.volt = nv40_volt_new,
//	.disp = nv04_disp_new,
//	.dma = nv04_dma_new,
//	.fifo = nv40_fifo_new,
//	.gr = nv40_gr_new,
//	.mpeg = nv44_mpeg_new,
//	.pm = nv40_pm_new,
//	.sw = nv10_sw_new,
};

static const struct nvkm_device_chip
nv68_chipset = {
	.name = "C68",
//	.bios = nvkm_bios_new,
//	.bus = nv31_bus_new,
//	.clk = nv40_clk_new,
//	.devinit = nv1a_devinit_new,
//	.fb = nv46_fb_new,
//	.gpio = nv10_gpio_new,
//	.i2c = nv04_i2c_new,
//	.imem = nv40_instmem_new,
//	.mc = nv4c_mc_new,
//	.mmu = nv44_mmu_new,
//	.therm = nv40_therm_new,
//	.timer = nv04_timer_new,
//	.volt = nv40_volt_new,
//	.disp = nv04_disp_new,
//	.dma = nv04_dma_new,
//	.fifo = nv40_fifo_new,
//	.gr = nv40_gr_new,
//	.mpeg = nv44_mpeg_new,
//	.pm = nv40_pm_new,
//	.sw = nv10_sw_new,
};

static const struct nvkm_device_chip
nv84_chipset = {
	.name = "G84",
//	.bar = nv50_bar_new,
//	.bios = nvkm_bios_new,
//	.bus = nv50_bus_new,
//	.clk = g84_clk_new,
//	.devinit = g84_devinit_new,
//	.fb = g84_fb_new,
//	.fuse = nv50_fuse_new,
//	.gpio = nv50_gpio_new,
//	.i2c = nv50_i2c_new,
//	.imem = nv50_instmem_new,
//	.mc = nv50_mc_new,
//	.mmu = nv50_mmu_new,
//	.mxm = nv50_mxm_new,
//	.therm = g84_therm_new,
//	.timer = nv04_timer_new,
//	.volt = nv40_volt_new,
//	.bsp = g84_bsp_new,
//	.cipher = g84_cipher_new,
//	.disp = g84_disp_new,
//	.dma = nv50_dma_new,
//	.fifo = g84_fifo_new,
//	.gr = nv50_gr_new,
//	.mpeg = g84_mpeg_new,
//	.pm = g84_pm_new,
//	.sw = nv50_sw_new,
//	.vp = g84_vp_new,
};

static const struct nvkm_device_chip
nv86_chipset = {
	.name = "G86",
//	.bar = nv50_bar_new,
//	.bios = nvkm_bios_new,
//	.bus = nv50_bus_new,
//	.clk = g84_clk_new,
//	.devinit = g84_devinit_new,
//	.fb = g84_fb_new,
//	.fuse = nv50_fuse_new,
//	.gpio = nv50_gpio_new,
//	.i2c = nv50_i2c_new,
//	.imem = nv50_instmem_new,
//	.mc = nv50_mc_new,
//	.mmu = nv50_mmu_new,
//	.mxm = nv50_mxm_new,
//	.therm = g84_therm_new,
//	.timer = nv04_timer_new,
//	.volt = nv40_volt_new,
//	.bsp = g84_bsp_new,
//	.cipher = g84_cipher_new,
//	.disp = g84_disp_new,
//	.dma = nv50_dma_new,
//	.fifo = g84_fifo_new,
//	.gr = nv50_gr_new,
//	.mpeg = g84_mpeg_new,
//	.pm = g84_pm_new,
//	.sw = nv50_sw_new,
//	.vp = g84_vp_new,
};

static const struct nvkm_device_chip
nv92_chipset = {
	.name = "G92",
//	.bar = nv50_bar_new,
//	.bios = nvkm_bios_new,
//	.bus = nv50_bus_new,
//	.clk = g84_clk_new,
//	.devinit = g84_devinit_new,
//	.fb = g84_fb_new,
//	.fuse = nv50_fuse_new,
//	.gpio = nv50_gpio_new,
//	.i2c = nv50_i2c_new,
//	.imem = nv50_instmem_new,
//	.mc = nv50_mc_new,
//	.mmu = nv50_mmu_new,
//	.mxm = nv50_mxm_new,
//	.therm = g84_therm_new,
//	.timer = nv04_timer_new,
//	.volt = nv40_volt_new,
//	.bsp = g84_bsp_new,
//	.cipher = g84_cipher_new,
//	.disp = g84_disp_new,
//	.dma = nv50_dma_new,
//	.fifo = g84_fifo_new,
//	.gr = nv50_gr_new,
//	.mpeg = g84_mpeg_new,
//	.pm = g84_pm_new,
//	.sw = nv50_sw_new,
//	.vp = g84_vp_new,
};

static const struct nvkm_device_chip
nv94_chipset = {
	.name = "G94",
//	.bar = nv50_bar_new,
//	.bios = nvkm_bios_new,
//	.bus = g94_bus_new,
//	.clk = g84_clk_new,
//	.devinit = g84_devinit_new,
//	.fb = g84_fb_new,
//	.fuse = nv50_fuse_new,
//	.gpio = g94_gpio_new,
//	.i2c = g94_i2c_new,
//	.imem = nv50_instmem_new,
//	.mc = g94_mc_new,
//	.mmu = nv50_mmu_new,
//	.mxm = nv50_mxm_new,
//	.therm = g84_therm_new,
//	.timer = nv04_timer_new,
//	.volt = nv40_volt_new,
//	.bsp = g84_bsp_new,
//	.cipher = g84_cipher_new,
//	.disp = g94_disp_new,
//	.dma = nv50_dma_new,
//	.fifo = g84_fifo_new,
//	.gr = nv50_gr_new,
//	.mpeg = g84_mpeg_new,
//	.pm = g84_pm_new,
//	.sw = nv50_sw_new,
//	.vp = g84_vp_new,
};

static const struct nvkm_device_chip
nv96_chipset = {
	.name = "G96",
//	.bios = nvkm_bios_new,
//	.gpio = g94_gpio_new,
//	.i2c = g94_i2c_new,
//	.fuse = nv50_fuse_new,
//	.clk = g84_clk_new,
//	.therm = g84_therm_new,
//	.mxm = nv50_mxm_new,
//	.devinit = g84_devinit_new,
//	.mc = g94_mc_new,
//	.bus = g94_bus_new,
//	.timer = nv04_timer_new,
//	.fb = g84_fb_new,
//	.imem = nv50_instmem_new,
//	.mmu = nv50_mmu_new,
//	.bar = nv50_bar_new,
//	.volt = nv40_volt_new,
//	.dma = nv50_dma_new,
//	.fifo = g84_fifo_new,
//	.sw = nv50_sw_new,
//	.gr = nv50_gr_new,
//	.mpeg = g84_mpeg_new,
//	.vp = g84_vp_new,
//	.cipher = g84_cipher_new,
//	.bsp = g84_bsp_new,
//	.disp = g94_disp_new,
//	.pm = g84_pm_new,
};

static const struct nvkm_device_chip
nv98_chipset = {
	.name = "G98",
//	.bios = nvkm_bios_new,
//	.gpio = g94_gpio_new,
//	.i2c = g94_i2c_new,
//	.fuse = nv50_fuse_new,
//	.clk = g84_clk_new,
//	.therm = g84_therm_new,
//	.mxm = nv50_mxm_new,
//	.devinit = g98_devinit_new,
//	.mc = g98_mc_new,
//	.bus = g94_bus_new,
//	.timer = nv04_timer_new,
//	.fb = g84_fb_new,
//	.imem = nv50_instmem_new,
//	.mmu = nv50_mmu_new,
//	.bar = nv50_bar_new,
//	.volt = nv40_volt_new,
//	.dma = nv50_dma_new,
//	.fifo = g84_fifo_new,
//	.sw = nv50_sw_new,
//	.gr = nv50_gr_new,
//	.mspdec = g98_mspdec_new,
//	.sec = g98_sec_new,
//	.msvld = g98_msvld_new,
//	.msppp = g98_msppp_new,
//	.disp = g94_disp_new,
//	.pm = g84_pm_new,
};

static const struct nvkm_device_chip
nva0_chipset = {
	.name = "GT200",
//	.bar = nv50_bar_new,
//	.bios = nvkm_bios_new,
//	.bus = g94_bus_new,
//	.clk = g84_clk_new,
//	.devinit = g84_devinit_new,
//	.fb = g84_fb_new,
//	.fuse = nv50_fuse_new,
//	.gpio = g94_gpio_new,
//	.i2c = nv50_i2c_new,
//	.imem = nv50_instmem_new,
//	.mc = g98_mc_new,
//	.mmu = nv50_mmu_new,
//	.mxm = nv50_mxm_new,
//	.therm = g84_therm_new,
//	.timer = nv04_timer_new,
//	.volt = nv40_volt_new,
//	.bsp = g84_bsp_new,
//	.cipher = g84_cipher_new,
//	.disp = gt200_disp_new,
//	.dma = nv50_dma_new,
//	.fifo = g84_fifo_new,
//	.gr = nv50_gr_new,
//	.mpeg = g84_mpeg_new,
//	.pm = gt200_pm_new,
//	.sw = nv50_sw_new,
//	.vp = g84_vp_new,
};

static const struct nvkm_device_chip
nva3_chipset = {
	.name = "GT215",
//	.bar = nv50_bar_new,
//	.bios = nvkm_bios_new,
//	.bus = g94_bus_new,
//	.clk = gt215_clk_new,
//	.devinit = gt215_devinit_new,
//	.fb = gt215_fb_new,
//	.fuse = nv50_fuse_new,
//	.gpio = g94_gpio_new,
//	.i2c = g94_i2c_new,
//	.imem = nv50_instmem_new,
//	.mc = g98_mc_new,
//	.mmu = nv50_mmu_new,
//	.mxm = nv50_mxm_new,
//	.pmu = gt215_pmu_new,
//	.therm = gt215_therm_new,
//	.timer = nv04_timer_new,
//	.volt = nv40_volt_new,
//	.ce[0] = gt215_ce_new,
//	.disp = gt215_disp_new,
//	.dma = nv50_dma_new,
//	.fifo = g84_fifo_new,
//	.gr = nv50_gr_new,
//	.mpeg = g84_mpeg_new,
//	.mspdec = g98_mspdec_new,
//	.msppp = g98_msppp_new,
//	.msvld = g98_msvld_new,
//	.pm = gt215_pm_new,
//	.sw = nv50_sw_new,
};

static const struct nvkm_device_chip
nva5_chipset = {
	.name = "GT216",
//	.bar = nv50_bar_new,
//	.bios = nvkm_bios_new,
//	.bus = g94_bus_new,
//	.clk = gt215_clk_new,
//	.devinit = gt215_devinit_new,
//	.fb = gt215_fb_new,
//	.fuse = nv50_fuse_new,
//	.gpio = g94_gpio_new,
//	.i2c = g94_i2c_new,
//	.imem = nv50_instmem_new,
//	.mc = g98_mc_new,
//	.mmu = nv50_mmu_new,
//	.mxm = nv50_mxm_new,
//	.pmu = gt215_pmu_new,
//	.therm = gt215_therm_new,
//	.timer = nv04_timer_new,
//	.volt = nv40_volt_new,
//	.ce[0] = gt215_ce_new,
//	.disp = gt215_disp_new,
//	.dma = nv50_dma_new,
//	.fifo = g84_fifo_new,
//	.gr = nv50_gr_new,
//	.mspdec = g98_mspdec_new,
//	.msppp = g98_msppp_new,
//	.msvld = g98_msvld_new,
//	.pm = gt215_pm_new,
//	.sw = nv50_sw_new,
};

static const struct nvkm_device_chip
nva8_chipset = {
	.name = "GT218",
//	.bar = nv50_bar_new,
//	.bios = nvkm_bios_new,
//	.bus = g94_bus_new,
//	.clk = gt215_clk_new,
//	.devinit = gt215_devinit_new,
//	.fb = gt215_fb_new,
//	.fuse = nv50_fuse_new,
//	.gpio = g94_gpio_new,
//	.i2c = g94_i2c_new,
//	.imem = nv50_instmem_new,
//	.mc = g98_mc_new,
//	.mmu = nv50_mmu_new,
//	.mxm = nv50_mxm_new,
//	.pmu = gt215_pmu_new,
//	.therm = gt215_therm_new,
//	.timer = nv04_timer_new,
//	.volt = nv40_volt_new,
//	.ce[0] = gt215_ce_new,
//	.disp = gt215_disp_new,
//	.dma = nv50_dma_new,
//	.fifo = g84_fifo_new,
//	.gr = nv50_gr_new,
//	.mspdec = g98_mspdec_new,
//	.msppp = g98_msppp_new,
//	.msvld = g98_msvld_new,
//	.pm = gt215_pm_new,
//	.sw = nv50_sw_new,
};

static const struct nvkm_device_chip
nvaa_chipset = {
	.name = "MCP77/MCP78",
//	.bar = nv50_bar_new,
//	.bios = nvkm_bios_new,
//	.bus = g94_bus_new,
//	.clk = mcp77_clk_new,
//	.devinit = g98_devinit_new,
//	.fb = mcp77_fb_new,
//	.fuse = nv50_fuse_new,
//	.gpio = g94_gpio_new,
//	.i2c = g94_i2c_new,
//	.imem = nv50_instmem_new,
//	.mc = g98_mc_new,
//	.mmu = nv50_mmu_new,
//	.mxm = nv50_mxm_new,
//	.therm = g84_therm_new,
//	.timer = nv04_timer_new,
//	.volt = nv40_volt_new,
//	.disp = g94_disp_new,
//	.dma = nv50_dma_new,
//	.fifo = g84_fifo_new,
//	.gr = nv50_gr_new,
//	.mspdec = g98_mspdec_new,
//	.msppp = g98_msppp_new,
//	.msvld = g98_msvld_new,
//	.pm = g84_pm_new,
//	.sec = g98_sec_new,
//	.sw = nv50_sw_new,
};

static const struct nvkm_device_chip
nvac_chipset = {
	.name = "MCP79/MCP7A",
//	.bar = nv50_bar_new,
//	.bios = nvkm_bios_new,
//	.bus = g94_bus_new,
//	.clk = mcp77_clk_new,
//	.devinit = g98_devinit_new,
//	.fb = mcp77_fb_new,
//	.fuse = nv50_fuse_new,
//	.gpio = g94_gpio_new,
//	.i2c = g94_i2c_new,
//	.imem = nv50_instmem_new,
//	.mc = g98_mc_new,
//	.mmu = nv50_mmu_new,
//	.mxm = nv50_mxm_new,
//	.therm = g84_therm_new,
//	.timer = nv04_timer_new,
//	.volt = nv40_volt_new,
//	.disp = g94_disp_new,
//	.dma = nv50_dma_new,
//	.fifo = g84_fifo_new,
//	.gr = nv50_gr_new,
//	.mspdec = g98_mspdec_new,
//	.msppp = g98_msppp_new,
//	.msvld = g98_msvld_new,
//	.pm = g84_pm_new,
//	.sec = g98_sec_new,
//	.sw = nv50_sw_new,
};

static const struct nvkm_device_chip
nvaf_chipset = {
	.name = "MCP89",
//	.bar = nv50_bar_new,
//	.bios = nvkm_bios_new,
//	.bus = g94_bus_new,
//	.clk = gt215_clk_new,
//	.devinit = mcp89_devinit_new,
//	.fb = mcp89_fb_new,
//	.fuse = nv50_fuse_new,
//	.gpio = g94_gpio_new,
//	.i2c = g94_i2c_new,
//	.imem = nv50_instmem_new,
//	.mc = g98_mc_new,
//	.mmu = nv50_mmu_new,
//	.mxm = nv50_mxm_new,
//	.pmu = gt215_pmu_new,
//	.therm = gt215_therm_new,
//	.timer = nv04_timer_new,
//	.volt = nv40_volt_new,
//	.ce[0] = gt215_ce_new,
//	.disp = gt215_disp_new,
//	.dma = nv50_dma_new,
//	.fifo = g84_fifo_new,
//	.gr = nv50_gr_new,
//	.mspdec = g98_mspdec_new,
//	.msppp = g98_msppp_new,
//	.msvld = g98_msvld_new,
//	.pm = gt215_pm_new,
//	.sw = nv50_sw_new,
};

static const struct nvkm_device_chip
nvc0_chipset = {
	.name = "GF100",
//	.bar = gf100_bar_new,
//	.bios = nvkm_bios_new,
//	.bus = gf100_bus_new,
//	.clk = gf100_clk_new,
//	.devinit = gf100_devinit_new,
//	.fb = gf100_fb_new,
//	.fuse = gf100_fuse_new,
//	.gpio = g94_gpio_new,
//	.i2c = g94_i2c_new,
//	.ibus = gf100_ibus_new,
//	.imem = nv50_instmem_new,
//	.ltc = gf100_ltc_new,
//	.mc = gf100_mc_new,
//	.mmu = gf100_mmu_new,
//	.mxm = nv50_mxm_new,
//	.pmu = gf100_pmu_new,
//	.therm = gt215_therm_new,
//	.timer = nv04_timer_new,
//	.volt = nv40_volt_new,
//	.ce[0] = gf100_ce0_new,
//	.ce[1] = gf100_ce1_new,
//	.disp = gt215_disp_new,
//	.dma = gf100_dma_new,
//	.fifo = gf100_fifo_new,
//	.gr = gf100_gr_new,
//	.mspdec = gf100_mspdec_new,
//	.msppp = gf100_msppp_new,
//	.msvld = gf100_msvld_new,
//	.pm = gf100_pm_new,
//	.sw = gf100_sw_new,
};

static const struct nvkm_device_chip
nvc1_chipset = {
	.name = "GF108",
//	.bar = gf100_bar_new,
//	.bios = nvkm_bios_new,
//	.bus = gf100_bus_new,
//	.clk = gf100_clk_new,
//	.devinit = gf100_devinit_new,
//	.fb = gf100_fb_new,
//	.fuse = gf100_fuse_new,
//	.gpio = g94_gpio_new,
//	.i2c = g94_i2c_new,
//	.ibus = gf100_ibus_new,
//	.imem = nv50_instmem_new,
//	.ltc = gf100_ltc_new,
//	.mc = gf106_mc_new,
//	.mmu = gf100_mmu_new,
//	.mxm = nv50_mxm_new,
//	.pmu = gf100_pmu_new,
//	.therm = gt215_therm_new,
//	.timer = nv04_timer_new,
//	.volt = nv40_volt_new,
//	.ce[0] = gf100_ce0_new,
//	.disp = gt215_disp_new,
//	.dma = gf100_dma_new,
//	.fifo = gf100_fifo_new,
//	.gr = gf108_gr_new,
//	.mspdec = gf100_mspdec_new,
//	.msppp = gf100_msppp_new,
//	.msvld = gf100_msvld_new,
//	.pm = gf108_pm_new,
//	.sw = gf100_sw_new,
};

static const struct nvkm_device_chip
nvc3_chipset = {
	.name = "GF106",
//	.bar = gf100_bar_new,
//	.bios = nvkm_bios_new,
//	.bus = gf100_bus_new,
//	.clk = gf100_clk_new,
//	.devinit = gf100_devinit_new,
//	.fb = gf100_fb_new,
//	.fuse = gf100_fuse_new,
//	.gpio = g94_gpio_new,
//	.i2c = g94_i2c_new,
//	.ibus = gf100_ibus_new,
//	.imem = nv50_instmem_new,
//	.ltc = gf100_ltc_new,
//	.mc = gf106_mc_new,
//	.mmu = gf100_mmu_new,
//	.mxm = nv50_mxm_new,
//	.pmu = gf100_pmu_new,
//	.therm = gt215_therm_new,
//	.timer = nv04_timer_new,
//	.volt = nv40_volt_new,
//	.ce[0] = gf100_ce0_new,
//	.disp = gt215_disp_new,
//	.dma = gf100_dma_new,
//	.fifo = gf100_fifo_new,
//	.gr = gf104_gr_new,
//	.mspdec = gf100_mspdec_new,
//	.msppp = gf100_msppp_new,
//	.msvld = gf100_msvld_new,
//	.pm = gf100_pm_new,
//	.sw = gf100_sw_new,
};

static const struct nvkm_device_chip
nvc4_chipset = {
	.name = "GF104",
//	.bar = gf100_bar_new,
//	.bios = nvkm_bios_new,
//	.bus = gf100_bus_new,
//	.clk = gf100_clk_new,
//	.devinit = gf100_devinit_new,
//	.fb = gf100_fb_new,
//	.fuse = gf100_fuse_new,
//	.gpio = g94_gpio_new,
//	.i2c = g94_i2c_new,
//	.ibus = gf100_ibus_new,
//	.imem = nv50_instmem_new,
//	.ltc = gf100_ltc_new,
//	.mc = gf100_mc_new,
//	.mmu = gf100_mmu_new,
//	.mxm = nv50_mxm_new,
//	.pmu = gf100_pmu_new,
//	.therm = gt215_therm_new,
//	.timer = nv04_timer_new,
//	.volt = nv40_volt_new,
//	.ce[0] = gf100_ce0_new,
//	.ce[1] = gf100_ce1_new,
//	.disp = gt215_disp_new,
//	.dma = gf100_dma_new,
//	.fifo = gf100_fifo_new,
//	.gr = gf104_gr_new,
//	.mspdec = gf100_mspdec_new,
//	.msppp = gf100_msppp_new,
//	.msvld = gf100_msvld_new,
//	.pm = gf100_pm_new,
//	.sw = gf100_sw_new,
};

static const struct nvkm_device_chip
nvc8_chipset = {
	.name = "GF110",
//	.bar = gf100_bar_new,
//	.bios = nvkm_bios_new,
//	.bus = gf100_bus_new,
//	.clk = gf100_clk_new,
//	.devinit = gf100_devinit_new,
//	.fb = gf100_fb_new,
//	.fuse = gf100_fuse_new,
//	.gpio = g94_gpio_new,
//	.i2c = g94_i2c_new,
//	.ibus = gf100_ibus_new,
//	.imem = nv50_instmem_new,
//	.ltc = gf100_ltc_new,
//	.mc = gf100_mc_new,
//	.mmu = gf100_mmu_new,
//	.mxm = nv50_mxm_new,
//	.pmu = gf100_pmu_new,
//	.therm = gt215_therm_new,
//	.timer = nv04_timer_new,
//	.volt = nv40_volt_new,
//	.ce[0] = gf100_ce0_new,
//	.ce[1] = gf100_ce1_new,
//	.disp = gt215_disp_new,
//	.dma = gf100_dma_new,
//	.fifo = gf100_fifo_new,
//	.gr = gf110_gr_new,
//	.mspdec = gf100_mspdec_new,
//	.msppp = gf100_msppp_new,
//	.msvld = gf100_msvld_new,
//	.pm = gf100_pm_new,
//	.sw = gf100_sw_new,
};

static const struct nvkm_device_chip
nvce_chipset = {
	.name = "GF114",
//	.bar = gf100_bar_new,
//	.bios = nvkm_bios_new,
//	.bus = gf100_bus_new,
//	.clk = gf100_clk_new,
//	.devinit = gf100_devinit_new,
//	.fb = gf100_fb_new,
//	.fuse = gf100_fuse_new,
//	.gpio = g94_gpio_new,
//	.i2c = g94_i2c_new,
//	.ibus = gf100_ibus_new,
//	.imem = nv50_instmem_new,
//	.ltc = gf100_ltc_new,
//	.mc = gf100_mc_new,
//	.mmu = gf100_mmu_new,
//	.mxm = nv50_mxm_new,
//	.pmu = gf100_pmu_new,
//	.therm = gt215_therm_new,
//	.timer = nv04_timer_new,
//	.volt = nv40_volt_new,
//	.ce[0] = gf100_ce0_new,
//	.ce[1] = gf100_ce1_new,
//	.disp = gt215_disp_new,
//	.dma = gf100_dma_new,
//	.fifo = gf100_fifo_new,
//	.gr = gf104_gr_new,
//	.mspdec = gf100_mspdec_new,
//	.msppp = gf100_msppp_new,
//	.msvld = gf100_msvld_new,
//	.pm = gf100_pm_new,
//	.sw = gf100_sw_new,
};

static const struct nvkm_device_chip
nvcf_chipset = {
	.name = "GF116",
//	.bar = gf100_bar_new,
//	.bios = nvkm_bios_new,
//	.bus = gf100_bus_new,
//	.clk = gf100_clk_new,
//	.devinit = gf100_devinit_new,
//	.fb = gf100_fb_new,
//	.fuse = gf100_fuse_new,
//	.gpio = g94_gpio_new,
//	.i2c = g94_i2c_new,
//	.ibus = gf100_ibus_new,
//	.imem = nv50_instmem_new,
//	.ltc = gf100_ltc_new,
//	.mc = gf106_mc_new,
//	.mmu = gf100_mmu_new,
//	.mxm = nv50_mxm_new,
//	.pmu = gf100_pmu_new,
//	.therm = gt215_therm_new,
//	.timer = nv04_timer_new,
//	.volt = nv40_volt_new,
//	.ce[0] = gf100_ce0_new,
//	.disp = gt215_disp_new,
//	.dma = gf100_dma_new,
//	.fifo = gf100_fifo_new,
//	.gr = gf104_gr_new,
//	.mspdec = gf100_mspdec_new,
//	.msppp = gf100_msppp_new,
//	.msvld = gf100_msvld_new,
//	.pm = gf100_pm_new,
//	.sw = gf100_sw_new,
};

static const struct nvkm_device_chip
nvd7_chipset = {
	.name = "GF117",
//	.bar = gf100_bar_new,
//	.bios = nvkm_bios_new,
//	.bus = gf100_bus_new,
//	.clk = gf100_clk_new,
//	.devinit = gf100_devinit_new,
//	.fb = gf100_fb_new,
//	.fuse = gf100_fuse_new,
//	.gpio = gf110_gpio_new,
//	.i2c = gf117_i2c_new,
//	.ibus = gf100_ibus_new,
//	.imem = nv50_instmem_new,
//	.ltc = gf100_ltc_new,
//	.mc = gf106_mc_new,
//	.mmu = gf100_mmu_new,
//	.mxm = nv50_mxm_new,
//	.therm = gf110_therm_new,
//	.timer = nv04_timer_new,
//	.ce[0] = gf100_ce0_new,
//	.disp = gf119_disp_new,
//	.dma = gf119_dma_new,
//	.fifo = gf100_fifo_new,
//	.gr = gf117_gr_new,
//	.mspdec = gf100_mspdec_new,
//	.msppp = gf100_msppp_new,
//	.msvld = gf100_msvld_new,
//	.pm = gf117_pm_new,
//	.sw = gf100_sw_new,
};

static const struct nvkm_device_chip
nvd9_chipset = {
	.name = "GF119",
//	.bar = gf100_bar_new,
//	.bios = nvkm_bios_new,
//	.bus = gf100_bus_new,
//	.clk = gf100_clk_new,
//	.devinit = gf100_devinit_new,
//	.fb = gf100_fb_new,
//	.fuse = gf100_fuse_new,
//	.gpio = gf110_gpio_new,
//	.i2c = gf110_i2c_new,
//	.ibus = gf100_ibus_new,
//	.imem = nv50_instmem_new,
//	.ltc = gf100_ltc_new,
//	.mc = gf106_mc_new,
//	.mmu = gf100_mmu_new,
//	.mxm = nv50_mxm_new,
//	.pmu = gf110_pmu_new,
//	.therm = gf110_therm_new,
//	.timer = nv04_timer_new,
//	.volt = nv40_volt_new,
//	.ce[0] = gf100_ce0_new,
//	.disp = gf119_disp_new,
//	.dma = gf119_dma_new,
//	.fifo = gf100_fifo_new,
//	.gr = gf119_gr_new,
//	.mspdec = gf100_mspdec_new,
//	.msppp = gf100_msppp_new,
//	.msvld = gf100_msvld_new,
//	.pm = gf117_pm_new,
//	.sw = gf100_sw_new,
};

static const struct nvkm_device_chip
nve4_chipset = {
	.name = "GK104",
//	.bar = gf100_bar_new,
//	.bios = nvkm_bios_new,
//	.bus = gf100_bus_new,
//	.clk = gk104_clk_new,
//	.devinit = gf100_devinit_new,
//	.fb = gk104_fb_new,
//	.fuse = gf100_fuse_new,
//	.gpio = gk104_gpio_new,
//	.i2c = gk104_i2c_new,
//	.ibus = gk104_ibus_new,
//	.imem = nv50_instmem_new,
//	.ltc = gk104_ltc_new,
//	.mc = gf106_mc_new,
//	.mmu = gf100_mmu_new,
//	.mxm = nv50_mxm_new,
//	.pmu = gk104_pmu_new,
//	.therm = gf110_therm_new,
//	.timer = nv04_timer_new,
//	.volt = nv40_volt_new,
//	.ce[0] = gk104_ce0_new,
//	.ce[1] = gk104_ce1_new,
//	.ce[2] = gk104_ce2_new,
//	.disp = gk104_disp_new,
//	.dma = gf119_dma_new,
//	.fifo = gk104_fifo_new,
//	.gr = gk104_gr_new,
//	.mspdec = gk104_mspdec_new,
//	.msppp = gf100_msppp_new,
//	.msvld = gk104_msvld_new,
//	.pm = gk104_pm_new,
//	.sw = gf100_sw_new,
};

static const struct nvkm_device_chip
nve6_chipset = {
	.name = "GK106",
//	.bar = gf100_bar_new,
//	.bios = nvkm_bios_new,
//	.bus = gf100_bus_new,
//	.clk = gk104_clk_new,
//	.devinit = gf100_devinit_new,
//	.fb = gk104_fb_new,
//	.fuse = gf100_fuse_new,
//	.gpio = gk104_gpio_new,
//	.i2c = gk104_i2c_new,
//	.ibus = gk104_ibus_new,
//	.imem = nv50_instmem_new,
//	.ltc = gk104_ltc_new,
//	.mc = gf106_mc_new,
//	.mmu = gf100_mmu_new,
//	.mxm = nv50_mxm_new,
//	.pmu = gk104_pmu_new,
//	.therm = gf110_therm_new,
//	.timer = nv04_timer_new,
//	.volt = nv40_volt_new,
//	.ce[0] = gk104_ce0_new,
//	.ce[1] = gk104_ce1_new,
//	.ce[2] = gk104_ce2_new,
//	.disp = gk104_disp_new,
//	.dma = gf119_dma_new,
//	.fifo = gk104_fifo_new,
//	.gr = gk104_gr_new,
//	.mspdec = gk104_mspdec_new,
//	.msppp = gf100_msppp_new,
//	.msvld = gk104_msvld_new,
//	.pm = gk104_pm_new,
//	.sw = gf100_sw_new,
};

static const struct nvkm_device_chip
nve7_chipset = {
	.name = "GK107",
//	.bar = gf100_bar_new,
//	.bios = nvkm_bios_new,
//	.bus = gf100_bus_new,
//	.clk = gk104_clk_new,
//	.devinit = gf100_devinit_new,
//	.fb = gk104_fb_new,
//	.fuse = gf100_fuse_new,
//	.gpio = gk104_gpio_new,
//	.i2c = gk104_i2c_new,
//	.ibus = gk104_ibus_new,
//	.imem = nv50_instmem_new,
//	.ltc = gk104_ltc_new,
//	.mc = gf106_mc_new,
//	.mmu = gf100_mmu_new,
//	.mxm = nv50_mxm_new,
//	.pmu = gf110_pmu_new,
//	.therm = gf110_therm_new,
//	.timer = nv04_timer_new,
//	.volt = nv40_volt_new,
//	.ce[0] = gk104_ce0_new,
//	.ce[1] = gk104_ce1_new,
//	.ce[2] = gk104_ce2_new,
//	.disp = gk104_disp_new,
//	.dma = gf119_dma_new,
//	.fifo = gk104_fifo_new,
//	.gr = gk104_gr_new,
//	.mspdec = gk104_mspdec_new,
//	.msppp = gf100_msppp_new,
//	.msvld = gk104_msvld_new,
//	.pm = gk104_pm_new,
//	.sw = gf100_sw_new,
};

static const struct nvkm_device_chip
nvea_chipset = {
	.name = "GK20A",
//	.bar = gk20a_bar_new,
//	.bus = gf100_bus_new,
//	.clk = gk20a_clk_new,
//	.fb = gk20a_fb_new,
//	.fuse = gf100_fuse_new,
//	.ibus = gk20a_ibus_new,
//	.imem = gk20a_instmem_new,
//	.ltc = gk104_ltc_new,
//	.mc = gk20a_mc_new,
//	.mmu = gf100_mmu_new,
//	.pmu = gk20a_pmu_new,
//	.timer = gk20a_timer_new,
//	.volt = gk20a_volt_new,
//	.ce[2] = gk104_ce2_new,
//	.dma = gf119_dma_new,
//	.fifo = gk20a_fifo_new,
//	.gr = gk20a_gr_new,
//	.pm = gk104_pm_new,
//	.sw = gf100_sw_new,
};

static const struct nvkm_device_chip
nvf0_chipset = {
	.name = "GK110",
//	.bar = gf100_bar_new,
//	.bios = nvkm_bios_new,
//	.bus = gf100_bus_new,
//	.clk = gk104_clk_new,
//	.devinit = gf100_devinit_new,
//	.fb = gk104_fb_new,
//	.fuse = gf100_fuse_new,
//	.gpio = gk104_gpio_new,
//	.i2c = gk104_i2c_new,
//	.ibus = gk104_ibus_new,
//	.imem = nv50_instmem_new,
//	.ltc = gk104_ltc_new,
//	.mc = gf106_mc_new,
//	.mmu = gf100_mmu_new,
//	.mxm = nv50_mxm_new,
//	.pmu = gk110_pmu_new,
//	.therm = gf110_therm_new,
//	.timer = nv04_timer_new,
//	.volt = nv40_volt_new,
//	.ce[0] = gk104_ce0_new,
//	.ce[1] = gk104_ce1_new,
//	.ce[2] = gk104_ce2_new,
//	.disp = gk110_disp_new,
//	.dma = gf119_dma_new,
//	.fifo = gk104_fifo_new,
//	.gr = gk110_gr_new,
//	.mspdec = gk104_mspdec_new,
//	.msppp = gf100_msppp_new,
//	.msvld = gk104_msvld_new,
//	.pm = gk110_pm_new,
//	.sw = gf100_sw_new,
};

static const struct nvkm_device_chip
nvf1_chipset = {
	.name = "GK110B",
//	.bar = gf100_bar_new,
//	.bios = nvkm_bios_new,
//	.bus = gf100_bus_new,
//	.clk = gk104_clk_new,
//	.devinit = gf100_devinit_new,
//	.fb = gk104_fb_new,
//	.fuse = gf100_fuse_new,
//	.gpio = gk104_gpio_new,
//	.i2c = gf110_i2c_new,
//	.ibus = gk104_ibus_new,
//	.imem = nv50_instmem_new,
//	.ltc = gk104_ltc_new,
//	.mc = gf106_mc_new,
//	.mmu = gf100_mmu_new,
//	.mxm = nv50_mxm_new,
//	.pmu = gk110_pmu_new,
//	.therm = gf110_therm_new,
//	.timer = nv04_timer_new,
//	.volt = nv40_volt_new,
//	.ce[0] = gk104_ce0_new,
//	.ce[1] = gk104_ce1_new,
//	.ce[2] = gk104_ce2_new,
//	.disp = gk110_disp_new,
//	.dma = gf119_dma_new,
//	.fifo = gk104_fifo_new,
//	.gr = gk110b_gr_new,
//	.mspdec = gk104_mspdec_new,
//	.msppp = gf100_msppp_new,
//	.msvld = gk104_msvld_new,
//	.pm = gk110_pm_new,
//	.sw = gf100_sw_new,
};

static const struct nvkm_device_chip
nv106_chipset = {
	.name = "GK208B",
//	.bar = gf100_bar_new,
//	.bios = nvkm_bios_new,
//	.bus = gf100_bus_new,
//	.clk = gk104_clk_new,
//	.devinit = gf100_devinit_new,
//	.fb = gk104_fb_new,
//	.fuse = gf100_fuse_new,
//	.gpio = gk104_gpio_new,
//	.i2c = gk104_i2c_new,
//	.ibus = gk104_ibus_new,
//	.imem = nv50_instmem_new,
//	.ltc = gk104_ltc_new,
//	.mc = gk20a_mc_new,
//	.mmu = gf100_mmu_new,
//	.mxm = nv50_mxm_new,
//	.pmu = gk208_pmu_new,
//	.therm = gf110_therm_new,
//	.timer = nv04_timer_new,
//	.volt = nv40_volt_new,
//	.ce[0] = gk104_ce0_new,
//	.ce[1] = gk104_ce1_new,
//	.ce[2] = gk104_ce2_new,
//	.disp = gk110_disp_new,
//	.dma = gf119_dma_new,
//	.fifo = gk208_fifo_new,
//	.gr = gk208_gr_new,
//	.mspdec = gk104_mspdec_new,
//	.msppp = gf100_msppp_new,
//	.msvld = gk104_msvld_new,
//	.sw = gf100_sw_new,
};

static const struct nvkm_device_chip
nv108_chipset = {
	.name = "GK208",
//	.bar = gf100_bar_new,
//	.bios = nvkm_bios_new,
//	.bus = gf100_bus_new,
//	.clk = gk104_clk_new,
//	.devinit = gf100_devinit_new,
//	.fb = gk104_fb_new,
//	.fuse = gf100_fuse_new,
//	.gpio = gk104_gpio_new,
//	.i2c = gk104_i2c_new,
//	.ibus = gk104_ibus_new,
//	.imem = nv50_instmem_new,
//	.ltc = gk104_ltc_new,
//	.mc = gk20a_mc_new,
//	.mmu = gf100_mmu_new,
//	.mxm = nv50_mxm_new,
//	.pmu = gk208_pmu_new,
//	.therm = gf110_therm_new,
//	.timer = nv04_timer_new,
//	.volt = nv40_volt_new,
//	.ce[0] = gk104_ce0_new,
//	.ce[1] = gk104_ce1_new,
//	.ce[2] = gk104_ce2_new,
//	.disp = gk110_disp_new,
//	.dma = gf119_dma_new,
//	.fifo = gk208_fifo_new,
//	.gr = gk208_gr_new,
//	.mspdec = gk104_mspdec_new,
//	.msppp = gf100_msppp_new,
//	.msvld = gk104_msvld_new,
//	.sw = gf100_sw_new,
};

static const struct nvkm_device_chip
nv117_chipset = {
	.name = "GM107",
//	.bar = gf100_bar_new,
//	.bios = nvkm_bios_new,
//	.bus = gf100_bus_new,
//	.clk = gk104_clk_new,
//	.devinit = gm107_devinit_new,
//	.fb = gm107_fb_new,
//	.fuse = gm107_fuse_new,
//	.gpio = gk104_gpio_new,
//	.i2c = gf110_i2c_new,
//	.ibus = gk104_ibus_new,
//	.imem = nv50_instmem_new,
//	.ltc = gm107_ltc_new,
//	.mc = gk20a_mc_new,
//	.mmu = gf100_mmu_new,
//	.mxm = nv50_mxm_new,
//	.pmu = gk208_pmu_new,
//	.therm = gm107_therm_new,
//	.timer = gk20a_timer_new,
//	.ce[0] = gk104_ce0_new,
//	.ce[2] = gk104_ce2_new,
//	.disp = gm107_disp_new,
//	.dma = gf119_dma_new,
//	.fifo = gk208_fifo_new,
//	.gr = gm107_gr_new,
//	.sw = gf100_sw_new,
};

static const struct nvkm_device_chip
nv124_chipset = {
	.name = "GM204",
//	.bar = gf100_bar_new,
//	.bios = nvkm_bios_new,
//	.bus = gf100_bus_new,
//	.devinit = gm204_devinit_new,
//	.fb = gm107_fb_new,
//	.fuse = gm107_fuse_new,
//	.gpio = gk104_gpio_new,
//	.i2c = gm204_i2c_new,
//	.ibus = gk104_ibus_new,
//	.imem = nv50_instmem_new,
//	.ltc = gm107_ltc_new,
//	.mc = gk20a_mc_new,
//	.mmu = gf100_mmu_new,
//	.mxm = nv50_mxm_new,
//	.pmu = gk208_pmu_new,
//	.timer = gk20a_timer_new,
//	.ce[0] = gm204_ce0_new,
//	.ce[1] = gm204_ce1_new,
//	.ce[2] = gm204_ce2_new,
//	.disp = gm204_disp_new,
//	.dma = gf119_dma_new,
//	.fifo = gm204_fifo_new,
//	.gr = gm204_gr_new,
//	.sw = gf100_sw_new,
};

static const struct nvkm_device_chip
nv126_chipset = {
	.name = "GM206",
//	.bar = gf100_bar_new,
//	.bios = nvkm_bios_new,
//	.bus = gf100_bus_new,
//	.devinit = gm204_devinit_new,
//	.fb = gm107_fb_new,
//	.fuse = gm107_fuse_new,
//	.gpio = gk104_gpio_new,
//	.i2c = gm204_i2c_new,
//	.ibus = gk104_ibus_new,
//	.imem = nv50_instmem_new,
//	.ltc = gm107_ltc_new,
//	.mc = gk20a_mc_new,
//	.mmu = gf100_mmu_new,
//	.mxm = nv50_mxm_new,
//	.pmu = gk208_pmu_new,
//	.timer = gk20a_timer_new,
//	.ce[0] = gm204_ce0_new,
//	.ce[1] = gm204_ce1_new,
//	.ce[2] = gm204_ce2_new,
//	.disp = gm204_disp_new,
//	.dma = gf119_dma_new,
//	.fifo = gm204_fifo_new,
//	.gr = gm206_gr_new,
//	.sw = gf100_sw_new,
};

static const struct nvkm_device_chip
nv12b_chipset = {
	.name = "GM20B",
//	.bar = gk20a_bar_new,
//	.bus = gf100_bus_new,
//	.fb = gk20a_fb_new,
//	.fuse = gm107_fuse_new,
//	.ibus = gk20a_ibus_new,
//	.imem = gk20a_instmem_new,
//	.ltc = gm107_ltc_new,
//	.mc = gk20a_mc_new,
//	.mmu = gf100_mmu_new,
//	.mmu = gf100_mmu_new,
//	.timer = gk20a_timer_new,
//	.ce[2] = gm204_ce2_new,
//	.dma = gf119_dma_new,
//	.fifo = gm20b_fifo_new,
//	.gr = gm20b_gr_new,
//	.sw = gf100_sw_new,
};

1980
#include <core/parent.h>
1981
#include <core/client.h>
1982

1983
struct nvkm_device *
1984 1985
nv_device(void *obj)
{
1986
	struct nvkm_object *device = nv_object(obj);
1987

1988
	if (device->engine == NULL) {
1989
		while (device && device->parent) {
1990
			if (!nv_iclass(device, NV_SUBDEV_CLASS) &&
1991
			    device->parent == &nvkm_client(device)->object) {
1992 1993 1994 1995 1996 1997
				struct {
					struct nvkm_parent base;
					struct nvkm_device *device;
				} *udevice = (void *)device;
				return udevice->device;
			}
1998
			device = device->parent;
1999
		}
2000
	} else {
2001
		device = &nv_object(obj)->engine->subdev.object;
2002 2003
		if (device && device->parent)
			device = device->parent;
2004
	}
2005
#if CONFIG_NOUVEAU_DEBUG >= NV_DBG_PARANOIA
2006
	BUG_ON(!device);
2007 2008 2009 2010
#endif
	return (void *)device;
}

2011
static int
2012 2013
nvkm_device_event_ctor(struct nvkm_object *object, void *data, u32 size,
		       struct nvkm_notify *notify)
2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024
{
	if (!WARN_ON(size != 0)) {
		notify->size  = 0;
		notify->types = 1;
		notify->index = 0;
		return 0;
	}
	return -EINVAL;
}

static const struct nvkm_event_func
2025 2026
nvkm_device_event_func = {
	.ctor = nvkm_device_event_ctor,
2027 2028
};

2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104
struct nvkm_subdev *
nvkm_device_subdev(struct nvkm_device *device, int index)
{
	struct nvkm_engine *engine;

	if (device->disable_mask & (1ULL << index))
		return NULL;

	switch (index) {
#define _(n,p,m) case NVDEV_SUBDEV_##n: if (p) return (m); break
	_(BAR    , device->bar    , &device->bar->subdev);
	_(VBIOS  , device->bios   , &device->bios->subdev);
	_(BUS    , device->bus    , &device->bus->subdev);
	_(CLK    , device->clk    , &device->clk->subdev);
	_(DEVINIT, device->devinit, &device->devinit->subdev);
	_(FB     , device->fb     , &device->fb->subdev);
	_(FUSE   , device->fuse   , &device->fuse->subdev);
	_(GPIO   , device->gpio   , &device->gpio->subdev);
	_(I2C    , device->i2c    , &device->i2c->subdev);
	_(IBUS   , device->ibus   ,  device->ibus);
	_(INSTMEM, device->imem   , &device->imem->subdev);
	_(LTC    , device->ltc    , &device->ltc->subdev);
	_(MC     , device->mc     , &device->mc->subdev);
	_(MMU    , device->mmu    , &device->mmu->subdev);
	_(MXM    , device->mxm    ,  device->mxm);
	_(PMU    , device->pmu    , &device->pmu->subdev);
	_(THERM  , device->therm  , &device->therm->subdev);
	_(TIMER  , device->timer  , &device->timer->subdev);
	_(VOLT   , device->volt   , &device->volt->subdev);
#undef _
	default:
		engine = nvkm_device_engine(device, index);
		if (engine)
			return &engine->subdev;
		break;
	}
	return NULL;
}

struct nvkm_engine *
nvkm_device_engine(struct nvkm_device *device, int index)
{
	if (device->disable_mask & (1ULL << index))
		return NULL;

	switch (index) {
#define _(n,p,m) case NVDEV_ENGINE_##n: if (p) return (m); break
	_(BSP    , device->bsp    ,  device->bsp);
	_(CE0    , device->ce[0]  ,  device->ce[0]);
	_(CE1    , device->ce[1]  ,  device->ce[1]);
	_(CE2    , device->ce[2]  ,  device->ce[2]);
	_(CIPHER , device->cipher ,  device->cipher);
	_(DISP   , device->disp   , &device->disp->engine);
	_(DMAOBJ , device->dma    , &device->dma->engine);
	_(FIFO   , device->fifo   , &device->fifo->engine);
	_(GR     , device->gr     , &device->gr->engine);
	_(IFB    , device->ifb    ,  device->ifb);
	_(ME     , device->me     ,  device->me);
	_(MPEG   , device->mpeg   ,  device->mpeg);
	_(MSENC  , device->msenc  ,  device->msenc);
	_(MSPDEC , device->mspdec ,  device->mspdec);
	_(MSPPP  , device->msppp  ,  device->msppp);
	_(MSVLD  , device->msvld  ,  device->msvld);
	_(PM     , device->pm     , &device->pm->engine);
	_(SEC    , device->sec    ,  device->sec);
	_(SW     , device->sw     , &device->sw->engine);
	_(VIC    , device->vic    ,  device->vic);
	_(VP     , device->vp     ,  device->vp);
#undef _
	default:
		WARN_ON(1);
		break;
	}
	return NULL;
}

2105 2106
int
nvkm_device_fini(struct nvkm_device *device, bool suspend)
2107
{
2108 2109
	const char *action = suspend ? "suspend" : "fini";
	struct nvkm_subdev *subdev;
2110
	int ret, i;
2111 2112 2113 2114 2115 2116
	s64 time;

	nvdev_trace(device, "%s running...\n", action);
	time = ktime_to_us(ktime_get());

	nvkm_acpi_fini(device);
2117 2118

	for (i = NVDEV_SUBDEV_NR - 1; i >= 0; i--) {
2119 2120 2121 2122
		if ((subdev = nvkm_device_subdev(device, i))) {
			ret = nvkm_subdev_fini(subdev, suspend);
			if (ret && suspend)
				goto fail;
2123 2124 2125
		}
	}

2126 2127 2128

	if (device->func->fini)
		device->func->fini(device, suspend);
2129 2130 2131 2132 2133

	time = ktime_to_us(ktime_get()) - time;
	nvdev_trace(device, "%s completed in %lldus...\n", action, time);
	return 0;

2134
fail:
2135 2136 2137 2138 2139
	do {
		if ((subdev = nvkm_device_subdev(device, i))) {
			int rret = nvkm_subdev_init(subdev);
			if (rret)
				nvkm_fatal(subdev, "failed restart, %d\n", ret);
2140
		}
2141
	} while (++i < NVDEV_SUBDEV_NR);
2142

2143
	nvdev_trace(device, "%s failed with %d\n", action, ret);
2144
	return ret;
2145 2146
}

2147
static int
2148 2149
nvkm_device_preinit(struct nvkm_device *device)
{
2150 2151
	struct nvkm_subdev *subdev;
	int ret, i;
2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162
	s64 time;

	nvdev_trace(device, "preinit running...\n");
	time = ktime_to_us(ktime_get());

	if (device->func->preinit) {
		ret = device->func->preinit(device);
		if (ret)
			goto fail;
	}

2163 2164 2165 2166 2167 2168 2169 2170 2171 2172
	for (i = 0; i < NVDEV_SUBDEV_NR; i++) {
		if ((subdev = nvkm_device_subdev(device, i))) {
			ret = nvkm_subdev_preinit(subdev);
			if (ret)
				goto fail;
		}
	}

	/*XXX: devinit */

2173 2174 2175 2176 2177 2178 2179 2180 2181
	time = ktime_to_us(ktime_get()) - time;
	nvdev_trace(device, "preinit completed in %lldus\n", time);
	return 0;

fail:
	nvdev_error(device, "preinit failed with %d\n", ret);
	return ret;
}

2182 2183
int
nvkm_device_init(struct nvkm_device *device)
2184
{
2185
	struct nvkm_subdev *subdev;
2186
	int ret, i = 0, c;
2187
	s64 time;
2188

2189 2190 2191 2192
	ret = nvkm_device_preinit(device);
	if (ret)
		return ret;

2193 2194 2195 2196
	nvkm_device_fini(device, false);

	nvdev_trace(device, "init running...\n");
	time = ktime_to_us(ktime_get());
2197

2198
	for (i = 0, c = 0; i < NVDEV_SUBDEV_NR; i++) {
2199
#define _(s,m) case s: if (device->oclass[s] && !device->m) {          \
2200
		ret = nvkm_object_old(nv_object(device), NULL,                \
2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266
				       device->oclass[s], NULL,  (s),          \
				       (struct nvkm_object **)&device->m);     \
		if (ret == -ENODEV) {                                          \
			device->oclass[s] = NULL;                              \
			continue;                                              \
		}                                                              \
		if (ret)                                                       \
			goto fail;                                             \
} break
		switch (i) {
		_(NVDEV_SUBDEV_BAR    ,     bar);
		_(NVDEV_SUBDEV_VBIOS  ,    bios);
		_(NVDEV_SUBDEV_BUS    ,     bus);
		_(NVDEV_SUBDEV_CLK    ,     clk);
		_(NVDEV_SUBDEV_DEVINIT, devinit);
		_(NVDEV_SUBDEV_FB     ,      fb);
		_(NVDEV_SUBDEV_FUSE   ,    fuse);
		_(NVDEV_SUBDEV_GPIO   ,    gpio);
		_(NVDEV_SUBDEV_I2C    ,     i2c);
		_(NVDEV_SUBDEV_IBUS   ,    ibus);
		_(NVDEV_SUBDEV_INSTMEM,    imem);
		_(NVDEV_SUBDEV_LTC    ,     ltc);
		_(NVDEV_SUBDEV_MC     ,      mc);
		_(NVDEV_SUBDEV_MMU    ,     mmu);
		_(NVDEV_SUBDEV_MXM    ,     mxm);
		_(NVDEV_SUBDEV_PMU    ,     pmu);
		_(NVDEV_SUBDEV_THERM  ,   therm);
		_(NVDEV_SUBDEV_TIMER  ,   timer);
		_(NVDEV_SUBDEV_VOLT   ,    volt);
		_(NVDEV_ENGINE_BSP    ,     bsp);
		_(NVDEV_ENGINE_CE0    ,   ce[0]);
		_(NVDEV_ENGINE_CE1    ,   ce[1]);
		_(NVDEV_ENGINE_CE2    ,   ce[2]);
		_(NVDEV_ENGINE_CIPHER ,  cipher);
		_(NVDEV_ENGINE_DISP   ,    disp);
		_(NVDEV_ENGINE_DMAOBJ ,     dma);
		_(NVDEV_ENGINE_FIFO   ,    fifo);
		_(NVDEV_ENGINE_GR     ,      gr);
		_(NVDEV_ENGINE_IFB    ,     ifb);
		_(NVDEV_ENGINE_ME     ,      me);
		_(NVDEV_ENGINE_MPEG   ,    mpeg);
		_(NVDEV_ENGINE_MSENC  ,   msenc);
		_(NVDEV_ENGINE_MSPDEC ,  mspdec);
		_(NVDEV_ENGINE_MSPPP  ,   msppp);
		_(NVDEV_ENGINE_MSVLD  ,   msvld);
		_(NVDEV_ENGINE_PM     ,      pm);
		_(NVDEV_ENGINE_SEC    ,     sec);
		_(NVDEV_ENGINE_SW     ,      sw);
		_(NVDEV_ENGINE_VIC    ,     vic);
		_(NVDEV_ENGINE_VP     ,      vp);
		default:
			WARN_ON(1);
			continue;
		}
#undef _

		/* note: can't init *any* subdevs until devinit has been run
		 * due to not knowing exactly what the vbios init tables will
		 * mess with.  devinit also can't be run until all of its
		 * dependencies have been created.
		 *
		 * this code delays init of any subdev until all of devinit's
		 * dependencies have been created, and then initialises each
		 * subdev in turn as they're created.
		 */
		while (i >= NVDEV_SUBDEV_DEVINIT_LAST && c <= i) {
2267 2268
			if ((subdev = nvkm_device_subdev(device, c++))) {
				ret = nvkm_subdev_init(subdev);
2269 2270 2271 2272 2273 2274
				if (ret)
					goto fail;
			}
		}
	}

2275 2276 2277 2278 2279 2280
	nvkm_acpi_init(device);

	time = ktime_to_us(ktime_get()) - time;
	nvdev_trace(device, "init completed in %lldus\n", time);
	return 0;

2281
fail:
2282 2283 2284 2285
	do {
		if ((subdev = nvkm_device_subdev(device, i)))
			nvkm_subdev_fini(subdev, false);
	} while (--i >= 0);
2286

2287
	nvdev_error(device, "init failed with %d\n", ret);
2288
	return ret;
2289 2290
}

A
Alexandre Courbot 已提交
2291
resource_size_t
2292
nv_device_resource_start(struct nvkm_device *device, unsigned int bar)
A
Alexandre Courbot 已提交
2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306
{
	if (nv_device_is_pci(device)) {
		return pci_resource_start(device->pdev, bar);
	} else {
		struct resource *res;
		res = platform_get_resource(device->platformdev,
					    IORESOURCE_MEM, bar);
		if (!res)
			return 0;
		return res->start;
	}
}

resource_size_t
2307
nv_device_resource_len(struct nvkm_device *device, unsigned int bar)
A
Alexandre Courbot 已提交
2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321
{
	if (nv_device_is_pci(device)) {
		return pci_resource_len(device->pdev, bar);
	} else {
		struct resource *res;
		res = platform_get_resource(device->platformdev,
					    IORESOURCE_MEM, bar);
		if (!res)
			return 0;
		return resource_size(res);
	}
}

int
2322
nv_device_get_irq(struct nvkm_device *device, bool stall)
A
Alexandre Courbot 已提交
2323 2324 2325 2326 2327 2328 2329 2330 2331
{
	if (nv_device_is_pci(device)) {
		return device->pdev->irq;
	} else {
		return platform_get_irq_byname(device->platformdev,
					       stall ? "stall" : "nonstall");
	}
}

2332 2333 2334 2335
void
nvkm_device_del(struct nvkm_device **pdevice)
{
	struct nvkm_device *device = *pdevice;
2336
	int i;
2337 2338
	if (device) {
		mutex_lock(&nv_devices_mutex);
2339 2340 2341 2342 2343 2344
		device->disable_mask = 0;
		for (i = NVDEV_SUBDEV_NR - 1; i >= 0; i--) {
			struct nvkm_subdev *subdev =
				nvkm_device_subdev(device, i);
			nvkm_subdev_del(&subdev);
		}
2345 2346

		nvkm_event_fini(&device->event);
2347 2348 2349

		if (device->pri)
			iounmap(device->pri);
2350
		list_del(&device->head);
2351 2352 2353

		if (device->func->dtor)
			*pdevice = device->func->dtor(device);
2354
		mutex_unlock(&nv_devices_mutex);
2355

2356
		kfree(*pdevice);
2357 2358 2359 2360
		*pdevice = NULL;
	}
}

2361 2362 2363 2364
static const struct nvkm_engine_func
nvkm_device_func = {
};

2365
int
2366 2367 2368 2369 2370 2371
nvkm_device_ctor(const struct nvkm_device_func *func,
		 const struct nvkm_device_quirk *quirk,
		 void *dev, enum nv_bus_type type, u64 handle,
		 const char *name, const char *cfg, const char *dbg,
		 bool detect, bool mmio, u64 subdev_mask,
		 struct nvkm_device *device)
2372
{
2373
	struct nvkm_subdev *subdev;
2374 2375 2376
	u64 mmio_base, mmio_size;
	u32 boot0, strap;
	void __iomem *map;
2377
	int ret = -EEXIST;
2378
	int i;
2379 2380

	mutex_lock(&nv_devices_mutex);
2381 2382
	if (nvkm_device_find_locked(handle))
		goto done;
2383

2384 2385
	device->func = func;
	device->quirk = quirk;
A
Alexandre Courbot 已提交
2386
	switch (type) {
2387
	case NVKM_BUS_PCI:
A
Alexandre Courbot 已提交
2388
		device->pdev = dev;
2389
		device->dev = &device->pdev->dev;
A
Alexandre Courbot 已提交
2390
		break;
2391
	case NVKM_BUS_PLATFORM:
A
Alexandre Courbot 已提交
2392
		device->platformdev = dev;
2393
		device->dev = &device->platformdev->dev;
A
Alexandre Courbot 已提交
2394 2395
		break;
	}
2396
	device->handle = handle;
2397 2398
	device->cfgopt = cfg;
	device->dbgopt = dbg;
2399
	device->name = name;
B
Ben Skeggs 已提交
2400
	list_add_tail(&device->head, &nv_devices);
2401

2402 2403 2404 2405 2406 2407
	ret = nvkm_engine_ctor(&nvkm_device_func, device, 0, 0,
			       true, &device->engine);
	device->engine.subdev.object.parent = NULL;
	if (ret)
		goto done;

2408
	ret = nvkm_event_init(&nvkm_device_event_func, 1, 1, &device->event);
2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491
	if (ret)
		goto done;

	mmio_base = nv_device_resource_start(device, 0);
	mmio_size = nv_device_resource_len(device, 0);

	/* identify the chipset, and determine classes of subdev/engines */
	if (detect) {
		map = ioremap(mmio_base, 0x102000);
		if (ret = -ENOMEM, map == NULL)
			goto done;

		/* switch mmio to cpu's native endianness */
#ifndef __BIG_ENDIAN
		if (ioread32_native(map + 0x000004) != 0x00000000) {
#else
		if (ioread32_native(map + 0x000004) == 0x00000000) {
#endif
			iowrite32_native(0x01000001, map + 0x000004);
			ioread32_native(map);
		}

		/* read boot0 and strapping information */
		boot0 = ioread32_native(map + 0x000000);
		strap = ioread32_native(map + 0x101000);
		iounmap(map);

		/* determine chipset and derive architecture from it */
		if ((boot0 & 0x1f000000) > 0) {
			device->chipset = (boot0 & 0x1ff00000) >> 20;
			device->chiprev = (boot0 & 0x000000ff);
			switch (device->chipset & 0x1f0) {
			case 0x010: {
				if (0x461 & (1 << (device->chipset & 0xf)))
					device->card_type = NV_10;
				else
					device->card_type = NV_11;
				device->chiprev = 0x00;
				break;
			}
			case 0x020: device->card_type = NV_20; break;
			case 0x030: device->card_type = NV_30; break;
			case 0x040:
			case 0x060: device->card_type = NV_40; break;
			case 0x050:
			case 0x080:
			case 0x090:
			case 0x0a0: device->card_type = NV_50; break;
			case 0x0c0:
			case 0x0d0: device->card_type = NV_C0; break;
			case 0x0e0:
			case 0x0f0:
			case 0x100: device->card_type = NV_E0; break;
			case 0x110:
			case 0x120: device->card_type = GM100; break;
			default:
				break;
			}
		} else
		if ((boot0 & 0xff00fff0) == 0x20004000) {
			if (boot0 & 0x00f00000)
				device->chipset = 0x05;
			else
				device->chipset = 0x04;
			device->card_type = NV_04;
		}

		switch (device->card_type) {
		case NV_04: ret = nv04_identify(device); break;
		case NV_10:
		case NV_11: ret = nv10_identify(device); break;
		case NV_20: ret = nv20_identify(device); break;
		case NV_30: ret = nv30_identify(device); break;
		case NV_40: ret = nv40_identify(device); break;
		case NV_50: ret = nv50_identify(device); break;
		case NV_C0: ret = gf100_identify(device); break;
		case NV_E0: ret = gk104_identify(device); break;
		case GM100: ret = gm100_identify(device); break;
		default:
			ret = -EINVAL;
			break;
		}

2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562
		switch (!ret * device->chipset) {
		case 0x004: device->chip = &nv4_chipset; break;
		case 0x005: device->chip = &nv5_chipset; break;
		case 0x010: device->chip = &nv10_chipset; break;
		case 0x011: device->chip = &nv11_chipset; break;
		case 0x015: device->chip = &nv15_chipset; break;
		case 0x017: device->chip = &nv17_chipset; break;
		case 0x018: device->chip = &nv18_chipset; break;
		case 0x01a: device->chip = &nv1a_chipset; break;
		case 0x01f: device->chip = &nv1f_chipset; break;
		case 0x020: device->chip = &nv20_chipset; break;
		case 0x025: device->chip = &nv25_chipset; break;
		case 0x028: device->chip = &nv28_chipset; break;
		case 0x02a: device->chip = &nv2a_chipset; break;
		case 0x030: device->chip = &nv30_chipset; break;
		case 0x031: device->chip = &nv31_chipset; break;
		case 0x034: device->chip = &nv34_chipset; break;
		case 0x035: device->chip = &nv35_chipset; break;
		case 0x036: device->chip = &nv36_chipset; break;
		case 0x040: device->chip = &nv40_chipset; break;
		case 0x041: device->chip = &nv41_chipset; break;
		case 0x042: device->chip = &nv42_chipset; break;
		case 0x043: device->chip = &nv43_chipset; break;
		case 0x044: device->chip = &nv44_chipset; break;
		case 0x045: device->chip = &nv45_chipset; break;
		case 0x046: device->chip = &nv46_chipset; break;
		case 0x047: device->chip = &nv47_chipset; break;
		case 0x049: device->chip = &nv49_chipset; break;
		case 0x04a: device->chip = &nv4a_chipset; break;
		case 0x04b: device->chip = &nv4b_chipset; break;
		case 0x04c: device->chip = &nv4c_chipset; break;
		case 0x04e: device->chip = &nv4e_chipset; break;
		case 0x050: device->chip = &nv50_chipset; break;
		case 0x063: device->chip = &nv63_chipset; break;
		case 0x067: device->chip = &nv67_chipset; break;
		case 0x068: device->chip = &nv68_chipset; break;
		case 0x084: device->chip = &nv84_chipset; break;
		case 0x086: device->chip = &nv86_chipset; break;
		case 0x092: device->chip = &nv92_chipset; break;
		case 0x094: device->chip = &nv94_chipset; break;
		case 0x096: device->chip = &nv96_chipset; break;
		case 0x098: device->chip = &nv98_chipset; break;
		case 0x0a0: device->chip = &nva0_chipset; break;
		case 0x0a3: device->chip = &nva3_chipset; break;
		case 0x0a5: device->chip = &nva5_chipset; break;
		case 0x0a8: device->chip = &nva8_chipset; break;
		case 0x0aa: device->chip = &nvaa_chipset; break;
		case 0x0ac: device->chip = &nvac_chipset; break;
		case 0x0af: device->chip = &nvaf_chipset; break;
		case 0x0c0: device->chip = &nvc0_chipset; break;
		case 0x0c1: device->chip = &nvc1_chipset; break;
		case 0x0c3: device->chip = &nvc3_chipset; break;
		case 0x0c4: device->chip = &nvc4_chipset; break;
		case 0x0c8: device->chip = &nvc8_chipset; break;
		case 0x0ce: device->chip = &nvce_chipset; break;
		case 0x0cf: device->chip = &nvcf_chipset; break;
		case 0x0d7: device->chip = &nvd7_chipset; break;
		case 0x0d9: device->chip = &nvd9_chipset; break;
		case 0x0e4: device->chip = &nve4_chipset; break;
		case 0x0e6: device->chip = &nve6_chipset; break;
		case 0x0e7: device->chip = &nve7_chipset; break;
		case 0x0ea: device->chip = &nvea_chipset; break;
		case 0x0f0: device->chip = &nvf0_chipset; break;
		case 0x0f1: device->chip = &nvf1_chipset; break;
		case 0x106: device->chip = &nv106_chipset; break;
		case 0x108: device->chip = &nv108_chipset; break;
		case 0x117: device->chip = &nv117_chipset; break;
		case 0x124: device->chip = &nv124_chipset; break;
		case 0x126: device->chip = &nv126_chipset; break;
		case 0x12b: device->chip = &nv12b_chipset; break;
		default:
2563 2564 2565 2566
			nvdev_error(device, "unknown chipset (%08x)\n", boot0);
			goto done;
		}

2567 2568
		nvdev_info(device, "NVIDIA %s (%08x)\n",
			   device->chip->name, boot0);
2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583

		/* determine frequency of timing crystal */
		if ( device->card_type <= NV_10 || device->chipset < 0x17 ||
		    (device->chipset >= 0x20 && device->chipset < 0x25))
			strap &= 0x00000040;
		else
			strap &= 0x00400040;

		switch (strap) {
		case 0x00000000: device->crystal = 13500; break;
		case 0x00000040: device->crystal = 14318; break;
		case 0x00400000: device->crystal = 27000; break;
		case 0x00400040: device->crystal = 25000; break;
		}
	} else {
2584
		device->chip = &null_chipset;
2585 2586 2587
		device->oclass[NVDEV_SUBDEV_VBIOS] = &nvkm_bios_oclass;
	}

2588 2589 2590
	if (!device->name)
		device->name = device->chip->name;

2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604
	if (mmio) {
		device->pri = ioremap(mmio_base, mmio_size);
		if (!device->pri) {
			nvdev_error(device, "unable to map PRI\n");
			return -ENOMEM;
		}
	}

	/* disable subdevs that aren't required (used by tools) */
	for (i = 0; i < NVDEV_SUBDEV_NR; i++) {
		if (!(subdev_mask & (1ULL << i)))
			device->oclass[i] = NULL;
	}

2605 2606
	atomic_set(&device->engine.subdev.object.usecount, 2);
	mutex_init(&device->mutex);
2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672

	for (i = 0; i < NVDEV_SUBDEV_NR; i++) {
#define _(s,m) case s:                                                         \
	if (device->chip->m && (subdev_mask & (1ULL << (s)))) {                \
		ret = device->chip->m(device, (s), &device->m);                \
		if (ret) {                                                     \
			subdev = nvkm_device_subdev(device, (s));              \
			nvkm_subdev_del(&subdev);                              \
			device->m = NULL;                                      \
			if (ret != -ENODEV) {                                  \
				nvdev_error(device, "%s ctor failed, %d\n",    \
					    nvkm_subdev_name[s], ret);         \
				goto done;                                     \
			}                                                      \
		}                                                              \
	}                                                                      \
	break
		switch (i) {
		_(NVDEV_SUBDEV_BAR    ,     bar);
		_(NVDEV_SUBDEV_VBIOS  ,    bios);
		_(NVDEV_SUBDEV_BUS    ,     bus);
		_(NVDEV_SUBDEV_CLK    ,     clk);
		_(NVDEV_SUBDEV_DEVINIT, devinit);
		_(NVDEV_SUBDEV_FB     ,      fb);
		_(NVDEV_SUBDEV_FUSE   ,    fuse);
		_(NVDEV_SUBDEV_GPIO   ,    gpio);
		_(NVDEV_SUBDEV_I2C    ,     i2c);
		_(NVDEV_SUBDEV_IBUS   ,    ibus);
		_(NVDEV_SUBDEV_INSTMEM,    imem);
		_(NVDEV_SUBDEV_LTC    ,     ltc);
		_(NVDEV_SUBDEV_MC     ,      mc);
		_(NVDEV_SUBDEV_MMU    ,     mmu);
		_(NVDEV_SUBDEV_MXM    ,     mxm);
		_(NVDEV_SUBDEV_PMU    ,     pmu);
		_(NVDEV_SUBDEV_THERM  ,   therm);
		_(NVDEV_SUBDEV_TIMER  ,   timer);
		_(NVDEV_SUBDEV_VOLT   ,    volt);
		_(NVDEV_ENGINE_BSP    ,     bsp);
		_(NVDEV_ENGINE_CE0    ,   ce[0]);
		_(NVDEV_ENGINE_CE1    ,   ce[1]);
		_(NVDEV_ENGINE_CE2    ,   ce[2]);
		_(NVDEV_ENGINE_CIPHER ,  cipher);
		_(NVDEV_ENGINE_DISP   ,    disp);
		_(NVDEV_ENGINE_DMAOBJ ,     dma);
		_(NVDEV_ENGINE_FIFO   ,    fifo);
		_(NVDEV_ENGINE_GR     ,      gr);
		_(NVDEV_ENGINE_IFB    ,     ifb);
		_(NVDEV_ENGINE_ME     ,      me);
		_(NVDEV_ENGINE_MPEG   ,    mpeg);
		_(NVDEV_ENGINE_MSENC  ,   msenc);
		_(NVDEV_ENGINE_MSPDEC ,  mspdec);
		_(NVDEV_ENGINE_MSPPP  ,   msppp);
		_(NVDEV_ENGINE_MSVLD  ,   msvld);
		_(NVDEV_ENGINE_PM     ,      pm);
		_(NVDEV_ENGINE_SEC    ,     sec);
		_(NVDEV_ENGINE_SW     ,      sw);
		_(NVDEV_ENGINE_VIC    ,     vic);
		_(NVDEV_ENGINE_VP     ,      vp);
		default:
			WARN_ON(1);
			continue;
		}
#undef _
	}

	ret = 0;
2673 2674 2675 2676
done:
	mutex_unlock(&nv_devices_mutex);
	return ret;
}