base.c 63.6 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
static const struct nvkm_device_chip
null_chipset = {
	.name = "NULL",
73
	.bios = nvkm_bios_new,
74 75 76 77 78
};

static const struct nvkm_device_chip
nv4_chipset = {
	.name = "NV04",
79
	.bios = nvkm_bios_new,
80
	.bus = nv04_bus_new,
81
	.clk = nv04_clk_new,
82
	.devinit = nv04_devinit_new,
83
	.fb = nv04_fb_new,
84
	.i2c = nv04_i2c_new,
85
	.imem = nv04_instmem_new,
86
	.mc = nv04_mc_new,
87
	.mmu = nv04_mmu_new,
88
	.timer = nv04_timer_new,
89
	.disp = nv04_disp_new,
90
	.dma = nv04_dma_new,
91
	.fifo = nv04_fifo_new,
92
	.gr = nv04_gr_new,
93 94 95 96 97 98
//	.sw = nv04_sw_new,
};

static const struct nvkm_device_chip
nv5_chipset = {
	.name = "NV05",
99
	.bios = nvkm_bios_new,
100
	.bus = nv04_bus_new,
101
	.clk = nv04_clk_new,
102
	.devinit = nv05_devinit_new,
103
	.fb = nv04_fb_new,
104
	.i2c = nv04_i2c_new,
105
	.imem = nv04_instmem_new,
106
	.mc = nv04_mc_new,
107
	.mmu = nv04_mmu_new,
108
	.timer = nv04_timer_new,
109
	.disp = nv04_disp_new,
110
	.dma = nv04_dma_new,
111
	.fifo = nv04_fifo_new,
112
	.gr = nv04_gr_new,
113 114 115 116 117 118
//	.sw = nv04_sw_new,
};

static const struct nvkm_device_chip
nv10_chipset = {
	.name = "NV10",
119
	.bios = nvkm_bios_new,
120
	.bus = nv04_bus_new,
121
	.clk = nv04_clk_new,
122
	.devinit = nv10_devinit_new,
123
	.fb = nv10_fb_new,
124
	.gpio = nv10_gpio_new,
125
	.i2c = nv04_i2c_new,
126
	.imem = nv04_instmem_new,
127
	.mc = nv04_mc_new,
128
	.mmu = nv04_mmu_new,
129
	.timer = nv04_timer_new,
130
	.disp = nv04_disp_new,
131
	.dma = nv04_dma_new,
132
	.gr = nv10_gr_new,
133 134 135 136 137
};

static const struct nvkm_device_chip
nv11_chipset = {
	.name = "NV11",
138
	.bios = nvkm_bios_new,
139
	.bus = nv04_bus_new,
140
	.clk = nv04_clk_new,
141
	.devinit = nv10_devinit_new,
142
	.fb = nv10_fb_new,
143
	.gpio = nv10_gpio_new,
144
	.i2c = nv04_i2c_new,
145
	.imem = nv04_instmem_new,
146
	.mc = nv04_mc_new,
147
	.mmu = nv04_mmu_new,
148
	.timer = nv04_timer_new,
149
	.disp = nv04_disp_new,
150
	.dma = nv04_dma_new,
151
	.fifo = nv10_fifo_new,
152
	.gr = nv15_gr_new,
153 154 155 156 157 158
//	.sw = nv10_sw_new,
};

static const struct nvkm_device_chip
nv15_chipset = {
	.name = "NV15",
159
	.bios = nvkm_bios_new,
160
	.bus = nv04_bus_new,
161
	.clk = nv04_clk_new,
162
	.devinit = nv10_devinit_new,
163
	.fb = nv10_fb_new,
164
	.gpio = nv10_gpio_new,
165
	.i2c = nv04_i2c_new,
166
	.imem = nv04_instmem_new,
167
	.mc = nv04_mc_new,
168
	.mmu = nv04_mmu_new,
169
	.timer = nv04_timer_new,
170
	.disp = nv04_disp_new,
171
	.dma = nv04_dma_new,
172
	.fifo = nv10_fifo_new,
173
	.gr = nv15_gr_new,
174 175 176 177 178 179
//	.sw = nv10_sw_new,
};

static const struct nvkm_device_chip
nv17_chipset = {
	.name = "NV17",
180
	.bios = nvkm_bios_new,
181
	.bus = nv04_bus_new,
182
	.clk = nv04_clk_new,
183
	.devinit = nv10_devinit_new,
184
	.fb = nv10_fb_new,
185
	.gpio = nv10_gpio_new,
186
	.i2c = nv04_i2c_new,
187
	.imem = nv04_instmem_new,
188
	.mc = nv04_mc_new,
189
	.mmu = nv04_mmu_new,
190
	.timer = nv04_timer_new,
191
	.disp = nv04_disp_new,
192
	.dma = nv04_dma_new,
193
	.fifo = nv17_fifo_new,
194
	.gr = nv17_gr_new,
195 196 197 198 199 200
//	.sw = nv10_sw_new,
};

static const struct nvkm_device_chip
nv18_chipset = {
	.name = "NV18",
201
	.bios = nvkm_bios_new,
202
	.bus = nv04_bus_new,
203
	.clk = nv04_clk_new,
204
	.devinit = nv10_devinit_new,
205
	.fb = nv10_fb_new,
206
	.gpio = nv10_gpio_new,
207
	.i2c = nv04_i2c_new,
208
	.imem = nv04_instmem_new,
209
	.mc = nv04_mc_new,
210
	.mmu = nv04_mmu_new,
211
	.timer = nv04_timer_new,
212
	.disp = nv04_disp_new,
213
	.dma = nv04_dma_new,
214
	.fifo = nv17_fifo_new,
215
	.gr = nv17_gr_new,
216 217 218 219 220 221
//	.sw = nv10_sw_new,
};

static const struct nvkm_device_chip
nv1a_chipset = {
	.name = "nForce",
222
	.bios = nvkm_bios_new,
223
	.bus = nv04_bus_new,
224
	.clk = nv04_clk_new,
225
	.devinit = nv1a_devinit_new,
226
	.fb = nv1a_fb_new,
227
	.gpio = nv10_gpio_new,
228
	.i2c = nv04_i2c_new,
229
	.imem = nv04_instmem_new,
230
	.mc = nv04_mc_new,
231
	.mmu = nv04_mmu_new,
232
	.timer = nv04_timer_new,
233
	.disp = nv04_disp_new,
234
	.dma = nv04_dma_new,
235
	.fifo = nv10_fifo_new,
236
	.gr = nv15_gr_new,
237 238 239 240 241 242
//	.sw = nv10_sw_new,
};

static const struct nvkm_device_chip
nv1f_chipset = {
	.name = "nForce2",
243
	.bios = nvkm_bios_new,
244
	.bus = nv04_bus_new,
245
	.clk = nv04_clk_new,
246
	.devinit = nv1a_devinit_new,
247
	.fb = nv1a_fb_new,
248
	.gpio = nv10_gpio_new,
249
	.i2c = nv04_i2c_new,
250
	.imem = nv04_instmem_new,
251
	.mc = nv04_mc_new,
252
	.mmu = nv04_mmu_new,
253
	.timer = nv04_timer_new,
254
	.disp = nv04_disp_new,
255
	.dma = nv04_dma_new,
256
	.fifo = nv17_fifo_new,
257
	.gr = nv17_gr_new,
258 259 260 261 262 263
//	.sw = nv10_sw_new,
};

static const struct nvkm_device_chip
nv20_chipset = {
	.name = "NV20",
264
	.bios = nvkm_bios_new,
265
	.bus = nv04_bus_new,
266
	.clk = nv04_clk_new,
267
	.devinit = nv20_devinit_new,
268
	.fb = nv20_fb_new,
269
	.gpio = nv10_gpio_new,
270
	.i2c = nv04_i2c_new,
271
	.imem = nv04_instmem_new,
272
	.mc = nv04_mc_new,
273
	.mmu = nv04_mmu_new,
274
	.timer = nv04_timer_new,
275
	.disp = nv04_disp_new,
276
	.dma = nv04_dma_new,
277
	.fifo = nv17_fifo_new,
278
	.gr = nv20_gr_new,
279 280 281 282 283 284
//	.sw = nv10_sw_new,
};

static const struct nvkm_device_chip
nv25_chipset = {
	.name = "NV25",
285
	.bios = nvkm_bios_new,
286
	.bus = nv04_bus_new,
287
	.clk = nv04_clk_new,
288
	.devinit = nv20_devinit_new,
289
	.fb = nv25_fb_new,
290
	.gpio = nv10_gpio_new,
291
	.i2c = nv04_i2c_new,
292
	.imem = nv04_instmem_new,
293
	.mc = nv04_mc_new,
294
	.mmu = nv04_mmu_new,
295
	.timer = nv04_timer_new,
296
	.disp = nv04_disp_new,
297
	.dma = nv04_dma_new,
298
	.fifo = nv17_fifo_new,
299
	.gr = nv25_gr_new,
300 301 302 303 304 305
//	.sw = nv10_sw_new,
};

static const struct nvkm_device_chip
nv28_chipset = {
	.name = "NV28",
306
	.bios = nvkm_bios_new,
307
	.bus = nv04_bus_new,
308
	.clk = nv04_clk_new,
309
	.devinit = nv20_devinit_new,
310
	.fb = nv25_fb_new,
311
	.gpio = nv10_gpio_new,
312
	.i2c = nv04_i2c_new,
313
	.imem = nv04_instmem_new,
314
	.mc = nv04_mc_new,
315
	.mmu = nv04_mmu_new,
316
	.timer = nv04_timer_new,
317
	.disp = nv04_disp_new,
318
	.dma = nv04_dma_new,
319
	.fifo = nv17_fifo_new,
320
	.gr = nv25_gr_new,
321 322 323 324 325 326
//	.sw = nv10_sw_new,
};

static const struct nvkm_device_chip
nv2a_chipset = {
	.name = "NV2A",
327
	.bios = nvkm_bios_new,
328
	.bus = nv04_bus_new,
329
	.clk = nv04_clk_new,
330
	.devinit = nv20_devinit_new,
331
	.fb = nv25_fb_new,
332
	.gpio = nv10_gpio_new,
333
	.i2c = nv04_i2c_new,
334
	.imem = nv04_instmem_new,
335
	.mc = nv04_mc_new,
336
	.mmu = nv04_mmu_new,
337
	.timer = nv04_timer_new,
338
	.disp = nv04_disp_new,
339
	.dma = nv04_dma_new,
340
	.fifo = nv17_fifo_new,
341
	.gr = nv2a_gr_new,
342 343 344 345 346 347
//	.sw = nv10_sw_new,
};

static const struct nvkm_device_chip
nv30_chipset = {
	.name = "NV30",
348
	.bios = nvkm_bios_new,
349
	.bus = nv04_bus_new,
350
	.clk = nv04_clk_new,
351
	.devinit = nv20_devinit_new,
352
	.fb = nv30_fb_new,
353
	.gpio = nv10_gpio_new,
354
	.i2c = nv04_i2c_new,
355
	.imem = nv04_instmem_new,
356
	.mc = nv04_mc_new,
357
	.mmu = nv04_mmu_new,
358
	.timer = nv04_timer_new,
359
	.disp = nv04_disp_new,
360
	.dma = nv04_dma_new,
361
	.fifo = nv17_fifo_new,
362
	.gr = nv30_gr_new,
363 364 365 366 367 368
//	.sw = nv10_sw_new,
};

static const struct nvkm_device_chip
nv31_chipset = {
	.name = "NV31",
369
	.bios = nvkm_bios_new,
370
	.bus = nv31_bus_new,
371
	.clk = nv04_clk_new,
372
	.devinit = nv20_devinit_new,
373
	.fb = nv30_fb_new,
374
	.gpio = nv10_gpio_new,
375
	.i2c = nv04_i2c_new,
376
	.imem = nv04_instmem_new,
377
	.mc = nv04_mc_new,
378
	.mmu = nv04_mmu_new,
379
	.timer = nv04_timer_new,
380
	.disp = nv04_disp_new,
381
	.dma = nv04_dma_new,
382
	.fifo = nv17_fifo_new,
383
	.gr = nv30_gr_new,
384 385 386 387 388 389 390
//	.mpeg = nv31_mpeg_new,
//	.sw = nv10_sw_new,
};

static const struct nvkm_device_chip
nv34_chipset = {
	.name = "NV34",
391
	.bios = nvkm_bios_new,
392
	.bus = nv31_bus_new,
393
	.clk = nv04_clk_new,
394
	.devinit = nv10_devinit_new,
395
	.fb = nv10_fb_new,
396
	.gpio = nv10_gpio_new,
397
	.i2c = nv04_i2c_new,
398
	.imem = nv04_instmem_new,
399
	.mc = nv04_mc_new,
400
	.mmu = nv04_mmu_new,
401
	.timer = nv04_timer_new,
402
	.disp = nv04_disp_new,
403
	.dma = nv04_dma_new,
404
	.fifo = nv17_fifo_new,
405
	.gr = nv34_gr_new,
406 407 408 409 410 411 412
//	.mpeg = nv31_mpeg_new,
//	.sw = nv10_sw_new,
};

static const struct nvkm_device_chip
nv35_chipset = {
	.name = "NV35",
413
	.bios = nvkm_bios_new,
414
	.bus = nv04_bus_new,
415
	.clk = nv04_clk_new,
416
	.devinit = nv20_devinit_new,
417
	.fb = nv35_fb_new,
418
	.gpio = nv10_gpio_new,
419
	.i2c = nv04_i2c_new,
420
	.imem = nv04_instmem_new,
421
	.mc = nv04_mc_new,
422
	.mmu = nv04_mmu_new,
423
	.timer = nv04_timer_new,
424
	.disp = nv04_disp_new,
425
	.dma = nv04_dma_new,
426
	.fifo = nv17_fifo_new,
427
	.gr = nv35_gr_new,
428 429 430 431 432 433
//	.sw = nv10_sw_new,
};

static const struct nvkm_device_chip
nv36_chipset = {
	.name = "NV36",
434
	.bios = nvkm_bios_new,
435
	.bus = nv31_bus_new,
436
	.clk = nv04_clk_new,
437
	.devinit = nv20_devinit_new,
438
	.fb = nv36_fb_new,
439
	.gpio = nv10_gpio_new,
440
	.i2c = nv04_i2c_new,
441
	.imem = nv04_instmem_new,
442
	.mc = nv04_mc_new,
443
	.mmu = nv04_mmu_new,
444
	.timer = nv04_timer_new,
445
	.disp = nv04_disp_new,
446
	.dma = nv04_dma_new,
447
	.fifo = nv17_fifo_new,
448
	.gr = nv35_gr_new,
449 450 451 452 453 454 455
//	.mpeg = nv31_mpeg_new,
//	.sw = nv10_sw_new,
};

static const struct nvkm_device_chip
nv40_chipset = {
	.name = "NV40",
456
	.bios = nvkm_bios_new,
457
	.bus = nv31_bus_new,
458
	.clk = nv40_clk_new,
459
	.devinit = nv1a_devinit_new,
460
	.fb = nv40_fb_new,
461
	.gpio = nv10_gpio_new,
462
	.i2c = nv04_i2c_new,
463
	.imem = nv40_instmem_new,
464
	.mc = nv40_mc_new,
465
	.mmu = nv04_mmu_new,
466
	.therm = nv40_therm_new,
467
	.timer = nv40_timer_new,
468
	.volt = nv40_volt_new,
469
	.disp = nv04_disp_new,
470
	.dma = nv04_dma_new,
471
	.fifo = nv40_fifo_new,
472
	.gr = nv40_gr_new,
473 474 475 476 477 478 479 480
//	.mpeg = nv40_mpeg_new,
//	.pm = nv40_pm_new,
//	.sw = nv10_sw_new,
};

static const struct nvkm_device_chip
nv41_chipset = {
	.name = "NV41",
481
	.bios = nvkm_bios_new,
482
	.bus = nv31_bus_new,
483
	.clk = nv40_clk_new,
484
	.devinit = nv1a_devinit_new,
485
	.fb = nv41_fb_new,
486
	.gpio = nv10_gpio_new,
487
	.i2c = nv04_i2c_new,
488
	.imem = nv40_instmem_new,
489
	.mc = nv40_mc_new,
490
	.mmu = nv41_mmu_new,
491
	.therm = nv40_therm_new,
492
	.timer = nv41_timer_new,
493
	.volt = nv40_volt_new,
494
	.disp = nv04_disp_new,
495
	.dma = nv04_dma_new,
496
	.fifo = nv40_fifo_new,
497
	.gr = nv40_gr_new,
498 499 500 501 502 503 504 505
//	.mpeg = nv40_mpeg_new,
//	.pm = nv40_pm_new,
//	.sw = nv10_sw_new,
};

static const struct nvkm_device_chip
nv42_chipset = {
	.name = "NV42",
506
	.bios = nvkm_bios_new,
507
	.bus = nv31_bus_new,
508
	.clk = nv40_clk_new,
509
	.devinit = nv1a_devinit_new,
510
	.fb = nv41_fb_new,
511
	.gpio = nv10_gpio_new,
512
	.i2c = nv04_i2c_new,
513
	.imem = nv40_instmem_new,
514
	.mc = nv40_mc_new,
515
	.mmu = nv41_mmu_new,
516
	.therm = nv40_therm_new,
517
	.timer = nv41_timer_new,
518
	.volt = nv40_volt_new,
519
	.disp = nv04_disp_new,
520
	.dma = nv04_dma_new,
521
	.fifo = nv40_fifo_new,
522
	.gr = nv40_gr_new,
523 524 525 526 527 528 529 530
//	.mpeg = nv40_mpeg_new,
//	.pm = nv40_pm_new,
//	.sw = nv10_sw_new,
};

static const struct nvkm_device_chip
nv43_chipset = {
	.name = "NV43",
531
	.bios = nvkm_bios_new,
532
	.bus = nv31_bus_new,
533
	.clk = nv40_clk_new,
534
	.devinit = nv1a_devinit_new,
535
	.fb = nv41_fb_new,
536
	.gpio = nv10_gpio_new,
537
	.i2c = nv04_i2c_new,
538
	.imem = nv40_instmem_new,
539
	.mc = nv40_mc_new,
540
	.mmu = nv41_mmu_new,
541
	.therm = nv40_therm_new,
542
	.timer = nv41_timer_new,
543
	.volt = nv40_volt_new,
544
	.disp = nv04_disp_new,
545
	.dma = nv04_dma_new,
546
	.fifo = nv40_fifo_new,
547
	.gr = nv40_gr_new,
548 549 550 551 552 553 554 555
//	.mpeg = nv40_mpeg_new,
//	.pm = nv40_pm_new,
//	.sw = nv10_sw_new,
};

static const struct nvkm_device_chip
nv44_chipset = {
	.name = "NV44",
556
	.bios = nvkm_bios_new,
557
	.bus = nv31_bus_new,
558
	.clk = nv40_clk_new,
559
	.devinit = nv1a_devinit_new,
560
	.fb = nv44_fb_new,
561
	.gpio = nv10_gpio_new,
562
	.i2c = nv04_i2c_new,
563
	.imem = nv40_instmem_new,
564
	.mc = nv44_mc_new,
565
	.mmu = nv44_mmu_new,
566
	.therm = nv40_therm_new,
567
	.timer = nv41_timer_new,
568
	.volt = nv40_volt_new,
569
	.disp = nv04_disp_new,
570
	.dma = nv04_dma_new,
571
	.fifo = nv40_fifo_new,
572
	.gr = nv44_gr_new,
573 574 575 576 577 578 579 580
//	.mpeg = nv44_mpeg_new,
//	.pm = nv40_pm_new,
//	.sw = nv10_sw_new,
};

static const struct nvkm_device_chip
nv45_chipset = {
	.name = "NV45",
581
	.bios = nvkm_bios_new,
582
	.bus = nv31_bus_new,
583
	.clk = nv40_clk_new,
584
	.devinit = nv1a_devinit_new,
585
	.fb = nv40_fb_new,
586
	.gpio = nv10_gpio_new,
587
	.i2c = nv04_i2c_new,
588
	.imem = nv40_instmem_new,
589
	.mc = nv40_mc_new,
590
	.mmu = nv04_mmu_new,
591
	.therm = nv40_therm_new,
592
	.timer = nv41_timer_new,
593
	.volt = nv40_volt_new,
594
	.disp = nv04_disp_new,
595
	.dma = nv04_dma_new,
596
	.fifo = nv40_fifo_new,
597
	.gr = nv40_gr_new,
598 599 600 601 602 603 604 605
//	.mpeg = nv44_mpeg_new,
//	.pm = nv40_pm_new,
//	.sw = nv10_sw_new,
};

