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