summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
Diffstat (limited to 'src/include')
-rw-r--r--src/include/device/device.h15
-rw-r--r--src/include/device/pci_def.h12
-rw-r--r--src/include/device/pci_ids.h16
-rw-r--r--src/include/device/resource.h23
-rw-r--r--src/include/device/smbus.h71
-rw-r--r--src/include/device/smbus_def.h9
6 files changed, 133 insertions, 13 deletions
diff --git a/src/include/device/device.h b/src/include/device/device.h
index 6dade9ed99..3e70f5d386 100644
--- a/src/include/device/device.h
+++ b/src/include/device/device.h
@@ -7,6 +7,8 @@
struct device;
typedef struct device * device_t;
+struct pci_operations;
+struct smbus_bus_operations;
struct device_operations {
void (*read_resources)(device_t dev);
@@ -15,6 +17,8 @@ struct device_operations {
void (*init)(device_t dev);
unsigned int (*scan_bus)(device_t bus, unsigned int max);
void (*enable)(device_t dev);
+ struct pci_operations *ops_pci;
+ struct smbus_bus_operations *ops_smbus_bus;
};
@@ -28,7 +32,7 @@ struct bus {
unsigned char cap; /* PCi capability offset */
};
-#define MAX_RESOURCES 8
+#define MAX_RESOURCES 12
#define MAX_LINKS 3
/*
* There is one device structure for each slot-number/function-number
@@ -47,6 +51,8 @@ struct device {
unsigned int class; /* 3 bytes: (base,sub,prog-if) */
unsigned int hdr_type; /* PCI header type */
unsigned int enabled : 1; /* set if we should enable the device */
+ unsigned int initialized : 1; /* set if we have initialized the device */
+ unsigned int have_resources : 1; /* Set if we have read the devices resources */
uint8_t command;
@@ -83,10 +89,9 @@ extern void enable_resources(struct device *dev);
extern void enumerate_static_device(void);
extern void enumerate_static_devices(void);
extern const char *dev_path(device_t dev);
-extern void compact_resources(device_t dev);
-extern struct resource *get_resource(device_t dev, unsigned index);
/* Helper functions */
+device_t find_dev_path(struct bus *parent, struct device_path *path);
device_t alloc_find_dev(struct bus *parent, struct device_path *path);
device_t dev_find_device (unsigned int vendor, unsigned int device, device_t from);
device_t dev_find_class (unsigned int class, device_t from);
@@ -103,6 +108,8 @@ extern void root_dev_read_resources(device_t dev);
extern void root_dev_set_resources(device_t dev);
extern unsigned int scan_static_bus(device_t bus, unsigned int max);
extern void enable_childrens_resources(device_t dev);
-extern unsigned int root_dev_scan_pci_bus(device_t root, unsigned int max);
+extern void root_dev_enable_resources(device_t dev);
+extern unsigned int root_dev_scan_bus(device_t root, unsigned int max);
+extern void root_dev_init(device_t dev);
#endif /* DEVICE_H */
diff --git a/src/include/device/pci_def.h b/src/include/device/pci_def.h
index 46229a12f4..dc2176babb 100644
--- a/src/include/device/pci_def.h
+++ b/src/include/device/pci_def.h
@@ -68,13 +68,13 @@
#define PCI_BASE_ADDRESS_SPACE 0x01 /* 0 = memory, 1 = I/O */
#define PCI_BASE_ADDRESS_SPACE_IO 0x01
#define PCI_BASE_ADDRESS_SPACE_MEMORY 0x00
-#define PCI_BASE_ADDRESS_MEM_TYPE_MASK 0x06
-#define PCI_BASE_ADDRESS_MEM_TYPE_32 0x00 /* 32 bit address */
-#define PCI_BASE_ADDRESS_MEM_TYPE_1M 0x02 /* Below 1M [obsolete] */
-#define PCI_BASE_ADDRESS_MEM_TYPE_64 0x04 /* 64 bit address */
+#define PCI_BASE_ADDRESS_MEM_LIMIT_MASK 0x06
+#define PCI_BASE_ADDRESS_MEM_LIMIT_32 0x00 /* 32 bit address */
+#define PCI_BASE_ADDRESS_MEM_LIMIT_1M 0x02 /* Below 1M [obsolete] */
+#define PCI_BASE_ADDRESS_MEM_LIMIT_64 0x04 /* 64 bit address */
#define PCI_BASE_ADDRESS_MEM_PREFETCH 0x08 /* prefetchable? */
-#define PCI_BASE_ADDRESS_MEM_MASK (~0x0fUL)
-#define PCI_BASE_ADDRESS_IO_MASK (~0x03UL)
+#define PCI_BASE_ADDRESS_MEM_ATTR_MASK 0x0f
+#define PCI_BASE_ADDRESS_IO_ATTR_MASK 0x03
/* bit 1 is reserved if address_space = 1 */
/* Header type 0 (normal devices) */
diff --git a/src/include/device/pci_ids.h b/src/include/device/pci_ids.h
index d840b3879a..808b5cd2c6 100644
--- a/src/include/device/pci_ids.h
+++ b/src/include/device/pci_ids.h
@@ -1758,6 +1758,22 @@
#define PCI_DEVICE_ID_INTEL_82801DB_11 0x24cb
#define PCI_DEVICE_ID_INTEL_82801DB_13 0x24cd
#define PCI_DEVICE_ID_INTEL_82801EB_0 0x24d0
+#define PCI_DEVICE_ID_INTEL_82801EB_USB 0x24d2
+#define PCI_DEVICE_ID_INTEL_82801EB_4 0x24d4
+#define PCI_DEVICE_ID_INTEL_82801EB_D 0x24dd
+#define PCI_DEVICE_ID_INTEL_82801EB_E 0x24de
+#define PCI_DEVICE_ID_INTEL_82801EB_IDE 0x24db
+#define PCI_DEVICE_ID_INTEL_82801ER_PCI 0x244e
+#define PCI_DEVICE_ID_INTEL_82801ER_ISA 0x24d0
+#define PCI_DEVICE_ID_INTEL_82801ER_USB 0x24d2
+#define PCI_DEVICE_ID_INTEL_82801ER_SMB 0x24d3
+#define PCI_DEVICE_ID_INTEL_82801ER_USB2 0x24d4
+#define PCI_DEVICE_ID_INTEL_82801ER_AC97_AUDIO 0x24d5
+#define PCI_DEVICE_ID_INTEL_82801ER_AC97_MODEM 0x24d6
+#define PCI_DEVICE_ID_INTEL_82801ER_USB3 0x24d7
+#define PCI_DEVICE_ID_INTEL_82801ER_EHCI 0x24dd
+#define PCI_DEVICE_ID_INTEL_82801ER_IDE 0x24db
+#define PCI_DEVICE_ID_INTEL_82801ER_SATA 0x24df
#define PCI_DEVICE_ID_INTEL_80310 0x530d
#define PCI_DEVICE_ID_INTEL_82810_MC1 0x7120
#define PCI_DEVICE_ID_INTEL_82810_IG1 0x7121
diff --git a/src/include/device/resource.h b/src/include/device/resource.h
index b79a296b5b..7ab8065c23 100644
--- a/src/include/device/resource.h
+++ b/src/include/device/resource.h
@@ -1,6 +1,7 @@
#ifndef RESOURCE_H
#define RESOURCE_H
+#include <stdint.h>
#define IORESOURCE_BITS 0x000000ff /* Bus-specific bits */
@@ -60,10 +61,12 @@
#define IORESOURCE_MEM_SHADOWABLE (1<<5) /* dup: IORESOURCE_SHADOWABLE */
#define IORESOURCE_MEM_EXPANSIONROM (1<<6)
+
+typedef uint64_t resource_t;
struct resource {
- unsigned long base; /* Base address of the resource */
- unsigned long size; /* Size of the resource */
- unsigned long limit; /* Largest valid value base + size -1 */
+ resource_t base; /* Base address of the resource */
+ resource_t size; /* Size of the resource */
+ resource_t limit; /* Largest valid value base + size -1 */
unsigned long flags; /* Descriptions of the kind of resource */
unsigned long index; /* Bus specific per device resource id */
unsigned char align; /* Required alignment (log 2) of the resource */
@@ -71,4 +74,18 @@ struct resource {
/* Alignment must be >= the granularity of the resource */
};
+/* Macros to generate index values for subtractive resources */
+#define IOINDEX_SUBTRACTIVE(IDX,LINK) (0x10000000 + ((IDX) << 8) + LINK)
+#define IOINDEX_SUBTRACTIVE_LINK(IDX) (IDX & 0xff)
+
+/* Generic resource helper functions */
+struct device;
+extern void compact_resources(struct device * dev);
+extern struct resource *probe_resource(struct device *dev, unsigned index);
+extern struct resource *new_resource(struct device * dev, unsigned index);
+extern struct resource *find_resource(struct device * dev, unsigned index);
+extern resource_t resource_end(struct resource *resource);
+extern resource_t resource_max(struct resource *resource);
+extern void report_resource_stored(struct device * dev, struct resource *resource, const char *comment);
+
#endif /* RESOURCE_H */
diff --git a/src/include/device/smbus.h b/src/include/device/smbus.h
new file mode 100644
index 0000000000..230f061900
--- /dev/null
+++ b/src/include/device/smbus.h
@@ -0,0 +1,71 @@
+#ifndef DEVICE_SMBUS_H
+#define DEVICE_SMBUS_H
+
+#include <stdint.h>
+#include <device/device.h>
+#include <device/path.h>
+#include <device/chip.h>
+#include <device/smbus_def.h>
+
+/* Common smbus bus operations */
+struct smbus_bus_operations {
+ int (*quick_read) (device_t dev);
+ int (*quick_write) (device_t dev);
+ int (*recv_byte) (device_t dev);
+ int (*send_byte) (device_t dev, uint8_t value);
+ int (*read_byte) (device_t dev, uint8_t addr);
+ int (*write_byte) (device_t dev, uint8_t addr, uint8_t value);
+ int (*read_word) (device_t dev, uint8_t addr);
+ int (*write_word) (device_t dev, uint8_t addr, uint16_t value);
+ int (*process_call)(device_t dev, uint8_t cmd, uint16_t data);
+ int (*block_read) (device_t dev, uint8_t cmd, uint8_t bytes, uint8_t *buffer);
+ int (*block_write) (device_t dev, uint8_t cmd, uint8_t bytes, const uint8_t *buffer);
+};
+
+static inline int smbus_quick_read(device_t dev)
+{
+ return dev->bus->dev->ops->ops_smbus_bus->quick_read(dev);
+}
+static inline int smbus_quick_write(device_t dev)
+{
+ return dev->bus->dev->ops->ops_smbus_bus->quick_write(dev);
+}
+static inline int smbus_recv_byte(device_t dev)
+{
+ return dev->bus->dev->ops->ops_smbus_bus->recv_byte(dev);
+}
+static inline int smbus_send_byte(device_t dev, uint8_t byte)
+{
+ return dev->bus->dev->ops->ops_smbus_bus->send_byte(dev, byte);
+}
+static inline int smbus_read_byte(device_t dev, uint8_t addr)
+{
+ return dev->bus->dev->ops->ops_smbus_bus->read_byte(dev, addr);
+}
+static inline int smbus_write_byte(device_t dev, uint8_t addr, uint8_t val)
+{
+ return dev->bus->dev->ops->ops_smbus_bus->write_byte(dev, addr, val);
+}
+static inline int smbus_read_word(device_t dev, uint8_t addr)
+{
+ return dev->bus->dev->ops->ops_smbus_bus->read_word(dev, addr);
+}
+static inline int smbus_write_word(device_t dev, uint8_t addr, uint16_t val)
+{
+ return dev->bus->dev->ops->ops_smbus_bus->write_word(dev, addr, val);
+}
+static inline int smbus_process_call(device_t dev, uint8_t cmd, uint16_t data)
+{
+ return dev->bus->dev->ops->ops_smbus_bus->process_call(dev, cmd, data);
+}
+static inline int smbus_block_read(device_t dev, uint8_t cmd, uint8_t bytes, uint8_t *buffer)
+{
+ return dev->bus->dev->ops->ops_smbus_bus->block_read(dev, cmd, bytes, buffer);
+}
+static inline int smbus_block_write(device_t dev, uint8_t cmd, uint8_t bytes, const uint8_t *buffer)
+{
+ return dev->bus->dev->ops->ops_smbus_bus->block_write(dev, cmd, bytes, buffer);
+}
+
+
+#endif /* DEVICE_SMBUS_H */
diff --git a/src/include/device/smbus_def.h b/src/include/device/smbus_def.h
new file mode 100644
index 0000000000..971e9756a9
--- /dev/null
+++ b/src/include/device/smbus_def.h
@@ -0,0 +1,9 @@
+#ifndef DEVICE_SMBUS_DEF_H
+#define DEVICE_SMBUS_DEF_H
+
+/* Error results are negative success is >= 0 */
+#define SMBUS_ERROR -1
+#define SMBUS_WAIT_UNTIL_READY_TIMEOUT -2
+#define SMBUS_WAIT_UNTIL_DONE_TIMEOUT -3
+
+#endif /* DEVICE_SMBUS_DEF_H */