5f4e36b87c91df2984f83c3d10cd5b0d107c66e3
[coreboot.git] / src / include / device / chip.h
1 #ifndef DEVICE_CHIP_H
2 #define DEVICE_CHIP_H
3
4 #include <device/path.h>
5 #include <device/device.h>
6
7 /* chips are arbitrary chips (superio, southbridge, etc.)
8  * They have private structures that define chip resources and default 
9  * settings. They have four externally visible functions for control. 
10  * They have a generic component which applies to all chips for 
11  * path, etc. 
12  */
13
14 /* some of the types of resources chips can control */
15 #if CONFIG_CHIP_CONFIGURE == 1
16 #define CONFIGURE(pass) chip_configure(&static_root, pass)
17 #else
18 #define CONFIGURE(pass)
19 #endif
20
21 enum chip_pass {
22         CONF_PASS_PRE_CONSOLE,
23         CONF_PASS_PRE_PCI,
24         CONF_PASS_PRE_DEVICE_ENUMERATE,
25         CONF_PASS_PRE_DEVICE_CONFIGURE,
26         CONF_PASS_PRE_DEVICE_ENABLE,
27         CONF_PASS_PRE_DEVICE_INITIALIZE,
28         CONF_PASS_POST_PCI,
29         CONF_PASS_PRE_BOOT
30 };
31
32
33 /* linkages from devices of a type (e.g. superio devices) 
34  * to the actual physical PCI device. This type is used in an array of 
35  * structs built by NLBConfig.py. We owe this idea to Plan 9.
36  */
37
38 struct chip;
39 struct device;
40
41 /* there is one of these for each TYPE of chip */
42 struct chip_control {
43         /* This is the print name for debugging */
44         char *name;
45         void (*enable)(struct chip *, enum chip_pass);
46         void (*enumerate)(struct chip *chip);
47         void (*enable_dev)(struct device *dev);
48 };
49
50 struct chip_resource {
51         unsigned long flags;
52         unsigned long index;
53         unsigned long base;
54 };
55
56 struct chip_device_path {
57         struct device_path path;
58         unsigned channel;
59         int enabled;
60         struct chip_resource resource[MAX_RESOURCES];
61 };
62
63 struct device;
64 struct bus;
65
66 #ifndef MAX_CHIP_PATHS
67 #define MAX_CHIP_PATHS 16
68 #endif
69 struct chip {
70         unsigned link;
71         struct chip_control *control; /* for this device */
72         struct chip_device_path path[MAX_CHIP_PATHS]; /* can be 0, in which case the default is taken */
73         char *configuration; /* can be 0. */
74         struct chip *next, *children;
75         /* there is one of these for each INSTANCE of a chip */
76         void *chip_info; /* the dreaded "void *" */
77         /* bus and device links into the device tree */
78         struct bus *bus;
79         struct device *dev;
80 };
81
82 extern struct chip static_root;
83 extern void chip_configure(struct chip *, enum chip_pass);
84 extern void chip_enumerate(struct chip *chip);
85 #endif /* DEVICE_CHIP_H */