static const struct nvkm_device_chip
nv46_chipset = {
	.name = "G72",
606
	.bios = nvkm_bios_new,
607
	.bus = nv31_bus_new,
608
	.clk = nv40_clk_new,
609
	.devinit = nv1a_devinit_new,
610
	.fb = nv46_fb_new,
611
	.gpio = nv10_gpio_new,
612
	.i2c = nv04_i2c_new,
613
	.imem = nv40_instmem_new,
614
	.mc = nv44_mc_new,
615
	.mmu = nv44_mmu_new,
616
	.therm = nv40_therm_new,
617
	.timer = nv41_timer_new,
618
	.volt = nv40_volt_new,
619
	.disp = nv04_disp_new,
620
	.dma = nv04_dma_new,
621
	.fifo = nv40_fifo_new,
622
	.gr = nv44_gr_new,
623 624 625 626 627 628 629 630
//	.mpeg = nv44_mpeg_new,
//	.pm = nv40_pm_new,
//	.sw = nv10_sw_new,
};

static const struct nvkm_device_chip
nv47_chipset = {
	.name = "G70",
631
	.bios = nvkm_bios_new,
632
	.bus = nv31_bus_new,
633
	.clk = nv40_clk_new,
634
	.devinit = nv1a_devinit_new,
635
	.fb = nv47_fb_new,
636
	.gpio = nv10_gpio_new,
637
	.i2c = nv04_i2c_new,
638
	.imem = nv40_instmem_new,
639
	.mc = nv40_mc_new,
640
	.mmu = nv41_mmu_new,
641
	.therm = nv40_therm_new,
642
	.timer = nv41_timer_new,
643
	.volt = nv40_volt_new,
644
	.disp = nv04_disp_new,
645
	.dma = nv04_dma_new,
646
	.fifo = nv40_fifo_new,
647
	.gr = nv40_gr_new,
648 649 650 651 652 653 654 655
//	.mpeg = nv44_mpeg_new,
//	.pm = nv40_pm_new,
//	.sw = nv10_sw_new,
};

static const struct nvkm_device_chip
nv49_chipset = {
	.name = "G71",
656
	.bios = nvkm_bios_new,
657
	.bus = nv31_bus_new,
658
	.clk = nv40_clk_new,
659
	.devinit = nv1a_devinit_new,
660
	.fb = nv49_fb_new,
661
	.gpio = nv10_gpio_new,
662
	.i2c = nv04_i2c_new,
663
	.imem = nv40_instmem_new,
664
	.mc = nv40_mc_new,
665
	.mmu = nv41_mmu_new,
666
	.therm = nv40_therm_new,
667
	.timer = nv41_timer_new,
668
	.volt = nv40_volt_new,
669
	.disp = nv04_disp_new,
670
	.dma = nv04_dma_new,
671
	.fifo = nv40_fifo_new,
672
	.gr = nv40_gr_new,
673 674 675 676 677 678 679 680
//	.mpeg = nv44_mpeg_new,
//	.pm = nv40_pm_new,
//	.sw = nv10_sw_new,
};

static const struct nvkm_device_chip
nv4a_chipset = {
	.name = "NV44A",
681
	.bios = nvkm_bios_new,
682
	.bus = nv31_bus_new,
683
	.clk = nv40_clk_new,
684
	.devinit = nv1a_devinit_new,
685
	.fb = nv44_fb_new,
686
	.gpio = nv10_gpio_new,
687
	.i2c = nv04_i2c_new,
688
	.imem = nv40_instmem_new,
689
	.mc = nv44_mc_new,
690
	.mmu = nv44_mmu_new,
691
	.therm = nv40_therm_new,
692
	.timer = nv41_timer_new,
693
	.volt = nv40_volt_new,
694
	.disp = nv04_disp_new,
695
	.dma = nv04_dma_new,
696
	.fifo = nv40_fifo_new,
697
	.gr = nv44_gr_new,
698 699 700 701 702 703 704 705
//	.mpeg = nv44_mpeg_new,
//	.pm = nv40_pm_new,
//	.sw = nv10_sw_new,
};

static const struct nvkm_device_chip
nv4b_chipset = {
	.name = "G73",
706
	.bios = nvkm_bios_new,
707
	.bus = nv31_bus_new,
708
	.clk = nv40_clk_new,
709
	.devinit = nv1a_devinit_new,
710
	.fb = nv49_fb_new,
711
	.gpio = nv10_gpio_new,
712
	.i2c = nv04_i2c_new,
713
	.imem = nv40_instmem_new,
714
	.mc = nv40_mc_new,
715
	.mmu = nv41_mmu_new,
716
	.therm = nv40_therm_new,
717
	.timer = nv41_timer_new,
718
	.volt = nv40_volt_new,
719
	.disp = nv04_disp_new,
720
	.dma = nv04_dma_new,
721
	.fifo = nv40_fifo_new,
722
	.gr = nv40_gr_new,
723 724 725 726 727 728 729 730
//	.mpeg = nv44_mpeg_new,
//	.pm = nv40_pm_new,
//	.sw = nv10_sw_new,
};

static const struct nvkm_device_chip
nv4c_chipset = {
	.name = "C61",
731
	.bios = nvkm_bios_new,
732
	.bus = nv31_bus_new,
733
	.clk = nv40_clk_new,
734
	.devinit = nv1a_devinit_new,
735
	.fb = nv46_fb_new,
736
	.gpio = nv10_gpio_new,
737
	.i2c = nv04_i2c_new,
738
	.imem = nv40_instmem_new,
739
	.mc = nv4c_mc_new,
740
	.mmu = nv44_mmu_new,
741
	.therm = nv40_therm_new,
742
	.timer = nv41_timer_new,
743
	.volt = nv40_volt_new,
744
	.disp = nv04_disp_new,
745
	.dma = nv04_dma_new,
746
	.fifo = nv40_fifo_new,
747
	.gr = nv44_gr_new,
748 749 750 751 752 753 754 755
//	.mpeg = nv44_mpeg_new,
//	.pm = nv40_pm_new,
//	.sw = nv10_sw_new,
};

static const struct nvkm_device_chip
nv4e_chipset = {
	.name = "C51",
756
	.bios = nvkm_bios_new,
757
	.bus = nv31_bus_new,
758
	.clk = nv40_clk_new,
759
	.devinit = nv1a_devinit_new,
760
	.fb = nv4e_fb_new,
761
	.gpio = nv10_gpio_new,
762
	.i2c = nv4e_i2c_new,
763
	.imem = nv40_instmem_new,
764
	.mc = nv4c_mc_new,
765
	.mmu = nv44_mmu_new,
766
	.therm = nv40_therm_new,
767
	.timer = nv41_timer_new,
768
	.volt = nv40_volt_new,
769
	.disp = nv04_disp_new,
770
	.dma = nv04_dma_new,
771
	.fifo = nv40_fifo_new,
772
	.gr = nv44_gr_new,
773 774 775 776 777 778 779 780
//	.mpeg = nv44_mpeg_new,
//	.pm = nv40_pm_new,
//	.sw = nv10_sw_new,
};

static const struct nvkm_device_chip
nv50_chipset = {
	.name = "G80",
781
	.bar = nv50_bar_new,
782
	.bios = nvkm_bios_new,
783
	.bus = nv50_bus_new,
784
	.clk = nv50_clk_new,
785
	.devinit = nv50_devinit_new,
786
	.fb = nv50_fb_new,
787
	.fuse = nv50_fuse_new,
788
	.gpio = nv50_gpio_new,
789
	.i2c = nv50_i2c_new,
790
	.imem = nv50_instmem_new,
791
	.mc = nv50_mc_new,
792
	.mmu = nv50_mmu_new,
793
	.mxm = nv50_mxm_new,
794
	.therm = nv50_therm_new,
795
	.timer = nv41_timer_new,
796
	.volt = nv40_volt_new,
797
	.disp = nv50_disp_new,
798
	.dma = nv50_dma_new,
799
	.fifo = nv50_fifo_new,
800
	.gr = nv50_gr_new,
801 802 803 804 805 806 807 808
//	.mpeg = nv50_mpeg_new,
//	.pm = nv50_pm_new,
//	.sw = nv50_sw_new,
};

static const struct nvkm_device_chip
nv63_chipset = {
	.name = "C73",
809
	.bios = nvkm_bios_new,
810
	.bus = nv31_bus_new,
811
	.clk = nv40_clk_new,
812
	.devinit = nv1a_devinit_new,
813
	.fb = nv46_fb_new,
814
	.gpio = nv10_gpio_new,
815
	.i2c = nv04_i2c_new,
816
	.imem = nv40_instmem_new,
817
	.mc = nv4c_mc_new,
818
	.mmu = nv44_mmu_new,
819
	.therm = nv40_therm_new,
820
	.timer = nv41_timer_new,
821
	.volt = nv40_volt_new,
822
	.disp = nv04_disp_new,
823
	.dma = nv04_dma_new,
824
	.fifo = nv40_fifo_new,
825
	.gr = nv44_gr_new,
826 827 828 829 830 831 832 833
//	.mpeg = nv44_mpeg_new,
//	.pm = nv40_pm_new,
//	.sw = nv10_sw_new,
};

static const struct nvkm_device_chip
nv67_chipset = {
	.name = "C67",
834
	.bios = nvkm_bios_new,
835
	.bus = nv31_bus_new,
836
	.clk = nv40_clk_new,
837
	.devinit = nv1a_devinit_new,
838
	.fb = nv46_fb_new,
839
	.gpio = nv10_gpio_new,
840
	.i2c = nv04_i2c_new,
841
	.imem = nv40_instmem_new,
842
	.mc = nv4c_mc_new,
843
	.mmu = nv44_mmu_new,
844
	.therm = nv40_therm_new,
845
	.timer = nv41_timer_new,
846
	.volt = nv40_volt_new,
847
	.disp = nv04_disp_new,
848
	.dma = nv04_dma_new,
849
	.fifo = nv40_fifo_new,
850
	.gr = nv44_gr_new,
851 852 853 854 855 856 857 858
//	.mpeg = nv44_mpeg_new,
//	.pm = nv40_pm_new,
//	.sw = nv10_sw_new,
};

