Skip to contentSkip to conversation

MIPS: Loongson: Add the Loongson-1A processor support

PATCH Superseded Binbin Zhou 3 participants 14 messages Mar 1, 2016 – Apr 22, 2016

Subsystems (3)

v3 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

v3 cover MIPS: Loongson: Add the Loongson-1A processor support

The Loongson 1A is similar with Loongson 1B, which is a 32-bit SoC. It implements the MIPS32 release 2 instruction set.

They share the same PRID, so we rewrite the PRID_REV_LOONGSON1B to PRID_REV_LOONGSON1A_1B, and use their CPU macros to distinguish.

However, Loongson 1A has a bug that the pll register can't be read, so we set the cpu clk in the inline command line.

The command line format is cpu_clk=osc_clk,cpu_mul, the osc_clk standby cpu clock and the cpu_mul repect the clock multiplier.

For example, we use the command is cpu_clk=33333333,8

Changes since v1:

1. According commit c908656a7531771ae7642990a7c5f3c7307bd612 (MIPS: Loongson: Naming style cleanup and rework) to fix the naming style.

Changes since v2:

1. Remove __irq_set_handler_locked()
2. Rebases on top of v4.5-rc5.

Binbin Zhou(8):
MIPS: Loongson: Add basic Loongson-1A CPU support
MIPS: Loongson: Add Loongson-1A Kconfig options
MIPS: Loongson: Add platform devices for Loongson-1A/1B
MIPS: Loongson: Add loongson-1A board support
MIPS: Loongson-1A: Workaround for pll register can't be read
MIPS: Loongson-1A: Add IRQ type setting support
MIPS: Loongson-1A: Enable SPARSEMEN and HIGHMEM
MIPS: Loongson: Add a Loongson-1A default config file

Signature · 27 lines
 arch/mips/Kconfig                                 |  11 +++++
 arch/mips/configs/ls1a_defconfig                  | 132 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 arch/mips/include/asm/cpu-type.h                  |   3 +-
 arch/mips/include/asm/cpu.h                       |   2 +-
 arch/mips/include/asm/mach-loongson32/irq.h       |   1 +
 arch/mips/include/asm/mach-loongson32/loongson1.h | 177 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------
 arch/mips/include/asm/mach-loongson32/platform.h  |  11 +++++
 arch/mips/include/asm/sparsemem.h                 |   6 ++-
 arch/mips/kernel/cpu-probe.c                      |   6 ++-
 arch/mips/loongson32/Kconfig                      |  21 ++++++++++
 arch/mips/loongson32/Makefile                     |   6 +++
 arch/mips/loongson32/Platform                     |   1 +
 arch/mips/loongson32/common/irq.c                 |  46 +++++++++++++++++++++
 arch/mips/loongson32/common/platform.c            | 298 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 arch/mips/loongson32/common/reset.c               |   6 +++
 arch/mips/loongson32/common/setup.c               |  45 ++++++++++++++++++++-
 arch/mips/loongson32/common/time.c                |  11 +++++
 arch/mips/loongson32/ls1a/Makefile                |   5 +++
 arch/mips/loongson32/ls1a/board.c                 | 107 ++++++++++++++++++++++++++++++++++++++++++++++++
 arch/mips/mm/c-r4k.c                              |   7 ++++
 drivers/clk/clk-ls1x.c                            |  19 +++++++--
 21 files changed, 886 insertions(+), 39 deletions(-)
 create mode 100644 arch/mips/configs/ls1a_defconfig
 create mode 100644 arch/mips/loongson32/ls1a/Makefile
 create mode 100644 arch/mips/loongson32/ls1a/board.c
--
1.9.0
#1 lore raw

PATCH v3 1/8 MIPS: Loongson: Add basic Loongson-1A CPU support

The Loongson 1A is similar with Loongson 1B, which is a 32-bit SoC. It implements the MIPS32 release 2 instruction set.

They share the same PRID, so we rewrite the PRID_REV_LOONGSON1B to PRID_REV_LOONGSON1A_1B, and use their CPU macros to distinguish.

---
 arch/mips/include/asm/cpu-type.h    | 3 ++-
 arch/mips/include/asm/cpu.h         | 2 +-
 arch/mips/kernel/cpu-probe.c        | 6 +++++-
 arch/mips/loongson32/Platform       | 1 +
 arch/mips/loongson32/common/setup.c | 6 +++++-
 arch/mips/mm/c-r4k.c                | 7 +++++++
 6 files changed, 21 insertions(+), 4 deletions(-)
arch/mips/include/asm/cpu-type.h +2 -1
index abee2bf..dd6bf46 100644
@@ -24,7 +24,8 @@ static inline int __pure __get_cpu_type(const int cpu_type)
 	case CPU_LOONGSON3:
 #endif
 
-#ifdef CONFIG_SYS_HAS_CPU_LOONGSON1B
+#if defined(CONFIG_SYS_HAS_CPU_LOONGSON1A) || \
+    defined(CONFIG_SYS_HAS_CPU_LOONGSON1B)
 	case CPU_LOONGSON1:
 #endif
 
arch/mips/include/asm/cpu.h +1 -1
index 7bea0f3..0c02803 100644
@@ -236,7 +236,7 @@
 #define PRID_REV_VR4181A	0x0070	/* Same as VR4122 */
 #define PRID_REV_VR4130		0x0080
 #define PRID_REV_34K_V1_0_2	0x0022
-#define PRID_REV_LOONGSON1B	0x0020
+#define PRID_REV_LOONGSON1A_1B	0x0020
 #define PRID_REV_LOONGSON2E	0x0002
 #define PRID_REV_LOONGSON2F	0x0003
 #define PRID_REV_LOONGSON3A	0x0005
arch/mips/kernel/cpu-probe.c +5 -1
index 9ad6157..012ff8c 100644
@@ -1199,8 +1199,12 @@ static inline void cpu_probe_legacy(struct cpuinfo_mips *c, unsigned int cpu)
 		c->cputype = CPU_LOONGSON1;
 
 		switch (c->processor_id & PRID_REV_MASK) {
-		case PRID_REV_LOONGSON1B:
+		case PRID_REV_LOONGSON1A_1B:
+#ifdef CONFIG_CPU_LOONGSON1A
+			__cpu_name[cpu] = "Loongson 1A";
+#else
 			__cpu_name[cpu] = "Loongson 1B";
+#endif
 			break;
 		}
 
arch/mips/loongson32/Platform +1 -0
index ebb6dc2..e114c85 100644
@@ -4,4 +4,5 @@ cflags-$(CONFIG_CPU_LOONGSON1)	+= \
 
 platform-$(CONFIG_MACH_LOONGSON32)	+= loongson32/
 cflags-$(CONFIG_MACH_LOONGSON32)	+= -I$(srctree)/arch/mips/include/asm/mach-loongson32
+load-$(CONFIG_LOONGSON1_LS1A)		+= 0xffffffff80200000
 load-$(CONFIG_LOONGSON1_LS1B)		+= 0xffffffff80100000
arch/mips/loongson32/common/setup.c +5 -1
index 62f41af..c3d2036 100644
@@ -21,8 +21,12 @@ const char *get_system_type(void)
 	unsigned int processor_id = (&current_cpu_data)->processor_id;
 
 	switch (processor_id & PRID_REV_MASK) {
-	case PRID_REV_LOONGSON1B:
+	case PRID_REV_LOONGSON1A_1B:
+#ifdef CONFIG_CPU_LOONGSON1A
+		return "LOONGSON LS1A";
+#else
 		return "LOONGSON LS1B";
+#endif
 	default:
 		return "LOONGSON (unknown)";
 	}
arch/mips/mm/c-r4k.c +7 -0
index caac3d7..1ffeb46 100644
@@ -1289,6 +1289,13 @@ static void probe_pcache(void)
 			c->dcache.flags |= MIPS_CACHE_PINDEX;
 			break;
 		}
+	case CPU_LOONGSON1:
+		if ((read_c0_config7() & (1 << 16))) {
+			/* effectively physically indexed dcache,
+			   thus no virtual aliases. */
+			c->dcache.flags |= MIPS_CACHE_PINDEX;
+			break;
+		}
 	default:
 		if (has_74k_erratum || c->dcache.waysize > PAGE_SIZE)
 			c->dcache.flags |= MIPS_CACHE_ALIASES;
Signature · 1 line
1.9.1
#2 lore raw

PATCH v3 2/8 MIPS: Loongson: Add Loongson-1A Kconfig options

In reply to Binbin Zhou

Added Kconfig options include: Loongson-1A CPU and machine definition, CPU cache features, 32-bit kernel and early printk support.

---
 arch/mips/Kconfig            | 11 +++++++++++
 arch/mips/loongson32/Kconfig | 20 ++++++++++++++++++++
 2 files changed, 31 insertions(+)
arch/mips/Kconfig +11 -0
index c5bf89cb..a6c157e 100644
@@ -1373,6 +1373,14 @@ config CPU_LOONGSON2F
 	  have a similar programming interface with FPGA northbridge used in
 	  Loongson2E.
 
+config CPU_LOONGSON1A
+	bool "Loongson 1A"
+	depends on SYS_HAS_CPU_LOONGSON1A
+	select CPU_LOONGSON1
+	help
+	  The Loongson 1A is a 32-bit SoC, which implements the MIPS32
+	  release 2 instruction set.
+
 config CPU_LOONGSON1B
 	bool "Loongson 1B"
 	depends on SYS_HAS_CPU_LOONGSON1B
@@ -1821,6 +1829,9 @@ config SYS_HAS_CPU_LOONGSON2F
 	select CPU_SUPPORTS_ADDRWINCFG if 64BIT
 	select CPU_SUPPORTS_UNCACHED_ACCELERATED
 
+config SYS_HAS_CPU_LOONGSON1A
+	bool
+
 config SYS_HAS_CPU_LOONGSON1B
 	bool
 
arch/mips/loongson32/Kconfig +20 -0
index 7704f20..741867c 100644
@@ -1,8 +1,28 @@
 if MACH_LOONGSON32
 
+config ZONE_DMA
+	prompt "Zone DMA"
+	bool
+
 choice
 	prompt "Machine Type"
 
+config LOONGSON1_LS1A
+	bool "Loongson LS1A board"
+	select CEVT_R4K
+	select CSRC_R4K
+	select SYS_HAS_CPU_LOONGSON1A
+	select DMA_NONCOHERENT
+	select BOOT_ELF32
+	select IRQ_MIPS_CPU
+	select SYS_SUPPORTS_32BIT_KERNEL
+	select SYS_SUPPORTS_LITTLE_ENDIAN
+	select SYS_SUPPORTS_HIGHMEM
+	select SYS_SUPPORTS_MIPS16
+	select SYS_HAS_EARLY_PRINTK
+	select USE_GENERIC_EARLY_PRINTK_8250
+	select COMMON_CLK
+
 config LOONGSON1_LS1B
 	bool "Loongson LS1B board"
 	select CEVT_R4K if !MIPS_EXTERNAL_TIMER
Signature · 1 line
1.9.1
#3 lore raw

Re: [PATCH v3 2/8] MIPS: Loongson: Add Loongson-1A Kconfig options

arch/mips/loongson32/Kconfig line 6

Quoted 11 lines · Binbin Zhou
arch/mips/loongson32/Kconfig +4 -0
index 7704f20..741867c 100644
@@ -1,8 +1,28 @@
 if MACH_LOONGSON32
 
+config ZONE_DMA
+	prompt "Zone DMA"
+	bool
+

There is already a ZONE_DMA option in arch/mips/Kconfig. Do you really need ZONE_DMA? Even if so I suggest to not present this option to the user interactively but enable it with a select - normal users building a kernel will probably not know what ZONE_DMA is.

Ralf

#4 lore raw

PATCH v3 3/8 MIPS: Loongson: Add platform devices for Loongson-1A/1B

In reply to Binbin Zhou

Added basic platform devices for Loongson 1A, including serial port, ethernet, AHCI, USB, RTC, SPI and so on.

Most of the devices are shared with Loongson 1B, like serial port, ethernet, USB and so on.
Specially, something like AHCI is only used in Loonson 1A.

---
 arch/mips/include/asm/mach-loongson32/irq.h       |   1 +
 arch/mips/include/asm/mach-loongson32/loongson1.h | 167 +++++++++++--
 arch/mips/include/asm/mach-loongson32/platform.h  |  11 +
 arch/mips/loongson32/common/platform.c            | 290 +++++++++++++++++++++-
 4 files changed, 441 insertions(+), 28 deletions(-)
arch/mips/include/asm/mach-loongson32/irq.h +1 -0
index 0d35b99..326e541 100644
@@ -65,6 +65,7 @@
 #define LS1X_OHCI_IRQ			LS1X_IRQ(1, 1)
 #define LS1X_GMAC0_IRQ			LS1X_IRQ(1, 2)
 #define LS1X_GMAC1_IRQ			LS1X_IRQ(1, 3)
+#define LS1X_AHCI_IRQ			LS1X_IRQ(1, 4)
 
 #define LS1X_IRQS		(LS1X_IRQ(4, 31) + 1 - LS1X_IRQ_BASE)
 
arch/mips/include/asm/mach-loongson32/loongson1.h +141 -26

173 lines not on this page · raw message

arch/mips/include/asm/mach-loongson32/platform.h +11 -0
index c32f03f..f25398c 100644
@@ -19,6 +19,17 @@ extern struct platform_device ls1x_eth0_pdev;
 extern struct platform_device ls1x_eth1_pdev;
 extern struct platform_device ls1x_ehci_pdev;
 extern struct platform_device ls1x_rtc_pdev;
+extern struct platform_device ls1x_fb_pdev;
+extern struct platform_device ls1x_i2c0_pdev;
+extern struct platform_device ls1x_i2c1_pdev;
+extern struct platform_device ls1x_i2c2_pdev;
+extern struct platform_device ls1x_ahci_pdev;
+extern struct platform_device ls1x_ohci_pdev;
+extern struct platform_device ls1x_wat_pdev;
+extern struct platform_device ls1x_audio_pdev;
+extern struct platform_device ls1x_spi0_pdev;
+extern struct platform_device ls1x_spi1_pdev;
+extern struct platform_device ls1x_nand_pdev;
 
 extern void __init ls1x_clk_init(void);
 extern void __init ls1x_serial_setup(struct platform_device *pdev);
arch/mips/loongson32/common/platform.c +288 -2

340 lines not on this page · raw message

Signature · 1 line
1.9.1
#5 lore raw

Re: [PATCH v3 3/8] MIPS: Loongson: Add platform devices for Loongson-1A/1B

Quoted 6 lines · Binbin Zhou

Added basic platform devices for Loongson 1A, including serial port, ethernet, AHCI, USB, RTC, SPI and so on.

Most of the devices are shared with Loongson 1B, like serial port, ethernet, USB and so on.
Specially, something like AHCI is only used in Loonson 1A.

                                                 ^^^^^^^

Loongson.

Quoted 9 lines
---
 arch/mips/include/asm/mach-loongson32/irq.h       |   1 +
 arch/mips/include/asm/mach-loongson32/loongson1.h | 167 +++++++++++--
 arch/mips/include/asm/mach-loongson32/platform.h  |  11 +
 arch/mips/loongson32/common/platform.c            | 290 +++++++++++++++++++++-
 4 files changed, 441 insertions(+), 28 deletions(-)

How about switching the platform to DT?

Ralf

#6 lore raw

PATCH v3 4/8 MIPS: Loongson: Add loongson-1A board support

In reply to Binbin Zhou

Loongson 1A's platform devices register.

Specially, Loongson 1A use ACPI to control restart/poweroff/halt.

---
 arch/mips/include/asm/mach-loongson32/loongson1.h |   8 ++
 arch/mips/loongson32/Makefile                     |   6 ++
 arch/mips/loongson32/common/reset.c               |   6 ++
 arch/mips/loongson32/common/setup.c               |  38 +++++++-
 arch/mips/loongson32/ls1a/Makefile                |   5 ++
 arch/mips/loongson32/ls1a/board.c                 | 105 ++++++++++++++++++++++
 6 files changed, 167 insertions(+), 1 deletion(-)
 create mode 100644 arch/mips/loongson32/ls1a/Makefile
 create mode 100644 arch/mips/loongson32/ls1a/board.c
arch/mips/include/asm/mach-loongson32/loongson1.h +8 -0
index 5c1ba48..3061e64 100644
@@ -157,6 +157,14 @@
 #define LS1X_LPC_CFG2_REG		(LS1X_LPC_REG_BASE + 0x8)
 #define LS1X_LPC_CFG3_REG		(LS1X_LPC_REG_BASE + 0xc)
 
+/* reg access */
+#define ls1x_readb(addr)		(*(volatile u8 *)CKSEG1ADDR(addr))
+#define ls1x_readw(addr)		(*(volatile u16 *)CKSEG1ADDR(addr))
+#define ls1x_readl(addr)		(*(volatile u32 *)CKSEG1ADDR(addr))
+#define ls1x_writeb(val, addr)		(*(volatile u8 *)CKSEG1ADDR(addr) = (val))
+#define ls1x_writew(val, addr)		(*(volatile u16 *)CKSEG1ADDR(addr) = (val))
+#define ls1x_writel(val, addr)		(*(volatile u32 *)CKSEG1ADDR(addr) = (val))
+
 #include <regs-clk.h>
 #include <regs-mux.h>
 #include <regs-pwm.h>
arch/mips/loongson32/Makefile +6 -0
index 5f4bd6e..c2a6559 100644
@@ -5,6 +5,12 @@
 obj-$(CONFIG_MACH_LOONGSON32) += common/
 
 #
+# Loongson LS1A board
+#
+
+obj-$(CONFIG_LOONGSON1_LS1A)  += ls1a/
+
+#
 # Loongson LS1B board
 #
 
arch/mips/loongson32/common/reset.c +6 -0
index c41e4ca..71630fd 100644
@@ -18,10 +18,14 @@ static void __iomem *wdt_base;
 
 static void ls1x_halt(void)
 {
+#ifdef CONFIG_CPU_LOONGSON1A
+	ls1x_writel(ls1x_readl(LS1X_PM1_CNT_REG) | 0x3d00, LS1X_PM1_CNT_REG);
+#else
 	while (1) {
 		if (cpu_wait)
 			cpu_wait();
 	}
+#endif
 }
 
 static void ls1x_restart(char *command)
@@ -30,7 +34,9 @@ static void ls1x_restart(char *command)
 	__raw_writel(0x1, wdt_base + WDT_TIMER);
 	__raw_writel(0x1, wdt_base + WDT_SET);
 
+#ifndef CONFIG_CPU_LOONGSON1A
 	ls1x_halt();
+#endif
 }
 
 static void ls1x_power_off(void)
arch/mips/loongson32/common/setup.c +37 -1
index c3d2036..87d21c9 100644
@@ -8,12 +8,48 @@
  */
 
 #include <asm/bootinfo.h>
-
+#include <linux/ioport.h>
+#include <linux/screen_info.h>
 #include <prom.h>
 
+void (*__wbflush)(void);
+static void wbflush_ls1x(void)
+{
+	asm(".set\tpush\n\t"
+	    ".set\tnoreorder\n\t"
+	    ".set mips3\n\t"
+	    "sync\n\t"
+	    "nop\n\t"
+	    ".set\tpop\n\t"
+	    ".set mips0\n\t");
+}
+
 void __init plat_mem_setup(void)
 {
 	add_memory_region(0x0, (memsize << 20), BOOT_MEM_RAM);
+
+#ifdef CONFIG_CPU_LOONGSON1A
+	ioport_resource.start	= 0;
+	ioport_resource.end	= 0xffffffff;
+	iomem_resource.start	= 0;
+	iomem_resource.end	= 0xffffffff;
+
+	__wbflush = wbflush_ls1x;
+
+	set_io_port_base(0xbc000000);
+
+#if defined(CONFIG_VGA_CONSOLE)
+	screen_info = (struct screen_info) {
+		.orig_x			= 0,
+		.orig_y			= 25,
+		.orig_video_cols	= 80,
+		.orig_video_lines	= 25,
+		.orig_video_isVGA	= VIDEO_TYPE_VGAC,
+		.orig_video_points	= 16,
+	};
+#endif
+	add_memory_region(0x20000000, 0x30000000, BOOT_MEM_RESERVED);
+#endif
 }
 
 const char *get_system_type(void)
arch/mips/loongson32/ls1a/Makefile new file +5 -0
new file mode 100644
index 0000000..7f2baf3
@@ -0,0 +1,5 @@
+#
+# Makefile for Loongson 1A based machines.
+#
+
+obj-y += board.o
arch/mips/loongson32/ls1a/board.c new file +105 -0

105 lines not on this page · raw message

Signature · 1 line
1.9.1
#7 lore raw

PATCH v3 5/8 MIPS: Loongson-1A: Workaround for pll register can't be read

In reply to Binbin Zhou

This is Loongson 1A's bug that the pll register can't be read, so we set the cpu clk in the inline command line.

The command line format is cpu_clk=osc_clk,cpu_mul,
the osc_clk standby cpu clock and the cpu_mul repect the clock multiplier. For example, we use the command is cpu_clk=33333333,8

---
 arch/mips/include/asm/mach-loongson32/loongson1.h |  2 ++
 arch/mips/loongson32/common/platform.c            |  8 +++++++-
 arch/mips/loongson32/common/time.c                | 16 ++++++++++++++++
 arch/mips/loongson32/ls1a/board.c                 |  2 ++
 drivers/clk/clk-ls1x.c                            | 19 +++++++++++++++----
 5 files changed, 42 insertions(+), 5 deletions(-)
