Skip to contentSkip to conversation

Lemote Loongson 2E patch update [take 2]

PATCH In review [email protected] 5 participants 27 messages Jun 6, 2007 – Jun 13, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

loongson 2e patch updated for 2.6.22-rc4

arch/mips/Kconfig                            |   37 ++
arch/mips/Makefile                           |    8
arch/mips/kernel/Makefile                    |    1
arch/mips/kernel/cpu-probe.c                 |    9
arch/mips/kernel/proc.c                      |    2
arch/mips/kernel/setup.c                     |    9
arch/mips/lemote/lm2e/Makefile               |    7
arch/mips/lemote/lm2e/bonito-irq.c           |   74 +++++
arch/mips/lemote/lm2e/dbg_io.c               |  146 ++++++++++
arch/mips/lemote/lm2e/irq.c                  |  146 ++++++++++
arch/mips/lemote/lm2e/pci.c                  |   72 +++++
arch/mips/lemote/lm2e/prom.c                 |  109 +++++++
arch/mips/lemote/lm2e/reset.c                |   49 +++
arch/mips/lemote/lm2e/setup.c                |  144 ++++++++++
arch/mips/lib-32/Makefile                    |    1
arch/mips/lib-64/Makefile                    |    1
arch/mips/mm/Makefile                        |    1
arch/mips/mm/c-r4k.c                         |   58 ++++
arch/mips/mm/tlb-r4k.c                       |   23 +
arch/mips/mm/tlbex.c                         |    9
arch/mips/pci/Makefile                       |    2
arch/mips/pci/fixup-lm2e.c                   |  255 ++++++++++++++++++
arch/mips/pci/ops-lm2e.c                     |  153 ++++++++++
drivers/char/mem.c                           |    5
include/asm-mips/addrspace.h                 |    3
include/asm-mips/bootinfo.h                  |    7
include/asm-mips/cacheops.h                  |    5
include/asm-mips/cpu.h                       |    8
include/asm-mips/mach-lemote/bonito.h        |  381 +++++++++++++++++++++++++++
include/asm-mips/mach-lemote/dma-coherence.h |   43 +++
include/asm-mips/mach-lemote/mc146818rtc.h   |   37 ++
include/asm-mips/module.h                    |    3
include/asm-mips/serial.h                    |   10
33 files changed, 1796 insertions(+), 22 deletions(-)
#1 lore raw

PATCH 1/15 new files for lemote fulong mini-PC support

From: Songmao Tian <[email protected]>

---
 arch/mips/lemote/lm2e/Makefile               |    7 +
 arch/mips/lemote/lm2e/bonito-irq.c           |   74 +++++
 arch/mips/lemote/lm2e/dbg_io.c               |  146 ++++++++++
 arch/mips/lemote/lm2e/irq.c                  |  146 ++++++++++
 arch/mips/lemote/lm2e/pci.c                  |   72 +++++
 arch/mips/lemote/lm2e/prom.c                 |  109 ++++++++
 arch/mips/lemote/lm2e/reset.c                |   49 ++++
 arch/mips/lemote/lm2e/setup.c                |  144 ++++++++++
 arch/mips/pci/fixup-lm2e.c                   |  255 +++++++++++++++++
 arch/mips/pci/ops-lm2e.c                     |  153 +++++++++++
 include/asm-mips/mach-lemote/bonito.h        |  381 ++++++++++++++++++++++++++
 include/asm-mips/mach-lemote/dma-coherence.h |   43 +++
 include/asm-mips/mach-lemote/mc146818rtc.h   |   36 +++
 13 files changed, 1615 insertions(+), 0 deletions(-)
 create mode 100644 arch/mips/lemote/lm2e/Makefile
 create mode 100644 arch/mips/lemote/lm2e/bonito-irq.c
 create mode 100644 arch/mips/lemote/lm2e/dbg_io.c
 create mode 100644 arch/mips/lemote/lm2e/irq.c
 create mode 100644 arch/mips/lemote/lm2e/pci.c
 create mode 100644 arch/mips/lemote/lm2e/prom.c
 create mode 100644 arch/mips/lemote/lm2e/reset.c
 create mode 100644 arch/mips/lemote/lm2e/setup.c
 create mode 100644 arch/mips/pci/fixup-lm2e.c
 create mode 100644 arch/mips/pci/ops-lm2e.c
 create mode 100644 include/asm-mips/mach-lemote/bonito.h
 create mode 100644 include/asm-mips/mach-lemote/dma-coherence.h
 create mode 100644 include/asm-mips/mach-lemote/mc146818rtc.h
arch/mips/lemote/lm2e/Makefile new file +7 -0
new file mode 100644
index 0000000..0ba6f12
@@ -0,0 +1,7 @@
+#
+# Makefile for Lemote Fulong mini-PC board.
+#
+
+obj-y += setup.o prom.o reset.o irq.o pci.o bonito-irq.o dbg_io.o
+EXTRA_AFLAGS := $(CFLAGS)
+
arch/mips/lemote/lm2e/bonito-irq.c new file +74 -0

74 lines not on this page · raw message

arch/mips/lemote/lm2e/dbg_io.c new file +146 -0

146 lines not on this page · raw message

arch/mips/lemote/lm2e/irq.c new file +146 -0

146 lines not on this page · raw message

arch/mips/lemote/lm2e/pci.c new file +72 -0

72 lines not on this page · raw message

arch/mips/lemote/lm2e/prom.c new file +109 -0

109 lines not on this page · raw message

arch/mips/lemote/lm2e/reset.c new file +49 -0

49 lines not on this page · raw message

arch/mips/lemote/lm2e/setup.c new file +144 -0

144 lines not on this page · raw message

arch/mips/pci/fixup-lm2e.c new file +255 -0

255 lines not on this page · raw message

arch/mips/pci/ops-lm2e.c new file +153 -0

153 lines not on this page · raw message

include/asm-mips/mach-lemote/bonito.h new file +381 -0

381 lines not on this page · raw message

include/asm-mips/mach-lemote/dma-coherence.h new file +43 -0

43 lines not on this page · raw message

include/asm-mips/mach-lemote/mc146818rtc.h new file +36 -0
new file mode 100644
index 0000000..7850f89
@@ -0,0 +1,36 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 1998, 2001, 03 by Ralf Baechle
+ *
+ * RTC routines for PC style attached Dallas chip.
+ */
+#ifndef __ASM_MACH_GENERIC_MC146818RTC_H
+#define __ASM_MACH_GENERIC_MC146818RTC_H
+
+#include <asm/io.h>
+
+#define RTC_PORT(x)	(0x70 + (x))
+#define RTC_IRQ		8
+
+static inline unsigned char CMOS_READ(unsigned long addr)
+{
+	outb_p(addr, RTC_PORT(0));
+	return inb_p(RTC_PORT(1));
+}
+
+static inline void CMOS_WRITE(unsigned char data, unsigned long addr)
+{
+	outb_p(addr, RTC_PORT(0));
+	outb_p(data, RTC_PORT(1));
+}
+
+#define RTC_ALWAYS_BCD	0
+
+#ifndef mc146818_decode_year
+#define mc146818_decode_year(year) ((year) < 70 ? (year) + 2000 : (year) + 1970)
+#endif
+
+#endif /* __ASM_MACH_GENERIC_MC146818RTC_H */
Signature · 1 line
1.5.2.1
#2 lore raw