static const struct nvkm_device_chip
nv68_chipset = {
	.name = "C68",
859
	.bios = nvkm_bios_new,
860
	.bus = nv31_bus_new,
861
	.clk = nv40_clk_new,
862
	.devinit = nv1a_devinit_new,
863
	.fb = nv46_fb_new,
864
	.gpio = nv10_gpio_new,
865
	.i2c = nv04_i2c_new,
866
	.imem = nv40_instmem_new,
867
	.mc = nv4c_mc_new,
868
	.mmu = nv44_mmu_new,
869
	.therm = nv40_therm_new,
870
	.timer = nv41_timer_new,
871
	.volt = nv40_volt_new,
872
	.disp = nv04_disp_new,
873
	.dma = nv04_dma_new,
874
	.fifo = nv40_fifo_new,
875
	.gr = nv44_gr_new,
876 877 878 879 880 881 882 883
//	.mpeg = nv44_mpeg_new,
//	.pm = nv40_pm_new,
//	.sw = nv10_sw_new,
};

static const struct nvkm_device_chip
nv84_chipset = {
	.name = "G84",
884
	.bar = g84_bar_new,
885
	.bios = nvkm_bios_new,
886
	.bus = nv50_bus_new,
887
	.clk = g84_clk_new,
888
	.devinit = g84_devinit_new,
889
	.fb = g84_fb_new,
890
	.fuse = nv50_fuse_new,
891
	.gpio = nv50_gpio_new,
892
	.i2c = nv50_i2c_new,
893
	.imem = nv50_instmem_new,
894
	.mc = nv50_mc_new,
895
	.mmu = nv50_mmu_new,
896
	.mxm = nv50_mxm_new,
897
	.therm = g84_therm_new,
898
	.timer = nv41_timer_new,
899
	.volt = nv40_volt_new,
900
	.bsp = g84_bsp_new,
901
	.cipher = g84_cipher_new,
902
	.disp = g84_disp_new,
903
	.dma = nv50_dma_new,
904
	.fifo = g84_fifo_new,
905
	.gr = g84_gr_new,
906 907 908
//	.mpeg = g84_mpeg_new,
//	.pm = g84_pm_new,
//	.sw = nv50_sw_new,
909
	.vp = g84_vp_new,
910 911 912 913 914
};

static const struct nvkm_device_chip
nv86_chipset = {
	.name = "G86",
915
	.bar = g84_bar_new,
916
	.bios = nvkm_bios_new,
917
	.bus = nv50_bus_new,
918
	.clk = g84_clk_new,
919
	.devinit = g84_devinit_new,
920
	.fb = g84_fb_new,
921
	.fuse = nv50_fuse_new,
922
	.gpio = nv50_gpio_new,
923
	.i2c = nv50_i2c_new,
924
	.imem = nv50_instmem_new,
925
	.mc = nv50_mc_new,
926
	.mmu = nv50_mmu_new,
927
	.mxm = nv50_mxm_new,
928
	.therm = g84_therm_new,
929
	.timer = nv41_timer_new,
930
	.volt = nv40_volt_new,
931
	.bsp = g84_bsp_new,
932
	.cipher = g84_cipher_new,
933
	.disp = g84_disp_new,
934
	.dma = nv50_dma_new,
935
	.fifo = g84_fifo_new,
936
	.gr = g84_gr_new,
937 938 939
//	.mpeg = g84_mpeg_new,
//	.pm = g84_pm_new,
//	.sw = nv50_sw_new,
940
	.vp = g84_vp_new,
941 942 943 944 945
};

static const struct nvkm_device_chip
nv92_chipset = {
	.name = "G92",
946
	.bar = g84_bar_new,
947
	.bios = nvkm_bios_new,
948
	.bus = nv50_bus_new,
949
	.clk = g84_clk_new,
950
	.devinit = g84_devinit_new,
951
	.fb = g84_fb_new,
952
	.fuse = nv50_fuse_new,
953
	.gpio = nv50_gpio_new,
954
	.i2c = nv50_i2c_new,
955
	.imem = nv50_instmem_new,
956
	.mc = nv50_mc_new,
957
	.mmu = nv50_mmu_new,
958
	.mxm = nv50_mxm_new,
959
	.therm = g84_therm_new,
960
	.timer = nv41_timer_new,
961
	.volt = nv40_volt_new,
962
	.bsp = g84_bsp_new,
963
	.cipher = g84_cipher_new,
964
	.disp = g84_disp_new,
965
	.dma = nv50_dma_new,
966
	.fifo = g84_fifo_new,
967
	.gr = g84_gr_new,
968 969 970
//	.mpeg = g84_mpeg_new,
//	.pm = g84_pm_new,
//	.sw = nv50_sw_new,
971
	.vp = g84_vp_new,
972 973 974 975 976
};

static const struct nvkm_device_chip
nv94_chipset = {
	.name = "G94",
977
	.bar = g84_bar_new,
978
	.bios = nvkm_bios_new,
979
	.bus = g94_bus_new,
980
	.clk = g84_clk_new,
981
	.devinit = g84_devinit_new,
982
	.fb = g84_fb_new,
983
	.fuse = nv50_fuse_new,
984
	.gpio = g94_gpio_new,
985
	.i2c = g94_i2c_new,
986
	.imem = nv50_instmem_new,
987
	.mc = g94_mc_new,
988
	.mmu = nv50_mmu_new,
989
	.mxm = nv50_mxm_new,
990
	.therm = g84_therm_new,
991
	.timer = nv41_timer_new,
992
	.volt = nv40_volt_new,
993
	.bsp = g84_bsp_new,
994
	.cipher = g84_cipher_new,
995
	.disp = g94_disp_new,
996
	.dma = nv50_dma_new,
997
	.fifo = g84_fifo_new,
998
	.gr = g84_gr_new,
999 1000 1001
//	.mpeg = g84_mpeg_new,
//	.pm = g84_pm_new,
//	.sw = nv50_sw_new,
1002
	.vp = g84_vp_new,
1003 1004 1005 1006 1007
};

static const struct nvkm_device_chip
nv96_chipset = {
	.name = "G96",
1008
	.bios = nvkm_bios_new,
1009
	.gpio = g94_gpio_new,
1010
	.i2c = g94_i2c_new,
1011
	.fuse = nv50_fuse_new,
1012
	.clk = g84_clk_new,
1013
	.therm = g84_therm_new,
1014
	.mxm = nv50_mxm_new,
1015
	.devinit = g84_devinit_new,
1016
	.mc = g94_mc_new,
1017
	.bus = g94_bus_new,
1018
	.timer = nv41_timer_new,
1019
	.fb = g84_fb_new,
1020
	.imem = nv50_instmem_new,
1021
	.mmu = nv50_mmu_new,
1022
	.bar = g84_bar_new,
1023
	.volt = nv40_volt_new,
1024
	.dma = nv50_dma_new,
1025
	.fifo = g84_fifo_new,
1026
//	.sw = nv50_sw_new,
1027
	.gr = g84_gr_new,
1028
//	.mpeg = g84_mpeg_new,
1029
	.vp = g84_vp_new,
1030
	.cipher = g84_cipher_new,
1031
	.bsp = g84_bsp_new,
1032
	.disp = g94_disp_new,
1033 1034 1035 1036 1037 1038
//	.pm = g84_pm_new,
};

static const struct nvkm_device_chip
nv98_chipset = {
	.name = "G98",
1039
	.bios = nvkm_bios_new,
1040
	.gpio = g94_gpio_new,
1041
	.i2c = g94_i2c_new,
1042
	.fuse = nv50_fuse_new,
1043
	.clk = g84_clk_new,
1044
	.therm = g84_therm_new,
1045
	.mxm = nv50_mxm_new,
1046
	.devinit = g98_devinit_new,
1047
	.mc = g98_mc_new,
1048
	.bus = g94_bus_new,
1049
	.timer = nv41_timer_new,
1050
	.fb = g84_fb_new,
1051
	.imem = nv50_instmem_new,
1052
	.mmu = nv50_mmu_new,
1053
	.bar = g84_bar_new,
1054
	.volt = nv40_volt_new,
1055
	.dma = nv50_dma_new,
1056
	.fifo = g84_fifo_new,
1057
//	.sw = nv50_sw_new,
1058
	.gr = g84_gr_new,
1059 1060 1061 1062
	.mspdec = g98_mspdec_new,
	.sec = g98_sec_new,
	.msvld = g98_msvld_new,
	.msppp = g98_msppp_new,
1063
	.disp = g94_disp_new,
1064 1065 1066 1067 1068 1069
//	.pm = g84_pm_new,
};

static const struct nvkm_device_chip
nva0_chipset = {
	.name = "GT200",
1070
	.bar = g84_bar_new,
1071
	.bios = nvkm_bios_new,
1072
	.bus = g94_bus_new,
1073
	.clk = g84_clk_new,
1074
	.devinit = g84_devinit_new,
1075
	.fb = g84_fb_new,
1076
	.fuse = nv50_fuse_new,
1077
	.gpio = g94_gpio_new,
1078
	.i2c = nv50_i2c_new,
1079
	.imem = nv50_instmem_new,
1080
	.mc = g98_mc_new,
1081
	.mmu = nv50_mmu_new,
1082
	.mxm = nv50_mxm_new,
1083
	.therm = g84_therm_new,
1084
	.timer = nv41_timer_new,
1085
	.volt = nv40_volt_new,
1086
	.bsp = g84_bsp_new,
1087
	.cipher = g84_cipher_new,
1088
	.disp = gt200_disp_new,
1089
	.dma = nv50_dma_new,
1090
	.fifo = g84_fifo_new,
1091
	.gr = gt200_gr_new,
1092 1093 1094
//	.mpeg = g84_mpeg_new,
//	.pm = gt200_pm_new,
//	.sw = nv50_sw_new,
1095
	.vp = g84_vp_new,
1096 1097 1098 1099 1100
};

