VServer 1.9.2 (patch-2.6.8.1-vs1.9.2.diff)
[linux-2.6.git] / drivers / pci / hotplug / rpaphp.h
1 /*
2  * PCI Hot Plug Controller Driver for RPA-compliant PPC64 platform.
3  *
4  * Copyright (C) 2003 Linda Xie <lxie@us.ibm.com>
5  *
6  * All rights reserved.
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or (at
11  * your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
16  * NON INFRINGEMENT.  See the GNU General Public License for more
17  * details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22  *
23  * Send feedback to <lxie@us.ibm.com>,
24  *
25  */
26
27 #ifndef _PPC64PHP_H
28 #define _PPC64PHP_H
29
30 #include <linux/pci.h>
31 #include "pci_hotplug.h"
32
33 #define HOTPLUG 1
34 #define EMBEDDED 0
35
36 #define DR_INDICATOR 9002
37 #define DR_ENTITY_SENSE 9003
38
39 #define POWER_ON        100
40 #define POWER_OFF       0
41
42 #define LED_OFF         0
43 #define LED_ON          1       /* continuous on */
44 #define LED_ID          2       /* slow blinking */
45 #define LED_ACTION      3       /* fast blinking */
46
47 /* Error status from rtas_get-sensor */
48 #define NEED_POWER    -9000     /* slot must be power up and unisolated to get state */
49 #define PWR_ONLY      -9001     /* slot must be powerd up to get state, leave isolated */
50 #define ERR_SENSE_USE -9002     /* No DR operation will succeed, slot is unusable  */
51
52 /* Sensor values from rtas_get-sensor */
53 #define EMPTY           0       /* No card in slot */
54 #define PRESENT         1       /* Card in slot */
55
56 #define MY_NAME "rpaphp"
57 extern int debug;
58 #define dbg(format, arg...)                                     \
59         do {                                                    \
60                 if (debug)                                      \
61                         printk(KERN_DEBUG "%s: " format,        \
62                                 MY_NAME , ## arg);              \
63         } while (0)
64 #define err(format, arg...) printk(KERN_ERR "%s: " format, MY_NAME , ## arg)
65 #define info(format, arg...) printk(KERN_INFO "%s: " format, MY_NAME , ## arg)
66 #define warn(format, arg...) printk(KERN_WARNING "%s: " format, MY_NAME , ## arg)
67
68 /* slot types */
69 #define VIO_DEV 1
70 #define PCI_DEV 2
71
72 /* slot states */
73
74 #define NOT_VALID       3
75 #define NOT_CONFIGURED  2
76 #define CONFIGURED      1
77 #define EMPTY           0
78
79 struct rpaphp_pci_func {
80         struct pci_dev *pci_dev;
81         struct list_head sibling;
82 };
83
84 /*
85  * struct slot - slot information for each *physical* slot
86  */
87 struct slot {
88         struct list_head rpaphp_slot_list;
89         int state;
90         u32 index;
91         u32 type;
92         u32 power_domain;
93         char *name;
94         char *location;
95         u8 removable;
96         u8 dev_type;            /* VIO or PCI */
97         struct device_node *dn; /* slot's device_node in OFDT */
98                                 /* dn has phb info */
99         struct pci_dev *bridge; /* slot's pci_dev in pci_devices */
100         union {
101                 struct list_head pci_funcs; /* pci_devs in PCI slot */ 
102                 struct vio_dev *vio_dev; /* vio_dev in VIO slot */
103         } dev;
104         struct hotplug_slot *hotplug_slot;
105 };
106
107 extern struct hotplug_slot_ops rpaphp_hotplug_slot_ops;
108 extern struct list_head rpaphp_slot_head;
109 extern int num_slots;
110
111 static inline int is_hotplug_capable(struct device_node *dn)
112 {
113         unsigned char *ptr = get_property(dn, "ibm,fw-pci-hot-plug-ctrl", NULL);
114
115         return (int) (ptr != NULL);
116 }
117
118 /* function prototypes */
119
120 /* rpaphp_pci.c */
121 extern struct pci_dev *rpaphp_find_pci_dev(struct device_node *dn);
122 extern int rpaphp_claim_resource(struct pci_dev *dev, int resource);
123 extern int rpaphp_enable_pci_slot(struct slot *slot);
124 extern int register_pci_slot(struct slot *slot);
125 extern int rpaphp_unconfig_pci_adapter(struct slot *slot);
126 extern int rpaphp_get_pci_adapter_status(struct slot *slot, int is_init, u8 * value);
127 extern struct hotplug_slot *rpaphp_find_hotplug_slot(struct pci_dev *dev);
128
129 /* rpaphp_core.c */
130 extern int rpaphp_add_slot(struct device_node *dn);
131 extern int rpaphp_remove_slot(struct slot *slot);
132 extern char *rpaphp_get_drc_name(struct device_node *dn);
133
134 /* rpaphp_vio.c */
135 extern int rpaphp_get_vio_adapter_status(struct slot *slot, int is_init, u8 * value);
136 extern int rpaphp_unconfig_vio_adapter(struct slot *slot);
137 extern int register_vio_slot(struct device_node *dn);
138 extern int rpaphp_enable_vio_slot(struct slot *slot);
139
140 /* rpaphp_slot.c */
141 extern void dealloc_slot_struct(struct slot *slot);
142 extern struct slot *alloc_slot_struct(struct device_node *dn, int drc_index, char *drc_name, int power_domain);
143 extern int register_slot(struct slot *slot);
144 extern int deregister_slot(struct slot *slot);
145 extern int rpaphp_get_power_status(struct slot *slot, u8 * value);
146 extern int rpaphp_set_attention_status(struct slot *slot, u8 status);
147         
148 #endif                          /* _PPC64PHP_H */