Re: [PATCH 01/15] new files for lemote fulong mini-PC support

On Wed, Jun 06, 2007 at 02:52:38PM +0800, [email protected] wrote:

So I've taken the whole patch set and combined it into just two separate patches for the -queue tree. I combined them because splitting a patchset into just new and modified files isn't terribly useful way. Patches should rather be split in a logic way such as "add suport for new feature x", "cleanup foobar frobnication state engine" or "fix bug y".

A few comments still:

arch/mips/pci/fixup-lm2e.c:

Quoted 34 lines
arch/mips/pci/fixup-lm2e.c new file +34 -0
+int __init pcibios_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
+{
+	unsigned int val;
+	if (PCI_SLOT(dev->devfn) == 4) {	/* wireless card(notebook) */
+		dev->irq = BONITO_IRQ_BASE + 26;
+		return dev->irq;
+	} else if (PCI_SLOT(dev->devfn) == 5) {	/* via686b */
+		switch (PCI_FUNC(dev->devfn)) {
+		case 2:
+			dev->irq = 10;
+			break;
+		case 3:
+			dev->irq = 11;
+			break;
+		case 5:
+			dev->irq = 9;
+			break;
+		}
+		return dev->irq;
+	} else if (PCI_SLOT(dev->devfn) == 6) {	/* radeon 7000 */
+		dev->irq = BONITO_IRQ_BASE + 27;
+		return dev->irq;
+	} else if (PCI_SLOT(dev->devfn) == 7) {	/* 8139 */
+		dev->irq = BONITO_IRQ_BASE + 26;
+		return dev->irq;
+	} else if (PCI_SLOT(dev->devfn) == 8) {	/* nec usb */
+		switch (PCI_FUNC(dev->devfn)) {
+		case 0:
+			dev->irq = BONITO_IRQ_BASE + 26;
+			break;
+		case 1:
+			dev->irq = BONITO_IRQ_BASE + 27;
+			break;
+		case 2:

arch/mips/pci/fixup-lm2e.c line 79

Quoted 10 lines
arch/mips/pci/fixup-lm2e.c new file +10 -0
+			dev->irq = BONITO_IRQ_BASE + 28;
+			break;
+		}
+		pci_read_config_dword(dev, 0xe0, &val);
+		pci_write_config_dword(dev, 0xe0, (val & ~7) | 0x4);
+		pci_write_config_dword(dev, 0xe4, 1 << 5);
+		return dev->irq;
+	} else
+		return 0;
+}

The purpose of pcibios_map_irq() is to map PCI slot numbers to host system interrupt numbers. PCI-to-PCI bridge may also need to be taken in consideration, that's why the function also receives a pin number but a generic standard compliant PCI device only ever uses INTA.

Things not to do:

o modify the pci_dev structure pointed to by the function's dev argument. So I changed the first argument to const struct pci_dev * to make that sort of things a bit harder in the future.
o doing any kind of other initialization. That sort of stuff should go elsewhere such as into a DECLARE_PCI_FIXUP_* call.
o The generic MIPS PCI code calls pcibios_map_irq() in order when initializing dev->irq, so you can't refer to that variable because either it's unset or your changes would be overwritten right away.
o To figure our the interrupt numbers you probably want to look at just the slot and pin arguments; PCI_{FUNC,SLOT} like any other dereferencing of dev look suspiciously wrong in this function - pcibios_map_irq can normally be implemented as just an array lookup, see fixup-malta.c or for a slightly more complicated example supporting multiple rather different systems fixup-sni.c.

Can you send a patch to fix this, please? Thanks :-)

arch/mips/pci/fixup-lm2e.c line 197

Quoted 4 lines
arch/mips/pci/fixup-lm2e.c new file +3 -0
+static void __init loongson2e_686b_func5_fixup(struct pci_dev *pdev)
+{
 
+	printk(KERN_INFO"ac97 interrupt = 9\n");

General comment - your kernel patches are fairly talkative - probably a bit too much.

Quoted 1 line

+static void __init loongson2e_fixup_pcimap(struct pci_dev *pdev)

[...]

Quoted 1 line

+DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, loongson2e_fixup_pcimap);

This one doesn't initialize or fixup any PCI device at all so I think this shold not be implemented as a PCI fixup. I suggest doing that before calling register_pci_controller().

arch/mips/pci/ops-lm2e.c

Quoted 1 line
arch/mips/pci/ops-lm2e.c +0 -0

This file could probable be combined with ops-bonito64.c. After all it's banging the essentially same hardware.

include/asm-mips/mach-lemote/bonito.h line 3

Quoted 9 lines
include/asm-mips/mach-lemote/bonito.h new file +3 -0
new file mode 100644
index 0000000..83f7ac3
@@ -0,0 +1,381 @@
+/*
+ * Based on Algorithmics header
+ */

And the original (C) header said:

* Bonito Register Map
*
* This file is the original bonito.h from Algorithmics with minor changes
* to fit into linux.
*
* Copyright (c) 1999 Algorithmics Ltd
*
* Carsten Langgaard, [email protected]
* Copyright (C) 2001 MIPS Technologies, Inc. All rights reserved. *
* Algorithmics gives permission for anyone to use and modify this file
* without any obligation or license condition except that you retain
* this copyright message in any source redistribution in whole or part.

So I did you a favor and put the (C) notice back into place.

Anyway, it seems the Fulong is based on a slightly older Bonito64 version and both Malta and Fulong can be made to share that header file easily.

A patch to resolve those issues would be appreciated. Note that now that I've put the patches into the -queue tree I'd appreciate a patch relative to that tree which lives at:

git://git.linux-mips.org/pub/scm/linux-queue.git

If you want to clone this tree and alrady have a copy of the normal Linux/MIPS git tree on your disk you can speedup the clone by a few orders of magnitude by using the --reference option like this:

  git clone --reference ~/src/linux/linux-mips \
        git://git.linux-mips.org/pub/scm/linux-queue.git

It will bring down the clone process to something on the order of a few seconds.

Ralf

#3 lore raw

PATCH 2/15 arch related Makefile update for lemote fulong mini-PC

In reply to [email protected]

From: Fuxin Zhang <[email protected]>