static const struct nvkm_device_chip
nva3_chipset = {
	.name = "GT215",
1101
	.bar = g84_bar_new,
1102
	.bios = nvkm_bios_new,
1103
	.bus = g94_bus_new,
1104
	.clk = gt215_clk_new,
1105
	.devinit = gt215_devinit_new,
1106
	.fb = gt215_fb_new,
1107
	.fuse = nv50_fuse_new,
1108
	.gpio = g94_gpio_new,
1109
	.i2c = g94_i2c_new,
1110
	.imem = nv50_instmem_new,
1111
	.mc = g98_mc_new,
1112
	.mmu = nv50_mmu_new,
1113
	.mxm = nv50_mxm_new,
1114
	.pmu = gt215_pmu_new,
1115
	.therm = gt215_therm_new,
1116
	.timer = nv41_timer_new,
1117
	.volt = nv40_volt_new,
1118
	.ce[0] = gt215_ce_new,
1119
	.disp = gt215_disp_new,
1120
	.dma = nv50_dma_new,
1121
	.fifo = g84_fifo_new,
1122
	.gr = gt215_gr_new,
1123
//	.mpeg = g84_mpeg_new,
1124 1125 1126
	.mspdec = gt215_mspdec_new,
	.msppp = gt215_msppp_new,
	.msvld = gt215_msvld_new,
1127 1128 1129 1130 1131 1132 1133
//	.pm = gt215_pm_new,
//	.sw = nv50_sw_new,
};

static const struct nvkm_device_chip
nva5_chipset = {
	.name = "GT216",
1134
	.bar = g84_bar_new,
1135
	.bios = nvkm_bios_new,
1136
	.bus = g94_bus_new,
1137
	.clk = gt215_clk_new,
1138
	.devinit = gt215_devinit_new,
1139
	.fb = gt215_fb_new,
1140
	.fuse = nv50_fuse_new,
1141
	.gpio = g94_gpio_new,
1142
	.i2c = g94_i2c_new,
1143
	.imem = nv50_instmem_new,
1144
	.mc = g98_mc_new,
1145
	.mmu = nv50_mmu_new,
1146
	.mxm = nv50_mxm_new,
1147
	.pmu = gt215_pmu_new,
1148
	.therm = gt215_therm_new,
1149
	.timer = nv41_timer_new,
1150
	.volt = nv40_volt_new,
1151
	.ce[0] = gt215_ce_new,
1152
	.disp = gt215_disp_new,
1153
	.dma = nv50_dma_new,
1154
	.fifo = g84_fifo_new,
1155
	.gr = gt215_gr_new,
1156 1157 1158
	.mspdec = gt215_mspdec_new,
	.msppp = gt215_msppp_new,
	.msvld = gt215_msvld_new,
1159 1160 1161 1162 1163 1164 1165
//	.pm = gt215_pm_new,
//	.sw = nv50_sw_new,
};

static const struct nvkm_device_chip
nva8_chipset = {
	.name = "GT218",
1166
	.bar = g84_bar_new,
1167
	.bios = nvkm_bios_new,
1168
	.bus = g94_bus_new,
1169
	.clk = gt215_clk_new,
1170
	.devinit = gt215_devinit_new,
1171
	.fb = gt215_fb_new,
1172
	.fuse = nv50_fuse_new,
1173
	.gpio = g94_gpio_new,
1174
	.i2c = g94_i2c_new,
1175
	.imem = nv50_instmem_new,
1176
	.mc = g98_mc_new,
1177
	.mmu = nv50_mmu_new,
1178
	.mxm = nv50_mxm_new,
1179
	.pmu = gt215_pmu_new,
1180
	.therm = gt215_therm_new,
1181
	.timer = nv41_timer_new,
1182
	.volt = nv40_volt_new,
1183
	.ce[0] = gt215_ce_new,
1184
	.disp = gt215_disp_new,
1185
	.dma = nv50_dma_new,
1186
	.fifo = g84_fifo_new,
1187
	.gr = gt215_gr_new,
1188 1189 1190
	.mspdec = gt215_mspdec_new,
	.msppp = gt215_msppp_new,
	.msvld = gt215_msvld_new,
1191 1192 1193 1194 1195 1196 1197
//	.pm = gt215_pm_new,
//	.sw = nv50_sw_new,
};

static const struct nvkm_device_chip
nvaa_chipset = {
	.name = "MCP77/MCP78",
1198
	.bar = g84_bar_new,
1199
	.bios = nvkm_bios_new,
1200
	.bus = g94_bus_new,
1201
	.clk = mcp77_clk_new,
1202
	.devinit = g98_devinit_new,
1203
	.fb = mcp77_fb_new,
1204
	.fuse = nv50_fuse_new,
1205
	.gpio = g94_gpio_new,
1206
	.i2c = g94_i2c_new,
1207
	.imem = nv50_instmem_new,
1208
	.mc = g98_mc_new,
1209
	.mmu = nv50_mmu_new,
1210
	.mxm = nv50_mxm_new,
1211
	.therm = g84_therm_new,
1212
	.timer = nv41_timer_new,
1213
	.volt = nv40_volt_new,
1214
	.disp = g94_disp_new,
1215
	.dma = nv50_dma_new,
1216
	.fifo = g84_fifo_new,
1217
	.gr = gt200_gr_new,
1218 1219 1220
	.mspdec = g98_mspdec_new,
	.msppp = g98_msppp_new,
	.msvld = g98_msvld_new,
1221
//	.pm = g84_pm_new,
1222
	.sec = g98_sec_new,
1223 1224 1225 1226 1227 1228
//	.sw = nv50_sw_new,
};

static const struct nvkm_device_chip
nvac_chipset = {
	.name = "MCP79/MCP7A",
1229
	.bar = g84_bar_new,
1230
	.bios = nvkm_bios_new,
1231
	.bus = g94_bus_new,
1232
	.clk = mcp77_clk_new,
1233
	.devinit = g98_devinit_new,
1234
	.fb = mcp77_fb_new,
1235
	.fuse = nv50_fuse_new,
1236
	.gpio = g94_gpio_new,
1237
	.i2c = g94_i2c_new,
1238
	.imem = nv50_instmem_new,
1239
	.mc = g98_mc_new,
1240
	.mmu = nv50_mmu_new,
1241
	.mxm = nv50_mxm_new,
1242
	.therm = g84_therm_new,
1243
	.timer = nv41_timer_new,
1244
	.volt = nv40_volt_new,
1245
	.disp = g94_disp_new,
1246
	.dma = nv50_dma_new,
1247
	.fifo = g84_fifo_new,
1248
	.gr = mcp79_gr_new,
1249 1250 1251
	.mspdec = g98_mspdec_new,
	.msppp = g98_msppp_new,
	.msvld = g98_msvld_new,
1252
//	.pm = g84_pm_new,
1253
	.sec = g98_sec_new,
1254 1255 1256 1257 1258 1259
//	.sw = nv50_sw_new,
};

static const struct nvkm_device_chip
nvaf_chipset = {
	.name = "MCP89",
1260
	.bar = g84_bar_new,
1261
	.bios = nvkm_bios_new,
1262
	.bus = g94_bus_new,
1263
	.clk = gt215_clk_new,
1264
	.devinit = mcp89_devinit_new,
1265
	.fb = mcp89_fb_new,
1266
	.fuse = nv50_fuse_new,
1267
	.gpio = g94_gpio_new,
1268
	.i2c = g94_i2c_new,
1269
	.imem = nv50_instmem_new,
1270
	.mc = g98_mc_new,
1271
	.mmu = nv50_mmu_new,
1272
	.mxm = nv50_mxm_new,
1273
	.pmu = gt215_pmu_new,
1274
	.therm = gt215_therm_new,
1275
	.timer = nv41_timer_new,
1276
	.volt = nv40_volt_new,
1277
	.ce[0] = gt215_ce_new,
1278
	.disp = gt215_disp_new,
1279
	.dma = nv50_dma_new,
1280
	.fifo = g84_fifo_new,
1281
	.gr = mcp89_gr_new,
1282 1283 1284
	.mspdec = gt215_mspdec_new,
	.msppp = gt215_msppp_new,
	.msvld = mcp89_msvld_new,
1285 1286 1287 1288 1289 1290 1291
//	.pm = gt215_pm_new,
//	.sw = nv50_sw_new,
};

static const struct nvkm_device_chip
nvc0_chipset = {
	.name = "GF100",
1292
	.bar = gf100_bar_new,
1293
	.bios = nvkm_bios_new,
1294
	.bus = gf100_bus_new,
1295
	.clk = gf100_clk_new,
1296
	.devinit = gf100_devinit_new,
1297
	.fb = gf100_fb_new,
1298
	.fuse = gf100_fuse_new,
1299
	.gpio = g94_gpio_new,
1300
	.i2c = g94_i2c_new,
1301
	.ibus = gf100_ibus_new,
1302
	.imem = nv50_instmem_new,
1303
	.ltc = gf100_ltc_new,
1304
	.mc = gf100_mc_new,
1305
	.mmu = gf100_mmu_new,
1306
	.mxm = nv50_mxm_new,
1307
	.pmu = gf100_pmu_new,
1308
	.therm = gt215_therm_new,
1309
	.timer = nv41_timer_new,
1310
	.volt = nv40_volt_new,
1311 1312
	.ce[0] = gf100_ce_new,
	.ce[1] = gf100_ce_new,
1313
	.disp = gt215_disp_new,
1314
	.dma = gf100_dma_new,
1315
	.fifo = gf100_fifo_new,
1316
	.gr = gf100_gr_new,
1317 1318 1319
	.mspdec = gf100_mspdec_new,
	.msppp = gf100_msppp_new,
	.msvld = gf100_msvld_new,
1320 1321 1322 1323 1324 1325 1326
//	.pm = gf100_pm_new,
//	.sw = gf100_sw_new,
};

static const struct nvkm_device_chip
nvc1_chipset = {
	.name = "GF108",
1327
	.bar = gf100_bar_new,
1328
	.bios = nvkm_bios_new,
1329
	.bus = gf100_bus_new,
1330
	.clk = gf100_clk_new,
1331
	.devinit = gf100_devinit_new,
1332
	.fb = gf100_fb_new,
1333
	.fuse = gf100_fuse_new,
1334
	.gpio = g94_gpio_new,
1335
	.i2c = g94_i2c_new,
1336
	.ibus = gf100_ibus_new,
1337
	.imem = nv50_instmem_new,
1338
	.ltc = gf100_ltc_new,
1339
	.mc = gf106_mc_new,
1340
	.mmu = gf100_mmu_new,
1341
	.mxm = nv50_mxm_new,
1342
	.pmu = gf100_pmu_new,
1343
	.therm = gt215_therm_new,
1344
	.timer = nv41_timer_new,
1345
	.volt = nv40_volt_new,
1346
	.ce[0] = gf100_ce_new,
1347
	.disp = gt215_disp_new,
1348
	.dma = gf100_dma_new,
1349
	.fifo = gf100_fifo_new,
1350
	.gr = gf108_gr_new,
1351 1352 1353
	.mspdec = gf100_mspdec_new,
	.msppp = gf100_msppp_new,
	.msvld = gf100_msvld_new,
1354 1355 1356 1357 1358 1359 1360
//	.pm = gf108_pm_new,
//	.sw = gf100_sw_new,
};

