All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 0/7] Add basic support for Loongson-2K1000
@ 2021-03-10  7:56 Qing Zhang
  2021-03-10  7:56 ` [PATCH v4 1/7] MIPS: Loongson64: DeviceTree " Qing Zhang
                   ` (6 more replies)
  0 siblings, 7 replies; 17+ messages in thread
From: Qing Zhang @ 2021-03-10  7:56 UTC (permalink / raw)
  To: Huacai Chen, Jiaxun Yang, Thomas Bogendoerfer, Thomas Gleixner,
	Marc Zyngier
  Cc: linux-mips, linux-kernel, devicetree

These patches support single-core DTS boot to the serial port login
interface, which can be operated using conventional commands.

I have successfully tested it on the Loongson 2K1000 machine.
pmon: http://cgit.loongnix.org/cgit/pmon-loongson3/

Note:
After the basic support is merged, 
I will submit SMP and other peripheral support in the future. 

Qing Zhang (7):
  MIPS: Loongson64: DeviceTree for Loongson-2K1000
  MIPS: Loongson64: Distinguish firmware dependencies DTB/LEFI
  MIPS: Loongson64: Add support for the Loongson-2K1000 to get
    cpu_clock_freq
  MIPS: Loongson64: Add Loongson-2K1000 early_printk_port
  irqchip/loongson-liointc: irqchip add 2.0 version
  dt-bindings: interrupt-controller: Add Loongson-2K1000 LIOINTC
  MIPS: Loongson64: Add a Loongson-2K1000 default config file

 .../loongson,liointc.yaml                     |   7 +-
 arch/mips/boot/dts/loongson/Makefile          |   1 +
 .../boot/dts/loongson/loongson64-2k1000.dtsi  | 243 ++++++++++++
 .../dts/loongson/loongson64_2core_2k1000.dts  |  10 +
 arch/mips/configs/loongson2k_defconfig        | 353 ++++++++++++++++++
 .../include/asm/mach-loongson64/boot_param.h  |   6 +
 .../asm/mach-loongson64/builtin_dtbs.h        |   1 +
 .../include/asm/mach-loongson64/loongson.h    |   3 +-
 arch/mips/loongson64/env.c                    |  13 +-
 arch/mips/loongson64/init.c                   |  21 +-
 arch/mips/loongson64/time.c                   |  24 ++
 drivers/irqchip/irq-loongson-liointc.c        |  58 ++-
 12 files changed, 723 insertions(+), 17 deletions(-)
 create mode 100644 arch/mips/boot/dts/loongson/loongson64-2k1000.dtsi
 create mode 100644 arch/mips/boot/dts/loongson/loongson64_2core_2k1000.dts
 create mode 100644 arch/mips/configs/loongson2k_defconfig

-- 
2.20.1


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

* [PATCH v4 1/7] MIPS: Loongson64: DeviceTree for Loongson-2K1000
  2021-03-10  7:56 [PATCH v4 0/7] Add basic support for Loongson-2K1000 Qing Zhang
@ 2021-03-10  7:56 ` Qing Zhang
  2021-03-10  7:56 ` [PATCH v4 2/7] MIPS: Loongson64: Distinguish firmware dependencies DTB/LEFI Qing Zhang
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 17+ messages in thread
From: Qing Zhang @ 2021-03-10  7:56 UTC (permalink / raw)
  To: Huacai Chen, Jiaxun Yang, Thomas Bogendoerfer, Thomas Gleixner,
	Marc Zyngier
  Cc: linux-mips, linux-kernel, devicetree, Ming Wang

Add DeviceTree files for Loongson-2K1000 processor,currently only
supports single-core boot.

Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
Signed-off-by: Qing Zhang <zhangqing@loongson.cn>
Tested-by: Ming Wang <wangming01@loongson.cn>
---

v3-v4: Standard submission of information 

 arch/mips/boot/dts/loongson/Makefile          |   1 +
 .../boot/dts/loongson/loongson64-2k1000.dtsi  | 243 ++++++++++++++++++
 .../dts/loongson/loongson64_2core_2k1000.dts  |  10 +
 .../asm/mach-loongson64/builtin_dtbs.h        |   1 +
 4 files changed, 255 insertions(+)
 create mode 100644 arch/mips/boot/dts/loongson/loongson64-2k1000.dtsi
 create mode 100644 arch/mips/boot/dts/loongson/loongson64_2core_2k1000.dts

diff --git a/arch/mips/boot/dts/loongson/Makefile b/arch/mips/boot/dts/loongson/Makefile
index 8fd0efb37423..72267bfda9b4 100644
--- a/arch/mips/boot/dts/loongson/Makefile
+++ b/arch/mips/boot/dts/loongson/Makefile
@@ -1,4 +1,5 @@
 # SPDX_License_Identifier: GPL_2.0
+dtb-$(CONFIG_MACH_LOONGSON64)	+= loongson64_2core_2k1000.dtb
 dtb-$(CONFIG_MACH_LOONGSON64)	+= loongson64c_4core_ls7a.dtb
 dtb-$(CONFIG_MACH_LOONGSON64)	+= loongson64c_4core_rs780e.dtb
 dtb-$(CONFIG_MACH_LOONGSON64)	+= loongson64c_8core_rs780e.dtb
diff --git a/arch/mips/boot/dts/loongson/loongson64-2k1000.dtsi b/arch/mips/boot/dts/loongson/loongson64-2k1000.dtsi
new file mode 100644
index 000000000000..fd0e99bfe57b
--- /dev/null
+++ b/arch/mips/boot/dts/loongson/loongson64-2k1000.dtsi
@@ -0,0 +1,243 @@
+// SPDX-License-Identifier: GPL-3.0
+
+/dts-v1/;
+
+#include <dt-bindings/interrupt-controller/irq.h>
+
+/ {
+	compatible = "loongson,loongson2k1000";
+
+	#address-cells = <2>;
+	#size-cells = <2>;
+
+	cpus {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		cpu0: cpu@0 {
+			device_type = "cpu";
+			compatible = "loongson,gs264";
+			reg = <0x0>;
+			#clock-cells = <1>;
+			clocks = <&cpu_clk>;
+		};
+	};
+
+	memory {
+		compatible = "memory";
+		device_type = "memory";
+		reg = <0x00000000 0x00200000 0x00000000 0x0ee00000>, /* 238 MB at 2 MB */
+			<0x00000000 0x20000000 0x00000000 0x1f000000>, /* 496 MB at 512 MB */
+			<0x00000001 0x10000000 0x00000001 0xb0000000>; /* 6912 MB at 4352MB */
+	};
+
+	cpu_clk: cpu_clk {
+		#clock-cells = <0>;
+		compatible = "fixed-clock";
+		clock-frequency = <800000000>;
+	};
+
+	cpuintc: interrupt-controller {
+		#address-cells = <0>;
+		#interrupt-cells = <1>;
+		interrupt-controller;
+		compatible = "mti,cpu-interrupt-controller";
+	};
+
+	package0: bus@10000000 {
+		compatible = "simple-bus";
+		#address-cells = <2>;
+		#size-cells = <2>;
+		ranges = <0 0x10000000 0 0x10000000 0 0x10000000 /* ioports */
+			0 0x40000000 0 0x40000000 0 0x40000000
+			0xfe 0x00000000 0xfe 0x00000000 0 0x40000000>;
+
+		liointc0: interrupt-controller@1fe11400 {
+			compatible = "loongson,liointc-2.0";
+			reg = <0 0x1fe11400 0 0x40>,
+				<0 0x1fe11040 0 0x8>,
+				<0 0x1fe11140 0 0x8>;
+			reg-names = "main", "isr0", "isr1";
+
+			interrupt-controller;
+			#interrupt-cells = <2>;
+
+			interrupt-parent = <&cpuintc>;
+			interrupts = <2>;
+			interrupt-names = "int0";
+
+			loongson,parent_int_map = <0xffffffff>, /* int0 */
+						<0x00000000>, /* int1 */
+						<0x00000000>, /* int2 */
+						<0x00000000>; /* int3 */
+		};
+
+		liointc1: interrupt-controller@1fe11440 {
+			compatible = "loongson,liointc-2.0";
+			reg = <0 0x1fe11440 0 0x40>,
+				<0 0x1fe11048 0 0x8>,
+				<0 0x1fe11148 0 0x8>;
+			reg-names = "main", "isr0", "isr1";
+
+			interrupt-controller;
+			#interrupt-cells = <2>;
+
+			interrupt-parent = <&cpuintc>;
+			interrupts = <3>;
+			interrupt-names = "int1";
+
+			loongson,parent_int_map = <0x00000000>, /* int0 */
+						<0xffffffff>, /* int1 */
+						<0x00000000>, /* int2 */
+						<0x00000000>; /* int3 */
+		};
+
+		uart0: serial@1fe00000 {
+			compatible = "ns16550a";
+			reg = <0 0x1fe00000 0 0x8>;
+			clock-frequency = <125000000>;
+			interrupt-parent = <&liointc0>;
+			interrupts = <0 IRQ_TYPE_LEVEL_LOW>;
+			no-loopback-test;
+		};
+
+		pci@1a000000 {
+			compatible = "loongson,ls2k-pci";
+			device_type = "pci";
+			#address-cells = <3>;
+			#size-cells = <2>;
+			#interrupt-cells = <2>;
+
+			reg = <0 0x1a000000 0 0x02000000>,
+				<0xfe 0x00000000 0 0x20000000>;
+
+			ranges = <0x01000000 0x0 0x00000000 0x0 0x18000000  0x0 0x00010000>,
+				 <0x02000000 0x0 0x40000000 0x0 0x40000000  0x0 0x40000000>;
+
+			ehci@4,1 {
+				compatible = "pci0014,7a14.0",
+						   "pci0014,7a14",
+						   "pciclass0c0320",
+						   "pciclass0c03";
+
+				reg = <0x2100 0x0 0x0 0x0 0x0>;
+				interrupts = <18 IRQ_TYPE_LEVEL_LOW>;
+				interrupt-parent = <&liointc1>;
+			};
+
+			ehci@4,2 {
+				compatible = "pci0014,7a24.0",
+						   "pci0014,7a24",
+						   "pciclass0c0310",
+						   "pciclass0c03";
+
+				reg = <0x2200 0x0 0x0 0x0 0x0>;
+				interrupts = <17 IRQ_TYPE_LEVEL_LOW>;
+				interrupt-parent = <&liointc1>;
+			};
+
+			sata@8,0 {
+				compatible = "pci0014,7a08.0",
+						   "pci0014,7a08",
+						   "pciclass010601",
+						   "pciclass0106";
+
+				reg = <0x4000 0x0 0x0 0x0 0x0>;
+				interrupts = <19 IRQ_TYPE_LEVEL_LOW>;
+				interrupt-parent = <&liointc0>;
+			};
+
+			pci_bridge@9,0 {
+				compatible = "pci0014,7a19.0",
+						   "pci0014,7a19",
+						   "pciclass060400",
+						   "pciclass0604";
+
+				reg = <0x4800 0x0 0x0 0x0 0x0>;
+				#interrupt-cells = <1>;
+				interrupts = <0 IRQ_TYPE_LEVEL_LOW>;
+				interrupt-parent = <&liointc1>;
+				interrupt-map-mask = <0 0 0 0>;
+				interrupt-map = <0 0 0 0 &liointc1 0 IRQ_TYPE_LEVEL_LOW>;
+				external-facing;
+			};
+
+			pci_bridge@a,0 {
+				compatible = "pci0014,7a19.0",
+						   "pci0014,7a19",
+						   "pciclass060400",
+						   "pciclass0604";
+
+				reg = <0x5000 0x0 0x0 0x0 0x0>;
+				#interrupt-cells = <1>;
+				interrupts = <1 IRQ_TYPE_LEVEL_LOW>;
+				interrupt-parent = <&liointc1>;
+				interrupt-map-mask = <0 0 0 0>;
+				interrupt-map = <0 0 0 0 &liointc1 1 IRQ_TYPE_LEVEL_LOW>;
+				external-facing;
+			};
+
+			pci_bridge@b,0 {
+				compatible = "pci0014,7a19.0",
+						   "pci0014,7a19",
+						   "pciclass060400",
+						   "pciclass0604";
+
+				reg = <0x5800 0x0 0x0 0x0 0x0>;
+				#interrupt-cells = <1>;
+				interrupts = <2 IRQ_TYPE_LEVEL_LOW>;
+				interrupt-parent = <&liointc1>;
+				interrupt-map-mask = <0 0 0 0>;
+				interrupt-map = <0 0 0 0 &liointc1 2 IRQ_TYPE_LEVEL_LOW>;
+				external-facing;
+			};
+
+			pci_bridge@c,0 {
+				compatible = "pci0014,7a19.0",
+						   "pci0014,7a19",
+						   "pciclass060400",
+						   "pciclass0604";
+
+				reg = <0x6000 0x0 0x0 0x0 0x0>;
+				#interrupt-cells = <1>;
+				interrupts = <3 IRQ_TYPE_LEVEL_LOW>;
+				interrupt-parent = <&liointc1>;
+				interrupt-map-mask = <0 0 0 0>;
+				interrupt-map = <0 0 0 0 &liointc1 3 IRQ_TYPE_LEVEL_LOW>;
+				external-facing;
+			};
+
+			pci_bridge@d,0 {
+				compatible = "pci0014,7a19.0",
+						   "pci0014,7a19",
+						   "pciclass060400",
+						   "pciclass0604";
+
+				reg = <0x6800 0x0 0x0 0x0 0x0>;
+				#interrupt-cells = <1>;
+				interrupts = <4 IRQ_TYPE_LEVEL_LOW>;
+				interrupt-parent = <&liointc1>;
+				interrupt-map-mask = <0 0 0 0>;
+				interrupt-map = <0 0 0 0 &liointc1 4 IRQ_TYPE_LEVEL_LOW>;
+				external-facing;
+			};
+
+			pci_bridge@e,0 {
+				compatible = "pci0014,7a19.0",
+						   "pci0014,7a19",
+						   "pciclass060400",
+						   "pciclass0604";
+
+				reg = <0x7000 0x0 0x0 0x0 0x0>;
+				#interrupt-cells = <1>;
+				interrupts = <5 IRQ_TYPE_LEVEL_LOW>;
+				interrupt-parent = <&liointc1>;
+				interrupt-map-mask = <0 0 0 0>;
+				interrupt-map = <0 0 0 0 &liointc1 5 IRQ_TYPE_LEVEL_LOW>;
+				external-facing;
+			};
+
+		};
+	};
+};
+
diff --git a/arch/mips/boot/dts/loongson/loongson64_2core_2k1000.dts b/arch/mips/boot/dts/loongson/loongson64_2core_2k1000.dts
new file mode 100644
index 000000000000..e31d2ee65cd5
--- /dev/null
+++ b/arch/mips/boot/dts/loongson/loongson64_2core_2k1000.dts
@@ -0,0 +1,10 @@
+// SPDX-License-Identifier: GPL-2.0
+
+/dts-v1/;
+
+#include "loongson64-2k1000.dtsi"
+
+/ {
+	compatible = "loongson,loongson64-2core-2k1000";
+};
+
diff --git a/arch/mips/include/asm/mach-loongson64/builtin_dtbs.h b/arch/mips/include/asm/mach-loongson64/builtin_dtbs.h
index 839410cda621..8be710557bdb 100644
--- a/arch/mips/include/asm/mach-loongson64/builtin_dtbs.h
+++ b/arch/mips/include/asm/mach-loongson64/builtin_dtbs.h
@@ -8,6 +8,7 @@
 #ifndef __ASM_MACH_LOONGSON64_BUILTIN_DTBS_H_
 #define __ASM_MACH_LOONGSON64_BUILTIN_DTBS_H_
 