---
 arch/mips/Makefile        |    8 ++++++++
 arch/mips/kernel/Makefile |    1 +
 arch/mips/lib-32/Makefile |    1 +
 arch/mips/lib-64/Makefile |    1 +
 arch/mips/mm/Makefile     |    1 +
 arch/mips/pci/Makefile    |    1 +
 6 files changed, 13 insertions(+), 0 deletions(-)
arch/mips/Makefile +8 -0
index 2b19605..3aedcf4 100644
@@ -118,6 +118,7 @@ cflags-$(CONFIG_CPU_R4300)	+= -march=r4300 -Wa,--trap
 cflags-$(CONFIG_CPU_VR41XX)	+= -march=r4100 -Wa,--trap
 cflags-$(CONFIG_CPU_R4X00)	+= -march=r4600 -Wa,--trap
 cflags-$(CONFIG_CPU_TX49XX)	+= -march=r4600 -Wa,--trap
+cflags-$(CONFIG_CPU_LOONGSON2)	+= -march=r4600 -Wa,--trap
 cflags-$(CONFIG_CPU_MIPS32_R1)	+= $(call cc-option,-march=mips32,-mips32 -U_MIPS_ISA -D_MIPS_ISA=_MIPS_ISA_MIPS32) \
 			-Wa,-mips32 -Wa,--trap
 cflags-$(CONFIG_CPU_MIPS32_R2)	+= $(call cc-option,-march=mips32r2,-mips32r2 -U_MIPS_ISA -D_MIPS_ISA=_MIPS_ISA_MIPS32) \
@@ -298,6 +299,13 @@ cflags-$(CONFIG_WR_PPMC)		+= -Iinclude/asm-mips/mach-wrppmc
 load-$(CONFIG_WR_PPMC)		+= 0xffffffff80100000
 
 #
+# lemote fulong mini-PC board
+#
+core-$(CONFIG_LEMOTE_FULONG) +=arch/mips/lemote/lm2e/
+load-$(CONFIG_LEMOTE_FULONG) +=0xffffffff80100000
+cflags-$(CONFIG_LEMOTE_FULONG) += -Iinclude/asm-mips/mach-lemote
+
+#
 # For all MIPS, Inc. eval boards
 #
 core-$(CONFIG_MIPS_BOARDS_GEN)	+= arch/mips/mips-boards/generic/
arch/mips/kernel/Makefile +1 -0
index 4924626..40fdf79 100644
@@ -31,6 +31,7 @@ obj-$(CONFIG_CPU_R10000)	+= r4k_fpu.o r4k_switch.o
 obj-$(CONFIG_CPU_SB1)		+= r4k_fpu.o r4k_switch.o
 obj-$(CONFIG_CPU_MIPS32)	+= r4k_fpu.o r4k_switch.o
 obj-$(CONFIG_CPU_MIPS64)	+= r4k_fpu.o r4k_switch.o
+obj-$(CONFIG_CPU_LOONGSON2)	+= r4k_fpu.o r4k_switch.o
 obj-$(CONFIG_CPU_R6000)		+= r6000_fpu.o r4k_switch.o
 
 obj-$(CONFIG_SMP)		+= smp.o
arch/mips/lib-32/Makefile +1 -0
index 8b94d4c..b4be604 100644
@@ -21,3 +21,4 @@ obj-$(CONFIG_CPU_SB1)		+= dump_tlb.o
 obj-$(CONFIG_CPU_TX39XX)	+= r3k_dump_tlb.o
 obj-$(CONFIG_CPU_TX49XX)	+= dump_tlb.o
 obj-$(CONFIG_CPU_VR41XX)	+= dump_tlb.o
+obj-$(CONFIG_CPU_LOONGSON2)	+= dump_tlb.o
arch/mips/lib-64/Makefile +1 -0
index 8b94d4c..b4be604 100644
@@ -21,3 +21,4 @@ obj-$(CONFIG_CPU_SB1)		+= dump_tlb.o
 obj-$(CONFIG_CPU_TX39XX)	+= r3k_dump_tlb.o
 obj-$(CONFIG_CPU_TX49XX)	+= dump_tlb.o
 obj-$(CONFIG_CPU_VR41XX)	+= dump_tlb.o
+obj-$(CONFIG_CPU_LOONGSON2)	+= dump_tlb.o
arch/mips/mm/Makefile +1 -0
index 293697b..ab24195 100644
@@ -21,6 +21,7 @@ obj-$(CONFIG_CPU_R5432)		+= c-r4k.o cex-gen.o pg-r4k.o tlb-r4k.o
 obj-$(CONFIG_CPU_R8000)		+= c-r4k.o cex-gen.o pg-r4k.o tlb-r8k.o
 obj-$(CONFIG_CPU_RM7000)	+= c-r4k.o cex-gen.o pg-r4k.o tlb-r4k.o
 obj-$(CONFIG_CPU_RM9000)	+= c-r4k.o cex-gen.o pg-r4k.o tlb-r4k.o
+obj-$(CONFIG_CPU_LOONGSON2)	+= c-r4k.o cex-gen.o pg-r4k.o tlb-r4k.o
 obj-$(CONFIG_CPU_SB1)		+= c-sb1.o cerr-sb1.o cex-sb1.o pg-sb1.o \
 				   tlb-r4k.o
 obj-$(CONFIG_CPU_TX39XX)	+= c-tx39.o pg-r4k.o tlb-r3k.o
arch/mips/pci/Makefile +1 -0
index aba3dbf..6396e02 100644
@@ -50,3 +50,4 @@ obj-$(CONFIG_TOSHIBA_RBTX4938)	+= fixup-tx4938.o ops-tx4938.o
 obj-$(CONFIG_VICTOR_MPC30X)	+= fixup-mpc30x.o
 obj-$(CONFIG_ZAO_CAPCELLA)	+= fixup-capcella.o
 obj-$(CONFIG_WR_PPMC)		+= fixup-wrppmc.o
+obj-$(CONFIG_LEMOTE_FULONG)	+= fixup-lm2e.o ops-lm2e.o
Signature · 1 line
1.5.2.1
#4 lore raw

PATCH 3/15 Kconfig update for lemote fulong miniPC

In reply to [email protected]

From: Sun Haiyong <[email protected]>

---
 arch/mips/Kconfig |   36 ++++++++++++++++++++++++++++++++++++
 1 files changed, 36 insertions(+), 0 deletions(-)
arch/mips/Kconfig +36 -0
index c20cd90..16f1861 100644
@@ -14,6 +14,25 @@ config ZONE_DMA
 choice
 	prompt "System type"
 	default SGI_IP22