arch/mips/include/asm/mach-loongson32/loongson1.h +2 -0
index 3061e64..82f951e 100644
@@ -165,6 +165,8 @@
 #define ls1x_writew(val, addr)		(*(volatile u16 *)CKSEG1ADDR(addr) = (val))
 #define ls1x_writel(val, addr)		(*(volatile u32 *)CKSEG1ADDR(addr) = (val))
 
+extern unsigned int ls1a_osc_clk, ls1a_cpu_mul;
+
 #include <regs-clk.h>
 #include <regs-mux.h>
 #include <regs-pwm.h>
arch/mips/loongson32/common/platform.c +7 -1
index 97d8c01..a5bb1eb 100644
@@ -63,9 +63,14 @@ struct platform_device ls1x_uart_pdev = {
 
 void __init ls1x_serial_setup(struct platform_device *pdev)
 {
-	struct clk *clk;
 	struct plat_serial8250_port *p;
 
+#ifdef CONFIG_CPU_LOONGSON1A
+	for (p = pdev->dev.platform_data; p->flags != 0; ++p)
+		p->uartclk = ls1a_osc_clk * 2;
+#else
+	struct clk *clk;
+
 	clk = clk_get(&pdev->dev, pdev->name);
 	if (IS_ERR(clk)) {
 		pr_err("unable to get %s clock, err=%ld",
@@ -76,6 +81,7 @@ void __init ls1x_serial_setup(struct platform_device *pdev)
 
 	for (p = pdev->dev.platform_data; p->flags != 0; ++p)
 		p->uartclk = clk_get_rate(clk);
+#endif
 }
 
 /* CPUFreq */
arch/mips/loongson32/common/time.c +16 -0
index 0996b02..bba1c84 100644
@@ -235,3 +235,19 @@ void __init plat_time_init(void)
 	mips_hpt_frequency = clk_get_rate(clk) / 2;
 #endif /* CONFIG_CEVT_CSRC_LS1X */
 }
+
+#ifdef CONFIG_CPU_LOONGSON1A
+unsigned int ls1a_osc_clk = 0, ls1a_cpu_mul = 0;
+
+static int __init get_cpu_clk(char *string)
+{
+	int ret;
+
+	ret = sscanf(string, "%u,%u", &ls1a_osc_clk, &ls1a_cpu_mul);
+	if (ret != 1)
+		return -EINVAL;
+
+	return 1;
+}
+__setup("cpu_clk=", get_cpu_clk);
+#endif
arch/mips/loongson32/ls1a/board.c +2 -0
index 98fb86c..9c53ecc 100644
@@ -95,6 +95,8 @@ int __init ls1a_platform_init(void)
 {
 	ls1a_route_setting();
 
+	ls1x_serial_setup(&ls1x_uart_pdev);
+
 	i2c_register_board_info(1, &ls1a_pcf8563, 1);
 	spi_register_board_info(ls1a_spi_info, ARRAY_SIZE(ls1a_spi_info));
 
drivers/clk/clk-ls1x.c +15 -4
index d4c6198..18326fb 100644
@@ -32,6 +32,14 @@ static void ls1x_pll_clk_disable(struct clk_hw *hw)
 static unsigned long ls1x_pll_recalc_rate(struct clk_hw *hw,
 					  unsigned long parent_rate)
 {
+#ifdef CONFIG_CPU_LOONGSON1A
+	/* workaround, loongson 1A pll register can't be read,
+	 * on gateway board, multi is set to 11 */
+	if (ls1a_osc_clk != 0 && ls1a_cpu_mul != 0)
+		return ls1a_osc_clk * ls1a_cpu_mul;
+	else
+		return 33333333 * 8;
+#else
 	u32 pll, rate;
 
 	pll = __raw_readl(LS1X_CLK_PLL_FREQ);
@@ -40,6 +48,7 @@ static unsigned long ls1x_pll_recalc_rate(struct clk_hw *hw,
 	rate >>= 1;
 
 	return rate;
+#endif
 }
 
 static const struct clk_ops ls1x_pll_clk_ops = {
@@ -107,7 +116,8 @@ void __init ls1x_clk_init(void)
 				   CLK_GET_RATE_NOCACHE, LS1X_CLK_PLL_DIV,
 				   DIV_CPU_SHIFT, DIV_CPU_WIDTH,
 				   CLK_DIVIDER_ONE_BASED |
-				   CLK_DIVIDER_ROUND_CLOSEST, &_lock);
+				   CLK_DIVIDER_ROUND_CLOSEST |
+				   CLK_DIVIDER_ALLOW_ZERO, &_lock);
 	clk_register_clkdev(clk, "cpu_clk_div", NULL);
 	clk = clk_register_mux(NULL, "cpu_clk", cpu_parents,
 			       ARRAY_SIZE(cpu_parents),
@@ -123,7 +133,8 @@ void __init ls1x_clk_init(void)
 	 */
 	clk = clk_register_divider(NULL, "dc_clk_div", "pll_clk",
 				   0, LS1X_CLK_PLL_DIV, DIV_DC_SHIFT,
-				   DIV_DC_WIDTH, CLK_DIVIDER_ONE_BASED, &_lock);
+				   DIV_DC_WIDTH, CLK_DIVIDER_ONE_BASED |
+				   CLK_DIVIDER_ALLOW_ZERO, &_lock);
 	clk_register_clkdev(clk, "dc_clk_div", NULL);
 	clk = clk_register_mux(NULL, "dc_clk", dc_parents,
 			       ARRAY_SIZE(dc_parents),
@@ -139,8 +150,8 @@ void __init ls1x_clk_init(void)
 	 */
 	clk = clk_register_divider(NULL, "ahb_clk_div", "pll_clk",
 				   0, LS1X_CLK_PLL_DIV, DIV_DDR_SHIFT,
-				   DIV_DDR_WIDTH, CLK_DIVIDER_ONE_BASED,
-				   &_lock);
+				   DIV_DDR_WIDTH, CLK_DIVIDER_ONE_BASED |
+				   CLK_DIVIDER_ALLOW_ZERO, &_lock);
 	clk_register_clkdev(clk, "ahb_clk_div", NULL);
 	clk = clk_register_mux(NULL, "ahb_clk", ahb_parents,
 			       ARRAY_SIZE(ahb_parents),
Signature · 1 line
1.9.1
#8 lore raw

Re: [PATCH v3 5/8] MIPS: Loongson-1A: Workaround for pll register can't be read

Please cc the clk maintainers and list on patches like this:

COMMON CLK FRAMEWORK

M:      Michael Turquette <[email protected]>
M:      Stephen Boyd <[email protected]>
L:      [email protected]
T:      git git://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git
S:      Maintained
F:      drivers/clk/
X:      drivers/clk/clkdev.c
F:      include/linux/clk-pr*
F:      include/linux/clk/

Ralf

Quoted 168 lines · Binbin Zhou

Date: Tue, 1 Mar 2016 08:48:13 +0800
From: Binbin Zhou <[email protected]>
To: Ralf Baechle <[email protected]>
Cc: John Crispin <[email protected]>, "Steven J . Hill"
<[email protected]>, [email protected], Fuxin Zhang <[email protected]>, Zhangjin Wu <[email protected]>, Kelvin Cheung <[email protected]>, Binbin Zhou <[email protected]>, Chunbo Cui <[email protected]>, Huacai Chen <[email protected]>
Subject: [PATCH v3 5/8] MIPS: Loongson-1A: Workaround for pll register
can't be read

This is Loongson 1A's bug that the pll register can't be read, so we set the cpu clk in the inline command line.

The command line format is cpu_clk=osc_clk,cpu_mul,
the osc_clk standby cpu clock and the cpu_mul repect the clock multiplier. For example, we use the command is cpu_clk=33333333,8

---
 arch/mips/include/asm/mach-loongson32/loongson1.h |  2 ++
 arch/mips/loongson32/common/platform.c            |  8 +++++++-
 arch/mips/loongson32/common/time.c                | 16 ++++++++++++++++
 arch/mips/loongson32/ls1a/board.c                 |  2 ++
 drivers/clk/clk-ls1x.c                            | 19 +++++++++++++++----
 5 files changed, 42 insertions(+), 5 deletions(-)
arch/mips/include/asm/mach-loongson32/loongson1.h +2 -0
index 3061e64..82f951e 100644
@@ -165,6 +165,8 @@
 #define ls1x_writew(val, addr)		(*(volatile u16 *)CKSEG1ADDR(addr) = (val))
 #define ls1x_writel(val, addr)		(*(volatile u32 *)CKSEG1ADDR(addr) = (val))
 
+extern unsigned int ls1a_osc_clk, ls1a_cpu_mul;
+
 #include <regs-clk.h>
 #include <regs-mux.h>
 #include <regs-pwm.h>
arch/mips/loongson32/common/platform.c +7 -1
index 97d8c01..a5bb1eb 100644
@@ -63,9 +63,14 @@ struct platform_device ls1x_uart_pdev = {
 
 void __init ls1x_serial_setup(struct platform_device *pdev)
 {
-	struct clk *clk;
 	struct plat_serial8250_port *p;
 
+#ifdef CONFIG_CPU_LOONGSON1A
+	for (p = pdev->dev.platform_data; p->flags != 0; ++p)
+		p->uartclk = ls1a_osc_clk * 2;
+#else
+	struct clk *clk;
+
 	clk = clk_get(&pdev->dev, pdev->name);
 	if (IS_ERR(clk)) {
 		pr_err("unable to get %s clock, err=%ld",
@@ -76,6 +81,7 @@ void __init ls1x_serial_setup(struct platform_device *pdev)
 
 	for (p = pdev->dev.platform_data; p->flags != 0; ++p)
 		p->uartclk = clk_get_rate(clk);
+#endif
 }
 
 /* CPUFreq */
arch/mips/loongson32/common/time.c +16 -0
index 0996b02..bba1c84 100644
@@ -235,3 +235,19 @@ void __init plat_time_init(void)
 	mips_hpt_frequency = clk_get_rate(clk) / 2;
 #endif /* CONFIG_CEVT_CSRC_LS1X */
 }
+
+#ifdef CONFIG_CPU_LOONGSON1A
+unsigned int ls1a_osc_clk = 0, ls1a_cpu_mul = 0;
+
+static int __init get_cpu_clk(char *string)
+{
+	int ret;
+
+	ret = sscanf(string, "%u,%u", &ls1a_osc_clk, &ls1a_cpu_mul);
+	if (ret != 1)
+		return -EINVAL;
+
+	return 1;
+}
+__setup("cpu_clk=", get_cpu_clk);
+#endif
arch/mips/loongson32/ls1a/board.c +2 -0
index 98fb86c..9c53ecc 100644
@@ -95,6 +95,8 @@ int __init ls1a_platform_init(void)
 {
 	ls1a_route_setting();
 
+	ls1x_serial_setup(&ls1x_uart_pdev);
+
 	i2c_register_board_info(1, &ls1a_pcf8563, 1);
 	spi_register_board_info(ls1a_spi_info, ARRAY_SIZE(ls1a_spi_info));
 
drivers/clk/clk-ls1x.c +15 -4
index d4c6198..18326fb 100644
@@ -32,6 +32,14 @@ static void ls1x_pll_clk_disable(struct clk_hw *hw)
 static unsigned long ls1x_pll_recalc_rate(struct clk_hw *hw,
 					  unsigned long parent_rate)
 {
+#ifdef CONFIG_CPU_LOONGSON1A
+	/* workaround, loongson 1A pll register can't be read,
+	 * on gateway board, multi is set to 11 */
+	if (ls1a_osc_clk != 0 && ls1a_cpu_mul != 0)
+		return ls1a_osc_clk * ls1a_cpu_mul;
+	else
+		return 33333333 * 8;
+#else
 	u32 pll, rate;
 
 	pll = __raw_readl(LS1X_CLK_PLL_FREQ);
@@ -40,6 +48,7 @@ static unsigned long ls1x_pll_recalc_rate(struct clk_hw *hw,
 	rate >>= 1;
 
 	return rate;
+#endif
 }
 
 static const struct clk_ops ls1x_pll_clk_ops = {
@@ -107,7 +116,8 @@ void __init ls1x_clk_init(void)
 				   CLK_GET_RATE_NOCACHE, LS1X_CLK_PLL_DIV,
 				   DIV_CPU_SHIFT, DIV_CPU_WIDTH,
 				   CLK_DIVIDER_ONE_BASED |
-				   CLK_DIVIDER_ROUND_CLOSEST, &_lock);
+				   CLK_DIVIDER_ROUND_CLOSEST |
+				   CLK_DIVIDER_ALLOW_ZERO, &_lock);
 	clk_register_clkdev(clk, "cpu_clk_div", NULL);
 	clk = clk_register_mux(NULL, "cpu_clk", cpu_parents,
 			       ARRAY_SIZE(cpu_parents),
@@ -123,7 +133,8 @@ void __init ls1x_clk_init(void)
 	 */
 	clk = clk_register_divider(NULL, "dc_clk_div", "pll_clk",
 				   0, LS1X_CLK_PLL_DIV, DIV_DC_SHIFT,
-				   DIV_DC_WIDTH, CLK_DIVIDER_ONE_BASED, &_lock);
+				   DIV_DC_WIDTH, CLK_DIVIDER_ONE_BASED |
+				   CLK_DIVIDER_ALLOW_ZERO, &_lock);
 	clk_register_clkdev(clk, "dc_clk_div", NULL);
 	clk = clk_register_mux(NULL, "dc_clk", dc_parents,
 			       ARRAY_SIZE(dc_parents),
@@ -139,8 +150,8 @@ void __init ls1x_clk_init(void)
 	 */
 	clk = clk_register_divider(NULL, "ahb_clk_div", "pll_clk",
 				   0, LS1X_CLK_PLL_DIV, DIV_DDR_SHIFT,
-				   DIV_DDR_WIDTH, CLK_DIVIDER_ONE_BASED,
-				   &_lock);
+				   DIV_DDR_WIDTH, CLK_DIVIDER_ONE_BASED |
+				   CLK_DIVIDER_ALLOW_ZERO, &_lock);
 	clk_register_clkdev(clk, "ahb_clk_div", NULL);
 	clk = clk_register_mux(NULL, "ahb_clk", ahb_parents,
 			       ARRAY_SIZE(ahb_parents),
Signature · 1 line
1.9.1

Ralf

#9 lore raw

Re: [PATCH v3 5/8] MIPS: Loongson-1A: Workaround for pll register can't be read

Quoted 23 lines · Ralf Baechle
Quoted 22 lines · Binbin Zhou
arch/mips/loongson32/common/platform.c +6 -1
index 97d8c01..a5bb1eb 100644
@@ -63,9 +63,14 @@ struct platform_device ls1x_uart_pdev = {
 
 void __init ls1x_serial_setup(struct platform_device *pdev)
 {
-	struct clk *clk;
 	struct plat_serial8250_port *p;
 
+#ifdef CONFIG_CPU_LOONGSON1A
+	for (p = pdev->dev.platform_data; p->flags != 0; ++p)
+		p->uartclk = ls1a_osc_clk * 2;
+#else
+	struct clk *clk;
+
 	clk = clk_get(&pdev->dev, pdev->name);
 	if (IS_ERR(clk)) {
 		pr_err("unable to get %s clock, err=%ld",
@@ -76,6 +81,7 @@ void __init ls1x_serial_setup(struct platform_device *pdev)
 
Quoted 3 lines

arch/mips/loongson32/common/platform.c void __init ls1x_serial_setup(struct platform_device *pdev) · line 84

Quoted 3 lines
arch/mips/loongson32/common/platform.c +1 -0
 	for (p = pdev->dev.platform_data; p->flags != 0; ++p)
 		p->uartclk = clk_get_rate(clk);
+#endif

I don't understand this change. Does the framework not work well enough to tell us the uart clk rate?

Quoted 16 lines
Quoted 8 lines
arch/mips/loongson32/common/platform.c +0 -0
 }
 
 /* CPUFreq */
arch/mips/loongson32/common/time.c +0 -0
index 0996b02..bba1c84 100644

arch/mips/loongson32/common/time.c void __init plat_time_init(void) · line 242

Quoted 8 lines
arch/mips/loongson32/common/time.c +5 -0
@@ -235,3 +235,19 @@ void __init plat_time_init(void)
 	mips_hpt_frequency = clk_get_rate(clk) / 2;
 #endif /* CONFIG_CEVT_CSRC_LS1X */
 }
+
+#ifdef CONFIG_CPU_LOONGSON1A
+unsigned int ls1a_osc_clk = 0, ls1a_cpu_mul = 0;
+
+static int __init get_cpu_clk(char *string)

Maybe name this function loongson_get_cpu_clk()?

Quoted 22 lines
Quoted 22 lines
drivers/clk/clk-ls1x.c +8 -0
index d4c6198..18326fb 100644
@@ -32,6 +32,14 @@ static void ls1x_pll_clk_disable(struct clk_hw *hw)
 static unsigned long ls1x_pll_recalc_rate(struct clk_hw *hw,
 					  unsigned long parent_rate)
 {
+#ifdef CONFIG_CPU_LOONGSON1A
+	/* workaround, loongson 1A pll register can't be read,
+	 * on gateway board, multi is set to 11 */
+	if (ls1a_osc_clk != 0 && ls1a_cpu_mul != 0)
+		return ls1a_osc_clk * ls1a_cpu_mul;
+	else
+		return 33333333 * 8;
+#else
 	u32 pll, rate;
 
 	pll = __raw_readl(LS1X_CLK_PLL_FREQ);
@@ -40,6 +48,7 @@ static unsigned long ls1x_pll_recalc_rate(struct clk_hw *hw,
 	rate >>= 1;
 
Quoted 6 lines

drivers/clk/clk-ls1x.c void __init ls1x_clk_init(void)

Quoted 6 lines
drivers/clk/clk-ls1x.c +1 -0
 	return rate;
+#endif
 }
 
 static const struct clk_ops ls1x_pll_clk_ops = {
@@ -107,7 +116,8 @@ void __init ls1x_clk_init(void)

Any reason we can't pass the rates to this function?

Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
#10 lore raw

PATCH v3 6/8 MIPS: Loongson-1A: Add IRQ type setting support

In reply to Binbin Zhou

Loongson 1A's INT controller support two different interrupt trigger mode:
level trigger and edge trigger.

Whether the INT controller stores the external interrupts is the difference between them.
The edge trigger should do this, and operate INT_CLR register to clear the CPU interrupt state.

---
 arch/mips/loongson32/common/irq.c | 46 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)
arch/mips/loongson32/common/irq.c +46 -0
index 455a770..01e8cb9 100644
@@ -62,12 +62,57 @@ static void ls1x_irq_unmask(struct irq_data *d)
 			| (1 << bit), LS1X_INTC_INTIEN(n));
 }
 
+static int ls1x_irq_set_type(struct irq_data *data, unsigned int flow_type)
+{
+	unsigned int bit = (data->irq - LS1X_IRQ_BASE) & 0x1f;
+	unsigned int n = (data->irq - LS1X_IRQ_BASE) >> 5;
+
+	if (flow_type & IRQ_TYPE_EDGE_BOTH) {
+		if ((flow_type & IRQ_TYPE_EDGE_BOTH) == IRQ_TYPE_EDGE_BOTH) {
+			pr_info("ls1x irq don't support both rising and falling\n");
+			return -1;
+		}
+		ls1x_writel(ls1x_readl(LS1X_INTC_INTCLR(n))
+				| (1 << bit), LS1X_INTC_INTCLR(n));
+		if (flow_type & IRQ_TYPE_EDGE_RISING)
+			ls1x_writel(ls1x_readl(LS1X_INTC_INTPOL(n))
+					| (1 << bit), LS1X_INTC_INTPOL(n));
+		else
+			ls1x_writel(ls1x_readl(LS1X_INTC_INTPOL(n))
+					& ~(1 << bit), LS1X_INTC_INTPOL(n));
+
+		ls1x_writel(ls1x_readl(LS1X_INTC_INTEDGE(n))
+				| (1 << bit), LS1X_INTC_INTEDGE(n));
+		ls1x_writel(ls1x_readl(LS1X_INTC_INTIEN(n))
+				| (1 << bit), LS1X_INTC_INTIEN(n));
+		irq_set_handler_locked(data, handle_edge_irq);
+	} else if (flow_type && IRQ_TYPE_LEVEL_MASK) {
+		ls1x_writel(ls1x_readl(LS1X_INTC_INTCLR(n))
+				| (1 << bit), LS1X_INTC_INTCLR(n));
+		if (flow_type & IRQ_TYPE_LEVEL_HIGH)
+			ls1x_writel(ls1x_readl(LS1X_INTC_INTPOL(n))
+					| (1 << bit), LS1X_INTC_INTPOL(n));
+		else if (flow_type & IRQ_TYPE_LEVEL_LOW)
+			ls1x_writel(ls1x_readl(LS1X_INTC_INTPOL(n))
+					& ~(1 << bit), LS1X_INTC_INTPOL(n));
+
+		ls1x_writel(ls1x_readl(LS1X_INTC_INTEDGE(n))
+				& ~(1 << bit), LS1X_INTC_INTEDGE(n));
+		ls1x_writel(ls1x_readl(LS1X_INTC_INTIEN(n))
+				| (1 << bit), LS1X_INTC_INTIEN(n));
+		irq_set_handler_locked(data, handle_level_irq);
+	}
+
+	return IRQ_SET_MASK_OK;
+}
+
 static struct irq_chip ls1x_irq_chip = {
 	.name		= "LS1X-INTC",
 	.irq_ack	= ls1x_irq_ack,
 	.irq_mask	= ls1x_irq_mask,
 	.irq_mask_ack	= ls1x_irq_mask_ack,
 	.irq_unmask	= ls1x_irq_unmask,
+	.irq_set_type	= ls1x_irq_set_type,
 };
 
 static void ls1x_irq_dispatch(int n)
@@ -138,6 +183,7 @@ static void __init ls1x_irq_init(int base)
 	setup_irq(INT1_IRQ, &cascade_irqaction);
 	setup_irq(INT2_IRQ, &cascade_irqaction);
 	setup_irq(INT3_IRQ, &cascade_irqaction);
+	setup_irq(INT4_IRQ, &cascade_irqaction);
 }
 
 void __init arch_init_irq(void)
Signature · 1 line
1.9.1
#11 lore raw

Re: [PATCH v3 6/8] MIPS: Loongson-1A: Add IRQ type setting support

Please consider moving this to drivers/irqchip/.

Ralf

Quoted 98 lines · Binbin Zhou

Date: Tue, 1 Mar 2016 08:48:14 +0800
From: Binbin Zhou <[email protected]>
To: Ralf Baechle <[email protected]>
Cc: John Crispin <[email protected]>, "Steven J . Hill"
<[email protected]>, [email protected], Fuxin Zhang <[email protected]>, Zhangjin Wu <[email protected]>, Kelvin Cheung <[email protected]>, Binbin Zhou <[email protected]>, Chunbo Cui <[email protected]>, Huacai Chen <[email protected]>
Subject: [PATCH v3 6/8] MIPS: Loongson-1A: Add IRQ type setting support

Loongson 1A's INT controller support two different interrupt trigger mode:
level trigger and edge trigger.

Whether the INT controller stores the external interrupts is the difference between them.
The edge trigger should do this, and operate INT_CLR register to clear the CPU interrupt state.

---
 arch/mips/loongson32/common/irq.c | 46 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)
arch/mips/loongson32/common/irq.c +46 -0
index 455a770..01e8cb9 100644
@@ -62,12 +62,57 @@ static void ls1x_irq_unmask(struct irq_data *d)
 			| (1 << bit), LS1X_INTC_INTIEN(n));
 }
 
+static int ls1x_irq_set_type(struct irq_data *data, unsigned int flow_type)
+{
+	unsigned int bit = (data->irq - LS1X_IRQ_BASE) & 0x1f;
+	unsigned int n = (data->irq - LS1X_IRQ_BASE) >> 5;
+
+	if (flow_type & IRQ_TYPE_EDGE_BOTH) {
+		if ((flow_type & IRQ_TYPE_EDGE_BOTH) == IRQ_TYPE_EDGE_BOTH) {
+			pr_info("ls1x irq don't support both rising and falling\n");
+			return -1;
+		}
+		ls1x_writel(ls1x_readl(LS1X_INTC_INTCLR(n))
+				| (1 << bit), LS1X_INTC_INTCLR(n));
+		if (flow_type & IRQ_TYPE_EDGE_RISING)
+			ls1x_writel(ls1x_readl(LS1X_INTC_INTPOL(n))
+					| (1 << bit), LS1X_INTC_INTPOL(n));
+		else
+			ls1x_writel(ls1x_readl(LS1X_INTC_INTPOL(n))
+					& ~(1 << bit), LS1X_INTC_INTPOL(n));
+
+		ls1x_writel(ls1x_readl(LS1X_INTC_INTEDGE(n))
+				| (1 << bit), LS1X_INTC_INTEDGE(n));
+		ls1x_writel(ls1x_readl(LS1X_INTC_INTIEN(n))
+				| (1 << bit), LS1X_INTC_INTIEN(n));
+		irq_set_handler_locked(data, handle_edge_irq);
+	} else if (flow_type && IRQ_TYPE_LEVEL_MASK) {
+		ls1x_writel(ls1x_readl(LS1X_INTC_INTCLR(n))
+				| (1 << bit), LS1X_INTC_INTCLR(n));
+		if (flow_type & IRQ_TYPE_LEVEL_HIGH)
+			ls1x_writel(ls1x_readl(LS1X_INTC_INTPOL(n))
+					| (1 << bit), LS1X_INTC_INTPOL(n));
+		else if (flow_type & IRQ_TYPE_LEVEL_LOW)
+			ls1x_writel(ls1x_readl(LS1X_INTC_INTPOL(n))
+					& ~(1 << bit), LS1X_INTC_INTPOL(n));
+
+		ls1x_writel(ls1x_readl(LS1X_INTC_INTEDGE(n))
+				& ~(1 << bit), LS1X_INTC_INTEDGE(n));
+		ls1x_writel(ls1x_readl(LS1X_INTC_INTIEN(n))
+				| (1 << bit), LS1X_INTC_INTIEN(n));
+		irq_set_handler_locked(data, handle_level_irq);
+	}
+
+	return IRQ_SET_MASK_OK;
+}
+
 static struct irq_chip ls1x_irq_chip = {
 	.name		= "LS1X-INTC",
 	.irq_ack	= ls1x_irq_ack,
 	.irq_mask	= ls1x_irq_mask,
 	.irq_mask_ack	= ls1x_irq_mask_ack,
 	.irq_unmask	= ls1x_irq_unmask,
+	.irq_set_type	= ls1x_irq_set_type,
 };
 
 static void ls1x_irq_dispatch(int n)
@@ -138,6 +183,7 @@ static void __init ls1x_irq_init(int base)
 	setup_irq(INT1_IRQ, &cascade_irqaction);
 	setup_irq(INT2_IRQ, &cascade_irqaction);
 	setup_irq(INT3_IRQ, &cascade_irqaction);
+	setup_irq(INT4_IRQ, &cascade_irqaction);
 }
 
 void __init arch_init_irq(void)
Signature · 1 line
1.9.1

Ralf

#12 lore raw

PATCH v3 7/8 MIPS: Loongson-1A: Enable SPARSEMEN and HIGHMEM

In reply to Binbin Zhou
---
 arch/mips/include/asm/sparsemem.h   | 6 +++++-
 arch/mips/loongson32/Kconfig        | 1 +
 arch/mips/loongson32/common/setup.c | 3 ++-
 3 files changed, 8 insertions(+), 2 deletions(-)
arch/mips/include/asm/sparsemem.h +5 -1
index b1071c1..f73e671 100644
@@ -11,7 +11,11 @@
 #else
 # define SECTION_SIZE_BITS	28
 #endif
-#define MAX_PHYSMEM_BITS	48
+#ifdef CONFIG_64BIT
+# define MAX_PHYSMEM_BITS	48
+#else
+# define MAX_PHYSMEM_BITS	36
+#endif
 
 #endif /* CONFIG_SPARSEMEM */
 #endif /* _MIPS_SPARSEMEM_H */
arch/mips/loongson32/Kconfig +1 -0
index 741867c..5a96672 100644
@@ -11,6 +11,7 @@ config LOONGSON1_LS1A
 	bool "Loongson LS1A board"
 	select CEVT_R4K
 	select CSRC_R4K
+	select ARCH_SPARSEMEM_ENABLE
 	select SYS_HAS_CPU_LOONGSON1A
 	select DMA_NONCOHERENT
 	select BOOT_ELF32
arch/mips/loongson32/common/setup.c +2 -1
index 87d21c9..d764fae 100644
@@ -48,7 +48,8 @@ void __init plat_mem_setup(void)
 		.orig_video_points	= 16,
 	};
 #endif
-	add_memory_region(0x20000000, 0x30000000, BOOT_MEM_RESERVED);
+	if (highmemsize > 0)
+		add_memory_region(0x50000000, highmemsize << 20, BOOT_MEM_RAM);
 #endif
 }
 
Signature · 1 line
1.9.1
#13 lore raw

PATCH v3 8/8 MIPS: Loongson: Add a Loongson-1A default config file

In reply to Binbin Zhou
---
 arch/mips/configs/ls1a_defconfig | 132 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 132 insertions(+)
 create mode 100644 arch/mips/configs/ls1a_defconfig
arch/mips/configs/ls1a_defconfig new file +132 -0
new file mode 100644
index 0000000..a3069f8
@@ -0,0 +1,132 @@
+CONFIG_MACH_LOONGSON32=y
+CONFIG_ZONE_DMA=y
+CONFIG_PAGE_SIZE_16KB=y
+CONFIG_HIGHMEM=y
+CONFIG_HZ_1000=y
+CONFIG_PREEMPT_VOLUNTARY=y
+# CONFIG_SECCOMP is not set
+# CONFIG_LOCALVERSION_AUTO is not set
+CONFIG_SYSVIPC=y
+CONFIG_POSIX_MQUEUE=y
+CONFIG_HIGH_RES_TIMERS=y
+CONFIG_BSD_PROCESS_ACCT=y
+CONFIG_BSD_PROCESS_ACCT_V3=y
+CONFIG_IKCONFIG=y
+CONFIG_IKCONFIG_PROC=y
+CONFIG_LOG_BUF_SHIFT=16
+CONFIG_CGROUPS=y
+CONFIG_BLK_CGROUP=y
+CONFIG_CGROUP_SCHED=y
+CONFIG_CGROUP_FREEZER=y
+CONFIG_CPUSETS=y
+CONFIG_CGROUP_DEVICE=y
+CONFIG_EXPERT=y
+CONFIG_MODULES=y
+CONFIG_MODULE_UNLOAD=y
+CONFIG_MODVERSIONS=y
+# CONFIG_BLK_DEV_BSG is not set
+# CONFIG_IOSCHED_DEADLINE is not set
+# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
+# CONFIG_SUSPEND is not set
+CONFIG_NET=y
+CONFIG_PACKET=y
+CONFIG_UNIX=y
+CONFIG_INET=y
+CONFIG_IP_PNP=y
+CONFIG_IP_PNP_DHCP=y
+CONFIG_SYN_COOKIES=y
+# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
+# CONFIG_INET_XFRM_MODE_TUNNEL is not set
+# CONFIG_INET_XFRM_MODE_BEET is not set
+# CONFIG_INET_DIAG is not set
+# CONFIG_IPV6 is not set
+CONFIG_BRIDGE=y
+# CONFIG_BRIDGE_IGMP_SNOOPING is not set
+# CONFIG_WIRELESS is not set
+CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
+CONFIG_DEVTMPFS=y
+CONFIG_DEVTMPFS_MOUNT=y
+# CONFIG_STANDALONE is not set
+CONFIG_MTD=y
+CONFIG_MTD_CMDLINE_PARTS=y
+CONFIG_MTD_BLOCK=y
+CONFIG_NFTL=y
+CONFIG_NFTL_RW=y
+CONFIG_MTD_NAND=y
+CONFIG_MTD_SPI_NOR=y
+CONFIG_BLK_DEV_LOOP=y
+CONFIG_BLK_DEV_RAM=y
+# CONFIG_SCSI_PROC_FS is not set
+CONFIG_BLK_DEV_SD=y
+# CONFIG_SCSI_LOWLEVEL is not set
+CONFIG_ATA=y
+# CONFIG_SATA_PMP is not set
+CONFIG_SATA_AHCI_PLATFORM=y
+# CONFIG_ATA_SFF is not set
+CONFIG_NETDEVICES=y
+CONFIG_NETCONSOLE=y
+# CONFIG_NET_VENDOR_ARC is not set
+# CONFIG_NET_VENDOR_BROADCOM is not set
+# CONFIG_NET_VENDOR_INTEL is not set
+# CONFIG_NET_VENDOR_MARVELL is not set
+# CONFIG_NET_VENDOR_MICREL is not set
+# CONFIG_NET_VENDOR_NATSEMI is not set
+# CONFIG_NET_VENDOR_SAMSUNG is not set
+# CONFIG_NET_VENDOR_SEEQ is not set
+# CONFIG_NET_VENDOR_SMSC is not set
+CONFIG_STMMAC_ETH=y
+# CONFIG_NET_VENDOR_VIA is not set
+# CONFIG_NET_VENDOR_WIZNET is not set
+CONFIG_REALTEK_PHY=y
+# CONFIG_USB_NET_DRIVERS is not set
+# CONFIG_WLAN is not set
+# CONFIG_INPUT_MOUSEDEV is not set
+# CONFIG_INPUT_KEYBOARD is not set
+# CONFIG_INPUT_MOUSE is not set
+# CONFIG_SERIO is not set
+CONFIG_VT_HW_CONSOLE_BINDING=y
+CONFIG_LEGACY_PTY_COUNT=8
+# CONFIG_DEVKMEM is not set
+CONFIG_SERIAL_8250=y
+CONFIG_SERIAL_8250_CONSOLE=y
+# CONFIG_HW_RANDOM is not set
+CONFIG_I2C=y
+CONFIG_SPI=y
+# CONFIG_HWMON is not set
+CONFIG_WATCHDOG=y
+# CONFIG_VGA_CONSOLE is not set
+CONFIG_USB=y
+CONFIG_USB_MON=y
+CONFIG_USB_XHCI_HCD=m
+CONFIG_USB_EHCI_HCD=y
+CONFIG_USB_EHCI_HCD_PLATFORM=y
+CONFIG_USB_OHCI_HCD=y
+CONFIG_USB_OHCI_HCD_PLATFORM=y
+CONFIG_USB_STORAGE=m
+CONFIG_USB_GADGET=y
+CONFIG_RTC_CLASS=y
+CONFIG_RTC_DRV_PCF8563=y
+# CONFIG_IOMMU_SUPPORT is not set
+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_DNOTIFY is not set
+CONFIG_VFAT_FS=y
+CONFIG_PROC_KCORE=y
+CONFIG_TMPFS=y
+CONFIG_TMPFS_POSIX_ACL=y
+# CONFIG_MISC_FILESYSTEMS is not set
+# CONFIG_NETWORK_FILESYSTEMS is not set
+CONFIG_NLS_CODEPAGE_437=y
+CONFIG_NLS_ISO8859_1=y
+CONFIG_PRINTK_TIME=y
+# CONFIG_ENABLE_WARN_DEPRECATED is not set
+# CONFIG_ENABLE_MUST_CHECK is not set
+CONFIG_MAGIC_SYSRQ=y
+# CONFIG_SCHED_DEBUG is not set
+# CONFIG_FTRACE is not set
+CONFIG_XZ_DEC=y
Signature · 1 line
1.9.1