static const struct nvkm_device_chip
nvc3_chipset = {
	.name = "GF106",
1361
	.bar = gf100_bar_new,
1362
	.bios = nvkm_bios_new,
1363
	.bus = gf100_bus_new,
1364
	.clk = gf100_clk_new,
1365
	.devinit = gf100_devinit_new,
1366
	.fb = gf100_fb_new,
1367
	.fuse = gf100_fuse_new,
1368
	.gpio = g94_gpio_new,
1369
	.i2c = g94_i2c_new,
1370
	.ibus = gf100_ibus_new,
1371
	.imem = nv50_instmem_new,
1372
	.ltc = gf100_ltc_new,
1373
	.mc = gf106_mc_new,
1374
	.mmu = gf100_mmu_new,
1375
	.mxm = nv50_mxm_new,
1376
	.pmu = gf100_pmu_new,
1377
	.therm = gt215_therm_new,
1378
	.timer = nv41_timer_new,
1379
	.volt = nv40_volt_new,
1380
	.ce[0] = gf100_ce_new,
1381
	.disp = gt215_disp_new,
1382
	.dma = gf100_dma_new,
1383
	.fifo = gf100_fifo_new,
1384
	.gr = gf104_gr_new,
1385 1386 1387
	.mspdec = gf100_mspdec_new,
	.msppp = gf100_msppp_new,
	.msvld = gf100_msvld_new,
1388 1389 1390 1391 1392 1393 1394
//	.pm = gf100_pm_new,
//	.sw = gf100_sw_new,
};

static const struct nvkm_device_chip
nvc4_chipset = {
	.name = "GF104",
1395
	.bar = gf100_bar_new,
1396
	.bios = nvkm_bios_new,
1397
	.bus = gf100_bus_new,
1398
	.clk = gf100_clk_new,
1399
	.devinit = gf100_devinit_new,
1400
	.fb = gf100_fb_new,
1401
	.fuse = gf100_fuse_new,
1402
	.gpio = g94_gpio_new,
1403
	.i2c = g94_i2c_new,
1404
	.ibus = gf100_ibus_new,
1405
	.imem = nv50_instmem_new,
1406
	.ltc = gf100_ltc_new,
1407
	.mc = gf100_mc_new,
1408
	.mmu = gf100_mmu_new,
1409
	.mxm = nv50_mxm_new,
1410
	.pmu = gf100_pmu_new,
1411
	.therm = gt215_therm_new,
1412
	.timer = nv41_timer_new,
1413
	.volt = nv40_volt_new,
1414 1415
	.ce[0] = gf100_ce_new,
	.ce[1] = gf100_ce_new,
1416
	.disp = gt215_disp_new,
1417
	.dma = gf100_dma_new,
1418
	.fifo = gf100_fifo_new,
1419
	.gr = gf104_gr_new,
1420 1421 1422
	.mspdec = gf100_mspdec_new,
	.msppp = gf100_msppp_new,
	.msvld = gf100_msvld_new,
1423 1424 1425 1426 1427 1428 1429
//	.pm = gf100_pm_new,
//	.sw = gf100_sw_new,
};

static const struct nvkm_device_chip
nvc8_chipset = {
	.name = "GF110",
1430
	.bar = gf100_bar_new,
1431
	.bios = nvkm_bios_new,
1432
	.bus = gf100_bus_new,
1433
	.clk = gf100_clk_new,
1434
	.devinit = gf100_devinit_new,
1435
	.fb = gf100_fb_new,
1436
	.fuse = gf100_fuse_new,
1437
	.gpio = g94_gpio_new,
1438
	.i2c = g94_i2c_new,
1439
	.ibus = gf100_ibus_new,
1440
	.imem = nv50_instmem_new,
1441
	.ltc = gf100_ltc_new,
1442
	.mc = gf100_mc_new,
1443
	.mmu = gf100_mmu_new,
1444
	.mxm = nv50_mxm_new,
1445
	.pmu = gf100_pmu_new,
1446
	.therm = gt215_therm_new,
1447
	.timer = nv41_timer_new,
1448
	.volt = nv40_volt_new,
1449 1450
	.ce[0] = gf100_ce_new,
	.ce[1] = gf100_ce_new,
1451
	.disp = gt215_disp_new,
1452
	.dma = gf100_dma_new,
1453
	.fifo = gf100_fifo_new,
1454
	.gr = gf110_gr_new,
1455 1456 1457
	.mspdec = gf100_mspdec_new,
	.msppp = gf100_msppp_new,
	.msvld = gf100_msvld_new,
1458 1459 1460 1461 1462 1463 1464
//	.pm = gf100_pm_new,
//	.sw = gf100_sw_new,
};

static const struct nvkm_device_chip
nvce_chipset = {
	.name = "GF114",
1465
	.bar = gf100_bar_new,
1466
	.bios = nvkm_bios_new,
1467
	.bus = gf100_bus_new,
1468
	.clk = gf100_clk_new,
1469
	.devinit = gf100_devinit_new,
1470
	.fb = gf100_fb_new,
1471
	.fuse = gf100_fuse_new,
1472
	.gpio = g94_gpio_new,
1473
	.i2c = g94_i2c_new,
1474
	.ibus = gf100_ibus_new,
1475
	.imem = nv50_instmem_new,
1476
	.ltc = gf100_ltc_new,
1477
	.mc = gf100_mc_new,
1478
	.mmu = gf100_mmu_new,
1479
	.mxm = nv50_mxm_new,
1480
	.pmu = gf100_pmu_new,
1481
	.therm = gt215_therm_new,
1482
	.timer = nv41_timer_new,
1483
	.volt = nv40_volt_new,
1484 1485
	.ce[0] = gf100_ce_new,
	.ce[1] = gf100_ce_new,
1486
	.disp = gt215_disp_new,
1487
	.dma = gf100_dma_new,
1488
	.fifo = gf100_fifo_new,
1489
	.gr = gf104_gr_new,
1490 1491 1492
	.mspdec = gf100_mspdec_new,
	.msppp = gf100_msppp_new,
	.msvld = gf100_msvld_new,
1493 1494 1495 1496 1497 1498 1499
//	.pm = gf100_pm_new,
//	.sw = gf100_sw_new,
};

static const struct nvkm_device_chip
nvcf_chipset = {
	.name = "GF116",
1500
	.bar = gf100_bar_new,
1501
	.bios = nvkm_bios_new,
1502
	.bus = gf100_bus_new,
1503
	.clk = gf100_clk_new,
1504
	.devinit = gf100_devinit_new,
1505
	.fb = gf100_fb_new,
1506
	.fuse = gf100_fuse_new,
1507
	.gpio = g94_gpio_new,
1508
	.i2c = g94_i2c_new,
1509
	.ibus = gf100_ibus_new,
1510
	.imem = nv50_instmem_new,
1511
	.ltc = gf100_ltc_new,
1512
	.mc = gf106_mc_new,
1513
	.mmu = gf100_mmu_new,
1514
	.mxm = nv50_mxm_new,
1515
	.pmu = gf100_pmu_new,
1516
	.therm = gt215_therm_new,
1517
	.timer = nv41_timer_new,
1518
	.volt = nv40_volt_new,
1519
	.ce[0] = gf100_ce_new,
1520
	.disp = gt215_disp_new,
1521
	.dma = gf100_dma_new,
1522
	.fifo = gf100_fifo_new,
1523
	.gr = gf104_gr_new,
1524 1525 1526
	.mspdec = gf100_mspdec_new,
	.msppp = gf100_msppp_new,
	.msvld = gf100_msvld_new,
1527 1528 1529 1530 1531 1532 1533
//	.pm = gf100_pm_new,
//	.sw = gf100_sw_new,
};

static const struct nvkm_device_chip
nvd7_chipset = {
	.name = "GF117",
1534
	.bar = gf100_bar_new,
1535
	.bios = nvkm_bios_new,
1536
	.bus = gf100_bus_new,
1537
	.clk = gf100_clk_new,
1538
	.devinit = gf100_devinit_new,
1539
	.fb = gf100_fb_new,
1540
	.fuse = gf100_fuse_new,
1541
	.gpio = gf119_gpio_new,
1542
	.i2c = gf117_i2c_new,
1543
	.ibus = gf100_ibus_new,
1544
	.imem = nv50_instmem_new,
1545
	.ltc = gf100_ltc_new,
1546
	.mc = gf106_mc_new,
1547
	.mmu = gf100_mmu_new,
1548
	.mxm = nv50_mxm_new,
1549
	.therm = gf119_therm_new,
1550
	.timer = nv41_timer_new,
1551
	.ce[0] = gf100_ce_new,
1552
	.disp = gf119_disp_new,
1553
	.dma = gf119_dma_new,
1554
	.fifo = gf100_fifo_new,
1555
	.gr = gf117_gr_new,
1556 1557 1558
	.mspdec = gf100_mspdec_new,
	.msppp = gf100_msppp_new,
	.msvld = gf100_msvld_new,
1559 1560 1561 1562 1563 1564 1565
//	.pm = gf117_pm_new,
//	.sw = gf100_sw_new,
};

static const struct nvkm_device_chip
nvd9_chipset = {
	.name = "GF119",
1566
	.bar = gf100_bar_new,
1567
	.bios = nvkm_bios_new,
1568
	.bus = gf100_bus_new,
1569
	.clk = gf100_clk_new,
1570
	.devinit = gf100_devinit_new,
1571
	.fb = gf100_fb_new,
1572
	.fuse = gf100_fuse_new,
1573
	.gpio = gf119_gpio_new,
1574
	.i2c = gf119_i2c_new,
1575
	.ibus = gf100_ibus_new,
1576
	.imem = nv50_instmem_new,
1577
	.ltc = gf100_ltc_new,
1578
	.mc = gf106_mc_new,
1579
	.mmu = gf100_mmu_new,
1580
	.mxm = nv50_mxm_new,
1581
	.pmu = gf119_pmu_new,
1582
	.therm = gf119_therm_new,
1583
	.timer = nv41_timer_new,
1584
	.volt = nv40_volt_new,
1585
	.ce[0] = gf100_ce_new,
1586
	.disp = gf119_disp_new,
1587
	.dma = gf119_dma_new,
1588
	.fifo = gf100_fifo_new,
1589
	.gr = gf119_gr_new,
1590 1591 1592
	.mspdec = gf100_mspdec_new,
	.msppp = gf100_msppp_new,
	.msvld = gf100_msvld_new,
1593 1594 1595 1596 1597 1598 1599
//	.pm = gf117_pm_new,
//	.sw = gf100_sw_new,
};

