summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
Diffstat (limited to 'src/include')
-rw-r--r--src/include/device/device.h7
-rw-r--r--src/include/device/pci_ops.h46
-rw-r--r--src/include/device/smbus.h4
-rw-r--r--src/include/reg_script.h20
4 files changed, 54 insertions, 23 deletions
diff --git a/src/include/device/device.h b/src/include/device/device.h
index 6713c9492c..c2f8ecefd7 100644
--- a/src/include/device/device.h
+++ b/src/include/device/device.h
@@ -14,14 +14,9 @@
#include <rules.h>
#include <device/resource.h>
#include <device/path.h>
-
-struct device;
-
-#ifndef __SIMPLE_DEVICE__
-typedef struct device *device_t;
-#endif
#include <arch/io.h>
+struct device;
struct pci_operations;
struct pci_bus_operations;
struct i2c_bus_operations;
diff --git a/src/include/device/pci_ops.h b/src/include/device/pci_ops.h
index 5e60e8de2d..54284f590a 100644
--- a/src/include/device/pci_ops.h
+++ b/src/include/device/pci_ops.h
@@ -15,33 +15,49 @@ void pci_write_config32(struct device *dev, unsigned int where, u32 val);
#endif
-/*
- * Use device_t here as the functions are to be used with either
- * __SIMPLE_DEVICE__ defined or undefined.
- */
+#ifdef __SIMPLE_DEVICE__
static __always_inline
-void pci_or_config8(device_t dev, unsigned int where, u8 ormask)
+void pci_or_config8(pci_devfn_t dev, unsigned int where, u8 ormask)
+#else
+static __always_inline
+void pci_or_config8(struct device *dev, unsigned int where, u8 ormask)
+#endif
{
u8 value = pci_read_config8(dev, where);
pci_write_config8(dev, where, value | ormask);
}
+#ifdef __SIMPLE_DEVICE__
+static __always_inline
+void pci_or_config16(pci_devfn_t dev, unsigned int where, u16 ormask)
+#else
static __always_inline
-void pci_or_config16(device_t dev, unsigned int where, u16 ormask)
+void pci_or_config16(struct device *dev, unsigned int where, u16 ormask)
+#endif
{
u16 value = pci_read_config16(dev, where);
pci_write_config16(dev, where, value | ormask);
}
+#ifdef __SIMPLE_DEVICE__
+static __always_inline
+void pci_or_config32(pci_devfn_t dev, unsigned int where, u32 ormask)
+#else
static __always_inline
-void pci_or_config32(device_t dev, unsigned int where, u32 ormask)
+void pci_or_config32(struct device *dev, unsigned int where, u32 ormask)
+#endif
{
u32 value = pci_read_config32(dev, where);
pci_write_config32(dev, where, value | ormask);
}
+#ifdef __SIMPLE_DEVICE__
static __always_inline
-void pci_update_config8(device_t dev, int reg, u8 mask, u8 or)
+void pci_update_config8(pci_devfn_t dev, int reg, u8 mask, u8 or)
+#else
+static __always_inline
+void pci_update_config8(struct device *dev, int reg, u8 mask, u8 or)
+#endif
{
u8 reg8;
@@ -51,8 +67,13 @@ void pci_update_config8(device_t dev, int reg, u8 mask, u8 or)
pci_write_config8(dev, reg, reg8);
}
+#ifdef __SIMPLE_DEVICE__
+static __always_inline
+void pci_update_config16(pci_devfn_t dev, int reg, u16 mask, u16 or)
+#else
static __always_inline
-void pci_update_config16(device_t dev, int reg, u16 mask, u16 or)
+void pci_update_config16(struct device *dev, int reg, u16 mask, u16 or)
+#endif
{
u16 reg16;
@@ -62,8 +83,13 @@ void pci_update_config16(device_t dev, int reg, u16 mask, u16 or)
pci_write_config16(dev, reg, reg16);
}
+#ifdef __SIMPLE_DEVICE__
+static __always_inline
+void pci_update_config32(pci_devfn_t dev, int reg, u32 mask, u32 or)
+#else
static __always_inline
-void pci_update_config32(device_t dev, int reg, u32 mask, u32 or)
+void pci_update_config32(struct device *dev, int reg, u32 mask, u32 or)
+#endif
{
u32 reg32;
diff --git a/src/include/device/smbus.h b/src/include/device/smbus.h
index 639e9383c0..de6cf40c79 100644
--- a/src/include/device/smbus.h
+++ b/src/include/device/smbus.h
@@ -51,8 +51,8 @@ static inline int smbus_write_byte(struct device *const dev, u8 addr, u8 val)
return i2c_dev_writeb_at(dev, addr, val);
}
-int smbus_block_read(device_t dev, u8 cmd, u8 bytes, u8 *buffer);
-int smbus_block_write(device_t dev, u8 cmd, u8 bytes, const u8 *buffer);
+int smbus_block_read(struct device *dev, u8 cmd, u8 bytes, u8 *buffer);
+int smbus_block_write(struct device *dev, u8 cmd, u8 bytes, const u8 *buffer);
#if IS_ENABLED(CONFIG_SMBUS_HAS_AUX_CHANNELS)
void smbus_switch_to_channel(uint8_t channel_number);
diff --git a/src/include/reg_script.h b/src/include/reg_script.h
index 116dd9264b..28fc82db0f 100644
--- a/src/include/reg_script.h
+++ b/src/include/reg_script.h
@@ -30,8 +30,6 @@
* are employed:
* - Chaining of tables that allow runtime tables to chain to compile-time
* tables.
- * - Notion of current device (device_t) being worked on. This allows for
- * PCI config, io, and mmio on a particular device's resources.
*
* Note that when using REG_SCRIPT_COMMAND_NEXT there is an implicit push
* and pop of the context. A chained reg_script inherits the previous
@@ -87,13 +85,21 @@ struct reg_script {
union {
uint32_t id;
const struct reg_script *next;
- device_t dev;
+#ifdef __SIMPLE_DEVICE__
+ pci_devfn_t dev;
+#else
+ struct device *dev;
+#endif
unsigned int res_index;
};
};
struct reg_script_context {
- device_t dev;
+#ifdef __SIMPLE_DEVICE__
+ pci_devfn_t dev;
+#else
+ struct device *dev;
+#endif
struct resource *res;
const struct reg_script *step;
uint8_t display_state; /* Only modified by reg_script_run_step */
@@ -437,6 +443,10 @@ IS_ENABLED(CONFIG_SOC_INTEL_FSP_BAYTRAIL)
_REG_SCRIPT_ENCODE_RAW(REG_SCRIPT_COMMAND_END, 0, 0, 0, 0, 0, 0, 0)
void reg_script_run(const struct reg_script *script);
-void reg_script_run_on_dev(device_t dev, const struct reg_script *step);
+#ifdef __SIMPLE_DEVICE__
+void reg_script_run_on_dev(pci_devfn_t dev, const struct reg_script *step);
+#else
+void reg_script_run_on_dev(struct device *dev, const struct reg_script *step);
+#endif
#endif /* REG_SCRIPT_H */