+config LEMOTE_FULONG
+	bool "Support for Lemote's fulong mini-PC"
+	select SYS_HAS_CPU_LOONGSON2
+	select DMA_NONCOHERENT
+	select BOOT_ELF32
+	select BOARD_SCACHE
+	select HW_HAS_PCI
+	select I8259
+	select ISA
+	select IRQ_CPU
+	select SYS_SUPPORTS_32BIT_KERNEL
+	select SYS_SUPPORTS_64BIT_KERNEL
+	select SYS_SUPPORTS_LITTLE_ENDIAN
+	select SYS_SUPPORTS_HIGHMEM
+	select SYS_HAS_EARLY_PRINTK
+	select GENERIC_HARDIRQS_NO__DO_IRQ
+	select CPU_HAS_WB
+	help
+         Lemote Fulong mini-PC board, which uses Chinese Loongson-2E CPU and a fpga north bridge
 
 config MACH_ALCHEMY
 	bool "Alchemy processor based machines"
@@ -933,6 +952,13 @@ choice
 	prompt "CPU type"
 	default CPU_R4X00
 
+config CPU_LOONGSON2
+	bool "LOONGSON2"
+	depends on SYS_HAS_CPU_LOONGSON2
+	select CPU_SUPPORTS_32BIT_KERNEL
+	select CPU_SUPPORTS_64BIT_KERNEL
+	select CPU_SUPPORTS_HIGHMEM
+
 config CPU_MIPS32_R1
 	bool "MIPS32 Release 1"
 	depends on SYS_HAS_CPU_MIPS32_R1
@@ -1143,6 +1169,9 @@ config CPU_SB1
 
 endchoice
 
+config SYS_HAS_CPU_LOONGSON2
+	bool
+
 config SYS_HAS_CPU_MIPS32_R1
 	bool
 
@@ -1477,6 +1506,13 @@ config CPU_HAS_SMARTMIPS
 config CPU_HAS_WB
 	bool
 
+config 64BIT_CONTEXT
+	bool "Save 64bit integer registers" if CPU_LOONGSON2 && 32BIT
+	help
+	  Loongson2 CPU is 64bit , when used in 32BIT mode, its integer registers
+	  can still be accessed as 64bit, mainly for multimedia instructions. We must have
+	  all 64bit save/restored to make sure those instructions to get correct result.
+
 #
 # Vectored interrupt mode is an R2 feature
 #
Signature · 1 line
1.5.2.1
#5 lore raw

PATCH 4/15 TO_PHYS_MASK for loongson2

In reply to [email protected]

From: Fuxin Zhang <[email protected]>

---
 include/asm-mips/addrspace.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
include/asm-mips/addrspace.h +1 -1
index 964c5ed..a4d9a07 100644
@@ -145,7 +145,7 @@
 #define TO_PHYS_MASK	_CONST64_(0x000000ffffffffff)	/* 2^^40 - 1 */
 #endif
 
-#if defined (CONFIG_CPU_R10000)
+#if defined (CONFIG_CPU_R10000) || defined (CONFIG_CPU_LOONGSON2)
 #define TO_PHYS_MASK	_CONST64_(0x000000ffffffffff)	/* 2^^40 - 1 */
 #endif
 
Signature · 1 line
1.5.2.1
#6 lore raw

Re: [PATCH 04/15] TO_PHYS_MASK for loongson2

include/asm-mips/addrspace.h line 150

Quoted 12 lines · On Wed, Jun 06, 2007 at 02:52:41PM +0800, [email protected] wrote:
include/asm-mips/addrspace.h +1 -1
index 964c5ed..a4d9a07 100644
@@ -145,7 +145,7 @@
 #define TO_PHYS_MASK	_CONST64_(0x000000ffffffffff)	/* 2^^40 - 1 */
 #endif
 
-#if defined (CONFIG_CPU_R10000)
+#if defined (CONFIG_CPU_R10000) || defined (CONFIG_CPU_LOONGSON2)
 #define TO_PHYS_MASK	_CONST64_(0x000000ffffffffff)	/* 2^^40 - 1 */
 #endif

I've already previously rejected this patch, see
http://www.linux-mips.org/cgi-bin/mesg.cgi?a=linux-mips&i=20070418120240.GD3938%40linux-mips.org
for why.

Anyway, I've implemented the suggested fix for the -queue tree, so you can drop this one from your patch queue.

Ralf

#7 lore raw

PATCH 5/15 add MACH_GROUP_LEMOTE & MACH_LEMOTE_FULONG

In reply to [email protected]

From: Fuxin Zhang <[email protected]>

---
 include/asm-mips/bootinfo.h |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
include/asm-mips/bootinfo.h +6 -0
index b0c3297..5006930 100644
@@ -213,6 +213,12 @@
 #define MACH_GROUP_NEC_EMMA2RH 25	/* NEC EMMA2RH (was 23)		*/
 #define  MACH_NEC_MARKEINS	0	/* NEC EMMA2RH Mark-eins	*/
 
+/*
+ * Valid machtype for group LEMOTE
+ */
+#define MACH_GROUP_LEMOTE          27
+#define  MACH_LEMOTE_FULONG        0
+
 #define CL_SIZE			COMMAND_LINE_SIZE
 
 const char *get_system_type(void);
Signature · 1 line
1.5.2.1
#8 lore raw

PATCH 6/15 define Hit_Invalidate_I to Index_Invalidate_I for loongson2

In reply to [email protected]

From: Fuxin Zhang <[email protected]>

---
 include/asm-mips/cacheops.h |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
include/asm-mips/cacheops.h +4 -0
index c4a1ec3..df7f2de 100644
@@ -20,7 +20,11 @@
 #define Index_Load_Tag_D	0x05
 #define Index_Store_Tag_I	0x08
 #define Index_Store_Tag_D	0x09
+#if defined(CONFIG_CPU_LOONGSON2)
+#define Hit_Invalidate_I    	0x00
+#else
 #define Hit_Invalidate_I	0x10
+#endif
 #define Hit_Invalidate_D	0x11
 #define Hit_Writeback_Inv_D	0x15
 
Signature · 1 line
1.5.2.1
#9 lore raw

PATCH 7/15 add Loongson processor definitions

In reply to [email protected]

From: Fuxin Zhang <[email protected]>

---
 include/asm-mips/cpu.h |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
include/asm-mips/cpu.h +6 -1
index d38fdbf..d289359 100644
@@ -89,6 +89,8 @@
 #define PRID_IMP_34K		0x9500
 #define PRID_IMP_24KE		0x9600
 #define PRID_IMP_74K		0x9700