static const struct nvkm_device_chip
nve4_chipset = {
	.name = "GK104",
1600
	.bar = gf100_bar_new,
1601
	.bios = nvkm_bios_new,
1602
	.bus = gf100_bus_new,
1603
	.clk = gk104_clk_new,
1604
	.devinit = gf100_devinit_new,
1605
	.fb = gk104_fb_new,
1606
	.fuse = gf100_fuse_new,
1607
	.gpio = gk104_gpio_new,
1608
	.i2c = gk104_i2c_new,
1609
	.ibus = gk104_ibus_new,
1610
	.imem = nv50_instmem_new,
1611
	.ltc = gk104_ltc_new,
1612
	.mc = gf106_mc_new,
1613
	.mmu = gf100_mmu_new,
1614
	.mxm = nv50_mxm_new,
1615
	.pmu = gk104_pmu_new,
1616
	.therm = gf119_therm_new,
1617
	.timer = nv41_timer_new,
1618
	.volt = nv40_volt_new,
1619 1620 1621
	.ce[0] = gk104_ce_new,
	.ce[1] = gk104_ce_new,
	.ce[2] = gk104_ce_new,
1622
	.disp = gk104_disp_new,
1623
	.dma = gf119_dma_new,
1624
	.fifo = gk104_fifo_new,
1625
	.gr = gk104_gr_new,
1626 1627 1628
	.mspdec = gk104_mspdec_new,
	.msppp = gf100_msppp_new,
	.msvld = gk104_msvld_new,
1629 1630 1631 1632 1633 1634 1635
//	.pm = gk104_pm_new,
//	.sw = gf100_sw_new,
};

static const struct nvkm_device_chip
nve6_chipset = {
	.name = "GK106",
1636
	.bar = gf100_bar_new,
1637
	.bios = nvkm_bios_new,
1638
	.bus = gf100_bus_new,
1639
	.clk = gk104_clk_new,
1640
	.devinit = gf100_devinit_new,
1641
	.fb = gk104_fb_new,
1642
	.fuse = gf100_fuse_new,
1643
	.gpio = gk104_gpio_new,
1644
	.i2c = gk104_i2c_new,
1645
	.ibus = gk104_ibus_new,
1646
	.imem = nv50_instmem_new,
1647
	.ltc = gk104_ltc_new,
1648
	.mc = gf106_mc_new,
1649
	.mmu = gf100_mmu_new,
1650
	.mxm = nv50_mxm_new,
1651
	.pmu = gk104_pmu_new,
1652
	.therm = gf119_therm_new,
1653
	.timer = nv41_timer_new,
1654
	.volt = nv40_volt_new,
1655 1656 1657
	.ce[0] = gk104_ce_new,
	.ce[1] = gk104_ce_new,
	.ce[2] = gk104_ce_new,
1658
	.disp = gk104_disp_new,
1659
	.dma = gf119_dma_new,
1660
	.fifo = gk104_fifo_new,
1661
	.gr = gk104_gr_new,
1662 1663 1664
	.mspdec = gk104_mspdec_new,
	.msppp = gf100_msppp_new,
	.msvld = gk104_msvld_new,
1665 1666 1667 1668 1669 1670 1671
//	.pm = gk104_pm_new,
//	.sw = gf100_sw_new,
};

static const struct nvkm_device_chip
nve7_chipset = {
	.name = "GK107",
1672
	.bar = gf100_bar_new,
1673
	.bios = nvkm_bios_new,
1674
	.bus = gf100_bus_new,
1675
	.clk = gk104_clk_new,
1676
	.devinit = gf100_devinit_new,
1677
	.fb = gk104_fb_new,
1678
	.fuse = gf100_fuse_new,
1679
	.gpio = gk104_gpio_new,
1680
	.i2c = gk104_i2c_new,
1681
	.ibus = gk104_ibus_new,
1682
	.imem = nv50_instmem_new,
1683
	.ltc = gk104_ltc_new,
1684
	.mc = gf106_mc_new,
1685
	.mmu = gf100_mmu_new,
1686
	.mxm = nv50_mxm_new,
1687
	.pmu = gf119_pmu_new,
1688
	.therm = gf119_therm_new,
1689
	.timer = nv41_timer_new,
1690
	.volt = nv40_volt_new,
1691 1692 1693
	.ce[0] = gk104_ce_new,
	.ce[1] = gk104_ce_new,
	.ce[2] = gk104_ce_new,
1694
	.disp = gk104_disp_new,
1695
	.dma = gf119_dma_new,
1696
	.fifo = gk104_fifo_new,
1697
	.gr = gk104_gr_new,
1698 1699 1700
	.mspdec = gk104_mspdec_new,
	.msppp = gf100_msppp_new,
	.msvld = gk104_msvld_new,
1701 1702 1703 1704 1705 1706 1707
//	.pm = gk104_pm_new,
//	.sw = gf100_sw_new,
};

static const struct nvkm_device_chip
nvea_chipset = {
	.name = "GK20A",
1708
	.bar = gk20a_bar_new,
1709
	.bus = gf100_bus_new,
1710
	.clk = gk20a_clk_new,
1711
	.fb = gk20a_fb_new,
1712
	.fuse = gf100_fuse_new,
1713
	.ibus = gk20a_ibus_new,
1714
	.imem = gk20a_instmem_new,
1715
	.ltc = gk104_ltc_new,
1716
	.mc = gk20a_mc_new,
1717
	.mmu = gf100_mmu_new,
1718
	.pmu = gk20a_pmu_new,
1719
	.timer = gk20a_timer_new,
1720
	.volt = gk20a_volt_new,
1721
	.ce[2] = gk104_ce_new,
1722
	.dma = gf119_dma_new,
1723
	.fifo = gk20a_fifo_new,
1724
	.gr = gk20a_gr_new,
1725 1726 1727 1728 1729 1730 1731
//	.pm = gk104_pm_new,
//	.sw = gf100_sw_new,
};

static const struct nvkm_device_chip
nvf0_chipset = {
	.name = "GK110",
1732
	.bar = gf100_bar_new,
1733
	.bios = nvkm_bios_new,
1734
	.bus = gf100_bus_new,
1735
	.clk = gk104_clk_new,
1736
	.devinit = gf100_devinit_new,
1737
	.fb = gk104_fb_new,
1738
	.fuse = gf100_fuse_new,
1739
	.gpio = gk104_gpio_new,
1740
	.i2c = gk104_i2c_new,
1741
	.ibus = gk104_ibus_new,
1742
	.imem = nv50_instmem_new,
1743
	.ltc = gk104_ltc_new,
1744
	.mc = gf106_mc_new,
1745
	.mmu = gf100_mmu_new,
1746
	.mxm = nv50_mxm_new,
1747
	.pmu = gk110_pmu_new,
1748
	.therm = gf119_therm_new,
1749
	.timer = nv41_timer_new,
1750
	.volt = nv40_volt_new,
1751 1752 1753
	.ce[0] = gk104_ce_new,
	.ce[1] = gk104_ce_new,
	.ce[2] = gk104_ce_new,
1754
	.disp = gk110_disp_new,
1755
	.dma = gf119_dma_new,
1756
	.fifo = gk104_fifo_new,
1757
	.gr = gk110_gr_new,
1758 1759 1760
	.mspdec = gk104_mspdec_new,
	.msppp = gf100_msppp_new,
	.msvld = gk104_msvld_new,
1761 1762 1763 1764 1765 1766 1767
//	.pm = gk110_pm_new,
//	.sw = gf100_sw_new,
};

static const struct nvkm_device_chip
nvf1_chipset = {
	.name = "GK110B",
1768
	.bar = gf100_bar_new,
1769
	.bios = nvkm_bios_new,
1770
	.bus = gf100_bus_new,
1771
	.clk = gk104_clk_new,
1772
	.devinit = gf100_devinit_new,
1773
	.fb = gk104_fb_new,
1774
	.fuse = gf100_fuse_new,
1775
	.gpio = gk104_gpio_new,
1776
	.i2c = gf119_i2c_new,
1777
	.ibus = gk104_ibus_new,
1778
	.imem = nv50_instmem_new,
1779
	.ltc = gk104_ltc_new,
1780
	.mc = gf106_mc_new,
1781
	.mmu = gf100_mmu_new,
1782
	.mxm = nv50_mxm_new,
1783
	.pmu = gk110_pmu_new,
1784
	.therm = gf119_therm_new,
1785
	.timer = nv41_timer_new,
1786
	.volt = nv40_volt_new,
1787 1788 1789
	.ce[0] = gk104_ce_new,
	.ce[1] = gk104_ce_new,
	.ce[2] = gk104_ce_new,
1790
	.disp = gk110_disp_new,
1791
	.dma = gf119_dma_new,
1792
	.fifo = gk104_fifo_new,
1793
	.gr = gk110b_gr_new,
1794 1795 1796
	.mspdec = gk104_mspdec_new,
	.msppp = gf100_msppp_new,
	.msvld = gk104_msvld_new,
1797 1798 1799 1800 1801 1802 1803
//	.pm = gk110_pm_new,
//	.sw = gf100_sw_new,
};

