5 #include <device/resource.h>
6 #include <device/path.h>
9 typedef struct device * device_t;
10 struct pci_operations;
11 struct smbus_bus_operations;
13 struct device_operations {
14 void (*read_resources)(device_t dev);
15 void (*set_resources)(device_t dev);
16 void (*enable_resources)(device_t dev);
17 void (*init)(device_t dev);
18 unsigned int (*scan_bus)(device_t bus, unsigned int max);
19 void (*enable)(device_t dev);
20 struct pci_operations *ops_pci;
21 struct smbus_bus_operations *ops_smbus_bus;
26 device_t dev; /* This bridge device */
27 device_t children; /* devices behind this bridge */
28 unsigned bridge_ctrl; /* Bridge control register */
29 unsigned char link; /* The index of this link */
30 unsigned char secondary; /* secondary bus number */
31 unsigned char subordinate; /* max subordinate bus number */
32 unsigned char cap; /* PCi capability offset */
35 #define MAX_RESOURCES 12
38 * There is one device structure for each slot-number/function-number
44 struct bus * bus; /* bus this device is on */
45 device_t sibling; /* next device on this bus */
46 device_t next; /* chain of all devices */
48 struct device_path path;
51 unsigned int class; /* 3 bytes: (base,sub,prog-if) */
52 unsigned int hdr_type; /* PCI header type */
53 unsigned int enabled : 1; /* set if we should enable the device */
54 unsigned int initialized : 1; /* set if we have initialized the device */
55 unsigned int have_resources : 1; /* Set if we have read the devices resources */
59 /* Base registers for this device, can be adjusted by
60 * pcibios_fixup() as necessary.
62 struct resource resource[MAX_RESOURCES];
63 unsigned int resources;
65 struct bus link[MAX_LINKS];
68 unsigned long rom_address;
69 struct device_operations *ops;
70 struct chip_control *chip_control;
74 extern struct device dev_root; /* root bus */
75 extern struct device *all_devices; /* list of all devices */
78 /* Generic device interface functions */
79 extern device_t alloc_dev(struct bus *parent, struct device_path *path);
80 extern void dev_enumerate(void);
81 extern void dev_configure(void);
82 extern void dev_enable(void);
83 extern void dev_initialize(void);
85 /* Generic device helper functions */
86 extern void compute_allocate_resource(struct bus *bus, struct resource *bridge,
87 unsigned long type_mask, unsigned long type);
88 extern void assign_resources(struct bus *bus);
89 extern void enable_resources(struct device *dev);
90 extern void enumerate_static_device(void);
91 extern void enumerate_static_devices(void);
92 extern const char *dev_path(device_t dev);
94 /* Helper functions */
95 device_t find_dev_path(struct bus *parent, struct device_path *path);
96 device_t alloc_find_dev(struct bus *parent, struct device_path *path);
97 device_t dev_find_device (unsigned int vendor, unsigned int device, device_t from);
98 device_t dev_find_class (unsigned int class, device_t from);
99 device_t dev_find_slot (unsigned int bus, unsigned int devfn);
101 /* Rounding for boundaries.
102 * Due to some chip bugs, go ahead and roung IO to 16
104 #define DEVICE_IO_ALIGN 16
105 #define DEVICE_MEM_ALIGN 4096
107 struct device_operations default_dev_ops_root;
108 extern void root_dev_read_resources(device_t dev);
109 extern void root_dev_set_resources(device_t dev);
110 extern unsigned int scan_static_bus(device_t bus, unsigned int max);
111 extern void enable_childrens_resources(device_t dev);
112 extern void root_dev_enable_resources(device_t dev);
113 extern unsigned int root_dev_scan_bus(device_t root, unsigned int max);
114 extern void root_dev_init(device_t dev);
116 #endif /* DEVICE_H */