summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Durbin <adurbin@chromium.org>2017-08-07 16:55:43 -0600
committerAaron Durbin <adurbin@chromium.org>2017-08-09 17:47:18 +0000
commitc30d913f1f76cbde79039b7865939182c0d7c37a (patch)
treee048c5e27424dea8d8490167415adaab941dd78a
parente9787ff61f81054bfd0c3e3ad214484e1bdf4db3 (diff)
device/pci: untangle struct device and device_t
This patch uses struct device explicitly for the ramstage functions as that's the actual type it's working on. Additionally, the declarations for types and functions are fully exposed so that compliation units don't have to guard certain functions from use because it's being compiled for multiple stages. Change-Id: I8db23ed400a59073e1e66522d020a5928f71f3a6 Signed-off-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: https://review.coreboot.org/20902 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org> Reviewed-by: Furquan Shaikh <furquan@google.com>
-rw-r--r--src/device/pci_device.c23
-rw-r--r--src/include/device/device.h39
-rw-r--r--src/include/device/pci.h42
3 files changed, 53 insertions, 51 deletions
diff --git a/src/device/pci_device.c b/src/device/pci_device.c
index 75e9a7910d..f43de451d4 100644
--- a/src/device/pci_device.c
+++ b/src/device/pci_device.c
@@ -162,7 +162,7 @@ unsigned pci_find_next_capability(struct device *dev, unsigned cap,
* @param cap PCI_CAP_LIST_ID of the PCI capability we're looking for.
* @return The next matching capability.
*/
-unsigned pci_find_capability(device_t dev, unsigned cap)
+unsigned int pci_find_capability(struct device *dev, unsigned int cap)
{
return pci_find_next_capability(dev, cap, 0);
}
@@ -781,7 +781,7 @@ struct device_operations default_pci_ops_bus = {
* @param dev Pointer to the device structure of the bridge.
* @return Appropriate bridge operations.
*/
-static struct device_operations *get_pci_bridge_ops(device_t dev)
+static struct device_operations *get_pci_bridge_ops(struct device *dev)
{
#if IS_ENABLED(CONFIG_PCIX_PLUGIN_SUPPORT)
unsigned int pcixpos;
@@ -976,7 +976,8 @@ static struct device *pci_scan_get_dev(struct device **list, unsigned int devfn)
* @param devfn A device/function number to look at.
* @return The device structure for the device (if found), NULL otherwise.
*/
-device_t pci_probe_dev(device_t dev, struct bus *bus, unsigned devfn)
+struct device *pci_probe_dev(struct device *dev, struct bus *bus,
+ unsigned int devfn)
{
u32 id, class;
u8 hdr_type;
@@ -1083,7 +1084,7 @@ device_t pci_probe_dev(device_t dev, struct bus *bus, unsigned devfn)
* @param sdev Simple device model identifier, created with PCI_DEV().
* @return Non-zero if bus:dev.fn of device matches.
*/
-unsigned int pci_match_simple_dev(device_t dev, pci_devfn_t sdev)
+unsigned int pci_match_simple_dev(struct device *dev, pci_devfn_t sdev)
{
return dev->bus->secondary == PCI_DEV2SEGBUS(sdev) &&
dev->path.pci.devfn == PCI_DEV2DEVFN(sdev);
@@ -1152,7 +1153,7 @@ void pci_scan_bus(struct bus *bus, unsigned min_devfn,
* There's probably a problem in devicetree.cb.
*/
if (old_devices) {
- device_t left;
+ struct device *left;
printk(BIOS_WARNING, "PCI: Left over static devices:\n");
for (left = old_devices; left; left = left->sibling)
printk(BIOS_WARNING, "%s\n", dev_path(left));
@@ -1289,7 +1290,7 @@ void pci_scan_bridge(struct device *dev)
*
* @param dev Pointer to the domain.
*/
-void pci_domain_scan_bus(device_t dev)
+void pci_domain_scan_bus(struct device *dev)
{
struct bus *link = dev->link_list;
pci_scan_bus(link, PCI_DEVFN(0, 0), 0xff);
@@ -1335,10 +1336,10 @@ const char *pin_to_str(int pin)
* @return The interrupt pin number (1 - 4) that 'dev' will
* trigger when generating an interrupt
*/
-static int swizzle_irq_pins(device_t dev, device_t *parent_bridge)
+static int swizzle_irq_pins(struct device *dev, struct device **parent_bridge)
{
- device_t parent; /* Our current device's parent device */
- device_t child; /* The child device of the parent */
+ struct device *parent; /* Our current device's parent device */
+ struct device *child; /* The child device of the parent */
uint8_t parent_bus = 0; /* Parent Bus number */
uint16_t parent_devfn = 0; /* Parent Device and Function number */
uint16_t child_devfn = 0; /* Child Device and Function number */
@@ -1403,7 +1404,7 @@ static int swizzle_irq_pins(device_t dev, device_t *parent_bridge)
* Errors: -1 is returned if the device is not enabled
* -2 is returned if a parent bridge could not be found.
*/
-int get_pci_irq_pins(device_t dev, device_t *parent_bdg)
+int get_pci_irq_pins(struct device *dev, struct device **parent_bdg)
{
uint8_t bus = 0; /* The bus this device is on */
uint16_t devfn = 0; /* This device's device and function numbers */
@@ -1465,7 +1466,7 @@ void pci_assign_irqs(unsigned bus, unsigned slot,
const unsigned char pIntAtoD[4])
{
unsigned int funct;
- device_t pdev;
+ struct device *pdev;
u8 line, irq;
/* Each slot may contain up to eight functions. */
diff --git a/src/include/device/device.h b/src/include/device/device.h
index 242d29762c..54d4ec314f 100644
--- a/src/include/device/device.h
+++ b/src/include/device/device.h
@@ -18,6 +18,8 @@ struct device;
#ifndef __SIMPLE_DEVICE__
typedef struct device *device_t;
+#endif
+
struct pci_operations;
struct pci_bus_operations;
struct i2c_bus_operations;
@@ -43,33 +45,33 @@ struct smbios_type11;
struct acpi_rsdp;
struct device_operations {
- void (*read_resources)(device_t dev);
- void (*set_resources)(device_t dev);
- void (*enable_resources)(device_t dev);
- void (*init)(device_t dev);
- void (*final)(device_t dev);
- void (*scan_bus)(device_t bus);
- void (*enable)(device_t dev);
- void (*disable)(device_t dev);
- void (*set_link)(device_t dev, unsigned int link);
+ void (*read_resources)(struct device *dev);
+ void (*set_resources)(struct device *dev);
+ void (*enable_resources)(struct device *dev);
+ void (*init)(struct device *dev);
+ void (*final)(struct device *dev);
+ void (*scan_bus)(struct device *bus);
+ void (*enable)(struct device *dev);
+ void (*disable)(struct device *dev);
+ void (*set_link)(struct device *dev, unsigned int link);
void (*reset_bus)(struct bus *bus);
#if IS_ENABLED(CONFIG_GENERATE_SMBIOS_TABLES)
- int (*get_smbios_data)(device_t dev, int *handle,
+ int (*get_smbios_data)(struct device *dev, int *handle,
unsigned long *current);
- void (*get_smbios_strings)(device_t dev, struct smbios_type11 *t);
+ void (*get_smbios_strings)(struct device *dev, struct smbios_type11 *t);
#endif
#if IS_ENABLED(CONFIG_HAVE_ACPI_TABLES)
- unsigned long (*write_acpi_tables)(device_t dev, unsigned long start,
- struct acpi_rsdp *rsdp);
- void (*acpi_fill_ssdt_generator)(device_t dev);
- void (*acpi_inject_dsdt_generator)(device_t dev);
- const char *(*acpi_name)(device_t dev);
+ unsigned long (*write_acpi_tables)(struct device *dev,
+ unsigned long start, struct acpi_rsdp *rsdp);
+ void (*acpi_fill_ssdt_generator)(struct device *dev);
+ void (*acpi_inject_dsdt_generator)(struct device *dev);
+ const char *(*acpi_name)(struct device *dev);
#endif
const struct pci_operations *ops_pci;
const struct i2c_bus_operations *ops_i2c_bus;
const struct spi_bus_operations *ops_spi_bus;
const struct smbus_bus_operations *ops_smbus_bus;
- const struct pci_bus_operations * (*ops_pci_bus)(device_t dev);
+ const struct pci_bus_operations * (*ops_pci_bus)(struct device *dev);
const struct pnp_mode_ops *ops_pnp_mode;
};
@@ -79,9 +81,6 @@ struct device_operations {
static inline void device_noop(struct device *dev) {}
#define DEVICE_NOOP device_noop
-#endif /* ! __SIMPLE_DEVICE__ */
-
-
struct bus {
DEVTREE_CONST struct device *dev; /* This bridge device */
diff --git a/src/include/device/pci.h b/src/include/device/pci.h
index 0f2d2bde00..bc7fada090 100644
--- a/src/include/device/pci.h
+++ b/src/include/device/pci.h
@@ -27,14 +27,13 @@
#include <device/pci_ops.h>
#include <device/pci_rom.h>
-#ifndef __SIMPLE_DEVICE__
/* Common pci operations without a standard interface */
struct pci_operations {
/* set the Subsystem IDs for the PCI device */
- void (*set_subsystem)(device_t dev, unsigned int vendor,
+ void (*set_subsystem)(struct device *dev, unsigned int vendor,
unsigned int device);
- void (*set_L1_ss_latency)(device_t dev, unsigned int off);
+ void (*set_L1_ss_latency)(struct device *dev, unsigned int off);
};
/* Common pci bus operations */
@@ -57,7 +56,11 @@ struct pci_driver {
const unsigned short *devices;
};
+#ifdef __SIMPLE_DEVICE__
+#define __pci_driver __attribute__((unused))
+#else
#define __pci_driver __attribute__((used, __section__(".rodata.pci_driver")))
+#endif
/** start of compile time generated pci driver array */
extern struct pci_driver _pci_drivers[];
/** end of compile time generated pci driver array */
@@ -67,19 +70,20 @@ extern struct pci_driver _epci_drivers[];
extern struct device_operations default_pci_ops_dev;
extern struct device_operations default_pci_ops_bus;
-void pci_dev_read_resources(device_t dev);
-void pci_bus_read_resources(device_t dev);
-void pci_dev_set_resources(device_t dev);
-void pci_dev_enable_resources(device_t dev);
-void pci_bus_enable_resources(device_t dev);
+void pci_dev_read_resources(struct device *dev);
+void pci_bus_read_resources(struct device *dev);
+void pci_dev_set_resources(struct device *dev);
+void pci_dev_enable_resources(struct device *dev);
+void pci_bus_enable_resources(struct device *dev);
void pci_bus_reset(struct bus *bus);
-device_t pci_probe_dev(device_t dev, struct bus *bus, unsigned int devfn);
+struct device *pci_probe_dev(struct device *dev, struct bus *bus,
+ unsigned int devfn);
void do_pci_scan_bridge(device_t bus,
void (*do_scan_bus)(struct bus *bus,
unsigned int min_devfn, unsigned int max_devfn));
-void pci_scan_bridge(device_t bus);
+void pci_scan_bridge(struct device *bus);
void pci_scan_bus(struct bus *bus, unsigned int min_devfn,
unsigned int max_devfn);
@@ -87,22 +91,22 @@ uint8_t pci_moving_config8(struct device *dev, unsigned int reg);
uint16_t pci_moving_config16(struct device *dev, unsigned int reg);
uint32_t pci_moving_config32(struct device *dev, unsigned int reg);
struct resource *pci_get_resource(struct device *dev, unsigned long index);
-void pci_dev_set_subsystem(device_t dev, unsigned int vendor,
+void pci_dev_set_subsystem(struct device *dev, unsigned int vendor,
unsigned int device);
void pci_dev_init(struct device *dev);
-unsigned int pci_match_simple_dev(device_t dev, pci_devfn_t sdev);
+unsigned int pci_match_simple_dev(struct device *dev, pci_devfn_t sdev);
const char *pin_to_str(int pin);
-int get_pci_irq_pins(device_t dev, device_t *parent_bdg);
+int get_pci_irq_pins(struct device *dev, struct device **parent_bdg);
void pci_assign_irqs(unsigned int bus, unsigned int slot,
const unsigned char pIntAtoD[4]);
-const char *get_pci_class_name(device_t dev);
-const char *get_pci_subclass_name(device_t dev);
+const char *get_pci_class_name(struct device *dev);
+const char *get_pci_subclass_name(struct device *dev);
#define PCI_IO_BRIDGE_ALIGN 4096
#define PCI_MEM_BRIDGE_ALIGN (1024*1024)
-static inline const struct pci_operations *ops_pci(device_t dev)
+static inline const struct pci_operations *ops_pci(struct device *dev)
{
const struct pci_operations *pops;
pops = 0;
@@ -111,16 +115,14 @@ static inline const struct pci_operations *ops_pci(device_t dev)
return pops;
}
-#endif /* ! __SIMPLE_DEVICE__ */
-
#ifdef __SIMPLE_DEVICE__
unsigned int pci_find_next_capability(pci_devfn_t dev, unsigned int cap,
unsigned int last);
unsigned int pci_find_capability(pci_devfn_t dev, unsigned int cap);
#else /* !__SIMPLE_DEVICE__ */
-unsigned int pci_find_next_capability(device_t dev, unsigned int cap,
+unsigned int pci_find_next_capability(struct device *dev, unsigned int cap,
unsigned int last);
-unsigned int pci_find_capability(device_t dev, unsigned int cap);
+unsigned int pci_find_capability(struct device *dev, unsigned int cap);
#endif /* __SIMPLE_DEVICE__ */
void pci_early_bridge_init(void);