+#define PRID_IMP_LOONGSON1      0x4200
+#define PRID_IMP_LOONGSON2      0x6300
 
 /*
  * These are the PRID's for when 23:16 == PRID_COMP_SIBYTE
@@ -200,7 +202,10 @@
 #define CPU_SB1A		62
 #define CPU_74K			63
 #define CPU_R14000		64
-#define CPU_LAST		64
+#define CPU_LOONGSON1           65
+#define CPU_LOONGSON2           66
+
+#define CPU_LAST		66
 
 /*
  * ISA Level encodings
Signature · 1 line
1.5.2.1
#10 lore raw

PATCH 8/15 define MODULE_PROC_FAMILY for Loongson2

In reply to [email protected]

From: Fuxin Zhang <[email protected]>

---
 include/asm-mips/module.h |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
include/asm-mips/module.h +2 -0
index 399d03f..f615324 100644
@@ -112,6 +112,8 @@ search_module_dbetables(unsigned long addr)
 #define MODULE_PROC_FAMILY "RM9000 "
 #elif defined CONFIG_CPU_SB1
 #define MODULE_PROC_FAMILY "SB1 "
+#elif defined CONFIG_CPU_LOONGSON2
+#define MODULE_PROC_FAMILY "LOONGSON2 "
 #else
 #error MODULE_PROC_FAMILY undefined for your processor configuration
 #endif
Signature · 1 line
1.5.2.1
#11 lore raw

PATCH 9/15 add serial port definition for lemote fulong

In reply to [email protected]

From: Songmao Tian <[email protected]>

---
 include/asm-mips/serial.h |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)
include/asm-mips/serial.h +8 -1
index ce51213..1237704 100644
@@ -164,6 +164,12 @@
 #define IP32_SERIAL_PORT_DEFNS
 #endif /* CONFIG_SGI_IP32 */
 
+#if defined(CONFIG_LEMOTE_FULONG)
+#define LEMOTE_FULONG_SERIAL_PORT_DEFNS			\
+	/* UART CLK   PORT IRQ     FLAGS        */	\
+	{ 0, BASE_BAUD, 0x3F8, 4, STD_COM_FLAGS },	/* ttyS0 */
+#endif
+
 #define SERIAL_PORT_DFNS				\
 	DDB5477_SERIAL_PORT_DEFNS			\
 	EV64120_SERIAL_PORT_DEFNS			\
@@ -172,6 +178,7 @@
 	STD_SERIAL_PORT_DEFNS				\
 	MOMENCO_OCELOT_C_SERIAL_PORT_DEFNS		\
 	MOMENCO_OCELOT_SERIAL_PORT_DEFNS		\
-	MOMENCO_OCELOT_3_SERIAL_PORT_DEFNS
+	MOMENCO_OCELOT_3_SERIAL_PORT_DEFNS		\
+	LEMOTE_FULONG_SERIAL_PORT_DEFNS
 
 #endif /* _ASM_SERIAL_H */
Signature · 1 line
1.5.2.1
#12 lore raw

Re: [PATCH 09/15] add serial port definition for lemote fulong

Quoted 10 lines · On Wed, Jun 06, 2007 at 02:52:46PM +0800, [email protected] wrote:
include/asm-mips/serial.h +6 -0
+#if defined(CONFIG_LEMOTE_FULONG)
+#define LEMOTE_FULONG_SERIAL_PORT_DEFNS			\
+	/* UART CLK   PORT IRQ     FLAGS        */	\
+	{ 0, BASE_BAUD, 0x3F8, 4, STD_COM_FLAGS },	/* ttyS0 */
+#endif
+
 #define SERIAL_PORT_DFNS				\
 	DDB5477_SERIAL_PORT_DEFNS			\
 	EV64120_SERIAL_PORT_DEFNS			\

include/asm-mips/serial.h line 184

Quoted 8 lines
include/asm-mips/serial.h +2 -1
@@ -172,6 +178,7 @@
 	STD_SERIAL_PORT_DEFNS				\
 	MOMENCO_OCELOT_C_SERIAL_PORT_DEFNS		\
 	MOMENCO_OCELOT_SERIAL_PORT_DEFNS		\
-	MOMENCO_OCELOT_3_SERIAL_PORT_DEFNS
+	MOMENCO_OCELOT_3_SERIAL_PORT_DEFNS		\
+	LEMOTE_FULONG_SERIAL_PORT_DEFNS
 
 #endif /* _ASM_SERIAL_H */

I wonder, is the standard CONFIG_HAVE_STD_PC_SERIAL_PORT which does basically the same thing as above but for all four ports of a typical PC-style 16652 configuration for some reason inacceptable for Fulong?

Ralf

#13 lore raw

Re: [PATCH 09/15] add serial port definition for lemote fulong

Quoted 10 lines
Quoted 3 lines

#endif /* _ASM_SERIAL_H */

I wonder, is the standard CONFIG_HAVE_STD_PC_SERIAL_PORT which does basically the same thing as above but for all four ports of a typical PC-style 16652 configuration for some reason inacceptable for Fulong?

Ralf

I think CONFIG_HAVE_STD_PC_SERIAL_PORT is ok, especially for that we now have CONFIG_SERIAL_8250_NR_UARTS. Nothing special for Fulong's serial ports(we used to have a special serial port inside the northbridge FPGA), and the 686B is "Standard PC" chip:)
We can take the simple way.

Quoted 4 lines
Signature · 11 lines
------------------------------------------------
Fuxin Zhang

Vice Researcher
Microprocessor Research Center, Institute of Computing Technolgy
Chiese Academy of China
Beijing, 100080
Email: [email protected]
http://www.ict.ac.cn

------------------------------------------------
#14 lore raw

Re: [PATCH 09/15] add serial port definition for lemote fulong

Quoted 6 lines · Fuxin Zhang

I think CONFIG_HAVE_STD_PC_SERIAL_PORT is ok, especially for that we now have CONFIG_SERIAL_8250_NR_UARTS.
Nothing special for Fulong's serial ports(we used to have a special serial port inside the northbridge FPGA), and the 686B is "Standard PC" chip:)
We can take the simple way.

Good. This simplifies the rewrite of the 8250 serial support to use the platform_device driver.

Ralf

#15 lore raw

Re: [PATCH 09/15] add serial port definition for lemote fulong

In reply to Fuxin Zhang
Quoted 6 lines · Fuxin Zhang

I think CONFIG_HAVE_STD_PC_SERIAL_PORT is ok, especially for that we now have CONFIG_SERIAL_8250_NR_UARTS.
Nothing special for Fulong's serial ports(we used to have a special serial port inside the northbridge FPGA), and the 686B is "Standard PC" chip:)
We can take the simple way.

So the serial port initialization rewrite is in -queue, now it needs some testing - on all platforms.

Ralf

#16 lore raw

PATCH 10/15 make cpu_probe recognize Loongson2

In reply to [email protected]

From: Fuxin Zhang <[email protected]>

---
 arch/mips/kernel/cpu-probe.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
arch/mips/kernel/cpu-probe.c +8 -0
index ab755ea..c9e3637 100644
@@ -464,6 +464,14 @@ static inline void cpu_probe_legacy(struct cpuinfo_mips *c)
 		             MIPS_CPU_LLSC;
 		c->tlbsize = 64;
 		break;