static const struct nvkm_device_chip
nv106_chipset = {
	.name = "GK208B",
1804
	.bar = gf100_bar_new,
1805
	.bios = nvkm_bios_new,
1806
	.bus = gf100_bus_new,
1807
	.clk = gk104_clk_new,
1808
	.devinit = gf100_devinit_new,
1809
	.fb = gk104_fb_new,
1810
	.fuse = gf100_fuse_new,
1811
	.gpio = gk104_gpio_new,
1812
	.i2c = gk104_i2c_new,
1813
	.ibus = gk104_ibus_new,
1814
	.imem = nv50_instmem_new,
1815
	.ltc = gk104_ltc_new,
1816
	.mc = gk20a_mc_new,
1817
	.mmu = gf100_mmu_new,
1818
	.mxm = nv50_mxm_new,
1819
	.pmu = gk208_pmu_new,
1820
	.therm = gf119_therm_new,
1821
	.timer = nv41_timer_new,
1822
	.volt = nv40_volt_new,
1823 1824 1825
	.ce[0] = gk104_ce_new,
	.ce[1] = gk104_ce_new,
	.ce[2] = gk104_ce_new,
1826
	.disp = gk110_disp_new,
1827
	.dma = gf119_dma_new,
1828
	.fifo = gk208_fifo_new,
1829
	.gr = gk208_gr_new,
1830 1831 1832
	.mspdec = gk104_mspdec_new,
	.msppp = gf100_msppp_new,
	.msvld = gk104_msvld_new,
1833 1834 1835 1836 1837 1838
//	.sw = gf100_sw_new,
};

static const struct nvkm_device_chip
nv108_chipset = {
	.name = "GK208",
1839
	.bar = gf100_bar_new,
1840
	.bios = nvkm_bios_new,
1841
	.bus = gf100_bus_new,
1842
	.clk = gk104_clk_new,
1843
	.devinit = gf100_devinit_new,
1844
	.fb = gk104_fb_new,
1845
	.fuse = gf100_fuse_new,
1846
	.gpio = gk104_gpio_new,
1847
	.i2c = gk104_i2c_new,
1848
	.ibus = gk104_ibus_new,
1849
	.imem = nv50_instmem_new,
1850
	.ltc = gk104_ltc_new,
1851
	.mc = gk20a_mc_new,
1852
	.mmu = gf100_mmu_new,
1853
	.mxm = nv50_mxm_new,
1854
	.pmu = gk208_pmu_new,
1855
	.therm = gf119_therm_new,
1856
	.timer = nv41_timer_new,
1857
	.volt = nv40_volt_new,
1858 1859 1860
	.ce[0] = gk104_ce_new,
	.ce[1] = gk104_ce_new,
	.ce[2] = gk104_ce_new,
1861
	.disp = gk110_disp_new,
1862
	.dma = gf119_dma_new,
1863
	.fifo = gk208_fifo_new,
1864
	.gr = gk208_gr_new,
1865 1866 1867
	.mspdec = gk104_mspdec_new,
	.msppp = gf100_msppp_new,
	.msvld = gk104_msvld_new,
1868 1869 1870 1871 1872 1873
//	.sw = gf100_sw_new,
};

static const struct nvkm_device_chip
nv117_chipset = {
	.name = "GM107",
1874
	.bar = gf100_bar_new,
1875
	.bios = nvkm_bios_new,
1876
	.bus = gf100_bus_new,
1877
	.clk = gk104_clk_new,
1878
	.devinit = gm107_devinit_new,
1879
	.fb = gm107_fb_new,
1880
	.fuse = gm107_fuse_new,
1881
	.gpio = gk104_gpio_new,
1882
	.i2c = gf119_i2c_new,
1883
	.ibus = gk104_ibus_new,
1884
	.imem = nv50_instmem_new,
1885
	.ltc = gm107_ltc_new,
1886
	.mc = gk20a_mc_new,
1887
	.mmu = gf100_mmu_new,
1888
	.mxm = nv50_mxm_new,
1889
	.pmu = gm107_pmu_new,
1890
	.therm = gm107_therm_new,
1891
	.timer = gk20a_timer_new,
1892 1893
	.ce[0] = gk104_ce_new,
	.ce[2] = gk104_ce_new,
1894
	.disp = gm107_disp_new,
1895
	.dma = gf119_dma_new,
1896
	.fifo = gk208_fifo_new,
1897
	.gr = gm107_gr_new,
1898 1899 1900 1901 1902 1903
//	.sw = gf100_sw_new,
};

static const struct nvkm_device_chip
nv124_chipset = {
	.name = "GM204",
1904
	.bar = gf100_bar_new,
1905
	.bios = nvkm_bios_new,
1906
	.bus = gf100_bus_new,
1907
	.devinit = gm204_devinit_new,
1908
	.fb = gm107_fb_new,
1909
	.fuse = gm107_fuse_new,
1910
	.gpio = gk104_gpio_new,
1911
	.i2c = gm204_i2c_new,
1912
	.ibus = gk104_ibus_new,
1913
	.imem = nv50_instmem_new,
1914
	.ltc = gm107_ltc_new,
1915
	.mc = gk20a_mc_new,
1916
	.mmu = gf100_mmu_new,
1917
	.mxm = nv50_mxm_new,
1918
	.pmu = gm107_pmu_new,
1919
	.timer = gk20a_timer_new,
1920 1921 1922
	.ce[0] = gm204_ce_new,
	.ce[1] = gm204_ce_new,
	.ce[2] = gm204_ce_new,
1923
	.disp = gm204_disp_new,
1924
	.dma = gf119_dma_new,
1925
	.fifo = gm204_fifo_new,
1926
	.gr = gm204_gr_new,
1927 1928 1929 1930 1931 1932
//	.sw = gf100_sw_new,
};

static const struct nvkm_device_chip
nv126_chipset = {
	.name = "GM206",
1933
	.bar = gf100_bar_new,
1934
	.bios = nvkm_bios_new,
1935
	.bus = gf100_bus_new,
1936
	.devinit = gm204_devinit_new,
1937
	.fb = gm107_fb_new,
1938
	.fuse = gm107_fuse_new,
1939
	.gpio = gk104_gpio_new,
1940
	.i2c = gm204_i2c_new,
1941
	.ibus = gk104_ibus_new,
1942
	.imem = nv50_instmem_new,
1943
	.ltc = gm107_ltc_new,
1944
	.mc = gk20a_mc_new,
1945
	.mmu = gf100_mmu_new,
1946
	.mxm = nv50_mxm_new,
1947
	.pmu = gm107_pmu_new,
1948
	.timer = gk20a_timer_new,
1949 1950 1951
	.ce[0] = gm204_ce_new,
	.ce[1] = gm204_ce_new,
	.ce[2] = gm204_ce_new,
1952
	.disp = gm204_disp_new,
1953
	.dma = gf119_dma_new,
1954
	.fifo = gm204_fifo_new,
1955
	.gr = gm206_gr_new,
1956 1957 1958 1959 1960 1961
//	.sw = gf100_sw_new,
};

static const struct nvkm_device_chip
nv12b_chipset = {
	.name = "GM20B",
1962
	.bar = gk20a_bar_new,
1963
	.bus = gf100_bus_new,
1964
	.fb = gk20a_fb_new,
1965
	.fuse = gm107_fuse_new,
1966
	.ibus = gk20a_ibus_new,
1967
	.imem = gk20a_instmem_new,
1968
	.ltc = gm107_ltc_new,
1969
	.mc = gk20a_mc_new,
1970 1971
	.mmu = gf100_mmu_new,
	.mmu = gf100_mmu_new,
1972
	.timer = gk20a_timer_new,
1973
	.ce[2] = gm204_ce_new,
1974
	.dma = gf119_dma_new,
1975
	.fifo = gm20b_fifo_new,
1976
	.gr = gm20b_gr_new,
1977 1978 1979
//	.sw = gf100_sw_new,
};

1980
#include <core/client.h>
1981

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

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

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

static const struct nvkm_event_func
2024 2025
nvkm_device_event_func = {
	.ctor = nvkm_device_event_ctor,
2026 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
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;
}

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

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

	nvkm_acpi_fini(device);
2116 2117

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

2125 2126 2127

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

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

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

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

2146
static int
2147 2148
nvkm_device_preinit(struct nvkm_device *device)
{
2149 2150
	struct nvkm_subdev *subdev;
	int ret, i;
2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161
	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;
	}

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

2170 2171 2172
	ret = nvkm_devinit_post(device->devinit, &device->disable_mask);
	if (ret)
		goto fail;
2173

2174 2175 2176 2177 2178 2179 2180 2181 2182
	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;
}

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

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

2194 2195 2196 2197
	nvkm_device_fini(device, false);

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

2199
	for (i = 0, c = 0; i < NVDEV_SUBDEV_NR; i++) {
2200
#define _(s,m) case s: if (device->oclass[s] && !device->m) {          \
2201
		ret = nvkm_object_old(nv_object(device), NULL,                \
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 2267
				       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) {
2268 2269
			if ((subdev = nvkm_device_subdev(device, c++))) {
				ret = nvkm_subdev_init(subdev);
2270 2271 2272 2273 2274 2275
				if (ret)
					goto fail;
			}
		}
	}

2276 2277 2278 2279 2280 2281
	nvkm_acpi_init(device);

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

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

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

A
Alexandre Courbot 已提交
2292
resource_size_t
2293
nv_device_resource_start(struct nvkm_device *device, unsigned int bar)
A
Alexandre Courbot 已提交
2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307
{
	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
2308
nv_device_resource_len(struct nvkm_device *device, unsigned int bar)
A
Alexandre Courbot 已提交
2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322
{
	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
2323
nv_device_get_irq(struct nvkm_device *device, bool stall)
A
Alexandre Courbot 已提交
2324 2325 2326 2327 2328 2329 2330 2331 2332
{
	if (nv_device_is_pci(device)) {
		return device->pdev->irq;
	} else {
		return platform_get_irq_byname(device->platformdev,
					       stall ? "stall" : "nonstall");
	}
}

2333 2334 2335 2336
void
nvkm_device_del(struct nvkm_device **pdevice)
{
	struct nvkm_device *device = *pdevice;
2337
	int i;
2338 2339
	if (device) {
		mutex_lock(&nv_devices_mutex);
2340 2341 2342 2343 2344 2345
		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);
		}
2346 2347

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

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

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

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

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

2366
int
2367 2368 2369 2370 2371 2372
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)
2373
{
2374
	struct nvkm_subdev *subdev;
2375 2376 2377
	u64 mmio_base, mmio_size;
	u32 boot0, strap;
	void __iomem *map;
2378
	int ret = -EEXIST;
2379
	int i;
2380 2381

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

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

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

2409
	ret = nvkm_event_init(&nvkm_device_event_func, 1, 1, &device->event);
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 2492
	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;
		}

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 2563
		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:
2564 2565 2566 2567
			nvdev_error(device, "unknown chipset (%08x)\n", boot0);
			goto done;
		}

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

		/* 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 {
2585
		device->chip = &null_chipset;
2586 2587
	}

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;
}