+extern u32 __dtb_loongson64_2core_2k1000_begin[];
 extern u32 __dtb_loongson64c_4core_ls7a_begin[];
 extern u32 __dtb_loongson64c_4core_rs780e_begin[];
 extern u32 __dtb_loongson64c_8core_rs780e_begin[];
-- 
2.20.1


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

* [PATCH v4 2/7] MIPS: Loongson64: Distinguish firmware dependencies DTB/LEFI
  2021-03-10  7:56 [PATCH v4 0/7] Add basic support for Loongson-2K1000 Qing Zhang
  2021-03-10  7:56 ` [PATCH v4 1/7] MIPS: Loongson64: DeviceTree " Qing Zhang
@ 2021-03-10  7:56 ` Qing Zhang
  2021-03-10 10:57   ` Oleksij Rempel
  2021-03-10  7:56 ` [PATCH v4 3/7] MIPS: Loongson64: Add support for the Loongson-2K1000 to get cpu_clock_freq Qing Zhang
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 17+ messages in thread
From: Qing Zhang @ 2021-03-10  7:56 UTC (permalink / raw)
  To: Huacai Chen, Jiaxun Yang, Thomas Bogendoerfer, Thomas Gleixner,
	Marc Zyngier
  Cc: linux-mips, linux-kernel, devicetree, Ming Wang

Add DTB boot support, only support Loongson-2K1000 processor
for now, determine whether to use the built-in DTB or the DTB
from the firmware by checking the range of CKSEG0 and XKPHYS.
loongson_fw_interface will be used in the future.

Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
Signed-off-by: Qing Zhang <zhangqing@loongson.cn>
Tested-by: Ming Wang <wangming01@loongson.cn>
---

v3-v4: Standard submission of information
       Fix error handling 

 .../include/asm/mach-loongson64/boot_param.h     |  6 ++++++
 arch/mips/include/asm/mach-loongson64/loongson.h |  3 ++-
 arch/mips/loongson64/env.c                       | 13 ++++++++++++-
 arch/mips/loongson64/init.c                      | 16 ++++++++++++++--
 4 files changed, 34 insertions(+), 4 deletions(-)

diff --git a/arch/mips/include/asm/mach-loongson64/boot_param.h b/arch/mips/include/asm/mach-loongson64/boot_param.h
index 4592841b6b0c..43737401dc06 100644
--- a/arch/mips/include/asm/mach-loongson64/boot_param.h
+++ b/arch/mips/include/asm/mach-loongson64/boot_param.h
@@ -198,7 +198,13 @@ enum loongson_bridge_type {
 	VIRTUAL = 3
 };
 
+enum loongson_fw_interface {
+	LOONGSON_LEFI,
+	LOONGSON_DTB,
+};
+
 struct loongson_system_configuration {
+	enum loongson_fw_interface fw_interface;
 	u32 nr_cpus;
 	u32 nr_nodes;
 	int cores_per_node;
diff --git a/arch/mips/include/asm/mach-loongson64/loongson.h b/arch/mips/include/asm/mach-loongson64/loongson.h
index ac1c20e172a2..3f885fa26ba6 100644
--- a/arch/mips/include/asm/mach-loongson64/loongson.h
+++ b/arch/mips/include/asm/mach-loongson64/loongson.h
@@ -23,7 +23,8 @@ extern u32 memsize, highmemsize;
 extern const struct plat_smp_ops loongson3_smp_ops;
 
 /* loongson-specific command line, env and memory initialization */
-extern void __init prom_init_env(void);
+extern void __init prom_dtb_init_env(void);
+extern void __init prom_lefi_init_env(void);
 extern void __init szmem(unsigned int node);
 extern void *loongson_fdt_blob;
 
diff --git a/arch/mips/loongson64/env.c b/arch/mips/loongson64/env.c
index 51a5d050a94c..e7d3a06175e3 100644
--- a/arch/mips/loongson64/env.c
+++ b/arch/mips/loongson64/env.c
@@ -43,7 +43,18 @@ const char *get_system_type(void)
 	return "Generic Loongson64 System";
 }
 
