diff options
Diffstat (limited to 'drivers/video/via/via-core.c')
-rw-r--r-- | drivers/video/via/via-core.c | 116 |
1 files changed, 116 insertions, 0 deletions
diff --git a/drivers/video/via/via-core.c b/drivers/video/via/via-core.c new file mode 100644 index 000000000000..e7201470cf35 --- /dev/null +++ b/drivers/video/via/via-core.c | |||
@@ -0,0 +1,116 @@ | |||
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/module.h> | ||
11 | #include <linux/platform_device.h> | ||
12 | #include "global.h" /* Includes everything under the sun */ | ||
13 | |||
14 | /* | ||
15 | * The default port config. | ||
16 | */ | ||
17 | static struct via_port_cfg adap_configs[] = { | ||
18 | [VIA_PORT_26] = { VIA_PORT_I2C, VIA_MODE_OFF, VIASR, 0x26 }, | ||
19 | [VIA_PORT_31] = { VIA_PORT_I2C, VIA_MODE_I2C, VIASR, 0x31 }, | ||
20 | [VIA_PORT_25] = { VIA_PORT_GPIO, VIA_MODE_GPIO, VIASR, 0x25 }, | ||
21 | [VIA_PORT_2C] = { VIA_PORT_GPIO, VIA_MODE_I2C, VIASR, 0x2c }, | ||
22 | [VIA_PORT_3D] = { VIA_PORT_GPIO, VIA_MODE_GPIO, VIASR, 0x3d }, | ||
23 | { 0, 0, 0, 0 } | ||
24 | }; | ||
25 | |||
26 | |||
27 | static int __devinit via_pci_probe(struct pci_dev *pdev, | ||
28 | const struct pci_device_id *ent) | ||
29 | { | ||
30 | int ret; | ||
31 | |||
32 | ret = pci_enable_device(pdev); | ||
33 | if (ret) | ||
34 | return ret; | ||
35 | /* | ||
36 | * Create the I2C busses. Bailing out on failure seems extreme, | ||
37 | * but that's what the code did before. | ||
38 | */ | ||
39 | ret = viafb_create_i2c_busses(adap_configs); | ||
40 | if (ret) | ||
41 | goto out_disable; | ||
42 | /* | ||
43 | * Set up the framebuffer. | ||
44 | */ | ||
45 | ret = via_fb_pci_probe(pdev, ent); | ||
46 | if (ret) | ||
47 | goto out_i2c; | ||
48 | return 0; | ||
49 | |||
50 | out_i2c: | ||
51 | viafb_delete_i2c_busses(); | ||
52 | out_disable: | ||
53 | pci_disable_device(pdev); | ||
54 | return ret; | ||
55 | } | ||
56 | |||
57 | static void __devexit via_pci_remove(struct pci_dev *pdev) | ||
58 | { | ||
59 | viafb_delete_i2c_busses(); | ||
60 | via_fb_pci_remove(pdev); | ||
61 | pci_disable_device(pdev); | ||
62 | } | ||
63 | |||
64 | |||
65 | static struct pci_device_id via_pci_table[] __devinitdata = { | ||
66 | { PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_CLE266_DID), | ||
67 | .driver_data = UNICHROME_CLE266 }, | ||
68 | { PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_PM800_DID), | ||
69 | .driver_data = UNICHROME_PM800 }, | ||
70 | { PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_K400_DID), | ||
71 | .driver_data = UNICHROME_K400 }, | ||
72 | { PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_K800_DID), | ||
73 | .driver_data = UNICHROME_K800 }, | ||
74 | { PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_P4M890_DID), | ||
75 | .driver_data = UNICHROME_CN700 }, | ||
76 | { PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_K8M890_DID), | ||
77 | .driver_data = UNICHROME_K8M890 }, | ||
78 | { PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_CX700_DID), | ||
79 | .driver_data = UNICHROME_CX700 }, | ||
80 | { PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_P4M900_DID), | ||
81 | .driver_data = UNICHROME_P4M900 }, | ||
82 | { PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_CN750_DID), | ||
83 | .driver_data = UNICHROME_CN750 }, | ||
84 | { PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_VX800_DID), | ||
85 | .driver_data = UNICHROME_VX800 }, | ||
86 | { PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_VX855_DID), | ||
87 | .driver_data = UNICHROME_VX855 }, | ||
88 | { } | ||
89 | }; | ||
90 | MODULE_DEVICE_TABLE(pci, via_pci_table); | ||
91 | |||
92 | static struct pci_driver via_driver = { | ||
93 | .name = "viafb", | ||
94 | .id_table = via_pci_table, | ||
95 | .probe = via_pci_probe, | ||
96 | .remove = __devexit_p(via_pci_remove), | ||
97 | }; | ||
98 | |||
99 | static int __init via_core_init(void) | ||
100 | { | ||
101 | int ret; | ||
102 | |||
103 | ret = viafb_init(); | ||
104 | if (ret) | ||
105 | return ret; | ||
106 | return pci_register_driver(&via_driver); | ||
107 | } | ||
108 | |||
109 | static void __exit via_core_exit(void) | ||
110 | { | ||
111 | pci_unregister_driver(&via_driver); | ||
112 | viafb_exit(); | ||
113 | } | ||
114 | |||
115 | module_init(via_core_init); | ||
116 | module_exit(via_core_exit); | ||