+	case PRID_IMP_LOONGSON2:
+		c->cputype = CPU_LOONGSON2;
+		c->isa_level = MIPS_CPU_ISA_III;
+		c->options = R4K_OPTS |
+			     MIPS_CPU_FPU | MIPS_CPU_LLSC |
+			     MIPS_CPU_32FPR;
+		c->tlbsize = 64;
+		break;
 	}
 }
 
Signature · 1 line
1.5.2.1
#17 lore raw

PATCH 11/15 add Loongson support to /proc/cpuinfo

In reply to [email protected]

From: Fuxin Zhang <[email protected]>

---
 arch/mips/kernel/proc.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
arch/mips/kernel/proc.c +1 -0
index 5ddc2e9..e915117 100644
@@ -84,6 +84,7 @@ static const char *cpu_name[] = {
 	[CPU_VR4181A]	= "NEC VR4181A",
 	[CPU_SR71000]	= "Sandcraft SR71000",
 	[CPU_PR4450]	= "Philips PR4450",
+	[CPU_LOONGSON2]	= "ICT Loongson-2",
 };
 
 
Signature · 1 line
1.5.2.1
#18 lore raw

PATCH 12/15 cheat for support of more than 256MB memory

In reply to [email protected]

From: Fuxin Zhang <[email protected]>

---
 arch/mips/kernel/setup.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
arch/mips/kernel/setup.c +8 -0
index 4975da0..62ef100 100644
@@ -509,6 +509,14 @@ static void __init resource_init(void)
 		res->end = end;
 
 		res->flags = IORESOURCE_MEM | IORESOURCE_BUSY;
+#if defined(CONFIG_LEMOTE_FULONG) && defined(CONFIG_64BIT)
+		/* to keep memory continous, we tell system 0x10000000 - 0x20000000 is reserved
+		 * for memory, in fact it is io region, don't occupy it
+		 *
+		 * SPARSEMEM?
+		 */
+		if (boot_mem_map.map[i].type != BOOT_MEM_RESERVED)
+#endif
 		request_resource(&iomem_resource, res);
 
 		/*
Signature · 1 line
1.5.2.1
#19 lore raw

PATCH 13/15 define MODULE_PROC_FAMILY for Loongson2

In reply to [email protected]

From: Fuxin Zhang <[email protected]>

---
 arch/mips/mm/c-r4k.c |   57 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 57 insertions(+), 0 deletions(-)
arch/mips/mm/c-r4k.c +57 -0
index df04a31..e9988a3 100644
@@ -335,6 +335,10 @@ static void r4k_flush_cache_all(void)
 
 static inline void local_r4k___flush_cache_all(void * args)
 {
+#if defined(CONFIG_CPU_LOONGSON2)
+	r4k_blast_scache();
+	return;
+#endif
 	r4k_blast_dcache();
 	r4k_blast_icache();
 
@@ -848,6 +852,26 @@ static void __init probe_pcache(void)
 		c->options |= MIPS_CPU_PREFETCH;
 		break;
 
+	case CPU_LOONGSON2:
+		icache_size = 1 << (12 + ((config & CONF_IC) >> 9));
+		c->icache.linesz = 16 << ((config & CONF_IB) >> 5);
+		if (prid & 0x3) {
+		  c->icache.ways = 4;
+		} else {
+		  c->icache.ways = 2;
+		}
+		c->icache.waybit= 0;
+
+		dcache_size = 1 << (12 + ((config & CONF_DC) >> 6));
+		c->dcache.linesz = 16 << ((config & CONF_DB) >> 4);
+		if (prid & 0x3) {
+		  c->dcache.ways = 4;
+		} else {
+		  c->dcache.ways = 2;
+		}
+		c->dcache.waybit = 0;
+		break;
+
 	default:
 		if (!(config & MIPS_CONF_M))
 			panic("Don't know how to probe P-caches on this cpu.");
@@ -963,6 +987,14 @@ static void __init probe_pcache(void)
 		break;
 	}
 
+#ifdef  CONFIG_CPU_LOONGSON2
+	/*
+	 * LOONGSON2 has 4 way icache, but when using indexed cache op,
+	 * one op will act on all 4 ways
+	 */
+	c->icache.ways = 1;
+#endif
+
 	printk("Primary instruction cache %ldkB, %s, %s, linesize %d bytes.\n",
 	       icache_size >> 10,
 	       cpu_has_vtag_icache ? "virtually tagged" : "physically tagged",
@@ -1036,6 +1068,25 @@ static int __init probe_scache(void)
 	return 1;
 }
 
+#if defined(CONFIG_CPU_LOONGSON2)
+static void __init loongson2_sc_init(void)
+{
+    struct cpuinfo_mips *c = &current_cpu_data;
+
+    scache_size = 512*1024;
+    c->scache.linesz = 32;
+    c->scache.ways = 4;
+    c->scache.waybit = 0;
+    c->scache.waysize = scache_size / (c->scache.ways);
+    c->scache.sets = scache_size /(c->scache.linesz * c->scache.ways);
+    printk("Unified secondary cache %ldkB %s, linesize %d bytes.\n",
+		    scache_size >> 10, way_string[c->scache.ways], c->scache.linesz);
+
+    c->options |= MIPS_CPU_INCLUSIVE_CACHES;
+    return;
+}
+#endif
+
 extern int r5k_sc_init(void);
 extern int rm7k_sc_init(void);
 extern int mips_sc_init(void);
@@ -1085,6 +1136,12 @@ static void __init setup_scache(void)
 #endif
 		return;
 
+#if defined(CONFIG_CPU_LOONGSON2)
+	case CPU_LOONGSON2:
+		loongson2_sc_init();
+		return;
+#endif
+
 	default:
 		if (c->isa_level == MIPS_CPU_ISA_M32R1 ||
 		    c->isa_level == MIPS_CPU_ISA_M32R2 ||
Signature · 1 line
1.5.2.1
#20 lore raw

PATCH 14/15 tlb handling support for Loongson2 processor

In reply to [email protected]

From: Fuxin Zhang <[email protected]>

---
 arch/mips/mm/tlb-r4k.c |   23 ++++++++++++++++++++++-
 arch/mips/mm/tlbex.c   |    8 +++++---
 2 files changed, 27 insertions(+), 4 deletions(-)
arch/mips/mm/tlb-r4k.c +22 -1
index 65160d4..dcd6913 100644
@@ -48,6 +48,22 @@ extern void build_tlb_refill_handler(void);
 
 #endif /* CONFIG_MIPS_MT_SMTC */
 
+#if defined(CONFIG_CPU_LOONGSON2)
+/*
+ * LOONGSON2 has a 4 entry itlb which is a subset of dtlb,
+ * unfortrunately, itlb is not totally transparent to software.
+ */
+#define FLUSH_ITLB write_c0_diag(4);
+
+#define FLUSH_ITLB_VM(vma) { if ((vma)->vm_flags & VM_EXEC)  write_c0_diag(4); }
+
+#else
+
+#define FLUSH_ITLB
+#define FLUSH_ITLB_VM(vma)
+
+#endif
+
 void local_flush_tlb_all(void)
 {
 	unsigned long flags;
@@ -73,6 +89,7 @@ void local_flush_tlb_all(void)
 	}
 	tlbw_use_hazard();
 	write_c0_entryhi(old_ctx);
+	FLUSH_ITLB;
 	EXIT_CRITICAL(flags);
 }
 
