Subversion Repositories shark

Rev

Rev 422 | Details | Compare with Previous | Last modification | View Log | RSS feed

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