All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/14] MIPS: Add Loongson-3 based machines support.
@ 2012-06-15  8:09 Huacai Chen
  2012-06-15  8:09 ` [PATCH 01/14] MIPS: Loongson: Add basic Loongson 3 CPU support Huacai Chen
                   ` (14 more replies)
  0 siblings, 15 replies; 34+ messages in thread
From: Huacai Chen @ 2012-06-15  8:09 UTC (permalink / raw)
  To: Ralf Baechle
  Cc: linux-mips, Fuxin Zhang, Zhangjin Wu, Huacai Chen, Hongliang Tao,
	Hua Yan

This patchset is for git repository git://git.linux-mips.org/pub/scm/
ralf/linux. Loongson-3 is a multi-core MIPS family CPU, it is MIPS64R2
compatible and has the same IMP field (0x6300) as Loongson-2. These
patches make Linux kernel support Loongson-3 CPU and Loongson-3 based
computers (including Laptop, Mini-ITX, All-In-One PC, etc.)

Huacai Chen(14):
 MIPS: Loongson: Add basic Loongson 3 CPU support.
 MIPS: Loongson 3: Add Lemote-3A machtypes definition.
 MIPS: Loongson: Make Loongson 3 to use BCD format for RTC.
 MIPS: Loongson: Add UEFI-like firmware interface support.
 MIPS: Loongson 3: Add HT-linked PCI support.
 MIPS: Loongson 3: Add IRQ init and dispatch support.
 MIPS: Loongson 3: Add serial port support.
 MIPS: Loongson: Add swiotlb to support big memory (>4GB).
 ata: Use 32bit DMA in AHCI for Loongson 3.
 drm/radeon: Make radeon card usable for Loongson.
 ALSA: Make hda sound card usable for Loongson.
 MIPS: Loongson 3: Add Loongson-3 SMP support.
 MIPS: Loongson 3: Add CPU Hotplug support.
 MIPS: Loongson: Add a Loongson 3 default config file.

Signed-off-by: Huacai Chen <chenhc@lemote.com>
Signed-off-by: Hongliang Tao <taohl@lemote.com>
Signed-off-by: Hua Yan <yanh@lemote.com>
---
 arch/mips/Kconfig                                  |   23 +
 arch/mips/configs/loongson3_defconfig              |  704 ++++++++++++++++++++
 arch/mips/include/asm/addrspace.h                  |    6 +
 arch/mips/include/asm/bootinfo.h                   |   23 +-
 arch/mips/include/asm/cpu.h                        |    6 +-
 arch/mips/include/asm/mach-loongson/boot_param.h   |  150 +++++
 .../mips/include/asm/mach-loongson/dma-coherence.h |   25 +-
 arch/mips/include/asm/mach-loongson/irq.h          |   26 +
 arch/mips/include/asm/mach-loongson/loongson.h     |   29 +-
 arch/mips/include/asm/mach-loongson/machine.h      |    6 +
 arch/mips/include/asm/mach-loongson/mc146818rtc.h  |    4 +
 arch/mips/include/asm/mach-loongson/pci.h          |    5 +
 arch/mips/include/asm/mach-loongson/spaces.h       |   15 +
 arch/mips/include/asm/module.h                     |    2 +
 arch/mips/include/asm/pgtable-bits.h               |    7 +
 arch/mips/include/asm/smp.h                        |    1 +
 arch/mips/kernel/Makefile                          |    1 +
 arch/mips/kernel/cpu-probe.c                       |   12 +-
 arch/mips/kernel/process.c                         |    4 +-
 arch/mips/lib/Makefile                             |    1 +
 arch/mips/loongson/Kconfig                         |   52 ++
 arch/mips/loongson/Makefile                        |    6 +
 arch/mips/loongson/Platform                        |    1 +
 arch/mips/loongson/common/Makefile                 |    5 +
 arch/mips/loongson/common/dma-swiotlb.c            |  147 ++++
 arch/mips/loongson/common/env.c                    |   67 ++-
 arch/mips/loongson/common/init.c                   |   14 +-
 arch/mips/loongson/common/machtype.c               |    5 +-
 arch/mips/loongson/common/mem.c                    |   42 ++
 arch/mips/loongson/common/pci.c                    |    6 +-
 arch/mips/loongson/common/reset.c                  |   14 +
 arch/mips/loongson/common/serial.c                 |   27 +
 arch/mips/loongson/common/setup.c                  |    6 +-
 arch/mips/loongson/common/uart_base.c              |    5 +
 arch/mips/loongson/loongson-3/Makefile             |    6 +
 arch/mips/loongson/loongson-3/irq.c                |   97 +++
 arch/mips/loongson/loongson-3/smp.c                |  453 +++++++++++++
 arch/mips/loongson/loongson-3/smp.h                |   24 +
 arch/mips/mm/Makefile                              |    1 +
 arch/mips/mm/c-r4k.c                               |   84 +++
 arch/mips/mm/dma-default.c                         |   13 +-
 arch/mips/mm/tlb-r4k.c                             |    2 +-
 arch/mips/mm/tlbex.c                               |    1 +
 arch/mips/pci/Makefile                             |    1 +
 arch/mips/pci/fixup-loongson3.c                    |   50 ++
 arch/mips/pci/ops-loongson3.c                      |  104 +++
 drivers/ata/ahci.c                                 |    5 +
 drivers/gpu/drm/drm_vm.c                           |    2 +-
 drivers/gpu/drm/radeon/radeon_bios.c               |   32 +
 drivers/gpu/drm/radeon/radeon_device.c             |    5 +
 drivers/gpu/drm/radeon/radeon_ttm.c                |    6 +-
 drivers/gpu/drm/ttm/ttm_bo_util.c                  |    2 +-
 include/drm/drm_sarea.h                            |    2 +
 include/linux/pci_ids.h                            |    2 +
 sound/pci/hda/hda_intel.c                          |    5 +
 sound/pci/hda/patch_conexant.c                     |   52 ++-
 56 files changed, 2339 insertions(+), 57 deletions(-)
 create mode 100644 arch/mips/configs/loongson3_defconfig
 create mode 100644 arch/mips/include/asm/mach-loongson/boot_param.h
 create mode 100644 arch/mips/include/asm/mach-loongson/irq.h
 create mode 100644 arch/mips/include/asm/mach-loongson/spaces.h
 create mode 100644 arch/mips/loongson/common/dma-swiotlb.c
 create mode 100644 arch/mips/loongson/loongson-3/Makefile
 create mode 100644 arch/mips/loongson/loongson-3/irq.c
 create mode 100644 arch/mips/loongson/loongson-3/smp.c
 create mode 100644 arch/mips/loongson/loongson-3/smp.h
 create mode 100644 arch/mips/pci/fixup-loongson3.c
 create mode 100644 arch/mips/pci/ops-loongson3.c
-- 
1.7.7.3

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH 01/14] MIPS: Loongson: Add basic Loongson 3 CPU support.
  2012-06-15  8:09 [PATCH 00/14] MIPS: Add Loongson-3 based machines support Huacai Chen
@ 2012-06-15  8:09 ` Huacai Chen
  2012-06-15 15:59   ` David Daney
  2012-06-15  8:09 ` [PATCH 02/14] MIPS: Loongson 3: Add Lemote-3A machtypes definition Huacai Chen
                   ` (13 subsequent siblings)
  14 siblings, 1 reply; 34+ messages in thread
From: Huacai Chen @ 2012-06-15  8:09 UTC (permalink / raw)
  To: Ralf Baechle
  Cc: linux-mips, Fuxin Zhang, Zhangjin Wu, Huacai Chen, Hongliang Tao,
	Hua Yan

Loongson-3 is a multi-core MIPS family CPU, it support MIPS64R2
fully. Loongson-3 has the same IMP field (0x6300) as Loongson-2.

Loongson-3 has a hardware-maintained cache, system software doesn't
need to maintain coherency.

Loongson-3A is the first revision of Loongson-3, and it is the quad-
core version of Loongson-2G. Loongson-3A has a simplified version named
Loongson-2Gq, the main difference between Loongson-3A/2Gq is 3A has two
HyperTransport controller but 2Gq has only one. HT0 is used for cross-
chip interconnection and HT1 is used to link PCI bus. Therefore, 2Gq
cannot support NUMA but 3A can.

Exsisting Loongson family CPUs:
Loongson-1: Loongson-1A, Loongson-1B, they are 32-bit MIPS CPUs.
Loongson-2: Loongson-2E, Loongson-2F, Loongson-2G(including Loongson-
            2Gq), they are 64-bit MIPS CPUs.
Loongson-3: Loongson-3A, it is a 64-bit MIPS CPU.

Signed-off-by: Huacai Chen <chenhc@lemote.com>
Signed-off-by: Hongliang Tao <taohl@lemote.com>
Signed-off-by: Hua Yan <yanh@lemote.com>
---
 arch/mips/Kconfig                            |   13 ++++
 arch/mips/include/asm/addrspace.h            |    6 ++
 arch/mips/include/asm/cpu.h                  |    6 +-
 arch/mips/include/asm/mach-loongson/spaces.h |   15 +++++
 arch/mips/include/asm/module.h               |    2 +
 arch/mips/include/asm/pgtable-bits.h         |    7 ++
 arch/mips/kernel/Makefile                    |    1 +
 arch/mips/kernel/cpu-probe.c                 |   12 +++-
 arch/mips/lib/Makefile                       |    1 +
 arch/mips/loongson/Kconfig                   |    4 +
 arch/mips/loongson/Platform                  |    1 +
 arch/mips/loongson/common/env.c              |    3 +
 arch/mips/loongson/common/setup.c            |    6 +-
 arch/mips/mm/Makefile                        |    1 +
 arch/mips/mm/c-r4k.c                         |   84 ++++++++++++++++++++++++++
 arch/mips/mm/tlb-r4k.c                       |    2 +-
 arch/mips/mm/tlbex.c                         |    1 +
 17 files changed, 156 insertions(+), 9 deletions(-)
 create mode 100644 arch/mips/include/asm/mach-loongson/spaces.h

diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index c179461..38e460b 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -1544,6 +1544,16 @@ config CPU_LOONGSON2
 	select CPU_SUPPORTS_64BIT_KERNEL
 	select CPU_SUPPORTS_HIGHMEM
 
+config CPU_LOONGSON3
+	bool "Loongson 3 CPU"
+	depends on SYS_HAS_CPU_LOONGSON3
+	select CPU_SUPPORTS_32BIT_KERNEL
+	select CPU_SUPPORTS_64BIT_KERNEL
+	select CPU_SUPPORTS_HIGHMEM
+	help
+		The Loongson 3 processor implements the MIPS III instruction set
+		with many extensions.
+
 config CPU_BMIPS
 	bool
 	select CPU_MIPS32
@@ -1562,6 +1572,9 @@ config SYS_HAS_CPU_LOONGSON2F
 	select CPU_SUPPORTS_ADDRWINCFG if 64BIT
 	select CPU_SUPPORTS_UNCACHED_ACCELERATED
 
+config SYS_HAS_CPU_LOONGSON3
+	bool
+
 config SYS_HAS_CPU_MIPS32_R1
 	bool
 
diff --git a/arch/mips/include/asm/addrspace.h b/arch/mips/include/asm/addrspace.h
index 569f80a..cf62bfb 100644
--- a/arch/mips/include/asm/addrspace.h
+++ b/arch/mips/include/asm/addrspace.h
@@ -116,7 +116,13 @@
 #define K_CALG_UNCACHED		2
 #define K_CALG_NONCOHERENT	3
 #define K_CALG_COH_EXCL		4
+
+#ifdef CONFIG_CPU_LOONGSON3
+#define K_CALG_COH_SHAREABLE	3
+#else
 #define K_CALG_COH_SHAREABLE	5
+#endif
+
 #define K_CALG_NOTUSED		6
 #define K_CALG_UNCACHED_ACCEL	7
 
diff --git a/arch/mips/include/asm/cpu.h b/arch/mips/include/asm/cpu.h
index 95e40c1..3fa996a 100644
--- a/arch/mips/include/asm/cpu.h
+++ b/arch/mips/include/asm/cpu.h
@@ -72,6 +72,7 @@
 #define PRID_IMP_R5432		0x5400
 #define PRID_IMP_R5500		0x5500
 #define PRID_IMP_LOONGSON2	0x6300
+#define PRID_IMP_LOONGSON3	0x6300
 
 #define PRID_IMP_UNKNOWN	0xff00
 
@@ -199,6 +200,7 @@
 #define PRID_REV_34K_V1_0_2	0x0022
 #define PRID_REV_LOONGSON2E	0x0002
 #define PRID_REV_LOONGSON2F	0x0003
+#define PRID_REV_LOONGSON3A	0x0005
 
 /*
  * Older processors used to encode processor version and revision in two
@@ -267,8 +269,8 @@ enum cpu_type_enum {
 	 * MIPS64 class processors
 	 */
 	CPU_5KC, CPU_5KE, CPU_20KC, CPU_25KF, CPU_SB1, CPU_SB1A, CPU_LOONGSON2,
-	CPU_CAVIUM_OCTEON, CPU_CAVIUM_OCTEON_PLUS, CPU_CAVIUM_OCTEON2,
-	CPU_XLR, CPU_XLP,
+	CPU_LOONGSON3, CPU_CAVIUM_OCTEON, CPU_CAVIUM_OCTEON_PLUS,
+	CPU_CAVIUM_OCTEON2, CPU_XLR, CPU_XLP,
 
 	CPU_LAST
 };
diff --git a/arch/mips/include/asm/mach-loongson/spaces.h b/arch/mips/include/asm/mach-loongson/spaces.h
new file mode 100644
index 0000000..1e82804
--- /dev/null
+++ b/arch/mips/include/asm/mach-loongson/spaces.h
@@ -0,0 +1,15 @@
+#ifndef __ASM_MACH_LOONGSON_SPACES_H_
+#define __ASM_MACH_LOONGSON_SPACES_H_
+
+#ifndef CAC_BASE
+#if defined(CONFIG_64BIT)
+#if defined(CONFIG_DMA_NONCOHERENT) || defined(CONFIG_CPU_LOONGSON3)
+#define CAC_BASE        _AC(0x9800000000000000, UL)
+#else
+#define CAC_BASE        _AC(0xa800000000000000, UL)
+#endif /* CONFIG_DMA_NONCOHERENT || CONFIG_CPU_LOONGSON3 */
+#endif /* CONFIG_64BIT */
+#endif /* CONFIG_CAC_BASE */
+
+#include <asm/mach-generic/spaces.h>
+#endif
diff --git a/arch/mips/include/asm/module.h b/arch/mips/include/asm/module.h
index 5300080..375964a 100644
--- a/arch/mips/include/asm/module.h
+++ b/arch/mips/include/asm/module.h
@@ -119,6 +119,8 @@ search_module_dbetables(unsigned long addr)
 #define MODULE_PROC_FAMILY "SB1 "
 #elif defined CONFIG_CPU_LOONGSON2
 #define MODULE_PROC_FAMILY "LOONGSON2 "
+#elif defined CONFIG_CPU_LOONGSON3
+#define MODULE_PROC_FAMILY "LOONGSON3 "
 #elif defined CONFIG_CPU_CAVIUM_OCTEON
 #define MODULE_PROC_FAMILY "OCTEON "
 #elif defined CONFIG_CPU_XLR
diff --git a/arch/mips/include/asm/pgtable-bits.h b/arch/mips/include/asm/pgtable-bits.h
index e9fe7e9..1afd39a 100644
--- a/arch/mips/include/asm/pgtable-bits.h
+++ b/arch/mips/include/asm/pgtable-bits.h
@@ -206,6 +206,13 @@ static inline uint64_t pte_to_entrylo(unsigned long pte_val)
 #define _CACHE_UNCACHED		    _CACHE_UC_B
 #define _CACHE_CACHABLE_NONCOHERENT _CACHE_WB
 
+#elif defined(CONFIG_CPU_LOONGSON3)
+
+#define _CACHE_UNCACHED             (2<<_CACHE_SHIFT)  /* LOONGSON       */
+#define _CACHE_CACHABLE_NONCOHERENT (3<<_CACHE_SHIFT)  /* LOONGSON       */
+#define _CACHE_CACHABLE_COHERENT    (3<<_CACHE_SHIFT)  /* LOONGSON-3     */
+#define _CACHE_UNCACHED_ACCELERATED (7<<_CACHE_SHIFT)  /* LOONGSON       */
+
 #else
 
 #define _CACHE_CACHABLE_NO_WA	    (0<<_CACHE_SHIFT)  /* R4600 only      */
diff --git a/arch/mips/kernel/Makefile b/arch/mips/kernel/Makefile
index fdaf65e..a0fc07f 100644
--- a/arch/mips/kernel/Makefile
+++ b/arch/mips/kernel/Makefile
@@ -35,6 +35,7 @@ obj-$(CONFIG_MODULES)		+= mips_ksyms.o module.o
 obj-$(CONFIG_FUNCTION_TRACER)	+= mcount.o ftrace.o
 
 obj-$(CONFIG_CPU_LOONGSON2)	+= r4k_fpu.o r4k_switch.o
+obj-$(CONFIG_CPU_LOONGSON3)	+= 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_R3000)		+= r2300_fpu.o r2300_switch.o
diff --git a/arch/mips/kernel/cpu-probe.c b/arch/mips/kernel/cpu-probe.c
index 27404ad..3283224 100644
--- a/arch/mips/kernel/cpu-probe.c
+++ b/arch/mips/kernel/cpu-probe.c
@@ -619,16 +619,22 @@ static inline void cpu_probe_legacy(struct cpuinfo_mips *c, unsigned int cpu)
 		c->tlbsize = 64;
 		break;
 	case PRID_IMP_LOONGSON2:
-		c->cputype = CPU_LOONGSON2;
-		__cpu_name[cpu] = "ICT Loongson-2";
-
 		switch (c->processor_id & PRID_REV_MASK) {
 		case PRID_REV_LOONGSON2E:
+			c->cputype = CPU_LOONGSON2;
+			__cpu_name[cpu] = "ICT Loongson-2";
 			set_elf_platform(cpu, "loongson2e");
 			break;
 		case PRID_REV_LOONGSON2F:
+			c->cputype = CPU_LOONGSON2;
+			__cpu_name[cpu] = "ICT Loongson-2";
 			set_elf_platform(cpu, "loongson2f");
 			break;
+		case PRID_REV_LOONGSON3A:
+			c->cputype = CPU_LOONGSON3;
+			__cpu_name[cpu] = "ICT Loongson-3";
+			set_elf_platform(cpu, "loongson3a");
+			break;
 		}
 
 		c->isa_level = MIPS_CPU_ISA_III;
diff --git a/arch/mips/lib/Makefile b/arch/mips/lib/Makefile
index 2a7c74f..59bed91 100644
--- a/arch/mips/lib/Makefile
+++ b/arch/mips/lib/Makefile
@@ -9,6 +9,7 @@ obj-y			+= iomap.o
 obj-$(CONFIG_PCI)	+= iomap-pci.o
 
 obj-$(CONFIG_CPU_LOONGSON2)	+= dump_tlb.o
+obj-$(CONFIG_CPU_LOONGSON3)	+= dump_tlb.o
 obj-$(CONFIG_CPU_MIPS32)	+= dump_tlb.o
 obj-$(CONFIG_CPU_MIPS64)	+= dump_tlb.o
 obj-$(CONFIG_CPU_NEVADA)	+= dump_tlb.o
diff --git a/arch/mips/loongson/Kconfig b/arch/mips/loongson/Kconfig
index aca93ee..d46a923 100644
--- a/arch/mips/loongson/Kconfig
+++ b/arch/mips/loongson/Kconfig
@@ -89,4 +89,8 @@ config LOONGSON_MC146818
 	bool
 	default n
 
+config ARCH_SPARSEMEM_ENABLE
+	bool
+	select SPARSEMEM_STATIC
+
 endif # MACH_LOONGSON
diff --git a/arch/mips/loongson/Platform b/arch/mips/loongson/Platform
index 29692e5..6205372 100644
--- a/arch/mips/loongson/Platform
+++ b/arch/mips/loongson/Platform
@@ -30,3 +30,4 @@ platform-$(CONFIG_MACH_LOONGSON) += loongson/
 cflags-$(CONFIG_MACH_LOONGSON) += -I$(srctree)/arch/mips/include/asm/mach-loongson -mno-branch-likely
 load-$(CONFIG_LEMOTE_FULOONG2E) += 0xffffffff80100000
 load-$(CONFIG_LEMOTE_MACH2F) += 0xffffffff80200000
+load-$(CONFIG_CPU_LOONGSON3) += 0xffffffff80200000
diff --git a/arch/mips/loongson/common/env.c b/arch/mips/loongson/common/env.c
index d93830a..efae736 100644
--- a/arch/mips/loongson/common/env.c
+++ b/arch/mips/loongson/common/env.c
@@ -68,6 +68,9 @@ void __init prom_init_env(void)
 		case PRID_REV_LOONGSON2F:
 			cpu_clock_freq = 797000000;
 			break;
+		case PRID_REV_LOONGSON3A:
+			cpu_clock_freq = 900000000;
+			break;
 		default:
 			cpu_clock_freq = 100000000;
 			break;
diff --git a/arch/mips/loongson/common/setup.c b/arch/mips/loongson/common/setup.c
index 27d826b..ebb17ef 100644
--- a/arch/mips/loongson/common/setup.c
+++ b/arch/mips/loongson/common/setup.c
@@ -18,9 +18,6 @@
 #include <linux/screen_info.h>
 #endif
 
-void (*__wbflush)(void);
-EXPORT_SYMBOL(__wbflush);
-
 static void wbflush_loongson(void)
 {
 	asm(".set\tpush\n\t"
@@ -32,6 +29,9 @@ static void wbflush_loongson(void)
 	    ".set mips0\n\t");
 }
 
