repo init
[linux-rt-nao.git] / lib / cimarron / cim_mod.c
blob20eb4284c7d438c03de0d10e98ce22ce4d052f4e
1 /* <LIC_AMD_STD>
2 * Copyright (c) 2003-2005 Advanced Micro Devices, Inc.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 * The full GNU General Public License is included in this distribution in the
19 * file called COPYING
20 * </LIC_AMD_STD> */
21 /* <CTL_AMD_STD>
22 * </CTL_AMD_STD> */
23 /* <DOC_AMD_STD>
24 * Cimarron module initalization
25 * Jordan Crouse (jordan.crouse@amd.com)
26 * </DOC_AMD_STD> */
28 #include <linux/kernel.h>
29 #include <linux/init.h>
30 #include <linux/module.h>
31 #include <linux/pci.h>
32 #include <linux/pci_ids.h>
34 #include "cim_mem.h"
35 #include "cim_dev.h"
36 #include "build_num.h"
38 #ifdef MODULE
39 MODULE_AUTHOR("Advanced Micro Devices, Inc.");
40 MODULE_DESCRIPTION("AMD Geode LX Graphics Abstraction Layer");
41 MODULE_LICENSE("GPL");
42 #endif
44 #define CIM_MOD_DRIVER_NAME "cimarron"
46 int cim_init_dev(void);
47 void cim_exit_dev(void);
49 int cim_init_memory(void);
50 void cim_exit_memory(void);
51 /* We do this because there really isn't any way to verify that the
52 KFB or V4L2 is going to be loaded before Cimarron is. We force
53 the issue by asking the other entities to call cim_mod_init()
54 and we set a flag indicating that we have already been set up
57 static int cim_init_flag = 0;
59 static int
60 cim_mod_probe(struct pci_dev *pcidev, const struct pci_device_id *pciid) {
61 int ret;
62 ret = pci_enable_device(pcidev);
63 if (ret) return ret;
64 ret = cim_init_memory();
65 if (ret) return ret;
67 ret = cim_init_dev();
68 if (ret) {
69 cim_exit_memory();
70 return ret;
72 return 0;
75 static void
76 cim_mod_remove(struct pci_dev *dev) {
77 cim_exit_memory();
78 cim_exit_dev();
81 static struct
82 pci_device_id cim_mod_id_table[] __devinitdata = {
83 {PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_LX_VIDEO, \
84 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
85 {0,}
88 MODULE_DEVICE_TABLE(pci, cim_mod_id_table);
90 static struct
91 pci_driver cim_mod_driver = {
92 name: CIM_MOD_DRIVER_NAME,
93 id_table: cim_mod_id_table,
94 probe: cim_mod_probe,
95 remove: cim_mod_remove
98 int __init
99 cim_mod_init(void)
101 int ret;
102 if( cim_init_flag != 0 ) return 0;
103 printk(KERN_INFO "%s\n", AMD_VERSION);
104 ret = pci_register_driver(&cim_mod_driver);
105 if( ret == 0 ) cim_init_flag = 1;
106 return ret;
109 #ifdef MODULE
110 void __exit
111 cim_mod_exit(void)
113 printk(KERN_INFO CIM_MOD_DRIVER_NAME " unloading\n");
114 pci_unregister_driver(&cim_mod_driver);
115 cim_init_flag = 0;
117 #endif
119 module_init(cim_mod_init);
121 #ifdef MODULE
122 module_exit(cim_mod_exit);
123 #endif