@@ -136,6 +153,7 @@ void local_flush_tlb_range(struct vm_area_struct *vma, unsigned long start,
 		} else {
 			drop_mmu_context(mm, cpu);
 		}
+		FLUSH_ITLB;
 		EXIT_CRITICAL(flags);
 	}
 }
@@ -178,6 +196,7 @@ void local_flush_tlb_kernel_range(unsigned long start, unsigned long end)
 	} else {
 		local_flush_tlb_all();
 	}
+	FLUSH_ITLB;
 	EXIT_CRITICAL(flags);
 }
 
@@ -210,6 +229,7 @@ void local_flush_tlb_page(struct vm_area_struct *vma, unsigned long page)
 
 	finish:
 		write_c0_entryhi(oldpid);
+		FLUSH_ITLB_VM(vma);
 		EXIT_CRITICAL(flags);
 	}
 }
@@ -241,7 +261,7 @@ void local_flush_tlb_one(unsigned long page)
 		tlbw_use_hazard();
 	}
 	write_c0_entryhi(oldpid);
-
+	FLUSH_ITLB;
 	EXIT_CRITICAL(flags);
 }
 
@@ -293,6 +313,7 @@ void __update_tlb(struct vm_area_struct * vma, unsigned long address, pte_t pte)
 	else
 		tlb_write_indexed();
 	tlbw_use_hazard();
+	FLUSH_ITLB_VM(vma);
 	EXIT_CRITICAL(flags);
 }
 
arch/mips/mm/tlbex.c +5 -3
index e714929..4ec0964 100644
@@ -893,6 +893,7 @@ static __init void build_tlb_write_entry(u32 **p, struct label **l,
 	case CPU_4KSC:
 	case CPU_20KC:
 	case CPU_25KF:
+	case CPU_LOONGSON2:
 		tlbw(p);
 		break;
 
@@ -1276,7 +1277,8 @@ static void __init build_r4000_tlb_refill_handler(void)
 	 * need three, with the second nop'ed and the third being
 	 * unused.
 	 */
-#ifdef CONFIG_32BIT
+	/* Loongson2 ebase is different than r4k, we have more space */
+#if defined(CONFIG_32BIT) || defined(CONFIG_CPU_LOONGSON2)
 	if ((p - tlb_handler) > 64)
 		panic("TLB refill handler space exceeded");
 #else
@@ -1289,7 +1291,7 @@ static void __init build_r4000_tlb_refill_handler(void)
 	/*
 	 * Now fold the handler in the TLB refill handler space.
 	 */
-#ifdef CONFIG_32BIT
+#if defined(CONFIG_32BIT) || defined(CONFIG_CPU_LOONGSON2)
 	f = final_handler;
 	/* Simplest case, just copy the handler. */
 	copy_handler(relocs, labels, tlb_handler, p, f);
@@ -1336,7 +1338,7 @@ static void __init build_r4000_tlb_refill_handler(void)
 		final_len);
 
 	f = final_handler;
-#ifdef CONFIG_64BIT
+#if defined(CONFIG_64BIT) && !defined(CONFIG_CPU_LOONGSON2)
 	if (final_len > 32)
 		final_len = 64;
 	else
Signature · 1 line
1.5.2.1
#21 lore raw

PATCH 15/15 work around for more than 256MB memory support

In reply to [email protected]

From: Fuxin Zhang <[email protected]>

---
 drivers/char/mem.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
drivers/char/mem.c +4 -0
index cc9a9d0..a19b46a 100644
@@ -82,8 +82,12 @@ static inline int uncached_access(struct file *file, unsigned long addr)
 	 */
 	if (file->f_flags & O_SYNC)
 		return 1;
+#if defined(CONFIG_LEMOTE_FULONG) && defined(CONFIG_64BIT)
+	return (addr >= __pa(high_memory)) || ((addr >=0x10000000) && (addr < 0x20000000));
+#else
 	return addr >= __pa(high_memory);
 #endif
+#endif
 }
 
 #ifndef ARCH_HAS_VALID_PHYS_ADDR_RANGE
Signature · 1 line
1.5.2.1
#22 lore raw

Re: [PATCH 15/15] work around for more than 256MB memory support

Quoted 12 lines · On 6/6/07, [email protected] <[email protected]> wrote:

From: Fuxin Zhang <[email protected]>

---
 drivers/char/mem.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
drivers/char/mem.c +0 -0
index cc9a9d0..a19b46a 100644

drivers/char/mem.c static inline int uncached_access(struct file *file, unsigned long addr) · line 91

Quoted 10 lines
drivers/char/mem.c +4 -0
@@ -82,8 +82,12 @@ static inline int uncached_access(struct file *file, unsigned long addr)
         */
        if (file->f_flags & O_SYNC)
                return 1;
+#if defined(CONFIG_LEMOTE_FULONG) && defined(CONFIG_64BIT)
+       return (addr >= __pa(high_memory)) || ((addr >=0x10000000) && (addr < 0x20000000));
+#else
        return addr >= __pa(high_memory);
 #endif
+#endif
 }

That would be nice to have a nice log to justify such a hack....

Thanks

Signature · 1 line
              Franck
#23 lore raw

Re: [PATCH 15/15] work around for more than 256MB memory support

Quoted 11 lines · Franck Bui-Huu
Quoted 11 lines
drivers/char/mem.c +2 -0
index cc9a9d0..a19b46a 100644
@@ -82,8 +82,12 @@ static inline int uncached_access(struct file *file, 
 unsigned long addr)
        */
       if (file->f_flags & O_SYNC)
               return 1;
+#if defined(CONFIG_LEMOTE_FULONG) && defined(CONFIG_64BIT)
+       return (addr >= __pa(high_memory)) || ((addr >=0x10000000) && 
Quoted 8 lines

drivers/char/mem.c static inline int uncached_access(struct file *file, · line 93

Quoted 6 lines
drivers/char/mem.c +2 -0
 (addr < 0x20000000));
+#else
       return addr >= __pa(high_memory);
 #endif
+#endif
 }

That would be nice to have a nice log to justify such a hack....

Unfortunately mem.c is soaked with #ifdef stuff. So I hope I can justify one more for another architecture but that'll be it. So I've put below patch into the queue tree. It will allow the Fulong code to override the function as needed. I also got this in the queue tree.