+void (*__wbflush)(void) = wbflush_loongson;
+EXPORT_SYMBOL(__wbflush);
+
 void __init plat_mem_setup(void)
 {
 	__wbflush = wbflush_loongson;
diff --git a/arch/mips/mm/Makefile b/arch/mips/mm/Makefile
index fd6203f..a79b6d1 100644
--- a/arch/mips/mm/Makefile
+++ b/arch/mips/mm/Makefile
@@ -12,6 +12,7 @@ obj-$(CONFIG_HIGHMEM)		+= highmem.o
 obj-$(CONFIG_HUGETLB_PAGE)	+= hugetlbpage.o
 
 obj-$(CONFIG_CPU_LOONGSON2)	+= c-r4k.o cex-gen.o tlb-r4k.o
+obj-$(CONFIG_CPU_LOONGSON3)	+= c-r4k.o cex-gen.o tlb-r4k.o
 obj-$(CONFIG_CPU_MIPS32)	+= c-r4k.o cex-gen.o tlb-r4k.o
 obj-$(CONFIG_CPU_MIPS64)	+= c-r4k.o cex-gen.o tlb-r4k.o
 obj-$(CONFIG_CPU_NEVADA)	+= c-r4k.o cex-gen.o tlb-r4k.o
diff --git a/arch/mips/mm/c-r4k.c b/arch/mips/mm/c-r4k.c
index ce0dbee..a1a3482 100644
--- a/arch/mips/mm/c-r4k.c
+++ b/arch/mips/mm/c-r4k.c
@@ -362,6 +362,9 @@ static inline void local_r4k___flush_cache_all(void * args)
 
 static void r4k___flush_cache_all(void)
 {
+#if defined(CONFIG_CPU_LOONGSON3)
+	return;
+#endif
 	r4k_on_each_cpu(local_r4k___flush_cache_all, NULL);
 }
 
@@ -382,11 +385,17 @@ static inline int has_valid_asid(const struct mm_struct *mm)
 
 static void r4k__flush_cache_vmap(void)
 {
+#if defined(CONFIG_CPU_LOONGSON3)
+	return;
+#endif
 	r4k_blast_dcache();
 }
 
 static void r4k__flush_cache_vunmap(void)
 {
+#if defined(CONFIG_CPU_LOONGSON3)
+	return;
+#endif
 	r4k_blast_dcache();
 }
 
@@ -408,6 +417,9 @@ static void r4k_flush_cache_range(struct vm_area_struct *vma,
 {
 	int exec = vma->vm_flags & VM_EXEC;
 
+#if defined(CONFIG_CPU_LOONGSON3)
+	return;
+#endif
 	if (cpu_has_dc_aliases || (exec && !cpu_has_ic_fills_f_dc))
 		r4k_on_each_cpu(local_r4k_flush_cache_range, vma);
 }
@@ -438,6 +450,9 @@ static inline void local_r4k_flush_cache_mm(void * args)
 
 static void r4k_flush_cache_mm(struct mm_struct *mm)
 {
+#if defined(CONFIG_CPU_LOONGSON3)
+	return;
+#endif
 	if (!cpu_has_dc_aliases)
 		return;
 
@@ -528,6 +543,9 @@ static void r4k_flush_cache_page(struct vm_area_struct *vma,
 	unsigned long addr, unsigned long pfn)
 {
 	struct flush_cache_page_args args;
+#if defined(CONFIG_CPU_LOONGSON3)
+	return;
+#endif
 
 	args.vma = vma;
 	args.addr = addr;
@@ -543,6 +561,9 @@ static inline void local_r4k_flush_data_cache_page(void * addr)
 
 static void r4k_flush_data_cache_page(unsigned long addr)
 {
+#if defined(CONFIG_CPU_LOONGSON3)
+	return;
+#endif
 	if (in_atomic())
 		local_r4k_flush_data_cache_page((void *)addr);
 	else
@@ -701,6 +722,9 @@ static void local_r4k_flush_cache_sigtramp(void * arg)
 
 static void r4k_flush_cache_sigtramp(unsigned long addr)
 {
+#if defined(CONFIG_CPU_LOONGSON3)
+	return;
+#endif
 	r4k_on_each_cpu(local_r4k_flush_cache_sigtramp, (void *) addr);
 }
 
@@ -952,6 +976,31 @@ static void __cpuinit probe_pcache(void)
 		c->dcache.waybit = 0;
 		break;
 
+	case CPU_LOONGSON3:
+		config1 = read_c0_config1();
+		if ((lsize = ((config1 >> 19) & 7)))
+			c->icache.linesz = 2 << lsize;
+		else
+			c->icache.linesz = lsize;
+		c->icache.sets = 64 << ((config1 >> 22) & 7);
+		c->icache.ways = 1 + ((config1 >> 16) & 7);
+		icache_size = c->icache.sets *
+					  c->icache.ways *
+					  c->icache.linesz;
+		c->icache.waybit = 0;
+
+		if ((lsize = ((config1 >> 10) & 7)))
+			c->dcache.linesz = 2 << lsize;
+		else
+			c->dcache.linesz = lsize;
+		c->dcache.sets = 64 << ((config1 >> 13) & 7);
+		c->dcache.ways = 1 + ((config1 >> 7) & 7);
+		dcache_size = c->dcache.sets *
+					  c->dcache.ways *
+					  c->dcache.linesz;
+		c->dcache.waybit = 0;
+		break;
+
 	default:
 		if (!(config & MIPS_CONF_M))
 			panic("Don't know how to probe P-caches on this cpu.");
@@ -1170,6 +1219,34 @@ static void __init loongson2_sc_init(void)
 }
 #endif
 
+#if defined(CONFIG_CPU_LOONGSON3)
+static void __init loongson3_sc_init(void)
+{
+	struct cpuinfo_mips *c = &current_cpu_data;
+	unsigned int config2, lsize;
+
+	config2 = read_c0_config2();
+	if ((lsize = ((config2 >> 4) & 15)))
+		c->scache.linesz = 2 << lsize;
+	else
+		c->scache.linesz = lsize;
+	c->scache.sets = 64 << ((config2 >> 8) & 15);
+	c->scache.ways = 1 + (config2 & 15);
+
+	scache_size = c->scache.sets *
+				  c->scache.ways *
+				  c->scache.linesz;
+	/* Loongson-3 has 4 cores, 1MB scache for each. scaches are shared */
+	scache_size *= 4;
+	c->scache.waybit = 0;
+	pr_info("Unified secondary cache %ldkB %s, linesize %d bytes.\n",
+	       scache_size >> 10, way_string[c->scache.ways], c->scache.linesz);
+	if (scache_size)
+		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);
@@ -1224,6 +1301,13 @@ static void __cpuinit setup_scache(void)
 		loongson2_sc_init();
 		return;
 #endif
+
+#if defined(CONFIG_CPU_LOONGSON3)
+	case CPU_LOONGSON3:
+		loongson3_sc_init();
+		return;
+#endif
+
 	case CPU_XLP:
 		/* don't need to worry about L2, fully coherent */
 		return;
diff --git a/arch/mips/mm/tlb-r4k.c b/arch/mips/mm/tlb-r4k.c
index d2572cb..11b9c88 100644
--- a/arch/mips/mm/tlb-r4k.c
+++ b/arch/mips/mm/tlb-r4k.c
@@ -50,7 +50,7 @@ extern void build_tlb_refill_handler(void);
 
 #endif /* CONFIG_MIPS_MT_SMTC */
 
-#if defined(CONFIG_CPU_LOONGSON2)
+#if defined(CONFIG_CPU_LOONGSON2) || defined(CONFIG_CPU_LOONGSON3)
 /*
  * LOONGSON2 has a 4 entry itlb which is a subset of dtlb,
  * unfortrunately, itlb is not totally transparent to software.
diff --git a/arch/mips/mm/tlbex.c b/arch/mips/mm/tlbex.c
index 03eb0ef..4420250 100644
--- a/arch/mips/mm/tlbex.c
+++ b/arch/mips/mm/tlbex.c
@@ -507,6 +507,7 @@ static void __cpuinit build_tlb_write_entry(u32 **p, struct uasm_label **l,
 	case CPU_BMIPS4380:
 	case CPU_BMIPS5000:
 	case CPU_LOONGSON2:
+	case CPU_LOONGSON3:
 	case CPU_R5500:
 		if (m4kc_tlbp_war())
 			uasm_i_nop(p);
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 02/14] MIPS: Loongson 3: Add Lemote-3A machtypes definition.
  2012-06-15  8:09 [PATCH 00/14] MIPS: Add Loongson-3 based machines support Huacai Chen
  2012-06-15  8:09 ` [PATCH 01/14] MIPS: Loongson: Add basic Loongson 3 CPU support Huacai Chen
@ 2012-06-15  8:09 ` Huacai Chen
  2012-06-15  8:09 ` [PATCH 03/14] MIPS: Loongson: Make Loongson 3 to use BCD format for RTC Huacai Chen
                   ` (12 subsequent siblings)
  14 siblings, 0 replies; 34+ messages in thread
From: Huacai Chen @ 2012-06-15  8:09 UTC (permalink / raw)
  To: Ralf Baechle
  Cc: linux-mips, Fuxin Zhang, Zhangjin Wu, Huacai Chen, Hongliang Tao,
	Hua Yan

Add three Loongson 3 based machine types:
MACH_LEMOTE_A1004 is laptop;
MACH_LEMOTE_A1101 is mini-itx;
MACH_LEMOTE_A1205 is all-in-one machine.

The most significant differrent between A1004 and A1101/A1205 is
the laptop has EC but others don't.

Signed-off-by: Huacai Chen <chenhc@lemote.com>
Signed-off-by: Hongliang Tao <taohl@lemote.com>
Signed-off-by: Hua Yan <yanh@lemote.com>
---
 arch/mips/include/asm/bootinfo.h              |   23 +++++++++++++--------
 arch/mips/include/asm/mach-loongson/machine.h |    6 +++++
 arch/mips/loongson/Kconfig                    |   26 +++++++++++++++++++++++++
 arch/mips/loongson/common/machtype.c          |    5 +++-
 4 files changed, 50 insertions(+), 10 deletions(-)

diff --git a/arch/mips/include/asm/bootinfo.h b/arch/mips/include/asm/bootinfo.h
index 7a51d87..d5da63e 100644
--- a/arch/mips/include/asm/bootinfo.h
+++ b/arch/mips/include/asm/bootinfo.h
@@ -61,15 +61,20 @@
 /*
  * Valid machtype for Loongson family
  */
-#define MACH_LOONGSON_UNKNOWN  0
-#define MACH_LEMOTE_FL2E       1
-#define MACH_LEMOTE_FL2F       2
-#define MACH_LEMOTE_ML2F7      3
-#define MACH_LEMOTE_YL2F89     4
-#define MACH_DEXXON_GDIUM2F10  5
-#define MACH_LEMOTE_NAS        6
-#define MACH_LEMOTE_LL2F       7
-#define MACH_LOONGSON_END      8
+enum loongson_machine_type {
+	MACH_LOONGSON_UNKNOWN,
+	MACH_LEMOTE_FL2E,
+	MACH_LEMOTE_FL2F,
+	MACH_LEMOTE_ML2F7,
+	MACH_LEMOTE_YL2F89,
+	MACH_DEXXON_GDIUM2F10,
+	MACH_LEMOTE_NAS,
+	MACH_LEMOTE_LL2F,
+	MACH_LEMOTE_A1004,
+	MACH_LEMOTE_A1101,
+	MACH_LEMOTE_A1205,
+	MACH_LOONGSON_END
+};
 
 /*
  * Valid machtype for group INGENIC
diff --git a/arch/mips/include/asm/mach-loongson/machine.h b/arch/mips/include/asm/mach-loongson/machine.h
index 4321338..481c5d9 100644
--- a/arch/mips/include/asm/mach-loongson/machine.h
+++ b/arch/mips/include/asm/mach-loongson/machine.h
@@ -24,4 +24,10 @@
 
 #endif
 
+#ifdef CONFIG_LEMOTE_MACH3A
+
+#define LOONGSON_MACHTYPE MACH_LEMOTE_A1004
+
+#endif /* CONFIG_LEMOTE_MACH3A */
+
 #endif /* __ASM_MACH_LOONGSON_MACHINE_H */
diff --git a/arch/mips/loongson/Kconfig b/arch/mips/loongson/Kconfig
index d46a923..6c56c97 100644
--- a/arch/mips/loongson/Kconfig
+++ b/arch/mips/loongson/Kconfig
@@ -58,6 +58,32 @@ config LEMOTE_MACH2F
 
 	  These family machines include fuloong2f mini PC, yeeloong2f notebook,
 	  LingLoong allinone PC and so forth.
+
+config LEMOTE_MACH3A
+	bool "Lemote Loongson 3A family machines"
+	select ARCH_SPARSEMEM_ENABLE
+	select GENERIC_ISA_DMA_SUPPORT_BROKEN
+	select GENERIC_HARDIRQS_NO__DO_IRQ
+	select BOOT_ELF32
+	select BOARD_SCACHE
+	select CSRC_R4K
+	select CEVT_R4K
+	select CPU_HAS_WB
+	select HW_HAS_PCI
+	select ISA
+	select I8259
+	select IRQ_CPU
+	select SYS_HAS_CPU_LOONGSON3
+	select SYS_HAS_EARLY_PRINTK
+	select SYS_SUPPORTS_SMP
+	select SYS_SUPPORTS_32BIT_KERNEL
+	select SYS_SUPPORTS_64BIT_KERNEL
+	select SYS_SUPPORTS_HIGHMEM
+	select SYS_SUPPORTS_LITTLE_ENDIAN
+	select LOONGSON_MC146818
+	help
+		Lemote Loongson 3A family machines utilize the 3A revision of
+		Loongson processor and RS780/SBX00 chipset.
 endchoice
 
 config CS5536
diff --git a/arch/mips/loongson/common/machtype.c b/arch/mips/loongson/common/machtype.c
index 2efd5d9..e377b44 100644
--- a/arch/mips/loongson/common/machtype.c
+++ b/arch/mips/loongson/common/machtype.c
@@ -25,8 +25,11 @@ static const char *system_types[] = {
 	[MACH_LEMOTE_ML2F7]             "lemote-mengloong-2f-7inches",
 	[MACH_LEMOTE_YL2F89]            "lemote-yeeloong-2f-8.9inches",
 	[MACH_DEXXON_GDIUM2F10]         "dexxon-gdium-2f",
-	[MACH_LEMOTE_NAS]		"lemote-nas-2f",
+	[MACH_LEMOTE_NAS]               "lemote-nas-2f",
 	[MACH_LEMOTE_LL2F]              "lemote-lynloong-2f",
+	[MACH_LEMOTE_A1004]             "lemote-3a-notebook-a1004",
+	[MACH_LEMOTE_A1101]             "lemote-3a-itx-a1101",
+	[MACH_LEMOTE_A1205]             "lemote-2gq-aio-a1205",
 	[MACH_LOONGSON_END]             NULL,
 };
 
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 03/14] MIPS: Loongson: Make Loongson 3 to use BCD format for RTC.
  2012-06-15  8:09 [PATCH 00/14] MIPS: Add Loongson-3 based machines support Huacai Chen
  2012-06-15  8:09 ` [PATCH 01/14] MIPS: Loongson: Add basic Loongson 3 CPU support Huacai Chen
  2012-06-15  8:09 ` [PATCH 02/14] MIPS: Loongson 3: Add Lemote-3A machtypes definition Huacai Chen
@ 2012-06-15  8:09 ` Huacai Chen
  2012-06-15  8:09 ` [PATCH 04/14] MIPS: Loongson: Add UEFI-like firmware interface support Huacai Chen
                   ` (11 subsequent siblings)
  14 siblings, 0 replies; 34+ messages in thread
From: Huacai Chen @ 2012-06-15  8:09 UTC (permalink / raw)
  To: Ralf Baechle
  Cc: linux-mips, Fuxin Zhang, Zhangjin Wu, Huacai Chen, Hongliang Tao,
	Hua Yan

Signed-off-by: Huacai Chen <chenhc@lemote.com>
Signed-off-by: Hongliang Tao <taohl@lemote.com>
Signed-off-by: Hua Yan <yanh@lemote.com>
---
 arch/mips/include/asm/mach-loongson/mc146818rtc.h |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/arch/mips/include/asm/mach-loongson/mc146818rtc.h b/arch/mips/include/asm/mach-loongson/mc146818rtc.h
index ed7fe97..6b10159 100644
--- a/arch/mips/include/asm/mach-loongson/mc146818rtc.h
+++ b/arch/mips/include/asm/mach-loongson/mc146818rtc.h
@@ -27,7 +27,11 @@ static inline void CMOS_WRITE(unsigned char data, unsigned long addr)
 	outb_p(data, RTC_PORT(1));
 }
 
+#ifdef CONFIG_CPU_LOONGSON3
+#define RTC_ALWAYS_BCD	1
+#else
 #define RTC_ALWAYS_BCD	0
+#endif
 
 #ifndef mc146818_decode_year
 #define mc146818_decode_year(year) ((year) < 70 ? (year) + 2000 : (year) + 1970)
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 04/14] MIPS: Loongson: Add UEFI-like firmware interface support.
  2012-06-15  8:09 [PATCH 00/14] MIPS: Add Loongson-3 based machines support Huacai Chen
                   ` (2 preceding siblings ...)
  2012-06-15  8:09 ` [PATCH 03/14] MIPS: Loongson: Make Loongson 3 to use BCD format for RTC Huacai Chen
@ 2012-06-15  8:09 ` Huacai Chen
  2012-06-15  8:09 ` [PATCH 05/14] MIPS: Loongson 3: Add HT-linked PCI support Huacai Chen
                   ` (10 subsequent siblings)
  14 siblings, 0 replies; 34+ messages in thread
From: Huacai Chen @ 2012-06-15  8:09 UTC (permalink / raw)
  To: Ralf Baechle
  Cc: linux-mips, Fuxin Zhang, Zhangjin Wu, Huacai Chen, Hongliang Tao,
	Hua Yan

The new UEFI-like firmware interface has 3 advantages:

1, Firmware export a physical memory map which is similar to X86's
   E820 map, so prom_init_memory() will be more elegant that #ifdef
   clauses can be removed.
2, Firmware export a pci irq routing table, we no longer need pci
   irq routing fixup in kernel's code.
3, Firmware has a built-in vga bios, and its address is exported,
   the linux kernel no longer need an embedded blob.

With the new interface, Loongson-3A/2G and all their successors can use
a unified kernel. All Loongson-based machines support this new interface
except 2E/2F series.

Signed-off-by: Huacai Chen <chenhc@lemote.com>
Signed-off-by: Hongliang Tao <taohl@lemote.com>
Signed-off-by: Hua Yan <yanh@lemote.com>
---
 arch/mips/include/asm/mach-loongson/boot_param.h |  150 ++++++++++++++++++++++
 arch/mips/include/asm/mach-loongson/loongson.h   |    4 +-
 arch/mips/loongson/Kconfig                       |    4 +
 arch/mips/loongson/common/env.c                  |   64 ++++++++--
 arch/mips/loongson/common/init.c                 |    9 +-
 arch/mips/loongson/common/mem.c                  |   42 ++++++
 arch/mips/loongson/common/pci.c                  |    6 +-
 arch/mips/loongson/common/reset.c                |   14 ++
 8 files changed, 273 insertions(+), 20 deletions(-)
 create mode 100644 arch/mips/include/asm/mach-loongson/boot_param.h

diff --git a/arch/mips/include/asm/mach-loongson/boot_param.h b/arch/mips/include/asm/mach-loongson/boot_param.h
new file mode 100644
index 0000000..b20c4e2
--- /dev/null
+++ b/arch/mips/include/asm/mach-loongson/boot_param.h
@@ -0,0 +1,150 @@
+#ifndef __ASM_MACH_LOONGSON_BOOT_PARAM_H_
+#define __ASM_MACH_LOONGSON_BOOT_PARAM_H_
+
+#define SYSTEM_RAM_LOW		1
+#define SYSTEM_RAM_HIGH		2
+#define MEM_RESERVED		3
+#define PCI_IO			4
+#define PCI_MEM			5
+#define LOONGSON_CFG_REG	6
+#define VIDEO_ROM		7
+#define ADAPTER_ROM		8
+#define ACPI_TABLE		9
+#define MAX_MEMORY_TYPE		10
+
+#define LOONGSON3_BOOT_MEM_MAP_MAX 128
+struct efi_memory_map_loongson{
+	u16 vers;	/* version of efi_memory_map */
+	u32 nr_map;	/* number of memory_maps */
+	u32 mem_freq;	/* memory frequence */
+	struct mem_map{
+		u32 node_id;	/* node_id which memory attached to */
+		u32 mem_type;	/* system memory, pci memory, pci io, etc. */
+		u64 mem_start;	/* memory map start address */
+		u32 mem_size;	/* each memory_map size, not the total size */
+	}map[LOONGSON3_BOOT_MEM_MAP_MAX];
+}__attribute__((packed));
+
+enum loongson_cpu_type
+{
+	Loongson_2E,
+	Loongson_2F,
+	Loongson_3A,
+	Loongson_3B,
+	Loongson_1A,
+	Loongson_1B
+};
+
+/*
+ * Capability and feature descriptor structure for MIPS CPU
+ */
+struct efi_cpuinfo_loongson {
+	u16 vers;   /* version of efi_cpuinfo_loongson */
+	u32 processor_id; /* PRID, e.g. 6305, 6306 */
+	enum loongson_cpu_type cputype; /* 3A, 3B, etc. */
+	u32 total_node;   /* num of total numa nodes */
+	u32 cpu_startup_core_id; /* Core id: */
+	u32 cpu_clock_freq; /* cpu_clock */
+	u32 nr_cpus;
+}__attribute__((packed));
+
+struct system_loongson{
+	u16 vers;   /* version of system_loongson */
+	u32 ccnuma_smp; /* 0:no numa; 1: has numa */
+	u32 sing_double_channel; /* 1:single; 2:double */
+}__attribute__((packed));
+
+struct irq_source_routing_table {
+	u16 vers;
+	u16 size;
+	u16 rtr_bus;
+	u16 rtr_devfn;
+	u32 vendor;
+	u32 device;
+	u32 PIC_type;   /* conform use HT or PCI to route to CPU-PIC */
+	u64 ht_int_bit; /* 3A: 1<<24; 3B:1<<16 */
+	u64 ht_enable;  /* irqs used in this PIC.eg:3a-0x0000d17a */
+	u32 node_id;    /* node id, 0x0—0, 0x1—1; 0x10—2;0x11—3;0x100—4 */
+	u64 pci_mem_start_addr;
+	u64 pci_mem_end_addr;
+	u64 pci_io_start_addr;
+	u64 pci_io_end_addr;
+	u64 pci_config_addr;
+}__attribute__((packed));
+
+struct interface_info{
+	u16 vers; /* version of the specificition */
+	u16 size;
+	u8  flag;
+	char description[64];
+}__attribute__((packed));
+
+#define MAX_RESOURCE_NUMBER 128
+struct resource_loongson {
+	u64 start; /* resource start address */
+	u64 end;   /* resource end address */
+	char name[64];
+	u32 flags;
+};
+
+struct archdev_data {};  /* arch specific additions */
+
+struct board_devices{
+	char name[64];   /* hold the device name */
+	u32 num_resources; /* number of device_resource */
+	struct resource_loongson resource[MAX_RESOURCE_NUMBER]; /* for each device`s resource */
+	/* arch specific additions */
+	struct archdev_data archdata;
+};
+
+struct loongson_special_attribute{
+	u16 vers;    /* version of this special */
+	char special_name[64]; /* special_atribute_name */
+	u32 loongson_special_type; /* type of special device */
+	struct resource_loongson resource[MAX_RESOURCE_NUMBER]; /* for each device`s resource */
+};
+
+struct loongson_params{
+	u64 memory_offset;	/* efi_memory_map_loongson struct offset */
+	u64 cpu_offset;		/* efi_cpuinfo_loongson struct offset */
+	u64 system_offset;  	/* system_loongson struct offset */
+	u64 irq_offset;  	/* irq_source_routing_table struct offset */
+	u64 interface_offset;  	/* interface_info struct offset */
+	u64 special_offset;  	/* loongson_special_attribute struct offset */
+	u64 boarddev_table_offset;  /* board_devices offset */
+};
+
+struct smbios_tables {
+	u16 vers;     /* version of smbios */
+	u64 vga_bios; /* vga_bios address */
+	struct loongson_params lp;
+};
+
+struct efi_reset_system_t{
+	u64 ResetCold;
+	u64 ResetWarm;
+	u64 ResetType;
+	u64 Shutdown;
+};
+
+struct efi_loongson {
+	u64 mps;	/* MPS table */
+	u64 acpi;	/* ACPI table (IA64 ext 0.71) */
+	u64 acpi20;	/* ACPI table (ACPI 2.0) */
+	struct smbios_tables smbios;	/* SM BIOS table */
+	u64 sal_systab;	/* SAL system table */
+	u64 boot_info;	/* boot info table */
+};
+
+struct boot_params{
+	struct efi_loongson efi;
+	struct efi_reset_system_t reset_system;
+};
+
+extern u32 nr_cpus_loongson;
+extern enum loongson_cpu_type cputype;
+extern struct efi_memory_map_loongson *emap;
+extern u64 ht_control_base;
+extern u64 pci_mem_start_addr,pci_mem_end_addr;
+extern u64 loongson_pciio_base;
+#endif
diff --git a/arch/mips/include/asm/mach-loongson/loongson.h b/arch/mips/include/asm/mach-loongson/loongson.h
index 1e29b9d..7efb911 100644
--- a/arch/mips/include/asm/mach-loongson/loongson.h
+++ b/arch/mips/include/asm/mach-loongson/loongson.h
@@ -23,8 +23,8 @@ extern void mach_prepare_reboot(void);
 extern void mach_prepare_shutdown(void);
 
 /* environment arguments from bootloader */
-extern unsigned long cpu_clock_freq;
-extern unsigned long memsize, highmemsize;
+extern u32 cpu_clock_freq;
+extern u32 memsize, highmemsize;
 
 /* loongson-specific command line, env and memory initialization */
 extern void __init prom_init_memory(void);
diff --git a/arch/mips/loongson/Kconfig b/arch/mips/loongson/Kconfig
index 6c56c97..9a31418 100644
--- a/arch/mips/loongson/Kconfig
+++ b/arch/mips/loongson/Kconfig
@@ -81,6 +81,7 @@ config LEMOTE_MACH3A
 	select SYS_SUPPORTS_HIGHMEM
 	select SYS_SUPPORTS_LITTLE_ENDIAN
 	select LOONGSON_MC146818
+	select UEFI_FIRMWARE_INTERFACE
 	help
 		Lemote Loongson 3A family machines utilize the 3A revision of
 		Loongson processor and RS780/SBX00 chipset.
@@ -119,4 +120,7 @@ config ARCH_SPARSEMEM_ENABLE
 	bool
 	select SPARSEMEM_STATIC
 
+config UEFI_FIRMWARE_INTERFACE
+	bool
+
 endif # MACH_LOONGSON
diff --git a/arch/mips/loongson/common/env.c b/arch/mips/loongson/common/env.c
index efae736..d2d8613 100644
--- a/arch/mips/loongson/common/env.c
+++ b/arch/mips/loongson/common/env.c
@@ -18,37 +18,53 @@
  * option) any later version.
  */
 #include <linux/module.h>
-
 #include <asm/bootinfo.h>
-
 #include <loongson.h>
+#include <boot_param.h>
+
+struct boot_params *boot_p;
+struct loongson_params *loongson_p;
+
+struct efi_cpuinfo_loongson *ecpu;
+struct efi_memory_map_loongson *emap;
+struct system_loongson *esys;
+struct irq_source_routing_table *eirq_source;
 
-unsigned long cpu_clock_freq;
+u64 ht_control_base;
+u64 pci_mem_start_addr, pci_mem_end_addr;
+u64 loongson_pciio_base;
+u64 vgabios_addr;
+u64 poweroff_addr, restart_addr;
+
+enum loongson_cpu_type cputype;
+unsigned int nr_cpus_loongson = NR_CPUS;
+
+u32 cpu_clock_freq;
 EXPORT_SYMBOL(cpu_clock_freq);
-unsigned long memsize, highmemsize;
 
 #define parse_even_earlier(res, option, p)				\
 do {									\
 	unsigned int tmp __maybe_unused;				\
 									\
 	if (strncmp(option, (char *)p, strlen(option)) == 0)		\
-		tmp = strict_strtol((char *)p + strlen(option"="), 10, &res); \
+		tmp = kstrtou32((char *)p + strlen(option"="), 10, &res); \
 } while (0)
 
 void __init prom_init_env(void)
 {
 	/* pmon passes arguments in 32bit pointers */
-	int *_prom_envp;
-	unsigned long bus_clock;
 	unsigned int processor_id;
+
+#ifndef CONFIG_UEFI_FIRMWARE_INTERFACE
+	int *_prom_envp;
 	long l;
+	extern u32 memsize, highmemsize;
 
 	/* firmware arguments are initialized in head.S */
 	_prom_envp = (int *)fw_arg2;
 
 	l = (long)*_prom_envp;
 	while (l != 0) {
-		parse_even_earlier(bus_clock, "busclock", l);
 		parse_even_earlier(cpu_clock_freq, "cpuclock", l);
 		parse_even_earlier(memsize, "memsize", l);
 		parse_even_earlier(highmemsize, "highmemsize", l);
@@ -57,8 +73,32 @@ void __init prom_init_env(void)
 	}
 	if (memsize == 0)
 		memsize = 256;
-	if (bus_clock == 0)
-		bus_clock = 66000000;
+#else
+	/* firmware arguments are initialized in head.S */
+	boot_p = (struct boot_params *)fw_arg2;
+	loongson_p = &(boot_p->efi.smbios.lp);
+
+	ecpu	= (struct efi_cpuinfo_loongson *)((u64)loongson_p + loongson_p->cpu_offset);
+	emap 	= (struct efi_memory_map_loongson *)((u64)loongson_p + loongson_p->memory_offset);
+	eirq_source = (struct irq_source_routing_table *)((u64)loongson_p + loongson_p->irq_offset);
+
+	cputype = ecpu->cputype;
+	nr_cpus_loongson = ecpu->nr_cpus;
+	cpu_clock_freq = ecpu->cpu_clock_freq;
+	if (nr_cpus_loongson > NR_CPUS || nr_cpus_loongson == 0)
+		nr_cpus_loongson = NR_CPUS;
+
+	pci_mem_start_addr = eirq_source->pci_mem_start_addr;
+	pci_mem_end_addr = eirq_source->pci_mem_end_addr;
+	loongson_pciio_base = eirq_source->pci_io_start_addr;
+
+	poweroff_addr = boot_p->reset_system.Shutdown;
+	restart_addr = boot_p->reset_system.ResetWarm;
+	pr_info("Shutdown Addr: %llx Reset Addr: %llx\n", poweroff_addr, restart_addr);
+
+	ht_control_base = 0x90000EFDFB000000; /* has no interface now */
+	vgabios_addr = boot_p->efi.smbios.vga_bios;
+#endif
 	if (cpu_clock_freq == 0) {
 		processor_id = (&current_cpu_data)->processor_id;
 		switch (processor_id & PRID_REV_MASK) {
@@ -76,7 +116,5 @@ void __init prom_init_env(void)
 			break;
 		}
 	}
-
-	pr_info("busclock=%ld, cpuclock=%ld, memsize=%ld, highmemsize=%ld\n",
-		bus_clock, cpu_clock_freq, memsize, highmemsize);
+	pr_info("CpuClock = %u\n", cpu_clock_freq);
 }
diff --git a/arch/mips/loongson/common/init.c b/arch/mips/loongson/common/init.c
index 19d3415..1c29b19 100644
--- a/arch/mips/loongson/common/init.c
+++ b/arch/mips/loongson/common/init.c
@@ -17,10 +17,6 @@ unsigned long __maybe_unused _loongson_addrwincfg_base;
 
 void __init prom_init(void)
 {
-	/* init base address of io space */
-	set_io_port_base((unsigned long)
-		ioremap(LOONGSON_PCIIO_BASE, LOONGSON_PCIIO_SIZE));
-
 #ifdef CONFIG_CPU_SUPPORTS_ADDRWINCFG
 	_loongson_addrwincfg_base = (unsigned long)
 		ioremap(LOONGSON_ADDRWINCFG_BASE, LOONGSON_ADDRWINCFG_SIZE);
@@ -28,6 +24,11 @@ void __init prom_init(void)
 
 	prom_init_cmdline();
 	prom_init_env();
+
+	/* init base address of io space */
+	set_io_port_base((unsigned long)
+		ioremap(LOONGSON_PCIIO_BASE, LOONGSON_PCIIO_SIZE));
+
 	prom_init_memory();
 
 	/*init the uart base address */
diff --git a/arch/mips/loongson/common/mem.c b/arch/mips/loongson/common/mem.c
index 30eba60..8a24b04 100644
--- a/arch/mips/loongson/common/mem.c
+++ b/arch/mips/loongson/common/mem.c
@@ -11,9 +11,14 @@
 #include <asm/bootinfo.h>
 
 #include <loongson.h>
+#include <boot_param.h>
 #include <mem.h>
 #include <pci.h>
 
+#ifndef CONFIG_UEFI_FIRMWARE_INTERFACE
+
+u32 memsize, highmemsize;
+
 void __init prom_init_memory(void)
 {
 	add_memory_region(0x0, (memsize << 20), BOOT_MEM_RAM);
@@ -49,6 +54,43 @@ void __init prom_init_memory(void)
 #endif /* !CONFIG_64BIT */
 }
 
+#else /* CONFIG_UEFI_FIRMWARE_INTERFACE */
+
+void __init prom_init_memory(void)
+{
+	int i;
+	u32 node_id;
+	u32 mem_type;
+
+	/* parse memory information */
+	for (i = 0; i < emap->nr_map; i++){
+		node_id = emap->map[i].node_id;
+		mem_type = emap->map[i].mem_type;
+
+		if (node_id == 0) {
+			switch (mem_type) {
+			case SYSTEM_RAM_LOW:
+				add_memory_region(emap->map[i].mem_start,
+					emap->map[i].mem_size << 20,
+					BOOT_MEM_RAM);
+				break;
+			case SYSTEM_RAM_HIGH:
+				add_memory_region(emap->map[i].mem_start,
+					emap->map[i].mem_size << 20,
+					BOOT_MEM_RAM);
+				break;
+			case MEM_RESERVED:
+				add_memory_region(emap->map[i].mem_start,
+					emap->map[i].mem_size << 20,
+					BOOT_MEM_RESERVED);
+				break;
+			}
+		}
+	}
+}
+
+#endif /* CONFIG_UEFI_FIRMWARE_INTERFACE */
+
 /* override of arch/mips/mm/cache.c: __uncached_access */
 int __uncached_access(struct file *file, unsigned long addr)
 {
diff --git a/arch/mips/loongson/common/pci.c b/arch/mips/loongson/common/pci.c
index 31d8c5e..0da387a 100644
--- a/arch/mips/loongson/common/pci.c
+++ b/arch/mips/loongson/common/pci.c
@@ -11,6 +11,7 @@
 
 #include <pci.h>
 #include <loongson.h>
+#include <boot_param.h>
 
 static struct resource loongson_pci_mem_resource = {
 	.name   = "pci memory space",
@@ -82,7 +83,10 @@ static int __init pcibios_init(void)
 	setup_pcimap();
 
 	loongson_pci_controller.io_map_base = mips_io_port_base;
-
+#ifdef CONFIG_UEFI_FIRMWARE_INTERFACE
+	loongson_pci_mem_resource.start = pci_mem_start_addr;
+	loongson_pci_mem_resource.end = pci_mem_end_addr;
+#endif
 	register_pci_controller(&loongson_pci_controller);
 
 	return 0;
diff --git a/arch/mips/loongson/common/reset.c b/arch/mips/loongson/common/reset.c
index 9e10d62..55c666b 100644
--- a/arch/mips/loongson/common/reset.c
+++ b/arch/mips/loongson/common/reset.c
@@ -36,17 +36,31 @@ static inline void loongson_reboot(void)
 
 static void loongson_restart(char *command)
 {
+#ifndef CONFIG_UEFI_FIRMWARE_INTERFACE
 	/* do preparation for reboot */
 	mach_prepare_reboot();
 
 	/* reboot via jumping to boot base address */
 	loongson_reboot();
+#else
+	extern u64 restart_addr;
+	void (*fw_restart)(void) = (void *)restart_addr;
+
+	fw_restart();
+#endif
 }
 
 static void loongson_poweroff(void)
 {
+#ifndef CONFIG_UEFI_FIRMWARE_INTERFACE
 	mach_prepare_shutdown();
 	unreachable();
+#else
+	extern u64 poweroff_addr;
+	void (*fw_poweroff)(void) = (void *)poweroff_addr;
+
+	fw_poweroff();
+#endif
 }
 
 static void loongson_halt(void)
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 05/14] MIPS: Loongson 3: Add HT-linked PCI support.
  2012-06-15  8:09 [PATCH 00/14] MIPS: Add Loongson-3 based machines support Huacai Chen
                   ` (3 preceding siblings ...)
  2012-06-15  8:09 ` [PATCH 04/14] MIPS: Loongson: Add UEFI-like firmware interface support Huacai Chen
@ 2012-06-15  8:09 ` Huacai Chen
  2012-06-15 14:34   ` LIU Qi
  2012-06-15  8:09 ` [PATCH 06/14] MIPS: Loongson 3: Add IRQ init and dispatch support Huacai Chen
                   ` (9 subsequent siblings)
  14 siblings, 1 reply; 34+ messages in thread
From: Huacai Chen @ 2012-06-15  8:09 UTC (permalink / raw)
  To: Ralf Baechle
  Cc: linux-mips, Fuxin Zhang, Zhangjin Wu, Huacai Chen, Hongliang Tao,
	Hua Yan

Loongson family machines use Hyper-Transport bus for inter-core
connection and device connection. The PCI bus is a subordinate
linked at HT1.

With UEFI-like firmware interface, We don't need PCI irq routing
fixup.

Signed-off-by: Huacai Chen <chenhc@lemote.com>
Signed-off-by: Hongliang Tao <taohl@lemote.com>
Signed-off-by: Hua Yan <yanh@lemote.com>
---
 arch/mips/Kconfig                              |    9 ++
 arch/mips/include/asm/mach-loongson/loongson.h |    7 ++
 arch/mips/include/asm/mach-loongson/pci.h      |    5 +
 arch/mips/pci/Makefile                         |    1 +
 arch/mips/pci/fixup-loongson3.c                |   50 +++++++++++
 arch/mips/pci/ops-loongson3.c                  |  104 ++++++++++++++++++++++++
 6 files changed, 176 insertions(+), 0 deletions(-)
 create mode 100644 arch/mips/pci/fixup-loongson3.c
 create mode 100644 arch/mips/pci/ops-loongson3.c

diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 38e460b..da2b1e5 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -2374,6 +2374,15 @@ config PCI
 	  your box. Other bus systems are ISA, EISA, or VESA. If you have PCI,
 	  say Y, otherwise N.
 
+config HT_PCI
+	bool "Support for HT-linked PCI"
+	select PCI_DOMAINS
+	help
+	  Loongson family machines use Hyper-Transport bus for inter-core
+	  connection and device connection. The PCI bus is a subordinate
+	  linked at HT. Choose Y unless you are using Loongson 2E/2F based
+	  machines.
+
 config PCI_DOMAINS
 	bool
 
diff --git a/arch/mips/include/asm/mach-loongson/loongson.h b/arch/mips/include/asm/mach-loongson/loongson.h
index 7efb911..f36f348 100644
--- a/arch/mips/include/asm/mach-loongson/loongson.h
+++ b/arch/mips/include/asm/mach-loongson/loongson.h
@@ -14,6 +14,7 @@
 #include <linux/io.h>
 #include <linux/init.h>
 #include <linux/irq.h>
+#include <boot_param.h>
 
 /* loongson internal northbridge initialization */
 extern void bonito_irq_init(void);
@@ -100,7 +101,13 @@ static inline void do_perfcnt_IRQ(void)
 #define LOONGSON_PCICFG_BASE	0x1fe80000
 #define LOONGSON_PCICFG_SIZE	0x00000800	/* 2K */
 #define LOONGSON_PCICFG_TOP	(LOONGSON_PCICFG_BASE+LOONGSON_PCICFG_SIZE-1)
+
+#if defined(CONFIG_HT_PCI)
+#define LOONGSON_PCIIO_BASE	loongson_pciio_base
+#else
 #define LOONGSON_PCIIO_BASE	0x1fd00000
+#endif
+
 #define LOONGSON_PCIIO_SIZE	0x00100000	/* 1M */
 #define LOONGSON_PCIIO_TOP	(LOONGSON_PCIIO_BASE+LOONGSON_PCIIO_SIZE-1)
 
diff --git a/arch/mips/include/asm/mach-loongson/pci.h b/arch/mips/include/asm/mach-loongson/pci.h
index bc99dab..1212774 100644
--- a/arch/mips/include/asm/mach-loongson/pci.h
+++ b/arch/mips/include/asm/mach-loongson/pci.h
@@ -40,8 +40,13 @@ extern struct pci_ops loongson_pci_ops;
 #else	/* loongson2f/32bit & loongson2e */
 
 /* this pci memory space is mapped by pcimap in pci.c */
+#ifdef CONFIG_CPU_LOONGSON3
+#define LOONGSON_PCI_MEM_START	0x40000000UL
+#define LOONGSON_PCI_MEM_END	0x7effffffUL
+#else
 #define LOONGSON_PCI_MEM_START	LOONGSON_PCILO1_BASE
 #define LOONGSON_PCI_MEM_END	(LOONGSON_PCILO1_BASE + 0x04000000 * 2)
+#endif
 /* this is an offset from mips_io_port_base */
 #define LOONGSON_PCI_IO_START	0x00004000UL
 
diff --git a/arch/mips/pci/Makefile b/arch/mips/pci/Makefile
index c703f43..4e0980c 100644
--- a/arch/mips/pci/Makefile
+++ b/arch/mips/pci/Makefile
@@ -30,6 +30,7 @@ obj-$(CONFIG_MIPS_COBALT)	+= fixup-cobalt.o
 obj-$(CONFIG_SOC_PNX8550)	+= fixup-pnx8550.o ops-pnx8550.o
 obj-$(CONFIG_LEMOTE_FULOONG2E)	+= fixup-fuloong2e.o ops-loongson2.o
 obj-$(CONFIG_LEMOTE_MACH2F)	+= fixup-lemote2f.o ops-loongson2.o
+obj-$(CONFIG_LEMOTE_MACH3A)	+= fixup-loongson3.o ops-loongson3.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
diff --git a/arch/mips/pci/fixup-loongson3.c b/arch/mips/pci/fixup-loongson3.c
new file mode 100644
index 0000000..e0fc80c
--- /dev/null
+++ b/arch/mips/pci/fixup-loongson3.c
@@ -0,0 +1,50 @@
+/*
+ * fixup-loongson3.c
+ *
+ * Copyright (C) 2012 Lemote, Inc.
+ * Author: Xiang Yu, xiangy@lemote.com
+ *         Chen Huacai, chenhc@lemote.com
+ *
+ * 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.
+ *
+ * THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR IMPLIED
+ * WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
+ * NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
+ * USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * You should have received a copy of the  GNU General Public License along
+ * with this program; if not, write  to the Free Software Foundation, Inc.,
+ * 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#include <linux/pci.h>
+
+static void print_fixup_info(struct pci_dev * pdev)
+{
+	printk(KERN_INFO "Fixup: bus%d dev%xh fun%xh %x:%x irq %d\n",
+			pdev->bus->number, PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn),
+			pdev->vendor, pdev->device, pdev->irq);
+
+}
+
+int __init pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
+{
+	print_fixup_info(dev);
+	return dev->irq;
+}
+
+/* Do platform specific device initialization at pci_enable_device() time */
+int pcibios_plat_dev_init(struct pci_dev *dev)
+{
+	return 0;
+}
diff --git a/arch/mips/pci/ops-loongson3.c b/arch/mips/pci/ops-loongson3.c
new file mode 100644
index 0000000..b29d333
--- /dev/null
+++ b/arch/mips/pci/ops-loongson3.c
@@ -0,0 +1,104 @@
+#include <linux/types.h>
+#include <linux/pci.h>
+#include <linux/kernel.h>
+
+#include <asm/mips-boards/bonito64.h>
+
+#include <loongson.h>
+
+#define PCI_ACCESS_READ  0
+#define PCI_ACCESS_WRITE 1
+
+#define HT1LO_PCICFG_BASE      0x1a000000
+#define HT1LO_PCICFG_BASE_TP1  0x1b000000
+
+static int loongson3_pci_config_access(unsigned char access_type,
+		struct pci_bus *bus, unsigned int devfn,
+		int where, u32 *data)
+{
+	unsigned char busnum = bus->number;
+	u_int64_t addr, type;
+	void *addrp;
+	int device = PCI_SLOT(devfn);
+	int function = PCI_FUNC(devfn);
+	int reg = where & ~3;
+
+	if (busnum == 0) {
+		if (device > 31)
+			return PCIBIOS_DEVICE_NOT_FOUND;
+		addr = (device << 11) | (function << 8) | reg;
+	    addrp = (void *)(TO_UNCAC(HT1LO_PCICFG_BASE) | (addr & 0xffff));
+		type = 0;
+
+	} else {
+		addr = (busnum << 16) | (device << 11) | (function << 8) | reg;
+	    addrp = (void *)(TO_UNCAC(HT1LO_PCICFG_BASE_TP1) | (addr));
+		type = 0x10000;
+	}
+
+	if (access_type == PCI_ACCESS_WRITE)
+		*(volatile unsigned int *)addrp = cpu_to_le32(*data);
+	else {
+		*data = le32_to_cpu(*(volatile unsigned int *)addrp);
+		if (*data == 0xffffffff) {
+			*data = -1;
+	        return PCIBIOS_DEVICE_NOT_FOUND;
+		}
+	}
+	return PCIBIOS_SUCCESSFUL;
+}
+
+static int loongson3_pci_pcibios_read(struct pci_bus *bus, unsigned int devfn,
+				 int where, int size, u32 * val)
+{
+	u32 data = 0;
+	int ret = loongson3_pci_config_access(PCI_ACCESS_READ,
+			bus, devfn, where, &data);
+
+	if (ret != PCIBIOS_SUCCESSFUL)
+		return ret;
+
+	if (size == 1)
+		*val = (data >> ((where & 3) << 3)) & 0xff;
+	else if (size == 2)
+		*val = (data >> ((where & 3) << 3)) & 0xffff;
+	else
+		*val = data;
+
+	return PCIBIOS_SUCCESSFUL;
+}
+
+static int loongson3_pci_pcibios_write(struct pci_bus *bus, unsigned int devfn,
+				  int where, int size, u32 val)
+{
+	u32 data = 0;
+	int ret;
+
+	if (size == 4)
+		data = val;
+	else {
+		ret = loongson3_pci_config_access(PCI_ACCESS_READ,
+				bus, devfn, where, &data);
+		if (ret != PCIBIOS_SUCCESSFUL)
+			return ret;
+
+		if (size == 1)
+			data = (data & ~(0xff << ((where & 3) << 3))) |
+			    (val << ((where & 3) << 3));
+		else if (size == 2)
+			data = (data & ~(0xffff << ((where & 3) << 3))) |
+			    (val << ((where & 3) << 3));
+	}
+
+	ret = loongson3_pci_config_access(PCI_ACCESS_WRITE,
+			bus, devfn, where, &data);
+	if (ret != PCIBIOS_SUCCESSFUL)
+		return ret;
+
+	return PCIBIOS_SUCCESSFUL;
+}
+
+struct pci_ops loongson_pci_ops = {
+	.read = loongson3_pci_pcibios_read,
+	.write = loongson3_pci_pcibios_write
+};
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 06/14] MIPS: Loongson 3: Add IRQ init and dispatch support.
  2012-06-15  8:09 [PATCH 00/14] MIPS: Add Loongson-3 based machines support Huacai Chen
                   ` (4 preceding siblings ...)
  2012-06-15  8:09 ` [PATCH 05/14] MIPS: Loongson 3: Add HT-linked PCI support Huacai Chen
@ 2012-06-15  8:09 ` Huacai Chen
  2012-06-15 14:32   ` LIU Qi
  2012-06-15  8:09 ` [PATCH 07/14] MIPS: Loongson 3: Add serial port support Huacai Chen
                   ` (8 subsequent siblings)
  14 siblings, 1 reply; 34+ messages in thread
From: Huacai Chen @ 2012-06-15  8:09 UTC (permalink / raw)
  To: Ralf Baechle
  Cc: linux-mips, Fuxin Zhang, Zhangjin Wu, Huacai Chen, Hongliang Tao,
	Hua Yan

IRQ routing path of Loongson-3:
Devices(most) --> I8259 --> HT Controller --> IRQ Routing Table --> CPU
                                                  ^
                                                  |
Device(legacy devices such as UART) --> Bonito ---|

IRQ Routing Table route 32 INTs to CPU's INT0~INT3(IP2~IP5 of CP0), 32
INTs include 16 HT INTs(mostly), 4 PCI INTs, 1 LPC INT, etc. IP6 is used
for IPI and IP7 is used for internal MIPS timer. LOONGSON_INT_ROUTER_*
are IRQ Routing Table registers.

I8259 IRQs are 1:1 mapped to HT1 INTs. LOONGSON_HT1_* are configuration
registers of HT1 controller.

Signed-off-by: Huacai Chen <chenhc@lemote.com>
Signed-off-by: Hongliang Tao <taohl@lemote.com>
Signed-off-by: Hua Yan <yanh@lemote.com>
---
 arch/mips/include/asm/mach-loongson/irq.h      |   26 +++++++
 arch/mips/include/asm/mach-loongson/loongson.h |    9 +++
 arch/mips/loongson/Makefile                    |    6 ++
 arch/mips/loongson/loongson-3/Makefile         |    4 +
 arch/mips/loongson/loongson-3/irq.c            |   87 ++++++++++++++++++++++++
 5 files changed, 132 insertions(+), 0 deletions(-)
 create mode 100644 arch/mips/include/asm/mach-loongson/irq.h
 create mode 100644 arch/mips/loongson/loongson-3/Makefile
 create mode 100644 arch/mips/loongson/loongson-3/irq.c

diff --git a/arch/mips/include/asm/mach-loongson/irq.h b/arch/mips/include/asm/mach-loongson/irq.h
new file mode 100644
index 0000000..c34c70a
--- /dev/null
+++ b/arch/mips/include/asm/mach-loongson/irq.h
@@ -0,0 +1,26 @@
+#ifndef __ASM_MACH_LOONGSON_IRQ_H_
+#define __ASM_MACH_LOONGSON_IRQ_H_
+
+#include <boot_param.h>
+
+/* cpu core interrupt numbers */
+#define MIPS_CPU_IRQ_BASE 56
+
+#define I8042_KBD_IRQ	0x01
+
+#ifdef CONFIG_CPU_LOONGSON3
+
+#define LOONGSON_UART_IRQ   (MIPS_CPU_IRQ_BASE + 2) /* uart */
+#define LOONGSON_I8259_IRQ  (MIPS_CPU_IRQ_BASE + 3) /* i8259 */
+#define LOONGSON_TIMER_IRQ  (MIPS_CPU_IRQ_BASE + 7) /* cpu timer */
+
+#define LOONGSON_HT1_CFG_BASE		ht_control_base
+#define LOONGSON_HT1_INT_VECTOR_BASE	LOONGSON_HT1_CFG_BASE + 0x80
+#define LOONGSON_HT1_INT_EN_BASE	LOONGSON_HT1_CFG_BASE + 0xa0
+#define LOONGSON_HT1_INT_VECTOR(n)	LOONGSON3_REG32(LOONGSON_HT1_INT_VECTOR_BASE, 4 * n)
+#define LOONGSON_HT1_INTN_EN(n)		LOONGSON3_REG32(LOONGSON_HT1_INT_EN_BASE, 4 * n)
+
+#endif
+
+#include_next <irq.h>
+#endif /* __ASM_MACH_LOONGSON_IRQ_H_ */
diff --git a/arch/mips/include/asm/mach-loongson/loongson.h b/arch/mips/include/asm/mach-loongson/loongson.h
index f36f348..fe7d9a6 100644
--- a/arch/mips/include/asm/mach-loongson/loongson.h
+++ b/arch/mips/include/asm/mach-loongson/loongson.h
@@ -61,6 +61,12 @@ extern int mach_i8259_irq(void);
 #define LOONGSON_REG(x) \
 	(*(volatile u32 *)((char *)CKSEG1ADDR(LOONGSON_REG_BASE) + (x)))
 
+#define LOONGSON3_REG8(base, x) \
+	(*(volatile u8 *)((char *)TO_UNCAC(base) + (x)))
+
+#define LOONGSON3_REG32(base, x) \
+	(*(volatile u32 *)((char *)TO_UNCAC(base) + (x)))
+
 #define LOONGSON_IRQ_BASE	32
 #define LOONGSON2_PERFCNT_IRQ	(MIPS_CPU_IRQ_BASE + 6) /* cpu perf counter */
 
@@ -86,6 +92,9 @@ static inline void do_perfcnt_IRQ(void)
 #define LOONGSON_REG_BASE 	0x1fe00000
 #define LOONGSON_REG_SIZE 	0x00100000	/* 256Bytes + 256Bytes + ??? */
 #define LOONGSON_REG_TOP	(LOONGSON_REG_BASE+LOONGSON_REG_SIZE-1)
+#define LOONGSON3_REG_BASE	0x3ff00000
+#define LOONGSON3_REG_SIZE 	0x00100000	/* 256Bytes + 256Bytes + ??? */
+#define LOONGSON3_REG_TOP	(LOONGSON3_REG_BASE+LOONGSON3_REG_SIZE-1)
 
 #define LOONGSON_LIO1_BASE 	0x1ff00000
 #define LOONGSON_LIO1_SIZE 	0x00100000	/* 1M */
diff --git a/arch/mips/loongson/Makefile b/arch/mips/loongson/Makefile
index 2b76cb0..b1e4f05 100644
--- a/arch/mips/loongson/Makefile
+++ b/arch/mips/loongson/Makefile
@@ -15,3 +15,9 @@ obj-$(CONFIG_LEMOTE_FULOONG2E)  += fuloong-2e/
 #
 
 obj-$(CONFIG_LEMOTE_MACH2F)  += lemote-2f/
+
+#
+# All Loongson-3 family machines
+#
+
+obj-$(CONFIG_CPU_LOONGSON3)  += loongson-3/
diff --git a/arch/mips/loongson/loongson-3/Makefile b/arch/mips/loongson/loongson-3/Makefile
new file mode 100644
index 0000000..b9968cd
--- /dev/null
+++ b/arch/mips/loongson/loongson-3/Makefile
@@ -0,0 +1,4 @@
+#
+# Makefile for Loongson-3 family machines
+#
+obj-y			+= irq.o
diff --git a/arch/mips/loongson/loongson-3/irq.c b/arch/mips/loongson/loongson-3/irq.c
new file mode 100644
index 0000000..27aef31
--- /dev/null
+++ b/arch/mips/loongson/loongson-3/irq.c
@@ -0,0 +1,87 @@
+#include <loongson.h>
+#include <irq.h>
+#include <linux/interrupt.h>
+#include <linux/module.h>
+
+#include <asm/irq_cpu.h>
+#include <asm/i8259.h>
+#include <asm/mipsregs.h>
+
+#define LOONGSON_INT_ROUTER_OFFSET	0x1400
+#define LOONGSON_INT_ROUTER_INTEN	LOONGSON3_REG32(LOONGSON3_REG_BASE, LOONGSON_INT_ROUTER_OFFSET + 0x24)
+#define LOONGSON_INT_ROUTER_INTENSET	LOONGSON3_REG32(LOONGSON3_REG_BASE, LOONGSON_INT_ROUTER_OFFSET + 0x28)
+#define LOONGSON_INT_ROUTER_INTENCLR	LOONGSON3_REG32(LOONGSON3_REG_BASE, LOONGSON_INT_ROUTER_OFFSET + 0x2c)
+#define LOONGSON_INT_ROUTER_ENTRY(n)	LOONGSON3_REG8(LOONGSON3_REG_BASE, LOONGSON_INT_ROUTER_OFFSET + n)
+#define LOONGSON_INT_ROUTER_LPC		LOONGSON_INT_ROUTER_ENTRY(0x0a)
+#define LOONGSON_INT_ROUTER_HT1(n)	LOONGSON_INT_ROUTER_ENTRY(n + 0x18)
+
+#define LOONGSON_INT_CORE0_INT0		0x11 /* route to int 0 of core 0 */
+#define LOONGSON_INT_CORE0_INT1		0x21 /* route to int 1 of core 0 */
+
+extern void loongson3_ipi_interrupt(struct pt_regs *regs);
+
+static void ht_irqdispatch(void)
+{
+	unsigned int i, irq;
+	unsigned int ht_irq[] = {1, 3, 4, 5, 6, 7, 8, 12, 14, 15};
+
+	irq = LOONGSON_HT1_INT_VECTOR(0);
+	LOONGSON_HT1_INT_VECTOR(0) = irq;
+
+	for (i = 0; i < (sizeof(ht_irq) / sizeof(*ht_irq)); i++) {
+		if (irq & (0x1 << ht_irq[i]))
+			do_IRQ(ht_irq[i]);
+	}
+}
+
+void mach_irq_dispatch(unsigned int pending)
+{
+	if (pending & CAUSEF_IP7)
+		do_IRQ(LOONGSON_TIMER_IRQ);
+#if defined(CONFIG_SMP)
+	else if (pending & CAUSEF_IP6)
+		loongson3_ipi_interrupt(NULL);
+#endif
+	else if (pending & CAUSEF_IP3)
+		ht_irqdispatch();
+	else if (pending & CAUSEF_IP2)
+		do_IRQ(LOONGSON_UART_IRQ);
+	else {
+		printk(KERN_ERR "%s : spurious interrupt\n", __func__);
+		spurious_interrupt();
+	}
+}
+
+static struct irqaction cascade_irqaction = {
+	.handler = no_action,
+	.name = "cascade",
+};
+
+void irq_router_init(void)
+{
+	int i;
+
+	/* route LPC int to cpu core0 int 0 */
+	LOONGSON_INT_ROUTER_LPC = LOONGSON_INT_CORE0_INT0;
+	/* route HT1 int0 ~ int7 to cpu core0 INT1*/
+	for (i = 0; i < 8; i++)
+		LOONGSON_INT_ROUTER_HT1(i) = LOONGSON_INT_CORE0_INT1;
+	/* enable HT1 interrupt */
+	LOONGSON_HT1_INTN_EN(0) = 0xffffffff;
+	/* enable router interrupt intenset */
+	LOONGSON_INT_ROUTER_INTENSET = LOONGSON_INT_ROUTER_INTEN | (0xffff << 16) | 0x1 << 10;
+}
+
+void __init mach_init_irq(void)
+{
+	clear_c0_status(ST0_IM | ST0_BEV);
+
+	irq_router_init();
+	mips_cpu_irq_init();
+	init_i8259_irqs();
+
+	/* setup i8259 irq */
+	setup_irq(LOONGSON_I8259_IRQ, &cascade_irqaction);
+
+	set_c0_status(STATUSF_IP2 | STATUSF_IP6);
+}
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 07/14] MIPS: Loongson 3: Add serial port support.
  2012-06-15  8:09 [PATCH 00/14] MIPS: Add Loongson-3 based machines support Huacai Chen
                   ` (5 preceding siblings ...)
  2012-06-15  8:09 ` [PATCH 06/14] MIPS: Loongson 3: Add IRQ init and dispatch support Huacai Chen
@ 2012-06-15  8:09 ` Huacai Chen
  2012-06-15  9:50   ` Arnaud Patard
  2012-06-15  8:09 ` [PATCH 08/14] MIPS: Loongson: Add swiotlb to support big memory (>4GB) Huacai Chen
                   ` (7 subsequent siblings)
  14 siblings, 1 reply; 34+ messages in thread
From: Huacai Chen @ 2012-06-15  8:09 UTC (permalink / raw)
  To: Ralf Baechle
  Cc: linux-mips, Fuxin Zhang, Zhangjin Wu, Huacai Chen, Hongliang Tao,
	Hua Yan

Signed-off-by: Huacai Chen <chenhc@lemote.com>
Signed-off-by: Hongliang Tao <taohl@lemote.com>
Signed-off-by: Hua Yan <yanh@lemote.com>
---
 arch/mips/include/asm/mach-loongson/loongson.h |    3 ++
 arch/mips/loongson/common/serial.c             |   27 ++++++++++++++++++++++++
 arch/mips/loongson/common/uart_base.c          |    5 ++++
 3 files changed, 35 insertions(+), 0 deletions(-)

diff --git a/arch/mips/include/asm/mach-loongson/loongson.h b/arch/mips/include/asm/mach-loongson/loongson.h
index fe7d9a6..16d0924 100644
--- a/arch/mips/include/asm/mach-loongson/loongson.h
+++ b/arch/mips/include/asm/mach-loongson/loongson.h
@@ -125,6 +125,9 @@ static inline void do_perfcnt_IRQ(void)
 #define LOONGSON_PCICONFIGBASE	0x00
 #define LOONGSON_REGBASE	0x100
 
+/* Loongson-3A cpu uart */
+#define LOONGSON_UART_BASE 0x1fe001e0
+
 /* PCI Configuration Registers */
 
 #define LOONGSON_PCI_REG(x)	LOONGSON_REG(LOONGSON_PCICONFIGBASE + (x))
diff --git a/arch/mips/loongson/common/serial.c b/arch/mips/loongson/common/serial.c
index 7580873..6bfe9dd 100644
--- a/arch/mips/loongson/common/serial.c
+++ b/arch/mips/loongson/common/serial.c
@@ -47,6 +47,33 @@ static struct plat_serial8250_port uart8250_data[][2] = {
 	[MACH_DEXXON_GDIUM2F10]         {PORT_M(3), {} },
 	[MACH_LEMOTE_NAS]               {PORT_M(3), {} },
 	[MACH_LEMOTE_LL2F]              {PORT(3), {} },
+	[MACH_LEMOTE_A1004]             {
+						{
+							.irq		= MIPS_CPU_IRQ_BASE + 2,
+							.uartclk	= 33177600,
+							.iotype		= UPIO_MEM,
+							.flags		= UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
+						},
+						{}
+					},
+	[MACH_LEMOTE_A1101]             {
+						{
+							.irq		= MIPS_CPU_IRQ_BASE + 2,
+							.uartclk	= 25000000,
+							.iotype		= UPIO_MEM,
+							.flags		= UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
+						},
+						{}
+					},
+	[MACH_LEMOTE_A1205]             {
+						{
+							.irq		= MIPS_CPU_IRQ_BASE + 2,
+							.uartclk	= 25000000,
+							.iotype		= UPIO_MEM,
+							.flags		= UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
+						},
+						{}
+					},
 	[MACH_LOONGSON_END]             {},
 };
 
diff --git a/arch/mips/loongson/common/uart_base.c b/arch/mips/loongson/common/uart_base.c
index d69ea54..ca86c07 100644
--- a/arch/mips/loongson/common/uart_base.c
+++ b/arch/mips/loongson/common/uart_base.c
@@ -30,6 +30,11 @@ void prom_init_loongson_uart_base(void)
 	case MACH_LEMOTE_LL2F:
 		loongson_uart_base = LOONGSON_PCIIO_BASE + 0x2f8;
 		break;
+	case MACH_LEMOTE_A1004:
+	case MACH_LEMOTE_A1101:
+	case MACH_LEMOTE_A1205:
+		loongson_uart_base = LOONGSON_UART_BASE;
+		break;
 	case MACH_LEMOTE_ML2F7:
 	case MACH_LEMOTE_YL2F89:
 	case MACH_DEXXON_GDIUM2F10:
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 08/14] MIPS: Loongson: Add swiotlb to support big memory (>4GB).
  2012-06-15  8:09 [PATCH 00/14] MIPS: Add Loongson-3 based machines support Huacai Chen
                   ` (6 preceding siblings ...)
  2012-06-15  8:09 ` [PATCH 07/14] MIPS: Loongson 3: Add serial port support Huacai Chen
@ 2012-06-15  8:09 ` Huacai Chen
  2012-06-15  8:09 ` [PATCH 09/14] ata: Use 32bit DMA in AHCI for Loongson 3 Huacai Chen
                   ` (6 subsequent siblings)
  14 siblings, 0 replies; 34+ messages in thread
From: Huacai Chen @ 2012-06-15  8:09 UTC (permalink / raw)
  To: Ralf Baechle
  Cc: linux-mips, Fuxin Zhang, Zhangjin Wu, Huacai Chen, Hongliang Tao,
	Hua Yan

This is probably a workaround because Loongson doesn't support DMA
address above 4GB. If memory is more than 4GB, CONFIG_SWIOTLB and
ZONE_DMA32 should be selected. In this way, DMA pages are allocated
below 4GB.

However, CONFIG_SWIOTLB+ZONE_DMA32 is not enough, so, in the following
patches, drivers of block device, graphics card, sound card, etc. will
all be set a DMA32 flags explitly.

Signed-off-by: Huacai Chen <chenhc@lemote.com>
Signed-off-by: Hongliang Tao <taohl@lemote.com>
Signed-off-by: Hua Yan <yanh@lemote.com>
---
 .../mips/include/asm/mach-loongson/dma-coherence.h |   25 +++-
 arch/mips/loongson/Kconfig                         |   18 +++
 arch/mips/loongson/common/Makefile                 |    5 +
 arch/mips/loongson/common/dma-swiotlb.c            |  147 ++++++++++++++++++++
 arch/mips/mm/dma-default.c                         |   13 ++-
 5 files changed, 203 insertions(+), 5 deletions(-)
 create mode 100644 arch/mips/loongson/common/dma-swiotlb.c

diff --git a/arch/mips/include/asm/mach-loongson/dma-coherence.h b/arch/mips/include/asm/mach-loongson/dma-coherence.h
index e143305..b1dc286 100644
--- a/arch/mips/include/asm/mach-loongson/dma-coherence.h
+++ b/arch/mips/include/asm/mach-loongson/dma-coherence.h
@@ -13,26 +13,43 @@
 
 struct device;
 
+extern dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr);
+extern phys_addr_t dma_to_phys(struct device *dev, dma_addr_t daddr);
 static inline dma_addr_t plat_map_dma_mem(struct device *dev, void *addr,
 					  size_t size)
 {
+#ifdef CONFIG_CPU_LOONGSON3
+	return virt_to_phys(addr) < 0x10000000 ?
+			(virt_to_phys(addr) | 0x0000000080000000) : virt_to_phys(addr);
+#else
 	return virt_to_phys(addr) | 0x80000000;
+#endif
 }
 
 static inline dma_addr_t plat_map_dma_mem_page(struct device *dev,
 					       struct page *page)
 {
+#ifdef CONFIG_CPU_LOONGSON3
+	return page_to_phys(page) < 0x10000000 ?
+			(page_to_phys(page) | 0x0000000080000000) : page_to_phys(page);
+#else
 	return page_to_phys(page) | 0x80000000;
+#endif
 }
 
 static inline unsigned long plat_dma_addr_to_phys(struct device *dev,
 	dma_addr_t dma_addr)
 {
-#if defined(CONFIG_CPU_LOONGSON2F) && defined(CONFIG_64BIT)
+#if defined(CONFIG_64BIT)
+#if defined(CONFIG_CPU_LOONGSON3)
+	return (dma_addr < 0x90000000 && dma_addr >= 0x80000000) ?
+			(dma_addr & 0x0fffffff) : dma_addr;
+#elif defined(CONFIG_CPU_LOONGSON2F)
 	return (dma_addr > 0x8fffffff) ? dma_addr : (dma_addr & 0x0fffffff);
+#endif /* CONFIG_CPU_LOONGSON3 */
 #else
 	return dma_addr & 0x7fffffff;
-#endif
+#endif /* CONFIG_64BIT */
 }
 
 static inline void plat_unmap_dma_mem(struct device *dev, dma_addr_t dma_addr,
@@ -65,7 +82,11 @@ static inline int plat_dma_mapping_error(struct device *dev,
 
 static inline int plat_device_is_coherent(struct device *dev)
 {
+#ifdef CONFIG_DMA_NONCOHERENT
 	return 0;
+#else
+	return 1;
+#endif /* CONFIG_DMA_NONCOHERENT */
 }
 
 #endif /* __ASM_MACH_LOONGSON_DMA_COHERENCE_H */
diff --git a/arch/mips/loongson/Kconfig b/arch/mips/loongson/Kconfig
index 9a31418..9a591ae 100644
--- a/arch/mips/loongson/Kconfig
+++ b/arch/mips/loongson/Kconfig
@@ -112,6 +112,24 @@ config LOONGSON_UART_BASE
 	default y
 	depends on EARLY_PRINTK || SERIAL_8250
 
+config LOONGSON_BIGMEM
+	bool "Soft IOMMU Support for Big Memory (>4GB)"
+	depends on CPU_LOONGSON3
+	select SWIOTLB
+	select ZONE_DMA32
+
+config IOMMU_HELPER
+	bool
+
+config NEED_SG_DMA_LENGTH
+	bool
+
+config SWIOTLB
+	bool
+	select IOMMU_HELPER
+	select NEED_SG_DMA_LENGTH
+	select NEED_DMA_MAP_STATE
+
 config LOONGSON_MC146818
 	bool
 	default n
diff --git a/arch/mips/loongson/common/Makefile b/arch/mips/loongson/common/Makefile
index e526488..3a26109 100644
--- a/arch/mips/loongson/common/Makefile
+++ b/arch/mips/loongson/common/Makefile
@@ -25,3 +25,8 @@ obj-$(CONFIG_CS5536) += cs5536/
 #
 
 obj-$(CONFIG_LOONGSON_SUSPEND) += pm.o
+
+#
+# Big Memory Support
+#
+obj-$(CONFIG_LOONGSON_BIGMEM) += dma-swiotlb.o
diff --git a/arch/mips/loongson/common/dma-swiotlb.c b/arch/mips/loongson/common/dma-swiotlb.c
new file mode 100644
index 0000000..f71490d
--- /dev/null
+++ b/arch/mips/loongson/common/dma-swiotlb.c
@@ -0,0 +1,147 @@
+#include <linux/mm.h>
+#include <linux/init.h>
+#include <linux/dma-mapping.h>
+#include <linux/scatterlist.h>
+#include <linux/swiotlb.h>
+#include <linux/bootmem.h>
+
+#include <asm/bootinfo.h>
+#include <dma-coherence.h>
+
+static void *loongson_dma_alloc_coherent(struct device *dev, size_t size,
+				dma_addr_t *dma_handle, gfp_t gfp, struct dma_attrs *attrs)
+{
+	void *ret;
+
+	if (dma_alloc_from_coherent(dev, size, dma_handle, &ret))
+		return ret;
+
+	/* ignore region specifiers */
+	gfp &= ~(__GFP_DMA | __GFP_DMA32 | __GFP_HIGHMEM);
+
+#ifdef CONFIG_ZONE_DMA
+	if (dev == NULL)
+		gfp |= __GFP_DMA;
+	else if (dev->coherent_dma_mask <= DMA_BIT_MASK(24))
+		gfp |= __GFP_DMA;
+	else
+#endif
+#ifdef CONFIG_ZONE_DMA32
+	if (dev->coherent_dma_mask <= DMA_BIT_MASK(32))
+		gfp |= __GFP_DMA32;
+	else
+#endif
+	;
+	gfp |= __GFP_NORETRY;
+
+	ret = swiotlb_alloc_coherent(dev, size, dma_handle, gfp);
+	mb();
+	return ret;
+}
+
+static void loongson_dma_free_coherent(struct device *dev, size_t size,
+				void *vaddr, dma_addr_t dma_handle, struct dma_attrs *attrs)
+{
+	int order = get_order(size);
+
+	if (dma_release_from_coherent(dev, order, vaddr))
+		return;
+
+	swiotlb_free_coherent(dev, size, vaddr, dma_handle);
+}
+
+static dma_addr_t loongson_dma_map_page(struct device *dev, struct page *page,
+				unsigned long offset, size_t size,
+				enum dma_data_direction dir,
+				struct dma_attrs *attrs)
+{
+	dma_addr_t daddr = swiotlb_map_page(dev, page, offset, size,
+					dir, attrs);
+	mb();
+	return daddr;
+}
+
+static int loongson_dma_map_sg(struct device *dev, struct scatterlist *sg,
+				int nents, enum dma_data_direction dir,
+				struct dma_attrs *attrs)
+{
+	int r = swiotlb_map_sg_attrs(dev, sg, nents, dir, NULL);
+	mb();
+
+	return r;
+}
+
+static void loongson_dma_sync_single_for_device(struct device *dev,
+				dma_addr_t dma_handle, size_t size,
+				enum dma_data_direction dir)
+{
+	swiotlb_sync_single_for_device(dev, dma_handle, size, dir);
+	mb();
+}
+
+static void loongson_dma_sync_sg_for_device(struct device *dev,
+				struct scatterlist *sg, int nents,
+				enum dma_data_direction dir)
+{
+	swiotlb_sync_sg_for_device(dev, sg, nents, dir);
+	mb();
+}
+
+static dma_addr_t loongson_unity_phys_to_dma(struct device *dev, phys_addr_t paddr)
+{
+	return (paddr < 0x10000000) ?
+			(paddr | 0x0000000080000000) : paddr;
+}
+
+static phys_addr_t loongson_unity_dma_to_phys(struct device *dev, dma_addr_t daddr)
+{
+	return (daddr < 0x90000000 && daddr >= 0x80000000) ?
+			(daddr & 0x0fffffff) : daddr;
+}
+
+struct loongson_dma_map_ops {
+	struct dma_map_ops dma_map_ops;
+	dma_addr_t (*phys_to_dma)(struct device *dev, phys_addr_t paddr);
+	phys_addr_t (*dma_to_phys)(struct device *dev, dma_addr_t daddr);
+};
+
+dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr)
+{
+	struct loongson_dma_map_ops *ops = container_of(get_dma_ops(dev),
+					struct loongson_dma_map_ops, dma_map_ops);
+
+	return ops->phys_to_dma(dev, paddr);
+}
+
+phys_addr_t dma_to_phys(struct device *dev, dma_addr_t daddr)
+{
+	struct loongson_dma_map_ops *ops = container_of(get_dma_ops(dev),
+					struct loongson_dma_map_ops, dma_map_ops);
+
+	return ops->dma_to_phys(dev, daddr);
+}
+
+static struct loongson_dma_map_ops loongson_linear_dma_map_ops = {
+	.dma_map_ops = {
+		.alloc = loongson_dma_alloc_coherent,
+		.free = loongson_dma_free_coherent,
+		.map_page = loongson_dma_map_page,
+		.unmap_page = swiotlb_unmap_page,
+		.map_sg = loongson_dma_map_sg,
+		.unmap_sg = swiotlb_unmap_sg_attrs,
+		.sync_single_for_cpu = swiotlb_sync_single_for_cpu,
+		.sync_single_for_device = loongson_dma_sync_single_for_device,
+		.sync_sg_for_cpu = swiotlb_sync_sg_for_cpu,
+		.sync_sg_for_device = loongson_dma_sync_sg_for_device,
+		.mapping_error = swiotlb_dma_mapping_error,
+		.dma_supported = swiotlb_dma_supported
+	},
+	.phys_to_dma = loongson_unity_phys_to_dma,
+	.dma_to_phys = loongson_unity_dma_to_phys
+};
+
+void __init plat_swiotlb_setup(void)
+{
+	swiotlb_init(1);
+	mips_dma_map_ops = &loongson_linear_dma_map_ops.dma_map_ops;
+}
diff --git a/arch/mips/mm/dma-default.c b/arch/mips/mm/dma-default.c
index 3fab204..122f4f8 100644
--- a/arch/mips/mm/dma-default.c
+++ b/arch/mips/mm/dma-default.c
@@ -42,6 +42,13 @@ static inline int cpu_is_noncoherent_r10000(struct device *dev)
 	       current_cpu_type() == CPU_R12000);
 }
 
+static inline int cpu_is_noncoherent_loongson(struct device *dev)
+{
+	return !plat_device_is_coherent(dev) &&
+			(current_cpu_type() == CPU_LOONGSON2 ||
+			 current_cpu_type() == CPU_LOONGSON3);
+}
+
 static gfp_t massage_gfp_flags(const struct device *dev, gfp_t gfp)
 {
 	gfp_t dma_flag;
@@ -209,7 +216,7 @@ static inline void __dma_sync(struct page *page,
 static void mips_dma_unmap_page(struct device *dev, dma_addr_t dma_addr,
 	size_t size, enum dma_data_direction direction, struct dma_attrs *attrs)
 {
-	if (cpu_is_noncoherent_r10000(dev))
+	if (cpu_is_noncoherent_r10000(dev) || cpu_is_noncoherent_loongson(dev))
 		__dma_sync(dma_addr_to_page(dev, dma_addr),
 			   dma_addr & ~PAGE_MASK, size, direction);
 
@@ -260,7 +267,7 @@ static void mips_dma_unmap_sg(struct device *dev, struct scatterlist *sg,
 static void mips_dma_sync_single_for_cpu(struct device *dev,
 	dma_addr_t dma_handle, size_t size, enum dma_data_direction direction)
 {
-	if (cpu_is_noncoherent_r10000(dev))
+	if (cpu_is_noncoherent_r10000(dev) || cpu_is_noncoherent_loongson(dev))
 		__dma_sync(dma_addr_to_page(dev, dma_handle),
 			   dma_handle & ~PAGE_MASK, size, direction);
 }
@@ -281,7 +288,7 @@ static void mips_dma_sync_sg_for_cpu(struct device *dev,
 
 	/* Make sure that gcc doesn't leave the empty loop body.  */
 	for (i = 0; i < nelems; i++, sg++) {
-		if (cpu_is_noncoherent_r10000(dev))
+		if (cpu_is_noncoherent_r10000(dev) || cpu_is_noncoherent_loongson(dev))
 			__dma_sync(sg_page(sg), sg->offset, sg->length,
 				   direction);
 	}
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 09/14] ata: Use 32bit DMA in AHCI for Loongson 3.
  2012-06-15  8:09 [PATCH 00/14] MIPS: Add Loongson-3 based machines support Huacai Chen
                   ` (7 preceding siblings ...)
  2012-06-15  8:09 ` [PATCH 08/14] MIPS: Loongson: Add swiotlb to support big memory (>4GB) Huacai Chen
@ 2012-06-15  8:09 ` Huacai Chen
  2012-06-15 10:04   ` Sergei Shtylyov
  2012-06-15  8:09 ` [PATCH 10/14] drm/radeon: Make radeon card usable for Loongson Huacai Chen
                   ` (5 subsequent siblings)
  14 siblings, 1 reply; 34+ messages in thread
From: Huacai Chen @ 2012-06-15  8:09 UTC (permalink / raw)
  To: Ralf Baechle
  Cc: linux-mips, Fuxin Zhang, Zhangjin Wu, Huacai Chen, Hongliang Tao,
	Hua Yan

Signed-off-by: Huacai Chen <chenhc@lemote.com>
Signed-off-by: Hongliang Tao <taohl@lemote.com>
Signed-off-by: Hua Yan <yanh@lemote.com>
---
 drivers/ata/ahci.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index ebaf67e..3e3cfd8 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -183,7 +183,12 @@ static const struct ata_port_info ahci_port_info[] = {
 	},
 	[board_ahci_sb700] =	/* for SB700 and SB800 */
 	{
+#ifndef CONFIG_CPU_LOONGSON3
 		AHCI_HFLAGS	(AHCI_HFLAG_IGN_SERR_INTERNAL),
+#else
+		AHCI_HFLAGS	(AHCI_HFLAG_IGN_SERR_INTERNAL |
+						AHCI_HFLAG_32BIT_ONLY),
+#endif
 		.flags		= AHCI_FLAG_COMMON,
 		.pio_mask	= ATA_PIO4,
 		.udma_mask	= ATA_UDMA6,
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 10/14] drm/radeon: Make radeon card usable for Loongson.
  2012-06-15  8:09 [PATCH 00/14] MIPS: Add Loongson-3 based machines support Huacai Chen
                   ` (8 preceding siblings ...)
  2012-06-15  8:09 ` [PATCH 09/14] ata: Use 32bit DMA in AHCI for Loongson 3 Huacai Chen
@ 2012-06-15  8:09 ` Huacai Chen
  2012-06-15 14:28   ` LIU Qi
  2012-06-15  8:09 ` [PATCH 11/14] ALSA: Make hda sound " Huacai Chen
                   ` (4 subsequent siblings)
  14 siblings, 1 reply; 34+ messages in thread
From: Huacai Chen @ 2012-06-15  8:09 UTC (permalink / raw)
  To: Ralf Baechle
  Cc: linux-mips, Fuxin Zhang, Zhangjin Wu, Huacai Chen, Hongliang Tao,
	Hua Yan

1, Use 32bit DMA as a workaround.
2, Read vga bios offered by system firmware.
3, Handle io prot correctly for MIPS.
4, Don't use swiotlb on Loongson machines.

Signed-off-by: Huacai Chen <chenhc@lemote.com>
Signed-off-by: Hongliang Tao <taohl@lemote.com>
Signed-off-by: Hua Yan <yanh@lemote.com>
---
 drivers/gpu/drm/drm_vm.c               |    2 +-
 drivers/gpu/drm/radeon/radeon_bios.c   |   32 ++++++++++++++++++++++++++++++++
 drivers/gpu/drm/radeon/radeon_device.c |    5 +++++
 drivers/gpu/drm/radeon/radeon_ttm.c    |    6 +++---
 drivers/gpu/drm/ttm/ttm_bo_util.c      |    2 +-
 include/drm/drm_sarea.h                |    2 ++
 6 files changed, 44 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/drm_vm.c b/drivers/gpu/drm/drm_vm.c
index 961ee08..3f06166 100644
--- a/drivers/gpu/drm/drm_vm.c
+++ b/drivers/gpu/drm/drm_vm.c
@@ -62,7 +62,7 @@ static pgprot_t drm_io_prot(uint32_t map_type, struct vm_area_struct *vma)
 		tmp = pgprot_writecombine(tmp);
 	else
 		tmp = pgprot_noncached(tmp);
-#elif defined(__sparc__) || defined(__arm__)
+#elif defined(__sparc__) || defined(__arm__) || defined(__mips__)
 	tmp = pgprot_noncached(tmp);
 #endif
 	return tmp;
diff --git a/drivers/gpu/drm/radeon/radeon_bios.c b/drivers/gpu/drm/radeon/radeon_bios.c
index 501f488..2630e22 100644
--- a/drivers/gpu/drm/radeon/radeon_bios.c
+++ b/drivers/gpu/drm/radeon/radeon_bios.c
@@ -29,6 +29,7 @@
 #include "radeon_reg.h"
 #include "radeon.h"
 #include "atom.h"
+#include <asm/bootinfo.h>
 
 #include <linux/vga_switcheroo.h>
 #include <linux/slab.h>
@@ -73,6 +74,32 @@ static bool igp_read_bios_from_vram(struct radeon_device *rdev)
 	return true;
 }
 
+#ifdef CONFIG_CPU_LOONGSON3
+extern u64 vgabios_addr;
+static bool loongson3_read_bios(struct radeon_device *rdev)
+{
+	u8 *bios;
+	resource_size_t size = 512 * 1024; /* ??? */
+
+	rdev->bios = NULL;
+
+	bios = (u8 *)vgabios_addr;
+	if (!bios) {
+		return false;
+	}
+
+	if (size == 0 || bios[0] != 0x55 || bios[1] != 0xaa) {
+		return false;
+	}
+	rdev->bios = kmalloc(size, GFP_KERNEL);
+	if (rdev->bios == NULL) {
+		return false;
+	}
+	memcpy(rdev->bios, bios, size);
+	return true;
+}
+#endif
+
 static bool radeon_read_bios(struct radeon_device *rdev)
 {
 	uint8_t __iomem *bios;
@@ -490,6 +517,11 @@ bool radeon_get_bios(struct radeon_device *rdev)
 	if (r == false) {
 		r = radeon_read_disabled_bios(rdev);
 	}
+#ifdef CONFIG_CPU_LOONGSON3
+	if (r == false) {
+		r = loongson3_read_bios(rdev);
+	}
+#endif
 	if (r == false || rdev->bios == NULL) {
 		DRM_ERROR("Unable to locate a BIOS ROM\n");
 		rdev->bios = NULL;
diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
index 066c98b..8aac7ab 100644
--- a/drivers/gpu/drm/radeon/radeon_device.c
+++ b/drivers/gpu/drm/radeon/radeon_device.c
@@ -777,6 +777,11 @@ int radeon_device_init(struct radeon_device *rdev,
 	    (rdev->family < CHIP_RS400))
 		rdev->need_dma32 = true;
 
+#ifdef CONFIG_CPU_LOONGSON3
+	/* Workaround: Loongson 3 doesn't support 40-bits DMA */
+	rdev->need_dma32 = true;
+#endif
+
 	dma_bits = rdev->need_dma32 ? 32 : 40;
 	r = pci_set_dma_mask(rdev->pdev, DMA_BIT_MASK(dma_bits));
 	if (r) {
diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
index c94a225..f49bdd1 100644
--- a/drivers/gpu/drm/radeon/radeon_ttm.c
+++ b/drivers/gpu/drm/radeon/radeon_ttm.c
@@ -630,7 +630,7 @@ static int radeon_ttm_tt_populate(struct ttm_tt *ttm)
 	}
 #endif
 
-#ifdef CONFIG_SWIOTLB
+#if defined(CONFIG_SWIOTLB) && !defined(CONFIG_CPU_LOONGSON3)
 	if (swiotlb_nr_tbl()) {
 		return ttm_dma_populate(&gtt->ttm, rdev->dev);
 	}
@@ -676,7 +676,7 @@ static void radeon_ttm_tt_unpopulate(struct ttm_tt *ttm)
 	}
 #endif
 
-#ifdef CONFIG_SWIOTLB
+#if defined(CONFIG_SWIOTLB) && !defined(CONFIG_CPU_LOONGSON3)
 	if (swiotlb_nr_tbl()) {
 		ttm_dma_unpopulate(&gtt->ttm, rdev->dev);
 		return;
@@ -906,7 +906,7 @@ static int radeon_ttm_debugfs_init(struct radeon_device *rdev)
 	radeon_mem_types_list[i].show = &ttm_page_alloc_debugfs;
 	radeon_mem_types_list[i].driver_features = 0;
 	radeon_mem_types_list[i++].data = NULL;
-#ifdef CONFIG_SWIOTLB
+#if defined(CONFIG_SWIOTLB) && !defined(CONFIG_CPU_LOONGSON3)
 	if (swiotlb_nr_tbl()) {
 		sprintf(radeon_mem_types_names[i], "ttm_dma_page_pool");
 		radeon_mem_types_list[i].name = radeon_mem_types_names[i];
diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c
index f8187ea..0df71ea 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_util.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_util.c
@@ -472,7 +472,7 @@ pgprot_t ttm_io_prot(uint32_t caching_flags, pgprot_t tmp)
 	else
 		tmp = pgprot_noncached(tmp);
 #endif
-#if defined(__sparc__)
+#if defined(__sparc__) || defined(__mips__)
 	if (!(caching_flags & TTM_PL_FLAG_CACHED))
 		tmp = pgprot_noncached(tmp);
 #endif
diff --git a/include/drm/drm_sarea.h b/include/drm/drm_sarea.h
index ee5389d..1d1a858 100644
--- a/include/drm/drm_sarea.h
+++ b/include/drm/drm_sarea.h
@@ -37,6 +37,8 @@
 /* SAREA area needs to be at least a page */
 #if defined(__alpha__)
 #define SAREA_MAX                       0x2000U
+#elif defined(__mips__)
+#define SAREA_MAX                       0x4000U
 #elif defined(__ia64__)
 #define SAREA_MAX                       0x10000U	/* 64kB */
 #else
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 11/14] ALSA: Make hda sound card usable for Loongson.
  2012-06-15  8:09 [PATCH 00/14] MIPS: Add Loongson-3 based machines support Huacai Chen
                   ` (9 preceding siblings ...)
  2012-06-15  8:09 ` [PATCH 10/14] drm/radeon: Make radeon card usable for Loongson Huacai Chen
@ 2012-06-15  8:09 ` Huacai Chen
  2012-06-15  8:09 ` [PATCH 12/14] MIPS: Loongson 3: Add Loongson-3 SMP support Huacai Chen
                   ` (3 subsequent siblings)
  14 siblings, 0 replies; 34+ messages in thread
From: Huacai Chen @ 2012-06-15  8:09 UTC (permalink / raw)
  To: Ralf Baechle
  Cc: linux-mips, Fuxin Zhang, Zhangjin Wu, Huacai Chen, Hongliang Tao,
	Hua Yan

Lemote A1004(Laptop) and A1205(All-In-One) use Conexant's hda codec,
this patch make it usable:
1, Use 32bit DMA as a workaround.
2, Modify patch_conexant.c to add Lemote specific code.

Signed-off-by: Huacai Chen <chenhc@lemote.com>
Signed-off-by: Hongliang Tao <taohl@lemote.com>
Signed-off-by: Hua Yan <yanh@lemote.com>
---
 include/linux/pci_ids.h        |    2 +
 sound/pci/hda/hda_intel.c      |    5 ++++
 sound/pci/hda/patch_conexant.c |   52 ++++++++++++++++++++++++++++++++++++++-
 3 files changed, 57 insertions(+), 2 deletions(-)

diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
index ab741b0..d8b0a52 100644
--- a/include/linux/pci_ids.h
+++ b/include/linux/pci_ids.h
@@ -2906,3 +2906,5 @@
 #define PCI_DEVICE_ID_XEN_PLATFORM	0x0001
 
 #define PCI_VENDOR_ID_OCZ		0x1b85
+
+#define PCI_VENDOR_ID_LEMOTE		0x1c06
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index 2b6392b..2b73ed4 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -3013,6 +3013,11 @@ static int DELAYED_INIT_MARK azx_first_init(struct azx *chip)
 		gcap &= ~ICH6_GCAP_64OK;
 	}
 
