11da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#ifndef __ALPHA_PCI_H 21da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define __ALPHA_PCI_H 31da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 41da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#ifdef __KERNEL__ 51da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 61da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <linux/spinlock.h> 77c53664dcd5df7349edb56f04c743bf66510a6f1FUJITA Tomonori#include <linux/dma-mapping.h> 81da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <asm/scatterlist.h> 91da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <asm/machvec.h> 10151d16d531c5bc60bad9dc62102be18f11b4280aBjorn Helgaas#include <asm-generic/pci-bridge.h> 111da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 121da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* 131da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * The following structure is used to manage multiple PCI busses. 141da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 151da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 161da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstruct pci_dev; 171da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstruct pci_bus; 181da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstruct resource; 191da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstruct pci_iommu_arena; 201da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstruct page; 211da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 221da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* A controller. Used to manage multiple PCI busses. */ 231da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 241da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstruct pci_controller { 251da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct pci_controller *next; 261da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct pci_bus *bus; 271da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct resource *io_space; 281da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct resource *mem_space; 291da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 301da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* The following are for reporting to userland. The invariant is 311da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds that if we report a BWX-capable dense memory, we do not report 321da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds a sparse memory at all, even if it exists. */ 331da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned long sparse_mem_base; 341da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned long dense_mem_base; 351da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned long sparse_io_base; 361da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned long dense_io_base; 371da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 381da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* This one's for the kernel only. It's in KSEG somewhere. */ 391da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned long config_space_base; 401da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 411da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned int index; 421da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* For compatibility with current (as of July 2003) pciutils 431da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds and XFree86. Eventually will be removed. */ 441da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned int need_domain_info; 451da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 461da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct pci_iommu_arena *sg_pci; 471da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct pci_iommu_arena *sg_isa; 481da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 491da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds void *sysdata; 501da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds}; 511da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 521da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* Override the logic in pci_scan_bus for skipping already-configured 531da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds bus numbers. */ 541da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 551da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define pcibios_assign_all_busses() 1 561da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 571da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define PCIBIOS_MIN_IO alpha_mv.min_io_address 581da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define PCIBIOS_MIN_MEM alpha_mv.min_mem_address 591da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 601da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsextern void pcibios_set_master(struct pci_dev *dev); 611da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 621da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* IOMMU controls. */ 631da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 641da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* The PCI address space does not equal the physical memory address space. 651da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds The networking and block device layers use this boolean for bounce buffer 661da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds decisions. */ 671da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define PCI_DMA_BUS_IS_PHYS 0 681da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 69c186caca3dbe7f44da624cb4f9d78e1b1dfb13b8FUJITA Tomonori#ifdef CONFIG_PCI 701da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 71c186caca3dbe7f44da624cb4f9d78e1b1dfb13b8FUJITA Tomonori/* implement the pci_ DMA API in terms of the generic device dma_ one */ 72c186caca3dbe7f44da624cb4f9d78e1b1dfb13b8FUJITA Tomonori#include <asm-generic/pci-dma-compat.h> 731da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 74e24c2d963a604d9eaa560c90371fa387d3eec8f1David S. Millerstatic inline void pci_dma_burst_advice(struct pci_dev *pdev, 75e24c2d963a604d9eaa560c90371fa387d3eec8f1David S. Miller enum pci_dma_burst_strategy *strat, 76e24c2d963a604d9eaa560c90371fa387d3eec8f1David S. Miller unsigned long *strategy_parameter) 77e24c2d963a604d9eaa560c90371fa387d3eec8f1David S. Miller{ 78e24c2d963a604d9eaa560c90371fa387d3eec8f1David S. Miller unsigned long cacheline_size; 79e24c2d963a604d9eaa560c90371fa387d3eec8f1David S. Miller u8 byte; 80e24c2d963a604d9eaa560c90371fa387d3eec8f1David S. Miller 81e24c2d963a604d9eaa560c90371fa387d3eec8f1David S. Miller pci_read_config_byte(pdev, PCI_CACHE_LINE_SIZE, &byte); 82e24c2d963a604d9eaa560c90371fa387d3eec8f1David S. Miller if (byte == 0) 83e24c2d963a604d9eaa560c90371fa387d3eec8f1David S. Miller cacheline_size = 1024; 84e24c2d963a604d9eaa560c90371fa387d3eec8f1David S. Miller else 85e24c2d963a604d9eaa560c90371fa387d3eec8f1David S. Miller cacheline_size = (int) byte * 4; 86e24c2d963a604d9eaa560c90371fa387d3eec8f1David S. Miller 87e24c2d963a604d9eaa560c90371fa387d3eec8f1David S. Miller *strat = PCI_DMA_BURST_BOUNDARY; 88e24c2d963a604d9eaa560c90371fa387d3eec8f1David S. Miller *strategy_parameter = cacheline_size; 89e24c2d963a604d9eaa560c90371fa387d3eec8f1David S. Miller} 90bb4a61b6eaee01707f24deeefc5d7136f25f75c5Andrew Morton#endif 91e24c2d963a604d9eaa560c90371fa387d3eec8f1David S. Miller 921da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* TODO: integrate with include/asm-generic/pci.h ? */ 931da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstatic inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel) 941da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 951da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return channel ? 15 : 14; 961da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 971da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 981da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define pci_domain_nr(bus) ((struct pci_controller *)(bus)->sysdata)->index 991da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1001da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstatic inline int pci_proc_domain(struct pci_bus *bus) 1011da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 1021da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct pci_controller *hose = bus->sysdata; 1031da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return hose->need_domain_info; 1041da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 1051da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1061da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#endif /* __KERNEL__ */ 1071da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1081da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* Values for the `which' argument to sys_pciconfig_iobase. */ 1091da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define IOBASE_HOSE 0 1101da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define IOBASE_SPARSE_MEM 1 1111da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define IOBASE_DENSE_MEM 2 1121da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define IOBASE_SPARSE_IO 3 1131da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define IOBASE_DENSE_IO 4 1141da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define IOBASE_ROOT_BUS 5 1151da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define IOBASE_FROM_HOSE 0x10000 1161da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1178255cf35d503db7c1b26ae53b6b7f23ada82316fAdrian Bunkextern struct pci_dev *isa_bridge; 1188255cf35d503db7c1b26ae53b6b7f23ada82316fAdrian Bunk 11910a0ef39fbd1d484c2bbc1ffd83d57ecef209140Ivan Kokshayskyextern int pci_legacy_read(struct pci_bus *bus, loff_t port, u32 *val, 12010a0ef39fbd1d484c2bbc1ffd83d57ecef209140Ivan Kokshaysky size_t count); 12110a0ef39fbd1d484c2bbc1ffd83d57ecef209140Ivan Kokshayskyextern int pci_legacy_write(struct pci_bus *bus, loff_t port, u32 val, 12210a0ef39fbd1d484c2bbc1ffd83d57ecef209140Ivan Kokshaysky size_t count); 12310a0ef39fbd1d484c2bbc1ffd83d57ecef209140Ivan Kokshayskyextern int pci_mmap_legacy_page_range(struct pci_bus *bus, 12410a0ef39fbd1d484c2bbc1ffd83d57ecef209140Ivan Kokshaysky struct vm_area_struct *vma, 12510a0ef39fbd1d484c2bbc1ffd83d57ecef209140Ivan Kokshaysky enum pci_mmap_state mmap_state); 12610a0ef39fbd1d484c2bbc1ffd83d57ecef209140Ivan Kokshayskyextern void pci_adjust_legacy_attr(struct pci_bus *bus, 12710a0ef39fbd1d484c2bbc1ffd83d57ecef209140Ivan Kokshaysky enum pci_mmap_state mmap_type); 12810a0ef39fbd1d484c2bbc1ffd83d57ecef209140Ivan Kokshaysky#define HAVE_PCI_LEGACY 1 12910a0ef39fbd1d484c2bbc1ffd83d57ecef209140Ivan Kokshaysky 13010a0ef39fbd1d484c2bbc1ffd83d57ecef209140Ivan Kokshayskyextern int pci_create_resource_files(struct pci_dev *dev); 13110a0ef39fbd1d484c2bbc1ffd83d57ecef209140Ivan Kokshayskyextern void pci_remove_resource_files(struct pci_dev *dev); 13210a0ef39fbd1d484c2bbc1ffd83d57ecef209140Ivan Kokshaysky 1331da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#endif /* __ALPHA_PCI_H */ 134