107
109
return !!((nv_rd32(dev, i2c->rd) >> 16) & 8);
112
static const uint32_t nv50_i2c_port[] = {
113
0x00e138, 0x00e150, 0x00e168, 0x00e180,
114
0x00e254, 0x00e274, 0x00e764, 0x00e780,
117
#define NV50_I2C_PORTS ARRAY_SIZE(nv50_i2c_port)
111
120
nv50_i2c_getscl(void *data)
130
139
nv50_i2c_setscl(void *data, int state)
132
141
struct nouveau_i2c_chan *i2c = data;
133
struct drm_device *dev = i2c->dev;
135
nv_wr32(dev, i2c->wr, 4 | (i2c->data ? 2 : 0) | (state ? 1 : 0));
143
nv_wr32(i2c->dev, i2c->wr, 4 | (i2c->data ? 2 : 0) | (state ? 1 : 0));
139
147
nv50_i2c_setsda(void *data, int state)
141
149
struct nouveau_i2c_chan *i2c = data;
142
struct drm_device *dev = i2c->dev;
144
nv_wr32(dev, i2c->wr,
145
(nv_rd32(dev, i2c->rd) & 1) | 4 | (state ? 2 : 0));
151
nv_mask(i2c->dev, i2c->wr, 0x00000006, 4 | (state ? 2 : 0));
146
152
i2c->data = state;
149
static const uint32_t nv50_i2c_port[] = {
150
0x00e138, 0x00e150, 0x00e168, 0x00e180,
151
0x00e254, 0x00e274, 0x00e764, 0x00e780,
154
#define NV50_I2C_PORTS ARRAY_SIZE(nv50_i2c_port)
156
nvd0_i2c_getscl(void *data)
158
struct nouveau_i2c_chan *i2c = data;
159
return !!(nv_rd32(i2c->dev, i2c->rd) & 0x10);
163
nvd0_i2c_getsda(void *data)
165
struct nouveau_i2c_chan *i2c = data;
166
return !!(nv_rd32(i2c->dev, i2c->rd) & 0x20);
157
170
nouveau_i2c_init(struct drm_device *dev, struct dcb_i2c_entry *entry, int index)
166
if (dev_priv->card_type >= NV_50 && entry->read >= NV50_I2C_PORTS) {
179
if (dev_priv->card_type >= NV_50 &&
180
dev_priv->card_type <= NV_C0 && entry->read >= NV50_I2C_PORTS) {
167
181
NV_ERROR(dev, "unknown i2c port %d\n", entry->read);
193
207
i2c->bit.setsda = nv50_i2c_setsda;
194
208
i2c->bit.setscl = nv50_i2c_setscl;
195
i2c->bit.getsda = nv50_i2c_getsda;
196
i2c->bit.getscl = nv50_i2c_getscl;
197
i2c->rd = nv50_i2c_port[entry->read];
209
if (dev_priv->card_type < NV_D0) {
210
i2c->bit.getsda = nv50_i2c_getsda;
211
i2c->bit.getscl = nv50_i2c_getscl;
212
i2c->rd = nv50_i2c_port[entry->read];
215
i2c->bit.getsda = nvd0_i2c_getsda;
216
i2c->bit.getscl = nvd0_i2c_getscl;
217
i2c->rd = 0x00d014 + (entry->read * 0x20);
201
222
i2c->rd = entry->read;
270
nv_wr32(dev, reg, (nv_rd32(dev, reg) & ~0xf003) | val);
291
/* nfi, but neither auxch or i2c work if it's 1 */
292
nv_mask(dev, reg + 0x0c, 0x00000001, 0x00000000);
293
/* nfi, but switches auxch vs normal i2c */
294
nv_mask(dev, reg + 0x00, 0x0000f003, val);
273
297
if (!i2c->chan && nouveau_i2c_init(dev, i2c, index))
310
334
NV_DEBUG(dev, "Probing %ss on I2C bus: %d\n", what, index);
312
for (i = 0; info[i].addr; i++) {
336
for (i = 0; i2c && info[i].addr; i++) {
313
337
if (nouveau_probe_i2c_addr(i2c, info[i].addr) &&
314
338
(!match || match(i2c, &info[i]))) {
315
339
NV_INFO(dev, "Detected %s: %s\n", what, info[i].type);