+#ifdef CONFIG_CPU_LOONGSON3
+	/* Workaround: Loongson 3 doesn't support 64-bit DMA */
+	gcap &= ~ICH6_GCAP_64OK;
+#endif
+
 	/* disable buffer size rounding to 128-byte multiples if supported */
 	if (align_buffer_size >= 0)
 		chip->align_buffer_size = !!align_buffer_size;
diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c
index 3acb582..1c8dfb9 100644
--- a/sound/pci/hda/patch_conexant.c
+++ b/sound/pci/hda/patch_conexant.c
@@ -142,6 +142,7 @@ struct conexant_spec {
 	unsigned int thinkpad:1;
 	unsigned int hp_laptop:1;
 	unsigned int asus:1;
+	unsigned int lemote:1;
 	unsigned int pin_eapd_ctrls:1;
 	unsigned int fixup_stereo_dmic:1;
 
@@ -2278,7 +2279,7 @@ static void cxt5066_automic(struct hda_codec *codec)
 		cxt5066_thinkpad_automic(codec);
 	else if (spec->hp_laptop)
 		cxt5066_hp_laptop_automic(codec);
-	else if (spec->asus)
+	else if (spec->asus || spec->lemote)
 		cxt5066_asus_automic(codec);
 }
 
@@ -2911,6 +2912,32 @@ static const struct hda_verb cxt5066_init_verbs_hp_laptop[] = {
 	{ } /* end */
 };
 
