VServer 1.9.2 (patch-2.6.8.1-vs1.9.2.diff)
[linux-2.6.git] / include / linux / mca.h
1 /*
2  * Header for Microchannel Architecture Bus
3  * Written by Martin Kolinek, February 1996
4  */
5
6 #ifndef _LINUX_MCA_H
7 #define _LINUX_MCA_H
8
9 /* FIXME: This shouldn't happen, but we need everything that previously
10  * included mca.h to compile.  Take it out later when the MCA #includes
11  * are sorted out */
12 #include <linux/device.h>
13
14 /* get the platform specific defines */
15 #ifdef CONFIG_MCA
16 #include <asm/mca.h>
17 #endif
18
19 /* The detection of MCA bus is done in the real mode (using BIOS).
20  * The information is exported to the protected code, where this
21  * variable is set to one in case MCA bus was detected.
22  */
23 #ifndef MCA_bus__is_a_macro
24 extern int  MCA_bus;
25 #endif
26
27 /* This sets up an information callback for /proc/mca/slot?.  The
28  * function is called with the buffer, slot, and device pointer (or
29  * some equally informative context information, or nothing, if you
30  * prefer), and is expected to put useful information into the
31  * buffer.  The adapter name, id, and POS registers get printed
32  * before this is called though, so don't do it again.
33  *
34  * This should be called with a NULL procfn when a module
35  * unregisters, thus preventing kernel crashes and other such
36  * nastiness.
37  */
38 typedef int (*MCA_ProcFn)(char* buf, int slot, void* dev);
39
40 /* Should only be called by the NMI interrupt handler, this will do some
41  * fancy stuff to figure out what might have generated a NMI.
42  */
43 extern void mca_handle_nmi(void);
44
45 enum MCA_AdapterStatus {
46         MCA_ADAPTER_NORMAL = 0,
47         MCA_ADAPTER_NONE = 1,
48         MCA_ADAPTER_DISABLED = 2,
49         MCA_ADAPTER_ERROR = 3
50 };
51
52 struct mca_device {
53         u64                     dma_mask;
54         int                     pos_id;
55         int                     slot;
56
57         /* index into id_table, set by the bus match routine */
58         int                     index;
59
60         /* is there a driver installed? 0 - No, 1 - Yes */
61         int                     driver_loaded;
62         /* POS registers */
63         unsigned char           pos[8];
64         /* if a pseudo adapter of the motherboard, this is the motherboard
65          * register value to use for setup cycles */
66         short                   pos_register;
67         
68         enum MCA_AdapterStatus  status;
69 #ifdef CONFIG_MCA_PROC_FS
70         /* name of the proc/mca file */
71         char                    procname[8];
72         /* /proc info callback */
73         MCA_ProcFn              procfn;
74         /* device/context info for proc callback */
75         void                    *proc_dev;
76 #endif
77         struct device           dev;
78         char                    name[32];
79 };
80 #define to_mca_device(mdev) container_of(mdev, struct mca_device, dev)
81
82 struct mca_bus_accessor_functions {
83         unsigned char   (*mca_read_pos)(struct mca_device *, int reg);
84         void            (*mca_write_pos)(struct mca_device *, int reg,
85                                          unsigned char byte);
86         int             (*mca_transform_irq)(struct mca_device *, int irq);
87         int             (*mca_transform_ioport)(struct mca_device *,
88                                                   int region);
89         void *          (*mca_transform_memory)(struct mca_device *,
90                                                 void *memory);
91 };
92
93 struct mca_bus {
94         u64                     default_dma_mask;
95         int                     number;
96         struct mca_bus_accessor_functions f;
97         struct device           dev;
98         char                    name[32];
99 };
100 #define to_mca_bus(mdev) container_of(mdev, struct mca_bus, dev)
101
102 struct mca_driver {
103         const short             *id_table;
104         void                    *driver_data;
105         struct device_driver    driver;
106 };
107 #define to_mca_driver(mdriver) container_of(mdriver, struct mca_driver, driver)
108
109 /* Ongoing supported API functions */
110 extern struct mca_device *mca_find_device_by_slot(int slot);
111 extern int mca_system_init(void);
112 extern struct mca_bus *mca_attach_bus(int);
113
114 extern unsigned char mca_device_read_stored_pos(struct mca_device *mca_dev,
115                                                 int reg);
116 extern unsigned char mca_device_read_pos(struct mca_device *mca_dev, int reg);
117 extern void mca_device_write_pos(struct mca_device *mca_dev, int reg,
118                                  unsigned char byte);
119 extern int mca_device_transform_irq(struct mca_device *mca_dev, int irq);
120 extern int mca_device_transform_ioport(struct mca_device *mca_dev, int port);
121 extern void *mca_device_transform_memory(struct mca_device *mca_dev,
122                                          void *mem);
123 extern int mca_device_claimed(struct mca_device *mca_dev);
124 extern void mca_device_set_claim(struct mca_device *mca_dev, int val);
125 extern void mca_device_set_name(struct mca_device *mca_dev, const char *name);
126 static inline char *mca_device_get_name(struct mca_device *mca_dev)
127 {
128         return mca_dev ? mca_dev->name : NULL;
129 }
130
131 extern enum MCA_AdapterStatus mca_device_status(struct mca_device *mca_dev);
132
133 extern struct bus_type mca_bus_type;
134
135 extern int mca_register_driver(struct mca_driver *drv);
136 extern void mca_unregister_driver(struct mca_driver *drv);
137
138 /* WARNING: only called by the boot time device setup */
139 extern int mca_register_device(int bus, struct mca_device *mca_dev);
140
141 #ifdef CONFIG_MCA_PROC_FS
142 extern void mca_do_proc_init(void);
143 extern void mca_set_adapter_procfn(int slot, MCA_ProcFn, void* dev);
144 #else
145 static inline void mca_do_proc_init(void)
146 {
147 }
148
149 static inline void mca_set_adapter_procfn(int slot, MCA_ProcFn fn, void* dev)
150 {
151 }
152 #endif
153
154 #endif /* _LINUX_MCA_H */