Skip to contentSkip to conversation

loongson: Merge and Clean up fuloong(2e), fuloong(2f) and yeeloong(2f) support

GIT repo Wu Zhangjin 3 participants 5 messages May 15, 2009

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

Dear all,

I have cleaned up the source code of loongson-based machines support and updated it to linux-2.6.29.3, the result is put to the following git repository:

git://dev.lemote.com/rt4ls.git linux-2.6.29-stable-loongson-to-ralf

this job is based on the to-mips branch of Yanhua's
git://dev.lemote.com/linux_loongson.git and the lm2e-fixes branch of Philippe's git://git.linux-cisco.org/linux-mips.git. thanks goes to them.

I have tested it with gcc 4.3 on fuloong(2e), fuloong(2f), yeeloong(2f), both 32bit and 64bit kernel works well, if you want to try it with gcc 4.4, please use the patch from attachment.

* the current source code architecture

$ tree arch/mips/loongson/
arch/mips/loongson/
|-- Kconfig
|-- Makefile
|-- common
|   |-- Makefile
|   |-- bonito-irq.c
|   |-- clock.c
|   |-- cmdline.c
|   |-- cs5536_vsm.c
|   |-- early_printk.c
|   |-- init.c
|   |-- irq.c
|   |-- mem.c
|   |-- mfgpt.c
|   |-- mipsdha.c
|   |-- misc.c
|   |-- pci.c
|   |-- reset.c
|   |-- rtc.c
|   |-- serial.c
|   |-- setup.c
|   `-- time.c
|-- fuloong-2e
|   |-- Makefile
|   |-- irq.c
|   `-- reset.c
|-- fuloong-2f
|   |-- Makefile
|   |-- irq.c
|   `-- reset.c
`-- yeeloong-2f
    |-- Makefile
    |-- init.c
    |-- irq.c
    `-- reset.c
4 directories, 30 files
$ tree arch/mips/include/asm/mach-loongson/
arch/mips/include/asm/mach-loongson/
|-- cpu-feature-overrides.h
|-- cs5536
|   |-- cs5536.h
|   |-- cs5536_pci.h
|   |-- mfgpt.h
|   `-- pcireg.h
|-- dma-coherence.h
|-- fuloong-2e
|   `-- machine.h
|-- fuloong-2f
|   `-- machine.h
|-- loongson.h
|-- mc146818rtc.h
|-- war.h
`-- yeeloong-2f
    `-- machine.h
4 directories, 12 files
$ ls arch/mips/pci/fixup-lemote2*
arch/mips/pci/fixup-lemote2e.c  arch/mips/pci/fixup-lemote2f.c
$ ls arch/mips/pci/ops-loongson2.c 
arch/mips/pci/ops-loongson2.c

* the main changes

1. make the source code of loongson support scalable, sharable

a. rename some lemote* names to loongson* names to support non-lemote
machines
b. remove the reference to bonito64, add a new loongson.h header file c. split the source code to loongson-specific(common/) &
board-specific parts(board-name/)
d. divide the source code files to the smallest logic function unit e. replace tons of magic numbers to understandable macros d. initialize several base addresses to simplify MMIO operation f. fixup RTC support

2. add basic lemote fuloong(2f) mini notebook support

a. add AMD cs5536 south bridge support
b. add fuloong-specific reboot/halt operation
c. add fuloong-specific irq operation
d. add cs5536 mfgpt timer support
e. add cpu frequency scaling support
f. add MIPS STD support

3. add basic lemote yeeloong(2f) mini notebook support

a. add yeeloong-specific reboot/halt operation
b. add yeeloong-specific command line operation

you can get the detail change logs from the git log.

Welcome your comments and suggestions. highly hope some fuloong and yeeloong users help to test it, thanks!

best regards!
Wu Zhangjin

#1 lore raw

Wu Zhangjin <[email protected]> writes:

Hi,

Quoted 6 lines

Dear all,

I have cleaned up the source code of loongson-based machines support and updated it to linux-2.6.29.3, the result is put to the following git repository:

Quoted 6 lines
   git://dev.lemote.com/rt4ls.git linux-2.6.29-stable-loongson-to-ralf

this job is based on the to-mips branch of Yanhua's
git://dev.lemote.com/linux_loongson.git and the lm2e-fixes branch of Philippe's git://git.linux-cisco.org/linux-mips.git. thanks goes to them.

I'd like to look at your patches but getting a git url prevents me to do this because replying/commenting is not possible. Can you please send patches to the list instead ?

Quoted 4 lines

I have tested it with gcc 4.3 on fuloong(2e), fuloong(2f), yeeloong(2f), both 32bit and 64bit kernel works well, if you want to try it with gcc 4.4, please use the patch from attachment.

I have some questions/comments :

- Why this patch is not merged in your patchset ?
- even if it should not affect the kernel, compiling with -march=loongson2f even for 2e (you're matching on loongson2 so 2e and 2f) looks weird.
- you're using the -mfix-ls2f-kernel binutils flag but afaik upstream binutils doesn't know it. I really don't know how such a thing should be handled but it seems strange to use this flag before binutils has been patched for it. (the previous comment about -march=loongson2f applies here too)

Quoted 2 lines

* the current source code architecture

fwiw, I like this new organisation. thanks.

Quoted 17 lines
$ tree arch/mips/loongson/
arch/mips/loongson/
|-- Kconfig
|-- Makefile
|-- common
|   |-- Makefile
|   |-- bonito-irq.c
|   |-- clock.c
|   |-- cmdline.c
|   |-- cs5536_vsm.c
|   |-- early_printk.c
|   |-- init.c
|   |-- irq.c
|   |-- mem.c
|   |-- mfgpt.c
|   |-- mipsdha.c

hm.. I thought that the mipsdha stuff was refused when submitting 2e support. Can someone check ?

Arnaud

#2 lore raw
Quoted 12 lines · Arnaud Patard

Wu Zhangjin <[email protected]> writes:

Hi,

Quoted 8 lines

Dear all,

I have cleaned up the source code of loongson-based machines support and updated it to linux-2.6.29.3, the result is put to the following git repository:

   git://dev.lemote.com/rt4ls.git linux-2.6.29-stable-loongson-to-ralf
Quoted 9 lines
Quoted 4 lines

this job is based on the to-mips branch of Yanhua's
git://dev.lemote.com/linux_loongson.git and the lm2e-fixes branch of Philippe's git://git.linux-cisco.org/linux-mips.git. thanks goes to them.

I'd like to look at your patches but getting a git url prevents me to do this because replying/commenting is not possible. Can you please send patches to the list instead ?

Yes, I will tune some commits and then send the patches out. thanks very much for your reply :-)

Quoted 8 lines
Quoted 4 lines

I have tested it with gcc 4.3 on fuloong(2e), fuloong(2f), yeeloong(2f), both 32bit and 64bit kernel works well, if you want to try it with gcc 4.4, please use the patch from attachment.

I have some questions/comments :

- Why this patch is not merged in your patchset ?

this patch is not ready yet for several reasons:

1. under gcc 4.4(I'm using the version 4.4.0 20090313, not update to the latest one yet), there are tons of problems when compiling linux-loongson in 32bit. basically, 64bit is okay, but also some problems there(i just found the reboot command of fuloong2f not work under gcc4.4, but works well under gcc 4.3).

2. -march=loongson2* only goes into gcc >= 4.4, so, there is a need to consider gcc >= 4.4 and gcc <= 4.3 differently, beside this compile option, some extra source code should be treated differently too. for example, this fix for gcc 4.4 will not work under gcc 4.3.

(quoted diff) +0 -0

b/arch/mips/include/asm/delay.h
index b0bccd2..db054ec 100644

arch/mips/include/asm/delay.h +0 -0
@@ -82,12 +82,10 @@ static inline void __udelay(unsigned long usecs,

unsigned long lpj)

                : "=h" (usecs), "=l" (lo)
                : "r" (usecs), "r" (lpj)
                : GCC_REG_ACCUM);
-       else if (sizeof(long) == 8 && !R4000_WAR)
-               __asm__("dmultu\t%2, %3"
-               : "=h" (usecs), "=l" (lo)
-               : "r" (usecs), "r" (lpj)
-               : GCC_REG_ACCUM);

- else if (sizeof(long) == 8 && R4000_WAR)
+ else if (sizeof(long) == 8 && !R4000_WAR) {
+ typedef unsigned int uint128_t
__attribute__((mode(TI)));
+ usecs = ((uint128_t) usecs * lpj) >> 64;
+ } else if (sizeof(long) == 8 && R4000_WAR)

                __asm__("dmultu\t%3, %4\n\tmfhi\t%0"
                : "=r" (usecs), "=h" (hi), "=l" (lo)
                : "r" (usecs), "r" (lpj
Quoted 3 lines

- even if it should not affect the kernel, compiling with -march=loongson2f even for 2e (you're matching on loongson2 so 2e and 2f) looks weird.

sorry, this is really a very obvious error, in 2e, -march=loongson2e should be used.

to fix this problem, perhaps we can add two new kernel options:

config CPU_LOONGSON2E
bool

config CPU_LOONGSON2F
bool

and then use this solution:

config FULOONG2E

	...
	select CPU_LOONGSON2E
	...

config YEELOONG2F

	...
	select CPU_LOONGSON2F
	...

cflags-$(CONFIG_CPU_LOONGSON2E) += -march=loongson2e -Wa,--trap cflags-$(CONFIG_CPU_LOONGSON2F) += -march=loongson2f -Wa,--trap

is this solution okay?

Quoted 6 lines

- you're using the -mfix-ls2f-kernel binutils flag but afaik upstream binutils doesn't know it. I really don't know how such a thing should be handled but it seems strange to use this flag before binutils has been patched for it. (the previous comment about -march=loongson2f applies here too)

so, it is better not use -mfix-ls2f-kernel before this option goes to the upstream binutils, i will remove it later.

but for the above reasons, i really do not want to focus on gcc 4.4 support currently, is it okay?

thanks!
Wu Zhangjin

#3 lore raw
Quoted 24 lines · Wu Zhangjin
Quoted 3 lines · Arnaud Patard

- even if it should not affect the kernel, compiling with -march=loongson2f even for 2e (you're matching on loongson2 so 2e and 2f) looks weird.

sorry, this is really a very obvious error, in 2e, -march=loongson2e should be used.

to fix this problem, perhaps we can add two new kernel options:

config CPU_LOONGSON2E
bool

config CPU_LOONGSON2F
bool

and then use this solution:

config FULOONG2E

	...
	select CPU_LOONGSON2E
	...

config YEELOONG2F

Quoted 8 lines
	...
	select CPU_LOONGSON2F
	...

cflags-$(CONFIG_CPU_LOONGSON2E) += -march=loongson2e -Wa,--trap cflags-$(CONFIG_CPU_LOONGSON2F) += -march=loongson2f -Wa,--trap

is this solution okay?

I have tried to solve this problem once. At that time, there is no loongson-dev list. So I send my patch to yanhua and zhang fuxin directly. It seems that they didn't forward that patch to you.

For the whole patch, please check attachment. It does not applicable on top of your work any more.

But here is how I deal with the CPU types:

@@ -951,14 +929,20 @@ choice
prompt "CPU type"
default CPU_R4X00

-config CPU_LOONGSON2

-       bool "Loongson 2"
-       depends on SYS_HAS_CPU_LOONGSON2
-       select CPU_SUPPORTS_32BIT_KERNEL
-       select CPU_SUPPORTS_64BIT_KERNEL
-       select CPU_SUPPORTS_HIGHMEM
+config CPU_LOONGSON2E
+       bool "Loongson 2E"
+       depends on SYS_HAS_CPU_LOONGSON2E
+       select CPU_LOONGSON2
+       help

+ The Loongson 2E processor implements the MIPS III instruction set
+ with many extensions.
+
+config CPU_LOONGSON2F

+       bool "Loongson 2F"
+       depends on SYS_HAS_CPU_LOONGSON2F
+       select CPU_LOONGSON2

help
- The Loongson 2E/2F processor implements the MIPS III instruction set
+ The Loongson 2F processor implements the MIPS III instruction set
with many extensions.

config CPU_MIPS32_R1
@@ -1171,7 +1155,16 @@ config CPU_SB1

endchoice

-config SYS_HAS_CPU_LOONGSON2
+config CPU_LOONGSON2

+       bool
+       select CPU_SUPPORTS_32BIT_KERNEL
+       select CPU_SUPPORTS_64BIT_KERNEL
+       select CPU_SUPPORTS_HIGHMEM

+
+config SYS_HAS_CPU_LOONGSON2E
+ bool
+
+config SYS_HAS_CPU_LOONGSON2F
bool

config SYS_HAS_CPU_MIPS32_R1

Signature · 4 lines
Zhang, Le
Gentoo/Loongson Developer
http://zhangle.is-a-geek.org
0260 C902 B8F8 6506 6586 2B90 BC51 C808 1E4E 2973

From 7f87a641bdc960d6e38a03197701df8b1c750d15 Mon Sep 17 00:00:00 2001
From: Zhang Le <[email protected]>
Date: Wed, 25 Mar 2009 05:44:05 +0800
Subject: [PATCH] Resent: [RFC] lemote products naming convention change

There is a little flaw in my previous patch, just fixed.

Previously, the naming convention lacks consistency. Like:
1. FULONG is actually FULOONG
2. 2E box is just called FULONG, while 2F box is called FULONG2F
3. 2F box is called FULONG2F, while 2F notebook is call 2FNOTEBOOK
4. 2F has a machine type LM2F, while 2E box has no machine type

So I tried to make it look better.

This patch applies to master branch of lemote's git. I have already tested it on my 2e/2f box and yeelong.

There are several changes in this patch:
1. added CPU type CPU_LOONGSON2E and CPU_LOONGSON2F in addition to CPU_LOONGSON2, so that we can minimize the change while make it possible to set different cflags for different CPUs.
2. added machine type MACH_LM2E, move fuloong 2e's Kconfig to its own directory
3. change all occurences of fulong to fuloong
4. change LEMOTE_FULONG to LEMOTE_FULOONG2E, make it clear that it uses Loongson 2E
5. change LEMOTE_2FNOTEBOOK to LEMOTE_YEELOONG2F

---
 arch/mips/Kconfig                               |   63 ++++++++++-------------
 arch/mips/Makefile                              |   24 ++++----
 arch/mips/configs/fulong_defconfig              |    6 +-
 arch/mips/configs/ls2f_fulong_defconfig         |    6 +-
 arch/mips/configs/ls2f_notebook_defconfig       |    6 +-
 arch/mips/configs/ls2f_notebook_fbsplash.config |    6 +-
 arch/mips/kernel/8250-platform.c                |    2 +-
 arch/mips/lemote/lm2e/Kconfig                   |   32 ++++++++++++
 arch/mips/lemote/lm2e/Makefile                  |    2 +-
 arch/mips/lemote/lm2e/prom.c                    |    2 +-
 arch/mips/lemote/lm2f/Kconfig                   |   23 ++++----
 arch/mips/lemote/lm2f/lmbook/Makefile           |    2 +-
 arch/mips/pci/Makefile                          |    6 +-
 arch/mips/pci/ops-bonito64.c                    |    4 +-
 arch/mips/zboot/Makefile                        |    2 +-
 arch/mips/zboot/lm2f/ns16550.c                  |    4 +-
 drivers/ata/Kconfig                             |    2 +-
 include/asm-mips/mips-boards/bonito64.h         |    2 +-
 18 files changed, 109 insertions(+), 85 deletions(-)
 create mode 100644 arch/mips/lemote/lm2e/Kconfig
arch/mips/Kconfig +28 -35
index 5059abe..d0ea735 100644
@@ -155,34 +155,11 @@ config LASAT
 	select SYS_SUPPORTS_LITTLE_ENDIAN
 	select GENERIC_HARDIRQS_NO__DO_IRQ
 
-config LEMOTE_FULONG
-	bool "Lemote Fulong mini-PC"
-	select ARCH_SPARSEMEM_ENABLE
-	select CEVT_R4K
-	select CSRC_R4K
-	select SYS_HAS_CPU_LOONGSON2
-	select DMA_NONCOHERENT
-	select BOOT_ELF32
-	select BOARD_SCACHE
-	select HAVE_STD_PC_SERIAL_PORT
-	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 GENERIC_ISA_DMA_SUPPORT_BROKEN
-	select CPU_HAS_WB
-	help
-	  Lemote Fulong mini-PC board based on the Chinese Loongson-2E CPU and
-	  an FPGA northbridge
+config MACH_LM2E
+	bool "Lemote Loongson 2E based machines"
 
 config MACH_LM2F
-	bool "Lemote LOONGSON2F based machines"
+	bool "Lemote Loongson 2F based machines"
 
 config MIPS_MALTA
 	bool "MIPS Malta board"
@@ -610,6 +587,7 @@ source "arch/mips/sgi-ip27/Kconfig"
 source "arch/mips/sibyte/Kconfig"
 source "arch/mips/txx9/Kconfig"
 source "arch/mips/vr41xx/Kconfig"
+source "arch/mips/lemote/lm2e/Kconfig"
 source "arch/mips/lemote/lm2f/Kconfig"
 
 endmenu
@@ -951,14 +929,20 @@ choice
 	prompt "CPU type"
 	default CPU_R4X00
 
-config CPU_LOONGSON2
-	bool "Loongson 2"
-	depends on SYS_HAS_CPU_LOONGSON2
-	select CPU_SUPPORTS_32BIT_KERNEL
-	select CPU_SUPPORTS_64BIT_KERNEL
-	select CPU_SUPPORTS_HIGHMEM
+config CPU_LOONGSON2E
+	bool "Loongson 2E"
+	depends on SYS_HAS_CPU_LOONGSON2E
+	select CPU_LOONGSON2
+	help
+	  The Loongson 2E processor implements the MIPS III instruction set
+	  with many extensions.
+
+config CPU_LOONGSON2F
+	bool "Loongson 2F"
+	depends on SYS_HAS_CPU_LOONGSON2F
+	select CPU_LOONGSON2
 	help
-	  The Loongson 2E/2F processor implements the MIPS III instruction set
+	  The Loongson 2F processor implements the MIPS III instruction set
 	  with many extensions.
 
 config CPU_MIPS32_R1
@@ -1171,7 +1155,16 @@ config CPU_SB1
 
 endchoice
 
-config SYS_HAS_CPU_LOONGSON2
+config CPU_LOONGSON2
+	bool
+	select CPU_SUPPORTS_32BIT_KERNEL
+	select CPU_SUPPORTS_64BIT_KERNEL
+	select CPU_SUPPORTS_HIGHMEM
+
+config SYS_HAS_CPU_LOONGSON2E
+	bool
+
+config SYS_HAS_CPU_LOONGSON2F
 	bool
 
 config SYS_HAS_CPU_MIPS32_R1
@@ -2036,7 +2029,7 @@ source "drivers/cpufreq/Kconfig"
 
 config LS2F_CPU_FREQ
 	tristate "Loongson-2F CPU Frequency driver"
-	depends on CPU_LOONGSON2 && CPU_FREQ
+	depends on CPU_LOONGSON2F && CPU_FREQ
 	select CPU_FREQ_TABLE
 	help
 	  This adds the cpufreq driver for Loongson-2F.
arch/mips/Makefile +12 -12
index 95036fd..2a59e77 100644
@@ -298,11 +298,11 @@ cflags-$(CONFIG_WR_PPMC)		+= -Iinclude/asm-mips/mach-wrppmc
 load-$(CONFIG_WR_PPMC)		+= 0xffffffff80100000
 
 #
-# lemote fulong mini-PC board
+# lemote loongson2e fuloong 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
+core-$(CONFIG_LEMOTE_FULOONG2E) +=arch/mips/lemote/lm2e/
+load-$(CONFIG_LEMOTE_FULOONG2E) +=0xffffffff80100000
+cflags-$(CONFIG_LEMOTE_FULOONG2E) += -I$(srctree)/arch/mips/include/asm/mach-lemote
 
 #
 # common lemote loongson2f stuffs
@@ -310,18 +310,18 @@ cflags-$(CONFIG_LEMOTE_FULONG) += -Iinclude/asm-mips/mach-lemote
 core-$(CONFIG_MACH_LM2F) +=arch/mips/lemote/lm2f/common/
 
 #
-# lemote loongson2f fulong mini-PC board
+# lemote loongson2f fuloong mini-PC board
 #
-core-$(CONFIG_LEMOTE_FULONG2F) +=arch/mips/lemote/lm2f/lmbox/
-load-$(CONFIG_LEMOTE_FULONG2F) +=0xffffffff80200000
-cflags-$(CONFIG_LEMOTE_FULONG2F) += -Iinclude/asm-mips/mach-lemote
+core-$(CONFIG_LEMOTE_FULOONG2F) +=arch/mips/lemote/lm2f/lmbox/
+load-$(CONFIG_LEMOTE_FULOONG2F) +=0xffffffff80200000
+cflags-$(CONFIG_LEMOTE_FULOONG2F) += -I$(srctree)/arch/mips/include/asm/mach-lemote
 
 #
-# lemote loongson2f notebook
+# lemote loongson2f yeeloong notebook
 #
-core-$(CONFIG_LEMOTE_2FNOTEBOOK) +=arch/mips/lemote/lm2f/lmbook/
-load-$(CONFIG_LEMOTE_2FNOTEBOOK) +=0xffffffff80200000
-cflags-$(CONFIG_LEMOTE_2FNOTEBOOK) += -Iinclude/asm-mips/mach-lemote
+core-$(CONFIG_LEMOTE_YEELOONG2F) +=arch/mips/lemote/lm2f/lmbook/
+load-$(CONFIG_LEMOTE_YEELOONG2F) +=0xffffffff80200000
+cflags-$(CONFIG_LEMOTE_YEELOONG2F) += -I$(srctree)/arch/mips/include/asm/mach-lemote
 
 #
 # MIPS Malta board
arch/mips/configs/fulong_defconfig +3 -3
index 6209800..170b4e5 100644
@@ -8,7 +8,7 @@ CONFIG_MIPS=y
 #
 # Machine selection
 #
-CONFIG_LEMOTE_FULONG=y
+CONFIG_LEMOTE_FULOONG2E=y
 # CONFIG_MACH_ALCHEMY is not set
 # CONFIG_BASLER_EXCITE is not set
 # CONFIG_MIPS_COBALT is not set
@@ -62,7 +62,7 @@ CONFIG_MIPS_L1_CACHE_SHIFT=5
 #
 # CPU selection
 #
-CONFIG_CPU_LOONGSON2=y
+CONFIG_CPU_LOONGSON2E=y
 # CONFIG_CPU_MIPS32_R1 is not set
 # CONFIG_CPU_MIPS32_R2 is not set
 # CONFIG_CPU_MIPS64_R1 is not set
@@ -82,7 +82,7 @@ CONFIG_CPU_LOONGSON2=y
 # CONFIG_CPU_RM7000 is not set
 # CONFIG_CPU_RM9000 is not set
 # CONFIG_CPU_SB1 is not set
-CONFIG_SYS_HAS_CPU_LOONGSON2=y
+CONFIG_SYS_HAS_CPU_LOONGSON2E=y
 CONFIG_SYS_SUPPORTS_32BIT_KERNEL=y
 CONFIG_SYS_SUPPORTS_64BIT_KERNEL=y
 CONFIG_CPU_SUPPORTS_32BIT_KERNEL=y
arch/mips/configs/ls2f_fulong_defconfig +3 -3
index 77c71bd..ea05368 100644
@@ -44,7 +44,7 @@ CONFIG_MACH_LM2F=y
 # CONFIG_TOSHIBA_RBTX4927 is not set
 # CONFIG_TOSHIBA_RBTX4938 is not set
 # CONFIG_WR_PPMC is not set
-CONFIG_LEMOTE_FULONG2F=y
+CONFIG_LEMOTE_FULOONG2F=y
 # CONFIG_LEMOTE_2FNOTEBOOK is not set
 CONFIG_CS5536_RTC_BUG=y
 CONFIG_CS5536=y
@@ -83,7 +83,7 @@ CONFIG_HAVE_STD_PC_SERIAL_PORT=y
 #
 # CPU selection
 #
-CONFIG_CPU_LOONGSON2=y
+CONFIG_CPU_LOONGSON2F=y
 # CONFIG_CPU_MIPS32_R1 is not set
 # CONFIG_CPU_MIPS32_R2 is not set
 # CONFIG_CPU_MIPS64_R1 is not set
@@ -103,7 +103,7 @@ CONFIG_CPU_LOONGSON2=y
 # CONFIG_CPU_RM7000 is not set
 # CONFIG_CPU_RM9000 is not set
 # CONFIG_CPU_SB1 is not set
-CONFIG_SYS_HAS_CPU_LOONGSON2=y
+CONFIG_SYS_HAS_CPU_LOONGSON2F=y
 CONFIG_SYS_SUPPORTS_32BIT_KERNEL=y
 CONFIG_SYS_SUPPORTS_64BIT_KERNEL=y
 CONFIG_CPU_SUPPORTS_32BIT_KERNEL=y
arch/mips/configs/ls2f_notebook_defconfig +3 -3
index 8251089..14516da 100644
@@ -43,7 +43,7 @@ CONFIG_MACH_LM2F=y
 # CONFIG_MIKROTIK_RB532 is not set
 # CONFIG_WR_PPMC is not set
 # CONFIG_LEMOTE_FULONG2F is not set
-CONFIG_LEMOTE_2FNOTEBOOK=y
+CONFIG_LEMOTE_YEELOONG2F=y
 CONFIG_CS5536_RTC_BUG=y
 CONFIG_CS5536=y
 CONFIG_RWSEM_GENERIC_SPINLOCK=y
@@ -80,7 +80,7 @@ CONFIG_HAVE_STD_PC_SERIAL_PORT=y
 #
 # CPU selection
 #
-CONFIG_CPU_LOONGSON2=y
+CONFIG_CPU_LOONGSON2F=y
 # CONFIG_CPU_MIPS32_R1 is not set
 # CONFIG_CPU_MIPS32_R2 is not set
 # CONFIG_CPU_MIPS64_R1 is not set
@@ -100,7 +100,7 @@ CONFIG_CPU_LOONGSON2=y
 # CONFIG_CPU_RM7000 is not set
 # CONFIG_CPU_RM9000 is not set
 # CONFIG_CPU_SB1 is not set
-CONFIG_SYS_HAS_CPU_LOONGSON2=y
+CONFIG_SYS_HAS_CPU_LOONGSON2F=y
 CONFIG_SYS_SUPPORTS_32BIT_KERNEL=y
 CONFIG_SYS_SUPPORTS_64BIT_KERNEL=y
 CONFIG_CPU_SUPPORTS_32BIT_KERNEL=y
arch/mips/configs/ls2f_notebook_fbsplash.config +3 -3
index 43d45cf..82cce00 100644
@@ -43,7 +43,7 @@ CONFIG_MACH_LM2F=y
 # CONFIG_MIKROTIK_RB532 is not set
 # CONFIG_WR_PPMC is not set
 # CONFIG_LEMOTE_FULONG2F is not set
-CONFIG_LEMOTE_2FNOTEBOOK=y
+CONFIG_LEMOTE_YEELOONG2F=y
 CONFIG_CS5536_RTC_BUG=y
 CONFIG_CS5536=y
 CONFIG_RWSEM_GENERIC_SPINLOCK=y
@@ -80,7 +80,7 @@ CONFIG_HAVE_STD_PC_SERIAL_PORT=y
 #
 # CPU selection
 #
-CONFIG_CPU_LOONGSON2=y
+CONFIG_CPU_LOONGSON2F=y
 # CONFIG_CPU_MIPS32_R1 is not set
 # CONFIG_CPU_MIPS32_R2 is not set
 # CONFIG_CPU_MIPS64_R1 is not set
@@ -100,7 +100,7 @@ CONFIG_CPU_LOONGSON2=y
 # CONFIG_CPU_RM7000 is not set
 # CONFIG_CPU_RM9000 is not set
 # CONFIG_CPU_SB1 is not set
-CONFIG_SYS_HAS_CPU_LOONGSON2=y
+CONFIG_SYS_HAS_CPU_LOONGSON2F=y
 CONFIG_SYS_SUPPORTS_32BIT_KERNEL=y
 CONFIG_SYS_SUPPORTS_64BIT_KERNEL=y
 CONFIG_CPU_SUPPORTS_32BIT_KERNEL=y
arch/mips/kernel/8250-platform.c +1 -1
index 6bf8ab3..308b02d 100644
@@ -27,7 +27,7 @@
 
 static struct plat_serial8250_port uart8250_data[] = {
 #ifdef CONFIG_MACH_LM2F
-#if defined(CONFIG_LEMOTE_NAS) || defined(CONFIG_LEMOTE_2FNOTEBOOK)
+#if defined(CONFIG_LEMOTE_NAS) || defined(CONFIG_LEMOTE_YEELOONG2F)
 	{ .membase = UART_BASE,
 	  .irq = 19,
 	  .uartclk = 3686400,
arch/mips/lemote/lm2e/Kconfig new file +32 -0
new file mode 100644
index 0000000..aa897c1
@@ -0,0 +1,32 @@
+choice
+	prompt "Machine type"
+	depends on MACH_LM2E
+	default LEMOTE_FULOONG2E
+
+config LEMOTE_FULOONG2E
+	bool "Lemote Fuloong 2E mini PC"
+	select ARCH_SPARSEMEM_ENABLE
+	select CEVT_R4K
+	select CSRC_R4K
+	select SYS_HAS_CPU_LOONGSON2E
+	select DMA_NONCOHERENT
+	select BOOT_ELF32
+	select BOARD_SCACHE
+	select HAVE_STD_PC_SERIAL_PORT
+	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 GENERIC_ISA_DMA_SUPPORT_BROKEN
+	select CPU_HAS_WB
+	help
+	  Lemote Fuloong mini-PC board based on the Chinese Loongson-2E CPU and
+	  an FPGA northbridge
+
+endchoice
arch/mips/lemote/lm2e/Makefile +1 -1
index d34671d..a31cff2 100644
@@ -1,5 +1,5 @@
 #
-# Makefile for Lemote Fulong mini-PC board.
+# Makefile for Lemote Fuloong mini-PC board.
 #
 
 obj-y += setup.o prom.o reset.o irq.o pci.o bonito-irq.o dbg_io.o mem.o
arch/mips/lemote/lm2e/prom.c +1 -1
index 7edc15d..1ea17b5 100644
@@ -30,7 +30,7 @@ static int *env;
 
 const char *get_system_type(void)
 {
-	return "lemote-fulong";
+	return "lemote-fuloong";
 }
 
 void __init prom_init_cmdline(void)
arch/mips/lemote/lm2f/Kconfig +11 -12
index 25c2b3d..f157f15 100644
@@ -1,14 +1,14 @@
 choice
 	prompt "Machine type"
 	depends on MACH_LM2F
-	default LEMOTE_FULONG2F
+	default LEMOTE_FULOONG2F
 
-config LEMOTE_FULONG2F
-	bool "Lemote Fulong mini-PC"
+config LEMOTE_FULOONG2F
+	bool "Lemote Fuloong 2F mini PC"
 	select ARCH_SPARSEMEM_ENABLE
 	select CEVT_R4K
 	select CSRC_R4K
-	select SYS_HAS_CPU_LOONGSON2
+	select SYS_HAS_CPU_LOONGSON2F
 	select DMA_NONCOHERENT
 	select BOOT_ELF32
 	select BOARD_SCACHE
@@ -27,14 +27,14 @@ config LEMOTE_FULONG2F
 	select CPU_HAS_WB
 	select CS5536
 	help
-	  Lemote Fulong mini-PC board based on the Chinese Loongson-2F CPU
+	  Lemote Fuloong mini-PC board based on the Chinese Loongson-2F CPU
 
-config LEMOTE_2FNOTEBOOK
-	bool "Lemote mini Notebook"
+config LEMOTE_YEELOONG2F
+	bool "Lemote Yeeloong 2F mini Notebook"
 	select ARCH_SPARSEMEM_ENABLE
 	select CEVT_R4K
 	select CSRC_R4K
-	select SYS_HAS_CPU_LOONGSON2
+	select SYS_HAS_CPU_LOONGSON2F
 	select DMA_NONCOHERENT
 	select BOOT_ELF32
 	select BOARD_SCACHE
@@ -53,7 +53,7 @@ config LEMOTE_2FNOTEBOOK
 	select CPU_HAS_WB
 	select CS5536
 	help
-	  Lemote Notebook based on the Chinese Loongson-2F CPU
+	  Lemote Yeelong Notebook based on the Chinese Loongson-2F CPU
 
 endchoice
 
@@ -66,7 +66,6 @@ config CS5536
 
 config LEMOTE_NAS
 	bool "Lemote NAS machine"
-	depends on LEMOTE_FULONG2F
-	help 
+	depends on LEMOTE_FULOONG2F
+	help
 	  Lemote's Loongson-2F based network attached system
-
arch/mips/lemote/lm2f/lmbook/Makefile +1 -1
index 92a19c3..cccb40d 100644
@@ -1,5 +1,5 @@
 #
-# Makefile for Lemote Loongson-2F mini notebook
+# Makefile for Lemote Loongson-2F yeeloong mini notebook
 #
 
 obj-y	+= setup.o prom.o reset.o irq.o bonito-irq.o dbg_io.o 
arch/mips/pci/Makefile +3 -3
index b023e1c..97b2cc5 100644
@@ -26,9 +26,9 @@ obj-$(CONFIG_MIPS_COBALT)	+= fixup-cobalt.o
 obj-$(CONFIG_SOC_AU1500)	+= fixup-au1000.o ops-au1000.o
 obj-$(CONFIG_SOC_AU1550)	+= fixup-au1000.o ops-au1000.o
 obj-$(CONFIG_SOC_PNX8550)	+= fixup-pnx8550.o ops-pnx8550.o
-obj-$(CONFIG_LEMOTE_FULONG)	+= fixup-lm2e.o ops-bonito64.o
-obj-$(CONFIG_LEMOTE_FULONG2F)	+= fixup-lm2f.o ops-loongson2f.o
-obj-$(CONFIG_LEMOTE_2FNOTEBOOK)	+= fixup-lmbook.o ops-loongson2f.o
+obj-$(CONFIG_LEMOTE_FULOONG2E)	+= fixup-lm2e.o ops-bonito64.o
+obj-$(CONFIG_LEMOTE_FULOONG2F)	+= fixup-lm2f.o ops-loongson2f.o
+obj-$(CONFIG_LEMOTE_YEELOONG2F)	+= fixup-lmbook.o ops-loongson2f.o
 obj-$(CONFIG_MIPS_MALTA)	+= fixup-malta.o
 obj-$(CONFIG_PMC_MSP7120_GW)	+= fixup-pmcmsp.o ops-pmcmsp.o
 obj-$(CONFIG_PMC_MSP7120_EVAL)	+= fixup-pmcmsp.o ops-pmcmsp.o
arch/mips/pci/ops-bonito64.c +2 -2
index f742c51..54e55e7 100644
@@ -29,7 +29,7 @@
 #define PCI_ACCESS_READ  0
 #define PCI_ACCESS_WRITE 1
 
-#ifdef CONFIG_LEMOTE_FULONG
+#ifdef CONFIG_LEMOTE_FULOONG2E
 #define CFG_SPACE_REG(offset) (void *)CKSEG1ADDR(BONITO_PCICFG_BASE | (offset))
 #define ID_SEL_BEGIN 11
 #else
@@ -77,7 +77,7 @@ static int bonito64_pcibios_config_access(unsigned char access_type,
 	addrp = CFG_SPACE_REG(addr & 0xffff);
 	if (access_type == PCI_ACCESS_WRITE) {
 		writel(cpu_to_le32(*data), addrp);
-#ifndef CONFIG_LEMOTE_FULONG
+#ifndef CONFIG_LEMOTE_FULOONG2E
 		/* Wait till done */
 		while (BONITO_PCIMSTAT & 0xF);
 #endif
arch/mips/zboot/Makefile +1 -1
index 9c3bc8a..7ca8aa8 100644
@@ -43,7 +43,7 @@ images/vmlinux.gz: $(TOPDIR)/vmlinux
 
 $(BOOT_TARGETS): lib/zlib.a images/vmlinux.gz
 
-ifdef CONFIG_LEMOTE_FULONG
+ifdef CONFIG_LEMOTE_FULOONG2E
 SUBARCH := $(obj)/lm2e
 KBUILD_IMAGE := arch/mips/zboot/lm2e/bzImage
 endif
arch/mips/zboot/lm2f/ns16550.c +2 -2
index 8bfe8bb..9410665 100644
@@ -8,7 +8,7 @@
 
 typedef struct NS16550 *NS16550_t;
 
-#ifdef CONFIG_LEMOTE_FULONG2F
+#ifdef CONFIG_LEMOTE_FULOONG2F
 #ifdef CONFIG_LEMOTE_NAS
 #define COM1 0xbff003f8
 #else 
@@ -16,7 +16,7 @@ typedef struct NS16550 *NS16550_t;
 #endif
 #endif
 
-#ifdef CONFIG_LEMOTE_2FNOTEBOOK 
+#ifdef CONFIG_LEMOTE_YEELOONG2F
 #define COM1 0xbff003f8
 #endif
 
drivers/ata/Kconfig +1 -1
index 11c8c19..a69a1ab 100644
@@ -311,7 +311,7 @@ config PATA_CS5535
 
 config PATA_CS5536
 	tristate "CS5536 PATA support (Experimental)"
-	depends on PCI && X86 && !X86_64 && EXPERIMENTAL
+	depends on PCI && ( X86 || MACH_LM2F ) && !X86_64
 	help
 	  This option enables support for the AMD CS5536
 	  companion chip used with the Geode LX processor family.
include/asm-mips/mips-boards/bonito64.h +1 -1
index 9e70093..86f7a76 100644
@@ -26,7 +26,7 @@
 /* offsets from base register */
 #define BONITO(x)	(x)
 
-#elif defined(CONFIG_LEMOTE_FULONG) ||defined(CONFIG_LEMOTE_FULONG2F) ||defined(CONFIG_LEMOTE_2FNOTEBOOK)
+#elif defined(CONFIG_MACH_LM2E) || defined(CONFIG_MACH_LM2F)
 
 #define BONITO(x) (*(volatile u32 *)((char *)CKSEG1ADDR(BONITO_REG_BASE) + (x)))
 #define BONITO_IRQ_BASE   32
Signature · 1 line
1.6.2.3
author Applied
#4 lore raw
Quoted 80 lines · Zhang Le
Quoted 24 lines · Wu Zhangjin
Quoted 3 lines · Arnaud Patard

- even if it should not affect the kernel, compiling with -march=loongson2f even for 2e (you're matching on loongson2 so 2e and 2f) looks weird.

sorry, this is really a very obvious error, in 2e, -march=loongson2e should be used.

to fix this problem, perhaps we can add two new kernel options:

config CPU_LOONGSON2E
bool

config CPU_LOONGSON2F
bool

and then use this solution:

config FULOONG2E

	...
	select CPU_LOONGSON2E
	...

config YEELOONG2F

Quoted 8 lines
	...
	select CPU_LOONGSON2F
	...

cflags-$(CONFIG_CPU_LOONGSON2E) += -march=loongson2e -Wa,--trap cflags-$(CONFIG_CPU_LOONGSON2F) += -march=loongson2f -Wa,--trap

is this solution okay?

I have tried to solve this problem once. At that time, there is no loongson-dev list. So I send my patch to yanhua and zhang fuxin directly. It seems that they didn't forward that patch to you.

For the whole patch, please check attachment. It does not applicable on top of your work any more.

But here is how I deal with the CPU types:

arch/mips/Kconfig +16 -8
@@ -951,14 +929,20 @@ choice
       prompt "CPU type"
       default CPU_R4X00
 
-config CPU_LOONGSON2
-       bool "Loongson 2"
-       depends on SYS_HAS_CPU_LOONGSON2
-       select CPU_SUPPORTS_32BIT_KERNEL
-       select CPU_SUPPORTS_64BIT_KERNEL
-       select CPU_SUPPORTS_HIGHMEM
+config CPU_LOONGSON2E
+       bool "Loongson 2E"
+       depends on SYS_HAS_CPU_LOONGSON2E
+       select CPU_LOONGSON2
+       help
+         The Loongson 2E processor implements the MIPS III instruction set
+         with many extensions.
+
+config CPU_LOONGSON2F
+       bool "Loongson 2F"
+       depends on SYS_HAS_CPU_LOONGSON2F
+       select CPU_LOONGSON2
        help
-         The Loongson 2E/2F processor implements the MIPS III instruction set
+         The Loongson 2F processor implements the MIPS III instruction set
         with many extensions.
 
 config CPU_MIPS32_R1
@@ -1171,7 +1155,16 @@ config CPU_SB1
 
 endchoice
 
-config SYS_HAS_CPU_LOONGSON2
+config CPU_LOONGSON2
+       bool
+       select CPU_SUPPORTS_32BIT_KERNEL

arch/mips/Kconfig config CPU_SB1 · line 1170

Quoted 10 lines
arch/mips/Kconfig +7 -0
+       select CPU_SUPPORTS_64BIT_KERNEL
+       select CPU_SUPPORTS_HIGHMEM
+
+config SYS_HAS_CPU_LOONGSON2E
+       bool
+
+config SYS_HAS_CPU_LOONGSON2F
        bool
 
 config SYS_HAS_CPU_MIPS32_R1

applied it, thanks!