+static struct hda_verb cxt5066_init_verbs_lemote[] = {
+	{0x14, AC_VERB_SET_CONNECT_SEL, 0x0}, /* ADC1: Connection index: 0 */
+	{0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
+	{0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT},
+
+	/* DAC2: unused */
+	{0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
+
+	/* ADC2, ADC3: unused */
+	{0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
+	{0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
+	{0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
+	{0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
+	{0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
+	{0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
+	{0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
+	{0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
+
+	/* Disable digital microphone port */
+	{0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
+
+	/* Disable SPDIF */
+	{0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
+	{ } /* end */
+};
+
 /* initialize jack-sensing, too */
 static int cxt5066_init(struct hda_codec *codec)
 {
@@ -2948,6 +2975,8 @@ enum {
 	CXT5066_THINKPAD,	/* Lenovo ThinkPad T410s, others? */
 	CXT5066_ASUS,		/* Asus K52JU, Lenovo G560 - Int mic at 0x1a and Ext mic at 0x1b */
 	CXT5066_HP_LAPTOP,      /* HP Laptop */
+	CXT5066_LEMOTE_A1004,   /* Lemote Laptop A1004 */
+	CXT5066_LEMOTE_A1205,   /* Lemote All-In-One A1205 */
 	CXT5066_AUTO,		/* BIOS auto-parser */
 	CXT5066_MODELS
 };
@@ -2961,6 +2990,8 @@ static const char * const cxt5066_models[CXT5066_MODELS] = {
 	[CXT5066_THINKPAD]	= "thinkpad",
 	[CXT5066_ASUS]		= "asus",
 	[CXT5066_HP_LAPTOP]	= "hp-laptop",
+	[CXT5066_LEMOTE_A1004]  = "lemote-laptop-a1004",
+	[CXT5066_LEMOTE_A1205]  = "lemote-aio-a1205",
 	[CXT5066_AUTO]		= "auto",
 };
 
@@ -2993,6 +3024,8 @@ static const struct snd_pci_quirk cxt5066_cfg_tbl[] = {
 	SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo U350", CXT5066_ASUS),
 	SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo G560", CXT5066_ASUS),
 	SND_PCI_QUIRK(0x17aa, 0x3938, "Lenovo G565", CXT5066_AUTO),
+	SND_PCI_QUIRK(0x1c06, 0x2011, "Lemote A1004", CXT5066_LEMOTE_A1004),
+	SND_PCI_QUIRK(0x1c06, 0x2012, "Lemote A1205", CXT5066_LEMOTE_A1205),
 	SND_PCI_QUIRK(0x1b0a, 0x2092, "CyberpowerPC Gamer Xplorer N57001", CXT5066_AUTO),
 	{}
 };
@@ -3073,7 +3106,22 @@ static int patch_cxt5066(struct hda_codec *codec)
 		spec->port_d_mode = 0;
 		spec->mic_boost = 3; /* default 30dB gain */
 		break;
-
+	case CXT5066_LEMOTE_A1004:
+	case CXT5066_LEMOTE_A1205:
+		codec->patch_ops.init = cxt5066_init;
+		codec->patch_ops.unsol_event = cxt5066_unsol_event;
+		spec->init_verbs[spec->num_init_verbs] =
+			cxt5066_init_verbs_lemote;
+		spec->num_init_verbs++;
+		spec->lemote = 1;
+		spec->mixers[spec->num_mixers++] = cxt5066_mixer_master;
+		spec->mixers[spec->num_mixers++] = cxt5066_mixers;
+		/* no S/PDIF out */
+		/* input source automatically selected */
+		spec->input_mux = NULL;
+		spec->port_d_mode = 0;
+		spec->mic_boost = 3; /* default 30dB gain */
+		break;
 	case CXT5066_OLPC_XO_1_5:
 		codec->patch_ops.init = cxt5066_olpc_init;
 		codec->patch_ops.unsol_event = cxt5066_olpc_unsol_event;
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 12/14] MIPS: Loongson 3: Add Loongson-3 SMP support.
  2012-06-15  8:09 [PATCH 00/14] MIPS: Add Loongson-3 based machines support Huacai Chen
                   ` (10 preceding siblings ...)
  2012-06-15  8:09 ` [PATCH 11/14] ALSA: Make hda sound " Huacai Chen
@ 2012-06-15  8:09 ` Huacai Chen
  2012-06-15  8:10 ` [PATCH 13/14] MIPS: Loongson 3: Add CPU Hotplug support Huacai Chen
                   ` (2 subsequent siblings)
  14 siblings, 0 replies; 34+ messages in thread
From: Huacai Chen @ 2012-06-15  8:09 UTC (permalink / raw)
  To: Ralf Baechle
  Cc: linux-mips, Fuxin Zhang, Zhangjin Wu, Huacai Chen, Hongliang Tao,
	Hua Yan

IPI registers of Loongson-3 include IPI_SET, IPI_CLEAR, IPI_STATUS,
IPI_EN and IPI_MAILBOX_BUF. Each bit of IPI_STATUS indicate a type of
IPI and IPI_EN indicate whether the IPI is enabled. The sender write 1
to IPI_SET bits generate IPIs in IPI_STATUS, and receiver write 1 to
bits of IPI_CLEAR to clear IPIs. IPI_MAILBOX_BUF are used to deliver
more information about IPIs.

Signed-off-by: Huacai Chen <chenhc@lemote.com>
Signed-off-by: Hongliang Tao <taohl@lemote.com>
Signed-off-by: Hua Yan <yanh@lemote.com>
---
 arch/mips/loongson/common/init.c       |    5 +
 arch/mips/loongson/loongson-3/Makefile |    2 +
 arch/mips/loongson/loongson-3/smp.c    |  278 ++++++++++++++++++++++++++++++++
 arch/mips/loongson/loongson-3/smp.h    |   24 +++
 4 files changed, 309 insertions(+), 0 deletions(-)
 create mode 100644 arch/mips/loongson/loongson-3/smp.c
 create mode 100644 arch/mips/loongson/loongson-3/smp.h

diff --git a/arch/mips/loongson/common/init.c b/arch/mips/loongson/common/init.c
index 1c29b19..30d20ad 100644
--- a/arch/mips/loongson/common/init.c
+++ b/arch/mips/loongson/common/init.c
@@ -12,6 +12,8 @@
 
 #include <loongson.h>
 
+extern struct plat_smp_ops loongson3_smp_ops;
+
 /* Loongson CPU address windows config space base address */
 unsigned long __maybe_unused _loongson_addrwincfg_base;
 
@@ -33,6 +35,9 @@ void __init prom_init(void)
 
 	/*init the uart base address */
 	prom_init_uart_base();
+#if defined(CONFIG_SMP)
+	register_smp_ops(&loongson3_smp_ops);
+#endif
 }
 
 void __init prom_free_prom_memory(void)
diff --git a/arch/mips/loongson/loongson-3/Makefile b/arch/mips/loongson/loongson-3/Makefile
index b9968cd..70152b2 100644
--- a/arch/mips/loongson/loongson-3/Makefile
+++ b/arch/mips/loongson/loongson-3/Makefile
@@ -2,3 +2,5 @@
 # Makefile for Loongson-3 family machines
 #
 obj-y			+= irq.o
+
+obj-$(CONFIG_SMP)	+= smp.o
diff --git a/arch/mips/loongson/loongson-3/smp.c b/arch/mips/loongson/loongson-3/smp.c
new file mode 100644
index 0000000..8923117
--- /dev/null
+++ b/arch/mips/loongson/loongson-3/smp.c
@@ -0,0 +1,278 @@
+/*
+ * Copyright (C) 2010, 2011, 2012, Lemote, Inc.
+ * Author: Chen Huacai, chenhc@lemote.com
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+#include <linux/init.h>
+#include <linux/cpu.h>
+#include <linux/sched.h>
+#include <linux/smp.h>
+#include <linux/cpufreq.h>
+#include <asm/processor.h>
+#include <asm/time.h>
+#include <asm/clock.h>
+#include <asm/tlbflush.h>
+#include <loongson.h>
+
+#include "smp.h"
+
+/* write a 64bit value to ipi register */
+void loongson3_ipi_write64(uint64_t action, void * addr)
+{
+	*((uint64_t *)addr) = action;
+};
+
+/* read a 64bit value from ipi register */
+uint64_t loongson3_ipi_read64(void * addr)
+{
+	return *((uint64_t *)addr);
+};
+
+/* write a 32bit value to ipi register */
+void loongson3_ipi_write32(uint32_t action, void * addr)
+{
+	*((uint32_t *)addr) = action;
+};
+
+/* read a 32bit value from ipi register */
+uint32_t loongson3_ipi_read32(void * addr)
+{
+	return *((uint32_t *)addr);
+};
+
+static void *ipi_set0_regs[] = {
+	(void *)(smp_core_group0_base + smp_core0_offset + SET0),
+	(void *)(smp_core_group0_base + smp_core1_offset + SET0),
+	(void *)(smp_core_group0_base + smp_core2_offset + SET0),
+	(void *)(smp_core_group0_base + smp_core3_offset + SET0),
+	(void *)(smp_core_group1_base + smp_core0_offset + SET0),
+	(void *)(smp_core_group1_base + smp_core1_offset + SET0),
+	(void *)(smp_core_group1_base + smp_core2_offset + SET0),
+	(void *)(smp_core_group1_base + smp_core3_offset + SET0),
+	(void *)(smp_core_group2_base + smp_core0_offset + SET0),
+	(void *)(smp_core_group2_base + smp_core1_offset + SET0),
+	(void *)(smp_core_group2_base + smp_core2_offset + SET0),
+	(void *)(smp_core_group2_base + smp_core3_offset + SET0),
+	(void *)(smp_core_group3_base + smp_core0_offset + SET0),
+	(void *)(smp_core_group3_base + smp_core1_offset + SET0),
+	(void *)(smp_core_group3_base + smp_core2_offset + SET0),
+	(void *)(smp_core_group3_base + smp_core3_offset + SET0),
+};
+
+static void *ipi_clear0_regs[] = {
+	(void *)(smp_core_group0_base + smp_core0_offset + CLEAR0),
+	(void *)(smp_core_group0_base + smp_core1_offset + CLEAR0),
+	(void *)(smp_core_group0_base + smp_core2_offset + CLEAR0),
+	(void *)(smp_core_group0_base + smp_core3_offset + CLEAR0),
+	(void *)(smp_core_group1_base + smp_core0_offset + CLEAR0),
+	(void *)(smp_core_group1_base + smp_core1_offset + CLEAR0),
+	(void *)(smp_core_group1_base + smp_core2_offset + CLEAR0),
+	(void *)(smp_core_group1_base + smp_core3_offset + CLEAR0),
+	(void *)(smp_core_group2_base + smp_core0_offset + CLEAR0),
+	(void *)(smp_core_group2_base + smp_core1_offset + CLEAR0),
+	(void *)(smp_core_group2_base + smp_core2_offset + CLEAR0),
+	(void *)(smp_core_group2_base + smp_core3_offset + CLEAR0),
+	(void *)(smp_core_group3_base + smp_core0_offset + CLEAR0),
+	(void *)(smp_core_group3_base + smp_core1_offset + CLEAR0),
+	(void *)(smp_core_group3_base + smp_core2_offset + CLEAR0),
+	(void *)(smp_core_group3_base + smp_core3_offset + CLEAR0),
+};
+
+static void *ipi_status_regs0[] = {
+	(void *)(smp_core_group0_base + smp_core0_offset + STATUS0),
+	(void *)(smp_core_group0_base + smp_core1_offset + STATUS0),
+	(void *)(smp_core_group0_base + smp_core2_offset + STATUS0),
+	(void *)(smp_core_group0_base + smp_core3_offset + STATUS0),
+	(void *)(smp_core_group1_base + smp_core0_offset + STATUS0),
+	(void *)(smp_core_group1_base + smp_core1_offset + STATUS0),
+	(void *)(smp_core_group1_base + smp_core2_offset + STATUS0),
+	(void *)(smp_core_group1_base + smp_core3_offset + STATUS0),
+	(void *)(smp_core_group2_base + smp_core0_offset + STATUS0),
+	(void *)(smp_core_group2_base + smp_core1_offset + STATUS0),
+	(void *)(smp_core_group2_base + smp_core2_offset + STATUS0),
+	(void *)(smp_core_group2_base + smp_core3_offset + STATUS0),
+	(void *)(smp_core_group3_base + smp_core0_offset + STATUS0),
+	(void *)(smp_core_group3_base + smp_core1_offset + STATUS0),
+	(void *)(smp_core_group3_base + smp_core2_offset + STATUS0),
+	(void *)(smp_core_group3_base + smp_core3_offset + STATUS0),
+};
+
+static void *ipi_en0_regs[] = {
+	(void *)(smp_core_group0_base + smp_core0_offset + EN0),
+	(void *)(smp_core_group0_base + smp_core1_offset + EN0),
+	(void *)(smp_core_group0_base + smp_core2_offset + EN0),
+	(void *)(smp_core_group0_base + smp_core3_offset + EN0),
+	(void *)(smp_core_group1_base + smp_core0_offset + EN0),
+	(void *)(smp_core_group1_base + smp_core1_offset + EN0),
+	(void *)(smp_core_group1_base + smp_core2_offset + EN0),
+	(void *)(smp_core_group1_base + smp_core3_offset + EN0),
+	(void *)(smp_core_group2_base + smp_core0_offset + EN0),
+	(void *)(smp_core_group2_base + smp_core1_offset + EN0),
+	(void *)(smp_core_group2_base + smp_core2_offset + EN0),
+	(void *)(smp_core_group2_base + smp_core3_offset + EN0),
+	(void *)(smp_core_group3_base + smp_core0_offset + EN0),
+	(void *)(smp_core_group3_base + smp_core1_offset + EN0),
+	(void *)(smp_core_group3_base + smp_core2_offset + EN0),
+	(void *)(smp_core_group3_base + smp_core3_offset + EN0),
+};
+
+static volatile void *ipi_mailbox_buf[] = {
+	(void *)(smp_core_group0_base + smp_core0_offset + BUF),
+	(void *)(smp_core_group0_base + smp_core1_offset + BUF),
+	(void *)(smp_core_group0_base + smp_core2_offset + BUF),
+	(void *)(smp_core_group0_base + smp_core3_offset + BUF),
+	(void *)(smp_core_group1_base + smp_core0_offset + BUF),
+	(void *)(smp_core_group1_base + smp_core1_offset + BUF),
+	(void *)(smp_core_group1_base + smp_core2_offset + BUF),
+	(void *)(smp_core_group1_base + smp_core3_offset + BUF),
+	(void *)(smp_core_group2_base + smp_core0_offset + BUF),
+	(void *)(smp_core_group2_base + smp_core1_offset + BUF),
+	(void *)(smp_core_group2_base + smp_core2_offset + BUF),
+	(void *)(smp_core_group2_base + smp_core3_offset + BUF),
+	(void *)(smp_core_group3_base + smp_core0_offset + BUF),
+	(void *)(smp_core_group3_base + smp_core1_offset + BUF),
+	(void *)(smp_core_group3_base + smp_core2_offset + BUF),
+	(void *)(smp_core_group3_base + smp_core3_offset + BUF),
+};
+
+/*
+ * Simple enough, just poke the appropriate ipi register
+ */
+static void loongson3_send_ipi_single(int cpu, unsigned int action)
+{
+	loongson3_ipi_write32((u32)action, ipi_set0_regs[cpu]);
+}
+
+static void loongson3_send_ipi_mask(const struct cpumask *mask, unsigned int action)
+{
+	unsigned int i;
+
+	for_each_cpu(i, mask)
+		loongson3_send_ipi_single(i, action);
+}
+
+void loongson3_ipi_interrupt(struct pt_regs *regs)
+{
+	int cpu = smp_processor_id();
+	unsigned int action;
+
+	/* Load the ipi register to figure out what we're supposed to do */
+	action = loongson3_ipi_read32(ipi_status_regs0[cpu]);
+
+	/* Clear the ipi register to clear the interrupt */
+	loongson3_ipi_write32((u32)action, ipi_clear0_regs[cpu]);
+
+	if (action & SMP_RESCHEDULE_YOURSELF) {
+		scheduler_ipi();
+	}
+
+	if (action & SMP_CALL_FUNCTION) {
+		smp_call_function_interrupt();
+	}
+}
+
+/*
+ * SMP init and finish on secondary CPUs
+ */
+void __cpuinit loongson3_init_secondary(void)
+{
+	int i;
+	unsigned int imask = STATUSF_IP7 | STATUSF_IP6 | STATUSF_IP5 |
+			     STATUSF_IP4 | STATUSF_IP3 | STATUSF_IP2;
+
+	/* Set interrupt mask, but don't enable */
+	change_c0_status(ST0_IM, imask);
+
+	for (i = 0; i < NR_CPUS; i++) {
+		loongson3_ipi_write32(0xffffffff, ipi_en0_regs[i]);
+	}
+}
+
+void __cpuinit loongson3_smp_finish(void)
+{
+	write_c0_compare(read_c0_count() + mips_hpt_frequency/HZ);
+	local_irq_enable();
+	loongson3_ipi_write64(0, (void *)(ipi_mailbox_buf[smp_processor_id()]+0x0));
+	printk(KERN_INFO "CPU#%d finished, CP0_ST=%x\n",
+			smp_processor_id(), read_c0_status());
+}
+
+void __init loongson3_smp_setup(void)
+{
+	int i, num;
+
+	init_cpu_possible(cpu_none_mask);
+	set_cpu_possible(0, true);
+
+	__cpu_number_map[0] = 0;
+	__cpu_logical_map[0] = 0;
+
+	/* For unified kernel, NR_CPUS is the maximum possible value,
+	 * nr_cpus_loongson is the really present value */
+	for (i = 1, num = 0; i < nr_cpus_loongson; i++) {
+		set_cpu_possible(i, true);
+		__cpu_number_map[i] = ++num;
+		__cpu_logical_map[num] = i;
+	}
+	printk(KERN_INFO "Detected %i available secondary CPU(s)\n", num);
+}
+
+void __init loongson3_prepare_cpus(unsigned int max_cpus)
+{
+}
+
+/*
+ * Setup the PC, SP, and GP of a secondary processor and start it runing!
+ */
+void __cpuinit loongson3_boot_secondary(int cpu, struct task_struct *idle)
+{
+	volatile unsigned long startargs[4];
+
+	printk(KERN_INFO "Booting CPU#%d...\n", cpu);
+
+	/* startargs[] are initial PC, SP and GP for secondary CPU */
+	startargs[0] = (unsigned long)&smp_bootstrap;
+	startargs[1] = (unsigned long)__KSTK_TOS(idle);
+	startargs[2] = (unsigned long)task_thread_info(idle);
+	startargs[3] = 0;
+
+	printk(KERN_DEBUG "CPU#%d, func_pc=%lx, sp=%lx, gp=%lx\n",
+			cpu, startargs[0], startargs[1], startargs[2]);
+
+	loongson3_ipi_write64(startargs[3], (void *)(ipi_mailbox_buf[cpu]+0x18));
+	loongson3_ipi_write64(startargs[2], (void *)(ipi_mailbox_buf[cpu]+0x10));
+	loongson3_ipi_write64(startargs[1], (void *)(ipi_mailbox_buf[cpu]+0x8));
+	loongson3_ipi_write64(startargs[0], (void *)(ipi_mailbox_buf[cpu]+0x0));
+}
+
+/*
+ * Final cleanup after all secondaries booted
+ */
+void __init loongson3_cpus_done(void)
+{
+}
+
+struct plat_smp_ops loongson3_smp_ops = {
+	.send_ipi_single = loongson3_send_ipi_single,
+	.send_ipi_mask = loongson3_send_ipi_mask,
+	.init_secondary = loongson3_init_secondary,
+	.smp_finish = loongson3_smp_finish,
+	.cpus_done = loongson3_cpus_done,
+	.boot_secondary = loongson3_boot_secondary,
+	.smp_setup = loongson3_smp_setup,
+	.prepare_cpus = loongson3_prepare_cpus,
+};
diff --git a/arch/mips/loongson/loongson-3/smp.h b/arch/mips/loongson/loongson-3/smp.h
new file mode 100644
index 0000000..dc9ce69
--- /dev/null
+++ b/arch/mips/loongson/loongson-3/smp.h
@@ -0,0 +1,24 @@
+/* for Loongson-3A smp support */
+
+/* 4 groups(nodes) in maximum in numa case */
+#define  smp_core_group0_base    0x900000003ff01000
+#define  smp_core_group1_base    0x900010003ff01000
+#define  smp_core_group2_base    0x900020003ff01000
+#define  smp_core_group3_base    0x900030003ff01000
+
+/* 4 cores in each group(node) */
+#define  smp_core0_offset  0x000
+#define  smp_core1_offset  0x100
+#define  smp_core2_offset  0x200
+#define  smp_core3_offset  0x300
+
+/* ipi registers offsets */
+#define  STATUS0  0x00
+#define  EN0      0x04
+#define  SET0     0x08
+#define  CLEAR0   0x0c
+#define  STATUS1  0x10
+#define  MASK1    0x14
+#define  SET1     0x18
+#define  CLEAR1   0x1c
+#define  BUF      0x20
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 13/14] MIPS: Loongson 3: Add CPU Hotplug support.
  2012-06-15  8:09 [PATCH 00/14] MIPS: Add Loongson-3 based machines support Huacai Chen
                   ` (11 preceding siblings ...)
  2012-06-15  8:09 ` [PATCH 12/14] MIPS: Loongson 3: Add Loongson-3 SMP support Huacai Chen
@ 2012-06-15  8:10 ` Huacai Chen
  2012-06-15  8:10 ` [PATCH 14/14] MIPS: Loongson: Add a Loongson 3 default config file Huacai Chen
  2012-06-15 13:10 ` [PATCH 00/14] MIPS: Add Loongson-3 based machines support LIU Qi
  14 siblings, 0 replies; 34+ messages in thread
From: Huacai Chen @ 2012-06-15  8:10 UTC (permalink / raw)
  To: Ralf Baechle
  Cc: linux-mips, Fuxin Zhang, Zhangjin Wu, Huacai Chen, Hongliang Tao,
	Hua Yan

Tips of Loongson's CPU Hotplug:
1, To fully shutdown a core in Loongson 3, the target core should go to
   CKSEG1 and flush all L2 cache entries at first. Then, another core
   (usually Core 0) can safely disable the clock of the target core. So
   play_dead() call loongson3_play_dead() via CKSEG1 (both uncached and
   unmmaped).
2, The default clocksource of Loongson is MIPS. Since clock source is a
   global device, timekeeping need the CP0' Count registers of each core
   be synchronous. Thus, when a core is up, we use a SMP_ASK_C0COUNT IPI
   to ask Core-0's Count.

Signed-off-by: Huacai Chen <chenhc@lemote.com>
Signed-off-by: Hongliang Tao <taohl@lemote.com>
Signed-off-by: Hua Yan <yanh@lemote.com>
---
 arch/mips/Kconfig                              |    1 +
 arch/mips/include/asm/mach-loongson/loongson.h |    6 +-
 arch/mips/include/asm/smp.h                    |    1 +
 arch/mips/kernel/process.c                     |    4 +-
 arch/mips/loongson/loongson-3/irq.c            |   10 ++
 arch/mips/loongson/loongson-3/smp.c            |  181 +++++++++++++++++++++++-
 6 files changed, 194 insertions(+), 9 deletions(-)

diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index da2b1e5..72a0bf1 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -256,6 +256,7 @@ config LASAT
 config MACH_LOONGSON
 	bool "Loongson family of machines"
 	select SYS_SUPPORTS_ZBOOT
+	select SYS_SUPPORTS_HOTPLUG_CPU
 	help
 	  This enables the support of Loongson family of machines.
 
diff --git a/arch/mips/include/asm/mach-loongson/loongson.h b/arch/mips/include/asm/mach-loongson/loongson.h
index 16d0924..fe8995c 100644
--- a/arch/mips/include/asm/mach-loongson/loongson.h
+++ b/arch/mips/include/asm/mach-loongson/loongson.h
@@ -249,6 +249,9 @@ static inline void do_perfcnt_IRQ(void)
 #define LOONGSON_PXARB_CFG		LOONGSON_REG(LOONGSON_REGBASE + 0x68)
 #define LOONGSON_PXARB_STATUS		LOONGSON_REG(LOONGSON_REGBASE + 0x6c)
 
+/* Chip Config */
+#define LOONGSON_CHIPCFG0		LOONGSON_REG(LOONGSON_REGBASE + 0x80)
+
 /* pcimap */
 
 #define LOONGSON_PCIMAP_PCIMAP_LO0	0x0000003f
@@ -265,9 +268,6 @@ static inline void do_perfcnt_IRQ(void)
 #include <linux/cpufreq.h>
 extern void loongson2_cpu_wait(void);
 extern struct cpufreq_frequency_table loongson2_clockmod_table[];
-
-/* Chip Config */
-#define LOONGSON_CHIPCFG0		LOONGSON_REG(LOONGSON_REGBASE + 0x80)
 #endif
 
 /*
diff --git a/arch/mips/include/asm/smp.h b/arch/mips/include/asm/smp.h
index d4fb4d8..a6edbbf 100644
--- a/arch/mips/include/asm/smp.h
+++ b/arch/mips/include/asm/smp.h
@@ -40,6 +40,7 @@ extern int __cpu_logical_map[NR_CPUS];
 #define SMP_CALL_FUNCTION	0x2
 /* Octeon - Tell another core to flush its icache */
 #define SMP_ICACHE_FLUSH	0x4
+#define SMP_ASK_C0COUNT		0x8
 
 extern volatile cpumask_t cpu_callin_map;
 
diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
index e9a5fd7..69b17a9 100644
--- a/arch/mips/kernel/process.c
+++ b/arch/mips/kernel/process.c
@@ -72,9 +72,7 @@ void __noreturn cpu_idle(void)
 			}
 		}
 #ifdef CONFIG_HOTPLUG_CPU
-		if (!cpu_online(cpu) && !cpu_isset(cpu, cpu_callin_map) &&
-		    (system_state == SYSTEM_RUNNING ||
-		     system_state == SYSTEM_BOOTING))
+		if (!cpu_online(cpu) && !cpu_isset(cpu, cpu_callin_map))
 			play_dead();
 #endif
 		rcu_idle_exit();
diff --git a/arch/mips/loongson/loongson-3/irq.c b/arch/mips/loongson/loongson-3/irq.c
index 27aef31..83f84e6 100644
--- a/arch/mips/loongson/loongson-3/irq.c
+++ b/arch/mips/loongson/loongson-3/irq.c
@@ -85,3 +85,13 @@ void __init mach_init_irq(void)
 
 	set_c0_status(STATUSF_IP2 | STATUSF_IP6);
 }
+
+#ifdef CONFIG_HOTPLUG_CPU
+
+void fixup_irqs(void)
+{
+	irq_cpu_offline();
+	clear_c0_status(ST0_IM);
+}
+
+#endif
diff --git a/arch/mips/loongson/loongson-3/smp.c b/arch/mips/loongson/loongson-3/smp.c
index 8923117..f0da4c3 100644
--- a/arch/mips/loongson/loongson-3/smp.c
+++ b/arch/mips/loongson/loongson-3/smp.c
@@ -30,6 +30,9 @@
 
 #include "smp.h"
 
+DEFINE_PER_CPU(int, cpu_state);
+DEFINE_PER_CPU(uint32_t, core0_c0count);
+
 /* write a 64bit value to ipi register */
 void loongson3_ipi_write64(uint64_t action, void * addr)
 {
@@ -167,8 +170,8 @@ static void loongson3_send_ipi_mask(const struct cpumask *mask, unsigned int act
 
 void loongson3_ipi_interrupt(struct pt_regs *regs)
 {
-	int cpu = smp_processor_id();
-	unsigned int action;
+	int i, cpu = smp_processor_id();
+	unsigned int action, c0count;
 
 	/* Load the ipi register to figure out what we're supposed to do */
 	action = loongson3_ipi_read32(ipi_status_regs0[cpu]);
@@ -183,14 +186,24 @@ void loongson3_ipi_interrupt(struct pt_regs *regs)
 	if (action & SMP_CALL_FUNCTION) {
 		smp_call_function_interrupt();
 	}
+
+	if (action & SMP_ASK_C0COUNT) {
+		BUG_ON(cpu != 0);
+		c0count = read_c0_count();
+		for (i=1; i<NR_CPUS; i++)
+			per_cpu(core0_c0count, i) = c0count;
+	}
 }
 
+#define MAX_LOOPS 1250
 /*
  * SMP init and finish on secondary CPUs
  */
 void __cpuinit loongson3_init_secondary(void)
 {
 	int i;
+	uint32_t initcount;
+	unsigned int cpu = smp_processor_id();
 	unsigned int imask = STATUSF_IP7 | STATUSF_IP6 | STATUSF_IP5 |
 			     STATUSF_IP4 | STATUSF_IP3 | STATUSF_IP2;
 
@@ -200,11 +213,24 @@ void __cpuinit loongson3_init_secondary(void)
 	for (i = 0; i < NR_CPUS; i++) {
 		loongson3_ipi_write32(0xffffffff, ipi_en0_regs[i]);
 	}
+
+	per_cpu(cpu_state, cpu) = CPU_ONLINE;
+
+	i = 0;
+	__get_cpu_var(core0_c0count) = 0;
+	loongson3_send_ipi_single(0, SMP_ASK_C0COUNT);
+	while (!__get_cpu_var(core0_c0count))
+		i++;
+
+	if (i > MAX_LOOPS)
+		i = MAX_LOOPS;
+	initcount = __get_cpu_var(core0_c0count) + i;
+	write_c0_count(initcount);
+	write_c0_compare(initcount + mips_hpt_frequency/HZ);
 }
 
 void __cpuinit loongson3_smp_finish(void)
 {
-	write_c0_compare(read_c0_count() + mips_hpt_frequency/HZ);
 	local_irq_enable();
 	loongson3_ipi_write64(0, (void *)(ipi_mailbox_buf[smp_processor_id()]+0x0));
 	printk(KERN_INFO "CPU#%d finished, CP0_ST=%x\n",
@@ -233,6 +259,8 @@ void __init loongson3_smp_setup(void)
 
 void __init loongson3_prepare_cpus(unsigned int max_cpus)
 {
+	init_cpu_present(cpu_possible_mask);
+	per_cpu(cpu_state, smp_processor_id()) = CPU_ONLINE;
 }
 
 /*
@@ -266,6 +294,149 @@ void __init loongson3_cpus_done(void)
 {
 }
 
+#ifdef CONFIG_HOTPLUG_CPU
+
+static DEFINE_SPINLOCK(smp_reserve_lock);
+
+extern void fixup_irqs(void);
+
+static int loongson3_cpu_disable(void)
+{
+	extern void (*flush_cache_all)(void);
+	unsigned int cpu = smp_processor_id();
+
+	if (cpu == 0)
+		return -EBUSY;
+
+	spin_lock(&smp_reserve_lock);
+	set_cpu_online(cpu, false);
+	cpu_clear(cpu, cpu_callin_map);
+	local_irq_disable();
+	fixup_irqs();
+	local_irq_enable();
+	flush_cache_all();
+	local_flush_tlb_all();
+	spin_unlock(&smp_reserve_lock);
+
+	return 0;
+}
+
+
+static void loongson3_cpu_die(unsigned int cpu)
+{
+	while (per_cpu(cpu_state, cpu) != CPU_DEAD)
+		cpu_relax();
+
+	mb();
+}
+
+/* To shutdown a core in Loongson 3, the target core should go to CKSEG1 and
+ * flush all L2 entries at first. Then, another core (usually Core 0) can
+ * safely disable the clock of the target core. loongson3_play_dead() is
+ * called via CKSEG1 (uncached and unmmaped) */
+void loongson3_play_dead(int *state_addr)
+{
+	__asm__ __volatile__(
+		"      .set push                         \n"
+		"      .set noreorder                    \n"
+		"      li $t0, 0x80000000                \n" /* KSEG0 */
+		"      li $t1, 512                       \n" /* num of L2 entries */
+		"flush_loop:                             \n" /* flush L2 */
+		"      cache 0, 0($t0)                   \n" /* ICache */
+		"      cache 0, 1($t0)                   \n"
+		"      cache 0, 2($t0)                   \n"
+		"      cache 0, 3($t0)                   \n"
+		"      cache 1, 0($t0)                   \n" /* DCache */
+		"      cache 1, 1($t0)                   \n"
+		"      cache 1, 2($t0)                   \n"
+		"      cache 1, 3($t0)                   \n"
+		"      addiu $t0, $t0, 0x20              \n"
+		"      bnez  $t1, flush_loop             \n"
+		"      addiu $t1, $t1, -1                \n"
+		"      li    $t0, 0x7                    \n" /* *state_addr = CPU_DEAD; */
+		"      sw    $t0, 0($a0)                 \n"
+		"      sync                              \n"
+		"      cache 21, 0($a0)                  \n" /* flush entry of *state_addr */
+		"      .set pop                          \n");
+
+	__asm__ __volatile__(
+		"      .set push                         \n"
+		"      .set noreorder                    \n"
+		"      .set mips64                       \n"
+		"      mfc0  $t2, $15, 1                 \n"
+		"      andi  $t2, 0x3ff                  \n"
+		"      .set mips3                        \n"
+		"      dli   $t0, 0x900000003ff01000     \n"
+		"      andi  $t3, $t2, 0x3               \n"
+		"      sll   $t3, 8                      \n"  /* get cpu id */
+		"      or    $t0, $t0, $t3               \n"
+		"      andi  $t1, $t2, 0xc               \n"
+		"      dsll  $t1, 42                     \n"  /* get node id */
+		"      or    $t0, $t0, $t1               \n"
+		"wait_for_init:                          \n"
+		"      li    $a0, 0x100                  \n"
+		"idle_loop:                              \n"
+		"      bnez  $a0, idle_loop              \n"
+		"      addiu $a0, -1                     \n"
+		"      lw    $v0, 0x20($t0)              \n"  /* get PC via mailbox */
+		"      nop                               \n"
+		"      beqz  $v0, wait_for_init          \n"
+		"      nop                               \n"
+		"      ld    $sp, 0x28($t0)              \n"  /* get SP via mailbox */
+		"      nop                               \n"
+		"      ld    $gp, 0x30($t0)              \n"  /* get GP via mailbox */
+		"      nop                               \n"
+		"      ld    $a1, 0x38($t0)              \n"
+		"      nop                               \n"
+		"      jr  $v0                           \n"  /* jump to initial PC */
+		"      nop                               \n"
+		"      .set pop                          \n");
+}
+
+void play_dead(void)
+{
+	int *state_addr;
+	unsigned int cpu = smp_processor_id();
+	void (*play_dead_at_ckseg1)(int *);
+
+	idle_task_exit();
+	play_dead_at_ckseg1 = (void *)CKSEG1ADDR((unsigned long)loongson3_play_dead);
+	state_addr = &per_cpu(cpu_state, cpu);
+	mb();
+	play_dead_at_ckseg1(state_addr);
+}
+
+#define CPU_POST_DEAD_FROZEN	(CPU_POST_DEAD | CPU_TASKS_FROZEN)
+static int __cpuinit loongson3_cpu_callback(struct notifier_block *nfb,
+	unsigned long action, void *hcpu)
+{
+	unsigned int cpu = (unsigned long)hcpu;
+
+	switch (action) {
+	case CPU_POST_DEAD:
+	case CPU_POST_DEAD_FROZEN:
+		printk(KERN_INFO "Disable clock for CPU#%d\n", cpu);
+		LOONGSON_CHIPCFG0 &= ~(1 << (12 + cpu));
+		break;
+	case CPU_UP_PREPARE:
+	case CPU_UP_PREPARE_FROZEN:
+		printk(KERN_INFO "Enable clock for CPU#%d\n", cpu);
+		LOONGSON_CHIPCFG0 |= 1 << (12 + cpu);
+		break;
+	}
+
+	return NOTIFY_OK;
+}
+
+static int __cpuinit register_loongson3_notifier(void)
+{
+	hotcpu_notifier(loongson3_cpu_callback, 0);
+	return 0;
+}
+early_initcall(register_loongson3_notifier);
+
+#endif
+
 struct plat_smp_ops loongson3_smp_ops = {
 	.send_ipi_single = loongson3_send_ipi_single,
 	.send_ipi_mask = loongson3_send_ipi_mask,
@@ -275,4 +446,8 @@ struct plat_smp_ops loongson3_smp_ops = {
 	.boot_secondary = loongson3_boot_secondary,
 	.smp_setup = loongson3_smp_setup,
 	.prepare_cpus = loongson3_prepare_cpus,
+#ifdef CONFIG_HOTPLUG_CPU
+	.cpu_disable = loongson3_cpu_disable,
+	.cpu_die = loongson3_cpu_die,
+#endif
 };
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 14/14] MIPS: Loongson: Add a Loongson 3 default config file.
  2012-06-15  8:09 [PATCH 00/14] MIPS: Add Loongson-3 based machines support Huacai Chen
                   ` (12 preceding siblings ...)
  2012-06-15  8:10 ` [PATCH 13/14] MIPS: Loongson 3: Add CPU Hotplug support Huacai Chen
@ 2012-06-15  8:10 ` Huacai Chen
  2012-06-15 14:37   ` LIU Qi
  2012-06-15 13:10 ` [PATCH 00/14] MIPS: Add Loongson-3 based machines support LIU Qi
  14 siblings, 1 reply; 34+ messages in thread
From: Huacai Chen @ 2012-06-15  8:10 UTC (permalink / raw)
  To: Ralf Baechle
  Cc: linux-mips, Fuxin Zhang, Zhangjin Wu, Huacai Chen, Hongliang Tao,
	Hua Yan

Signed-off-by: Huacai Chen <chenhc@lemote.com>
Signed-off-by: Hongliang Tao <taohl@lemote.com>
Signed-off-by: Hua Yan <yanh@lemote.com>
---
 arch/mips/configs/loongson3_defconfig |  704 +++++++++++++++++++++++++++++++++
 1 files changed, 704 insertions(+), 0 deletions(-)
 create mode 100644 arch/mips/configs/loongson3_defconfig

diff --git a/arch/mips/configs/loongson3_defconfig b/arch/mips/configs/loongson3_defconfig
new file mode 100644
index 0000000..02c0139
--- /dev/null
+++ b/arch/mips/configs/loongson3_defconfig
@@ -0,0 +1,704 @@
+CONFIG_MIPS=y
+CONFIG_MACH_LOONGSON=y
+CONFIG_ARCH_SPARSEMEM_ENABLE=y
+CONFIG_IOMMU_HELPER=y
+CONFIG_NEED_SG_DMA_LENGTH=y
+CONFIG_SWIOTLB=y
+CONFIG_LEMOTE_MACH3A=y
+CONFIG_LOONGSON_UART_BASE=y
+CONFIG_LOONGSON_BIGMEM=y
+CONFIG_LOONGSON_MC146818=y
+CONFIG_UEFI_FIRMWARE_INTERFACE=y
+CONFIG_RWSEM_GENERIC_SPINLOCK=y
+CONFIG_GENERIC_HWEIGHT=y
+CONFIG_GENERIC_CALIBRATE_DELAY=y
+CONFIG_GENERIC_CLOCKEVENTS=y
+CONFIG_GENERIC_CMOS_UPDATE=y
+CONFIG_SCHED_OMIT_FRAME_POINTER=y
+CONFIG_CEVT_R4K_LIB=y
+CONFIG_CEVT_R4K=y
+CONFIG_CSRC_R4K_LIB=y
+CONFIG_CSRC_R4K=y
+CONFIG_ARCH_DMA_ADDR_T_64BIT=y
+CONFIG_NEED_DMA_MAP_STATE=y
+CONFIG_SYS_HAS_EARLY_PRINTK=y
+CONFIG_HOTPLUG_CPU=y
+CONFIG_SYS_SUPPORTS_HOTPLUG_CPU=y
+CONFIG_I8259=y
+CONFIG_GENERIC_ISA_DMA=y
+CONFIG_GENERIC_ISA_DMA_SUPPORT_BROKEN=y
+CONFIG_ISA_DMA_API=y
+CONFIG_CPU_LITTLE_ENDIAN=y
+CONFIG_SYS_SUPPORTS_LITTLE_ENDIAN=y
+CONFIG_IRQ_CPU=y
+CONFIG_BOOT_ELF32=y
+CONFIG_MIPS_L1_CACHE_SHIFT=5
+CONFIG_SYS_SUPPORTS_ZBOOT=y
+CONFIG_CPU_LOONGSON3=y
+CONFIG_SYS_HAS_CPU_LOONGSON3=y
+CONFIG_SYS_SUPPORTS_32BIT_KERNEL=y
+CONFIG_SYS_SUPPORTS_64BIT_KERNEL=y
+CONFIG_CPU_SUPPORTS_32BIT_KERNEL=y
+CONFIG_CPU_SUPPORTS_64BIT_KERNEL=y
+CONFIG_64BIT=y
+CONFIG_PAGE_SIZE_16KB=y
+CONFIG_FORCE_MAX_ZONEORDER=11
+CONFIG_BOARD_SCACHE=y
+CONFIG_MIPS_MT_DISABLED=y
+CONFIG_CPU_HAS_WB=y
+CONFIG_CPU_HAS_SYNC=y
+CONFIG_CPU_SUPPORTS_HIGHMEM=y
+CONFIG_SYS_SUPPORTS_HIGHMEM=y
+CONFIG_ARCH_FLATMEM_ENABLE=y
+CONFIG_SELECT_MEMORY_MODEL=y
+CONFIG_SPARSEMEM_MANUAL=y
+CONFIG_SPARSEMEM=y
+CONFIG_HAVE_MEMORY_PRESENT=y
+CONFIG_SPARSEMEM_STATIC=y
+CONFIG_HAVE_MEMBLOCK=y
+CONFIG_HAVE_MEMBLOCK_NODE_MAP=y
+CONFIG_ARCH_DISCARD_MEMBLOCK=y
+CONFIG_PAGEFLAGS_EXTENDED=y
+CONFIG_SPLIT_PTLOCK_CPUS=4
+CONFIG_PHYS_ADDR_T_64BIT=y
+CONFIG_ZONE_DMA_FLAG=0
+CONFIG_VIRT_TO_BUS=y
+CONFIG_KSM=y
+CONFIG_DEFAULT_MMAP_MIN_ADDR=4096
+CONFIG_SMP=y
+CONFIG_SYS_SUPPORTS_SMP=y
+CONFIG_NR_CPUS=4
+CONFIG_TICK_ONESHOT=y
+CONFIG_NO_HZ=y
+CONFIG_HIGH_RES_TIMERS=y
+CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
+CONFIG_HZ_256=y
+CONFIG_SYS_SUPPORTS_ARBIT_HZ=y
+CONFIG_HZ=256
+CONFIG_PREEMPT=y
+CONFIG_PREEMPT_COUNT=y
+CONFIG_KEXEC=y
+CONFIG_SECCOMP=y
+CONFIG_LOCKDEP_SUPPORT=y
+CONFIG_STACKTRACE_SUPPORT=y
+CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
+CONFIG_HAVE_IRQ_WORK=y
+CONFIG_EXPERIMENTAL=y
+CONFIG_INIT_ENV_ARG_LIMIT=32
+CONFIG_CROSS_COMPILE=""
+CONFIG_LOCALVERSION=""
+# CONFIG_LOCALVERSION_AUTO is not set
+CONFIG_HAVE_KERNEL_GZIP=y
+CONFIG_HAVE_KERNEL_BZIP2=y
+CONFIG_HAVE_KERNEL_LZMA=y
+CONFIG_HAVE_KERNEL_LZO=y
+CONFIG_KERNEL_GZIP=y
+CONFIG_DEFAULT_HOSTNAME="(none)"
+CONFIG_SWAP=y
+CONFIG_SYSVIPC=y
+CONFIG_SYSVIPC_SYSCTL=y
+CONFIG_POSIX_MQUEUE=y
+CONFIG_POSIX_MQUEUE_SYSCTL=y
+CONFIG_BSD_PROCESS_ACCT=y
+CONFIG_BSD_PROCESS_ACCT_V3=y
+CONFIG_AUDIT=y
+CONFIG_HAVE_GENERIC_HARDIRQS=y
+CONFIG_GENERIC_HARDIRQS=y
+CONFIG_GENERIC_IRQ_PROBE=y
+CONFIG_GENERIC_IRQ_SHOW=y
+CONFIG_IRQ_FORCED_THREADING=y
+CONFIG_TREE_PREEMPT_RCU=y
+CONFIG_PREEMPT_RCU=y
+CONFIG_RCU_FANOUT=64
+CONFIG_LOG_BUF_SHIFT=14
+CONFIG_CGROUPS=y
+CONFIG_CPUSETS=y
+CONFIG_PROC_PID_CPUSET=y
+CONFIG_RESOURCE_COUNTERS=y
+CONFIG_CGROUP_MEM_RES_CTLR=y
+CONFIG_CGROUP_MEM_RES_CTLR_SWAP=y
+CONFIG_CGROUP_MEM_RES_CTLR_SWAP_ENABLED=y
+CONFIG_CGROUP_SCHED=y
+CONFIG_FAIR_GROUP_SCHED=y
+CONFIG_BLK_CGROUP=y
+CONFIG_SCHED_AUTOGROUP=y
+CONFIG_MM_OWNER=y
+CONFIG_SYSFS_DEPRECATED=y
+CONFIG_RELAY=y
+CONFIG_BLK_DEV_INITRD=y
+CONFIG_INITRAMFS_SOURCE=""
+CONFIG_RD_GZIP=y
+CONFIG_CC_OPTIMIZE_FOR_SIZE=y
+CONFIG_SYSCTL=y
+CONFIG_ANON_INODES=y
+CONFIG_EXPERT=y
+CONFIG_SYSCTL_SYSCALL=y
+CONFIG_KALLSYMS=y
+CONFIG_HOTPLUG=y
+CONFIG_PRINTK=y
+CONFIG_BUG=y
+CONFIG_BASE_FULL=y
+CONFIG_FUTEX=y
+CONFIG_EPOLL=y
+CONFIG_SIGNALFD=y
+CONFIG_TIMERFD=y
+CONFIG_EVENTFD=y
+CONFIG_SHMEM=y
+CONFIG_AIO=y
+CONFIG_EMBEDDED=y
+CONFIG_HAVE_PERF_EVENTS=y
+CONFIG_PERF_USE_VMALLOC=y
+CONFIG_VM_EVENT_COUNTERS=y
+CONFIG_PCI_QUIRKS=y
+CONFIG_SLUB_DEBUG=y
+CONFIG_COMPAT_BRK=y
+CONFIG_SLUB=y
+CONFIG_HAVE_OPROFILE=y
+CONFIG_HAVE_SYSCALL_WRAPPERS=y
+CONFIG_HAVE_KPROBES=y
+CONFIG_HAVE_KRETPROBES=y
+CONFIG_HAVE_DMA_ATTRS=y
+CONFIG_USE_GENERIC_SMP_HELPERS=y
+CONFIG_HAVE_DMA_API_DEBUG=y
+CONFIG_HAVE_ARCH_JUMP_LABEL=y
+CONFIG_ARCH_WANT_OLD_COMPAT_IPC=y
+CONFIG_HAVE_GENERIC_DMA_COHERENT=y
+CONFIG_SLABINFO=y
+CONFIG_RT_MUTEXES=y
+CONFIG_BASE_SMALL=0
+CONFIG_MODULES=y
+CONFIG_MODULE_UNLOAD=y
+CONFIG_MODULE_FORCE_UNLOAD=y
+CONFIG_STOP_MACHINE=y
+CONFIG_BLOCK=y
+CONFIG_BLK_DEV_BSG=y
+CONFIG_BLK_DEV_BSGLIB=y
+CONFIG_PARTITION_ADVANCED=y
+CONFIG_MSDOS_PARTITION=y
+CONFIG_BLOCK_COMPAT=y
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
+CONFIG_CFQ_GROUP_IOSCHED=y
+CONFIG_DEFAULT_CFQ=y
+CONFIG_DEFAULT_IOSCHED="cfq"
+CONFIG_UNINLINE_SPIN_UNLOCK=y
+CONFIG_MUTEX_SPIN_ON_OWNER=y
+CONFIG_HW_HAS_PCI=y
+CONFIG_PCI=y
+CONFIG_HT_PCI=y
+CONFIG_PCI_DOMAINS=y
+CONFIG_ISA=y
+CONFIG_MMU=y
+CONFIG_ZONE_DMA32=y
+CONFIG_HOTPLUG_PCI=y
+CONFIG_HOTPLUG_PCI_SHPC=m
+CONFIG_BINFMT_ELF=y
+CONFIG_ARCH_BINFMT_ELF_RANDOMIZE_PIE=y
+CONFIG_MIPS32_COMPAT=y
+CONFIG_COMPAT=y
+CONFIG_SYSVIPC_COMPAT=y
+CONFIG_MIPS32_O32=y
+CONFIG_MIPS32_N32=y
+CONFIG_BINFMT_ELF32=y
+CONFIG_ARCH_HIBERNATION_POSSIBLE=y
+CONFIG_ARCH_SUSPEND_POSSIBLE=y
+CONFIG_PM_RUNTIME=y
+CONFIG_PM=y
+CONFIG_NET=y
+CONFIG_COMPAT_NETLINK_MESSAGES=y
+CONFIG_PACKET=y
+CONFIG_UNIX=y
+CONFIG_INET=y
+CONFIG_IP_MULTICAST=y
+CONFIG_IP_ADVANCED_ROUTER=y
+CONFIG_IP_MULTIPLE_TABLES=y
+CONFIG_IP_ROUTE_MULTIPATH=y
+CONFIG_IP_ROUTE_VERBOSE=y
+CONFIG_IP_ROUTE_CLASSID=y
+CONFIG_TCP_CONG_CUBIC=y
+CONFIG_DEFAULT_TCP_CONG="cubic"
+CONFIG_NETFILTER=y
+CONFIG_NETFILTER_ADVANCED=y
+CONFIG_NETFILTER_NETLINK=m
+CONFIG_NETFILTER_NETLINK_QUEUE=m
+CONFIG_NETFILTER_NETLINK_LOG=m
+CONFIG_NETFILTER_XTABLES=m
+CONFIG_NETFILTER_XT_MARK=m
+CONFIG_NETFILTER_XT_TARGET_CLASSIFY=m
+CONFIG_NETFILTER_XT_TARGET_HL=m
+CONFIG_NETFILTER_XT_TARGET_MARK=m
+CONFIG_NETFILTER_XT_TARGET_NFQUEUE=m
+CONFIG_NETFILTER_XT_MATCH_COMMENT=m
+CONFIG_NETFILTER_XT_MATCH_DCCP=m
+CONFIG_NETFILTER_XT_MATCH_ECN=m
+CONFIG_NETFILTER_XT_MATCH_ESP=m
+CONFIG_NETFILTER_XT_MATCH_HL=m
+CONFIG_NETFILTER_XT_MATCH_LENGTH=m
+CONFIG_NETFILTER_XT_MATCH_LIMIT=m
+CONFIG_NETFILTER_XT_MATCH_MAC=m
+CONFIG_NETFILTER_XT_MATCH_MARK=m
+CONFIG_NETFILTER_XT_MATCH_MULTIPORT=m
+CONFIG_NETFILTER_XT_MATCH_PKTTYPE=m
+CONFIG_NETFILTER_XT_MATCH_QUOTA=m
+CONFIG_NETFILTER_XT_MATCH_REALM=m
+CONFIG_NETFILTER_XT_MATCH_SCTP=m
+CONFIG_NETFILTER_XT_MATCH_STATISTIC=m
+CONFIG_NETFILTER_XT_MATCH_STRING=m
+CONFIG_NETFILTER_XT_MATCH_TCPMSS=m
+CONFIG_IP_NF_QUEUE=m
+CONFIG_IP_NF_IPTABLES=m
+CONFIG_IP_NF_MATCH_AH=m
+CONFIG_IP_NF_MATCH_ECN=m
+CONFIG_IP_NF_MATCH_TTL=m
+CONFIG_IP_NF_FILTER=m
+CONFIG_IP_NF_TARGET_REJECT=m
+CONFIG_IP_NF_TARGET_ULOG=m
+CONFIG_IP_NF_MANGLE=m
+CONFIG_IP_NF_TARGET_ECN=m
+CONFIG_IP_NF_TARGET_TTL=m
+CONFIG_IP_NF_RAW=m
+CONFIG_IP_NF_ARPTABLES=m
+CONFIG_IP_NF_ARPFILTER=m
+CONFIG_IP_NF_ARP_MANGLE=m
+CONFIG_DNS_RESOLVER=y
+CONFIG_RPS=y
+CONFIG_RFS_ACCEL=y
+CONFIG_XPS=y
+CONFIG_BQL=y
+CONFIG_FIB_RULES=y
+CONFIG_WIRELESS=y
+CONFIG_WEXT_CORE=y
+CONFIG_WEXT_PROC=y
+CONFIG_CFG80211=y
+CONFIG_CFG80211_DEFAULT_PS=y
+CONFIG_CFG80211_WEXT=y
+CONFIG_LIB80211=y
+CONFIG_MAC80211=y
+CONFIG_MAC80211_HAS_RC=y
+CONFIG_MAC80211_RC_MINSTREL=y
+CONFIG_MAC80211_RC_MINSTREL_HT=y
+CONFIG_MAC80211_RC_DEFAULT_MINSTREL=y
+CONFIG_MAC80211_RC_DEFAULT="minstrel_ht"
+CONFIG_MAC80211_LEDS=y
+CONFIG_RFKILL=y
+CONFIG_RFKILL_LEDS=y
+CONFIG_RFKILL_INPUT=y
+CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
+CONFIG_DEVTMPFS=y
+CONFIG_DEVTMPFS_MOUNT=y
+CONFIG_STANDALONE=y
+CONFIG_PREVENT_FIRMWARE_BUILD=y
+CONFIG_FW_LOADER=y
+CONFIG_FIRMWARE_IN_KERNEL=y
+CONFIG_EXTRA_FIRMWARE=""
+CONFIG_DMA_SHARED_BUFFER=y
+CONFIG_MTD=y
+CONFIG_BLK_DEV=y
+CONFIG_BLK_DEV_LOOP=y
+CONFIG_BLK_DEV_LOOP_MIN_COUNT=8
+CONFIG_BLK_DEV_CRYPTOLOOP=y
+CONFIG_BLK_DEV_RAM=y
+CONFIG_BLK_DEV_RAM_COUNT=16
+CONFIG_BLK_DEV_RAM_SIZE=8192
+CONFIG_HAVE_IDE=y
+CONFIG_SCSI_MOD=y
+CONFIG_RAID_ATTRS=m
+CONFIG_SCSI=y
+CONFIG_SCSI_DMA=y
+CONFIG_SCSI_TGT=y
+CONFIG_SCSI_NETLINK=y
+CONFIG_SCSI_PROC_FS=y
+CONFIG_BLK_DEV_SD=y
+CONFIG_CHR_DEV_SG=y
+CONFIG_CHR_DEV_SCH=m
+CONFIG_SCSI_MULTI_LUN=y
+CONFIG_SCSI_CONSTANTS=y
+CONFIG_SCSI_LOGGING=y
+CONFIG_SCSI_WAIT_SCAN=m
+CONFIG_SCSI_SPI_ATTRS=m
+CONFIG_SCSI_FC_ATTRS=m
+CONFIG_SCSI_ISCSI_ATTRS=m
+CONFIG_SCSI_LOWLEVEL=y
+CONFIG_ATA=y
+CONFIG_ATA_VERBOSE_ERROR=y
+CONFIG_SATA_PMP=y
+CONFIG_SATA_AHCI=y
+CONFIG_MD=y
+CONFIG_BLK_DEV_DM=y
+CONFIG_DM_CRYPT=y
+CONFIG_DM_SNAPSHOT=y
+CONFIG_DM_MIRROR=y
+CONFIG_DM_ZERO=y
+CONFIG_NETDEVICES=y
+CONFIG_NET_CORE=y
+CONFIG_MII=y
+CONFIG_ETHERNET=y
+CONFIG_NET_VENDOR_REALTEK=y
+CONFIG_R8169=y
+CONFIG_WLAN=y
+CONFIG_ATH_COMMON=y
+CONFIG_ATH9K_HW=y
+CONFIG_ATH9K_COMMON=y
+CONFIG_ATH9K_BTCOEX_SUPPORT=y
+CONFIG_ATH9K=y
+CONFIG_ATH9K_PCI=y
+CONFIG_ATH9K_RATE_CONTROL=y
+CONFIG_INPUT=y
+CONFIG_INPUT_POLLDEV=m
+CONFIG_INPUT_SPARSEKMAP=y
+CONFIG_INPUT_MOUSEDEV=y
+CONFIG_INPUT_MOUSEDEV_PSAUX=y
+CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
+CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
+CONFIG_INPUT_EVDEV=y
+CONFIG_INPUT_KEYBOARD=y
+CONFIG_KEYBOARD_ATKBD=y
+CONFIG_KEYBOARD_XTKBD=m
+CONFIG_INPUT_MOUSE=y
+CONFIG_MOUSE_PS2=y
+CONFIG_MOUSE_PS2_ALPS=y
+CONFIG_MOUSE_PS2_LOGIPS2PP=y
+CONFIG_MOUSE_PS2_SYNAPTICS=y
+CONFIG_MOUSE_PS2_TRACKPOINT=y
+CONFIG_MOUSE_PS2_SENTELIC=y
+CONFIG_MOUSE_SERIAL=m
+CONFIG_INPUT_MISC=y
+CONFIG_INPUT_UINPUT=m
+CONFIG_SERIO=y
+CONFIG_SERIO_I8042=y
+CONFIG_SERIO_SERPORT=m
+CONFIG_SERIO_LIBPS2=y
+CONFIG_SERIO_RAW=m
+CONFIG_VT=y
+CONFIG_CONSOLE_TRANSLATIONS=y
+CONFIG_VT_CONSOLE=y
+CONFIG_HW_CONSOLE=y
+CONFIG_UNIX98_PTYS=y
+CONFIG_LEGACY_PTYS=y
+CONFIG_LEGACY_PTY_COUNT=16
+CONFIG_SERIAL_NONSTANDARD=y
+CONFIG_N_HDLC=m
+CONFIG_DEVKMEM=y
+CONFIG_STALDRV=y
+CONFIG_SERIAL_8250=y
+CONFIG_SERIAL_8250_CONSOLE=y
+CONFIG_SERIAL_8250_PCI=y
+CONFIG_SERIAL_8250_NR_UARTS=16
+CONFIG_SERIAL_8250_RUNTIME_UARTS=4
+CONFIG_SERIAL_8250_EXTENDED=y
+CONFIG_SERIAL_8250_MANY_PORTS=y
+CONFIG_SERIAL_8250_SHARE_IRQ=y
+CONFIG_SERIAL_8250_RSA=y
+CONFIG_SERIAL_CORE=y
+CONFIG_SERIAL_CORE_CONSOLE=y
+CONFIG_IPMI_HANDLER=m
+CONFIG_IPMI_DEVICE_INTERFACE=m
+CONFIG_IPMI_SI=m
+CONFIG_IPMI_WATCHDOG=m
+CONFIG_IPMI_POWEROFF=m
+CONFIG_HW_RANDOM=y
+CONFIG_R3964=m
+CONFIG_RAW_DRIVER=m
+CONFIG_MAX_RAW_DEVS=256
+CONFIG_DEVPORT=y
+CONFIG_I2C=y
+CONFIG_I2C_BOARDINFO=y
+CONFIG_I2C_COMPAT=y
+CONFIG_I2C_CHARDEV=y
+CONFIG_I2C_HELPER_AUTO=y
+CONFIG_I2C_ALGOBIT=y
+CONFIG_I2C_PIIX4=y
+CONFIG_SPI=y
+CONFIG_SPI_MASTER=y
+CONFIG_SPI_BITBANG=m
+CONFIG_POWER_SUPPLY=y
+CONFIG_HWMON=y
+CONFIG_HWMON_VID=m
+CONFIG_SENSORS_ADM1021=m
+CONFIG_SENSORS_ADM1025=m
+CONFIG_SENSORS_ADM1026=m
+CONFIG_SENSORS_ADM1031=m
+CONFIG_SENSORS_ADM9240=m
+CONFIG_SENSORS_ATXP1=m
+CONFIG_SENSORS_DS1621=m
+CONFIG_SENSORS_GL518SM=m
+CONFIG_SENSORS_GL520SM=m
+CONFIG_SENSORS_IT87=m
+CONFIG_SENSORS_LM63=m
+CONFIG_SENSORS_LM70=m
+CONFIG_SENSORS_LM75=m
+CONFIG_SENSORS_LM77=m
+CONFIG_SENSORS_LM78=m
+CONFIG_SENSORS_LM80=m
+CONFIG_SENSORS_LM83=m
+CONFIG_SENSORS_LM85=m
+CONFIG_SENSORS_LM87=m
+CONFIG_SENSORS_LM90=m
+CONFIG_SENSORS_LM92=m
+CONFIG_SENSORS_MAX1619=m
+CONFIG_SENSORS_PC87360=m
+CONFIG_SENSORS_SMSC47M1=m
+CONFIG_SENSORS_SMSC47M192=m
+CONFIG_SENSORS_SMSC47B397=m
+CONFIG_SENSORS_W83781D=m
+CONFIG_SENSORS_W83791D=m
+CONFIG_SENSORS_W83792D=m
+CONFIG_SENSORS_W83793=m
+CONFIG_SENSORS_W83L785TS=m
+CONFIG_SENSORS_W83627HF=m
+CONFIG_SENSORS_W83627EHF=m
+CONFIG_SSB_POSSIBLE=y
+CONFIG_BCMA_POSSIBLE=y
+CONFIG_VGA_ARB=y
+CONFIG_VGA_ARB_MAX_GPUS=16
+CONFIG_DRM=y
+CONFIG_DRM_KMS_HELPER=y
+CONFIG_DRM_TTM=y
+CONFIG_DRM_RADEON=y
+CONFIG_DRM_RADEON_KMS=y
+CONFIG_VIDEO_OUTPUT_CONTROL=y
+CONFIG_FB=y
+CONFIG_FB_DDC=y
+CONFIG_FB_CFB_FILLRECT=y
+CONFIG_FB_CFB_COPYAREA=y
+CONFIG_FB_CFB_IMAGEBLIT=y
+CONFIG_FB_BACKLIGHT=y
+CONFIG_FB_MODE_HELPERS=y
+CONFIG_FB_RADEON=y
+CONFIG_FB_RADEON_I2C=y
+CONFIG_FB_RADEON_BACKLIGHT=y
+CONFIG_FB_ATY128=y
+CONFIG_FB_ATY128_BACKLIGHT=y
+CONFIG_FB_ATY=y
+CONFIG_FB_ATY_CT=y
+CONFIG_FB_ATY_GENERIC_LCD=y
+CONFIG_FB_ATY_GX=y
+CONFIG_FB_ATY_BACKLIGHT=y
+CONFIG_BACKLIGHT_LCD_SUPPORT=y
+CONFIG_LCD_CLASS_DEVICE=y
+CONFIG_BACKLIGHT_CLASS_DEVICE=y
+CONFIG_BACKLIGHT_GENERIC=y
+# CONFIG_VGA_CONSOLE is not set
+CONFIG_DUMMY_CONSOLE=y
+CONFIG_FRAMEBUFFER_CONSOLE=y
+CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY=y
+CONFIG_FRAMEBUFFER_CONSOLE_ROTATION=y
+CONFIG_FONT_8x8=y
+CONFIG_FONT_8x16=y
+CONFIG_LOGO=y
+CONFIG_LOGO_LINUX_MONO=y
+CONFIG_LOGO_LINUX_VGA16=y
+CONFIG_LOGO_LINUX_CLUT224=y
+CONFIG_SOUND=y
+CONFIG_SND=y
+CONFIG_SND_TIMER=y
+CONFIG_SND_PCM=y
+CONFIG_SND_HWDEP=y
+CONFIG_SND_SEQUENCER=m
+CONFIG_SND_SEQ_DUMMY=m
+CONFIG_SND_DYNAMIC_MINORS=y
+CONFIG_SND_SUPPORT_OLD_API=y
+CONFIG_SND_VERBOSE_PROCFS=y
+CONFIG_SND_VMASTER=y
+CONFIG_SND_KCTL_JACK=y
+CONFIG_SND_DRIVERS=y
+CONFIG_SND_DUMMY=y
+CONFIG_SND_ALOOP=y
+CONFIG_SND_PCI=y
+CONFIG_SND_HDA_INTEL=y
+CONFIG_SND_HDA_PREALLOC_SIZE=64
+CONFIG_SND_HDA_HWDEP=y
+CONFIG_SND_HDA_RECONFIG=y
+CONFIG_SND_HDA_PATCH_LOADER=y
+CONFIG_SND_HDA_CODEC_REALTEK=y
+CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS=y
+CONFIG_SND_HDA_CODEC_HDMI=y
+CONFIG_SND_HDA_CODEC_CONEXANT=y
+CONFIG_SND_HDA_GENERIC=y
+CONFIG_SND_MIPS=y
+CONFIG_HID_SUPPORT=y
+CONFIG_HID=y
+CONFIG_USB_HID=y
+CONFIG_HID_A4TECH=m
+CONFIG_USB_ARCH_HAS_OHCI=y
+CONFIG_USB_ARCH_HAS_EHCI=y
+CONFIG_USB_ARCH_HAS_XHCI=y
+CONFIG_USB_SUPPORT=y
+CONFIG_USB_COMMON=y
+CONFIG_USB_ARCH_HAS_HCD=y
+CONFIG_USB=y
+CONFIG_USB_DEVICEFS=y
+CONFIG_USB_MON=y
+CONFIG_USB_EHCI_HCD=y
+CONFIG_USB_EHCI_ROOT_HUB_TT=y
+CONFIG_USB_EHCI_TT_NEWSCHED=y
+CONFIG_USB_OHCI_HCD=y
+CONFIG_USB_OHCI_LITTLE_ENDIAN=y
+CONFIG_USB_UHCI_HCD=m
+CONFIG_USB_STORAGE=m
+CONFIG_NEW_LEDS=y
+CONFIG_LEDS_CLASS=y
+CONFIG_LEDS_TRIGGERS=y
+CONFIG_RTC_LIB=y
+CONFIG_RTC_CLASS=y
+CONFIG_RTC_HCTOSYS=y
+CONFIG_RTC_HCTOSYS_DEVICE="rtc0"
+CONFIG_RTC_INTF_SYSFS=y
+CONFIG_RTC_INTF_PROC=y
+CONFIG_RTC_INTF_DEV=y
+CONFIG_RTC_DRV_CMOS=y
+CONFIG_DMADEVICES=y
+CONFIG_IOMMU_SUPPORT=y
+CONFIG_EXT2_FS=y
+CONFIG_EXT2_FS_XATTR=y
+CONFIG_EXT2_FS_POSIX_ACL=y
+CONFIG_EXT2_FS_SECURITY=y
+CONFIG_EXT3_FS=y
+CONFIG_EXT3_DEFAULTS_TO_ORDERED=y
+CONFIG_EXT3_FS_XATTR=y
+CONFIG_EXT3_FS_POSIX_ACL=y
+CONFIG_EXT3_FS_SECURITY=y
+CONFIG_EXT4_FS=y
+CONFIG_EXT4_FS_XATTR=y
+CONFIG_EXT4_FS_POSIX_ACL=y
+CONFIG_EXT4_FS_SECURITY=y
+CONFIG_JBD=y
+CONFIG_JBD2=y
+CONFIG_FS_MBCACHE=y
+CONFIG_FS_POSIX_ACL=y
+CONFIG_EXPORTFS=m
+CONFIG_FILE_LOCKING=y
+CONFIG_FSNOTIFY=y
+CONFIG_DNOTIFY=y
+CONFIG_INOTIFY_USER=y
+CONFIG_QUOTA=y
+CONFIG_QUOTACTL=y
+CONFIG_AUTOFS4_FS=y
+CONFIG_FUSE_FS=m
+CONFIG_ISO9660_FS=m
+CONFIG_JOLIET=y
+CONFIG_PROC_FS=y
+CONFIG_PROC_KCORE=y
+CONFIG_PROC_SYSCTL=y
+CONFIG_PROC_PAGE_MONITOR=y
+CONFIG_SYSFS=y
+CONFIG_TMPFS=y
+CONFIG_MISC_FILESYSTEMS=y
+CONFIG_NETWORK_FILESYSTEMS=y
+CONFIG_NFS_FS=m
+CONFIG_NFS_V3=y
+CONFIG_NFS_V3_ACL=y
+CONFIG_NFS_V4=y
+CONFIG_NFS_USE_KERNEL_DNS=y
+CONFIG_NFSD=m
+CONFIG_NFSD_V2_ACL=y
+CONFIG_NFSD_V3=y
+CONFIG_NFSD_V3_ACL=y
+CONFIG_NFSD_V4=y
+CONFIG_LOCKD=m
+CONFIG_LOCKD_V4=y
+CONFIG_NFS_ACL_SUPPORT=m
+CONFIG_NFS_COMMON=y
+CONFIG_SUNRPC=m
+CONFIG_SUNRPC_GSS=m
+CONFIG_CIFS=m
+CONFIG_NLS=y
+CONFIG_NLS_DEFAULT="iso8859-1"
+CONFIG_NLS_CODEPAGE_437=y
+CONFIG_NLS_CODEPAGE_936=y
+CONFIG_NLS_UTF8=y
+CONFIG_TRACE_IRQFLAGS_SUPPORT=y
+CONFIG_PRINTK_TIME=y
+CONFIG_DEFAULT_MESSAGE_LOGLEVEL=4
+CONFIG_FRAME_WARN=1024
+CONFIG_MAGIC_SYSRQ=y
+CONFIG_DEBUG_SECTION_MISMATCH=y
+CONFIG_DEBUG_KERNEL=y
+CONFIG_SCHED_DEBUG=y
+CONFIG_DEBUG_PREEMPT=y
+CONFIG_RCU_CPU_STALL_TIMEOUT=60
+CONFIG_RCU_CPU_STALL_VERBOSE=y
+CONFIG_HAVE_FUNCTION_TRACER=y
+CONFIG_HAVE_FUNCTION_GRAPH_TRACER=y
+CONFIG_HAVE_FUNCTION_TRACE_MCOUNT_TEST=y
+CONFIG_HAVE_DYNAMIC_FTRACE=y
+CONFIG_HAVE_FTRACE_MCOUNT_RECORD=y
+CONFIG_HAVE_C_RECORDMCOUNT=y
+CONFIG_TRACING_SUPPORT=y
+CONFIG_FTRACE=y
+CONFIG_BRANCH_PROFILE_NONE=y
+CONFIG_HAVE_ARCH_KGDB=y
+CONFIG_EARLY_PRINTK=y
+CONFIG_KEYS=y
+CONFIG_DEFAULT_SECURITY_DAC=y
+CONFIG_DEFAULT_SECURITY=""
+CONFIG_CRYPTO=y
+CONFIG_CRYPTO_ALGAPI=y
+CONFIG_CRYPTO_ALGAPI2=y
+CONFIG_CRYPTO_AEAD=m
+CONFIG_CRYPTO_AEAD2=y
+CONFIG_CRYPTO_BLKCIPHER=y
+CONFIG_CRYPTO_BLKCIPHER2=y
+CONFIG_CRYPTO_HASH=y
+CONFIG_CRYPTO_HASH2=y
+CONFIG_CRYPTO_RNG=m
+CONFIG_CRYPTO_RNG2=y
+CONFIG_CRYPTO_PCOMP2=y
+CONFIG_CRYPTO_MANAGER=y
+CONFIG_CRYPTO_MANAGER2=y
+CONFIG_CRYPTO_MANAGER_DISABLE_TESTS=y
+CONFIG_CRYPTO_WORKQUEUE=y
+CONFIG_CRYPTO_AUTHENC=m
+CONFIG_CRYPTO_CBC=y
+CONFIG_CRYPTO_ECB=m
+CONFIG_CRYPTO_HMAC=y
+CONFIG_CRYPTO_CRC32C=m
+CONFIG_CRYPTO_MD4=m
+CONFIG_CRYPTO_MD5=y
+CONFIG_CRYPTO_MICHAEL_MIC=m
+CONFIG_CRYPTO_SHA1=m
+CONFIG_CRYPTO_SHA256=m
+CONFIG_CRYPTO_SHA512=m
+CONFIG_CRYPTO_TGR192=m
+CONFIG_CRYPTO_WP512=m
+CONFIG_CRYPTO_AES=y
+CONFIG_CRYPTO_ANUBIS=m
+CONFIG_CRYPTO_ARC4=y
+CONFIG_CRYPTO_BLOWFISH=m
+CONFIG_CRYPTO_BLOWFISH_COMMON=m
+CONFIG_CRYPTO_CAST5=m
+CONFIG_CRYPTO_CAST6=m
+CONFIG_CRYPTO_DES=m
+CONFIG_CRYPTO_KHAZAD=m
+CONFIG_CRYPTO_SERPENT=m
+CONFIG_CRYPTO_TEA=m
+CONFIG_CRYPTO_TWOFISH=m
+CONFIG_CRYPTO_TWOFISH_COMMON=m
+CONFIG_CRYPTO_DEFLATE=m
+CONFIG_CRYPTO_ANSI_CPRNG=m
+CONFIG_CRYPTO_HW=y
+CONFIG_BITREVERSE=y
+CONFIG_NO_GENERIC_PCI_IOPORT_MAP=y
+CONFIG_GENERIC_PCI_IOMAP=y
+CONFIG_GENERIC_IO=y
+CONFIG_CRC16=y
+CONFIG_CRC_T10DIF=m
+CONFIG_CRC32=y
+CONFIG_CRC32_SLICEBY8=y
+CONFIG_LIBCRC32C=m
+CONFIG_AUDIT_GENERIC=y
+CONFIG_ZLIB_INFLATE=y
+CONFIG_ZLIB_DEFLATE=m
+CONFIG_DECOMPRESS_GZIP=y
+CONFIG_TEXTSEARCH=y
+CONFIG_TEXTSEARCH_KMP=m
+CONFIG_TEXTSEARCH_BM=m
+CONFIG_TEXTSEARCH_FSM=m
+CONFIG_HAS_IOMEM=y
+CONFIG_HAS_IOPORT=y
+CONFIG_HAS_DMA=y
+CONFIG_CPU_RMAP=y
+CONFIG_DQL=y
+CONFIG_NLATTR=y
+CONFIG_AVERAGE=y
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* Re: [PATCH 07/14] MIPS: Loongson 3: Add serial port support.
  2012-06-15  8:09 ` [PATCH 07/14] MIPS: Loongson 3: Add serial port support Huacai Chen
@ 2012-06-15  9:50   ` Arnaud Patard
  2012-06-15 11:44     ` huacai chen
  0 siblings, 1 reply; 34+ messages in thread
From: Arnaud Patard @ 2012-06-15  9:50 UTC (permalink / raw)
  To: Huacai Chen
  Cc: Ralf Baechle, linux-mips, Fuxin Zhang, Zhangjin Wu, Huacai Chen,
	Hongliang Tao, Hua Yan

Huacai Chen <chenhuacai@gmail.com> writes:

> Signed-off-by: Huacai Chen <chenhc@lemote.com>
> Signed-off-by: Hongliang Tao <taohl@lemote.com>
> Signed-off-by: Hua Yan <yanh@lemote.com>
> ---
>  arch/mips/include/asm/mach-loongson/loongson.h |    3 ++
>  arch/mips/loongson/common/serial.c             |   27 ++++++++++++++++++++++++
>  arch/mips/loongson/common/uart_base.c          |    5 ++++
>  3 files changed, 35 insertions(+), 0 deletions(-)
>
> diff --git a/arch/mips/include/asm/mach-loongson/loongson.h b/arch/mips/include/asm/mach-loongson/loongson.h
> index fe7d9a6..16d0924 100644
> --- a/arch/mips/include/asm/mach-loongson/loongson.h
> +++ b/arch/mips/include/asm/mach-loongson/loongson.h
> @@ -125,6 +125,9 @@ static inline void do_perfcnt_IRQ(void)
>  #define LOONGSON_PCICONFIGBASE	0x00
>  #define LOONGSON_REGBASE	0x100
>  
> +/* Loongson-3A cpu uart */
> +#define LOONGSON_UART_BASE 0x1fe001e0

hm. if it's loongson3 specifique, why is it called like this and not
LOONGSON3_UART_BASE ?
Moreover, from a quick look, why don't you define it later in the file
with the proper macros, say:

#define LOONGSON3_UART_BASE     LOONGSON_REG(LOONGSON_REGBASE + 0xe0)


> +
>  /* PCI Configuration Registers */
>  
>  #define LOONGSON_PCI_REG(x)	LOONGSON_REG(LOONGSON_PCICONFIGBASE + (x))
> diff --git a/arch/mips/loongson/common/serial.c b/arch/mips/loongson/common/serial.c
> index 7580873..6bfe9dd 100644
> --- a/arch/mips/loongson/common/serial.c
> +++ b/arch/mips/loongson/common/serial.c
> @@ -47,6 +47,33 @@ static struct plat_serial8250_port uart8250_data[][2] = {
>  	[MACH_DEXXON_GDIUM2F10]         {PORT_M(3), {} },
>  	[MACH_LEMOTE_NAS]               {PORT_M(3), {} },
>  	[MACH_LEMOTE_LL2F]              {PORT(3), {} },
> +	[MACH_LEMOTE_A1004]             {
> +						{
> +							.irq		= MIPS_CPU_IRQ_BASE + 2,
> +							.uartclk	= 33177600,
> +							.iotype		= UPIO_MEM,
> +							.flags		= UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
> +						},
> +						{}
> +					},
> +	[MACH_LEMOTE_A1101]             {
> +						{
> +							.irq		= MIPS_CPU_IRQ_BASE + 2,
> +							.uartclk	= 25000000,
> +							.iotype		= UPIO_MEM,
> +							.flags		= UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
> +						},
> +						{}
> +					},
> +	[MACH_LEMOTE_A1205]             {
> +						{
> +							.irq		= MIPS_CPU_IRQ_BASE + 2,
> +							.uartclk	= 25000000,
> +							.iotype		= UPIO_MEM,
> +							.flags		= UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
> +						},
> +						{}
> +					},
>  	[MACH_LOONGSON_END]             {},

What about modifying PORT_M to makes things clearer ?

Arnaud

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH 09/14] ata: Use 32bit DMA in AHCI for Loongson 3.
  2012-06-15  8:09 ` [PATCH 09/14] ata: Use 32bit DMA in AHCI for Loongson 3 Huacai Chen
@ 2012-06-15 10:04   ` Sergei Shtylyov
  2012-06-15 12:42     ` huacai chen
  0 siblings, 1 reply; 34+ messages in thread
From: Sergei Shtylyov @ 2012-06-15 10:04 UTC (permalink / raw)
  To: Huacai Chen
  Cc: Ralf Baechle, linux-mips, Fuxin Zhang, Zhangjin Wu, Huacai Chen,
	Hongliang Tao, Hua Yan, linux-ide

Hello.

On 15-06-2012 12:09, Huacai Chen wrote:

> Signed-off-by: Huacai Chen<chenhc@lemote.com>
> Signed-off-by: Hongliang Tao<taohl@lemote.com>
> Signed-off-by: Hua Yan<yanh@lemote.com>

    You  should have CCed the 'linux-ide' mailing list.

> diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
> index ebaf67e..3e3cfd8 100644
> --- a/drivers/ata/ahci.c
> +++ b/drivers/ata/ahci.c
> @@ -183,7 +183,12 @@ static const struct ata_port_info ahci_port_info[] = {
>   	},
>   	[board_ahci_sb700] =	/* for SB700 and SB800 */
>   	{
> +#ifndef CONFIG_CPU_LOONGSON3
>   		AHCI_HFLAGS	(AHCI_HFLAG_IGN_SERR_INTERNAL),
> +#else
> +		AHCI_HFLAGS	(AHCI_HFLAG_IGN_SERR_INTERNAL |
> +						AHCI_HFLAG_32BIT_ONLY),
> +#endif

    No, this #ifdef'ery won't do. You should add a new board type.

MBR, Sergei

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH 07/14] MIPS: Loongson 3: Add serial port support.
  2012-06-15  9:50   ` Arnaud Patard
@ 2012-06-15 11:44     ` huacai chen
  0 siblings, 0 replies; 34+ messages in thread
From: huacai chen @ 2012-06-15 11:44 UTC (permalink / raw)
  To: Arnaud Patard
  Cc: Ralf Baechle, linux-mips, Fuxin Zhang, Zhangjin Wu, Huacai Chen,
	Hongliang Tao, Hua Yan

Thank you, I'll follow your tips.

On Fri, Jun 15, 2012 at 5:50 PM, Arnaud Patard
<arnaud.patard@rtp-net.org> wrote:
> Huacai Chen <chenhuacai@gmail.com> writes:
>
>> Signed-off-by: Huacai Chen <chenhc@lemote.com>
>> Signed-off-by: Hongliang Tao <taohl@lemote.com>
>> Signed-off-by: Hua Yan <yanh@lemote.com>
>> ---
>>  arch/mips/include/asm/mach-loongson/loongson.h |    3 ++
>>  arch/mips/loongson/common/serial.c             |   27 ++++++++++++++++++++++++
>>  arch/mips/loongson/common/uart_base.c          |    5 ++++
>>  3 files changed, 35 insertions(+), 0 deletions(-)
>>
>> diff --git a/arch/mips/include/asm/mach-loongson/loongson.h b/arch/mips/include/asm/mach-loongson/loongson.h
>> index fe7d9a6..16d0924 100644
>> --- a/arch/mips/include/asm/mach-loongson/loongson.h
>> +++ b/arch/mips/include/asm/mach-loongson/loongson.h
>> @@ -125,6 +125,9 @@ static inline void do_perfcnt_IRQ(void)
>>  #define LOONGSON_PCICONFIGBASE       0x00
>>  #define LOONGSON_REGBASE     0x100
>>
>> +/* Loongson-3A cpu uart */
>> +#define LOONGSON_UART_BASE 0x1fe001e0
>
> hm. if it's loongson3 specifique, why is it called like this and not
> LOONGSON3_UART_BASE ?
> Moreover, from a quick look, why don't you define it later in the file
> with the proper macros, say:
>
> #define LOONGSON3_UART_BASE     LOONGSON_REG(LOONGSON_REGBASE + 0xe0)
>
>
>> +
>>  /* PCI Configuration Registers */
>>
>>  #define LOONGSON_PCI_REG(x)  LOONGSON_REG(LOONGSON_PCICONFIGBASE + (x))
>> diff --git a/arch/mips/loongson/common/serial.c b/arch/mips/loongson/common/serial.c
>> index 7580873..6bfe9dd 100644
>> --- a/arch/mips/loongson/common/serial.c
>> +++ b/arch/mips/loongson/common/serial.c
>> @@ -47,6 +47,33 @@ static struct plat_serial8250_port uart8250_data[][2] = {
>>       [MACH_DEXXON_GDIUM2F10]         {PORT_M(3), {} },
>>       [MACH_LEMOTE_NAS]               {PORT_M(3), {} },
>>       [MACH_LEMOTE_LL2F]              {PORT(3), {} },
>> +     [MACH_LEMOTE_A1004]             {
>> +                                             {
>> +                                                     .irq            = MIPS_CPU_IRQ_BASE + 2,
>> +                                                     .uartclk        = 33177600,
>> +                                                     .iotype         = UPIO_MEM,
>> +                                                     .flags          = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
>> +                                             },
>> +                                             {}
>> +                                     },
>> +     [MACH_LEMOTE_A1101]             {
>> +                                             {
>> +                                                     .irq            = MIPS_CPU_IRQ_BASE + 2,
>> +                                                     .uartclk        = 25000000,
>> +                                                     .iotype         = UPIO_MEM,
>> +                                                     .flags          = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
>> +                                             },
>> +                                             {}
>> +                                     },
>> +     [MACH_LEMOTE_A1205]             {
>> +                                             {
>> +                                                     .irq            = MIPS_CPU_IRQ_BASE + 2,
>> +                                                     .uartclk        = 25000000,
>> +                                                     .iotype         = UPIO_MEM,
>> +                                                     .flags          = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
>> +                                             },
>> +                                             {}
>> +                                     },
>>       [MACH_LOONGSON_END]             {},
>
> What about modifying PORT_M to makes things clearer ?
>
> Arnaud

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH 09/14] ata: Use 32bit DMA in AHCI for Loongson 3.
  2012-06-15 10:04   ` Sergei Shtylyov
@ 2012-06-15 12:42     ` huacai chen
  2012-06-17 12:05       ` Borislav Petkov
  0 siblings, 1 reply; 34+ messages in thread
From: huacai chen @ 2012-06-15 12:42 UTC (permalink / raw)
  To: Sergei Shtylyov
  Cc: Ralf Baechle, linux-mips, Fuxin Zhang, Zhangjin Wu, Huacai Chen,
	Hongliang Tao, Hua Yan, linux-ide

On Fri, Jun 15, 2012 at 6:04 PM, Sergei Shtylyov <sshtylyov@mvista.com> wrote:
> Hello.
>
>
> On 15-06-2012 12:09, Huacai Chen wrote:
>
>> Signed-off-by: Huacai Chen<chenhc@lemote.com>
>> Signed-off-by: Hongliang Tao<taohl@lemote.com>
>> Signed-off-by: Hua Yan<yanh@lemote.com>
>
>
>   You  should have CCed the 'linux-ide' mailing list.
>
>
>> diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
>> index ebaf67e..3e3cfd8 100644
>> --- a/drivers/ata/ahci.c
>> +++ b/drivers/ata/ahci.c
>> @@ -183,7 +183,12 @@ static const struct ata_port_info ahci_port_info[] =
>> {
>>        },
>>        [board_ahci_sb700] =    /* for SB700 and SB800 */
>>        {
>> +#ifndef CONFIG_CPU_LOONGSON3
>>                AHCI_HFLAGS     (AHCI_HFLAG_IGN_SERR_INTERNAL),
>> +#else
>> +               AHCI_HFLAGS     (AHCI_HFLAG_IGN_SERR_INTERNAL |
>> +                                               AHCI_HFLAG_32BIT_ONLY),
>> +#endif
>
>
>   No, this #ifdef'ery won't do. You should add a new board type.
All Loongson-3 based machines use AMD SB700 chipsets, add a new board
type is better than #ifdef?

>
> MBR, Sergei

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH 00/14] MIPS: Add Loongson-3 based machines support.
  2012-06-15  8:09 [PATCH 00/14] MIPS: Add Loongson-3 based machines support Huacai Chen
                   ` (13 preceding siblings ...)
  2012-06-15  8:10 ` [PATCH 14/14] MIPS: Loongson: Add a Loongson 3 default config file Huacai Chen
@ 2012-06-15 13:10 ` LIU Qi
  2012-06-16 12:46   ` huacai chen
  14 siblings, 1 reply; 34+ messages in thread
From: LIU Qi @ 2012-06-15 13:10 UTC (permalink / raw)
  To: Huacai Chen
  Cc: Ralf Baechle, linux-mips, Fuxin Zhang, Zhangjin Wu, Huacai Chen,
	Hongliang Tao, Hua Yan

On Fri, Jun 15, 2012 at 04:09:47PM +0800, Huacai Chen wrote:
 > This patchset is for git repository git://git.linux-mips.org/pub/scm/
 > ralf/linux. Loongson-3 is a multi-core MIPS family CPU, it is MIPS64R2
 > compatible and has the same IMP field (0x6300) as Loongson-2. These
 > patches make Linux kernel support Loongson-3 CPU and Loongson-3 based
 > computers (including Laptop, Mini-ITX, All-In-One PC, etc.)
 > 
 > Huacai Chen(14):
 >  MIPS: Loongson: Add basic Loongson 3 CPU support.
 >  MIPS: Loongson 3: Add Lemote-3A machtypes definition.
 >  MIPS: Loongson: Make Loongson 3 to use BCD format for RTC.
 >  MIPS: Loongson: Add UEFI-like firmware interface support.
 >  MIPS: Loongson 3: Add HT-linked PCI support.
 >  MIPS: Loongson 3: Add IRQ init and dispatch support.
 >  MIPS: Loongson 3: Add serial port support.
 >  MIPS: Loongson: Add swiotlb to support big memory (>4GB).
 >  ata: Use 32bit DMA in AHCI for Loongson 3.
 >  drm/radeon: Make radeon card usable for Loongson.
 >  ALSA: Make hda sound card usable for Loongson.
 >  MIPS: Loongson 3: Add Loongson-3 SMP support.
 >  MIPS: Loongson 3: Add CPU Hotplug support.
 >  MIPS: Loongson: Add a Loongson 3 default config file.
 > 
 > Signed-off-by: Huacai Chen <chenhc@lemote.com>
 > Signed-off-by: Hongliang Tao <taohl@lemote.com>
 > Signed-off-by: Hua Yan <yanh@lemote.com>

The compiled kernel with your patches just doesn't boot. I tested with
the Loongson3 laptop and mini-itx. Do they need the newer PMON version
with UEFI-like interface support to boot the system?

LIU Qi

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH 10/14] drm/radeon: Make radeon card usable for Loongson.
  2012-06-15  8:09 ` [PATCH 10/14] drm/radeon: Make radeon card usable for Loongson Huacai Chen
@ 2012-06-15 14:28   ` LIU Qi
  0 siblings, 0 replies; 34+ messages in thread
From: LIU Qi @ 2012-06-15 14:28 UTC (permalink / raw)
  To: Huacai Chen
  Cc: Ralf Baechle, linux-mips, Fuxin Zhang, Zhangjin Wu, Huacai Chen,
	Hongliang Tao, Hua Yan

On Fri, Jun 15, 2012 at 04:09:57PM +0800, Huacai Chen wrote:
 > 1, Use 32bit DMA as a workaround.
 > 2, Read vga bios offered by system firmware.
 > 3, Handle io prot correctly for MIPS.
 > 4, Don't use swiotlb on Loongson machines.
 > 
 > Signed-off-by: Huacai Chen <chenhc@lemote.com>
 > Signed-off-by: Hongliang Tao <taohl@lemote.com>
 > Signed-off-by: Hua Yan <yanh@lemote.com>
 > ---
 >  drivers/gpu/drm/drm_vm.c               |    2 +-
 >  drivers/gpu/drm/radeon/radeon_bios.c   |   32 ++++++++++++++++++++++++++++++++
 >  drivers/gpu/drm/radeon/radeon_device.c |    5 +++++
 >  drivers/gpu/drm/radeon/radeon_ttm.c    |    6 +++---
 >  drivers/gpu/drm/ttm/ttm_bo_util.c      |    2 +-
 >  include/drm/drm_sarea.h                |    2 ++
 >  6 files changed, 44 insertions(+), 5 deletions(-)

Fix the following compiling warnings, please:

  CC      drivers/gpu/drm/drm_vm.o
drivers/gpu/drm/drm_vm.c: In function ‘drm_do_vm_dma_fault’:
drivers/gpu/drm/drm_vm.c:309: warning: passing argument 1 of ‘virt_to_phys’ makes pointer from integer without a cast
/home/liuqi/workspace/linux.git/arch/mips/include/asm/io.h:117: note: expected ‘const volatile void *’ but argument is of type ‘long unsigned
int’

  CC      drivers/gpu/drm/radeon/radeon_ttm.o
In file included from drivers/gpu/drm/radeon/radeon_ttm.c:36:
include/drm/ttm/ttm_page_alloc.h:81: warning: ‘struct device’ declared inside parameter list
include/drm/ttm/ttm_page_alloc.h:81: warning: its scope is only this definition or declaration, which is probably not what you want
include/drm/ttm/ttm_page_alloc.h:82: warning: ‘struct device’ declared inside parameter list

LIU Qi

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH 06/14] MIPS: Loongson 3: Add IRQ init and dispatch support.
  2012-06-15  8:09 ` [PATCH 06/14] MIPS: Loongson 3: Add IRQ init and dispatch support Huacai Chen
@ 2012-06-15 14:32   ` LIU Qi
  0 siblings, 0 replies; 34+ messages in thread
From: LIU Qi @ 2012-06-15 14:32 UTC (permalink / raw)
  To: Huacai Chen
  Cc: Ralf Baechle, linux-mips, Fuxin Zhang, Zhangjin Wu, Huacai Chen,
	Hongliang Tao, Hua Yan

On Fri, Jun 15, 2012 at 04:09:53PM +0800, Huacai Chen wrote:
 > IRQ routing path of Loongson-3:
 > Devices(most) --> I8259 --> HT Controller --> IRQ Routing Table --> CPU
 >                                                   ^
 >                                                   |
 > Device(legacy devices such as UART) --> Bonito ---|
 > 
 > IRQ Routing Table route 32 INTs to CPU's INT0~INT3(IP2~IP5 of CP0), 32
 > INTs include 16 HT INTs(mostly), 4 PCI INTs, 1 LPC INT, etc. IP6 is used
 > for IPI and IP7 is used for internal MIPS timer. LOONGSON_INT_ROUTER_*
 > are IRQ Routing Table registers.
 > 
 > I8259 IRQs are 1:1 mapped to HT1 INTs. LOONGSON_HT1_* are configuration
 > registers of HT1 controller.
 > 
 > Signed-off-by: Huacai Chen <chenhc@lemote.com>
 > Signed-off-by: Hongliang Tao <taohl@lemote.com>
 > Signed-off-by: Hua Yan <yanh@lemote.com>
 > ---
 >  arch/mips/include/asm/mach-loongson/irq.h      |   26 +++++++
 >  arch/mips/include/asm/mach-loongson/loongson.h |    9 +++
 >  arch/mips/loongson/Makefile                    |    6 ++
 >  arch/mips/loongson/loongson-3/Makefile         |    4 +
 >  arch/mips/loongson/loongson-3/irq.c            |   87 ++++++++++++++++++++++++
 >  5 files changed, 132 insertions(+), 0 deletions(-)
 >  create mode 100644 arch/mips/include/asm/mach-loongson/irq.h
 >  create mode 100644 arch/mips/loongson/loongson-3/Makefile
 >  create mode 100644 arch/mips/loongson/loongson-3/irq.c
Fix the following compiling warning please:

  CC      drivers/input/serio/i8042.o
In file included from drivers/input/serio/i8042.h:32,
                 from drivers/input/serio/i8042.c:91:
drivers/input/serio/i8042-io.h:36:1: warning: "I8042_KBD_IRQ" redefined
In file included from
/home/liuqi/workspace/linux.git/arch/mips/include/asm/irq.h:18,
                 from include/linux/irq.h:27,
                 from include/asm-generic/hardirq.h:12,
                 from
/home/liuqi/workspace/linux.git/arch/mips/include/asm/hardirq.h:16,
                 from include/linux/hardirq.h:7,
                 from include/linux/interrupt.h:12,
                 from drivers/input/serio/i8042.c:18:
/home/liuqi/workspace/linux.git/arch/mips/include/asm/mach-loongson/irq.h:9:1: warning: this is the location of the previous definition

LIU Qi

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH 05/14] MIPS: Loongson 3: Add HT-linked PCI support.
  2012-06-15  8:09 ` [PATCH 05/14] MIPS: Loongson 3: Add HT-linked PCI support Huacai Chen
@ 2012-06-15 14:34   ` LIU Qi
  0 siblings, 0 replies; 34+ messages in thread
From: LIU Qi @ 2012-06-15 14:34 UTC (permalink / raw)
  To: Huacai Chen
  Cc: Ralf Baechle, linux-mips, Fuxin Zhang, Zhangjin Wu, Huacai Chen,
	Hongliang Tao, Hua Yan

On Fri, Jun 15, 2012 at 04:09:52PM +0800, Huacai Chen wrote:
 > Loongson family machines use Hyper-Transport bus for inter-core
 > connection and device connection. The PCI bus is a subordinate
 > linked at HT1.
 > 
 > With UEFI-like firmware interface, We don't need PCI irq routing
 > fixup.
 > 
 > Signed-off-by: Huacai Chen <chenhc@lemote.com>
 > Signed-off-by: Hongliang Tao <taohl@lemote.com>
 > Signed-off-by: Hua Yan <yanh@lemote.com>
 > ---
 >  arch/mips/Kconfig                              |    9 ++
 >  arch/mips/include/asm/mach-loongson/loongson.h |    7 ++
 >  arch/mips/include/asm/mach-loongson/pci.h      |    5 +
 >  arch/mips/pci/Makefile                         |    1 +
 >  arch/mips/pci/fixup-loongson3.c                |   50 +++++++++++
 >  arch/mips/pci/ops-loongson3.c                  |  104 ++++++++++++++++++++++++
 >  6 files changed, 176 insertions(+), 0 deletions(-)
 >  create mode 100644 arch/mips/pci/fixup-loongson3.c
 >  create mode 100644 arch/mips/pci/ops-loongson3.c
Fix the following compiling warning please:

  CC      arch/mips/pci/fixup-loongson3.o
arch/mips/pci/fixup-loongson3.c: In function ‘pcibios_map_irq’:
arch/mips/pci/fixup-loongson3.c:42: warning: passing argument 1 of ‘print_fixup_info’ discards qualifiers from pointer target type
arch/mips/pci/fixup-loongson3.c:32: note: expected ‘struct pci_dev *’ but argument is of type ‘const struct pci_dev *’

LIU Qi

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH 14/14] MIPS: Loongson: Add a Loongson 3 default config file.
  2012-06-15  8:10 ` [PATCH 14/14] MIPS: Loongson: Add a Loongson 3 default config file Huacai Chen
@ 2012-06-15 14:37   ` LIU Qi
  2012-06-16 12:52     ` huacai chen
  0 siblings, 1 reply; 34+ messages in thread
From: LIU Qi @ 2012-06-15 14:37 UTC (permalink / raw)
  To: Huacai Chen
  Cc: Ralf Baechle, linux-mips, Fuxin Zhang, Zhangjin Wu, Huacai Chen,
	Hongliang Tao, Hua Yan

On Fri, Jun 15, 2012 at 04:10:01PM +0800, Huacai Chen wrote:
 > Signed-off-by: Huacai Chen <chenhc@lemote.com>
 > Signed-off-by: Hongliang Tao <taohl@lemote.com>
 > Signed-off-by: Hua Yan <yanh@lemote.com>
 > ---
 >  arch/mips/configs/loongson3_defconfig |  704 +++++++++++++++++++++++++++++++++
 >  1 files changed, 704 insertions(+), 0 deletions(-)
 >  create mode 100644 arch/mips/configs/loongson3_defconfig

It is better to generate the defconfig file using `make savedefconfig`.

LIU Qi

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH 01/14] MIPS: Loongson: Add basic Loongson 3 CPU support.
  2012-06-15  8:09 ` [PATCH 01/14] MIPS: Loongson: Add basic Loongson 3 CPU support Huacai Chen
@ 2012-06-15 15:59   ` David Daney
  2012-06-15 16:13     ` Ralf Baechle
  0 siblings, 1 reply; 34+ messages in thread
From: David Daney @ 2012-06-15 15:59 UTC (permalink / raw)
  To: Huacai Chen
  Cc: Ralf Baechle, linux-mips, Fuxin Zhang, Zhangjin Wu, Huacai Chen,
	Hongliang Tao, Hua Yan

On 06/15/2012 01:09 AM, Huacai Chen wrote:
> Loongson-3 is a multi-core MIPS family CPU, it support MIPS64R2
> fully. Loongson-3 has the same IMP field (0x6300) as Loongson-2.
>
> Loongson-3 has a hardware-maintained cache, system software doesn't
> need to maintain coherency.
>
> Loongson-3A is the first revision of Loongson-3, and it is the quad-
> core version of Loongson-2G. Loongson-3A has a simplified version named
> Loongson-2Gq, the main difference between Loongson-3A/2Gq is 3A has two
> HyperTransport controller but 2Gq has only one. HT0 is used for cross-
> chip interconnection and HT1 is used to link PCI bus. Therefore, 2Gq
> cannot support NUMA but 3A can.
>
> Exsisting Loongson family CPUs:
> Loongson-1: Loongson-1A, Loongson-1B, they are 32-bit MIPS CPUs.
> Loongson-2: Loongson-2E, Loongson-2F, Loongson-2G(including Loongson-
>              2Gq), they are 64-bit MIPS CPUs.
> Loongson-3: Loongson-3A, it is a 64-bit MIPS CPU.
>
> Signed-off-by: Huacai Chen<chenhc@lemote.com>
> Signed-off-by: Hongliang Tao<taohl@lemote.com>
> Signed-off-by: Hua Yan<yanh@lemote.com>
> ---
>   arch/mips/Kconfig                            |   13 ++++
>   arch/mips/include/asm/addrspace.h            |    6 ++
>   arch/mips/include/asm/cpu.h                  |    6 +-
>   arch/mips/include/asm/mach-loongson/spaces.h |   15 +++++
>   arch/mips/include/asm/module.h               |    2 +
>   arch/mips/include/asm/pgtable-bits.h         |    7 ++
>   arch/mips/kernel/Makefile                    |    1 +
>   arch/mips/kernel/cpu-probe.c                 |   12 +++-
>   arch/mips/lib/Makefile                       |    1 +
>   arch/mips/loongson/Kconfig                   |    4 +
>   arch/mips/loongson/Platform                  |    1 +
>   arch/mips/loongson/common/env.c              |    3 +
>   arch/mips/loongson/common/setup.c            |    6 +-
>   arch/mips/mm/Makefile                        |    1 +
>   arch/mips/mm/c-r4k.c                         |   84 ++++++++++++++++++++++++++
>   arch/mips/mm/tlb-r4k.c                       |    2 +-
>   arch/mips/mm/tlbex.c                         |    1 +
>   17 files changed, 156 insertions(+), 9 deletions(-)

This patch is too big.  It should be split up into smaller but related 
parts.

For example, the parts that add new identifier constants should be 
first.  Then a separate patch for cpu-probe.c where they are used.

And...

>   create mode 100644 arch/mips/include/asm/mach-loongson/spaces.h
>
> diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
> index c179461..38e460b 100644
> --- a/arch/mips/Kconfig
> +++ b/arch/mips/Kconfig
> @@ -1544,6 +1544,16 @@ config CPU_LOONGSON2
>   	select CPU_SUPPORTS_64BIT_KERNEL
>   	select CPU_SUPPORTS_HIGHMEM
>
> +config CPU_LOONGSON3
> +	bool "Loongson 3 CPU"
> +	depends on SYS_HAS_CPU_LOONGSON3
> +	select CPU_SUPPORTS_32BIT_KERNEL
> +	select CPU_SUPPORTS_64BIT_KERNEL
> +	select CPU_SUPPORTS_HIGHMEM
> +	help
> +		The Loongson 3 processor implements the MIPS III instruction set
> +		with many extensions.
> +

This bit must be the very last patch of the entire set, not the first.

Ask yourself what would happen if someone did a build selecting 
CPU_LOONGSON3 after this patch were applied?  Would a runnable kernel 
result?  If the answer is no, then you did it in the wrong order.

David Daney

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH 01/14] MIPS: Loongson: Add basic Loongson 3 CPU support.
  2012-06-15 15:59   ` David Daney
@ 2012-06-15 16:13     ` Ralf Baechle
  2012-06-16 12:49       ` huacai chen
  0 siblings, 1 reply; 34+ messages in thread
From: Ralf Baechle @ 2012-06-15 16:13 UTC (permalink / raw)
  To: David Daney
  Cc: Huacai Chen, linux-mips, Fuxin Zhang, Zhangjin Wu, Huacai Chen,
	Hongliang Tao, Hua Yan

On Fri, Jun 15, 2012 at 08:59:37AM -0700, David Daney wrote:

> On 06/15/2012 01:09 AM, Huacai Chen wrote:
> >Loongson-3 is a multi-core MIPS family CPU, it support MIPS64R2
> >fully. Loongson-3 has the same IMP field (0x6300) as Loongson-2.
> >
> >Loongson-3 has a hardware-maintained cache, system software doesn't
> >need to maintain coherency.
> >
> >Loongson-3A is the first revision of Loongson-3, and it is the quad-
> >core version of Loongson-2G. Loongson-3A has a simplified version named
> >Loongson-2Gq, the main difference between Loongson-3A/2Gq is 3A has two
> >HyperTransport controller but 2Gq has only one. HT0 is used for cross-
> >chip interconnection and HT1 is used to link PCI bus. Therefore, 2Gq
> >cannot support NUMA but 3A can.
> >
> >Exsisting Loongson family CPUs:
> >Loongson-1: Loongson-1A, Loongson-1B, they are 32-bit MIPS CPUs.
> >Loongson-2: Loongson-2E, Loongson-2F, Loongson-2G(including Loongson-
> >             2Gq), they are 64-bit MIPS CPUs.
> >Loongson-3: Loongson-3A, it is a 64-bit MIPS CPU.
> >
> >Signed-off-by: Huacai Chen<chenhc@lemote.com>
> >Signed-off-by: Hongliang Tao<taohl@lemote.com>
> >Signed-off-by: Hua Yan<yanh@lemote.com>
> >---
> >  arch/mips/Kconfig                            |   13 ++++
> >  arch/mips/include/asm/addrspace.h            |    6 ++
> >  arch/mips/include/asm/cpu.h                  |    6 +-
> >  arch/mips/include/asm/mach-loongson/spaces.h |   15 +++++
> >  arch/mips/include/asm/module.h               |    2 +
> >  arch/mips/include/asm/pgtable-bits.h         |    7 ++
> >  arch/mips/kernel/Makefile                    |    1 +
> >  arch/mips/kernel/cpu-probe.c                 |   12 +++-
> >  arch/mips/lib/Makefile                       |    1 +
> >  arch/mips/loongson/Kconfig                   |    4 +
> >  arch/mips/loongson/Platform                  |    1 +
> >  arch/mips/loongson/common/env.c              |    3 +
> >  arch/mips/loongson/common/setup.c            |    6 +-
> >  arch/mips/mm/Makefile                        |    1 +
> >  arch/mips/mm/c-r4k.c                         |   84 ++++++++++++++++++++++++++
> >  arch/mips/mm/tlb-r4k.c                       |    2 +-
> >  arch/mips/mm/tlbex.c                         |    1 +
> >  17 files changed, 156 insertions(+), 9 deletions(-)
> 
> This patch is too big.  It should be split up into smaller but
> related parts.
> 
> For example, the parts that add new identifier constants should be
> first.  Then a separate patch for cpu-probe.c where they are used.
> 
> And...
> 
> >  create mode 100644 arch/mips/include/asm/mach-loongson/spaces.h
> >
> >diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
> >index c179461..38e460b 100644
> >--- a/arch/mips/Kconfig
> >+++ b/arch/mips/Kconfig
> >@@ -1544,6 +1544,16 @@ config CPU_LOONGSON2
> >  	select CPU_SUPPORTS_64BIT_KERNEL
> >  	select CPU_SUPPORTS_HIGHMEM
> >
> >+config CPU_LOONGSON3
> >+	bool "Loongson 3 CPU"
> >+	depends on SYS_HAS_CPU_LOONGSON3
> >+	select CPU_SUPPORTS_32BIT_KERNEL
> >+	select CPU_SUPPORTS_64BIT_KERNEL
> >+	select CPU_SUPPORTS_HIGHMEM
> >+	help
> >+		The Loongson 3 processor implements the MIPS III instruction set
> >+		with many extensions.
> >+
> 
> This bit must be the very last patch of the entire set, not the first.
> 
> Ask yourself what would happen if someone did a build selecting
> CPU_LOONGSON3 after this patch were applied?  Would a runnable
> kernel result?  If the answer is no, then you did it in the wrong
> order.

Just to clarify and also because I only recently had the discussion with
somebody.  What is very important is that a patch series never ever
break something when it gets only partially applied.  This is because
all the automated testing and debugging that is being used today.  The
most common example is git-bisect but lately aiaiai [1] is becoming
fashionable, too.  So I rather spend some extra time on reviewing a big,
complex patch now than living with the consequences of improper splitting
later.  But of course properlz split patches are always preferred :-)

  Ralf

[1] http://lwn.net/Articles/488992/

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH 00/14] MIPS: Add Loongson-3 based machines support.
  2012-06-15 13:10 ` [PATCH 00/14] MIPS: Add Loongson-3 based machines support LIU Qi
@ 2012-06-16 12:46   ` huacai chen
  0 siblings, 0 replies; 34+ messages in thread
From: huacai chen @ 2012-06-16 12:46 UTC (permalink / raw)
  To: LIU Qi
  Cc: Ralf Baechle, linux-mips, Fuxin Zhang, Zhangjin Wu, Huacai Chen,
	Hongliang Tao, Hua Yan

Yes, the 4th patch is add UEFI-like interface and old interface is not
supported.

On Fri, Jun 15, 2012 at 9:10 PM, LIU Qi <liuqi82@gmail.com> wrote:
> On Fri, Jun 15, 2012 at 04:09:47PM +0800, Huacai Chen wrote:
>  > This patchset is for git repository git://git.linux-mips.org/pub/scm/
>  > ralf/linux. Loongson-3 is a multi-core MIPS family CPU, it is MIPS64R2
>  > compatible and has the same IMP field (0x6300) as Loongson-2. These
>  > patches make Linux kernel support Loongson-3 CPU and Loongson-3 based
>  > computers (including Laptop, Mini-ITX, All-In-One PC, etc.)
>  >
>  > Huacai Chen(14):
>  >  MIPS: Loongson: Add basic Loongson 3 CPU support.
>  >  MIPS: Loongson 3: Add Lemote-3A machtypes definition.
>  >  MIPS: Loongson: Make Loongson 3 to use BCD format for RTC.
>  >  MIPS: Loongson: Add UEFI-like firmware interface support.
>  >  MIPS: Loongson 3: Add HT-linked PCI support.
>  >  MIPS: Loongson 3: Add IRQ init and dispatch support.
>  >  MIPS: Loongson 3: Add serial port support.
>  >  MIPS: Loongson: Add swiotlb to support big memory (>4GB).
>  >  ata: Use 32bit DMA in AHCI for Loongson 3.
>  >  drm/radeon: Make radeon card usable for Loongson.
>  >  ALSA: Make hda sound card usable for Loongson.
>  >  MIPS: Loongson 3: Add Loongson-3 SMP support.
>  >  MIPS: Loongson 3: Add CPU Hotplug support.
>  >  MIPS: Loongson: Add a Loongson 3 default config file.
>  >
>  > Signed-off-by: Huacai Chen <chenhc@lemote.com>
>  > Signed-off-by: Hongliang Tao <taohl@lemote.com>
>  > Signed-off-by: Hua Yan <yanh@lemote.com>
>
> The compiled kernel with your patches just doesn't boot. I tested with
> the Loongson3 laptop and mini-itx. Do they need the newer PMON version
> with UEFI-like interface support to boot the system?
>
> LIU Qi

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH 01/14] MIPS: Loongson: Add basic Loongson 3 CPU support.
  2012-06-15 16:13     ` Ralf Baechle
@ 2012-06-16 12:49       ` huacai chen
  0 siblings, 0 replies; 34+ messages in thread
From: huacai chen @ 2012-06-16 12:49 UTC (permalink / raw)
  To: Ralf Baechle
  Cc: David Daney, linux-mips, Fuxin Zhang, Zhangjin Wu, Huacai Chen,
	Hongliang Tao, Hua Yan

OK, I'll split patches next week.

On Sat, Jun 16, 2012 at 12:13 AM, Ralf Baechle <ralf@linux-mips.org> wrote:
> On Fri, Jun 15, 2012 at 08:59:37AM -0700, David Daney wrote:
>
>> On 06/15/2012 01:09 AM, Huacai Chen wrote:
>> >Loongson-3 is a multi-core MIPS family CPU, it support MIPS64R2
>> >fully. Loongson-3 has the same IMP field (0x6300) as Loongson-2.
>> >
>> >Loongson-3 has a hardware-maintained cache, system software doesn't
>> >need to maintain coherency.
>> >
>> >Loongson-3A is the first revision of Loongson-3, and it is the quad-
>> >core version of Loongson-2G. Loongson-3A has a simplified version named
>> >Loongson-2Gq, the main difference between Loongson-3A/2Gq is 3A has two
>> >HyperTransport controller but 2Gq has only one. HT0 is used for cross-
>> >chip interconnection and HT1 is used to link PCI bus. Therefore, 2Gq
>> >cannot support NUMA but 3A can.
>> >
>> >Exsisting Loongson family CPUs:
>> >Loongson-1: Loongson-1A, Loongson-1B, they are 32-bit MIPS CPUs.
>> >Loongson-2: Loongson-2E, Loongson-2F, Loongson-2G(including Loongson-
>> >             2Gq), they are 64-bit MIPS CPUs.
>> >Loongson-3: Loongson-3A, it is a 64-bit MIPS CPU.
>> >
>> >Signed-off-by: Huacai Chen<chenhc@lemote.com>
>> >Signed-off-by: Hongliang Tao<taohl@lemote.com>
>> >Signed-off-by: Hua Yan<yanh@lemote.com>
>> >---
>> >  arch/mips/Kconfig                            |   13 ++++
>> >  arch/mips/include/asm/addrspace.h            |    6 ++
>> >  arch/mips/include/asm/cpu.h                  |    6 +-
>> >  arch/mips/include/asm/mach-loongson/spaces.h |   15 +++++
>> >  arch/mips/include/asm/module.h               |    2 +
>> >  arch/mips/include/asm/pgtable-bits.h         |    7 ++
>> >  arch/mips/kernel/Makefile                    |    1 +
>> >  arch/mips/kernel/cpu-probe.c                 |   12 +++-
>> >  arch/mips/lib/Makefile                       |    1 +
>> >  arch/mips/loongson/Kconfig                   |    4 +
>> >  arch/mips/loongson/Platform                  |    1 +
>> >  arch/mips/loongson/common/env.c              |    3 +
>> >  arch/mips/loongson/common/setup.c            |    6 +-
>> >  arch/mips/mm/Makefile                        |    1 +
>> >  arch/mips/mm/c-r4k.c                         |   84 ++++++++++++++++++++++++++
>> >  arch/mips/mm/tlb-r4k.c                       |    2 +-
>> >  arch/mips/mm/tlbex.c                         |    1 +
>> >  17 files changed, 156 insertions(+), 9 deletions(-)
>>
>> This patch is too big.  It should be split up into smaller but
>> related parts.
>>
>> For example, the parts that add new identifier constants should be
>> first.  Then a separate patch for cpu-probe.c where they are used.
>>
>> And...
>>
>> >  create mode 100644 arch/mips/include/asm/mach-loongson/spaces.h
>> >
>> >diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
>> >index c179461..38e460b 100644
>> >--- a/arch/mips/Kconfig
>> >+++ b/arch/mips/Kconfig
>> >@@ -1544,6 +1544,16 @@ config CPU_LOONGSON2
>> >     select CPU_SUPPORTS_64BIT_KERNEL
>> >     select CPU_SUPPORTS_HIGHMEM
>> >
>> >+config CPU_LOONGSON3
>> >+    bool "Loongson 3 CPU"
>> >+    depends on SYS_HAS_CPU_LOONGSON3
>> >+    select CPU_SUPPORTS_32BIT_KERNEL
>> >+    select CPU_SUPPORTS_64BIT_KERNEL
>> >+    select CPU_SUPPORTS_HIGHMEM
>> >+    help
>> >+            The Loongson 3 processor implements the MIPS III instruction set
>> >+            with many extensions.
>> >+
>>
>> This bit must be the very last patch of the entire set, not the first.
>>
>> Ask yourself what would happen if someone did a build selecting
>> CPU_LOONGSON3 after this patch were applied?  Would a runnable
>> kernel result?  If the answer is no, then you did it in the wrong
>> order.
>
> Just to clarify and also because I only recently had the discussion with
> somebody.  What is very important is that a patch series never ever
> break something when it gets only partially applied.  This is because
> all the automated testing and debugging that is being used today.  The
> most common example is git-bisect but lately aiaiai [1] is becoming
> fashionable, too.  So I rather spend some extra time on reviewing a big,
> complex patch now than living with the consequences of improper splitting
> later.  But of course properlz split patches are always preferred :-)
>
>  Ralf
>
> [1] http://lwn.net/Articles/488992/

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH 14/14] MIPS: Loongson: Add a Loongson 3 default config file.
  2012-06-15 14:37   ` LIU Qi
@ 2012-06-16 12:52     ` huacai chen
  0 siblings, 0 replies; 34+ messages in thread
From: huacai chen @ 2012-06-16 12:52 UTC (permalink / raw)
  To: LIU Qi
  Cc: Ralf Baechle, linux-mips, Fuxin Zhang, Zhangjin Wu, Huacai Chen,
	Hongliang Tao, Hua Yan

Thank you, I'll do this later.

On Fri, Jun 15, 2012 at 10:37 PM, LIU Qi <liuqi82@gmail.com> wrote:
> On Fri, Jun 15, 2012 at 04:10:01PM +0800, Huacai Chen wrote:
>  > Signed-off-by: Huacai Chen <chenhc@lemote.com>
>  > Signed-off-by: Hongliang Tao <taohl@lemote.com>
>  > Signed-off-by: Hua Yan <yanh@lemote.com>
>  > ---
>  >  arch/mips/configs/loongson3_defconfig |  704 +++++++++++++++++++++++++++++++++
>  >  1 files changed, 704 insertions(+), 0 deletions(-)
>  >  create mode 100644 arch/mips/configs/loongson3_defconfig
>
> It is better to generate the defconfig file using `make savedefconfig`.
>
> LIU Qi

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH 09/14] ata: Use 32bit DMA in AHCI for Loongson 3.
  2012-06-15 12:42     ` huacai chen
@ 2012-06-17 12:05       ` Borislav Petkov
  2012-06-18  9:04         ` huacai chen
  0 siblings, 1 reply; 34+ messages in thread
From: Borislav Petkov @ 2012-06-17 12:05 UTC (permalink / raw)
  To: huacai chen
  Cc: Sergei Shtylyov, Ralf Baechle, linux-mips, Fuxin Zhang,
	Zhangjin Wu, Huacai Chen, Hongliang Tao, Hua Yan, linux-ide

On Fri, Jun 15, 2012 at 08:42:47PM +0800, huacai chen wrote:
> On Fri, Jun 15, 2012 at 6:04 PM, Sergei Shtylyov <sshtylyov@mvista.com> wrote:
> > Hello.
> >
> >
> > On 15-06-2012 12:09, Huacai Chen wrote:
> >
> >> Signed-off-by: Huacai Chen<chenhc@lemote.com>
> >> Signed-off-by: Hongliang Tao<taohl@lemote.com>
> >> Signed-off-by: Hua Yan<yanh@lemote.com>
> >
> >
> >   You  should have CCed the 'linux-ide' mailing list.
> >
> >
> >> diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
> >> index ebaf67e..3e3cfd8 100644
> >> --- a/drivers/ata/ahci.c
> >> +++ b/drivers/ata/ahci.c
> >> @@ -183,7 +183,12 @@ static const struct ata_port_info ahci_port_info[] =
> >> {
> >>        },
> >>        [board_ahci_sb700] =    /* for SB700 and SB800 */
> >>        {
> >> +#ifndef CONFIG_CPU_LOONGSON3
> >>                AHCI_HFLAGS     (AHCI_HFLAG_IGN_SERR_INTERNAL),
> >> +#else
> >> +               AHCI_HFLAGS     (AHCI_HFLAG_IGN_SERR_INTERNAL |
> >> +                                               AHCI_HFLAG_32BIT_ONLY),
> >> +#endif
> >
> >
> >   No, this #ifdef'ery won't do. You should add a new board type.
> All Loongson-3 based machines use AMD SB700 chipsets, add a new board
> type is better than #ifdef?

SB700/800 chipsets don't need to set a 32-bit only DMA flag; why do you
need it when you use the same chipset?

-- 
Regards/Gruss,
    Boris.

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH 09/14] ata: Use 32bit DMA in AHCI for Loongson 3.
  2012-06-17 12:05       ` Borislav Petkov
@ 2012-06-18  9:04         ` huacai chen
  2012-06-18 10:10           ` Borislav Petkov
  0 siblings, 1 reply; 34+ messages in thread
From: huacai chen @ 2012-06-18  9:04 UTC (permalink / raw)
  To: Borislav Petkov
  Cc: Sergei Shtylyov, Ralf Baechle, linux-mips, Fuxin Zhang,
	Zhangjin Wu, Huacai Chen, Hongliang Tao, Hua Yan, linux-ide

Do you means it is a better idea to modify "enum board_ids" and add a
new board id such as board_ahci_sb700_loongson, and then add a new
entry in ahci_port_info[]?
If so, I think there is a problem: the pci id of our AHCI controller
is 1002:4390, if I add board_ahci_sb700_loongson, then I should also
add
{ PCI_VDEVICE(ATI, 0x4390), board_ahci_sb700_loongson },
in ahci_pci_tbl[], but ahci_pci_tbl[] already has a line
{ PCI_VDEVICE(ATI, 0x4390), board_ahci_sb700 },
Then which entry will match the device?

On Sun, Jun 17, 2012 at 8:05 PM, Borislav Petkov <bp@alien8.de> wrote:
> On Fri, Jun 15, 2012 at 08:42:47PM +0800, huacai chen wrote:
>> On Fri, Jun 15, 2012 at 6:04 PM, Sergei Shtylyov <sshtylyov@mvista.com> wrote:
>> > Hello.
>> >
>> >
>> > On 15-06-2012 12:09, Huacai Chen wrote:
>> >
>> >> Signed-off-by: Huacai Chen<chenhc@lemote.com>
>> >> Signed-off-by: Hongliang Tao<taohl@lemote.com>
>> >> Signed-off-by: Hua Yan<yanh@lemote.com>
>> >
>> >
>> >   You  should have CCed the 'linux-ide' mailing list.
>> >
>> >
>> >> diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
>> >> index ebaf67e..3e3cfd8 100644
>> >> --- a/drivers/ata/ahci.c
>> >> +++ b/drivers/ata/ahci.c
>> >> @@ -183,7 +183,12 @@ static const struct ata_port_info ahci_port_info[] =
>> >> {
>> >>        },
>> >>        [board_ahci_sb700] =    /* for SB700 and SB800 */
>> >>        {
>> >> +#ifndef CONFIG_CPU_LOONGSON3
>> >>                AHCI_HFLAGS     (AHCI_HFLAG_IGN_SERR_INTERNAL),
>> >> +#else
>> >> +               AHCI_HFLAGS     (AHCI_HFLAG_IGN_SERR_INTERNAL |
>> >> +                                               AHCI_HFLAG_32BIT_ONLY),
>> >> +#endif
>> >
>> >
>> >   No, this #ifdef'ery won't do. You should add a new board type.
>> All Loongson-3 based machines use AMD SB700 chipsets, add a new board
>> type is better than #ifdef?
>
> SB700/800 chipsets don't need to set a 32-bit only DMA flag; why do you
> need it when you use the same chipset?
>
> --
> Regards/Gruss,
>    Boris.

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH 09/14] ata: Use 32bit DMA in AHCI for Loongson 3.
  2012-06-18  9:04         ` huacai chen
@ 2012-06-18 10:10           ` Borislav Petkov
  2012-06-18 10:41             ` Huacai Chen
  0 siblings, 1 reply; 34+ messages in thread
From: Borislav Petkov @ 2012-06-18 10:10 UTC (permalink / raw)
  To: huacai chen
  Cc: Sergei Shtylyov, Ralf Baechle, linux-mips, Fuxin Zhang,
	Zhangjin Wu, Huacai Chen, Hongliang Tao, Hua Yan, linux-ide

On Mon, Jun 18, 2012 at 05:04:14PM +0800, huacai chen wrote:
> Do you means it is a better idea to modify "enum board_ids" and add a
> new board id such as board_ahci_sb700_loongson, and then add a new
> entry in ahci_port_info[]?
> If so, I think there is a problem: the pci id of our AHCI controller
> is 1002:4390, if I add board_ahci_sb700_loongson, then I should also
> add
> { PCI_VDEVICE(ATI, 0x4390), board_ahci_sb700_loongson },
> in ahci_pci_tbl[], but ahci_pci_tbl[] already has a line
> { PCI_VDEVICE(ATI, 0x4390), board_ahci_sb700 },
> Then which entry will match the device?

Before you do anything, my question is:

SB700/800 chipsets don't need to set a 32-bit only DMA flag; why do you
need it when you use the same chipset?

So why do you need to do 32-bit DMA only when the chipset supports
64-bit DMA just fine?

Thanks.

-- 
Regards/Gruss,
    Boris.

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH 09/14] ata: Use 32bit DMA in AHCI for Loongson 3.
  2012-06-18 10:10           ` Borislav Petkov
@ 2012-06-18 10:41             ` Huacai Chen
  2012-06-18 14:52               ` Borislav Petkov
  0 siblings, 1 reply; 34+ messages in thread
From: Huacai Chen @ 2012-06-18 10:41 UTC (permalink / raw)
  To: Borislav Petkov
  Cc: Sergei Shtylyov, Ralf Baechle, linux-mips, Fuxin Zhang,
	Zhangjin Wu, Huacai Chen, Hongliang Tao, Hua Yan, linux-ide

Ohh, this is because Loongson-3 has a hardware bug, when the HT
controller receive a 64-bit DMA address, the high bits is lost. So set
to 32-bit DMA is just a workaround.

I'm sorry that I didn't describe this clearly.

On Mon, Jun 18, 2012 at 6:10 PM, Borislav Petkov <bp@alien8.de> wrote:
> On Mon, Jun 18, 2012 at 05:04:14PM +0800, huacai chen wrote:
>> Do you means it is a better idea to modify "enum board_ids" and add a
>> new board id such as board_ahci_sb700_loongson, and then add a new
>> entry in ahci_port_info[]?
>> If so, I think there is a problem: the pci id of our AHCI controller
>> is 1002:4390, if I add board_ahci_sb700_loongson, then I should also
>> add
>> { PCI_VDEVICE(ATI, 0x4390), board_ahci_sb700_loongson },
>> in ahci_pci_tbl[], but ahci_pci_tbl[] already has a line
>> { PCI_VDEVICE(ATI, 0x4390), board_ahci_sb700 },
>> Then which entry will match the device?
>
> Before you do anything, my question is:
>
> SB700/800 chipsets don't need to set a 32-bit only DMA flag; why do you
> need it when you use the same chipset?
>
> So why do you need to do 32-bit DMA only when the chipset supports
> 64-bit DMA just fine?
>
> Thanks.
>
> --
> Regards/Gruss,
>    Boris.

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH 09/14] ata: Use 32bit DMA in AHCI for Loongson 3.
  2012-06-18 10:41             ` Huacai Chen
@ 2012-06-18 14:52               ` Borislav Petkov
  0 siblings, 0 replies; 34+ messages in thread
From: Borislav Petkov @ 2012-06-18 14:52 UTC (permalink / raw)
  To: Huacai Chen
  Cc: Sergei Shtylyov, Ralf Baechle, linux-mips, Fuxin Zhang,
	Zhangjin Wu, Huacai Chen, Hongliang Tao, Hua Yan, linux-ide

On Mon, Jun 18, 2012 at 06:41:58PM +0800, Huacai Chen wrote:
> Ohh, this is because Loongson-3 has a hardware bug, when the HT
> controller receive a 64-bit DMA address, the high bits is lost. So set
> to 32-bit DMA is just a workaround.

Ok, this should definitely go into the commit message of your patch then
since it explains why you need that flag set.

Thanks.

-- 
Regards/Gruss,
Boris.

^ permalink raw reply	[flat|nested] 34+ messages in thread

end of thread, other threads:[~2012-06-18 14:52 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-15  8:09 [PATCH 00/14] MIPS: Add Loongson-3 based machines support Huacai Chen
2012-06-15  8:09 ` [PATCH 01/14] MIPS: Loongson: Add basic Loongson 3 CPU support Huacai Chen
2012-06-15 15:59   ` David Daney
2012-06-15 16:13     ` Ralf Baechle
2012-06-16 12:49       ` huacai chen
2012-06-15  8:09 ` [PATCH 02/14] MIPS: Loongson 3: Add Lemote-3A machtypes definition Huacai Chen
2012-06-15  8:09 ` [PATCH 03/14] MIPS: Loongson: Make Loongson 3 to use BCD format for RTC Huacai Chen
2012-06-15  8:09 ` [PATCH 04/14] MIPS: Loongson: Add UEFI-like firmware interface support Huacai Chen
2012-06-15  8:09 ` [PATCH 05/14] MIPS: Loongson 3: Add HT-linked PCI support Huacai Chen
2012-06-15 14:34   ` LIU Qi
2012-06-15  8:09 ` [PATCH 06/14] MIPS: Loongson 3: Add IRQ init and dispatch support Huacai Chen
2012-06-15 14:32   ` LIU Qi
2012-06-15  8:09 ` [PATCH 07/14] MIPS: Loongson 3: Add serial port support Huacai Chen
2012-06-15  9:50   ` Arnaud Patard
2012-06-15 11:44     ` huacai chen
2012-06-15  8:09 ` [PATCH 08/14] MIPS: Loongson: Add swiotlb to support big memory (>4GB) Huacai Chen
2012-06-15  8:09 ` [PATCH 09/14] ata: Use 32bit DMA in AHCI for Loongson 3 Huacai Chen
2012-06-15 10:04   ` Sergei Shtylyov
2012-06-15 12:42     ` huacai chen
2012-06-17 12:05       ` Borislav Petkov
2012-06-18  9:04         ` huacai chen
2012-06-18 10:10           ` Borislav Petkov
2012-06-18 10:41             ` Huacai Chen
2012-06-18 14:52               ` Borislav Petkov
2012-06-15  8:09 ` [PATCH 10/14] drm/radeon: Make radeon card usable for Loongson Huacai Chen
2012-06-15 14:28   ` LIU Qi
2012-06-15  8:09 ` [PATCH 11/14] ALSA: Make hda sound " Huacai Chen
2012-06-15  8:09 ` [PATCH 12/14] MIPS: Loongson 3: Add Loongson-3 SMP support Huacai Chen
2012-06-15  8:10 ` [PATCH 13/14] MIPS: Loongson 3: Add CPU Hotplug support Huacai Chen
2012-06-15  8:10 ` [PATCH 14/14] MIPS: Loongson: Add a Loongson 3 default config file Huacai Chen
2012-06-15 14:37   ` LIU Qi
2012-06-16 12:52     ` huacai chen
2012-06-15 13:10 ` [PATCH 00/14] MIPS: Add Loongson-3 based machines support LIU Qi
2012-06-16 12:46   ` huacai chen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.