📄 pci.h
字号:
#define PCI_AGP_STATUS_RQ_MASK 0xff000000 /* Maximum number of requests - 1 */#define PCI_AGP_STATUS_SBA 0x0200 /* Sideband addressing supported */#define PCI_AGP_STATUS_64BIT 0x0020 /* 64-bit addressing supported */#define PCI_AGP_STATUS_FW 0x0010 /* FW transfers supported */#define PCI_AGP_STATUS_RATE4 0x0004 /* 4x transfer rate supported */#define PCI_AGP_STATUS_RATE2 0x0002 /* 2x transfer rate supported */#define PCI_AGP_STATUS_RATE1 0x0001 /* 1x transfer rate supported */#define PCI_AGP_COMMAND 8 /* Control register */#define PCI_AGP_COMMAND_RQ_MASK 0xff000000 /* Master: Maximum number of requests */#define PCI_AGP_COMMAND_SBA 0x0200 /* Sideband addressing enabled */#define PCI_AGP_COMMAND_AGP 0x0100 /* Allow processing of AGP transactions */#define PCI_AGP_COMMAND_64BIT 0x0020 /* Allow processing of 64-bit addresses */#define PCI_AGP_COMMAND_FW 0x0010 /* Force FW transfers */#define PCI_AGP_COMMAND_RATE4 0x0004 /* Use 4x rate */#define PCI_AGP_COMMAND_RATE2 0x0002 /* Use 4x rate */#define PCI_AGP_COMMAND_RATE1 0x0001 /* Use 4x rate */#define PCI_AGP_SIZEOF 12/* PCI-X registers */#define PCI_X_CMD_DPERR_E 0x0001 /* Data Parity Error Recovery Enable */#define PCI_X_CMD_ERO 0x0002 /* Enable Relaxed Ordering */#define PCI_X_CMD_MAX_READ 0x0000 /* Max Memory Read Byte Count */#define PCI_X_CMD_MAX_SPLIT 0x0030 /* Max Outstanding Split Transactions */#define PCI_X_CMD_VERSION(x) (((x) >> 12) & 3) /* Version *//* Slot Identification */#define PCI_SID_ESR 2 /* Expansion Slot Register */#define PCI_SID_ESR_NSLOTS 0x1f /* Number of expansion slots available */#define PCI_SID_ESR_FIC 0x20 /* First In Chassis Flag */#define PCI_SID_CHASSIS_NR 3 /* Chassis Number *//* Message Signalled Interrupts registers */#define PCI_MSI_FLAGS 2 /* Various flags */#define PCI_MSI_FLAGS_64BIT 0x80 /* 64-bit addresses allowed */#define PCI_MSI_FLAGS_QSIZE 0x70 /* Message queue size configured */#define PCI_MSI_FLAGS_QMASK 0x0e /* Maximum queue size available */#define PCI_MSI_FLAGS_ENABLE 0x01 /* MSI feature enabled */#define PCI_MSI_RFU 3 /* Rest of capability flags */#define PCI_MSI_ADDRESS_LO 4 /* Lower 32 bits */#define PCI_MSI_ADDRESS_HI 8 /* Upper 32 bits (if PCI_MSI_FLAGS_64BIT set) */#define PCI_MSI_DATA_32 8 /* 16 bits of data for 32-bit devices */#define PCI_MSI_DATA_64 12 /* 16 bits of data for 64-bit devices */#define PCI_MAX_PCI_DEVICES 32#define PCI_MAX_PCI_FUNCTIONS 8/* Include the ID list */#include <pci_ids.h>struct pci_region { unsigned long bus_start; /* Start on the bus */ unsigned long phys_start; /* Start in physical address space */ unsigned long size; /* Size */ unsigned long flags; /* Resource flags */ unsigned long bus_lower;};#define PCI_REGION_MEM 0x00000000 /* PCI memory space */#define PCI_REGION_IO 0x00000001 /* PCI IO space */#define PCI_REGION_TYPE 0x00000001#define PCI_REGION_PREFETCH 0x00000008 /* prefetchable PCI memory */#define PCI_REGION_MEMORY 0x00000100 /* System memory */#define PCI_REGION_RO 0x00000200 /* Read-only memory */extern __inline__ void pci_set_region(struct pci_region *reg, unsigned long bus_start, unsigned long phys_start, unsigned long size, unsigned long flags) { reg->bus_start = bus_start; reg->phys_start = phys_start; reg->size = size; reg->flags = flags;}typedef int pci_dev_t;#define PCI_BUS(d) (((d) >> 16) & 0xff)#define PCI_DEV(d) (((d) >> 11) & 0x1f)#define PCI_FUNC(d) (((d) >> 8) & 0x7)#define PCI_BDF(b,d,f) ((b) << 16 | (d) << 11 | (f) << 8)#define PCI_ANY_ID (~0)struct pci_device_id { unsigned int vendor, device; /* Vendor and device ID or PCI_ANY_ID */};struct pci_controller;struct pci_config_table { unsigned int vendor, device; /* Vendor and device ID or PCI_ANY_ID */ unsigned int class; /* Class ID, or PCI_ANY_ID */ unsigned int bus; /* Bus number, or PCI_ANY_ID */ unsigned int dev; /* Device number, or PCI_ANY_ID */ unsigned int func; /* Function number, or PCI_ANY_ID */ void (*config_device)(struct pci_controller* hose, pci_dev_t dev, struct pci_config_table *); unsigned long priv[3];};extern void pci_cfgfunc_do_nothing(struct pci_controller* hose, pci_dev_t dev, struct pci_config_table *);extern void pci_cfgfunc_config_device(struct pci_controller* hose, pci_dev_t dev, struct pci_config_table *);#define MAX_PCI_REGIONS 7/* * Structure of a PCI controller (host bridge) */struct pci_controller { struct pci_controller *next; int first_busno; int last_busno; volatile unsigned int *cfg_addr; volatile unsigned char *cfg_data; struct pci_region regions[MAX_PCI_REGIONS]; int region_count; struct pci_config_table *config_table; void (*fixup_irq)(struct pci_controller *, pci_dev_t); /* Low-level architecture-dependent routines */ int (*read_byte)(struct pci_controller*, pci_dev_t, int where, u8 *); int (*read_word)(struct pci_controller*, pci_dev_t, int where, u16 *); int (*read_dword)(struct pci_controller*, pci_dev_t, int where, u32 *); int (*write_byte)(struct pci_controller*, pci_dev_t, int where, u8); int (*write_word)(struct pci_controller*, pci_dev_t, int where, u16); int (*write_dword)(struct pci_controller*, pci_dev_t, int where, u32); /* Used by auto config */ struct pci_region *pci_mem, *pci_io, *pci_prefetch; /* Used by ppc405 autoconfig*/ struct pci_region *pci_fb; int current_busno;};extern __inline__ void pci_set_ops(struct pci_controller *hose, int (*read_byte)(struct pci_controller*, pci_dev_t, int where, u8 *), int (*read_word)(struct pci_controller*, pci_dev_t, int where, u16 *), int (*read_dword)(struct pci_controller*, pci_dev_t, int where, u32 *), int (*write_byte)(struct pci_controller*, pci_dev_t, int where, u8), int (*write_word)(struct pci_controller*, pci_dev_t, int where, u16), int (*write_dword)(struct pci_controller*, pci_dev_t, int where, u32)) { hose->read_byte = read_byte; hose->read_word = read_word; hose->read_dword = read_dword; hose->write_byte = write_byte; hose->write_word = write_word; hose->write_dword = write_dword;}extern void pci_setup_indirect(struct pci_controller* hose, u32 cfg_addr, u32 cfg_data);extern unsigned long pci_hose_bus_to_phys(struct pci_controller* hose, unsigned long addr, unsigned long flags);extern unsigned long pci_hose_phys_to_bus(struct pci_controller* hose, unsigned long addr, unsigned long flags);#define pci_phys_to_bus(dev, addr, flags) \ pci_hose_phys_to_bus(pci_bus_to_hose(PCI_BUS(dev)), (addr), (flags))#define pci_bus_to_phys(dev, addr, flags) \ pci_hose_bus_to_phys(pci_bus_to_hose(PCI_BUS(dev)), (addr), (flags))#define pci_phys_to_mem(dev, addr) pci_phys_to_bus((dev), (addr), PCI_REGION_MEM)#define pci_mem_to_phys(dev, addr) pci_bus_to_phys((dev), (addr), PCI_REGION_MEM)#define pci_phys_to_io(dev, addr) pci_phys_to_bus((dev), (addr), PCI_REGION_IO)#define pci_io_to_phys(dev, addr) pci_bus_to_phys((dev), (addr), PCI_REGION_IO)extern int pci_hose_read_config_byte(struct pci_controller *hose, pci_dev_t dev, int where, u8 *val);extern int pci_hose_read_config_word(struct pci_controller *hose, pci_dev_t dev, int where, u16 *val);extern int pci_hose_read_config_dword(struct pci_controller *hose, pci_dev_t dev, int where, u32 *val);extern int pci_hose_write_config_byte(struct pci_controller *hose, pci_dev_t dev, int where, u8 val);extern int pci_hose_write_config_word(struct pci_controller *hose, pci_dev_t dev, int where, u16 val);extern int pci_hose_write_config_dword(struct pci_controller *hose, pci_dev_t dev, int where, u32 val);extern int pci_read_config_byte(pci_dev_t dev, int where, u8 *val);extern int pci_read_config_word(pci_dev_t dev, int where, u16 *val);extern int pci_read_config_dword(pci_dev_t dev, int where, u32 *val);extern int pci_write_config_byte(pci_dev_t dev, int where, u8 val);extern int pci_write_config_word(pci_dev_t dev, int where, u16 val);extern int pci_write_config_dword(pci_dev_t dev, int where, u32 val);extern int pci_hose_read_config_byte_via_dword(struct pci_controller *hose, pci_dev_t dev, int where, u8 *val);extern int pci_hose_read_config_word_via_dword(struct pci_controller *hose, pci_dev_t dev, int where, u16 *val);extern int pci_hose_write_config_byte_via_dword(struct pci_controller *hose, pci_dev_t dev, int where, u8 val);extern int pci_hose_write_config_word_via_dword(struct pci_controller *hose, pci_dev_t dev, int where, u16 val);extern void pci_register_hose(struct pci_controller* hose);extern struct pci_controller* pci_bus_to_hose(int bus);extern int pci_hose_scan(struct pci_controller *hose);extern int pci_hose_scan_bus(struct pci_controller *hose, int bus);extern void pciauto_region_init(struct pci_region* res);extern void pciauto_region_align(struct pci_region *res, unsigned long size);extern int pciauto_region_allocate(struct pci_region* res, unsigned int size, unsigned int *bar);extern void pciauto_setup_device(struct pci_controller *hose, pci_dev_t dev, int bars_num, struct pci_region *mem, struct pci_region *prefetch, struct pci_region *io);int pciauto_config_device(struct pci_controller *hose, pci_dev_t dev);extern pci_dev_t pci_find_device (unsigned int vendor, unsigned int device, int index);extern pci_dev_t pci_find_devices (struct pci_device_id *ids, int index);extern pci_dev_t pci_find_class(int wanted_class, int wanted_sub_code, int wanted_prog_if, int index);extern int pci_hose_config_device(struct pci_controller *hose, pci_dev_t dev, unsigned long io, unsigned long mem, unsigned long command);#ifdef CONFIG_MPC824Xextern void pci_mpc824x_init (struct pci_controller *hose);#endif#ifdef CONFIG_MPC85xxextern void pci_mpc85xx_init (struct pci_controller *hose);#endif#endif /* _PCI_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -