37 #include <linux/module.h>
39 #include <linux/errno.h>
40 #include <linux/pci.h>
41 #include <linux/string.h>
44 #define DRIVER_VERSION "0.1"
46 #define DRIVER_DESC "Generic port I/O CompactPCI Hot Plug Driver"
49 #define MY_NAME "cpcihp_generic"
51 #define MY_NAME THIS_MODULE->name
54 #define dbg(format, arg...) \
57 printk (KERN_DEBUG "%s: " format "\n", \
60 #define err(format, arg...) printk(KERN_ERR "%s: " format "\n", MY_NAME , ## arg)
61 #define info(format, arg...) printk(KERN_INFO "%s: " format "\n", MY_NAME , ## arg)
62 #define warn(format, arg...) printk(KERN_WARNING "%s: " format "\n", MY_NAME , ## arg)
67 static u8 bridge_busnr;
68 static u8 bridge_slot;
73 static unsigned int enum_bit;
79 static int __init validate_parameters(
void)
86 info(
"not configured, disabling.");
94 if(p == str || tmp > 0xff) {
95 err(
"Invalid hotplug bus bridge device bus number");
98 bridge_busnr = (
u8) tmp;
99 dbg(
"bridge_busnr = 0x%02x", bridge_busnr);
101 err(
"Invalid hotplug bus bridge device");
106 if(p == str || tmp > 0x1f) {
107 err(
"Invalid hotplug bus bridge device slot number");
110 bridge_slot = (
u8) tmp;
111 dbg(
"bridge_slot = 0x%02x", bridge_slot);
114 dbg(
"last_slot = 0x%02x", last_slot);
116 err(
"Need to specify first_slot and last_slot");
120 err(
"first_slot must be less than last_slot");
125 dbg(
"enum_bit = 0x%02x", enum_bit);
127 err(
"Invalid #ENUM bit");
130 enum_mask = 1 << enum_bit;
134 static int query_enum(
void)
139 return ((value & enum_mask) == enum_mask);
142 static int __init cpcihp_generic_init(
void)
149 status = validate_parameters();
160 err(
"Invalid bridge device %s", bridge);
168 generic_hpc_ops.query_enum = query_enum;
169 generic_hpc.ops = &generic_hpc_ops;
173 err(
"Could not register cPCI hotplug controller");
176 dbg(
"registered controller");
180 err(
"Could not register cPCI hotplug bus");
181 goto init_bus_register_error;
183 dbg(
"registered bus");
187 err(
"Could not started cPCI hotplug system");
188 goto init_start_error;
190 dbg(
"started cpci hp system");
194 init_bus_register_error:
196 err(
"status = %d", status);
201 static void __exit cpcihp_generic_exit(
void)
218 MODULE_PARM_DESC(bridge,
"Hotswap bus bridge device, <bus>:<slot> (bus and slot are in hexadecimal)");