Ralf

 arch/mips/mm/cache.c |   10 ++++++++++
 drivers/char/mem.c   |    7 +++++++
 2 files changed, 17 insertions(+)
arch/mips/mm/cache.c +10 -0
Index: linux-queue/arch/mips/mm/cache.c
===================================================================
@@ -6,6 +6,8 @@
  * Copyright (C) 1994 - 2003, 07 by Ralf Baechle ([email protected])
  * Copyright (C) 2007 MIPS Technologies, Inc.
  */
+#include <linux/fs.h>
+#include <linux/fcntl.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
@@ -164,3 +166,11 @@ void __init cpu_cache_init(void)
 
 	panic(cache_panic);
 }
+
+int __weak __uncached_access(struct file *file, unsigned long addr)
+{
+	if (file->f_flags & O_SYNC)
+		return 1;
+
+	return addr >= __pa(high_memory);
+}
drivers/char/mem.c +7 -0
Index: linux-queue/drivers/char/mem.c
===================================================================
@@ -75,6 +75,13 @@ static inline int uncached_access(struct
 	 * On ia64, we ignore O_SYNC because we cannot tolerate memory attribute aliases.
 	 */
 	return !(efi_mem_attributes(addr) & EFI_MEMORY_WB);
+#elif defined(CONFIG_MIPS)
+	{
+		extern int __uncached_access(struct file *file,
+		                             unsigned long addr);
+
+		return __uncached_access(file, addr);
+	}
 #else
 	/*
 	 * Accessing memory above the top the kernel knows about or through a file pointer
#24 lore raw

PATCH 1/1 override of arch/mips/mm/cache.c: __uncached_access

From: Songmao Tian <[email protected]>

---
 arch/mips/lemote/lm2e/Makefile |    2 +-
 arch/mips/lemote/lm2e/mem.c    |   25 +++++++++++++++++++++++++
 2 files changed, 26 insertions(+), 1 deletions(-)
 create mode 100644 arch/mips/lemote/lm2e/mem.c
arch/mips/lemote/lm2e/Makefile +1 -1
index 0ba6f12..fb1b48c 100644
@@ -2,6 +2,6 @@
 # Makefile for Lemote Fulong mini-PC board.
 #
 
-obj-y += setup.o prom.o reset.o irq.o pci.o bonito-irq.o dbg_io.o
+obj-y += setup.o prom.o reset.o irq.o pci.o bonito-irq.o dbg_io.o mem.o
 EXTRA_AFLAGS := $(CFLAGS)
 
arch/mips/lemote/lm2e/mem.c new file +25 -0
new file mode 100644
index 0000000..6068a17
@@ -0,0 +1,25 @@
+/*
+ * This program is free software; you can redistribute  it and/or modify it
+ * under  the terms of  the GNU General  Public License as published by the
+ * Free Software Foundation;  either version 2 of the  License, or (at your
+ * option) any later version.
+ */
+
+#include <linux/fs.h>
+#include <linux/fcntl.h>
+#include <linux/mm.h>
+
+/* override of arch/mips/mm/cache.c: __uncached_access */
+int __uncached_access(struct file *file, unsigned long addr)
+{
+	if (file->f_flags & O_SYNC)
+		return 1;
+
+	/* 
+	 * on lemote loongson 2e system, peripheral register 
+	 * reside between 0x1000 0000 and 0x2000 0000
+	 */
+	return addr >= __pa(high_memory) ||
+		((addr >=0x10000000) && (addr < 0x20000000));
+}
+
Signature · 1 line
1.5.2.1
#25 lore raw

Re: [PATCH] override of arch/mips/mm/cache.c: __uncached_access

Recent Xorg depends on this hack/patch.

For example,if we are using this memory layout:
0-256MB phys mem
256-512M pci io/mem region
512-768MB phys mem
Xorg will crash due to pci video memory mapping problem.

So this is not really only for Fulong.

BTW:
Songmao, we'd better add a comment to justify this code.

Quoted 53 lines · [email protected] 写道:

From: Songmao Tian <[email protected]>

---
 arch/mips/lemote/lm2e/Makefile |    2 +-
 arch/mips/lemote/lm2e/mem.c    |   25 +++++++++++++++++++++++++
 2 files changed, 26 insertions(+), 1 deletions(-)
 create mode 100644 arch/mips/lemote/lm2e/mem.c
arch/mips/lemote/lm2e/Makefile +1 -1
index 0ba6f12..fb1b48c 100644
@@ -2,6 +2,6 @@
 # Makefile for Lemote Fulong mini-PC board.
 #
 
-obj-y += setup.o prom.o reset.o irq.o pci.o bonito-irq.o dbg_io.o
+obj-y += setup.o prom.o reset.o irq.o pci.o bonito-irq.o dbg_io.o mem.o
 EXTRA_AFLAGS := $(CFLAGS)
 
arch/mips/lemote/lm2e/mem.c new file +25 -0
new file mode 100644
index 0000000..6068a17
@@ -0,0 +1,25 @@
+/*
+ * This program is free software; you can redistribute  it and/or modify it
+ * under  the terms of  the GNU General  Public License as published by the
+ * Free Software Foundation;  either version 2 of the  License, or (at your
+ * option) any later version.
+ */
+
+#include <linux/fs.h>
+#include <linux/fcntl.h>
+#include <linux/mm.h>
+
+/* override of arch/mips/mm/cache.c: __uncached_access */
+int __uncached_access(struct file *file, unsigned long addr)
+{
+	if (file->f_flags & O_SYNC)
+		return 1;
+
+	/* 
+	 * on lemote loongson 2e system, peripheral register 
+	 * reside between 0x1000 0000 and 0x2000 0000
+	 */
+	return addr >= __pa(high_memory) ||
+		((addr >=0x10000000) && (addr < 0x20000000));
+}
+
Signature · 14 lines
------------------------------------------------
张福新
江苏中科龙梦科技有限公司
地址:江苏省常熟市虞山镇梦兰工业园

General Manager
JiangSu Lemote Corp. Ltd.
MengLan, Yushan, Changshu, JiangSu Province, China
ZIP: 215500 
Tel: 86-512-52308679
Fax: 86-512-52308688
Email: [email protected]
http://www.lemote.com
------------------------------------------------
#26 lore raw

Re: [PATCH] override of arch/mips/mm/cache.c: __uncached_access

Quoted 10 lines · Fuxin Zhang

For example,if we are using this memory layout:
0-256MB phys mem
256-512M pci io/mem region
512-768MB phys mem
Xorg will crash due to pci video memory mapping problem.

So this is not really only for Fulong.

BTW:
Songmao, we'd better add a comment to justify this code.

Note I didn't fundamentally object to the patch; it was rather a a question of _how_ to do it. The patch I put into the -queue tree will allow you to put all the Fulong-specifics into the Fulong code rather than the generic code.

Ralf