From: Huacai Chen <chenhc@lemote.com>
To: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: linux-mips@vger.kernel.org, Fuxin Zhang <zhangfx@lemote.com>,
Zhangjin Wu <wuzhangjin@gmail.com>,
Huacai Chen <chenhuacai@gmail.com>,
Jiaxun Yang <jiaxun.yang@flygoat.com>,
Huacai Chen <chenhc@lemote.com>
Subject: [PATCH V2] MIPS: Loongson64: Reserve legacy MMIO space according to bridge type
Date: Fri, 17 Jul 2020 17:10:35 +0800 [thread overview]
Message-ID: <1594977035-27899-1-git-send-email-chenhc@lemote.com> (raw)
Define MMIO_LOWER_RESERVED as a constant is incorrect, because different
PCHs (bridge types) have different legacy MMIO space size. According to
the datasheets, the legacy MMIO space size of LS7A is 0x20000, and which
of other PCHs is 0x4000. So it is necessary to reserve legacy MMIO space
according to the bridge type.
Currently IO_SPACE_LIMIT is defined as 0xffff which is too small for the
LS7A bridge, so increase it to 0xfffff for LOONGSON64.
Signed-off-by: Huacai Chen <chenhc@lemote.com>
---
arch/mips/include/asm/io.h | 2 --
arch/mips/include/asm/mach-generic/spaces.h | 4 ++++
arch/mips/include/asm/mach-loongson64/spaces.h | 3 +--
arch/mips/loongson64/init.c | 18 ++++++++++++++----
4 files changed, 19 insertions(+), 8 deletions(-)
diff --git a/arch/mips/include/asm/io.h b/arch/mips/include/asm/io.h
index 346fffd..8ca53f1 100644
--- a/arch/mips/include/asm/io.h
+++ b/arch/mips/include/asm/io.h
@@ -51,8 +51,6 @@
/* ioswab[bwlq], __mem_ioswab[bwlq] are defined in mangle-port.h */
-#define IO_SPACE_LIMIT 0xffff
-
/*
* On MIPS I/O ports are memory mapped, so we access them using normal
* load/store instructions. mips_io_port_base is the virtual address to
diff --git a/arch/mips/include/asm/mach-generic/spaces.h b/arch/mips/include/asm/mach-generic/spaces.h
index ee5ebe9..aa84b85 100644
--- a/arch/mips/include/asm/mach-generic/spaces.h
+++ b/arch/mips/include/asm/mach-generic/spaces.h
@@ -103,4 +103,8 @@
#endif
#endif
+#ifndef IO_SPACE_LIMIT
+#define IO_SPACE_LIMIT 0xffff
+#endif
+
#endif /* __ASM_MACH_GENERIC_SPACES_H */
diff --git a/arch/mips/include/asm/mach-loongson64/spaces.h b/arch/mips/include/asm/mach-loongson64/spaces.h
index 3de0ac9..0ad02c8 100644
--- a/arch/mips/include/asm/mach-loongson64/spaces.h
+++ b/arch/mips/include/asm/mach-loongson64/spaces.h
@@ -11,8 +11,7 @@
#define PCI_IOSIZE SZ_16M
#define MAP_BASE (PCI_IOBASE + PCI_IOSIZE)
-/* Reserved at the start of PCI_IOBASE for legacy drivers */
-#define MMIO_LOWER_RESERVED 0x10000
+#define IO_SPACE_LIMIT 0xfffff
#include <asm/mach-generic/spaces.h>
#endif
diff --git a/arch/mips/loongson64/init.c b/arch/mips/loongson64/init.c
index 59ddada..606cdc4 100644
--- a/arch/mips/loongson64/init.c
+++ b/arch/mips/loongson64/init.c
@@ -65,14 +65,25 @@ void __init prom_free_prom_memory(void)
static __init void reserve_pio_range(void)
{
+ /* Reserved at the start of PCI_IOBASE for legacy drivers */
+ int mmio_lower_reserved;
struct logic_pio_hwaddr *range;
range = kzalloc(sizeof(*range), GFP_ATOMIC);
if (!range)
return;
+ switch (loongson_sysconf.bridgetype) {
+ case LS7A:
+ mmio_lower_reserved = 0x20000;
+ break;
+ default:
+ mmio_lower_reserved = 0x4000;
+ break;
+ }
+
range->fwnode = &of_root->fwnode;
- range->size = MMIO_LOWER_RESERVED;
+ range->size = mmio_lower_reserved;
range->hw_start = LOONGSON_PCIIO_BASE;
range->flags = LOGIC_PIO_CPU_MMIO;
@@ -89,9 +100,8 @@ static __init void reserve_pio_range(void)
* i8259 would access I/O space, so mapping must be done here.
* Please remove it when all drivers can be managed by logic_pio.
*/
- ioremap_page_range(PCI_IOBASE, PCI_IOBASE + MMIO_LOWER_RESERVED,
- LOONGSON_PCIIO_BASE,
- pgprot_device(PAGE_KERNEL));
+ ioremap_page_range(PCI_IOBASE, PCI_IOBASE + mmio_lower_reserved,
+ LOONGSON_PCIIO_BASE, pgprot_device(PAGE_KERNEL));
return;
unregister:
--
2.7.0
next reply other threads:[~2020-07-17 9:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-17 9:10 Huacai Chen [this message]
2020-07-21 8:32 ` [PATCH V2] MIPS: Loongson64: Reserve legacy MMIO space according to bridge type Thomas Bogendoerfer
2020-07-21 9:07 ` Huacai Chen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1594977035-27899-1-git-send-email-chenhc@lemote.com \
--to=chenhc@lemote.com \
--cc=chenhuacai@gmail.com \
--cc=jiaxun.yang@flygoat.com \
--cc=linux-mips@vger.kernel.org \
--cc=tsbogend@alpha.franken.de \
--cc=wuzhangjin@gmail.com \
--cc=zhangfx@lemote.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox