The PCI specifications says that an I/O region must be aligned on a 4 KB boundary, and a memory region aligned on a 1 MB boundary. However, the Marvell PCIe interfaces rely on address decoding windows (which allow to associate a range of physical addresses with a given device). For PCIe memory windows, those windows are defined with a 1 MB granularity (which matches the PCI specs), but PCIe I/O windows can only be defined with a 64 KB granularity, so they have to be 64 KB aligned. We therefore need to tell the PCI core about this special alignement requirement. The PCI core already calls pcibios_align_resource() in the ARM PCI core, specifically for such purposes. So this patch extends the ARM PCI core so that it calls a ->align_resource() hook registered by the PCI driver, exactly like the existing ->map_irq() and ->swizzle() hooks. A particular PCI driver can register a align_resource() hook, and do its own specific alignement, depending on the specific constraints of the underlying hardware. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
		
			
				
	
	
		
			104 lines
		
	
	
	
		
			2.8 KiB
			
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			104 lines
		
	
	
	
		
			2.8 KiB
			
		
	
	
	
		
			C
		
	
	
	
	
	
/*
 | 
						|
 *  arch/arm/include/asm/mach/pci.h
 | 
						|
 *
 | 
						|
 *  Copyright (C) 2000 Russell King
 | 
						|
 *
 | 
						|
 * This program is free software; you can redistribute it and/or modify
 | 
						|
 * it under the terms of the GNU General Public License version 2 as
 | 
						|
 * published by the Free Software Foundation.
 | 
						|
 */
 | 
						|
 | 
						|
#ifndef __ASM_MACH_PCI_H
 | 
						|
#define __ASM_MACH_PCI_H
 | 
						|
 | 
						|
#include <linux/ioport.h>
 | 
						|
 | 
						|
struct pci_sys_data;
 | 
						|
struct pci_ops;
 | 
						|
struct pci_bus;
 | 
						|
 | 
						|
struct hw_pci {
 | 
						|
#ifdef CONFIG_PCI_DOMAINS
 | 
						|
	int		domain;
 | 
						|
#endif
 | 
						|
	struct pci_ops	*ops;
 | 
						|
	int		nr_controllers;
 | 
						|
	void		**private_data;
 | 
						|
	int		(*setup)(int nr, struct pci_sys_data *);
 | 
						|
	struct pci_bus *(*scan)(int nr, struct pci_sys_data *);
 | 
						|
	void		(*preinit)(void);
 | 
						|
	void		(*postinit)(void);
 | 
						|
	u8		(*swizzle)(struct pci_dev *dev, u8 *pin);
 | 
						|
	int		(*map_irq)(const struct pci_dev *dev, u8 slot, u8 pin);
 | 
						|
	resource_size_t (*align_resource)(struct pci_dev *dev,
 | 
						|
					  const struct resource *res,
 | 
						|
					  resource_size_t start,
 | 
						|
					  resource_size_t size,
 | 
						|
					  resource_size_t align);
 | 
						|
};
 | 
						|
 | 
						|
/*
 | 
						|
 * Per-controller structure
 | 
						|
 */
 | 
						|
struct pci_sys_data {
 | 
						|
#ifdef CONFIG_PCI_DOMAINS
 | 
						|
	int		domain;
 | 
						|
#endif
 | 
						|
	struct list_head node;
 | 
						|
	int		busnr;		/* primary bus number			*/
 | 
						|
	u64		mem_offset;	/* bus->cpu memory mapping offset	*/
 | 
						|
	unsigned long	io_offset;	/* bus->cpu IO mapping offset		*/
 | 
						|
	struct pci_bus	*bus;		/* PCI bus				*/
 | 
						|
	struct list_head resources;	/* root bus resources (apertures)       */
 | 
						|
	struct resource io_res;
 | 
						|
	char		io_res_name[12];
 | 
						|
					/* Bridge swizzling			*/
 | 
						|
	u8		(*swizzle)(struct pci_dev *, u8 *);
 | 
						|
					/* IRQ mapping				*/
 | 
						|
	int		(*map_irq)(const struct pci_dev *, u8, u8);
 | 
						|
					/* Resource alignement requirements	*/
 | 
						|
	resource_size_t (*align_resource)(struct pci_dev *dev,
 | 
						|
					  const struct resource *res,
 | 
						|
					  resource_size_t start,
 | 
						|
					  resource_size_t size,
 | 
						|
					  resource_size_t align);
 | 
						|
	void		*private_data;	/* platform controller private data	*/
 | 
						|
};
 | 
						|
 | 
						|
/*
 | 
						|
 * Call this with your hw_pci struct to initialise the PCI system.
 | 
						|
 */
 | 
						|
void pci_common_init(struct hw_pci *);
 | 
						|
 | 
						|
/*
 | 
						|
 * Setup early fixed I/O mapping.
 | 
						|
 */
 | 
						|
#if defined(CONFIG_PCI)
 | 
						|
extern void pci_map_io_early(unsigned long pfn);
 | 
						|
#else
 | 
						|
static inline void pci_map_io_early(unsigned long pfn) {}
 | 
						|
#endif
 | 
						|
 | 
						|
/*
 | 
						|
 * PCI controllers
 | 
						|
 */
 | 
						|
extern struct pci_ops iop3xx_ops;
 | 
						|
extern int iop3xx_pci_setup(int nr, struct pci_sys_data *);
 | 
						|
extern void iop3xx_pci_preinit(void);
 | 
						|
extern void iop3xx_pci_preinit_cond(void);
 | 
						|
 | 
						|
extern struct pci_ops dc21285_ops;
 | 
						|
extern int dc21285_setup(int nr, struct pci_sys_data *);
 | 
						|
extern void dc21285_preinit(void);
 | 
						|
extern void dc21285_postinit(void);
 | 
						|
 | 
						|
extern struct pci_ops via82c505_ops;
 | 
						|
extern int via82c505_setup(int nr, struct pci_sys_data *);
 | 
						|
extern void via82c505_init(void *sysdata);
 | 
						|
 | 
						|
extern struct pci_ops pci_v3_ops;
 | 
						|
extern int pci_v3_setup(int nr, struct pci_sys_data *);
 | 
						|
extern void pci_v3_preinit(void);
 | 
						|
extern void pci_v3_postinit(void);
 | 
						|
 | 
						|
#endif /* __ASM_MACH_PCI_H */
 |