From 3478d912663ddf9eaf8273e361ad93d9ba8474c9 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sat, 2 Jan 2010 23:08:15 +0000 Subject: amazon: work on pci controller SVN-Revision: 19013 --- target/linux/amazon/config-2.6.30 | 1 + target/linux/amazon/files/arch/mips/amazon/pci.c | 81 ++++++++++------------ target/linux/amazon/files/arch/mips/amazon/setup.c | 5 ++ .../amazon/files/include/asm-mips/amazon/amazon.h | 11 ++- .../include/asm-mips/mach-amazon/mangle-port.h | 52 -------------- target/linux/amazon/patches-2.6.30/100-board.patch | 5 +- 6 files changed, 54 insertions(+), 101 deletions(-) delete mode 100644 target/linux/amazon/files/include/asm-mips/mach-amazon/mangle-port.h (limited to 'target/linux') diff --git a/target/linux/amazon/config-2.6.30 b/target/linux/amazon/config-2.6.30 index f9124795bc..fa062cee93 100644 --- a/target/linux/amazon/config-2.6.30 +++ b/target/linux/amazon/config-2.6.30 @@ -138,6 +138,7 @@ CONFIG_SCHED_OMIT_FRAME_POINTER=y # CONFIG_SIBYTE_SENTOSA is not set # CONFIG_SIBYTE_SWARM is not set # CONFIG_SLOW_WORK is not set +CONFIG_SWAP_IO_SPACE=y CONFIG_SYS_HAS_CPU_MIPS32_R1=y CONFIG_SYS_HAS_CPU_MIPS32_R2=y CONFIG_SYS_HAS_EARLY_PRINTK=y diff --git a/target/linux/amazon/files/arch/mips/amazon/pci.c b/target/linux/amazon/files/arch/mips/amazon/pci.c index a5596c80d4..1b2afb9d4f 100644 --- a/target/linux/amazon/files/arch/mips/amazon/pci.c +++ b/target/linux/amazon/files/arch/mips/amazon/pci.c @@ -36,7 +36,7 @@ #endif #define AMAZON_PCI_MEM_SIZE 0x00400000 #define AMAZON_PCI_IO_BASE 0xb2400000 -#define AMAZON_PCI_IO_SIZE 0x00002000 +#define AMAZON_PCI_IO_SIZE 0x00200000 #define AMAZON_PCI_CFG_BUSNUM_SHF 16 #define AMAZON_PCI_CFG_DEVNUM_SHF 11 @@ -45,27 +45,15 @@ #define PCI_ACCESS_READ 0 #define PCI_ACCESS_WRITE 1 -static inline u32 amazon_r32(u32 addr) -{ - u32 *ptr = (u32 *) addr; - return __raw_readl(ptr); -} - -static inline void amazon_w32(u32 addr, u32 val) -{ - u32 *ptr = (u32 *) addr; - __raw_writel(val, ptr); -} - - static struct resource pci_io_resource = { .name = "io pci IO space", -#if 0 +#if 1 .start = AMAZON_PCI_IO_BASE, .end = AMAZON_PCI_IO_BASE + AMAZON_PCI_IO_SIZE - 1, -#endif +#else .start = 0, - .end = AMAZON_PCI_IO_SIZE - 1, + .end = 0x00002000 - 1, +#endif .flags = IORESOURCE_IO }; @@ -76,15 +64,6 @@ static struct resource pci_mem_resource = { .flags = IORESOURCE_MEM }; -static inline u32 amazon_pci_swap(u32 val) -{ -#ifdef CONFIG_AMAZON_PCI_HW_SWAP - return swab32(val); -#else - return val; -#endif -} - static int amazon_pci_config_access(unsigned char access_type, struct pci_bus *bus, unsigned int devfn, unsigned int where, u32 *data) { @@ -92,31 +71,43 @@ static int amazon_pci_config_access(unsigned char access_type, u32 pci_addr; u32 val; int ret; - + /* Amazon support slot from 0 to 15 */ /* devfn 0 & 0x20 is itself */ - if ((bus->number != 0) || (devfn == 0) || (devfn == 0x20)) + if ((bus->number != 0) || (devfn > 0x7f) || (devfn == 0) || (devfn == 0x20)) return 1; - pci_addr=AMAZON_PCI_CFG_BASE | + local_irq_save(flags); + + pci_addr = AMAZON_PCI_CFG_BASE | bus->number << AMAZON_PCI_CFG_BUSNUM_SHF | devfn << AMAZON_PCI_CFG_FUNNUM_SHF | (where & ~0x3); - - local_irq_save(flags); - if (access_type == PCI_ACCESS_WRITE) { - val = amazon_pci_swap(*data); + + if (access_type == PCI_ACCESS_WRITE) + { +#ifdef CONFIG_SWAP_IO_SPACE + val = swab32(*data); +#endif ret = put_dbe(val, (u32 *)pci_addr); } else { ret = get_dbe(val, (u32 *)pci_addr); - *data = amazon_pci_swap(val); +#ifdef CONFIG_SWAP_IO_SPACE + *data = swab32(val); +#else + *data = val; +#endif } - amazon_w32(PCI_MODE, amazon_r32(PCI_MODE) & (~(1<