2 * Compaq Hot Plug Controller Driver
4 * Copyright (c) 1995,2001 Compaq Computer Corporation
5 * Copyright (c) 2001,2003 Greg Kroah-Hartman (greg@kroah.com)
6 * Copyright (c) 2001 IBM Corp.
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or (at
13 * your option) any later version.
15 * This program is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
18 * NON INFRINGEMENT. See the GNU General Public License for more
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 * Send feedback to <greg@kroah.com>
29 #include <linux/config.h>
30 #include <linux/module.h>
31 #include <linux/kernel.h>
32 #include <linux/types.h>
33 #include <linux/proc_fs.h>
34 #include <linux/workqueue.h>
35 #include <linux/pci.h>
39 /* A few routines that create sysfs entries for the hot plug controller */
41 static ssize_t
show_ctrl (struct device
*dev
, struct device_attribute
*attr
, char *buf
)
43 struct pci_dev
*pci_dev
;
44 struct controller
*ctrl
;
47 struct pci_resource
*res
;
49 pci_dev
= container_of (dev
, struct pci_dev
, dev
);
50 ctrl
= pci_get_drvdata(pci_dev
);
52 out
+= sprintf(buf
, "Free resources: memory\n");
55 while (res
&& index
--) {
56 out
+= sprintf(out
, "start = %8.8x, length = %8.8x\n", res
->base
, res
->length
);
59 out
+= sprintf(out
, "Free resources: prefetchable memory\n");
61 res
= ctrl
->p_mem_head
;
62 while (res
&& index
--) {
63 out
+= sprintf(out
, "start = %8.8x, length = %8.8x\n", res
->base
, res
->length
);
66 out
+= sprintf(out
, "Free resources: IO\n");
69 while (res
&& index
--) {
70 out
+= sprintf(out
, "start = %8.8x, length = %8.8x\n", res
->base
, res
->length
);
73 out
+= sprintf(out
, "Free resources: bus numbers\n");
76 while (res
&& index
--) {
77 out
+= sprintf(out
, "start = %8.8x, length = %8.8x\n", res
->base
, res
->length
);
83 static DEVICE_ATTR (ctrl
, S_IRUGO
, show_ctrl
, NULL
);
85 static ssize_t
show_dev (struct device
*dev
, struct device_attribute
*attr
, char *buf
)
87 struct pci_dev
*pci_dev
;
88 struct controller
*ctrl
;
91 struct pci_resource
*res
;
92 struct pci_func
*new_slot
;
95 pci_dev
= container_of (dev
, struct pci_dev
, dev
);
96 ctrl
= pci_get_drvdata(pci_dev
);
101 new_slot
= shpchp_slot_find(slot
->bus
, slot
->device
, 0);
104 out
+= sprintf(out
, "assigned resources: memory\n");
106 res
= new_slot
->mem_head
;
107 while (res
&& index
--) {
108 out
+= sprintf(out
, "start = %8.8x, length = %8.8x\n", res
->base
, res
->length
);
111 out
+= sprintf(out
, "assigned resources: prefetchable memory\n");
113 res
= new_slot
->p_mem_head
;
114 while (res
&& index
--) {
115 out
+= sprintf(out
, "start = %8.8x, length = %8.8x\n", res
->base
, res
->length
);
118 out
+= sprintf(out
, "assigned resources: IO\n");
120 res
= new_slot
->io_head
;
121 while (res
&& index
--) {
122 out
+= sprintf(out
, "start = %8.8x, length = %8.8x\n", res
->base
, res
->length
);
125 out
+= sprintf(out
, "assigned resources: bus numbers\n");
127 res
= new_slot
->bus_head
;
128 while (res
&& index
--) {
129 out
+= sprintf(out
, "start = %8.8x, length = %8.8x\n", res
->base
, res
->length
);
137 static DEVICE_ATTR (dev
, S_IRUGO
, show_dev
, NULL
);
139 void shpchp_create_ctrl_files (struct controller
*ctrl
)
141 device_create_file (&ctrl
->pci_dev
->dev
, &dev_attr_ctrl
);
142 device_create_file (&ctrl
->pci_dev
->dev
, &dev_attr_dev
);