2003-04-24 08:25:08 +02:00
|
|
|
#ifndef PCI_OPS_H
|
|
|
|
#define PCI_OPS_H
|
|
|
|
|
|
|
|
#include <stdint.h>
|
2003-06-12 21:23:51 +02:00
|
|
|
#include <device/device.h>
|
2004-11-04 12:04:33 +01:00
|
|
|
#include <arch/pci_ops.h>
|
2003-06-12 21:23:51 +02:00
|
|
|
|
2019-03-01 07:08:28 +01:00
|
|
|
#ifdef __SIMPLE_DEVICE__
|
|
|
|
|
|
|
|
/* Avoid name collisions as different stages have different signature
|
|
|
|
* for these functions. The _s_ stands for simple, fundamental IO or
|
|
|
|
* MMIO variant.
|
|
|
|
*/
|
|
|
|
#define pci_read_config8 pci_s_read_config8
|
|
|
|
#define pci_read_config16 pci_s_read_config16
|
|
|
|
#define pci_read_config32 pci_s_read_config32
|
|
|
|
#define pci_write_config8 pci_s_write_config8
|
|
|
|
#define pci_write_config16 pci_s_write_config16
|
|
|
|
#define pci_write_config32 pci_s_write_config32
|
|
|
|
#else
|
2014-10-28 17:04:40 +01:00
|
|
|
u8 pci_read_config8(struct device *dev, unsigned int where);
|
|
|
|
u16 pci_read_config16(struct device *dev, unsigned int where);
|
|
|
|
u32 pci_read_config32(struct device *dev, unsigned int where);
|
|
|
|
void pci_write_config8(struct device *dev, unsigned int where, u8 val);
|
|
|
|
void pci_write_config16(struct device *dev, unsigned int where, u16 val);
|
|
|
|
void pci_write_config32(struct device *dev, unsigned int where, u32 val);
|
2019-03-01 12:43:02 +01:00
|
|
|
const struct pci_bus_operations *pci_bus_default_ops(struct device *dev);
|
2013-03-21 19:51:41 +01:00
|
|
|
#endif
|
2009-03-06 20:11:52 +01:00
|
|
|
|
2018-12-05 11:03:36 +01:00
|
|
|
#ifdef __SIMPLE_DEVICE__
|
2018-09-13 10:10:45 +02:00
|
|
|
static __always_inline
|
2018-12-05 11:03:36 +01:00
|
|
|
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
|
2018-04-18 10:11:59 +02:00
|
|
|
{
|
|
|
|
u8 value = pci_read_config8(dev, where);
|
|
|
|
pci_write_config8(dev, where, value | ormask);
|
|
|
|
}
|
|
|
|
|
2018-12-05 11:03:36 +01:00
|
|
|
#ifdef __SIMPLE_DEVICE__
|
|
|
|
static __always_inline
|
|
|
|
void pci_or_config16(pci_devfn_t dev, unsigned int where, u16 ormask)
|
|
|
|
#else
|
2018-09-13 10:10:45 +02:00
|
|
|
static __always_inline
|
2018-12-05 11:03:36 +01:00
|
|
|
void pci_or_config16(struct device *dev, unsigned int where, u16 ormask)
|
|
|
|
#endif
|
2018-04-18 10:11:59 +02:00
|
|
|
{
|
|
|
|
u16 value = pci_read_config16(dev, where);
|
|
|
|
pci_write_config16(dev, where, value | ormask);
|
|
|
|
}
|
|
|
|
|
2018-12-05 11:03:36 +01:00
|
|
|
#ifdef __SIMPLE_DEVICE__
|
|
|
|
static __always_inline
|
|
|
|
void pci_or_config32(pci_devfn_t dev, unsigned int where, u32 ormask)
|
|
|
|
#else
|
2018-09-13 10:10:45 +02:00
|
|
|
static __always_inline
|
2018-12-05 11:03:36 +01:00
|
|
|
void pci_or_config32(struct device *dev, unsigned int where, u32 ormask)
|
|
|
|
#endif
|
2018-04-18 10:11:59 +02:00
|
|
|
{
|
|
|
|
u32 value = pci_read_config32(dev, where);
|
|
|
|
pci_write_config32(dev, where, value | ormask);
|
|
|
|
}
|
|
|
|
|
2018-12-05 11:03:36 +01:00
|
|
|
#ifdef __SIMPLE_DEVICE__
|
2018-09-13 10:10:45 +02:00
|
|
|
static __always_inline
|
2018-12-05 11:03:36 +01:00
|
|
|
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
|
2018-04-18 10:11:59 +02:00
|
|
|
{
|
|
|
|
u8 reg8;
|
|
|
|
|
|
|
|
reg8 = pci_read_config8(dev, reg);
|
|
|
|
reg8 &= mask;
|
|
|
|
reg8 |= or;
|
|
|
|
pci_write_config8(dev, reg, reg8);
|
|
|
|
}
|
|
|
|
|
2018-12-05 11:03:36 +01:00
|
|
|
#ifdef __SIMPLE_DEVICE__
|
|
|
|
static __always_inline
|
|
|
|
void pci_update_config16(pci_devfn_t dev, int reg, u16 mask, u16 or)
|
|
|
|
#else
|
2018-09-13 10:10:45 +02:00
|
|
|
static __always_inline
|
2018-12-05 11:03:36 +01:00
|
|
|
void pci_update_config16(struct device *dev, int reg, u16 mask, u16 or)
|
|
|
|
#endif
|
2018-04-18 10:11:59 +02:00
|
|
|
{
|
|
|
|
u16 reg16;
|
|
|
|
|
|
|
|
reg16 = pci_read_config16(dev, reg);
|
|
|
|
reg16 &= mask;
|
|
|
|
reg16 |= or;
|
|
|
|
pci_write_config16(dev, reg, reg16);
|
|
|
|
}
|
|
|
|
|
2018-12-05 11:03:36 +01:00
|
|
|
#ifdef __SIMPLE_DEVICE__
|
|
|
|
static __always_inline
|
|
|
|
void pci_update_config32(pci_devfn_t dev, int reg, u32 mask, u32 or)
|
|
|
|
#else
|
2018-09-13 10:10:45 +02:00
|
|
|
static __always_inline
|
2018-12-05 11:03:36 +01:00
|
|
|
void pci_update_config32(struct device *dev, int reg, u32 mask, u32 or)
|
|
|
|
#endif
|
2018-04-18 10:11:59 +02:00
|
|
|
{
|
|
|
|
u32 reg32;
|
|
|
|
|
|
|
|
reg32 = pci_read_config32(dev, reg);
|
|
|
|
reg32 &= mask;
|
|
|
|
reg32 |= or;
|
|
|
|
pci_write_config32(dev, reg, reg32);
|
|
|
|
}
|
|
|
|
|
2003-04-24 08:25:08 +02:00
|
|
|
#endif /* PCI_OPS_H */
|