-void __init prom_init_env(void)
+
+void __init prom_dtb_init_env(void)
+{
+	if ((fw_arg2 < CKSEG0 || fw_arg2 > CKSEG1)
+		&& (fw_arg2 < XKPHYS || fw_arg2 > XKSEG))
+
+		loongson_fdt_blob = __dtb_loongson64_2core_2k1000_begin;
+	else
+		loongson_fdt_blob = (void *)fw_arg2;
+}
+
+void __init prom_lefi_init_env(void)
 {
 	struct boot_params *boot_p;
 	struct loongson_params *loongson_p;
diff --git a/arch/mips/loongson64/init.c b/arch/mips/loongson64/init.c
index cfa788bca871..ed280b73bf89 100644
--- a/arch/mips/loongson64/init.c
+++ b/arch/mips/loongson64/init.c
@@ -52,6 +52,10 @@ void __init szmem(unsigned int node)
 	static unsigned long num_physpages;
 	u64 node_id, node_psize, start_pfn, end_pfn, mem_start, mem_size;
 
+	/* Otherwise come from DTB */
+	if (loongson_sysconf.fw_interface != LOONGSON_LEFI)
+		return;
+
 	/* Parse memory information and activate */
 	for (i = 0; i < loongson_memmap->nr_map; i++) {
 		node_id = loongson_memmap->map[i].node_id;
@@ -94,12 +98,20 @@ static void __init prom_init_memory(void)
 void __init prom_init(void)
 {
 	fw_init_cmdline();
-	prom_init_env();
+
+	if (fw_arg2 == 0 || (fdt_magic(fw_arg2) == FDT_MAGIC)) {
+		loongson_sysconf.fw_interface = LOONGSON_DTB;
+		prom_dtb_init_env();
+	} else {
+		loongson_sysconf.fw_interface = LOONGSON_LEFI;
+		prom_lefi_init_env();
+	}
 
 	/* init base address of io space */
 	set_io_port_base(PCI_IOBASE);
 
-	loongson_sysconf.early_config();
+	if (loongson_sysconf.early_config)
+		loongson_sysconf.early_config();
 
 #ifdef CONFIG_NUMA
 	prom_init_numa_memory();
-- 
2.20.1


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

* [PATCH v4 3/7] MIPS: Loongson64: Add support for the Loongson-2K1000 to get cpu_clock_freq
  2021-03-10  7:56 [PATCH v4 0/7] Add basic support for Loongson-2K1000 Qing Zhang
  2021-03-10  7:56 ` [PATCH v4 1/7] MIPS: Loongson64: DeviceTree " Qing Zhang
  2021-03-10  7:56 ` [PATCH v4 2/7] MIPS: Loongson64: Distinguish firmware dependencies DTB/LEFI Qing Zhang
@ 2021-03-10  7:56 ` Qing Zhang
  2021-03-10  8:50   ` Sergei Shtylyov
  2021-03-10  7:56 ` [PATCH v4 4/7] MIPS: Loongson64: Add Loongson-2K1000 early_printk_port Qing Zhang
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 17+ messages in thread
From: Qing Zhang @ 2021-03-10  7:56 UTC (permalink / raw)
  To: Huacai Chen, Jiaxun Yang, Thomas Bogendoerfer, Thomas Gleixner,
	Marc Zyngier
  Cc: linux-mips, linux-kernel, devicetree, Ming Wang

Get the fixed-clock from the CPU0 node of the device tree.

Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
Signed-off-by: Qing Zhang <zhangqing@loongson.cn>
Tested-by: Ming Wang <wangming01@loongson.cn>
---

v3-v4: Standard submission of information
       Add return after error

 arch/mips/loongson64/time.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/arch/mips/loongson64/time.c b/arch/mips/loongson64/time.c
index 91e842b58365..2d84f9b20a9b 100644
--- a/arch/mips/loongson64/time.c
+++ b/arch/mips/loongson64/time.c
@@ -11,9 +11,33 @@
 #include <asm/hpet.h>
 
 #include <loongson.h>
+#include <linux/clk.h>
+#include <linux/of_clk.h>
 
 void __init plat_time_init(void)
 {
+	struct clk *clk = NULL;
+	struct device_node *np;
+
+	if (loongson_sysconf.fw_interface == LOONGSON_DTB) {
+		of_clk_init(NULL);
+
+		np = of_get_cpu_node(0, NULL);
+		if (!np) {
+			pr_err("Failed to get CPU node\n");
+			return;
+		}
+
+		clk = of_clk_get(np, 0);
+		if (IS_ERR(clk)) {
+			pr_err("Failed to get CPU clock: %ld\n", PTR_ERR(clk));
+			return;
+		}
+
+		cpu_clock_freq = clk_get_rate(clk);
+		clk_put(clk);
+	}
+
 	/* setup mips r4k timer */
 	mips_hpt_frequency = cpu_clock_freq / 2;
 
-- 
2.20.1


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

* [PATCH v4 4/7] MIPS: Loongson64: Add Loongson-2K1000 early_printk_port
  2021-03-10  7:56 [PATCH v4 0/7] Add basic support for Loongson-2K1000 Qing Zhang
                   ` (2 preceding siblings ...)
  2021-03-10  7:56 ` [PATCH v4 3/7] MIPS: Loongson64: Add support for the Loongson-2K1000 to get cpu_clock_freq Qing Zhang
@ 2021-03-10  7:56 ` Qing Zhang
  2021-03-10  7:56 ` [PATCH v4 5/7] irqchip/loongson-liointc: irqchip add 2.0 version Qing Zhang
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 17+ messages in thread
From: Qing Zhang @ 2021-03-10  7:56 UTC (permalink / raw)
  To: Huacai Chen, Jiaxun Yang, Thomas Bogendoerfer, Thomas Gleixner,
	Marc Zyngier
  Cc: linux-mips, linux-kernel, devicetree, Ming Wang

Distinguish between Loongson-3A series CPU and Loongson-2K1000 CPU UART0.

Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
Signed-off-by: Qing Zhang <zhangqing@loongson.cn>
Tested-by: Ming Wang <wangming01@loongson.cn>
---

v3-v4: Standard submission of information

 arch/mips/loongson64/init.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/arch/mips/loongson64/init.c b/arch/mips/loongson64/init.c
index ed280b73bf89..d5a1eddb8202 100644
--- a/arch/mips/loongson64/init.c
+++ b/arch/mips/loongson64/init.c
@@ -120,7 +120,10 @@ void __init prom_init(void)
 #endif
 
 	/* Hardcode to CPU UART 0 */
-	setup_8250_early_printk_port(TO_UNCAC(LOONGSON_REG_BASE + 0x1e0), 0, 1024);
+	if ((read_c0_prid() & PRID_IMP_MASK) == PRID_IMP_LOONGSON_64R)
+		setup_8250_early_printk_port(TO_UNCAC(LOONGSON_REG_BASE), 0, 1024);
+	else
+		setup_8250_early_printk_port(TO_UNCAC(LOONGSON_REG_BASE + 0x1e0), 0, 1024);
 
 	register_smp_ops(&loongson3_smp_ops);
 	board_nmi_handler_setup = mips_nmi_setup;
-- 
2.20.1


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

* [PATCH v4 5/7] irqchip/loongson-liointc: irqchip add 2.0 version
  2021-03-10  7:56 [PATCH v4 0/7] Add basic support for Loongson-2K1000 Qing Zhang
                   ` (3 preceding siblings ...)
  2021-03-10  7:56 ` [PATCH v4 4/7] MIPS: Loongson64: Add Loongson-2K1000 early_printk_port Qing Zhang
@ 2021-03-10  7:56 ` Qing Zhang
  2021-03-10  7:56 ` [PATCH v4 6/7] dt-bindings: interrupt-controller: Add Loongson-2K1000 LIOINTC Qing Zhang
  2021-03-10  7:56 ` [PATCH v4 7/7] MIPS: Loongson64: Add a Loongson-2K1000 default config file Qing Zhang
  6 siblings, 0 replies; 17+ messages in thread
From: Qing Zhang @ 2021-03-10  7:56 UTC (permalink / raw)
  To: Huacai Chen, Jiaxun Yang, Thomas Bogendoerfer, Thomas Gleixner,
	Marc Zyngier
  Cc: linux-mips, linux-kernel, devicetree, Ming Wang

Add IO interrupt controller support for Loongson-2K1000, different
from the Loongson-3A series is that 2K1000 has 64 interrupt sources,
0-31 correspond to the device tree liointc0 device node, and the other
correspond to liointc1 node.

Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
Signed-off-by: Qing Zhang <zhangqing@loongson.cn>
Tested-by: Ming Wang <wangming01@loongson.cn>
---

v3-v4: Standard submission of information

 drivers/irqchip/irq-loongson-liointc.c | 58 ++++++++++++++++++++++----
 1 file changed, 49 insertions(+), 9 deletions(-)

diff --git a/drivers/irqchip/irq-loongson-liointc.c b/drivers/irqchip/irq-loongson-liointc.c
index 09b91b81851c..33219244c551 100644
--- a/drivers/irqchip/irq-loongson-liointc.c
+++ b/drivers/irqchip/irq-loongson-liointc.c
@@ -20,6 +20,7 @@
 
 #define LIOINTC_CHIP_IRQ	32
 #define LIOINTC_NUM_PARENT 4
+#define LIOINTC_NUM_CORES	4
 
 #define LIOINTC_INTC_CHIP_START	0x20
 
@@ -42,6 +43,7 @@ struct liointc_handler_data {
 struct liointc_priv {
 	struct irq_chip_generic		*gc;
 	struct liointc_handler_data	handler[LIOINTC_NUM_PARENT];
+	void __iomem			*core_isr[LIOINTC_NUM_CORES];
 	u8				map_cache[LIOINTC_CHIP_IRQ];
 	bool				has_lpc_irq_errata;
 };
@@ -51,11 +53,12 @@ static void liointc_chained_handle_irq(struct irq_desc *desc)
 	struct liointc_handler_data *handler = irq_desc_get_handler_data(desc);
 	struct irq_chip *chip = irq_desc_get_chip(desc);
 	struct irq_chip_generic *gc = handler->priv->gc;
+	int core = get_ebase_cpunum() % LIOINTC_NUM_CORES;
 	u32 pending;
 
 	chained_irq_enter(chip, desc);
 
-	pending = readl(gc->reg_base + LIOINTC_REG_INTC_STATUS);
+	pending = readl(handler->priv->core_isr[core]);
 
 	if (!pending) {
 		/* Always blame LPC IRQ if we have that bug */
@@ -141,6 +144,18 @@ static void liointc_resume(struct irq_chip_generic *gc)
 }
 
 static const char * const parent_names[] = {"int0", "int1", "int2", "int3"};
+static const char * const core_reg_names[] = {"isr0", "isr1", "isr2", "isr3"};
+
+static void __iomem *liointc_get_reg_byname(struct device_node *node,
+						const char *name)
+{
+	int index = of_property_match_string(node, "reg-names", name);
+
+	if (index < 0)
+		return NULL;
+
+	return of_iomap(node, index);
+}
 
 static int __init liointc_of_init(struct device_node *node,
 				  struct device_node *parent)
@@ -159,10 +174,28 @@ static int __init liointc_of_init(struct device_node *node,
 	if (!priv)
 		return -ENOMEM;
 
-	base = of_iomap(node, 0);
-	if (!base) {
-		err = -ENODEV;
-		goto out_free_priv;
+	if (of_device_is_compatible(node, "loongson,liointc-2.0")) {
+		base = liointc_get_reg_byname(node, "main");
+		if (!base) {
+			err = -ENODEV;
+			goto out_free_priv;
+		}
+
+		for (i = 0; i < LIOINTC_NUM_CORES; i++)
+			priv->core_isr[i] = liointc_get_reg_byname(node, core_reg_names[i]);
+		if (!priv->core_isr[0]) {
+			err = -ENODEV;
+			goto out_iounmap_base;
+		}
+	} else {
+		base = of_iomap(node, 0);
+		if (!base) {
+			err = -ENODEV;
+			goto out_free_priv;
+		}
+
+		for (i = 0; i < LIOINTC_NUM_CORES; i++)
+			priv->core_isr[i] = base + LIOINTC_REG_INTC_STATUS;
 	}
 
 	for (i = 0; i < LIOINTC_NUM_PARENT; i++) {
@@ -172,7 +205,7 @@ static int __init liointc_of_init(struct device_node *node,
 	}
 	if (!have_parent) {
 		err = -ENODEV;
-		goto out_iounmap;
+		goto out_iounmap_isr;
 	}
 
 	sz = of_property_read_variable_u32_array(node,
@@ -183,7 +216,7 @@ static int __init liointc_of_init(struct device_node *node,
 	if (sz < 4) {
 		pr_err("loongson-liointc: No parent_int_map\n");
 		err = -ENODEV;
-		goto out_iounmap;
+		goto out_iounmap_isr;
 	}
 
 	for (i = 0; i < LIOINTC_NUM_PARENT; i++)
@@ -195,7 +228,7 @@ static int __init liointc_of_init(struct device_node *node,
 	if (!domain) {
 		pr_err("loongson-liointc: cannot add IRQ domain\n");
 		err = -EINVAL;
-		goto out_iounmap;
+		goto out_iounmap_isr;
 	}
 
 	err = irq_alloc_domain_generic_chips(domain, 32, 1,
@@ -260,7 +293,13 @@ static int __init liointc_of_init(struct device_node *node,
 
 out_free_domain:
 	irq_domain_remove(domain);
-out_iounmap:
+out_iounmap_isr:
+	for (i = 0; i < LIOINTC_NUM_CORES; i++) {
+		if (!priv->core_isr[i])
+			continue;
+		iounmap(priv->core_isr[i]);
+	}
+out_iounmap_base:
 	iounmap(base);
 out_free_priv:
 	kfree(priv);
@@ -270,3 +309,4 @@ static int __init liointc_of_init(struct device_node *node,
 
 IRQCHIP_DECLARE(loongson_liointc_1_0, "loongson,liointc-1.0", liointc_of_init);
 IRQCHIP_DECLARE(loongson_liointc_1_0a, "loongson,liointc-1.0a", liointc_of_init);
+IRQCHIP_DECLARE(loongson_liointc_2_0, "loongson,liointc-2.0", liointc_of_init);
-- 
2.20.1


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

* [PATCH v4 6/7] dt-bindings: interrupt-controller: Add Loongson-2K1000 LIOINTC
  2021-03-10  7:56 [PATCH v4 0/7] Add basic support for Loongson-2K1000 Qing Zhang
                   ` (4 preceding siblings ...)
  2021-03-10  7:56 ` [PATCH v4 5/7] irqchip/loongson-liointc: irqchip add 2.0 version Qing Zhang
@ 2021-03-10  7:56 ` Qing Zhang
  2021-03-10 12:04   ` Jiaxun Yang
  2021-03-10  7:56 ` [PATCH v4 7/7] MIPS: Loongson64: Add a Loongson-2K1000 default config file Qing Zhang
  6 siblings, 1 reply; 17+ messages in thread
From: Qing Zhang @ 2021-03-10  7:56 UTC (permalink / raw)
  To: Huacai Chen, Jiaxun Yang, Thomas Bogendoerfer, Thomas Gleixner,
	Marc Zyngier
  Cc: linux-mips, linux-kernel, devicetree, Ming Wang

Add liointc-2.0 properties support, so update the maxItems and description.

Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
Signed-off-by: Qing Zhang <zhangqing@loongson.cn>
Tested-by: Ming Wang <wangming01@loongson.cn>
---

v3-v4: Standard submission of information

 .../bindings/interrupt-controller/loongson,liointc.yaml    | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/Documentation/devicetree/bindings/interrupt-controller/loongson,liointc.yaml b/Documentation/devicetree/bindings/interrupt-controller/loongson,liointc.yaml
index f38e0113f360..5280cf60a9a7 100644
--- a/Documentation/devicetree/bindings/interrupt-controller/loongson,liointc.yaml
+++ b/Documentation/devicetree/bindings/interrupt-controller/loongson,liointc.yaml
@@ -10,9 +10,9 @@ maintainers:
   - Jiaxun Yang <jiaxun.yang@flygoat.com>
 
 description: |
-  This interrupt controller is found in the Loongson-3 family of chips as the primary
-  package interrupt controller which can route local I/O interrupt to interrupt lines
-  of cores.
+  This interrupt controller is found in the Loongson-3 family of chips and
+  Loongson-2K1000 chip, as the primary package interrupt controller which
+  can route local I/O interrupt to interrupt lines of cores.
 
 allOf:
   - $ref: /schemas/interrupt-controller.yaml#
@@ -22,6 +22,7 @@ properties:
     oneOf:
       - const: loongson,liointc-1.0
       - const: loongson,liointc-1.0a
+      - const: loongson,liointc-2.0
 
   reg:
     maxItems: 1
-- 
2.20.1


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

* [PATCH v4 7/7] MIPS: Loongson64: Add a Loongson-2K1000 default config file
  2021-03-10  7:56 [PATCH v4 0/7] Add basic support for Loongson-2K1000 Qing Zhang
                   ` (5 preceding siblings ...)
  2021-03-10  7:56 ` [PATCH v4 6/7] dt-bindings: interrupt-controller: Add Loongson-2K1000 LIOINTC Qing Zhang
@ 2021-03-10  7:56 ` Qing Zhang
  6 siblings, 0 replies; 17+ messages in thread
From: Qing Zhang @ 2021-03-10  7:56 UTC (permalink / raw)
  To: Huacai Chen, Jiaxun Yang, Thomas Bogendoerfer, Thomas Gleixner,
	Marc Zyngier
  Cc: linux-mips, linux-kernel, devicetree, Ming Wang

Add default config for Loongson-2K1000.

Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
Signed-off-by: Qing Zhang <zhangqing@loongson.cn>
Tested-by: Ming Wang <wangming01@loongson.cn>
---

v3-v4: Standard submission of information

 arch/mips/configs/loongson2k_defconfig | 353 +++++++++++++++++++++++++
 1 file changed, 353 insertions(+)
 create mode 100644 arch/mips/configs/loongson2k_defconfig

diff --git a/arch/mips/configs/loongson2k_defconfig b/arch/mips/configs/loongson2k_defconfig
new file mode 100644
index 000000000000..e948ca487e2d
--- /dev/null
+++ b/arch/mips/configs/loongson2k_defconfig
@@ -0,0 +1,353 @@
+# CONFIG_LOCALVERSION_AUTO is not set
+CONFIG_KERNEL_LZMA=y
+CONFIG_SYSVIPC=y
+CONFIG_POSIX_MQUEUE=y
+CONFIG_AUDIT=y
+CONFIG_NO_HZ=y
+CONFIG_HIGH_RES_TIMERS=y
+CONFIG_PREEMPT=y
+CONFIG_BSD_PROCESS_ACCT=y
+CONFIG_BSD_PROCESS_ACCT_V3=y
+CONFIG_TASKSTATS=y
+CONFIG_TASK_DELAY_ACCT=y
+CONFIG_TASK_XACCT=y
+CONFIG_TASK_IO_ACCOUNTING=y
+CONFIG_MEMCG=y
+CONFIG_BLK_CGROUP=y
+CONFIG_SCHED_AUTOGROUP=y
+CONFIG_SYSFS_DEPRECATED=y
+CONFIG_RELAY=y
+CONFIG_BLK_DEV_INITRD=y
+CONFIG_EMBEDDED=y
+CONFIG_MACH_LOONGSON64=y
+# CONFIG_CPU_LOONGSON3_CPUCFG_EMULATION is not set
+CONFIG_HZ_256=y
+CONFIG_MIPS32_O32=y
+CONFIG_MIPS32_N32=y
+CONFIG_MODULES=y
+CONFIG_MODULE_FORCE_LOAD=y
+CONFIG_MODULE_UNLOAD=y
+CONFIG_MODULE_FORCE_UNLOAD=y
+CONFIG_MODVERSIONS=y
+CONFIG_PARTITION_ADVANCED=y
+CONFIG_MQ_IOSCHED_DEADLINE=m
+CONFIG_IOSCHED_BFQ=y
+CONFIG_BFQ_GROUP_IOSCHED=y
+CONFIG_BINFMT_MISC=m
+CONFIG_KSM=y
+CONFIG_NET=y
+CONFIG_PACKET=y
+CONFIG_UNIX=y
+CONFIG_XFRM_USER=y
+CONFIG_NET_KEY=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_NETFILTER=y
+CONFIG_NETFILTER_NETLINK_LOG=m
+CONFIG_NETFILTER_XT_TARGET_CLASSIFY=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_ESP=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_STATISTIC=m
+CONFIG_NETFILTER_XT_MATCH_STRING=m
+CONFIG_NETFILTER_XT_MATCH_TCPMSS=m
+CONFIG_IP_VS=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_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_IP_SCTP=m
+CONFIG_L2TP=m
+CONFIG_BRIDGE=m
+CONFIG_CFG80211=m
+CONFIG_CFG80211_WEXT=y
+CONFIG_MAC80211=m
+CONFIG_RFKILL=m
+CONFIG_RFKILL_INPUT=y
+CONFIG_PCIEPORTBUS=y
+CONFIG_HOTPLUG_PCI_PCIE=y
+CONFIG_PCIEASPM_PERFORMANCE=y
+CONFIG_HOTPLUG_PCI=y
+CONFIG_DEVTMPFS=y
+CONFIG_DEVTMPFS_MOUNT=y
+CONFIG_MTD=m
+CONFIG_BLK_DEV_LOOP=y
+CONFIG_BLK_DEV_CRYPTOLOOP=y
+CONFIG_BLK_DEV_RAM=y
+CONFIG_BLK_DEV_RAM_SIZE=8192
+CONFIG_RAID_ATTRS=m
+CONFIG_BLK_DEV_SD=y
+CONFIG_BLK_DEV_SR=y
+CONFIG_CHR_DEV_SG=y
+CONFIG_CHR_DEV_SCH=m
+CONFIG_SCSI_CONSTANTS=y
+CONFIG_SCSI_LOGGING=y
+CONFIG_SCSI_SPI_ATTRS=m
+CONFIG_SCSI_FC_ATTRS=m
+CONFIG_ISCSI_TCP=m
+CONFIG_MEGARAID_NEWGEN=y
+CONFIG_MEGARAID_MM=y
+CONFIG_MEGARAID_MAILBOX=y
+CONFIG_MEGARAID_LEGACY=y
+CONFIG_MEGARAID_SAS=y
+CONFIG_ATA=y
+CONFIG_SATA_AHCI=y
+CONFIG_PATA_ATIIXP=y
+CONFIG_MD=y
+CONFIG_BLK_DEV_MD=m
+CONFIG_MD_LINEAR=m
+CONFIG_MD_RAID0=m
+CONFIG_MD_RAID1=m
+CONFIG_MD_RAID10=m
+CONFIG_MD_RAID456=m
+CONFIG_MD_MULTIPATH=m
+CONFIG_BLK_DEV_DM=m
+CONFIG_DM_CRYPT=m
+CONFIG_DM_SNAPSHOT=m
+CONFIG_DM_MIRROR=m
+CONFIG_DM_ZERO=m
+CONFIG_TARGET_CORE=m
+CONFIG_TCM_IBLOCK=m
+CONFIG_TCM_FILEIO=m
+CONFIG_TCM_PSCSI=m
+CONFIG_LOOPBACK_TARGET=m
+CONFIG_ISCSI_TARGET=m
+CONFIG_NETDEVICES=y
+CONFIG_TUN=m
+# CONFIG_NET_VENDOR_3COM is not set
+# CONFIG_NET_VENDOR_ADAPTEC is not set
+# CONFIG_NET_VENDOR_ALTEON is not set
+# CONFIG_NET_VENDOR_AMD is not set
+# CONFIG_NET_VENDOR_ARC is not set
+# CONFIG_NET_VENDOR_ATHEROS is not set
+# CONFIG_NET_VENDOR_BROADCOM is not set
+# CONFIG_NET_VENDOR_BROCADE is not set
+# CONFIG_NET_VENDOR_CHELSIO is not set
+# CONFIG_NET_VENDOR_CIRRUS is not set
+# CONFIG_NET_VENDOR_CISCO is not set
+# CONFIG_NET_VENDOR_DEC is not set
+# CONFIG_NET_VENDOR_DLINK is not set
+# CONFIG_NET_VENDOR_EMULEX is not set
+# CONFIG_NET_VENDOR_I825XX is not set
+CONFIG_E1000=y
+CONFIG_E1000E=y
+CONFIG_IGB=y
+CONFIG_IXGB=y
+CONFIG_IXGBE=y
+# CONFIG_NET_VENDOR_MARVELL is not set
+# CONFIG_NET_VENDOR_MELLANOX is not set
+# CONFIG_NET_VENDOR_MICREL is not set
+# CONFIG_NET_VENDOR_MICROCHIP is not set
+# CONFIG_NET_VENDOR_MICROSEMI is not set
+# CONFIG_NET_VENDOR_MYRI is not set
+# CONFIG_NET_VENDOR_NATSEMI is not set
+# CONFIG_NET_VENDOR_NETERION is not set
+# CONFIG_NET_VENDOR_NETRONOME is not set
+# CONFIG_NET_VENDOR_NI is not set
+# CONFIG_NET_VENDOR_NVIDIA is not set
+# CONFIG_NET_VENDOR_OKI is not set
+# CONFIG_NET_VENDOR_PACKET_ENGINES is not set
+# CONFIG_NET_VENDOR_PENSANDO is not set
+# CONFIG_NET_VENDOR_QLOGIC is not set
+# CONFIG_NET_VENDOR_QUALCOMM is not set
+# CONFIG_NET_VENDOR_RDC is not set
+CONFIG_8139CP=y
+CONFIG_8139TOO=y
+# CONFIG_8139TOO_PIO is not set
+CONFIG_R8169=y
+# CONFIG_NET_VENDOR_RENESAS is not set
+# CONFIG_NET_VENDOR_ROCKER is not set
+# CONFIG_NET_VENDOR_SAMSUNG is not set
+# CONFIG_NET_VENDOR_SEEQ is not set
+# CONFIG_NET_VENDOR_SOLARFLARE is not set
+# CONFIG_NET_VENDOR_SILAN is not set
+# CONFIG_NET_VENDOR_SIS is not set
+# CONFIG_NET_VENDOR_SMSC is not set
+CONFIG_STMMAC_ETH=y
+# CONFIG_NET_VENDOR_SUN is not set
+# CONFIG_NET_VENDOR_TEHUTI is not set
+# CONFIG_NET_VENDOR_TI is not set
+# CONFIG_NET_VENDOR_TOSHIBA is not set
+# CONFIG_NET_VENDOR_VIA is not set
+# CONFIG_NET_VENDOR_WIZNET is not set
+CONFIG_PPP=m
+CONFIG_PPP_BSDCOMP=m
+CONFIG_PPP_DEFLATE=m
+CONFIG_PPP_FILTER=y
+CONFIG_PPP_MPPE=m
+CONFIG_PPP_MULTILINK=y
+CONFIG_PPPOE=m
+CONFIG_PPPOL2TP=m
+CONFIG_PPP_ASYNC=m
+CONFIG_PPP_SYNC_TTY=m
+CONFIG_ATH9K=m
+CONFIG_HOSTAP=m
+CONFIG_INPUT_LEDS=m
+CONFIG_INPUT_SPARSEKMAP=y
+CONFIG_INPUT_EVDEV=y
+# CONFIG_KEYBOARD_ATKBD is not set
+CONFIG_KEYBOARD_XTKBD=m
+# CONFIG_MOUSE_PS2 is not set
+CONFIG_INPUT_MISC=y
+CONFIG_INPUT_UINPUT=m
+# CONFIG_SERIO_I8042 is not set
+CONFIG_SERIO_SERPORT=m
+CONFIG_SERIO_LIBPS2=y
+CONFIG_SERIO_RAW=m
+CONFIG_LEGACY_PTY_COUNT=16
+CONFIG_SERIAL_8250=y
+# CONFIG_SERIAL_8250_16550A_VARIANTS is not set
+CONFIG_SERIAL_8250_CONSOLE=y
+CONFIG_SERIAL_8250_NR_UARTS=16
+CONFIG_SERIAL_8250_EXTENDED=y
+CONFIG_SERIAL_8250_MANY_PORTS=y
+CONFIG_SERIAL_8250_SHARE_IRQ=y
+CONFIG_SERIAL_8250_RSA=y
+CONFIG_SERIAL_OF_PLATFORM=y
+CONFIG_SERIAL_NONSTANDARD=y
+CONFIG_HW_RANDOM=y
+CONFIG_RAW_DRIVER=m
+CONFIG_I2C_CHARDEV=y
+CONFIG_I2C_PIIX4=y
+CONFIG_GPIO_LOONGSON=y
+CONFIG_SENSORS_LM75=m
+CONFIG_SENSORS_LM93=m
+CONFIG_SENSORS_W83627HF=m
+# CONFIG_MEDIA_CEC_SUPPORT is not set
+CONFIG_MEDIA_SUPPORT=m
+# CONFIG_MEDIA_CONTROLLER is not set
+CONFIG_MEDIA_USB_SUPPORT=y
+CONFIG_USB_VIDEO_CLASS=m
+CONFIG_DRM=y
+CONFIG_DRM_RADEON=y
+CONFIG_FB_RADEON=y
+CONFIG_LCD_CLASS_DEVICE=y
+CONFIG_LCD_PLATFORM=m
+# CONFIG_VGA_CONSOLE is not set
+CONFIG_FRAMEBUFFER_CONSOLE=y
+CONFIG_FRAMEBUFFER_CONSOLE_ROTATION=y
+CONFIG_LOGO=y
+CONFIG_SOUND=y
+CONFIG_SND=y
+CONFIG_SND_VERBOSE_PRINTK=y
+CONFIG_SND_SEQUENCER=y
+CONFIG_SND_SEQ_DUMMY=m
+# CONFIG_SND_ISA is not set
+CONFIG_SND_HDA_INTEL=y
+CONFIG_SND_HDA_HWDEP=y
+CONFIG_SND_HDA_PATCH_LOADER=y
+CONFIG_SND_HDA_CODEC_REALTEK=y
+CONFIG_SND_HDA_CODEC_ANALOG=y
+CONFIG_SND_HDA_CODEC_SIGMATEL=y
+CONFIG_SND_HDA_CODEC_VIA=y
+CONFIG_SND_HDA_CODEC_CONEXANT=y
+# CONFIG_SND_USB is not set
+CONFIG_SND_SOC=y
+CONFIG_HID_A4TECH=m
+CONFIG_HID_SUNPLUS=m
+CONFIG_USB=y
+CONFIG_USB_MON=y
+CONFIG_USB_XHCI_HCD=y
+CONFIG_USB_EHCI_HCD=y
+CONFIG_USB_EHCI_ROOT_HUB_TT=y
+CONFIG_USB_OHCI_HCD=y
+CONFIG_USB_UHCI_HCD=m
+CONFIG_USB_STORAGE=y
+CONFIG_USB_SERIAL=m
+CONFIG_USB_SERIAL_OPTION=m
+CONFIG_RTC_CLASS=y
+CONFIG_RTC_DRV_CMOS=y
+CONFIG_DMADEVICES=y
+# CONFIG_CPU_HWMON is not set
+CONFIG_PM_DEVFREQ=y
+CONFIG_DEVFREQ_GOV_SIMPLE_ONDEMAND=y
+CONFIG_DEVFREQ_GOV_PERFORMANCE=y
+CONFIG_DEVFREQ_GOV_POWERSAVE=y
+CONFIG_DEVFREQ_GOV_USERSPACE=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_FS_POSIX_ACL=y
+CONFIG_EXT3_FS_SECURITY=y
+CONFIG_XFS_FS=y
+CONFIG_XFS_QUOTA=y
+CONFIG_XFS_POSIX_ACL=y
+CONFIG_QUOTA=y
+# CONFIG_PRINT_QUOTA_WARNING is not set
+CONFIG_AUTOFS4_FS=y
+CONFIG_FUSE_FS=m
+CONFIG_ISO9660_FS=m
+CONFIG_JOLIET=y
+CONFIG_MSDOS_FS=y
+CONFIG_VFAT_FS=y
+CONFIG_FAT_DEFAULT_CODEPAGE=936
+CONFIG_FAT_DEFAULT_IOCHARSET="gb2312"
+CONFIG_PROC_KCORE=y
+CONFIG_TMPFS=y
+CONFIG_TMPFS_POSIX_ACL=y
+CONFIG_CONFIGFS_FS=y
+CONFIG_CRAMFS=m
+CONFIG_SQUASHFS=y
+CONFIG_SQUASHFS_XATTR=y
+CONFIG_NFS_FS=m
+CONFIG_NFS_V3_ACL=y
+CONFIG_NFS_V4=m
+CONFIG_NFSD=m
+CONFIG_NFSD_V3_ACL=y
+CONFIG_NFSD_V4=y
+CONFIG_CIFS=m
+CONFIG_NLS_CODEPAGE_437=y
+CONFIG_NLS_CODEPAGE_936=y
+CONFIG_NLS_ASCII=y
+CONFIG_NLS_UTF8=y
+CONFIG_SECURITY=y
+CONFIG_SECURITYFS=y
+CONFIG_SECURITY_NETWORK=y
+CONFIG_SECURITY_PATH=y
+CONFIG_SECURITY_SELINUX=y
+CONFIG_SECURITY_SELINUX_BOOTPARAM=y
+CONFIG_SECURITY_SELINUX_DISABLE=y
+CONFIG_DEFAULT_SECURITY_DAC=y
+CONFIG_CRYPTO_SEQIV=m
+CONFIG_CRYPTO_HMAC=y
+CONFIG_CRYPTO_MD5=y
+CONFIG_CRYPTO_TGR192=m
+CONFIG_CRYPTO_WP512=m
+CONFIG_CRYPTO_BLOWFISH=m
+CONFIG_CRYPTO_CAST5=m
+CONFIG_CRYPTO_CAST6=m
+CONFIG_CRYPTO_SERPENT=m
+CONFIG_CRYPTO_TWOFISH=m
+CONFIG_CRYPTO_DEFLATE=m
+CONFIG_PRINTK_TIME=y
+CONFIG_FRAME_WARN=1024
+CONFIG_STRIP_ASM_SYMS=y
+CONFIG_MAGIC_SYSRQ=y
+# CONFIG_SCHED_DEBUG is not set
+# CONFIG_DEBUG_PREEMPT is not set
+# CONFIG_FTRACE is not set
-- 
2.20.1


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

* Re: [PATCH v4 3/7] MIPS: Loongson64: Add support for the Loongson-2K1000 to get cpu_clock_freq
  2021-03-10  7:56 ` [PATCH v4 3/7] MIPS: Loongson64: Add support for the Loongson-2K1000 to get cpu_clock_freq Qing Zhang
@ 2021-03-10  8:50   ` Sergei Shtylyov
  2021-03-10  9:37     ` zhangqing
  0 siblings, 1 reply; 17+ messages in thread
From: Sergei Shtylyov @ 2021-03-10  8:50 UTC (permalink / raw)
  To: Qing Zhang, Huacai Chen, Jiaxun Yang, Thomas Bogendoerfer,
	Thomas Gleixner, Marc Zyngier
  Cc: linux-mips, linux-kernel, devicetree, Ming Wang

Hello!

On 10.03.2021 10:56, Qing Zhang wrote:

> Get the fixed-clock from the CPU0 node of the device tree.
> 
> Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
> Signed-off-by: Qing Zhang <zhangqing@loongson.cn>
> Tested-by: Ming Wang <wangming01@loongson.cn>
> ---
> 
> v3-v4: Standard submission of information
>         Add return after error
> 
>   arch/mips/loongson64/time.c | 24 ++++++++++++++++++++++++
>   1 file changed, 24 insertions(+)
> 
> diff --git a/arch/mips/loongson64/time.c b/arch/mips/loongson64/time.c
> index 91e842b58365..2d84f9b20a9b 100644
> --- a/arch/mips/loongson64/time.c
> +++ b/arch/mips/loongson64/time.c
> @@ -11,9 +11,33 @@
>   #include <asm/hpet.h>
>   
>   #include <loongson.h>
> +#include <linux/clk.h>
> +#include <linux/of_clk.h>
>   
>   void __init plat_time_init(void)
>   {
> +	struct clk *clk = NULL;

    You don't seem to need this initializer.

> +	struct device_node *np;
> +
> +	if (loongson_sysconf.fw_interface == LOONGSON_DTB) {
> +		of_clk_init(NULL);
> +
> +		np = of_get_cpu_node(0, NULL);
> +		if (!np) {
> +			pr_err("Failed to get CPU node\n");
> +			return;
> +		}
> +
> +		clk = of_clk_get(np, 0);
> +		if (IS_ERR(clk)) {
> +			pr_err("Failed to get CPU clock: %ld\n", PTR_ERR(clk));
> +			return;
> +		}
> +
> +		cpu_clock_freq = clk_get_rate(clk);
> +		clk_put(clk);
> +	}
> +
>   	/* setup mips r4k timer */
>   	mips_hpt_frequency = cpu_clock_freq / 2;
>   
> 


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

* Re: [PATCH v4 3/7] MIPS: Loongson64: Add support for the Loongson-2K1000 to get cpu_clock_freq
  2021-03-10  8:50   ` Sergei Shtylyov
@ 2021-03-10  9:37     ` zhangqing
  2021-03-10 12:06       ` Jiaxun Yang
  0 siblings, 1 reply; 17+ messages in thread
From: zhangqing @ 2021-03-10  9:37 UTC (permalink / raw)
  To: Sergei Shtylyov, Huacai Chen, Jiaxun Yang, Thomas Bogendoerfer,
	Thomas Gleixner, Marc Zyngier
  Cc: linux-mips, linux-kernel, devicetree, Ming Wang



On 03/10/2021 04:50 PM, Sergei Shtylyov wrote:
> Hello!
>
>    You don't seem to need this initializer.
Hi,Sergei

Thanks for your suggestion,
clk will not be affected by others when it is defined until the value is 
obtained,
=NULL can be deleted, but I think it seems to have no effect.

Thanks,
Qing
>
>


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

* Re: [PATCH v4 2/7] MIPS: Loongson64: Distinguish firmware dependencies DTB/LEFI
  2021-03-10  7:56 ` [PATCH v4 2/7] MIPS: Loongson64: Distinguish firmware dependencies DTB/LEFI Qing Zhang
@ 2021-03-10 10:57   ` Oleksij Rempel
  2021-03-10 12:12     ` Jiaxun Yang
  0 siblings, 1 reply; 17+ messages in thread
From: Oleksij Rempel @ 2021-03-10 10:57 UTC (permalink / raw)
  To: Qing Zhang, Huacai Chen, Jiaxun Yang, Thomas Bogendoerfer,
	Thomas Gleixner, Marc Zyngier
  Cc: linux-mips, linux-kernel, devicetree, Ming Wang

Hi,

Am 10.03.21 um 08:56 schrieb Qing Zhang:
> Add DTB boot support, only support Loongson-2K1000 processor
> for now, determine whether to use the built-in DTB or the DTB
> from the firmware by checking the range of CKSEG0 and XKPHYS.
> loongson_fw_interface will be used in the future.
>
> Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
> Signed-off-by: Qing Zhang <zhangqing@loongson.cn>
> Tested-by: Ming Wang <wangming01@loongson.cn>
> ---
>
> v3-v4: Standard submission of information
>        Fix error handling
>
>  .../include/asm/mach-loongson64/boot_param.h     |  6 ++++++
>  arch/mips/include/asm/mach-loongson64/loongson.h |  3 ++-
>  arch/mips/loongson64/env.c                       | 13 ++++++++++++-
>  arch/mips/loongson64/init.c                      | 16 ++++++++++++++--
>  4 files changed, 34 insertions(+), 4 deletions(-)
>
> diff --git a/arch/mips/include/asm/mach-loongson64/boot_param.h b/arch/mips/include/asm/mach-loongson64/boot_param.h
> index 4592841b6b0c..43737401dc06 100644
> --- a/arch/mips/include/asm/mach-loongson64/boot_param.h
> +++ b/arch/mips/include/asm/mach-loongson64/boot_param.h
> @@ -198,7 +198,13 @@ enum loongson_bridge_type {
>  	VIRTUAL = 3
>  };
>
> +enum loongson_fw_interface {
> +	LOONGSON_LEFI,
> +	LOONGSON_DTB,
> +};
> +
>  struct loongson_system_configuration {
> +	enum loongson_fw_interface fw_interface;
>  	u32 nr_cpus;
>  	u32 nr_nodes;
>  	int cores_per_node;
> diff --git a/arch/mips/include/asm/mach-loongson64/loongson.h b/arch/mips/include/asm/mach-loongson64/loongson.h
> index ac1c20e172a2..3f885fa26ba6 100644
> --- a/arch/mips/include/asm/mach-loongson64/loongson.h
> +++ b/arch/mips/include/asm/mach-loongson64/loongson.h
> @@ -23,7 +23,8 @@ extern u32 memsize, highmemsize;
>  extern const struct plat_smp_ops loongson3_smp_ops;
>
>  /* loongson-specific command line, env and memory initialization */
> -extern void __init prom_init_env(void);
> +extern void __init prom_dtb_init_env(void);
> +extern void __init prom_lefi_init_env(void);
>  extern void __init szmem(unsigned int node);
>  extern void *loongson_fdt_blob;
>
> diff --git a/arch/mips/loongson64/env.c b/arch/mips/loongson64/env.c
> index 51a5d050a94c..e7d3a06175e3 100644
> --- a/arch/mips/loongson64/env.c
> +++ b/arch/mips/loongson64/env.c
> @@ -43,7 +43,18 @@ const char *get_system_type(void)
>  	return "Generic Loongson64 System";
>  }
>
> -void __init prom_init_env(void)
> +
> +void __init prom_dtb_init_env(void)
> +{
> +	if ((fw_arg2 < CKSEG0 || fw_arg2 > CKSEG1)
> +		&& (fw_arg2 < XKPHYS || fw_arg2 > XKSEG))
> +
> +		loongson_fdt_blob = __dtb_loongson64_2core_2k1000_begin;
> +	else
> +		loongson_fdt_blob = (void *)fw_arg2;
> +}
> +
> +void __init prom_lefi_init_env(void)
>  {
>  	struct boot_params *boot_p;
>  	struct loongson_params *loongson_p;
> diff --git a/arch/mips/loongson64/init.c b/arch/mips/loongson64/init.c
> index cfa788bca871..ed280b73bf89 100644
> --- a/arch/mips/loongson64/init.c
> +++ b/arch/mips/loongson64/init.c
> @@ -52,6 +52,10 @@ void __init szmem(unsigned int node)
>  	static unsigned long num_physpages;
>  	u64 node_id, node_psize, start_pfn, end_pfn, mem_start, mem_size;
>
> +	/* Otherwise come from DTB */
> +	if (loongson_sysconf.fw_interface != LOONGSON_LEFI)
> +		return;
> +
>  	/* Parse memory information and activate */
>  	for (i = 0; i < loongson_memmap->nr_map; i++) {
>  		node_id = loongson_memmap->map[i].node_id;
> @@ -94,12 +98,20 @@ static void __init prom_init_memory(void)
>  void __init prom_init(void)
>  {
>  	fw_init_cmdline();
> -	prom_init_env();
> +
> +	if (fw_arg2 == 0 || (fdt_magic(fw_arg2) == FDT_MAGIC)) {
> +		loongson_sysconf.fw_interface = LOONGSON_DTB;
> +		prom_dtb_init_env();
> +	} else {
> +		loongson_sysconf.fw_interface = LOONGSON_LEFI;
> +		prom_lefi_init_env();
> +	}

Is it possible to make it compatible with MIPS UHI boot protocol? So boot loaders will be able to
handle Loongson kernel images as any other MIPS kernel images?

This protocol is described here on page 15, "3. Boot protocols"
https://docplayer.net/62444141-Unified-hosting-interface-md01069-reference-manual.html

According to this protocol, you should have:
fw_arg0 = -2
fw_arg1 = Virtual (kseg0) address of Device Tree Blob

This would made LS a first grade resident for many boot loaders and save a lot of needles headaches.

--
Regards,
Oleksij

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

* Re: [PATCH v4 6/7] dt-bindings: interrupt-controller: Add Loongson-2K1000 LIOINTC
  2021-03-10  7:56 ` [PATCH v4 6/7] dt-bindings: interrupt-controller: Add Loongson-2K1000 LIOINTC Qing Zhang
@ 2021-03-10 12:04   ` Jiaxun Yang
  2021-03-11  1:43     ` zhangqing
  0 siblings, 1 reply; 17+ messages in thread
From: Jiaxun Yang @ 2021-03-10 12:04 UTC (permalink / raw)
  To: Qing Zhang, Huacai Chen, Thomas Bogendoerfer, Thomas Gleixner,
	Marc Zyngier
  Cc: linux-mips, linux-kernel, devicetree, Ming Wang



On Wed, Mar 10, 2021, at 3:56 PM, Qing Zhang wrote:
> Add liointc-2.0 properties support, so update the maxItems and description.
> 
> Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
^ I have nothing todo with this patch so please drop me for this one :-)

> Signed-off-by: Qing Zhang <zhangqing@loongson.cn>
> Tested-by: Ming Wang <wangming01@loongson.cn>
> ---
> 
> v3-v4: Standard submission of information
^ It's called commit message.

> 
>  .../bindings/interrupt-controller/loongson,liointc.yaml    | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git 
> a/Documentation/devicetree/bindings/interrupt-controller/loongson,liointc.yaml b/Documentation/devicetree/bindings/interrupt-controller/loongson,liointc.yaml
> index f38e0113f360..5280cf60a9a7 100644
> --- 
> a/Documentation/devicetree/bindings/interrupt-controller/loongson,liointc.yaml
> +++ 
> b/Documentation/devicetree/bindings/interrupt-controller/loongson,liointc.yaml
> @@ -10,9 +10,9 @@ maintainers:
>    - Jiaxun Yang <jiaxun.yang@flygoat.com>
>  
>  description: |
> -  This interrupt controller is found in the Loongson-3 family of chips 
> as the primary
> -  package interrupt controller which can route local I/O interrupt to 
> interrupt lines
> -  of cores.
> +  This interrupt controller is found in the Loongson-3 family of chips 
> and
> +  Loongson-2K1000 chip, as the primary package interrupt controller 
> which
> +  can route local I/O interrupt to interrupt lines of cores.
>  
>  allOf:
>    - $ref: /schemas/interrupt-controller.yaml#
> @@ -22,6 +22,7 @@ properties:
>      oneOf:
>        - const: loongson,liointc-1.0
>        - const: loongson,liointc-1.0a
> +      - const: loongson,liointc-2.0
>  
>    reg:
>      maxItems: 1
^ Please document multiple reg prop change as well.

Thanks.

- Jiaxun

> -- 
> 2.20.1
> 
>

-- 
- Jiaxun

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

* Re: [PATCH v4 3/7] MIPS: Loongson64: Add support for the Loongson-2K1000 to get cpu_clock_freq
  2021-03-10  9:37     ` zhangqing
@ 2021-03-10 12:06       ` Jiaxun Yang
  0 siblings, 0 replies; 17+ messages in thread
From: Jiaxun Yang @ 2021-03-10 12:06 UTC (permalink / raw)
  To: Qing Zhang, Sergei Shtylyov, Huacai Chen, Thomas Bogendoerfer,
	Thomas Gleixner, Marc Zyngier
  Cc: linux-mips, linux-kernel, devicetree, Ming Wang



On Wed, Mar 10, 2021, at 5:37 PM, zhangqing wrote:
> 
> 
> On 03/10/2021 04:50 PM, Sergei Shtylyov wrote:
> > Hello!
> >
> >    You don't seem to need this initializer.
> Hi,Sergei
> 
> Thanks for your suggestion,
> clk will not be affected by others when it is defined until the value is 
> obtained,
> =NULL can be deleted, but I think it seems to have no effect.

Please do reasonable change only.

Thanks.

- Jiaxun

> 
> Thanks,
> Qing
> >
> >
> 
>

-- 
- Jiaxun

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

* Re: [PATCH v4 2/7] MIPS: Loongson64: Distinguish firmware dependencies DTB/LEFI
  2021-03-10 10:57   ` Oleksij Rempel
@ 2021-03-10 12:12     ` Jiaxun Yang
  2021-03-10 13:26       ` Oleksij Rempel
  0 siblings, 1 reply; 17+ messages in thread
From: Jiaxun Yang @ 2021-03-10 12:12 UTC (permalink / raw)
  To: Oleksij Rempel, Qing Zhang, Huacai Chen, Thomas Bogendoerfer,
	Thomas Gleixner, Marc Zyngier
  Cc: linux-mips, linux-kernel, devicetree, Ming Wang



On Wed, Mar 10, 2021, at 6:57 PM, Oleksij Rempel wrote:
> Hi,
> 
> Am 10.03.21 um 08:56 schrieb Qing Zhang:
> > Add DTB boot support, only support Loongson-2K1000 processor
> > for now, determine whether to use the built-in DTB or the DTB
> > from the firmware by checking the range of CKSEG0 and XKPHYS.
> > loongson_fw_interface will be used in the future.
> >
> > Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
> > Signed-off-by: Qing Zhang <zhangqing@loongson.cn>
> > Tested-by: Ming Wang <wangming01@loongson.cn>
> > ---
> >
> > v3-v4: Standard submission of information
> >        Fix error handling
> >
> >  .../include/asm/mach-loongson64/boot_param.h     |  6 ++++++
> >  arch/mips/include/asm/mach-loongson64/loongson.h |  3 ++-
> >  arch/mips/loongson64/env.c                       | 13 ++++++++++++-
> >  arch/mips/loongson64/init.c                      | 16 ++++++++++++++--
> >  4 files changed, 34 insertions(+), 4 deletions(-)
> >
> > diff --git a/arch/mips/include/asm/mach-loongson64/boot_param.h b/arch/mips/include/asm/mach-loongson64/boot_param.h
> > index 4592841b6b0c..43737401dc06 100644
> > --- a/arch/mips/include/asm/mach-loongson64/boot_param.h
> > +++ b/arch/mips/include/asm/mach-loongson64/boot_param.h
> > @@ -198,7 +198,13 @@ enum loongson_bridge_type {
> >  	VIRTUAL = 3
> >  };
> >
> > +enum loongson_fw_interface {
> > +	LOONGSON_LEFI,
> > +	LOONGSON_DTB,
> > +};
> > +
> >  struct loongson_system_configuration {
> > +	enum loongson_fw_interface fw_interface;
> >  	u32 nr_cpus;
> >  	u32 nr_nodes;
> >  	int cores_per_node;
> > diff --git a/arch/mips/include/asm/mach-loongson64/loongson.h b/arch/mips/include/asm/mach-loongson64/loongson.h
> > index ac1c20e172a2..3f885fa26ba6 100644
> > --- a/arch/mips/include/asm/mach-loongson64/loongson.h
> > +++ b/arch/mips/include/asm/mach-loongson64/loongson.h
> > @@ -23,7 +23,8 @@ extern u32 memsize, highmemsize;
> >  extern const struct plat_smp_ops loongson3_smp_ops;
> >
> >  /* loongson-specific command line, env and memory initialization */
> > -extern void __init prom_init_env(void);
> > +extern void __init prom_dtb_init_env(void);
> > +extern void __init prom_lefi_init_env(void);
> >  extern void __init szmem(unsigned int node);
> >  extern void *loongson_fdt_blob;
> >
> > diff --git a/arch/mips/loongson64/env.c b/arch/mips/loongson64/env.c
> > index 51a5d050a94c..e7d3a06175e3 100644
> > --- a/arch/mips/loongson64/env.c
> > +++ b/arch/mips/loongson64/env.c
> > @@ -43,7 +43,18 @@ const char *get_system_type(void)
> >  	return "Generic Loongson64 System";
> >  }
> >
> > -void __init prom_init_env(void)
> > +
> > +void __init prom_dtb_init_env(void)
> > +{
> > +	if ((fw_arg2 < CKSEG0 || fw_arg2 > CKSEG1)
> > +		&& (fw_arg2 < XKPHYS || fw_arg2 > XKSEG))
> > +
> > +		loongson_fdt_blob = __dtb_loongson64_2core_2k1000_begin;
> > +	else
> > +		loongson_fdt_blob = (void *)fw_arg2;
> > +}
> > +
> > +void __init prom_lefi_init_env(void)
> >  {
> >  	struct boot_params *boot_p;
> >  	struct loongson_params *loongson_p;
> > diff --git a/arch/mips/loongson64/init.c b/arch/mips/loongson64/init.c
> > index cfa788bca871..ed280b73bf89 100644
> > --- a/arch/mips/loongson64/init.c
> > +++ b/arch/mips/loongson64/init.c
> > @@ -52,6 +52,10 @@ void __init szmem(unsigned int node)
> >  	static unsigned long num_physpages;
> >  	u64 node_id, node_psize, start_pfn, end_pfn, mem_start, mem_size;
> >
> > +	/* Otherwise come from DTB */
> > +	if (loongson_sysconf.fw_interface != LOONGSON_LEFI)
> > +		return;
> > +
> >  	/* Parse memory information and activate */
> >  	for (i = 0; i < loongson_memmap->nr_map; i++) {
> >  		node_id = loongson_memmap->map[i].node_id;
> > @@ -94,12 +98,20 @@ static void __init prom_init_memory(void)
> >  void __init prom_init(void)
> >  {
> >  	fw_init_cmdline();
> > -	prom_init_env();
> > +
> > +	if (fw_arg2 == 0 || (fdt_magic(fw_arg2) == FDT_MAGIC)) {
> > +		loongson_sysconf.fw_interface = LOONGSON_DTB;
> > +		prom_dtb_init_env();
> > +	} else {
> > +		loongson_sysconf.fw_interface = LOONGSON_LEFI;
> > +		prom_lefi_init_env();
> > +	}
> 
> Is it possible to make it compatible with MIPS UHI boot protocol? So 
> boot loaders will be able to
> handle Loongson kernel images as any other MIPS kernel images?

Hmm, as Loongson did many stuff in non-generic manner it's almost impossible :-(
Also their are many devices shipped with current boot protocol.


> 
> This protocol is described here on page 15, "3. Boot protocols"
> https://docplayer.net/62444141-Unified-hosting-interface-md01069-reference-manual.html
> 
> According to this protocol, you should have:
> fw_arg0 = -2
> fw_arg1 = Virtual (kseg0) address of Device Tree Blob
> 
> This would made LS a first grade resident for many boot loaders and 
> save a lot of needles headaches.

Loongson is stepping away from MIPS and it seems like they're going to use EDK-II for their Loongarch.
TBH I've checked Loongson's PMON code and realized it can't be ported to other projects easily.

Tons of unregonized assembly code.


Thanks.

- Jiaxun

> 
> --
> Regards,
> Oleksij
>

-- 
- Jiaxun

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

* Re: [PATCH v4 2/7] MIPS: Loongson64: Distinguish firmware dependencies DTB/LEFI
  2021-03-10 12:12     ` Jiaxun Yang
@ 2021-03-10 13:26       ` Oleksij Rempel
       [not found]         ` <a2b1ad18-8f4b-8e43-e175-c372580a7168@flygoat.com>
  0 siblings, 1 reply; 17+ messages in thread
From: Oleksij Rempel @ 2021-03-10 13:26 UTC (permalink / raw)
  To: Jiaxun Yang, Qing Zhang, Huacai Chen, Thomas Bogendoerfer,
	Thomas Gleixner, Marc Zyngier
  Cc: linux-mips, linux-kernel, devicetree, Ming Wang

Am 10.03.21 um 13:12 schrieb Jiaxun Yang:
>
>
> On Wed, Mar 10, 2021, at 6:57 PM, Oleksij Rempel wrote:
>> Hi,
>>
>> Am 10.03.21 um 08:56 schrieb Qing Zhang:
>>> Add DTB boot support, only support Loongson-2K1000 processor
>>> for now, determine whether to use the built-in DTB or the DTB
>>> from the firmware by checking the range of CKSEG0 and XKPHYS.
>>> loongson_fw_interface will be used in the future.
>>>
>>> Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
>>> Signed-off-by: Qing Zhang <zhangqing@loongson.cn>
>>> Tested-by: Ming Wang <wangming01@loongson.cn>
>>> ---
>>>
>>> v3-v4: Standard submission of information
>>>        Fix error handling
>>>
>>>  .../include/asm/mach-loongson64/boot_param.h     |  6 ++++++
>>>  arch/mips/include/asm/mach-loongson64/loongson.h |  3 ++-
>>>  arch/mips/loongson64/env.c                       | 13 ++++++++++++-
>>>  arch/mips/loongson64/init.c                      | 16 ++++++++++++++--
>>>  4 files changed, 34 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/arch/mips/include/asm/mach-loongson64/boot_param.h b/arch/mips/include/asm/mach-loongson64/boot_param.h
>>> index 4592841b6b0c..43737401dc06 100644
>>> --- a/arch/mips/include/asm/mach-loongson64/boot_param.h
>>> +++ b/arch/mips/include/asm/mach-loongson64/boot_param.h
>>> @@ -198,7 +198,13 @@ enum loongson_bridge_type {
>>>  	VIRTUAL = 3
>>>  };
>>>
>>> +enum loongson_fw_interface {
>>> +	LOONGSON_LEFI,
>>> +	LOONGSON_DTB,
>>> +};
>>> +
>>>  struct loongson_system_configuration {
>>> +	enum loongson_fw_interface fw_interface;
>>>  	u32 nr_cpus;
>>>  	u32 nr_nodes;
>>>  	int cores_per_node;
>>> diff --git a/arch/mips/include/asm/mach-loongson64/loongson.h b/arch/mips/include/asm/mach-loongson64/loongson.h
>>> index ac1c20e172a2..3f885fa26ba6 100644
>>> --- a/arch/mips/include/asm/mach-loongson64/loongson.h
>>> +++ b/arch/mips/include/asm/mach-loongson64/loongson.h
>>> @@ -23,7 +23,8 @@ extern u32 memsize, highmemsize;
>>>  extern const struct plat_smp_ops loongson3_smp_ops;
>>>
>>>  /* loongson-specific command line, env and memory initialization */
>>> -extern void __init prom_init_env(void);
>>> +extern void __init prom_dtb_init_env(void);
>>> +extern void __init prom_lefi_init_env(void);
>>>  extern void __init szmem(unsigned int node);
>>>  extern void *loongson_fdt_blob;
>>>
>>> diff --git a/arch/mips/loongson64/env.c b/arch/mips/loongson64/env.c
>>> index 51a5d050a94c..e7d3a06175e3 100644
>>> --- a/arch/mips/loongson64/env.c
>>> +++ b/arch/mips/loongson64/env.c
>>> @@ -43,7 +43,18 @@ const char *get_system_type(void)
>>>  	return "Generic Loongson64 System";
>>>  }
>>>
>>> -void __init prom_init_env(void)
>>> +
>>> +void __init prom_dtb_init_env(void)
>>> +{
>>> +	if ((fw_arg2 < CKSEG0 || fw_arg2 > CKSEG1)
>>> +		&& (fw_arg2 < XKPHYS || fw_arg2 > XKSEG))
>>> +
>>> +		loongson_fdt_blob = __dtb_loongson64_2core_2k1000_begin;
>>> +	else
>>> +		loongson_fdt_blob = (void *)fw_arg2;
>>> +}
>>> +
>>> +void __init prom_lefi_init_env(void)
>>>  {
>>>  	struct boot_params *boot_p;
>>>  	struct loongson_params *loongson_p;
>>> diff --git a/arch/mips/loongson64/init.c b/arch/mips/loongson64/init.c
>>> index cfa788bca871..ed280b73bf89 100644
>>> --- a/arch/mips/loongson64/init.c
>>> +++ b/arch/mips/loongson64/init.c
>>> @@ -52,6 +52,10 @@ void __init szmem(unsigned int node)
>>>  	static unsigned long num_physpages;
>>>  	u64 node_id, node_psize, start_pfn, end_pfn, mem_start, mem_size;
>>>
>>> +	/* Otherwise come from DTB */
>>> +	if (loongson_sysconf.fw_interface != LOONGSON_LEFI)
>>> +		return;
>>> +
>>>  	/* Parse memory information and activate */
>>>  	for (i = 0; i < loongson_memmap->nr_map; i++) {
>>>  		node_id = loongson_memmap->map[i].node_id;
>>> @@ -94,12 +98,20 @@ static void __init prom_init_memory(void)
>>>  void __init prom_init(void)
>>>  {
>>>  	fw_init_cmdline();
>>> -	prom_init_env();
>>> +
>>> +	if (fw_arg2 == 0 || (fdt_magic(fw_arg2) == FDT_MAGIC)) {
>>> +		loongson_sysconf.fw_interface = LOONGSON_DTB;
>>> +		prom_dtb_init_env();
>>> +	} else {
>>> +		loongson_sysconf.fw_interface = LOONGSON_LEFI;
>>> +		prom_lefi_init_env();
>>> +	}
>>
>> Is it possible to make it compatible with MIPS UHI boot protocol? So
>> boot loaders will be able to
>> handle Loongson kernel images as any other MIPS kernel images?
>
> Hmm, as Loongson did many stuff in non-generic manner it's almost impossible :-(
> Also their are many devices shipped with current boot protocol.

I would like to understand, why it is impossible. Do fw_arg0 provide memory address or some kind of
count/size? Can it be negative?

We already had same situation with ARM and it was fixed. Why this can't be done for MIPS or LS?

>
>>
>> This protocol is described here on page 15, "3. Boot protocols"
>> https://docplayer.net/62444141-Unified-hosting-interface-md01069-reference-manual.html
>>
>> According to this protocol, you should have:
>> fw_arg0 = -2
>> fw_arg1 = Virtual (kseg0) address of Device Tree Blob
>>
>> This would made LS a first grade resident for many boot loaders and
>> save a lot of needles headaches.
>
> Loongson is stepping away from MIPS and it seems like they're going to use EDK-II for their Loongarch.

It seems to be UEFI related, it seems to be not related to the CPU arch, or do i'm missing something?

In any case, if this is true, then it means, that Loongsoon is about to drop support for old boot
loaders (PMON?) and do new thing (one more boot protocol?). So argumentation, we upstream old own
protocol, but will drop it to make some thing new is not really good example :)

> TBH I've checked Loongson's PMON code and realized it can't be ported to other projects easily.
> Tons of unregonized assembly code.

No need to port it. Here is example of working clean code:
https://git.pengutronix.de/cgit/barebox/tree/arch/mips/boards/loongson-ls1b/lowlevel.S

And this boot loader would boot any

--
Regards,
Oleksij

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

* Re: [PATCH v4 2/7] MIPS: Loongson64: Distinguish firmware dependencies DTB/LEFI
       [not found]         ` <a2b1ad18-8f4b-8e43-e175-c372580a7168@flygoat.com>
@ 2021-03-10 16:03           ` Oleksij Rempel
  0 siblings, 0 replies; 17+ messages in thread
From: Oleksij Rempel @ 2021-03-10 16:03 UTC (permalink / raw)
  To: Jiaxun Yang, Qing Zhang, Huacai Chen, Thomas Bogendoerfer,
	Thomas Gleixner, Marc Zyngier
  Cc: linux-mips, linux-kernel, devicetree, Ming Wang

Am 10.03.21 um 16:58 schrieb Jiaxun Yang:
>
>
> 在 2021/3/10 21:26, Oleksij Rempel 写道:
> [...]
>> I would like to understand, why it is impossible. Do fw_arg0 provide memory address or some kind of
>> count/size? Can it be negative?
>>
>> We already had same situation with ARM and it was fixed. Why this can't be done for MIPS or LS?
>
> Well we can fix it for future MIPS systems but not present Loongson.
>
> Actually I've talked to several Chinese MIPS chip vendors and they
> all agreed to unify the booting protcol.
>
> I raised the same question to Loongson ~3 years ago but got
> negative response.
> The idea got reject in a recent private discussions with Loongson
> about 2K1000 upstream stuff.
>
> Also I realized Loongson's chip comes with too many ISA level
> custom designs which makes it impossible to use MIPS generic
> kernel.
>  
>
>>>> This protocol is described here on page 15, "3. Boot protocols"
>>>> https://docplayer.net/62444141-Unified-hosting-interface-md01069-reference-manual.html
>>>>
>>>> According to this protocol, you should have:
>>>> fw_arg0 = -2
>>>> fw_arg1 = Virtual (kseg0) address of Device Tree Blob
>>>>
>>>> This would made LS a first grade resident for many boot loaders and
>>>> save a lot of needles headaches.
>>>>
>>> Loongson is stepping away from MIPS and it seems like they're going to use EDK-II for their Loongarch.
>>>
>> It seems to be UEFI related, it seems to be not related to the CPU arch, or do i'm missing something?
> I meant they won't invest much to MIPS based chips :-(
>> In any case, if this is true, then it means, that Loongsoon is about to drop support for old boot
>> loaders (PMON?) and do new thing (one more boot protocol?). So argumentation, we upstream old own
>> protocol, but will drop it to make some thing new is not really good example :)
> Yes, actually many new Loongson desktop machines (3A3000/3A4000) are shipped
> with UEFI and relies on second stage bootloader to convert to old boot
> protocol.
>
> I'm againt to upstraming the "new" protocol as it's non-standard UEFI
> with many
> nonsense design.
>
>
>>> TBH I've checked Loongson's PMON code and realized it can't be ported to other projects easily.
>>> Tons of unregonized assembly code.
>>>
>> No need to port it. Here is example of working clean code:
>> https://git.pengutronix.de/cgit/barebox/tree/arch/mips/boards/loongson-ls1b/lowlevel.S
> I've ported U-Boot to LS1C as well. But LS1B/LS1C is Loongson32.
> Loongson64 based systems like LS2K is much more complex than it.
> The bootloader is fullfilled with assembly and mostly undocumented.
> LS2K's PMON contains ~50k lines of assembly.

OK, i hope i'll never have customers using this chips. Are there any
reason why do we wont to keep it alive? :D


--
Regards,
Oleksij

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

* Re: [PATCH v4 6/7] dt-bindings: interrupt-controller: Add Loongson-2K1000 LIOINTC
  2021-03-10 12:04   ` Jiaxun Yang
@ 2021-03-11  1:43     ` zhangqing
  0 siblings, 0 replies; 17+ messages in thread
From: zhangqing @ 2021-03-11  1:43 UTC (permalink / raw)
  To: Jiaxun Yang, Huacai Chen, Thomas Bogendoerfer, Thomas Gleixner,
	Marc Zyngier
  Cc: linux-mips, linux-kernel, devicetree, Ming Wang

On 03/10/2021 08:04 PM, Jiaxun Yang wrote:
>
> On Wed, Mar 10, 2021, at 3:56 PM, Qing Zhang wrote:
>> Add liointc-2.0 properties support, so update the maxItems and description.
>>
>> Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
> ^ I have nothing todo with this patch so please drop me for this one :-)
>
>> Signed-off-by: Qing Zhang <zhangqing@loongson.cn>
>> Tested-by: Ming Wang <wangming01@loongson.cn>
>> ---
>>
>> v3-v4: Standard submission of information
> ^ It's called commit message.
>
>>   .../bindings/interrupt-controller/loongson,liointc.yaml    | 7 ++++---
>>   1 file changed, 4 insertions(+), 3 deletions(-)
>>
>> diff --git
>> a/Documentation/devicetree/bindings/interrupt-controller/loongson,liointc.yaml b/Documentation/devicetree/bindings/interrupt-controller/loongson,liointc.yaml
>> index f38e0113f360..5280cf60a9a7 100644
>> ---
>> a/Documentation/devicetree/bindings/interrupt-controller/loongson,liointc.yaml
>> +++
>> b/Documentation/devicetree/bindings/interrupt-controller/loongson,liointc.yaml
>> @@ -10,9 +10,9 @@ maintainers:
>>     - Jiaxun Yang <jiaxun.yang@flygoat.com>
>>   
>>   description: |
>> -  This interrupt controller is found in the Loongson-3 family of chips
>> as the primary
>> -  package interrupt controller which can route local I/O interrupt to
>> interrupt lines
>> -  of cores.
>> +  This interrupt controller is found in the Loongson-3 family of chips
>> and
>> +  Loongson-2K1000 chip, as the primary package interrupt controller
>> which
>> +  can route local I/O interrupt to interrupt lines of cores.
>>   
>>   allOf:
>>     - $ref: /schemas/interrupt-controller.yaml#
>> @@ -22,6 +22,7 @@ properties:
>>       oneOf:
>>         - const: loongson,liointc-1.0
>>         - const: loongson,liointc-1.0a
>> +      - const: loongson,liointc-2.0
>>   
>>     reg:
>>       maxItems: 1
> ^ Please document multiple reg prop change as well.
   Hi, Jiaxun

   Thank you for your reply,

   I will do it and send v5.

   Thanks,
   -Qing
>
> Thanks.
>
> - Jiaxun
>
>> -- 
>> 2.20.1
>>
>>


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

end of thread, other threads:[~2021-03-11  1:44 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-10  7:56 [PATCH v4 0/7] Add basic support for Loongson-2K1000 Qing Zhang
2021-03-10  7:56 ` [PATCH v4 1/7] MIPS: Loongson64: DeviceTree " Qing Zhang
2021-03-10  7:56 ` [PATCH v4 2/7] MIPS: Loongson64: Distinguish firmware dependencies DTB/LEFI Qing Zhang
2021-03-10 10:57   ` Oleksij Rempel
2021-03-10 12:12     ` Jiaxun Yang
2021-03-10 13:26       ` Oleksij Rempel
     [not found]         ` <a2b1ad18-8f4b-8e43-e175-c372580a7168@flygoat.com>
2021-03-10 16:03           ` Oleksij Rempel
2021-03-10  7:56 ` [PATCH v4 3/7] MIPS: Loongson64: Add support for the Loongson-2K1000 to get cpu_clock_freq Qing Zhang
2021-03-10  8:50   ` Sergei Shtylyov
2021-03-10  9:37     ` zhangqing
2021-03-10 12:06       ` Jiaxun Yang
2021-03-10  7:56 ` [PATCH v4 4/7] MIPS: Loongson64: Add Loongson-2K1000 early_printk_port Qing Zhang
2021-03-10  7:56 ` [PATCH v4 5/7] irqchip/loongson-liointc: irqchip add 2.0 version Qing Zhang
2021-03-10  7:56 ` [PATCH v4 6/7] dt-bindings: interrupt-controller: Add Loongson-2K1000 LIOINTC Qing Zhang
2021-03-10 12:04   ` Jiaxun Yang
2021-03-11  1:43     ` zhangqing
2021-03-10  7:56 ` [PATCH v4 7/7] MIPS: Loongson64: Add a Loongson-2K1000 default config file Qing Zhang

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.