mirror of
https://github.com/torvalds/linux.git
synced 2026-05-28 17:13:52 +02:00
Loongson2ef reserves io range below 0x4000 (LOONGSON_PCI_IO_START) while ISA-mode only IDE controller on the south bridge still has a hard dependency on ISA IO ports. The reservation was done by lifting loongson_pci_io_resource.start onto 0x4000. Prior to commitae81aad5c2("MIPS: PCI: Use pci_enable_resources()"), the arch specific pcibios_enable_resources() did not check if the resources were claimed, which diverges from what PCI core checks, effectively hiding the fact that IDE IO resources were not properly within the resource tree. After starting to use pcibios_enable_resources() from PCI core, enabling IDE controller fails: pata_cs5536 0000:00:0e.2: BAR 0 [io 0x01f0-0x01f7]: not claimed; can't enable device pata_cs5536 0000:00:0e.2: probe with driver pata_cs5536 failed with error -22 MIPS PCI code already has support for enforcing lower bounds using PCIBIOS_MIN_IO in pcibios_align_resource() without altering the IO window start address itself. Make Loongson2ef PCI code use PCIBIOS_MIN_IO too. Fixes:ae81aad5c2("MIPS: PCI: Use pci_enable_resources()") Cc: stable@vger.kernel.org Tested-by: Beiyan Yun <root@infi.wang> Tested-by: Yao Zi <me@ziyao.cc> Signed-off-by: Rong Zhang <rongrong@oss.cipunited.com> Acked-by: Jiaxun Yang <jiaxun.yang@flygoat.com> Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
92 lines
2.7 KiB
C
92 lines
2.7 KiB
C
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
/*
|
|
* Copyright (C) 2007 Lemote, Inc. & Institute of Computing Technology
|
|
* Author: Fuxin Zhang, zhangfx@lemote.com
|
|
*/
|
|
#include <linux/pci.h>
|
|
|
|
#include <pci.h>
|
|
#include <loongson.h>
|
|
|
|
static struct resource loongson_pci_mem_resource = {
|
|
.name = "pci memory space",
|
|
.start = LOONGSON_PCI_MEM_START,
|
|
.end = LOONGSON_PCI_MEM_END,
|
|
.flags = IORESOURCE_MEM,
|
|
};
|
|
|
|
static struct resource loongson_pci_io_resource = {
|
|
.name = "pci io space",
|
|
.start = 0x00000000UL, /* See loongson2ef_pcibios_init(). */
|
|
.end = IO_SPACE_LIMIT,
|
|
.flags = IORESOURCE_IO,
|
|
};
|
|
|
|
static struct pci_controller loongson_pci_controller = {
|
|
.pci_ops = &loongson_pci_ops,
|
|
.io_resource = &loongson_pci_io_resource,
|
|
.mem_resource = &loongson_pci_mem_resource,
|
|
.mem_offset = 0x00000000UL,
|
|
.io_offset = 0x00000000UL,
|
|
};
|
|
|
|
static void __init setup_pcimap(void)
|
|
{
|
|
/*
|
|
* local to PCI mapping for CPU accessing PCI space
|
|
* CPU address space [256M,448M] is window for accessing pci space
|
|
* we set pcimap_lo[0,1,2] to map it to pci space[0M,64M], [320M,448M]
|
|
*
|
|
* pcimap: PCI_MAP2 PCI_Mem_Lo2 PCI_Mem_Lo1 PCI_Mem_Lo0
|
|
* [<2G] [384M,448M] [320M,384M] [0M,64M]
|
|
*/
|
|
LOONGSON_PCIMAP = LOONGSON_PCIMAP_PCIMAP_2 |
|
|
LOONGSON_PCIMAP_WIN(2, LOONGSON_PCILO2_BASE) |
|
|
LOONGSON_PCIMAP_WIN(1, LOONGSON_PCILO1_BASE) |
|
|
LOONGSON_PCIMAP_WIN(0, 0);
|
|
|
|
/*
|
|
* PCI-DMA to local mapping: [2G,2G+256M] -> [0M,256M]
|
|
*/
|
|
LOONGSON_PCIBASE0 = 0x80000000ul; /* base: 2G -> mmap: 0M */
|
|
/* size: 256M, burst transmission, pre-fetch enable, 64bit */
|
|
LOONGSON_PCI_HIT0_SEL_L = 0xc000000cul;
|
|
LOONGSON_PCI_HIT0_SEL_H = 0xfffffffful;
|
|
LOONGSON_PCI_HIT1_SEL_L = 0x00000006ul; /* set this BAR as invalid */
|
|
LOONGSON_PCI_HIT1_SEL_H = 0x00000000ul;
|
|
LOONGSON_PCI_HIT2_SEL_L = 0x00000006ul; /* set this BAR as invalid */
|
|
LOONGSON_PCI_HIT2_SEL_H = 0x00000000ul;
|
|
|
|
/* avoid deadlock of PCI reading/writing lock operation */
|
|
LOONGSON_PCI_ISR4C = 0xd2000001ul;
|
|
|
|
/* can not change gnt to break pci transfer when device's gnt not
|
|
deassert for some broken device */
|
|
LOONGSON_PXARB_CFG = 0x00fe0105ul;
|
|
|
|
#ifdef CONFIG_CPU_SUPPORTS_ADDRWINCFG
|
|
/*
|
|
* set cpu addr window2 to map CPU address space to PCI address space
|
|
*/
|
|
LOONGSON_ADDRWIN_CPUTOPCI(ADDRWIN_WIN2, LOONGSON_CPU_MEM_SRC,
|
|
LOONGSON_PCI_MEM_DST, MMAP_CPUTOPCI_SIZE);
|
|
#endif
|
|
}
|
|
|
|
void __init loongson2ef_pcibios_init(void)
|
|
{
|
|
setup_pcimap();
|
|
|
|
/*
|
|
* ISA-mode only IDE controllers have a hard dependency on ISA IO ports.
|
|
*
|
|
* Claim them by setting PCI IO space to start at 0x00000000, and set
|
|
* PCIBIOS_MIN_IO to prevent non-legacy PCI devices from touching
|
|
* reserved regions.
|
|
*/
|
|
PCIBIOS_MIN_IO = LOONGSON_PCI_IO_START;
|
|
|
|
loongson_pci_controller.io_map_base = mips_io_port_base;
|
|
register_pci_controller(&loongson_pci_controller);
|
|
}
|