Linux v2.6.13-rc3
[pohmelfs.git] / include / linux / mca.h
blob5cff2923092bfca0aaa9cd050f1855befbec03ad
1 /*
2 * Header for Microchannel Architecture Bus
3 * Written by Martin Kolinek, February 1996
4 */
6 #ifndef _LINUX_MCA_H
7 #define _LINUX_MCA_H
9 #include <linux/device.h>
11 #ifdef CONFIG_MCA
12 #include <asm/mca.h>
14 extern int MCA_bus;
15 #else
16 #define MCA_bus 0
17 #endif
19 /* This sets up an information callback for /proc/mca/slot?. The
20 * function is called with the buffer, slot, and device pointer (or
21 * some equally informative context information, or nothing, if you
22 * prefer), and is expected to put useful information into the
23 * buffer. The adapter name, id, and POS registers get printed
24 * before this is called though, so don't do it again.
26 * This should be called with a NULL procfn when a module
27 * unregisters, thus preventing kernel crashes and other such
28 * nastiness.
30 typedef int (*MCA_ProcFn)(char* buf, int slot, void* dev);
32 /* Should only be called by the NMI interrupt handler, this will do some
33 * fancy stuff to figure out what might have generated a NMI.
35 extern void mca_handle_nmi(void);
37 enum MCA_AdapterStatus {
38 MCA_ADAPTER_NORMAL = 0,
39 MCA_ADAPTER_NONE = 1,
40 MCA_ADAPTER_DISABLED = 2,
41 MCA_ADAPTER_ERROR = 3
44 struct mca_device {
45 u64 dma_mask;
46 int pos_id;
47 int slot;
49 /* index into id_table, set by the bus match routine */
50 int index;
52 /* is there a driver installed? 0 - No, 1 - Yes */
53 int driver_loaded;
54 /* POS registers */
55 unsigned char pos[8];
56 /* if a pseudo adapter of the motherboard, this is the motherboard
57 * register value to use for setup cycles */
58 short pos_register;
60 enum MCA_AdapterStatus status;
61 #ifdef CONFIG_MCA_PROC_FS
62 /* name of the proc/mca file */
63 char procname[8];
64 /* /proc info callback */
65 MCA_ProcFn procfn;
66 /* device/context info for proc callback */
67 void *proc_dev;
68 #endif
69 struct device dev;
70 char name[32];
72 #define to_mca_device(mdev) container_of(mdev, struct mca_device, dev)
74 struct mca_bus_accessor_functions {
75 unsigned char (*mca_read_pos)(struct mca_device *, int reg);
76 void (*mca_write_pos)(struct mca_device *, int reg,
77 unsigned char byte);
78 int (*mca_transform_irq)(struct mca_device *, int irq);
79 int (*mca_transform_ioport)(struct mca_device *,
80 int region);
81 void * (*mca_transform_memory)(struct mca_device *,
82 void *memory);
85 struct mca_bus {
86 u64 default_dma_mask;
87 int number;
88 struct mca_bus_accessor_functions f;
89 struct device dev;
90 char name[32];
92 #define to_mca_bus(mdev) container_of(mdev, struct mca_bus, dev)
94 struct mca_driver {
95 const short *id_table;
96 void *driver_data;
97 struct device_driver driver;
99 #define to_mca_driver(mdriver) container_of(mdriver, struct mca_driver, driver)
101 /* Ongoing supported API functions */
102 extern struct mca_device *mca_find_device_by_slot(int slot);
103 extern int mca_system_init(void);
104 extern struct mca_bus *mca_attach_bus(int);
106 extern unsigned char mca_device_read_stored_pos(struct mca_device *mca_dev,
107 int reg);
108 extern unsigned char mca_device_read_pos(struct mca_device *mca_dev, int reg);
109 extern void mca_device_write_pos(struct mca_device *mca_dev, int reg,
110 unsigned char byte);
111 extern int mca_device_transform_irq(struct mca_device *mca_dev, int irq);
112 extern int mca_device_transform_ioport(struct mca_device *mca_dev, int port);
113 extern void *mca_device_transform_memory(struct mca_device *mca_dev,
114 void *mem);
115 extern int mca_device_claimed(struct mca_device *mca_dev);
116 extern void mca_device_set_claim(struct mca_device *mca_dev, int val);
117 extern void mca_device_set_name(struct mca_device *mca_dev, const char *name);
118 static inline char *mca_device_get_name(struct mca_device *mca_dev)
120 return mca_dev ? mca_dev->name : NULL;
123 extern enum MCA_AdapterStatus mca_device_status(struct mca_device *mca_dev);
125 extern struct bus_type mca_bus_type;
127 extern int mca_register_driver(struct mca_driver *drv);
128 extern void mca_unregister_driver(struct mca_driver *drv);
130 /* WARNING: only called by the boot time device setup */
131 extern int mca_register_device(int bus, struct mca_device *mca_dev);
133 #ifdef CONFIG_MCA_PROC_FS
134 extern void mca_do_proc_init(void);
135 extern void mca_set_adapter_procfn(int slot, MCA_ProcFn, void* dev);
136 #else
137 static inline void mca_do_proc_init(void)
141 static inline void mca_set_adapter_procfn(int slot, MCA_ProcFn fn, void* dev)
144 #endif
146 #endif /* _LINUX_MCA_H */