diff options
Diffstat (limited to 'drivers/gpu/drm/nouveau/nouveau_bios.c')
| -rw-r--r-- | drivers/gpu/drm/nouveau/nouveau_bios.c | 657 |
1 files changed, 496 insertions, 161 deletions
diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.c b/drivers/gpu/drm/nouveau/nouveau_bios.c index fc924b64919..7369b5e7364 100644 --- a/drivers/gpu/drm/nouveau/nouveau_bios.c +++ b/drivers/gpu/drm/nouveau/nouveau_bios.c | |||
| @@ -28,6 +28,8 @@ | |||
| 28 | #include "nouveau_hw.h" | 28 | #include "nouveau_hw.h" |
| 29 | #include "nouveau_encoder.h" | 29 | #include "nouveau_encoder.h" |
| 30 | 30 | ||
| 31 | #include <linux/io-mapping.h> | ||
| 32 | |||
| 31 | /* these defines are made up */ | 33 | /* these defines are made up */ |
| 32 | #define NV_CIO_CRE_44_HEADA 0x0 | 34 | #define NV_CIO_CRE_44_HEADA 0x0 |
| 33 | #define NV_CIO_CRE_44_HEADB 0x3 | 35 | #define NV_CIO_CRE_44_HEADB 0x3 |
| @@ -203,36 +205,26 @@ struct methods { | |||
| 203 | const bool rw; | 205 | const bool rw; |
| 204 | }; | 206 | }; |
| 205 | 207 | ||
| 206 | static struct methods nv04_methods[] = { | 208 | static struct methods shadow_methods[] = { |
| 207 | { "PROM", load_vbios_prom, false }, | ||
| 208 | { "PRAMIN", load_vbios_pramin, true }, | ||
| 209 | { "PCIROM", load_vbios_pci, true }, | ||
| 210 | }; | ||
| 211 | |||
| 212 | static struct methods nv50_methods[] = { | ||
| 213 | { "ACPI", load_vbios_acpi, true }, | ||
| 214 | { "PRAMIN", load_vbios_pramin, true }, | 209 | { "PRAMIN", load_vbios_pramin, true }, |
| 215 | { "PROM", load_vbios_prom, false }, | 210 | { "PROM", load_vbios_prom, false }, |
| 216 | { "PCIROM", load_vbios_pci, true }, | 211 | { "PCIROM", load_vbios_pci, true }, |
| 212 | { "ACPI", load_vbios_acpi, true }, | ||
| 217 | }; | 213 | }; |
| 218 | 214 | #define NUM_SHADOW_METHODS ARRAY_SIZE(shadow_methods) | |
| 219 | #define METHODCNT 3 | ||
| 220 | 215 | ||
| 221 | static bool NVShadowVBIOS(struct drm_device *dev, uint8_t *data) | 216 | static bool NVShadowVBIOS(struct drm_device *dev, uint8_t *data) |
| 222 | { | 217 | { |
| 223 | struct drm_nouveau_private *dev_priv = dev->dev_private; | 218 | struct methods *methods = shadow_methods; |
| 224 | struct methods *methods; | ||
| 225 | int i; | ||
| 226 | int testscore = 3; | 219 | int testscore = 3; |
| 227 | int scores[METHODCNT]; | 220 | int scores[NUM_SHADOW_METHODS], i; |
| 228 | 221 | ||
| 229 | if (nouveau_vbios) { | 222 | if (nouveau_vbios) { |
| 230 | methods = nv04_methods; | 223 | for (i = 0; i < NUM_SHADOW_METHODS; i++) |
| 231 | for (i = 0; i < METHODCNT; i++) | ||
| 232 | if (!strcasecmp(nouveau_vbios, methods[i].desc)) | 224 | if (!strcasecmp(nouveau_vbios, methods[i].desc)) |
| 233 | break; | 225 | break; |
| 234 | 226 | ||
| 235 | if (i < METHODCNT) { | 227 | if (i < NUM_SHADOW_METHODS) { |
| 236 | NV_INFO(dev, "Attempting to use BIOS image from %s\n", | 228 | NV_INFO(dev, "Attempting to use BIOS image from %s\n", |
| 237 | methods[i].desc); | 229 | methods[i].desc); |
| 238 | 230 | ||
| @@ -244,12 +236,7 @@ static bool NVShadowVBIOS(struct drm_device *dev, uint8_t *data) | |||
| 244 | NV_ERROR(dev, "VBIOS source \'%s\' invalid\n", nouveau_vbios); | 236 | NV_ERROR(dev, "VBIOS source \'%s\' invalid\n", nouveau_vbios); |
| 245 | } | 237 | } |
| 246 | 238 | ||
| 247 | if (dev_priv->card_type < NV_50) | 239 | for (i = 0; i < NUM_SHADOW_METHODS; i++) { |
| 248 | methods = nv04_methods; | ||
| 249 | else | ||
| 250 | methods = nv50_methods; | ||
| 251 | |||
| 252 | for (i = 0; i < METHODCNT; i++) { | ||
| 253 | NV_TRACE(dev, "Attempting to load BIOS image from %s\n", | 240 | NV_TRACE(dev, "Attempting to load BIOS image from %s\n", |
| 254 | methods[i].desc); | 241 | methods[i].desc); |
| 255 | data[0] = data[1] = 0; /* avoid reuse of previous image */ | 242 | data[0] = data[1] = 0; /* avoid reuse of previous image */ |
| @@ -260,7 +247,7 @@ static bool NVShadowVBIOS(struct drm_device *dev, uint8_t *data) | |||
| 260 | } | 247 | } |
| 261 | 248 | ||
| 262 | while (--testscore > 0) { | 249 | while (--testscore > 0) { |
| 263 | for (i = 0; i < METHODCNT; i++) { | 250 | for (i = 0; i < NUM_SHADOW_METHODS; i++) { |
| 264 | if (scores[i] == testscore) { | 251 | if (scores[i] == testscore) { |
| 265 | NV_TRACE(dev, "Using BIOS image from %s\n", | 252 | NV_TRACE(dev, "Using BIOS image from %s\n", |
| 266 | methods[i].desc); | 253 | methods[i].desc); |
| @@ -935,7 +922,7 @@ init_io_restrict_prog(struct nvbios *bios, uint16_t offset, | |||
| 935 | NV_ERROR(bios->dev, | 922 | NV_ERROR(bios->dev, |
| 936 | "0x%04X: Config 0x%02X exceeds maximal bound 0x%02X\n", | 923 | "0x%04X: Config 0x%02X exceeds maximal bound 0x%02X\n", |
| 937 | offset, config, count); | 924 | offset, config, count); |
| 938 | return -EINVAL; | 925 | return len; |
| 939 | } | 926 | } |
| 940 | 927 | ||
| 941 | configval = ROM32(bios->data[offset + 11 + config * 4]); | 928 | configval = ROM32(bios->data[offset + 11 + config * 4]); |
| @@ -1037,7 +1024,7 @@ init_io_restrict_pll(struct nvbios *bios, uint16_t offset, | |||
| 1037 | NV_ERROR(bios->dev, | 1024 | NV_ERROR(bios->dev, |
| 1038 | "0x%04X: Config 0x%02X exceeds maximal bound 0x%02X\n", | 1025 | "0x%04X: Config 0x%02X exceeds maximal bound 0x%02X\n", |
| 1039 | offset, config, count); | 1026 | offset, config, count); |
| 1040 | return -EINVAL; | 1027 | return len; |
| 1041 | } | 1028 | } |
| 1042 | 1029 | ||
| 1043 | freq = ROM16(bios->data[offset + 12 + config * 2]); | 1030 | freq = ROM16(bios->data[offset + 12 + config * 2]); |
| @@ -1209,7 +1196,7 @@ init_dp_condition(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
| 1209 | dpe = nouveau_bios_dp_table(dev, dcb, &dummy); | 1196 | dpe = nouveau_bios_dp_table(dev, dcb, &dummy); |
| 1210 | if (!dpe) { | 1197 | if (!dpe) { |
| 1211 | NV_ERROR(dev, "0x%04X: INIT_3A: no encoder table!!\n", offset); | 1198 | NV_ERROR(dev, "0x%04X: INIT_3A: no encoder table!!\n", offset); |
| 1212 | return -EINVAL; | 1199 | return 3; |
| 1213 | } | 1200 | } |
| 1214 | 1201 | ||
| 1215 | switch (cond) { | 1202 | switch (cond) { |
| @@ -1233,12 +1220,16 @@ init_dp_condition(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
| 1233 | int ret; | 1220 | int ret; |
| 1234 | 1221 | ||
| 1235 | auxch = nouveau_i2c_find(dev, bios->display.output->i2c_index); | 1222 | auxch = nouveau_i2c_find(dev, bios->display.output->i2c_index); |
| 1236 | if (!auxch) | 1223 | if (!auxch) { |
| 1237 | return -ENODEV; | 1224 | NV_ERROR(dev, "0x%04X: couldn't get auxch\n", offset); |
| 1225 | return 3; | ||
| 1226 | } | ||
| 1238 | 1227 | ||
| 1239 | ret = nouveau_dp_auxch(auxch, 9, 0xd, &cond, 1); | 1228 | ret = nouveau_dp_auxch(auxch, 9, 0xd, &cond, 1); |
| 1240 | if (ret) | 1229 | if (ret) { |
| 1241 | return ret; | 1230 | NV_ERROR(dev, "0x%04X: auxch rd fail: %d\n", offset, ret); |
| 1231 | return 3; | ||
| 1232 | } | ||
| 1242 | 1233 | ||
| 1243 | if (cond & 1) | 1234 | if (cond & 1) |
| 1244 | iexec->execute = false; | 1235 | iexec->execute = false; |
| @@ -1407,7 +1398,7 @@ init_io_restrict_pll2(struct nvbios *bios, uint16_t offset, | |||
| 1407 | NV_ERROR(bios->dev, | 1398 | NV_ERROR(bios->dev, |
| 1408 | "0x%04X: Config 0x%02X exceeds maximal bound 0x%02X\n", | 1399 | "0x%04X: Config 0x%02X exceeds maximal bound 0x%02X\n", |
| 1409 | offset, config, count); | 1400 | offset, config, count); |
| 1410 | return -EINVAL; | 1401 | return len; |
| 1411 | } | 1402 | } |
| 1412 | 1403 | ||
| 1413 | freq = ROM32(bios->data[offset + 11 + config * 4]); | 1404 | freq = ROM32(bios->data[offset + 11 + config * 4]); |
| @@ -1467,6 +1458,7 @@ init_i2c_byte(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
| 1467 | * "mask n" and OR it with "data n" before writing it back to the device | 1458 | * "mask n" and OR it with "data n" before writing it back to the device |
| 1468 | */ | 1459 | */ |
| 1469 | 1460 | ||
| 1461 | struct drm_device *dev = bios->dev; | ||
| 1470 | uint8_t i2c_index = bios->data[offset + 1]; | 1462 | uint8_t i2c_index = bios->data[offset + 1]; |
| 1471 | uint8_t i2c_address = bios->data[offset + 2] >> 1; | 1463 | uint8_t i2c_address = bios->data[offset + 2] >> 1; |
| 1472 | uint8_t count = bios->data[offset + 3]; | 1464 | uint8_t count = bios->data[offset + 3]; |
| @@ -1481,9 +1473,11 @@ init_i2c_byte(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
| 1481 | "Count: 0x%02X\n", | 1473 | "Count: 0x%02X\n", |
| 1482 | offset, i2c_index, i2c_address, count); | 1474 | offset, i2c_index, i2c_address, count); |
| 1483 | 1475 | ||
| 1484 | chan = init_i2c_device_find(bios->dev, i2c_index); | 1476 | chan = init_i2c_device_find(dev, i2c_index); |
| 1485 | if (!chan) | 1477 | if (!chan) { |
| 1486 | return -ENODEV; | 1478 | NV_ERROR(dev, "0x%04X: i2c bus not found\n", offset); |
| 1479 | return len; | ||
| 1480 | } | ||
| 1487 | 1481 | ||
| 1488 | for (i = 0; i < count; i++) { | 1482 | for (i = 0; i < count; i++) { |
| 1489 | uint8_t reg = bios->data[offset + 4 + i * 3]; | 1483 | uint8_t reg = bios->data[offset + 4 + i * 3]; |
| @@ -1494,8 +1488,10 @@ init_i2c_byte(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
| 1494 | ret = i2c_smbus_xfer(&chan->adapter, i2c_address, 0, | 1488 | ret = i2c_smbus_xfer(&chan->adapter, i2c_address, 0, |
| 1495 | I2C_SMBUS_READ, reg, | 1489 | I2C_SMBUS_READ, reg, |
| 1496 | I2C_SMBUS_BYTE_DATA, &val); | 1490 | I2C_SMBUS_BYTE_DATA, &val); |
| 1497 | if (ret < 0) | 1491 | if (ret < 0) { |
| 1498 | return ret; | 1492 | NV_ERROR(dev, "0x%04X: i2c rd fail: %d\n", offset, ret); |
| 1493 | return len; | ||
| 1494 | } | ||
| 1499 | 1495 | ||
| 1500 | BIOSLOG(bios, "0x%04X: I2CReg: 0x%02X, Value: 0x%02X, " | 1496 | BIOSLOG(bios, "0x%04X: I2CReg: 0x%02X, Value: 0x%02X, " |
| 1501 | "Mask: 0x%02X, Data: 0x%02X\n", | 1497 | "Mask: 0x%02X, Data: 0x%02X\n", |
| @@ -1509,8 +1505,10 @@ init_i2c_byte(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
| 1509 | ret = i2c_smbus_xfer(&chan->adapter, i2c_address, 0, | 1505 | ret = i2c_smbus_xfer(&chan->adapter, i2c_address, 0, |
| 1510 | I2C_SMBUS_WRITE, reg, | 1506 | I2C_SMBUS_WRITE, reg, |
| 1511 | I2C_SMBUS_BYTE_DATA, &val); | 1507 | I2C_SMBUS_BYTE_DATA, &val); |
| 1512 | if (ret < 0) | 1508 | if (ret < 0) { |
| 1513 | return ret; | 1509 | NV_ERROR(dev, "0x%04X: i2c wr fail: %d\n", offset, ret); |
| 1510 | return len; | ||
| 1511 | } | ||
| 1514 | } | 1512 | } |
| 1515 | 1513 | ||
| 1516 | return len; | 1514 | return len; |
| @@ -1535,6 +1533,7 @@ init_zm_i2c_byte(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
| 1535 | * "DCB I2C table entry index", set the register to "data n" | 1533 | * "DCB I2C table entry index", set the register to "data n" |
| 1536 | */ | 1534 | */ |
| 1537 | 1535 | ||
| 1536 | struct drm_device *dev = bios->dev; | ||
| 1538 | uint8_t i2c_index = bios->data[offset + 1]; | 1537 | uint8_t i2c_index = bios->data[offset + 1]; |
| 1539 | uint8_t i2c_address = bios->data[offset + 2] >> 1; | 1538 | uint8_t i2c_address = bios->data[offset + 2] >> 1; |
| 1540 | uint8_t count = bios->data[offset + 3]; | 1539 | uint8_t count = bios->data[offset + 3]; |
| @@ -1549,9 +1548,11 @@ init_zm_i2c_byte(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
| 1549 | "Count: 0x%02X\n", | 1548 | "Count: 0x%02X\n", |
| 1550 | offset, i2c_index, i2c_address, count); | 1549 | offset, i2c_index, i2c_address, count); |
| 1551 | 1550 | ||
| 1552 | chan = init_i2c_device_find(bios->dev, i2c_index); | 1551 | chan = init_i2c_device_find(dev, i2c_index); |
| 1553 | if (!chan) | 1552 | if (!chan) { |
| 1554 | return -ENODEV; | 1553 | NV_ERROR(dev, "0x%04X: i2c bus not found\n", offset); |
| 1554 | return len; | ||
| 1555 | } | ||
| 1555 | 1556 | ||
| 1556 | for (i = 0; i < count; i++) { | 1557 | for (i = 0; i < count; i++) { |
| 1557 | uint8_t reg = bios->data[offset + 4 + i * 2]; | 1558 | uint8_t reg = bios->data[offset + 4 + i * 2]; |
| @@ -1568,8 +1569,10 @@ init_zm_i2c_byte(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
| 1568 | ret = i2c_smbus_xfer(&chan->adapter, i2c_address, 0, | 1569 | ret = i2c_smbus_xfer(&chan->adapter, i2c_address, 0, |
| 1569 | I2C_SMBUS_WRITE, reg, | 1570 | I2C_SMBUS_WRITE, reg, |
| 1570 | I2C_SMBUS_BYTE_DATA, &val); | 1571 | I2C_SMBUS_BYTE_DATA, &val); |
| 1571 | if (ret < 0) | 1572 | if (ret < 0) { |
| 1572 | return ret; | 1573 | NV_ERROR(dev, "0x%04X: i2c wr fail: %d\n", offset, ret); |
| 1574 | return len; | ||
| 1575 | } | ||
| 1573 | } | 1576 | } |
| 1574 | 1577 | ||
| 1575 | return len; | 1578 | return len; |
| @@ -1592,6 +1595,7 @@ init_zm_i2c(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
| 1592 | * address" on the I2C bus given by "DCB I2C table entry index" | 1595 | * address" on the I2C bus given by "DCB I2C table entry index" |
| 1593 | */ | 1596 | */ |
| 1594 | 1597 | ||
| 1598 | struct drm_device *dev = bios->dev; | ||
| 1595 | uint8_t i2c_index = bios->data[offset + 1]; | 1599 | uint8_t i2c_index = bios->data[offset + 1]; |
| 1596 | uint8_t i2c_address = bios->data[offset + 2] >> 1; | 1600 | uint8_t i2c_address = bios->data[offset + 2] >> 1; |
| 1597 | uint8_t count = bios->data[offset + 3]; | 1601 | uint8_t count = bios->data[offset + 3]; |
| @@ -1599,7 +1603,7 @@ init_zm_i2c(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
| 1599 | struct nouveau_i2c_chan *chan; | 1603 | struct nouveau_i2c_chan *chan; |
| 1600 | struct i2c_msg msg; | 1604 | struct i2c_msg msg; |
| 1601 | uint8_t data[256]; | 1605 | uint8_t data[256]; |
| 1602 | int i; | 1606 | int ret, i; |
| 1603 | 1607 | ||
| 1604 | if (!iexec->execute) | 1608 | if (!iexec->execute) |
| 1605 | return len; | 1609 | return len; |
| @@ -1608,9 +1612,11 @@ init_zm_i2c(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
| 1608 | "Count: 0x%02X\n", | 1612 | "Count: 0x%02X\n", |
| 1609 | offset, i2c_index, i2c_address, count); | 1613 | offset, i2c_index, i2c_address, count); |
| 1610 | 1614 | ||
| 1611 | chan = init_i2c_device_find(bios->dev, i2c_index); | 1615 | chan = init_i2c_device_find(dev, i2c_index); |
| 1612 | if (!chan) | 1616 | if (!chan) { |
| 1613 | return -ENODEV; | 1617 | NV_ERROR(dev, "0x%04X: i2c bus not found\n", offset); |
| 1618 | return len; | ||
| 1619 | } | ||
| 1614 | 1620 | ||
| 1615 | for (i = 0; i < count; i++) { | 1621 | for (i = 0; i < count; i++) { |
| 1616 | data[i] = bios->data[offset + 4 + i]; | 1622 | data[i] = bios->data[offset + 4 + i]; |
| @@ -1623,8 +1629,11 @@ init_zm_i2c(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
| 1623 | msg.flags = 0; | 1629 | msg.flags = 0; |
| 1624 | msg.len = count; | 1630 | msg.len = count; |
| 1625 | msg.buf = data; | 1631 | msg.buf = data; |
| 1626 | if (i2c_transfer(&chan->adapter, &msg, 1) != 1) | 1632 | ret = i2c_transfer(&chan->adapter, &msg, 1); |
| 1627 | return -EIO; | 1633 | if (ret != 1) { |
| 1634 | NV_ERROR(dev, "0x%04X: i2c wr fail: %d\n", offset, ret); | ||
| 1635 | return len; | ||
| 1636 | } | ||
| 1628 | } | 1637 | } |
| 1629 | 1638 | ||
| 1630 | return len; | 1639 | return len; |
| @@ -1648,6 +1657,7 @@ init_tmds(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
| 1648 | * used -- see get_tmds_index_reg() | 1657 | * used -- see get_tmds_index_reg() |
| 1649 | */ | 1658 | */ |
| 1650 | 1659 | ||
| 1660 | struct drm_device *dev = bios->dev; | ||
| 1651 | uint8_t mlv = bios->data[offset + 1]; | 1661 | uint8_t mlv = bios->data[offset + 1]; |
| 1652 | uint32_t tmdsaddr = bios->data[offset + 2]; | 1662 | uint32_t tmdsaddr = bios->data[offset + 2]; |
| 1653 | uint8_t mask = bios->data[offset + 3]; | 1663 | uint8_t mask = bios->data[offset + 3]; |
| @@ -1662,8 +1672,10 @@ init_tmds(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
| 1662 | offset, mlv, tmdsaddr, mask, data); | 1672 | offset, mlv, tmdsaddr, mask, data); |
| 1663 | 1673 | ||
| 1664 | reg = get_tmds_index_reg(bios->dev, mlv); | 1674 | reg = get_tmds_index_reg(bios->dev, mlv); |
| 1665 | if (!reg) | 1675 | if (!reg) { |
| 1666 | return -EINVAL; | 1676 | NV_ERROR(dev, "0x%04X: no tmds_index_reg\n", offset); |
| 1677 | return 5; | ||
| 1678 | } | ||
| 1667 | 1679 | ||
| 1668 | bios_wr32(bios, reg, | 1680 | bios_wr32(bios, reg, |
| 1669 | tmdsaddr | NV_PRAMDAC_FP_TMDS_CONTROL_WRITE_DISABLE); | 1681 | tmdsaddr | NV_PRAMDAC_FP_TMDS_CONTROL_WRITE_DISABLE); |
| @@ -1693,6 +1705,7 @@ init_zm_tmds_group(struct nvbios *bios, uint16_t offset, | |||
| 1693 | * register is used -- see get_tmds_index_reg() | 1705 | * register is used -- see get_tmds_index_reg() |
| 1694 | */ | 1706 | */ |
| 1695 | 1707 | ||
| 1708 | struct drm_device *dev = bios->dev; | ||
| 1696 | uint8_t mlv = bios->data[offset + 1]; | 1709 | uint8_t mlv = bios->data[offset + 1]; |
| 1697 | uint8_t count = bios->data[offset + 2]; | 1710 | uint8_t count = bios->data[offset + 2]; |
| 1698 | int len = 3 + count * 2; | 1711 | int len = 3 + count * 2; |
| @@ -1706,8 +1719,10 @@ init_zm_tmds_group(struct nvbios *bios, uint16_t offset, | |||
| 1706 | offset, mlv, count); | 1719 | offset, mlv, count); |
| 1707 | 1720 | ||
| 1708 | reg = get_tmds_index_reg(bios->dev, mlv); | 1721 | reg = get_tmds_index_reg(bios->dev, mlv); |
| 1709 | if (!reg) | 1722 | if (!reg) { |
| 1710 | return -EINVAL; | 1723 | NV_ERROR(dev, "0x%04X: no tmds_index_reg\n", offset); |
| 1724 | return len; | ||
| 1725 | } | ||
| 1711 | 1726 | ||
| 1712 | for (i = 0; i < count; i++) { | 1727 | for (i = 0; i < count; i++) { |
| 1713 | uint8_t tmdsaddr = bios->data[offset + 3 + i * 2]; | 1728 | uint8_t tmdsaddr = bios->data[offset + 3 + i * 2]; |
| @@ -2054,6 +2069,323 @@ init_zm_index_io(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
| 2054 | return 5; | 2069 | return 5; |
| 2055 | } | 2070 | } |
| 2056 | 2071 | ||
| 2072 | static inline void | ||
| 2073 | bios_md32(struct nvbios *bios, uint32_t reg, | ||
| 2074 | uint32_t mask, uint32_t val) | ||
| 2075 | { | ||
| 2076 | bios_wr32(bios, reg, (bios_rd32(bios, reg) & ~mask) | val); | ||
| 2077 | } | ||
| 2078 | |||
| 2079 | static uint32_t | ||
| 2080 | peek_fb(struct drm_device *dev, struct io_mapping *fb, | ||
| 2081 | uint32_t off) | ||
| 2082 | { | ||
| 2083 | uint32_t val = 0; | ||
| 2084 | |||
| 2085 | if (off < pci_resource_len(dev->pdev, 1)) { | ||
| 2086 | uint32_t __iomem *p = io_mapping_map_atomic_wc(fb, off, KM_USER0); | ||
| 2087 | |||
| 2088 | val = ioread32(p); | ||
| 2089 | |||
| 2090 | io_mapping_unmap_atomic(p, KM_USER0); | ||
| 2091 | } | ||
| 2092 | |||
| 2093 | return val; | ||
| 2094 | } | ||
| 2095 | |||
| 2096 | static void | ||
| 2097 | poke_fb(struct drm_device *dev, struct io_mapping *fb, | ||
| 2098 | uint32_t off, uint32_t val) | ||
| 2099 | { | ||
| 2100 | if (off < pci_resource_len(dev->pdev, 1)) { | ||
| 2101 | uint32_t __iomem *p = io_mapping_map_atomic_wc(fb, off, KM_USER0); | ||
| 2102 | |||
| 2103 | iowrite32(val, p); | ||
| 2104 | wmb(); | ||
| 2105 | |||
| 2106 | io_mapping_unmap_atomic(p, KM_USER0); | ||
| 2107 | } | ||
| 2108 | } | ||
| 2109 | |||
| 2110 | static inline bool | ||
| 2111 | read_back_fb(struct drm_device *dev, struct io_mapping *fb, | ||
| 2112 | uint32_t off, uint32_t val) | ||
| 2113 | { | ||
| 2114 | poke_fb(dev, fb, off, val); | ||
| 2115 | return val == peek_fb(dev, fb, off); | ||
| 2116 | } | ||
| 2117 | |||
| 2118 | static int | ||
| 2119 | nv04_init_compute_mem(struct nvbios *bios) | ||
| 2120 | { | ||
| 2121 | struct drm_device *dev = bios->dev; | ||
| 2122 | uint32_t patt = 0xdeadbeef; | ||
| 2123 | struct io_mapping *fb; | ||
| 2124 | int i; | ||
| 2125 | |||
| 2126 | /* Map the framebuffer aperture */ | ||
| 2127 | fb = io_mapping_create_wc(pci_resource_start(dev->pdev, 1), | ||
| 2128 | pci_resource_len(dev->pdev, 1)); | ||
| 2129 | if (!fb) | ||
| 2130 | return -ENOMEM; | ||
| 2131 | |||
| 2132 | /* Sequencer and refresh off */ | ||
| 2133 | NVWriteVgaSeq(dev, 0, 1, NVReadVgaSeq(dev, 0, 1) | 0x20); | ||
| 2134 | bios_md32(bios, NV04_PFB_DEBUG_0, 0, NV04_PFB_DEBUG_0_REFRESH_OFF); | ||
| 2135 | |||
| 2136 | bios_md32(bios, NV04_PFB_BOOT_0, ~0, | ||
| 2137 | NV04_PFB_BOOT_0_RAM_AMOUNT_16MB | | ||
| 2138 | NV04_PFB_BOOT_0_RAM_WIDTH_128 | | ||
| 2139 | NV04_PFB_BOOT_0_RAM_TYPE_SGRAM_16MBIT); | ||
| 2140 | |||
| 2141 | for (i = 0; i < 4; i++) | ||
| 2142 | poke_fb(dev, fb, 4 * i, patt); | ||
| 2143 | |||
| 2144 | poke_fb(dev, fb, 0x400000, patt + 1); | ||
| 2145 | |||
| 2146 | if (peek_fb(dev, fb, 0) == patt + 1) { | ||
| 2147 | bios_md32(bios, NV04_PFB_BOOT_0, NV04_PFB_BOOT_0_RAM_TYPE, | ||
| 2148 | NV04_PFB_BOOT_0_RAM_TYPE_SDRAM_16MBIT); | ||
| 2149 | bios_md32(bios, NV04_PFB_DEBUG_0, | ||
| 2150 | NV04_PFB_DEBUG_0_REFRESH_OFF, 0); | ||
| 2151 | |||
| 2152 | for (i = 0; i < 4; i++) | ||
| 2153 | poke_fb(dev, fb, 4 * i, patt); | ||
| 2154 | |||
| 2155 | if ((peek_fb(dev, fb, 0xc) & 0xffff) != (patt & 0xffff)) | ||
| 2156 | bios_md32(bios, NV04_PFB_BOOT_0, | ||
| 2157 | NV04_PFB_BOOT_0_RAM_WIDTH_128 | | ||
| 2158 | NV04_PFB_BOOT_0_RAM_AMOUNT, | ||
| 2159 | NV04_PFB_BOOT_0_RAM_AMOUNT_8MB); | ||
| 2160 | |||
| 2161 | } else if ((peek_fb(dev, fb, 0xc) & 0xffff0000) != | ||
| 2162 | (patt & 0xffff0000)) { | ||
| 2163 | bios_md32(bios, NV04_PFB_BOOT_0, | ||
| 2164 | NV04_PFB_BOOT_0_RAM_WIDTH_128 | | ||
| 2165 | NV04_PFB_BOOT_0_RAM_AMOUNT, | ||
| 2166 | NV04_PFB_BOOT_0_RAM_AMOUNT_4MB); | ||
| 2167 | |||
| 2168 | } else if (peek_fb(dev, fb, 0) == patt) { | ||
| 2169 | if (read_back_fb(dev, fb, 0x800000, patt)) | ||
| 2170 | bios_md32(bios, NV04_PFB_BOOT_0, | ||
| 2171 | NV04_PFB_BOOT_0_RAM_AMOUNT, | ||
| 2172 | NV04_PFB_BOOT_0_RAM_AMOUNT_8MB); | ||
| 2173 | else | ||
| 2174 | bios_md32(bios, NV04_PFB_BOOT_0, | ||
| 2175 | NV04_PFB_BOOT_0_RAM_AMOUNT, | ||
| 2176 | NV04_PFB_BOOT_0_RAM_AMOUNT_4MB); | ||
| 2177 | |||
| 2178 | bios_md32(bios, NV04_PFB_BOOT_0, NV04_PFB_BOOT_0_RAM_TYPE, | ||
| 2179 | NV04_PFB_BOOT_0_RAM_TYPE_SGRAM_8MBIT); | ||
| 2180 | |||
| 2181 | } else if (!read_back_fb(dev, fb, 0x800000, patt)) { | ||
| 2182 | bios_md32(bios, NV04_PFB_BOOT_0, NV04_PFB_BOOT_0_RAM_AMOUNT, | ||
| 2183 | NV04_PFB_BOOT_0_RAM_AMOUNT_8MB); | ||
| 2184 | |||
| 2185 | } | ||
| 2186 | |||
| 2187 | /* Refresh on, sequencer on */ | ||
| 2188 | bios_md32(bios, NV04_PFB_DEBUG_0, NV04_PFB_DEBUG_0_REFRESH_OFF, 0); | ||
| 2189 | NVWriteVgaSeq(dev, 0, 1, NVReadVgaSeq(dev, 0, 1) & ~0x20); | ||
| 2190 | |||
| 2191 | io_mapping_free(fb); | ||
| 2192 | return 0; | ||
| 2193 | } | ||
| 2194 | |||
| 2195 | static const uint8_t * | ||
| 2196 | nv05_memory_config(struct nvbios *bios) | ||
| 2197 | { | ||
| 2198 | /* Defaults for BIOSes lacking a memory config table */ | ||
| 2199 | static const uint8_t default_config_tab[][2] = { | ||
| 2200 | { 0x24, 0x00 }, | ||
| 2201 | { 0x28, 0x00 }, | ||
| 2202 | { 0x24, 0x01 }, | ||
| 2203 | { 0x1f, 0x00 }, | ||
| 2204 | { 0x0f, 0x00 }, | ||
| 2205 | { 0x17, 0x00 }, | ||
| 2206 | { 0x06, 0x00 }, | ||
| 2207 | { 0x00, 0x00 } | ||
| 2208 | }; | ||
| 2209 | int i = (bios_rd32(bios, NV_PEXTDEV_BOOT_0) & | ||
| 2210 | NV_PEXTDEV_BOOT_0_RAMCFG) >> 2; | ||
| 2211 | |||
| 2212 | if (bios->legacy.mem_init_tbl_ptr) | ||
| 2213 | return &bios->data[bios->legacy.mem_init_tbl_ptr + 2 * i]; | ||
| 2214 | else | ||
| 2215 | return default_config_tab[i]; | ||
| 2216 | } | ||
| 2217 | |||
| 2218 | static int | ||
| 2219 | nv05_init_compute_mem(struct nvbios *bios) | ||
| 2220 | { | ||
| 2221 | struct drm_device *dev = bios->dev; | ||
| 2222 | const uint8_t *ramcfg = nv05_memory_config(bios); | ||
| 2223 | uint32_t patt = 0xdeadbeef; | ||
| 2224 | struct io_mapping *fb; | ||
| 2225 | int i, v; | ||
| 2226 | |||
| 2227 | /* Map the framebuffer aperture */ | ||
| 2228 | fb = io_mapping_create_wc(pci_resource_start(dev->pdev, 1), | ||
| 2229 | pci_resource_len(dev->pdev, 1)); | ||
| 2230 | if (!fb) | ||
| 2231 | return -ENOMEM; | ||
| 2232 | |||
| 2233 | /* Sequencer off */ | ||
| 2234 | NVWriteVgaSeq(dev, 0, 1, NVReadVgaSeq(dev, 0, 1) | 0x20); | ||
| 2235 | |||
| 2236 | if (bios_rd32(bios, NV04_PFB_BOOT_0) & NV04_PFB_BOOT_0_UMA_ENABLE) | ||
| 2237 | goto out; | ||
| 2238 | |||
| 2239 | bios_md32(bios, NV04_PFB_DEBUG_0, NV04_PFB_DEBUG_0_REFRESH_OFF, 0); | ||
| 2240 | |||
| 2241 | /* If present load the hardcoded scrambling table */ | ||
| 2242 | if (bios->legacy.mem_init_tbl_ptr) { | ||
| 2243 | uint32_t *scramble_tab = (uint32_t *)&bios->data[ | ||
| 2244 | bios->legacy.mem_init_tbl_ptr + 0x10]; | ||
| 2245 | |||
| 2246 | for (i = 0; i < 8; i++) | ||
| 2247 | bios_wr32(bios, NV04_PFB_SCRAMBLE(i), | ||
| 2248 | ROM32(scramble_tab[i])); | ||
| 2249 | } | ||
| 2250 | |||
| 2251 | /* Set memory type/width/length defaults depending on the straps */ | ||
| 2252 | bios_md32(bios, NV04_PFB_BOOT_0, 0x3f, ramcfg[0]); | ||
| 2253 | |||
| 2254 | if (ramcfg[1] & 0x80) | ||
| 2255 | bios_md32(bios, NV04_PFB_CFG0, 0, NV04_PFB_CFG0_SCRAMBLE); | ||
| 2256 | |||
| 2257 | bios_md32(bios, NV04_PFB_CFG1, 0x700001, (ramcfg[1] & 1) << 20); | ||
| 2258 | bios_md32(bios, NV04_PFB_CFG1, 0, 1); | ||
| 2259 | |||
| 2260 | /* Probe memory bus width */ | ||
| 2261 | for (i = 0; i < 4; i++) | ||
| 2262 | poke_fb(dev, fb, 4 * i, patt); | ||
| 2263 | |||
| 2264 | if (peek_fb(dev, fb, 0xc) != patt) | ||
| 2265 | bios_md32(bios, NV04_PFB_BOOT_0, | ||
| 2266 | NV04_PFB_BOOT_0_RAM_WIDTH_128, 0); | ||
| 2267 | |||
| 2268 | /* Probe memory length */ | ||
| 2269 | v = bios_rd32(bios, NV04_PFB_BOOT_0) & NV04_PFB_BOOT_0_RAM_AMOUNT; | ||
| 2270 | |||
| 2271 | if (v == NV04_PFB_BOOT_0_RAM_AMOUNT_32MB && | ||
| 2272 | (!read_back_fb(dev, fb, 0x1000000, ++patt) || | ||
| 2273 | !read_back_fb(dev, fb, 0, ++patt))) | ||
| 2274 | bios_md32(bios, NV04_PFB_BOOT_0, NV04_PFB_BOOT_0_RAM_AMOUNT, | ||
| 2275 | NV04_PFB_BOOT_0_RAM_AMOUNT_16MB); | ||
| 2276 | |||
| 2277 | if (v == NV04_PFB_BOOT_0_RAM_AMOUNT_16MB && | ||
| 2278 | !read_back_fb(dev, fb, 0x800000, ++patt)) | ||
| 2279 | bios_md32(bios, NV04_PFB_BOOT_0, NV04_PFB_BOOT_0_RAM_AMOUNT, | ||
| 2280 | NV04_PFB_BOOT_0_RAM_AMOUNT_8MB); | ||
| 2281 | |||
| 2282 | if (!read_back_fb(dev, fb, 0x400000, ++patt)) | ||
| 2283 | bios_md32(bios, NV04_PFB_BOOT_0, NV04_PFB_BOOT_0_RAM_AMOUNT, | ||
| 2284 | NV04_PFB_BOOT_0_RAM_AMOUNT_4MB); | ||
| 2285 | |||
| 2286 | out: | ||
| 2287 | /* Sequencer on */ | ||
| 2288 | NVWriteVgaSeq(dev, 0, 1, NVReadVgaSeq(dev, 0, 1) & ~0x20); | ||
| 2289 | |||
| 2290 | io_mapping_free(fb); | ||
| 2291 | return 0; | ||
| 2292 | } | ||
| 2293 | |||
| 2294 | static int | ||
| 2295 | nv10_init_compute_mem(struct nvbios *bios) | ||
| 2296 | { | ||
| 2297 | struct drm_device *dev = bios->dev; | ||
| 2298 | struct drm_nouveau_private *dev_priv = bios->dev->dev_private; | ||
| 2299 | const int mem_width[] = { 0x10, 0x00, 0x20 }; | ||
| 2300 | const int mem_width_count = (dev_priv->chipset >= 0x17 ? 3 : 2); | ||
| 2301 | uint32_t patt = 0xdeadbeef; | ||
| 2302 | struct io_mapping *fb; | ||
| 2303 | int i, j, k; | ||
| 2304 | |||
| 2305 | /* Map the framebuffer aperture */ | ||
| 2306 | fb = io_mapping_create_wc(pci_resource_start(dev->pdev, 1), | ||
| 2307 | pci_resource_len(dev->pdev, 1)); | ||
| 2308 | if (!fb) | ||
| 2309 | return -ENOMEM; | ||
| 2310 | |||
| 2311 | bios_wr32(bios, NV10_PFB_REFCTRL, NV10_PFB_REFCTRL_VALID_1); | ||
| 2312 | |||
| 2313 | /* Probe memory bus width */ | ||
| 2314 | for (i = 0; i < mem_width_count; i++) { | ||
| 2315 | bios_md32(bios, NV04_PFB_CFG0, 0x30, mem_width[i]); | ||
| 2316 | |||
| 2317 | for (j = 0; j < 4; j++) { | ||
| 2318 | for (k = 0; k < 4; k++) | ||
| 2319 | poke_fb(dev, fb, 0x1c, 0); | ||
| 2320 | |||
| 2321 | poke_fb(dev, fb, 0x1c, patt); | ||
| 2322 | poke_fb(dev, fb, 0x3c, 0); | ||
| 2323 | |||
| 2324 | if (peek_fb(dev, fb, 0x1c) == patt) | ||
| 2325 | goto mem_width_found; | ||
| 2326 | } | ||
| 2327 | } | ||
| 2328 | |||
| 2329 | mem_width_found: | ||
| 2330 | patt <<= 1; | ||
| 2331 | |||
| 2332 | /* Probe amount of installed memory */ | ||
| 2333 | for (i = 0; i < 4; i++) { | ||
| 2334 | int off = bios_rd32(bios, NV04_PFB_FIFO_DATA) - 0x100000; | ||
| 2335 | |||
| 2336 | poke_fb(dev, fb, off, patt); | ||
| 2337 | poke_fb(dev, fb, 0, 0); | ||
| 2338 | |||
| 2339 | peek_fb(dev, fb, 0); | ||
| 2340 | peek_fb(dev, fb, 0); | ||
| 2341 | peek_fb(dev, fb, 0); | ||
| 2342 | peek_fb(dev, fb, 0); | ||
| 2343 | |||
| 2344 | if (peek_fb(dev, fb, off) == patt) | ||
| 2345 | goto amount_found; | ||
| 2346 | } | ||
| 2347 | |||
| 2348 | /* IC missing - disable the upper half memory space. */ | ||
| 2349 | bios_md32(bios, NV04_PFB_CFG0, 0x1000, 0); | ||
| 2350 | |||
| 2351 | amount_found: | ||
| 2352 | io_mapping_free(fb); | ||
| 2353 | return 0; | ||
| 2354 | } | ||
| 2355 | |||
| 2356 | static int | ||
| 2357 | nv20_init_compute_mem(struct nvbios *bios) | ||
| 2358 | { | ||
| 2359 | struct drm_device *dev = bios->dev; | ||
| 2360 | struct drm_nouveau_private *dev_priv = bios->dev->dev_private; | ||
| 2361 | uint32_t mask = (dev_priv->chipset >= 0x25 ? 0x300 : 0x900); | ||
| 2362 | uint32_t amount, off; | ||
| 2363 | struct io_mapping *fb; | ||
| 2364 | |||
| 2365 | /* Map the framebuffer aperture */ | ||
| 2366 | fb = io_mapping_create_wc(pci_resource_start(dev->pdev, 1), | ||
| 2367 | pci_resource_len(dev->pdev, 1)); | ||
| 2368 | if (!fb) | ||
| 2369 | return -ENOMEM; | ||
| 2370 | |||
| 2371 | bios_wr32(bios, NV10_PFB_REFCTRL, NV10_PFB_REFCTRL_VALID_1); | ||
| 2372 | |||
| 2373 | /* Allow full addressing */ | ||
| 2374 | bios_md32(bios, NV04_PFB_CFG0, 0, mask); | ||
| 2375 | |||
| 2376 | amount = bios_rd32(bios, NV04_PFB_FIFO_DATA); | ||
| 2377 | for (off = amount; off > 0x2000000; off -= 0x2000000) | ||
| 2378 | poke_fb(dev, fb, off - 4, off); | ||
| 2379 | |||
| 2380 | amount = bios_rd32(bios, NV04_PFB_FIFO_DATA); | ||
| 2381 | if (amount != peek_fb(dev, fb, amount - 4)) | ||
| 2382 | /* IC missing - disable the upper half memory space. */ | ||
| 2383 | bios_md32(bios, NV04_PFB_CFG0, mask, 0); | ||
| 2384 | |||
| 2385 | io_mapping_free(fb); | ||
| 2386 | return 0; | ||
| 2387 | } | ||
| 2388 | |||
| 2057 | static int | 2389 | static int |
| 2058 | init_compute_mem(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | 2390 | init_compute_mem(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) |
| 2059 | { | 2391 | { |
| @@ -2062,64 +2394,57 @@ init_compute_mem(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
| 2062 | * | 2394 | * |
| 2063 | * offset (8 bit): opcode | 2395 | * offset (8 bit): opcode |
| 2064 | * | 2396 | * |
| 2065 | * This opcode is meant to set NV_PFB_CFG0 (0x100200) appropriately so | 2397 | * This opcode is meant to set the PFB memory config registers |
| 2066 | * that the hardware can correctly calculate how much VRAM it has | 2398 | * appropriately so that we can correctly calculate how much VRAM it |
| 2067 | * (and subsequently report that value in NV_PFB_CSTATUS (0x10020C)) | 2399 | * has (on nv10 and better chipsets the amount of installed VRAM is |
| 2400 | * subsequently reported in NV_PFB_CSTATUS (0x10020C)). | ||
| 2068 | * | 2401 | * |
| 2069 | * The implementation of this opcode in general consists of two parts: | 2402 | * The implementation of this opcode in general consists of several |
| 2070 | * 1) determination of the memory bus width | 2403 | * parts: |
| 2071 | * 2) determination of how many of the card's RAM pads have ICs attached | ||
| 2072 | * | 2404 | * |
| 2073 | * 1) is done by a cunning combination of writes to offsets 0x1c and | 2405 | * 1) Determination of memory type and density. Only necessary for |
| 2074 | * 0x3c in the framebuffer, and seeing whether the written values are | 2406 | * really old chipsets, the memory type reported by the strap bits |
| 2075 | * read back correctly. This then affects bits 4-7 of NV_PFB_CFG0 | 2407 | * (0x101000) is assumed to be accurate on nv05 and newer. |
| 2076 | * | 2408 | * |
| 2077 | * 2) is done by a cunning combination of writes to an offset slightly | 2409 | * 2) Determination of the memory bus width. Usually done by a cunning |
| 2078 | * less than the maximum memory reported by NV_PFB_CSTATUS, then seeing | 2410 | * combination of writes to offsets 0x1c and 0x3c in the fb, and |
| 2079 | * if the test pattern can be read back. This then affects bits 12-15 of | 2411 | * seeing whether the written values are read back correctly. |
| 2080 | * NV_PFB_CFG0 | ||
| 2081 | * | 2412 | * |
| 2082 | * In this context a "cunning combination" may include multiple reads | 2413 | * Only necessary on nv0x-nv1x and nv34, on the other cards we can |
| 2083 | * and writes to varying locations, often alternating the test pattern | 2414 | * trust the straps. |
| 2084 | * and 0, doubtless to make sure buffers are filled, residual charges | ||
| 2085 | * on tracks are removed etc. | ||
| 2086 | * | 2415 | * |
| 2087 | * Unfortunately, the "cunning combination"s mentioned above, and the | 2416 | * 3) Determination of how many of the card's RAM pads have ICs |
| 2088 | * changes to the bits in NV_PFB_CFG0 differ with nearly every bios | 2417 | * attached, usually done by a cunning combination of writes to an |
| 2089 | * trace I have. | 2418 | * offset slightly less than the maximum memory reported by |
| 2419 | * NV_PFB_CSTATUS, then seeing if the test pattern can be read back. | ||
| 2090 | * | 2420 | * |
| 2091 | * Therefore, we cheat and assume the value of NV_PFB_CFG0 with which | 2421 | * This appears to be a NOP on IGPs and NV4x or newer chipsets, both io |
| 2092 | * we started was correct, and use that instead | 2422 | * logs of the VBIOS and kmmio traces of the binary driver POSTing the |
| 2423 | * card show nothing being done for this opcode. Why is it still listed | ||
| 2424 | * in the table?! | ||
| 2093 | */ | 2425 | */ |
| 2094 | 2426 | ||
| 2095 | /* no iexec->execute check by design */ | 2427 | /* no iexec->execute check by design */ |
| 2096 | 2428 | ||
| 2097 | /* | ||
| 2098 | * This appears to be a NOP on G8x chipsets, both io logs of the VBIOS | ||
| 2099 | * and kmmio traces of the binary driver POSTing the card show nothing | ||
| 2100 | * being done for this opcode. why is it still listed in the table?! | ||
| 2101 | */ | ||
| 2102 | |||
| 2103 | struct drm_nouveau_private *dev_priv = bios->dev->dev_private; | 2429 | struct drm_nouveau_private *dev_priv = bios->dev->dev_private; |
| 2430 | int ret; | ||
| 2104 | 2431 | ||
| 2105 | if (dev_priv->card_type >= NV_40) | 2432 | if (dev_priv->chipset >= 0x40 || |
| 2106 | return 1; | 2433 | dev_priv->chipset == 0x1a || |
| 2107 | 2434 | dev_priv->chipset == 0x1f) | |
| 2108 | /* | 2435 | ret = 0; |
| 2109 | * On every card I've seen, this step gets done for us earlier in | 2436 | else if (dev_priv->chipset >= 0x20 && |
| 2110 | * the init scripts | 2437 | dev_priv->chipset != 0x34) |
| 2111 | uint8_t crdata = bios_idxprt_rd(dev, NV_VIO_SRX, 0x01); | 2438 | ret = nv20_init_compute_mem(bios); |
| 2112 | bios_idxprt_wr(dev, NV_VIO_SRX, 0x01, crdata | 0x20); | 2439 | else if (dev_priv->chipset >= 0x10) |
| 2113 | */ | 2440 | ret = nv10_init_compute_mem(bios); |
| 2114 | 2441 | else if (dev_priv->chipset >= 0x5) | |
| 2115 | /* | 2442 | ret = nv05_init_compute_mem(bios); |
| 2116 | * This also has probably been done in the scripts, but an mmio trace of | 2443 | else |
| 2117 | * s3 resume shows nvidia doing it anyway (unlike the NV_VIO_SRX write) | 2444 | ret = nv04_init_compute_mem(bios); |
| 2118 | */ | ||
| 2119 | bios_wr32(bios, NV_PFB_REFCTRL, NV_PFB_REFCTRL_VALID_1); | ||
| 2120 | 2445 | ||
| 2121 | /* write back the saved configuration value */ | 2446 | if (ret) |
| 2122 | bios_wr32(bios, NV_PFB_CFG0, bios->state.saved_nv_pfb_cfg0); | 2447 | return ret; |
| 2123 | 2448 | ||
| 2124 | return 1; | 2449 | return 1; |
| 2125 | } | 2450 | } |
| @@ -2146,7 +2471,8 @@ init_reset(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
| 2146 | /* no iexec->execute check by design */ | 2471 | /* no iexec->execute check by design */ |
| 2147 | 2472 | ||
| 2148 | pci_nv_19 = bios_rd32(bios, NV_PBUS_PCI_NV_19); | 2473 | pci_nv_19 = bios_rd32(bios, NV_PBUS_PCI_NV_19); |
| 2149 | bios_wr32(bios, NV_PBUS_PCI_NV_19, 0); | 2474 | bios_wr32(bios, NV_PBUS_PCI_NV_19, pci_nv_19 & ~0xf00); |
| 2475 | |||
| 2150 | bios_wr32(bios, reg, value1); | 2476 | bios_wr32(bios, reg, value1); |
| 2151 | 2477 | ||
| 2152 | udelay(10); | 2478 | udelay(10); |
| @@ -2182,7 +2508,7 @@ init_configure_mem(struct nvbios *bios, uint16_t offset, | |||
| 2182 | uint32_t reg, data; | 2508 | uint32_t reg, data; |
| 2183 | 2509 | ||
| 2184 | if (bios->major_version > 2) | 2510 | if (bios->major_version > 2) |
| 2185 | return -ENODEV; | 2511 | return 0; |
| 2186 | 2512 | ||
| 2187 | bios_idxprt_wr(bios, NV_VIO_SRX, NV_VIO_SR_CLOCK_INDEX, bios_idxprt_rd( | 2513 | bios_idxprt_wr(bios, NV_VIO_SRX, NV_VIO_SR_CLOCK_INDEX, bios_idxprt_rd( |
| 2188 | bios, NV_VIO_SRX, NV_VIO_SR_CLOCK_INDEX) | 0x20); | 2514 | bios, NV_VIO_SRX, NV_VIO_SR_CLOCK_INDEX) | 0x20); |
| @@ -2195,14 +2521,14 @@ init_configure_mem(struct nvbios *bios, uint16_t offset, | |||
| 2195 | reg = ROM32(bios->data[seqtbloffs += 4])) { | 2521 | reg = ROM32(bios->data[seqtbloffs += 4])) { |
| 2196 | 2522 | ||
| 2197 | switch (reg) { | 2523 | switch (reg) { |
| 2198 | case NV_PFB_PRE: | 2524 | case NV04_PFB_PRE: |
| 2199 | data = NV_PFB_PRE_CMD_PRECHARGE; | 2525 | data = NV04_PFB_PRE_CMD_PRECHARGE; |
| 2200 | break; | 2526 | break; |
| 2201 | case NV_PFB_PAD: | 2527 | case NV04_PFB_PAD: |
| 2202 | data = NV_PFB_PAD_CKE_NORMAL; | 2528 | data = NV04_PFB_PAD_CKE_NORMAL; |
| 2203 | break; | 2529 | break; |
| 2204 | case NV_PFB_REF: | 2530 | case NV04_PFB_REF: |
| 2205 | data = NV_PFB_REF_CMD_REFRESH; | 2531 | data = NV04_PFB_REF_CMD_REFRESH; |
| 2206 | break; | 2532 | break; |
| 2207 | default: | 2533 | default: |
| 2208 | data = ROM32(bios->data[meminitdata]); | 2534 | data = ROM32(bios->data[meminitdata]); |
| @@ -2237,7 +2563,7 @@ init_configure_clk(struct nvbios *bios, uint16_t offset, | |||
| 2237 | int clock; | 2563 | int clock; |
| 2238 | 2564 | ||
| 2239 | if (bios->major_version > 2) | 2565 | if (bios->major_version > 2) |
| 2240 | return -ENODEV; | 2566 | return 0; |
| 2241 | 2567 | ||
| 2242 | clock = ROM16(bios->data[meminitoffs + 4]) * 10; | 2568 | clock = ROM16(bios->data[meminitoffs + 4]) * 10; |
| 2243 | setPLL(bios, NV_PRAMDAC_NVPLL_COEFF, clock); | 2569 | setPLL(bios, NV_PRAMDAC_NVPLL_COEFF, clock); |
| @@ -2270,7 +2596,7 @@ init_configure_preinit(struct nvbios *bios, uint16_t offset, | |||
| 2270 | uint8_t cr3c = ((straps << 2) & 0xf0) | (straps & (1 << 6)); | 2596 | uint8_t cr3c = ((straps << 2) & 0xf0) | (straps & (1 << 6)); |
| 2271 | 2597 | ||
| 2272 | if (bios->major_version > 2) | 2598 | if (bios->major_version > 2) |
| 2273 | return -ENODEV; | 2599 | return 0; |
| 2274 | 2600 | ||
| 2275 | bios_idxprt_wr(bios, NV_CIO_CRX__COLOR, | 2601 | bios_idxprt_wr(bios, NV_CIO_CRX__COLOR, |
| 2276 | NV_CIO_CRE_SCRATCH4__INDEX, cr3c); | 2602 | NV_CIO_CRE_SCRATCH4__INDEX, cr3c); |
| @@ -2404,7 +2730,7 @@ init_ram_condition(struct nvbios *bios, uint16_t offset, | |||
| 2404 | * offset + 1 (8 bit): mask | 2730 | * offset + 1 (8 bit): mask |
| 2405 | * offset + 2 (8 bit): cmpval | 2731 | * offset + 2 (8 bit): cmpval |
| 2406 | * | 2732 | * |
| 2407 | * Test if (NV_PFB_BOOT_0 & "mask") equals "cmpval". | 2733 | * Test if (NV04_PFB_BOOT_0 & "mask") equals "cmpval". |
| 2408 | * If condition not met skip subsequent opcodes until condition is | 2734 | * If condition not met skip subsequent opcodes until condition is |
| 2409 | * inverted (INIT_NOT), or we hit INIT_RESUME | 2735 | * inverted (INIT_NOT), or we hit INIT_RESUME |
| 2410 | */ | 2736 | */ |
| @@ -2416,7 +2742,7 @@ init_ram_condition(struct nvbios *bios, uint16_t offset, | |||
| 2416 | if (!iexec->execute) | 2742 | if (!iexec->execute) |
| 2417 | return 3; | 2743 | return 3; |
| 2418 | 2744 | ||
| 2419 | data = bios_rd32(bios, NV_PFB_BOOT_0) & mask; | 2745 | data = bios_rd32(bios, NV04_PFB_BOOT_0) & mask; |
| 2420 | 2746 | ||
| 2421 | BIOSLOG(bios, "0x%04X: Checking if 0x%08X equals 0x%08X\n", | 2747 | BIOSLOG(bios, "0x%04X: Checking if 0x%08X equals 0x%08X\n", |
| 2422 | offset, data, cmpval); | 2748 | offset, data, cmpval); |
| @@ -2810,12 +3136,13 @@ init_gpio(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
| 2810 | */ | 3136 | */ |
| 2811 | 3137 | ||
| 2812 | struct drm_nouveau_private *dev_priv = bios->dev->dev_private; | 3138 | struct drm_nouveau_private *dev_priv = bios->dev->dev_private; |
| 3139 | struct nouveau_gpio_engine *pgpio = &dev_priv->engine.gpio; | ||
| 2813 | const uint32_t nv50_gpio_ctl[2] = { 0xe100, 0xe28c }; | 3140 | const uint32_t nv50_gpio_ctl[2] = { 0xe100, 0xe28c }; |
| 2814 | int i; | 3141 | int i; |
| 2815 | 3142 | ||
| 2816 | if (dev_priv->card_type != NV_50) { | 3143 | if (dev_priv->card_type != NV_50) { |
| 2817 | NV_ERROR(bios->dev, "INIT_GPIO on unsupported chipset\n"); | 3144 | NV_ERROR(bios->dev, "INIT_GPIO on unsupported chipset\n"); |
| 2818 | return -ENODEV; | 3145 | return 1; |
| 2819 | } | 3146 | } |
| 2820 | 3147 | ||
| 2821 | if (!iexec->execute) | 3148 | if (!iexec->execute) |
| @@ -2830,7 +3157,7 @@ init_gpio(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
| 2830 | BIOSLOG(bios, "0x%04X: set gpio 0x%02x, state %d\n", | 3157 | BIOSLOG(bios, "0x%04X: set gpio 0x%02x, state %d\n", |
| 2831 | offset, gpio->tag, gpio->state_default); | 3158 | offset, gpio->tag, gpio->state_default); |
| 2832 | if (bios->execute) | 3159 | if (bios->execute) |
| 2833 | nv50_gpio_set(bios->dev, gpio->tag, gpio->state_default); | 3160 | pgpio->set(bios->dev, gpio->tag, gpio->state_default); |
| 2834 | 3161 | ||
| 2835 | /* The NVIDIA binary driver doesn't appear to actually do | 3162 | /* The NVIDIA binary driver doesn't appear to actually do |
| 2836 | * any of this, my VBIOS does however. | 3163 | * any of this, my VBIOS does however. |
| @@ -2887,10 +3214,7 @@ init_ram_restrict_zm_reg_group(struct nvbios *bios, uint16_t offset, | |||
| 2887 | uint8_t index; | 3214 | uint8_t index; |
| 2888 | int i; | 3215 | int i; |
| 2889 | 3216 | ||
| 2890 | 3217 | /* critical! to know the length of the opcode */; | |
| 2891 | if (!iexec->execute) | ||
| 2892 | return len; | ||
| 2893 | |||
| 2894 | if (!blocklen) { | 3218 | if (!blocklen) { |
| 2895 | NV_ERROR(bios->dev, | 3219 | NV_ERROR(bios->dev, |
| 2896 | "0x%04X: Zero block length - has the M table " | 3220 | "0x%04X: Zero block length - has the M table " |
| @@ -2898,6 +3222,9 @@ init_ram_restrict_zm_reg_group(struct nvbios *bios, uint16_t offset, | |||
| 2898 | return -EINVAL; | 3222 | return -EINVAL; |
| 2899 | } | 3223 | } |
| 2900 | 3224 | ||
| 3225 | if (!iexec->execute) | ||
| 3226 | return len; | ||
| 3227 | |||
| 2901 | strap_ramcfg = (bios_rd32(bios, NV_PEXTDEV_BOOT_0) >> 2) & 0xf; | 3228 | strap_ramcfg = (bios_rd32(bios, NV_PEXTDEV_BOOT_0) >> 2) & 0xf; |
| 2902 | index = bios->data[bios->ram_restrict_tbl_ptr + strap_ramcfg]; | 3229 | index = bios->data[bios->ram_restrict_tbl_ptr + strap_ramcfg]; |
| 2903 | 3230 | ||
| @@ -3079,14 +3406,14 @@ init_auxch(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
| 3079 | 3406 | ||
| 3080 | if (!bios->display.output) { | 3407 | if (!bios->display.output) { |
| 3081 | NV_ERROR(dev, "INIT_AUXCH: no active output\n"); | 3408 | NV_ERROR(dev, "INIT_AUXCH: no active output\n"); |
| 3082 | return -EINVAL; | 3409 | return len; |
| 3083 | } | 3410 | } |
| 3084 | 3411 | ||
| 3085 | auxch = init_i2c_device_find(dev, bios->display.output->i2c_index); | 3412 | auxch = init_i2c_device_find(dev, bios->display.output->i2c_index); |
| 3086 | if (!auxch) { | 3413 | if (!auxch) { |
| 3087 | NV_ERROR(dev, "INIT_AUXCH: couldn't get auxch %d\n", | 3414 | NV_ERROR(dev, "INIT_AUXCH: couldn't get auxch %d\n", |
| 3088 | bios->display.output->i2c_index); | 3415 | bios->display.output->i2c_index); |
| 3089 | return -ENODEV; | 3416 | return len; |
| 3090 | } | 3417 | } |
| 3091 | 3418 | ||
| 3092 | if (!iexec->execute) | 3419 | if (!iexec->execute) |
| @@ -3099,7 +3426,7 @@ init_auxch(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
| 3099 | ret = nouveau_dp_auxch(auxch, 9, addr, &data, 1); | 3426 | ret = nouveau_dp_auxch(auxch, 9, addr, &data, 1); |
| 3100 | if (ret) { | 3427 | if (ret) { |
| 3101 | NV_ERROR(dev, "INIT_AUXCH: rd auxch fail %d\n", ret); | 3428 | NV_ERROR(dev, "INIT_AUXCH: rd auxch fail %d\n", ret); |
| 3102 | return ret; | 3429 | return len; |
| 3103 | } | 3430 | } |
| 3104 | 3431 | ||
| 3105 | data &= bios->data[offset + 0]; | 3432 | data &= bios->data[offset + 0]; |
| @@ -3108,7 +3435,7 @@ init_auxch(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
| 3108 | ret = nouveau_dp_auxch(auxch, 8, addr, &data, 1); | 3435 | ret = nouveau_dp_auxch(auxch, 8, addr, &data, 1); |
| 3109 | if (ret) { | 3436 | if (ret) { |
| 3110 | NV_ERROR(dev, "INIT_AUXCH: wr auxch fail %d\n", ret); | 3437 | NV_ERROR(dev, "INIT_AUXCH: wr auxch fail %d\n", ret); |
| 3111 | return ret; | 3438 | return len; |
| 3112 | } | 3439 | } |
| 3113 | } | 3440 | } |
| 3114 | 3441 | ||
| @@ -3138,14 +3465,14 @@ init_zm_auxch(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
| 3138 | 3465 | ||
| 3139 | if (!bios->display.output) { | 3466 | if (!bios->display.output) { |
| 3140 | NV_ERROR(dev, "INIT_ZM_AUXCH: no active output\n"); | 3467 | NV_ERROR(dev, "INIT_ZM_AUXCH: no active output\n"); |
| 3141 | return -EINVAL; | 3468 | return len; |
| 3142 | } | 3469 | } |
| 3143 | 3470 | ||
| 3144 | auxch = init_i2c_device_find(dev, bios->display.output->i2c_index); | 3471 | auxch = init_i2c_device_find(dev, bios->display.output->i2c_index); |
| 3145 | if (!auxch) { | 3472 | if (!auxch) { |
| 3146 | NV_ERROR(dev, "INIT_ZM_AUXCH: couldn't get auxch %d\n", | 3473 | NV_ERROR(dev, "INIT_ZM_AUXCH: couldn't get auxch %d\n", |
| 3147 | bios->display.output->i2c_index); | 3474 | bios->display.output->i2c_index); |
| 3148 | return -ENODEV; | 3475 | return len; |
| 3149 | } | 3476 | } |
| 3150 | 3477 | ||
| 3151 | if (!iexec->execute) | 3478 | if (!iexec->execute) |
| @@ -3156,7 +3483,7 @@ init_zm_auxch(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
| 3156 | ret = nouveau_dp_auxch(auxch, 8, addr, &bios->data[offset], 1); | 3483 | ret = nouveau_dp_auxch(auxch, 8, addr, &bios->data[offset], 1); |
| 3157 | if (ret) { | 3484 | if (ret) { |
| 3158 | NV_ERROR(dev, "INIT_ZM_AUXCH: wr auxch fail %d\n", ret); | 3485 | NV_ERROR(dev, "INIT_ZM_AUXCH: wr auxch fail %d\n", ret); |
| 3159 | return ret; | 3486 | return len; |
| 3160 | } | 3487 | } |
| 3161 | } | 3488 | } |
| 3162 | 3489 | ||
| @@ -5166,10 +5493,14 @@ static int parse_bmp_structure(struct drm_device *dev, struct nvbios *bios, unsi | |||
| 5166 | bios->legacy.i2c_indices.crt = bios->data[legacy_i2c_offset]; | 5493 | bios->legacy.i2c_indices.crt = bios->data[legacy_i2c_offset]; |
| 5167 | bios->legacy.i2c_indices.tv = bios->data[legacy_i2c_offset + 1]; | 5494 | bios->legacy.i2c_indices.tv = bios->data[legacy_i2c_offset + 1]; |
| 5168 | bios->legacy.i2c_indices.panel = bios->data[legacy_i2c_offset + 2]; | 5495 | bios->legacy.i2c_indices.panel = bios->data[legacy_i2c_offset + 2]; |
| 5169 | bios->dcb.i2c[0].write = bios->data[legacy_i2c_offset + 4]; | 5496 | if (bios->data[legacy_i2c_offset + 4]) |
| 5170 | bios->dcb.i2c[0].read = bios->data[legacy_i2c_offset + 5]; | 5497 | bios->dcb.i2c[0].write = bios->data[legacy_i2c_offset + 4]; |
| 5171 | bios->dcb.i2c[1].write = bios->data[legacy_i2c_offset + 6]; | 5498 | if (bios->data[legacy_i2c_offset + 5]) |
| 5172 | bios->dcb.i2c[1].read = bios->data[legacy_i2c_offset + 7]; | 5499 | bios->dcb.i2c[0].read = bios->data[legacy_i2c_offset + 5]; |
| 5500 | if (bios->data[legacy_i2c_offset + 6]) | ||
| 5501 | bios->dcb.i2c[1].write = bios->data[legacy_i2c_offset + 6]; | ||
| 5502 | if (bios->data[legacy_i2c_offset + 7]) | ||
| 5503 | bios->dcb.i2c[1].read = bios->data[legacy_i2c_offset + 7]; | ||
| 5173 | 5504 | ||
| 5174 | if (bmplength > 74) { | 5505 | if (bmplength > 74) { |
| 5175 | bios->fmaxvco = ROM32(bmp[67]); | 5506 | bios->fmaxvco = ROM32(bmp[67]); |
| @@ -5604,9 +5935,12 @@ parse_dcb20_entry(struct drm_device *dev, struct dcb_table *dcb, | |||
| 5604 | if (conf & 0x4 || conf & 0x8) | 5935 | if (conf & 0x4 || conf & 0x8) |
| 5605 | entry->lvdsconf.use_power_scripts = true; | 5936 | entry->lvdsconf.use_power_scripts = true; |
| 5606 | } else { | 5937 | } else { |
| 5607 | mask = ~0x5; | 5938 | mask = ~0x7; |
| 5939 | if (conf & 0x2) | ||
| 5940 | entry->lvdsconf.use_acpi_for_edid = true; | ||
| 5608 | if (conf & 0x4) | 5941 | if (conf & 0x4) |
| 5609 | entry->lvdsconf.use_power_scripts = true; | 5942 | entry->lvdsconf.use_power_scripts = true; |
| 5943 | entry->lvdsconf.sor.link = (conf & 0x00000030) >> 4; | ||
| 5610 | } | 5944 | } |
| 5611 | if (conf & mask) { | 5945 | if (conf & mask) { |
| 5612 | /* | 5946 | /* |
| @@ -5721,13 +6055,6 @@ parse_dcb15_entry(struct drm_device *dev, struct dcb_table *dcb, | |||
| 5721 | case OUTPUT_TV: | 6055 | case OUTPUT_TV: |
| 5722 | entry->tvconf.has_component_output = false; | 6056 | entry->tvconf.has_component_output = false; |
| 5723 | break; | 6057 | break; |
| 5724 | case OUTPUT_TMDS: | ||
| 5725 | /* | ||
| 5726 | * Invent a DVI-A output, by copying the fields of the DVI-D | ||
| 5727 | * output; reported to work by math_b on an NV20(!). | ||
| 5728 | */ | ||
| 5729 | fabricate_vga_output(dcb, entry->i2c_index, entry->heads); | ||
| 5730 | break; | ||
| 5731 | case OUTPUT_LVDS: | 6058 | case OUTPUT_LVDS: |
| 5732 | if ((conn & 0x00003f00) != 0x10) | 6059 | if ((conn & 0x00003f00) != 0x10) |
| 5733 | entry->lvdsconf.use_straps_for_mode = true; | 6060 | entry->lvdsconf.use_straps_for_mode = true; |
| @@ -5808,6 +6135,31 @@ void merge_like_dcb_entries(struct drm_device *dev, struct dcb_table *dcb) | |||
| 5808 | dcb->entries = newentries; | 6135 | dcb->entries = newentries; |
| 5809 | } | 6136 | } |
| 5810 | 6137 | ||
| 6138 | static bool | ||
| 6139 | apply_dcb_encoder_quirks(struct drm_device *dev, int idx, u32 *conn, u32 *conf) | ||
| 6140 | { | ||
| 6141 | /* Dell Precision M6300 | ||
| 6142 | * DCB entry 2: 02025312 00000010 | ||
| 6143 | * DCB entry 3: 02026312 00000020 | ||
| 6144 | * | ||
| 6145 | * Identical, except apparently a different connector on a | ||
| 6146 | * different SOR link. Not a clue how we're supposed to know | ||
| 6147 | * which one is in use if it even shares an i2c line... | ||
| 6148 | * | ||
| 6149 | * Ignore the connector on the second SOR link to prevent | ||
| 6150 | * nasty problems until this is sorted (assuming it's not a | ||
| 6151 | * VBIOS bug). | ||
| 6152 | */ | ||
| 6153 | if ((dev->pdev->device == 0x040d) && | ||
| 6154 | (dev->pdev->subsystem_vendor == 0x1028) && | ||
| 6155 | (dev->pdev->subsystem_device == 0x019b)) { | ||
| 6156 | if (*conn == 0x02026312 && *conf == 0x00000020) | ||
| 6157 | return false; | ||
| 6158 | } | ||
| 6159 | |||
| 6160 | return true; | ||
| 6161 | } | ||
| 6162 | |||
| 5811 | static int | 6163 | static int |
| 5812 | parse_dcb_table(struct drm_device *dev, struct nvbios *bios, bool twoHeads) | 6164 | parse_dcb_table(struct drm_device *dev, struct nvbios *bios, bool twoHeads) |
| 5813 | { | 6165 | { |
| @@ -5941,6 +6293,9 @@ parse_dcb_table(struct drm_device *dev, struct nvbios *bios, bool twoHeads) | |||
| 5941 | if ((connection & 0x0000000f) == 0x0000000f) | 6293 | if ((connection & 0x0000000f) == 0x0000000f) |
| 5942 | continue; | 6294 | continue; |
| 5943 | 6295 | ||
| 6296 | if (!apply_dcb_encoder_quirks(dev, i, &connection, &config)) | ||
| 6297 | continue; | ||
| 6298 | |||
| 5944 | NV_TRACEWARN(dev, "Raw DCB entry %d: %08x %08x\n", | 6299 | NV_TRACEWARN(dev, "Raw DCB entry %d: %08x %08x\n", |
| 5945 | dcb->entries, connection, config); | 6300 | dcb->entries, connection, config); |
| 5946 | 6301 | ||
| @@ -6196,9 +6551,8 @@ nouveau_run_vbios_init(struct drm_device *dev) | |||
| 6196 | struct nvbios *bios = &dev_priv->vbios; | 6551 | struct nvbios *bios = &dev_priv->vbios; |
| 6197 | int i, ret = 0; | 6552 | int i, ret = 0; |
| 6198 | 6553 | ||
| 6199 | NVLockVgaCrtcs(dev, false); | 6554 | /* Reset the BIOS head to 0. */ |
| 6200 | if (nv_two_heads(dev)) | 6555 | bios->state.crtchead = 0; |
| 6201 | NVSetOwner(dev, bios->state.crtchead); | ||
| 6202 | 6556 | ||
| 6203 | if (bios->major_version < 5) /* BMP only */ | 6557 | if (bios->major_version < 5) /* BMP only */ |
| 6204 | load_nv17_hw_sequencer_ucode(dev, bios); | 6558 | load_nv17_hw_sequencer_ucode(dev, bios); |
| @@ -6231,8 +6585,6 @@ nouveau_run_vbios_init(struct drm_device *dev) | |||
| 6231 | } | 6585 | } |
| 6232 | } | 6586 | } |
| 6233 | 6587 | ||
| 6234 | NVLockVgaCrtcs(dev, true); | ||
| 6235 | |||
| 6236 | return ret; | 6588 | return ret; |
| 6237 | } | 6589 | } |
| 6238 | 6590 | ||
| @@ -6253,7 +6605,6 @@ static bool | |||
| 6253 | nouveau_bios_posted(struct drm_device *dev) | 6605 | nouveau_bios_posted(struct drm_device *dev) |
| 6254 | { | 6606 | { |
| 6255 | struct drm_nouveau_private *dev_priv = dev->dev_private; | 6607 | struct drm_nouveau_private *dev_priv = dev->dev_private; |
| 6256 | bool was_locked; | ||
| 6257 | unsigned htotal; | 6608 | unsigned htotal; |
| 6258 | 6609 | ||
| 6259 | if (dev_priv->chipset >= NV_50) { | 6610 | if (dev_priv->chipset >= NV_50) { |
| @@ -6263,13 +6614,12 @@ nouveau_bios_posted(struct drm_device *dev) | |||
| 6263 | return true; | 6614 | return true; |
| 6264 | } | 6615 | } |
| 6265 | 6616 | ||
| 6266 | was_locked = NVLockVgaCrtcs(dev, false); | ||
| 6267 | htotal = NVReadVgaCrtc(dev, 0, 0x06); | 6617 | htotal = NVReadVgaCrtc(dev, 0, 0x06); |
| 6268 | htotal |= (NVReadVgaCrtc(dev, 0, 0x07) & 0x01) << 8; | 6618 | htotal |= (NVReadVgaCrtc(dev, 0, 0x07) & 0x01) << 8; |
| 6269 | htotal |= (NVReadVgaCrtc(dev, 0, 0x07) & 0x20) << 4; | 6619 | htotal |= (NVReadVgaCrtc(dev, 0, 0x07) & 0x20) << 4; |
| 6270 | htotal |= (NVReadVgaCrtc(dev, 0, 0x25) & 0x01) << 10; | 6620 | htotal |= (NVReadVgaCrtc(dev, 0, 0x25) & 0x01) << 10; |
| 6271 | htotal |= (NVReadVgaCrtc(dev, 0, 0x41) & 0x01) << 11; | 6621 | htotal |= (NVReadVgaCrtc(dev, 0, 0x41) & 0x01) << 11; |
| 6272 | NVLockVgaCrtcs(dev, was_locked); | 6622 | |
| 6273 | return (htotal != 0); | 6623 | return (htotal != 0); |
| 6274 | } | 6624 | } |
| 6275 | 6625 | ||
| @@ -6278,8 +6628,6 @@ nouveau_bios_init(struct drm_device *dev) | |||
| 6278 | { | 6628 | { |
| 6279 | struct drm_nouveau_private *dev_priv = dev->dev_private; | 6629 | struct drm_nouveau_private *dev_priv = dev->dev_private; |
| 6280 | struct nvbios *bios = &dev_priv->vbios; | 6630 | struct nvbios *bios = &dev_priv->vbios; |
| 6281 | uint32_t saved_nv_pextdev_boot_0; | ||
| 6282 | bool was_locked; | ||
| 6283 | int ret; | 6631 | int ret; |
| 6284 | 6632 | ||
| 6285 | if (!NVInitVBIOS(dev)) | 6633 | if (!NVInitVBIOS(dev)) |
| @@ -6299,40 +6647,27 @@ nouveau_bios_init(struct drm_device *dev) | |||
| 6299 | if (!bios->major_version) /* we don't run version 0 bios */ | 6647 | if (!bios->major_version) /* we don't run version 0 bios */ |
| 6300 | return 0; | 6648 | return 0; |
| 6301 | 6649 | ||
| 6302 | /* these will need remembering across a suspend */ | ||
| 6303 | saved_nv_pextdev_boot_0 = bios_rd32(bios, NV_PEXTDEV_BOOT_0); | ||
| 6304 | bios->state.saved_nv_pfb_cfg0 = bios_rd32(bios, NV_PFB_CFG0); | ||
| 6305 | |||
| 6306 | /* init script execution disabled */ | 6650 | /* init script execution disabled */ |
| 6307 | bios->execute = false; | 6651 | bios->execute = false; |
| 6308 | 6652 | ||
| 6309 | /* ... unless card isn't POSTed already */ | 6653 | /* ... unless card isn't POSTed already */ |
| 6310 | if (!nouveau_bios_posted(dev)) { | 6654 | if (!nouveau_bios_posted(dev)) { |
| 6311 | NV_INFO(dev, "Adaptor not initialised\n"); | 6655 | NV_INFO(dev, "Adaptor not initialised, " |
| 6312 | if (dev_priv->card_type < NV_40) { | 6656 | "running VBIOS init tables.\n"); |
| 6313 | NV_ERROR(dev, "Unable to POST this chipset\n"); | ||
| 6314 | return -ENODEV; | ||
| 6315 | } | ||
| 6316 | |||
| 6317 | NV_INFO(dev, "Running VBIOS init tables\n"); | ||
| 6318 | bios->execute = true; | 6657 | bios->execute = true; |
| 6319 | } | 6658 | } |
| 6320 | 6659 | ||
| 6321 | bios_wr32(bios, NV_PEXTDEV_BOOT_0, saved_nv_pextdev_boot_0); | ||
| 6322 | |||
| 6323 | ret = nouveau_run_vbios_init(dev); | 6660 | ret = nouveau_run_vbios_init(dev); |
| 6324 | if (ret) | 6661 | if (ret) |
| 6325 | return ret; | 6662 | return ret; |
| 6326 | 6663 | ||
| 6327 | /* feature_byte on BMP is poor, but init always sets CR4B */ | 6664 | /* feature_byte on BMP is poor, but init always sets CR4B */ |
| 6328 | was_locked = NVLockVgaCrtcs(dev, false); | ||
| 6329 | if (bios->major_version < 5) | 6665 | if (bios->major_version < 5) |
| 6330 | bios->is_mobile = NVReadVgaCrtc(dev, 0, NV_CIO_CRE_4B) & 0x40; | 6666 | bios->is_mobile = NVReadVgaCrtc(dev, 0, NV_CIO_CRE_4B) & 0x40; |
| 6331 | 6667 | ||
| 6332 | /* all BIT systems need p_f_m_t for digital_min_front_porch */ | 6668 | /* all BIT systems need p_f_m_t for digital_min_front_porch */ |
| 6333 | if (bios->is_mobile || bios->major_version >= 5) | 6669 | if (bios->is_mobile || bios->major_version >= 5) |
| 6334 | ret = parse_fp_mode_table(dev, bios); | 6670 | ret = parse_fp_mode_table(dev, bios); |
| 6335 | NVLockVgaCrtcs(dev, was_locked); | ||
| 6336 | 6671 | ||
| 6337 | /* allow subsequent scripts to execute */ | 6672 | /* allow subsequent scripts to execute */ |
| 6338 | bios->execute = true; | 6673 | bios->execute = true; |
