]> bbs.cooldavid.org Git - net-next-2.6.git/blob - drivers/video/via/via-core.c
Merge branch 'v4l_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab...
[net-next-2.6.git] / drivers / video / via / via-core.c
1 /*
2  * Copyright 1998-2009 VIA Technologies, Inc. All Rights Reserved.
3  * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved.
4  * Copyright 2009 Jonathan Corbet <corbet@lwn.net>
5  */
6
7 /*
8  * Core code for the Via multifunction framebuffer device.
9  */
10 #include <linux/via-core.h>
11 #include <linux/via_i2c.h>
12 #include <linux/via-gpio.h>
13 #include "global.h"
14
15 #include <linux/module.h>
16 #include <linux/interrupt.h>
17 #include <linux/platform_device.h>
18
19 /*
20  * The default port config.
21  */
22 static struct via_port_cfg adap_configs[] = {
23         [VIA_PORT_26]   = { VIA_PORT_I2C,  VIA_MODE_I2C, VIASR, 0x26 },
24         [VIA_PORT_31]   = { VIA_PORT_I2C,  VIA_MODE_I2C, VIASR, 0x31 },
25         [VIA_PORT_25]   = { VIA_PORT_GPIO, VIA_MODE_GPIO, VIASR, 0x25 },
26         [VIA_PORT_2C]   = { VIA_PORT_GPIO, VIA_MODE_I2C, VIASR, 0x2c },
27         [VIA_PORT_3D]   = { VIA_PORT_GPIO, VIA_MODE_GPIO, VIASR, 0x3d },
28         { 0, 0, 0, 0 }
29 };
30
31 /*
32  * We currently only support one viafb device (will there ever be
33  * more than one?), so just declare it globally here.
34  */
35 static struct viafb_dev global_dev;
36
37
38 /*
39  * Basic register access; spinlock required.
40  */
41 static inline void viafb_mmio_write(int reg, u32 v)
42 {
43         iowrite32(v, global_dev.engine_mmio + reg);
44 }
45
46 static inline int viafb_mmio_read(int reg)
47 {
48         return ioread32(global_dev.engine_mmio + reg);
49 }
50
51 /* ---------------------------------------------------------------------- */
52 /*
53  * Interrupt management.  We have a single IRQ line for a lot of
54  * different functions, so we need to share it.  The design here
55  * is that we don't want to reimplement the shared IRQ code here;
56  * we also want to avoid having contention for a single handler thread.
57  * So each subdev driver which needs interrupts just requests
58  * them directly from the kernel.  We just have what's needed for
59  * overall access to the interrupt control register.
60  */
61
62 /*
63  * Which interrupts are enabled now?
64  */
65 static u32 viafb_enabled_ints;
66
67 static void __devinit viafb_int_init(void)
68 {
69         viafb_enabled_ints = 0;
70
71         viafb_mmio_write(VDE_INTERRUPT, 0);
72 }
73
74 /*
75  * Allow subdevs to ask for specific interrupts to be enabled.  These
76  * functions must be called with reg_lock held
77  */
78 void viafb_irq_enable(u32 mask)
79 {
80         viafb_enabled_ints |= mask;
81         viafb_mmio_write(VDE_INTERRUPT, viafb_enabled_ints | VDE_I_ENABLE);
82 }
83 EXPORT_SYMBOL_GPL(viafb_irq_enable);
84
85 void viafb_irq_disable(u32 mask)
86 {
87         viafb_enabled_ints &= ~mask;
88         if (viafb_enabled_ints == 0)
89                 viafb_mmio_write(VDE_INTERRUPT, 0);  /* Disable entirely */
90         else
91                 viafb_mmio_write(VDE_INTERRUPT,
92                                 viafb_enabled_ints | VDE_I_ENABLE);
93 }
94 EXPORT_SYMBOL_GPL(viafb_irq_disable);
95
96 /* ---------------------------------------------------------------------- */
97 /*
98  * Currently, the camera driver is the only user of the DMA code, so we
99  * only compile it in if the camera driver is being built.  Chances are,
100  * most viafb systems will not need to have this extra code for a while.
101  * As soon as another user comes long, the ifdef can be removed.
102  */
103 #if defined(CONFIG_VIDEO_VIA_CAMERA) || defined(CONFIG_VIDEO_VIA_CAMERA_MODULE)
104 /*
105  * Access to the DMA engine.  This currently provides what the camera
106  * driver needs (i.e. outgoing only) but is easily expandable if need
107  * be.
108  */
109
110 /*
111  * There are four DMA channels in the vx855.  For now, we only
112  * use one of them, though.  Most of the time, the DMA channel
113  * will be idle, so we keep the IRQ handler unregistered except
114  * when some subsystem has indicated an interest.
115  */
116 static int viafb_dma_users;
117 static DECLARE_COMPLETION(viafb_dma_completion);
118 /*
119  * This mutex protects viafb_dma_users and our global interrupt
120  * registration state; it also serializes access to the DMA
121  * engine.
122  */
123 static DEFINE_MUTEX(viafb_dma_lock);
124
125 /*
126  * The VX855 DMA descriptor (used for s/g transfers) looks
127  * like this.
128  */
129 struct viafb_vx855_dma_descr {
130         u32     addr_low;       /* Low part of phys addr */
131         u32     addr_high;      /* High 12 bits of addr */
132         u32     fb_offset;      /* Offset into FB memory */
133         u32     seg_size;       /* Size, 16-byte units */
134         u32     tile_mode;      /* "tile mode" setting */
135         u32     next_desc_low;  /* Next descriptor addr */
136         u32     next_desc_high;
137         u32     pad;            /* Fill out to 64 bytes */
138 };
139
140 /*
141  * Flags added to the "next descriptor low" pointers
142  */
143 #define VIAFB_DMA_MAGIC         0x01  /* ??? Just has to be there */
144 #define VIAFB_DMA_FINAL_SEGMENT 0x02  /* Final segment */
145
146 /*
147  * The completion IRQ handler.
148  */
149 static irqreturn_t viafb_dma_irq(int irq, void *data)
150 {
151         int csr;
152         irqreturn_t ret = IRQ_NONE;
153
154         spin_lock(&global_dev.reg_lock);
155         csr = viafb_mmio_read(VDMA_CSR0);
156         if (csr & VDMA_C_DONE) {
157                 viafb_mmio_write(VDMA_CSR0, VDMA_C_DONE);
158                 complete(&viafb_dma_completion);
159                 ret = IRQ_HANDLED;
160         }
161         spin_unlock(&global_dev.reg_lock);
162         return ret;
163 }
164
165 /*
166  * Indicate a need for DMA functionality.
167  */
168 int viafb_request_dma(void)
169 {
170         int ret = 0;
171
172         /*
173          * Only VX855 is supported currently.
174          */
175         if (global_dev.chip_type != UNICHROME_VX855)
176                 return -ENODEV;
177         /*
178          * Note the new user and set up our interrupt handler
179          * if need be.
180          */
181         mutex_lock(&viafb_dma_lock);
182         viafb_dma_users++;
183         if (viafb_dma_users == 1) {
184                 ret = request_irq(global_dev.pdev->irq, viafb_dma_irq,
185                                 IRQF_SHARED, "via-dma", &viafb_dma_users);
186                 if (ret)
187                         viafb_dma_users--;
188                 else
189                         viafb_irq_enable(VDE_I_DMA0TDEN);
190         }
191         mutex_unlock(&viafb_dma_lock);
192         return ret;
193 }
194 EXPORT_SYMBOL_GPL(viafb_request_dma);
195
196 void viafb_release_dma(void)
197 {
198         mutex_lock(&viafb_dma_lock);
199         viafb_dma_users--;
200         if (viafb_dma_users == 0) {
201                 viafb_irq_disable(VDE_I_DMA0TDEN);
202                 free_irq(global_dev.pdev->irq, &viafb_dma_users);
203         }
204         mutex_unlock(&viafb_dma_lock);
205 }
206 EXPORT_SYMBOL_GPL(viafb_release_dma);
207
208
209 #if 0
210 /*
211  * Copy a single buffer from FB memory, synchronously.  This code works
212  * but is not currently used.
213  */
214 void viafb_dma_copy_out(unsigned int offset, dma_addr_t paddr, int len)
215 {
216         unsigned long flags;
217         int csr;
218
219         mutex_lock(&viafb_dma_lock);
220         init_completion(&viafb_dma_completion);
221         /*
222          * Program the controller.
223          */
224         spin_lock_irqsave(&global_dev.reg_lock, flags);
225         viafb_mmio_write(VDMA_CSR0, VDMA_C_ENABLE|VDMA_C_DONE);
226         /* Enable ints; must happen after CSR0 write! */
227         viafb_mmio_write(VDMA_MR0, VDMA_MR_TDIE);
228         viafb_mmio_write(VDMA_MARL0, (int) (paddr & 0xfffffff0));
229         viafb_mmio_write(VDMA_MARH0, (int) ((paddr >> 28) & 0xfff));
230         /* Data sheet suggests DAR0 should be <<4, but it lies */
231         viafb_mmio_write(VDMA_DAR0, offset);
232         viafb_mmio_write(VDMA_DQWCR0, len >> 4);
233         viafb_mmio_write(VDMA_TMR0, 0);
234         viafb_mmio_write(VDMA_DPRL0, 0);
235         viafb_mmio_write(VDMA_DPRH0, 0);
236         viafb_mmio_write(VDMA_PMR0, 0);
237         csr = viafb_mmio_read(VDMA_CSR0);
238         viafb_mmio_write(VDMA_CSR0, VDMA_C_ENABLE|VDMA_C_START);
239         spin_unlock_irqrestore(&global_dev.reg_lock, flags);
240         /*
241          * Now we just wait until the interrupt handler says
242          * we're done.
243          */
244         wait_for_completion_interruptible(&viafb_dma_completion);
245         viafb_mmio_write(VDMA_MR0, 0); /* Reset int enable */
246         mutex_unlock(&viafb_dma_lock);
247 }
248 EXPORT_SYMBOL_GPL(viafb_dma_copy_out);
249 #endif
250
251 /*
252  * Do a scatter/gather DMA copy from FB memory.  You must have done
253  * a successful call to viafb_request_dma() first.
254  */
255 int viafb_dma_copy_out_sg(unsigned int offset, struct scatterlist *sg, int nsg)
256 {
257         struct viafb_vx855_dma_descr *descr;
258         void *descrpages;
259         dma_addr_t descr_handle;
260         unsigned long flags;
261         int i;
262         struct scatterlist *sgentry;
263         dma_addr_t nextdesc;
264
265         /*
266          * Get a place to put the descriptors.
267          */
268         descrpages = dma_alloc_coherent(&global_dev.pdev->dev,
269                         nsg*sizeof(struct viafb_vx855_dma_descr),
270                         &descr_handle, GFP_KERNEL);
271         if (descrpages == NULL) {
272                 dev_err(&global_dev.pdev->dev, "Unable to get descr page.\n");
273                 return -ENOMEM;
274         }
275         mutex_lock(&viafb_dma_lock);
276         /*
277          * Fill them in.
278          */
279         descr = descrpages;
280         nextdesc = descr_handle + sizeof(struct viafb_vx855_dma_descr);
281         for_each_sg(sg, sgentry, nsg, i) {
282                 dma_addr_t paddr = sg_dma_address(sgentry);
283                 descr->addr_low = paddr & 0xfffffff0;
284                 descr->addr_high = ((u64) paddr >> 32) & 0x0fff;
285                 descr->fb_offset = offset;
286                 descr->seg_size = sg_dma_len(sgentry) >> 4;
287                 descr->tile_mode = 0;
288                 descr->next_desc_low = (nextdesc&0xfffffff0) | VIAFB_DMA_MAGIC;
289                 descr->next_desc_high = ((u64) nextdesc >> 32) & 0x0fff;
290                 descr->pad = 0xffffffff;  /* VIA driver does this */
291                 offset += sg_dma_len(sgentry);
292                 nextdesc += sizeof(struct viafb_vx855_dma_descr);
293                 descr++;
294         }
295         descr[-1].next_desc_low = VIAFB_DMA_FINAL_SEGMENT|VIAFB_DMA_MAGIC;
296         /*
297          * Program the engine.
298          */
299         spin_lock_irqsave(&global_dev.reg_lock, flags);
300         init_completion(&viafb_dma_completion);
301         viafb_mmio_write(VDMA_DQWCR0, 0);
302         viafb_mmio_write(VDMA_CSR0, VDMA_C_ENABLE|VDMA_C_DONE);
303         viafb_mmio_write(VDMA_MR0, VDMA_MR_TDIE | VDMA_MR_CHAIN);
304         viafb_mmio_write(VDMA_DPRL0, descr_handle | VIAFB_DMA_MAGIC);
305         viafb_mmio_write(VDMA_DPRH0,
306                         (((u64)descr_handle >> 32) & 0x0fff) | 0xf0000);
307         (void) viafb_mmio_read(VDMA_CSR0);
308         viafb_mmio_write(VDMA_CSR0, VDMA_C_ENABLE|VDMA_C_START);
309         spin_unlock_irqrestore(&global_dev.reg_lock, flags);
310         /*
311          * Now we just wait until the interrupt handler says
312          * we're done.  Except that, actually, we need to wait a little
313          * longer: the interrupts seem to jump the gun a little and we
314          * get corrupted frames sometimes.
315          */
316         wait_for_completion_timeout(&viafb_dma_completion, 1);
317         msleep(1);
318         if ((viafb_mmio_read(VDMA_CSR0)&VDMA_C_DONE) == 0)
319                 printk(KERN_ERR "VIA DMA timeout!\n");
320         /*
321          * Clean up and we're done.
322          */
323         viafb_mmio_write(VDMA_CSR0, VDMA_C_DONE);
324         viafb_mmio_write(VDMA_MR0, 0); /* Reset int enable */
325         mutex_unlock(&viafb_dma_lock);
326         dma_free_coherent(&global_dev.pdev->dev,
327                         nsg*sizeof(struct viafb_vx855_dma_descr), descrpages,
328                         descr_handle);
329         return 0;
330 }
331 EXPORT_SYMBOL_GPL(viafb_dma_copy_out_sg);
332 #endif /* CONFIG_VIDEO_VIA_CAMERA */
333
334 /* ---------------------------------------------------------------------- */
335 /*
336  * Figure out how big our framebuffer memory is.  Kind of ugly,
337  * but evidently we can't trust the information found in the
338  * fbdev configuration area.
339  */
340 static u16 via_function3[] = {
341         CLE266_FUNCTION3, KM400_FUNCTION3, CN400_FUNCTION3, CN700_FUNCTION3,
342         CX700_FUNCTION3, KM800_FUNCTION3, KM890_FUNCTION3, P4M890_FUNCTION3,
343         P4M900_FUNCTION3, VX800_FUNCTION3, VX855_FUNCTION3, VX900_FUNCTION3,
344 };
345
346 /* Get the BIOS-configured framebuffer size from PCI configuration space
347  * of function 3 in the respective chipset */
348 static int viafb_get_fb_size_from_pci(int chip_type)
349 {
350         int i;
351         u8 offset = 0;
352         u32 FBSize;
353         u32 VideoMemSize;
354
355         /* search for the "FUNCTION3" device in this chipset */
356         for (i = 0; i < ARRAY_SIZE(via_function3); i++) {
357                 struct pci_dev *pdev;
358
359                 pdev = pci_get_device(PCI_VENDOR_ID_VIA, via_function3[i],
360                                       NULL);
361                 if (!pdev)
362                         continue;
363
364                 DEBUG_MSG(KERN_INFO "Device ID = %x\n", pdev->device);
365
366                 switch (pdev->device) {
367                 case CLE266_FUNCTION3:
368                 case KM400_FUNCTION3:
369                         offset = 0xE0;
370                         break;
371                 case CN400_FUNCTION3:
372                 case CN700_FUNCTION3:
373                 case CX700_FUNCTION3:
374                 case KM800_FUNCTION3:
375                 case KM890_FUNCTION3:
376                 case P4M890_FUNCTION3:
377                 case P4M900_FUNCTION3:
378                 case VX800_FUNCTION3:
379                 case VX855_FUNCTION3:
380                 case VX900_FUNCTION3:
381                 /*case CN750_FUNCTION3: */
382                         offset = 0xA0;
383                         break;
384                 }
385
386                 if (!offset)
387                         break;
388
389                 pci_read_config_dword(pdev, offset, &FBSize);
390                 pci_dev_put(pdev);
391         }
392
393         if (!offset) {
394                 printk(KERN_ERR "cannot determine framebuffer size\n");
395                 return -EIO;
396         }
397
398         FBSize = FBSize & 0x00007000;
399         DEBUG_MSG(KERN_INFO "FB Size = %x\n", FBSize);
400
401         if (chip_type < UNICHROME_CX700) {
402                 switch (FBSize) {
403                 case 0x00004000:
404                         VideoMemSize = (16 << 20);      /*16M */
405                         break;
406
407                 case 0x00005000:
408                         VideoMemSize = (32 << 20);      /*32M */
409                         break;
410
411                 case 0x00006000:
412                         VideoMemSize = (64 << 20);      /*64M */
413                         break;
414
415                 default:
416                         VideoMemSize = (32 << 20);      /*32M */
417                         break;
418                 }
419         } else {
420                 switch (FBSize) {
421                 case 0x00001000:
422                         VideoMemSize = (8 << 20);       /*8M */
423                         break;
424
425                 case 0x00002000:
426                         VideoMemSize = (16 << 20);      /*16M */
427                         break;
428
429                 case 0x00003000:
430                         VideoMemSize = (32 << 20);      /*32M */
431                         break;
432
433                 case 0x00004000:
434                         VideoMemSize = (64 << 20);      /*64M */
435                         break;
436
437                 case 0x00005000:
438                         VideoMemSize = (128 << 20);     /*128M */
439                         break;
440
441                 case 0x00006000:
442                         VideoMemSize = (256 << 20);     /*256M */
443                         break;
444
445                 case 0x00007000:        /* Only on VX855/875 */
446                         VideoMemSize = (512 << 20);     /*512M */
447                         break;
448
449                 default:
450                         VideoMemSize = (32 << 20);      /*32M */
451                         break;
452                 }
453         }
454
455         return VideoMemSize;
456 }
457
458
459 /*
460  * Figure out and map our MMIO regions.
461  */
462 static int __devinit via_pci_setup_mmio(struct viafb_dev *vdev)
463 {
464         int ret;
465         /*
466          * Hook up to the device registers.  Note that we soldier
467          * on if it fails; the framebuffer can operate (without
468          * acceleration) without this region.
469          */
470         vdev->engine_start = pci_resource_start(vdev->pdev, 1);
471         vdev->engine_len = pci_resource_len(vdev->pdev, 1);
472         vdev->engine_mmio = ioremap_nocache(vdev->engine_start,
473                         vdev->engine_len);
474         if (vdev->engine_mmio == NULL)
475                 dev_err(&vdev->pdev->dev,
476                                 "Unable to map engine MMIO; operation will be "
477                                 "slow and crippled.\n");
478         /*
479          * Map in framebuffer memory.  For now, failure here is
480          * fatal.  Unfortunately, in the absence of significant
481          * vmalloc space, failure here is also entirely plausible.
482          * Eventually we want to move away from mapping this
483          * entire region.
484          */
485         if (vdev->chip_type == UNICHROME_VX900)
486                 vdev->fbmem_start = pci_resource_start(vdev->pdev, 2);
487         else
488                 vdev->fbmem_start = pci_resource_start(vdev->pdev, 0);
489         ret = vdev->fbmem_len = viafb_get_fb_size_from_pci(vdev->chip_type);
490         if (ret < 0)
491                 goto out_unmap;
492         vdev->fbmem = ioremap_nocache(vdev->fbmem_start, vdev->fbmem_len);
493         if (vdev->fbmem == NULL) {
494                 ret = -ENOMEM;
495                 goto out_unmap;
496         }
497         return 0;
498 out_unmap:
499         iounmap(vdev->engine_mmio);
500         return ret;
501 }
502
503 static void via_pci_teardown_mmio(struct viafb_dev *vdev)
504 {
505         iounmap(vdev->fbmem);
506         iounmap(vdev->engine_mmio);
507 }
508
509 /*
510  * Create our subsidiary devices.
511  */
512 static struct viafb_subdev_info {
513         char *name;
514         struct platform_device *platdev;
515 } viafb_subdevs[] = {
516         {
517                 .name = "viafb-gpio",
518         },
519         {
520                 .name = "viafb-i2c",
521         },
522 #if defined(CONFIG_VIDEO_VIA_CAMERA) || defined(CONFIG_VIDEO_VIA_CAMERA_MODULE)
523         {
524                 .name = "viafb-camera",
525         },
526 #endif
527 };
528 #define N_SUBDEVS ARRAY_SIZE(viafb_subdevs)
529
530 static int __devinit via_create_subdev(struct viafb_dev *vdev,
531                 struct viafb_subdev_info *info)
532 {
533         int ret;
534
535         info->platdev = platform_device_alloc(info->name, -1);
536         if (!info->platdev) {
537                 dev_err(&vdev->pdev->dev, "Unable to allocate pdev %s\n",
538                         info->name);
539                 return -ENOMEM;
540         }
541         info->platdev->dev.parent = &vdev->pdev->dev;
542         info->platdev->dev.platform_data = vdev;
543         ret = platform_device_add(info->platdev);
544         if (ret) {
545                 dev_err(&vdev->pdev->dev, "Unable to add pdev %s\n",
546                                 info->name);
547                 platform_device_put(info->platdev);
548                 info->platdev = NULL;
549         }
550         return ret;
551 }
552
553 static int __devinit via_setup_subdevs(struct viafb_dev *vdev)
554 {
555         int i;
556
557         /*
558          * Ignore return values.  Even if some of the devices
559          * fail to be created, we'll still be able to use some
560          * of the rest.
561          */
562         for (i = 0; i < N_SUBDEVS; i++)
563                 via_create_subdev(vdev, viafb_subdevs + i);
564         return 0;
565 }
566
567 static void via_teardown_subdevs(void)
568 {
569         int i;
570
571         for (i = 0; i < N_SUBDEVS; i++)
572                 if (viafb_subdevs[i].platdev) {
573                         viafb_subdevs[i].platdev->dev.platform_data = NULL;
574                         platform_device_unregister(viafb_subdevs[i].platdev);
575                 }
576 }
577
578
579 static int __devinit via_pci_probe(struct pci_dev *pdev,
580                 const struct pci_device_id *ent)
581 {
582         int ret;
583
584         ret = pci_enable_device(pdev);
585         if (ret)
586                 return ret;
587         /*
588          * Global device initialization.
589          */
590         memset(&global_dev, 0, sizeof(global_dev));
591         global_dev.pdev = pdev;
592         global_dev.chip_type = ent->driver_data;
593         global_dev.port_cfg = adap_configs;
594         spin_lock_init(&global_dev.reg_lock);
595         ret = via_pci_setup_mmio(&global_dev);
596         if (ret)
597                 goto out_disable;
598         /*
599          * Set up interrupts and create our subdevices.  Continue even if
600          * some things fail.
601          */
602         viafb_int_init();
603         via_setup_subdevs(&global_dev);
604         /*
605          * Set up the framebuffer device
606          */
607         ret = via_fb_pci_probe(&global_dev);
608         if (ret)
609                 goto out_subdevs;
610         return 0;
611
612 out_subdevs:
613         via_teardown_subdevs();
614         via_pci_teardown_mmio(&global_dev);
615 out_disable:
616         pci_disable_device(pdev);
617         return ret;
618 }
619
620 static void __devexit via_pci_remove(struct pci_dev *pdev)
621 {
622         via_teardown_subdevs();
623         via_fb_pci_remove(pdev);
624         via_pci_teardown_mmio(&global_dev);
625         pci_disable_device(pdev);
626 }
627
628
629 static struct pci_device_id via_pci_table[] __devinitdata = {
630         { PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_CLE266_DID),
631           .driver_data = UNICHROME_CLE266 },
632         { PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_K400_DID),
633           .driver_data = UNICHROME_K400 },
634         { PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_K800_DID),
635           .driver_data = UNICHROME_K800 },
636         { PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_PM800_DID),
637           .driver_data = UNICHROME_PM800 },
638         { PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_CN700_DID),
639           .driver_data = UNICHROME_CN700 },
640         { PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_CX700_DID),
641           .driver_data = UNICHROME_CX700 },
642         { PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_CN750_DID),
643           .driver_data = UNICHROME_CN750 },
644         { PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_K8M890_DID),
645           .driver_data = UNICHROME_K8M890 },
646         { PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_P4M890_DID),
647           .driver_data = UNICHROME_P4M890 },
648         { PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_P4M900_DID),
649           .driver_data = UNICHROME_P4M900 },
650         { PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_VX800_DID),
651           .driver_data = UNICHROME_VX800 },
652         { PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_VX855_DID),
653           .driver_data = UNICHROME_VX855 },
654         { PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_VX900_DID),
655           .driver_data = UNICHROME_VX900 },
656         { }
657 };
658 MODULE_DEVICE_TABLE(pci, via_pci_table);
659
660 static struct pci_driver via_driver = {
661         .name           = "viafb",
662         .id_table       = via_pci_table,
663         .probe          = via_pci_probe,
664         .remove         = __devexit_p(via_pci_remove),
665 #ifdef CONFIG_PM
666         .suspend        = viafb_suspend,
667         .resume         = viafb_resume,
668 #endif
669 };
670
671 static int __init via_core_init(void)
672 {
673         int ret;
674
675         ret = viafb_init();
676         if (ret)
677                 return ret;
678         viafb_i2c_init();
679         viafb_gpio_init();
680         return pci_register_driver(&via_driver);
681 }
682
683 static void __exit via_core_exit(void)
684 {
685         pci_unregister_driver(&via_driver);
686         viafb_gpio_exit();
687         viafb_i2c_exit();
688         viafb_exit();
689 }
690
691 module_init(via_core_init);
692 module_exit(via_core_exit);