2 * Compaq Hot Plug Controller Driver
4 * Copyright (C) 1995,2001 Compaq Computer Corporation
5 * Copyright (C) 2001 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/pci.h>
39 static struct proc_dir_entry *ctrl_proc_root;
41 /* A few routines that create proc entries for the hot plug controller */
43 static int read_ctrl (char *buf, char **start, off_t offset, int len, int *eof, void *data)
45 struct controller *ctrl = (struct controller *)data;
48 struct pci_resource *res;
50 if (offset > 0) return 0; /* no partial requests */
54 out += sprintf(out, "hot plug ctrl Info Page\n");
55 out += sprintf(out, "bus = %d, device = %d, function = %d\n",ctrl->bus,
56 ctrl->device, ctrl->function);
57 out += sprintf(out, "Free resources: memory\n");
60 while (res && index--) {
61 out += sprintf(out, "start = %8.8x, length = %8.8x\n", res->base, res->length);
64 out += sprintf(out, "Free resources: prefetchable memory\n");
66 res = ctrl->p_mem_head;
67 while (res && index--) {
68 out += sprintf(out, "start = %8.8x, length = %8.8x\n", res->base, res->length);
71 out += sprintf(out, "Free resources: IO\n");
74 while (res && index--) {
75 out += sprintf(out, "start = %8.8x, length = %8.8x\n", res->base, res->length);
78 out += sprintf(out, "Free resources: bus numbers\n");
81 while (res && index--) {
82 out += sprintf(out, "start = %8.8x, length = %8.8x\n", res->base, res->length);
92 static int read_dev (char *buf, char **start, off_t offset, int len, int *eof, void *data)
94 struct controller *ctrl = (struct controller *)data;
97 struct pci_resource *res;
98 struct pci_func *new_slot;
101 if (offset > 0) return 0; /* no partial requests */
105 out += sprintf(out, "hot plug ctrl Info Page\n");
106 out += sprintf(out, "bus = %d, device = %d, function = %d\n",ctrl->bus,
107 ctrl->device, ctrl->function);
112 new_slot = cpqhp_slot_find(slot->bus, slot->device, 0);
113 out += sprintf(out, "assigned resources: memory\n");
115 res = new_slot->mem_head;
116 while (res && index--) {
117 out += sprintf(out, "start = %8.8x, length = %8.8x\n", res->base, res->length);
120 out += sprintf(out, "assigned resources: prefetchable memory\n");
122 res = new_slot->p_mem_head;
123 while (res && index--) {
124 out += sprintf(out, "start = %8.8x, length = %8.8x\n", res->base, res->length);
127 out += sprintf(out, "assigned resources: IO\n");
129 res = new_slot->io_head;
130 while (res && index--) {
131 out += sprintf(out, "start = %8.8x, length = %8.8x\n", res->base, res->length);
134 out += sprintf(out, "assigned resources: bus numbers\n");
136 res = new_slot->bus_head;
137 while (res && index--) {
138 out += sprintf(out, "start = %8.8x, length = %8.8x\n", res->base, res->length);
150 int cpqhp_proc_create_ctrl (struct controller *ctrl)
152 strcpy(ctrl->proc_name, "hpca");
153 ctrl->proc_name[3] = 'a' + ctrl->bus;
155 ctrl->proc_entry = create_proc_entry(ctrl->proc_name, S_IFREG | S_IRUGO, ctrl_proc_root);
156 ctrl->proc_entry->data = ctrl;
157 ctrl->proc_entry->read_proc = &read_ctrl;
159 strcpy(ctrl->proc_name2, "slot_a");
160 ctrl->proc_name2[5] = 'a' + ctrl->bus;
161 ctrl->proc_entry2 = create_proc_entry(ctrl->proc_name2, S_IFREG | S_IRUGO, ctrl_proc_root);
162 ctrl->proc_entry2->data = ctrl;
163 ctrl->proc_entry2->read_proc = &read_dev;
168 int cpqhp_proc_remove_ctrl (struct controller *ctrl)
170 if (ctrl->proc_entry)
171 remove_proc_entry(ctrl->proc_name, ctrl_proc_root);
172 if (ctrl->proc_entry2)
173 remove_proc_entry(ctrl->proc_name2, ctrl_proc_root);
178 int cpqhp_proc_init_ctrl (void)
180 ctrl_proc_root = proc_mkdir("hpc", proc_root_driver);
183 ctrl_proc_root->owner = THIS_MODULE;
187 int cpqhp_proc_destroy_ctrl (void)
189 remove_proc_entry("hpc", proc_root_driver);