diff options
author | Ben Skeggs <bskeggs@redhat.com> | 2012-07-10 00:36:38 -0400 |
---|---|---|
committer | Ben Skeggs <bskeggs@redhat.com> | 2012-10-02 23:12:46 -0400 |
commit | 4196faa8623264b79279a06fd186654c959f2767 (patch) | |
tree | d84bb1e28744a3dfbafc1e9203a2ea1fda43eb86 /drivers/gpu/drm/nouveau/nouveau_bios.c | |
parent | e0996aea4c349ba302b63203b7d5cab6034dbdca (diff) |
drm/nouveau/i2c: port to subdev interfaces
v2/v3: Ben Skeggs <bskeggs@redhat.com>
- fix typo in default bus selection
- fix accidental loss of destructor
v4: Dmitry Eremin-Solenikov <dmitry_eremin@mentor.com>
- fix typo causing incorrect default i2c port settings when no BMP data
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/nouveau/nouveau_bios.c')
-rw-r--r-- | drivers/gpu/drm/nouveau/nouveau_bios.c | 49 |
1 files changed, 21 insertions, 28 deletions
diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.c b/drivers/gpu/drm/nouveau/nouveau_bios.c index 4f0d9bd1914b..35b0a8f9c008 100644 --- a/drivers/gpu/drm/nouveau/nouveau_bios.c +++ b/drivers/gpu/drm/nouveau/nouveau_bios.c | |||
@@ -528,7 +528,7 @@ static int dcb_entry_idx_from_crtchead(struct drm_device *dev) | |||
528 | return dcb_entry; | 528 | return dcb_entry; |
529 | } | 529 | } |
530 | 530 | ||
531 | static struct nouveau_i2c_chan * | 531 | static struct nouveau_i2c_port * |
532 | init_i2c_device_find(struct drm_device *dev, int i2c_index) | 532 | init_i2c_device_find(struct drm_device *dev, int i2c_index) |
533 | { | 533 | { |
534 | if (i2c_index == 0xff) { | 534 | if (i2c_index == 0xff) { |
@@ -537,9 +537,9 @@ init_i2c_device_find(struct drm_device *dev, int i2c_index) | |||
537 | /* note: dcb_entry_idx_from_crtchead needs pre-script set-up */ | 537 | /* note: dcb_entry_idx_from_crtchead needs pre-script set-up */ |
538 | int idx = dcb_entry_idx_from_crtchead(dev); | 538 | int idx = dcb_entry_idx_from_crtchead(dev); |
539 | 539 | ||
540 | i2c_index = NV_I2C_DEFAULT(0); | 540 | i2c_index = 0x80; //NV_I2C_DEFAULT(0); |
541 | if (idx != 0x7f && dcb->entry[idx].i2c_upper_default) | 541 | if (idx != 0x7f && dcb->entry[idx].i2c_upper_default) |
542 | i2c_index = NV_I2C_DEFAULT(1); | 542 | i2c_index = 0x81; //NV_I2C_DEFAULT(1); |
543 | } | 543 | } |
544 | 544 | ||
545 | return nouveau_i2c_find(dev, i2c_index); | 545 | return nouveau_i2c_find(dev, i2c_index); |
@@ -920,7 +920,7 @@ init_dp_condition(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
920 | break; | 920 | break; |
921 | case 5: | 921 | case 5: |
922 | { | 922 | { |
923 | struct nouveau_i2c_chan *auxch; | 923 | struct nouveau_i2c_port *auxch; |
924 | int ret; | 924 | int ret; |
925 | 925 | ||
926 | auxch = nouveau_i2c_find(dev, bios->display.output->i2c_index); | 926 | auxch = nouveau_i2c_find(dev, bios->display.output->i2c_index); |
@@ -929,7 +929,7 @@ init_dp_condition(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
929 | return 3; | 929 | return 3; |
930 | } | 930 | } |
931 | 931 | ||
932 | ret = nouveau_dp_auxch(auxch, 9, 0xd, &cond, 1); | 932 | ret = auxch_rd(dev, auxch, 0xd, &cond, 1); |
933 | if (ret) { | 933 | if (ret) { |
934 | NV_ERROR(dev, "0x%04X: auxch rd fail: %d\n", offset, ret); | 934 | NV_ERROR(dev, "0x%04X: auxch rd fail: %d\n", offset, ret); |
935 | return 3; | 935 | return 3; |
@@ -1166,7 +1166,7 @@ init_i2c_byte(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
1166 | uint8_t i2c_index = bios->data[offset + 1]; | 1166 | uint8_t i2c_index = bios->data[offset + 1]; |
1167 | uint8_t i2c_address = bios->data[offset + 2] >> 1; | 1167 | uint8_t i2c_address = bios->data[offset + 2] >> 1; |
1168 | uint8_t count = bios->data[offset + 3]; | 1168 | uint8_t count = bios->data[offset + 3]; |
1169 | struct nouveau_i2c_chan *chan; | 1169 | struct nouveau_i2c_port *chan; |
1170 | int len = 4 + count * 3; | 1170 | int len = 4 + count * 3; |
1171 | int ret, i; | 1171 | int ret, i; |
1172 | 1172 | ||
@@ -1189,7 +1189,7 @@ init_i2c_byte(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
1189 | uint8_t data = bios->data[offset + 6 + i * 3]; | 1189 | uint8_t data = bios->data[offset + 6 + i * 3]; |
1190 | union i2c_smbus_data val; | 1190 | union i2c_smbus_data val; |
1191 | 1191 | ||
1192 | ret = i2c_smbus_xfer(&chan->adapter, i2c_address, 0, | 1192 | ret = i2c_smbus_xfer(nouveau_i2c_adapter(chan), i2c_address, 0, |
1193 | I2C_SMBUS_READ, reg, | 1193 | I2C_SMBUS_READ, reg, |
1194 | I2C_SMBUS_BYTE_DATA, &val); | 1194 | I2C_SMBUS_BYTE_DATA, &val); |
1195 | if (ret < 0) { | 1195 | if (ret < 0) { |
@@ -1206,7 +1206,7 @@ init_i2c_byte(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
1206 | 1206 | ||
1207 | val.byte &= mask; | 1207 | val.byte &= mask; |
1208 | val.byte |= data; | 1208 | val.byte |= data; |
1209 | ret = i2c_smbus_xfer(&chan->adapter, i2c_address, 0, | 1209 | ret = i2c_smbus_xfer(nouveau_i2c_adapter(chan), i2c_address, 0, |
1210 | I2C_SMBUS_WRITE, reg, | 1210 | I2C_SMBUS_WRITE, reg, |
1211 | I2C_SMBUS_BYTE_DATA, &val); | 1211 | I2C_SMBUS_BYTE_DATA, &val); |
1212 | if (ret < 0) { | 1212 | if (ret < 0) { |
@@ -1241,7 +1241,7 @@ init_zm_i2c_byte(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
1241 | uint8_t i2c_index = bios->data[offset + 1]; | 1241 | uint8_t i2c_index = bios->data[offset + 1]; |
1242 | uint8_t i2c_address = bios->data[offset + 2] >> 1; | 1242 | uint8_t i2c_address = bios->data[offset + 2] >> 1; |
1243 | uint8_t count = bios->data[offset + 3]; | 1243 | uint8_t count = bios->data[offset + 3]; |
1244 | struct nouveau_i2c_chan *chan; | 1244 | struct nouveau_i2c_port *chan; |
1245 | int len = 4 + count * 2; | 1245 | int len = 4 + count * 2; |
1246 | int ret, i; | 1246 | int ret, i; |
1247 | 1247 | ||
@@ -1270,7 +1270,7 @@ init_zm_i2c_byte(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
1270 | if (!bios->execute) | 1270 | if (!bios->execute) |
1271 | continue; | 1271 | continue; |
1272 | 1272 | ||
1273 | ret = i2c_smbus_xfer(&chan->adapter, i2c_address, 0, | 1273 | ret = i2c_smbus_xfer(nouveau_i2c_adapter(chan), i2c_address, 0, |
1274 | I2C_SMBUS_WRITE, reg, | 1274 | I2C_SMBUS_WRITE, reg, |
1275 | I2C_SMBUS_BYTE_DATA, &val); | 1275 | I2C_SMBUS_BYTE_DATA, &val); |
1276 | if (ret < 0) { | 1276 | if (ret < 0) { |
@@ -1304,7 +1304,7 @@ init_zm_i2c(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
1304 | uint8_t i2c_address = bios->data[offset + 2] >> 1; | 1304 | uint8_t i2c_address = bios->data[offset + 2] >> 1; |
1305 | uint8_t count = bios->data[offset + 3]; | 1305 | uint8_t count = bios->data[offset + 3]; |
1306 | int len = 4 + count; | 1306 | int len = 4 + count; |
1307 | struct nouveau_i2c_chan *chan; | 1307 | struct nouveau_i2c_port *chan; |
1308 | struct i2c_msg msg; | 1308 | struct i2c_msg msg; |
1309 | uint8_t data[256]; | 1309 | uint8_t data[256]; |
1310 | int ret, i; | 1310 | int ret, i; |
@@ -1333,7 +1333,7 @@ init_zm_i2c(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
1333 | msg.flags = 0; | 1333 | msg.flags = 0; |
1334 | msg.len = count; | 1334 | msg.len = count; |
1335 | msg.buf = data; | 1335 | msg.buf = data; |
1336 | ret = i2c_transfer(&chan->adapter, &msg, 1); | 1336 | ret = i2c_transfer(nouveau_i2c_adapter(chan), &msg, 1); |
1337 | if (ret != 1) { | 1337 | if (ret != 1) { |
1338 | NV_ERROR(dev, "0x%04X: i2c wr fail: %d\n", offset, ret); | 1338 | NV_ERROR(dev, "0x%04X: i2c wr fail: %d\n", offset, ret); |
1339 | return len; | 1339 | return len; |
@@ -1769,7 +1769,7 @@ init_i2c_if(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
1769 | uint8_t reg = bios->data[offset + 3]; | 1769 | uint8_t reg = bios->data[offset + 3]; |
1770 | uint8_t mask = bios->data[offset + 4]; | 1770 | uint8_t mask = bios->data[offset + 4]; |
1771 | uint8_t data = bios->data[offset + 5]; | 1771 | uint8_t data = bios->data[offset + 5]; |
1772 | struct nouveau_i2c_chan *chan; | 1772 | struct nouveau_i2c_port *chan; |
1773 | union i2c_smbus_data val; | 1773 | union i2c_smbus_data val; |
1774 | int ret; | 1774 | int ret; |
1775 | 1775 | ||
@@ -1782,7 +1782,7 @@ init_i2c_if(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
1782 | if (!chan) | 1782 | if (!chan) |
1783 | return -ENODEV; | 1783 | return -ENODEV; |
1784 | 1784 | ||
1785 | ret = i2c_smbus_xfer(&chan->adapter, i2c_address, 0, | 1785 | ret = i2c_smbus_xfer(nouveau_i2c_adapter(chan), i2c_address, 0, |
1786 | I2C_SMBUS_READ, reg, | 1786 | I2C_SMBUS_READ, reg, |
1787 | I2C_SMBUS_BYTE_DATA, &val); | 1787 | I2C_SMBUS_BYTE_DATA, &val); |
1788 | if (ret < 0) { | 1788 | if (ret < 0) { |
@@ -3167,7 +3167,7 @@ init_auxch(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
3167 | */ | 3167 | */ |
3168 | 3168 | ||
3169 | struct drm_device *dev = bios->dev; | 3169 | struct drm_device *dev = bios->dev; |
3170 | struct nouveau_i2c_chan *auxch; | 3170 | struct nouveau_i2c_port *auxch; |
3171 | uint32_t addr = ROM32(bios->data[offset + 1]); | 3171 | uint32_t addr = ROM32(bios->data[offset + 1]); |
3172 | uint8_t count = bios->data[offset + 5]; | 3172 | uint8_t count = bios->data[offset + 5]; |
3173 | int len = 6 + count * 2; | 3173 | int len = 6 + count * 2; |
@@ -3192,7 +3192,7 @@ init_auxch(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
3192 | for (i = 0; i < count; i++, offset += 2) { | 3192 | for (i = 0; i < count; i++, offset += 2) { |
3193 | uint8_t data; | 3193 | uint8_t data; |
3194 | 3194 | ||
3195 | ret = nouveau_dp_auxch(auxch, 9, addr, &data, 1); | 3195 | ret = auxch_rd(dev, auxch, addr, &data, 1); |
3196 | if (ret) { | 3196 | if (ret) { |
3197 | NV_ERROR(dev, "INIT_AUXCH: rd auxch fail %d\n", ret); | 3197 | NV_ERROR(dev, "INIT_AUXCH: rd auxch fail %d\n", ret); |
3198 | return len; | 3198 | return len; |
@@ -3201,7 +3201,7 @@ init_auxch(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
3201 | data &= bios->data[offset + 0]; | 3201 | data &= bios->data[offset + 0]; |
3202 | data |= bios->data[offset + 1]; | 3202 | data |= bios->data[offset + 1]; |
3203 | 3203 | ||
3204 | ret = nouveau_dp_auxch(auxch, 8, addr, &data, 1); | 3204 | ret = auxch_wr(dev, auxch, addr, &data, 1); |
3205 | if (ret) { | 3205 | if (ret) { |
3206 | NV_ERROR(dev, "INIT_AUXCH: wr auxch fail %d\n", ret); | 3206 | NV_ERROR(dev, "INIT_AUXCH: wr auxch fail %d\n", ret); |
3207 | return len; | 3207 | return len; |
@@ -3226,7 +3226,7 @@ init_zm_auxch(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
3226 | */ | 3226 | */ |
3227 | 3227 | ||
3228 | struct drm_device *dev = bios->dev; | 3228 | struct drm_device *dev = bios->dev; |
3229 | struct nouveau_i2c_chan *auxch; | 3229 | struct nouveau_i2c_port *auxch; |
3230 | uint32_t addr = ROM32(bios->data[offset + 1]); | 3230 | uint32_t addr = ROM32(bios->data[offset + 1]); |
3231 | uint8_t count = bios->data[offset + 5]; | 3231 | uint8_t count = bios->data[offset + 5]; |
3232 | int len = 6 + count; | 3232 | int len = 6 + count; |
@@ -3249,7 +3249,7 @@ init_zm_auxch(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
3249 | 3249 | ||
3250 | offset += 6; | 3250 | offset += 6; |
3251 | for (i = 0; i < count; i++, offset++) { | 3251 | for (i = 0; i < count; i++, offset++) { |
3252 | ret = nouveau_dp_auxch(auxch, 8, addr, &bios->data[offset], 1); | 3252 | ret = auxch_wr(dev, auxch, addr, &bios->data[offset], 1); |
3253 | if (ret) { | 3253 | if (ret) { |
3254 | NV_ERROR(dev, "INIT_ZM_AUXCH: wr auxch fail %d\n", ret); | 3254 | NV_ERROR(dev, "INIT_ZM_AUXCH: wr auxch fail %d\n", ret); |
3255 | return len; | 3255 | return len; |
@@ -3285,7 +3285,7 @@ init_i2c_long_if(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
3285 | uint8_t reghi = bios->data[offset + 4]; | 3285 | uint8_t reghi = bios->data[offset + 4]; |
3286 | uint8_t mask = bios->data[offset + 5]; | 3286 | uint8_t mask = bios->data[offset + 5]; |
3287 | uint8_t data = bios->data[offset + 6]; | 3287 | uint8_t data = bios->data[offset + 6]; |
3288 | struct nouveau_i2c_chan *chan; | 3288 | struct nouveau_i2c_port *chan; |
3289 | uint8_t buf0[2] = { reghi, reglo }; | 3289 | uint8_t buf0[2] = { reghi, reglo }; |
3290 | uint8_t buf1[1]; | 3290 | uint8_t buf1[1]; |
3291 | struct i2c_msg msg[2] = { | 3291 | struct i2c_msg msg[2] = { |
@@ -3304,7 +3304,7 @@ init_i2c_long_if(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) | |||
3304 | return -ENODEV; | 3304 | return -ENODEV; |
3305 | 3305 | ||
3306 | 3306 | ||
3307 | ret = i2c_transfer(&chan->adapter, msg, 2); | 3307 | ret = i2c_transfer(nouveau_i2c_adapter(chan), msg, 2); |
3308 | if (ret < 0) { | 3308 | if (ret < 0) { |
3309 | BIOSLOG(bios, "0x%04X: I2CReg: 0x%02X:0x%02X, Value: [no device], " | 3309 | BIOSLOG(bios, "0x%04X: I2CReg: 0x%02X:0x%02X, Value: [no device], " |
3310 | "Mask: 0x%02X, Data: 0x%02X\n", | 3310 | "Mask: 0x%02X, Data: 0x%02X\n", |
@@ -6270,10 +6270,6 @@ nouveau_bios_init(struct drm_device *dev) | |||
6270 | if (ret) | 6270 | if (ret) |
6271 | return ret; | 6271 | return ret; |
6272 | 6272 | ||
6273 | ret = nouveau_i2c_init(dev); | ||
6274 | if (ret) | ||
6275 | return ret; | ||
6276 | |||
6277 | ret = nouveau_mxm_init(dev); | 6273 | ret = nouveau_mxm_init(dev); |
6278 | if (ret) | 6274 | if (ret) |
6279 | return ret; | 6275 | return ret; |
@@ -6318,8 +6314,5 @@ nouveau_bios_init(struct drm_device *dev) | |||
6318 | void | 6314 | void |
6319 | nouveau_bios_takedown(struct drm_device *dev) | 6315 | nouveau_bios_takedown(struct drm_device *dev) |
6320 | { | 6316 | { |
6321 | struct drm_nouveau_private *dev_priv = dev->dev_private; | ||
6322 | |||
6323 | nouveau_mxm_fini(dev); | 6317 | nouveau_mxm_fini(dev); |
6324 | nouveau_i2c_fini(dev); | ||
6325 | } | 6318 | } |