add loongson mips ls1c300 initial support
Subsystems (6)
v6 cover add loongson mips ls1c300 initial support
From: Du Huanpeng <[email protected]>
---
Changelog for v6:
- rebase to 2026.3.10, version [ba7bf918dafcd093ad733b07ba490baeb20cf5da]
- no more includes common.h
- use <linux/time.h> MSEC_PER_SEC instead of self made
- The board specific parts should be in the board MAINTAINER file
- rename arch/mips/mach-lsmips/ to ...mach-loongson/
- rename functions names from lsmips_* to loongson_*
- rename drivers/clk/lsmips/ to ...loongson/, rename clk driver name too
- move TEXT_BASE, SPL_TEXT_BASE from mach-xxx/Kconfig to ls1c300_defconfig
- rename hardware register name CONFIG_VALID to VALID (checkpatch error)
- change dt bindings header license to gpl-2.0 OR MIT (checkpatch warning)
- change dm-u-boot to bootph- in device tree
- remove guards(#if/#endif) from include/configs/ls1c300.h
- keep ARCH_LSMIPS macro, should I change it too ???
Changelog for v5:
- add detail commit message
- small fix in watchdog driver
Changelog for v4:
- rebase to [247aa5a191159ea7e03bf1918e22fbbb784cd410]
- fix rebase issues
- use spl without SPL_DM
- fix some more codingstyle
- fix some more typo
- add comments about writing sdram controler
- keep .noreoder and do not use delay slot
Changelog for v3:
- change cpu clock id from CLK_CPU to CLK_CPU_THROT
- migrate all APB dev's clock id to CLK_APB
- remove uarts' <reg-shift> property to use default value <0>
- move /clocks/acc node to /soc/acc
- call clk_request() before use a clk
- make get_tbclk() return 1/2 clock of cpu
- disable debug_uart by default
- add ops for cpu_throt_factor clk
- declare MSEC_PER_SEC for converting between sec and msec
- return a error code when the wdt clock is out of range
- minor format and codingstyle fixes
- rebase to [9859465bfe838bc8264d45e1a1bed847bba74bad]
Changelog for v2:
1. dtsi:
add status disabled for uart0 ~ uart11
remove bootargs from chosen
make serial0 alias for uart2
oscillator remove @0 unit-address
change uart2 address to kuseg
2. cleanup Kconfig and update defconfig
- make these options configurable, disabled by default:
CMD_DM
DM_ETH
DM_GPIO
DM_SPI
DM_SPI_FLASH
DM_RESET
PINCONF
PINCTRL
PINMUX
RESET_LSMIPS
- make these options configurable, enabled by default:
CLK
DISPLAY_CPUINFO
SYSRESET
ROM_EXCEPTION_VECTORS
- disabled:
CONFIG_ENV_IS_IN_SPI_FLASH
3. fix codingstyle drivers/watchdog/lsmips-wdt.c
- priv->base + offset
- add comment for default clock value
4. remove address base definition header
- remove arch/mips/mach-lsmips/ls1c300/ls1c300.h
- clean up files uses this header
5. spl and debug uart
- add comment for spl & debug uart pinmuxing
- cleanup unused registers base header
6. dtsi
- add "loongson,ls1c300-uart" to all uart node
7. board dts
- add memory node to board dts, start at 0x80000000, size 64MB
8. Kconfig
- make ROM_EXCEPTION_VECTORS user configureable
- enable ROM_EXCEPTION_VECTORS in defconfig
9.
- seperate sdram_init to sdram_init.S
- add macro helpers to do sdram, pll lowlevel init
10. dtsi
- move clock nodes to /clocks/xxx
11.
- define CONFIG_SKIP_LOWLEVEL_INIT to 1
12.
- remove option PINCTRL_LS1C300 from Kconfig
13.
- dram_init, use get_ram_size() to detect ram size.
14. clk driver
- create custom clock ops for PLL
- remove debug code
15.
- rebase to 59bffec43a657598b194b9eb30dc01eec06078c7
- remove CONFIG_SYS_MONITOR_BASE from include/configs/
Du Huanpeng (7):
mips: loongson: minimal initial SoC support
mips: loongson: lowlevel initialize
mips: loongson: lowlevel debug serial
mips: loongson: ls1c300 board support
mips: loongson: add clk driver
mips: loongson: add watchdog driver
mips: loongson: ls1c300 dts and bindings
MAINTAINERS | 9 + arch/mips/Kconfig | 11 ++ arch/mips/Makefile | 1 + arch/mips/dts/loongson32-ls1c300b.dtsi | 151 +++++++++++++++ arch/mips/dts/ls1c300-eval.dts | 30 +++ arch/mips/mach-loongson/Kconfig | 69 +++++++ arch/mips/mach-loongson/Makefile | 6 + arch/mips/mach-loongson/cpu.c | 19 ++ arch/mips/mach-loongson/include/mach/serial.h | 16 ++ arch/mips/mach-loongson/ls1c300/Makefile | 7 + arch/mips/mach-loongson/ls1c300/gpio.c | 66 +++++++ arch/mips/mach-loongson/ls1c300/init.c | 61 ++++++ .../mach-loongson/ls1c300/lowlevel_init.S | 134 +++++++++++++ arch/mips/mach-loongson/ls1c300/sdram.S | 95 ++++++++++ arch/mips/mach-loongson/ls1c300/serial.c | 104 ++++++++++ arch/mips/mach-loongson/spl.c | 46 +++++ board/loongson/ls1c300-eval/Kconfig | 12 ++ board/loongson/ls1c300-eval/MAINTAINERS | 7 + board/loongson/ls1c300-eval/Makefile | 3 + board/loongson/ls1c300-eval/board.c | 19 ++ configs/ls1c300_defconfig | 52 +++++ drivers/clk/Makefile | 1 + drivers/clk/loongson/Makefile | 3 + drivers/clk/loongson/clk-ls1c300.c | 179 ++++++++++++++++++ drivers/watchdog/Kconfig | 8 + drivers/watchdog/Makefile | 1 + drivers/watchdog/loongson_wdt.c | 127 +++++++++++++ include/configs/ls1c300.h | 36 ++++ include/dt-bindings/clock/ls1c300-clk.h | 18 ++ include/dt-bindings/reset/ls1c300-reset.h | 36 ++++ 30 files changed, 1327 insertions(+) create mode 100644 arch/mips/dts/loongson32-ls1c300b.dtsi create mode 100644 arch/mips/dts/ls1c300-eval.dts create mode 100644 arch/mips/mach-loongson/Kconfig create mode 100644 arch/mips/mach-loongson/Makefile create mode 100644 arch/mips/mach-loongson/cpu.c create mode 100644 arch/mips/mach-loongson/include/mach/serial.h create mode 100644 arch/mips/mach-loongson/ls1c300/Makefile create mode 100644 arch/mips/mach-loongson/ls1c300/gpio.c create mode 100644 arch/mips/mach-loongson/ls1c300/init.c create mode 100644 arch/mips/mach-loongson/ls1c300/lowlevel_init.S create mode 100644 arch/mips/mach-loongson/ls1c300/sdram.S create mode 100644 arch/mips/mach-loongson/ls1c300/serial.c create mode 100644 arch/mips/mach-loongson/spl.c create mode 100644 board/loongson/ls1c300-eval/Kconfig create mode 100644 board/loongson/ls1c300-eval/MAINTAINERS create mode 100644 board/loongson/ls1c300-eval/Makefile create mode 100644 board/loongson/ls1c300-eval/board.c create mode 100644 configs/ls1c300_defconfig create mode 100644 drivers/clk/loongson/Makefile create mode 100644 drivers/clk/loongson/clk-ls1c300.c create mode 100644 drivers/watchdog/loongson_wdt.c create mode 100644 include/configs/ls1c300.h create mode 100644 include/dt-bindings/clock/ls1c300-clk.h create mode 100644 include/dt-bindings/reset/ls1c300-reset.h
Signature · 1 line
2.43.0
PATCH v6 1/7 mips: loongson: minimal initial SoC support
From: Du Huanpeng <[email protected]>
Loongson 1C is a cost-effective SOC chip for industrial control and the Internet of Things. The Loongson 1C includes a floating-point processing unit, supports multiple types of memory, and supports high-capacity MLC NAND Flash. Loongson 1C provides developers with a wealth of peripheral interfaces and on-chip modules, including Camera controller, USB OTG and USB HOST interfaces, AC97/I2S controller, LCD controller, SPI interface, UART interface, etc., providing sufficient computing power and multi-application connectivity.
Some highlights of this SoC are:
- Single core LS232, MIPS32 instruction set compatible, main frequency 300MHZ
- 16KB data cache and 16KB instruction cache
- 64 bit float unit, hardware division
- 8/16 bit SDRAM controller, 45 ~ 133MHz
- 8/16 bit SRAM, NAND
- I2S/AC97, LCD, MAC, USB, OTG, SPI, I2C, PWM, CAN, SDIO, ADC
- 12 UARTs
Links:
https://www.loongson.cn/
introduce base support for the ls1c300 SoC.
- debug UART2
- serial console
- clock
- watchdog
- sysreset
- uart
--- MAINTAINERS | 9 ++++ arch/mips/Kconfig | 11 ++++ arch/mips/Makefile | 1 + arch/mips/mach-loongson/Kconfig | 69 ++++++++++++++++++++++++ arch/mips/mach-loongson/Makefile | 6 +++ arch/mips/mach-loongson/cpu.c | 19 +++++++ arch/mips/mach-loongson/ls1c300/Makefile | 7 +++ arch/mips/mach-loongson/ls1c300/init.c | 61 +++++++++++++++++++++ arch/mips/mach-loongson/spl.c | 46 ++++++++++++++++ 9 files changed, 229 insertions(+) create mode 100644 arch/mips/mach-loongson/Kconfig create mode 100644 arch/mips/mach-loongson/Makefile create mode 100644 arch/mips/mach-loongson/cpu.c create mode 100644 arch/mips/mach-loongson/ls1c300/Makefile create mode 100644 arch/mips/mach-loongson/ls1c300/init.c create mode 100644 arch/mips/mach-loongson/spl.c
MAINTAINERS +9 -0
@@ -1385,6 +1385,15 @@ F: drivers/net/cortina_ni.c F: drivers/net/cortina_ni.h F: drivers/net/phy/ca_phy.c +MIPS LOONGSON LS1C300 +M: Du Huanpeng <[email protected]> +S: Maintained +F: arch/mips/dts/loongson32-ls1c300b.dtsi +F: arch/mips/mach-loongson/ +F: drivers/clk/loongson/ +F: drivers/watchdog/loongson_wdt.c +F: include/dt-bindings/clock/ls1c300-clk.h + MIPS MEDIATEK M: Weijie Gao <[email protected]> R: GSS_MTK_Uboot_upstream <[email protected]>
arch/mips/Kconfig +11 -0
@@ -88,6 +88,16 @@ config ARCH_MTMIPS select SUPPORT_LITTLE_ENDIAN select SUPPORT_SPL +config ARCH_LSMIPS + bool "Support Loongson MIPS platforms" + select DM + select DM_SERIAL + select OF_CONTROL + select SUPPORTS_CPU_MIPS32_R1 + select SUPPORTS_CPU_MIPS32_R2 + select SUPPORTS_LITTLE_ENDIAN + select SUPPORT_SPL + config ARCH_JZ47XX bool "Support Ingenic JZ47xx" select SUPPORT_SPL
@@ -202,6 +212,7 @@ source "arch/mips/mach-bmips/Kconfig" source "arch/mips/mach-jz47xx/Kconfig" source "arch/mips/mach-pic32/Kconfig" source "arch/mips/mach-mtmips/Kconfig" +source "arch/mips/mach-loongson/Kconfig" source "arch/mips/mach-octeon/Kconfig" if MIPS
arch/mips/Makefile +1 -0
@@ -19,6 +19,7 @@ machine-$(CONFIG_ARCH_BMIPS) += bmips machine-$(CONFIG_ARCH_JZ47XX) += jz47xx machine-$(CONFIG_MACH_PIC32) += pic32 machine-$(CONFIG_ARCH_MTMIPS) += mtmips +machine-$(CONFIG_ARCH_LSMIPS) += loongson machine-$(CONFIG_ARCH_MSCC) += mscc machine-${CONFIG_ARCH_OCTEON} += octeon
arch/mips/mach-loongson/Kconfig new file +69 -0
69 lines not on this page · raw message
arch/mips/mach-loongson/Makefile new file +6 -0
@@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0+ + +obj-y += cpu.o +obj-$(CONFIG_SPL_BUILD) += spl.o + +obj-$(CONFIG_SOC_LS1C300) += ls1c300/
arch/mips/mach-loongson/cpu.c new file +19 -0
@@ -0,0 +1,19 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Copyright (C) 2018 Stefan Roese <[email protected]> +* Copyright (C) 2022-2026 Du Huanpeng <[email protected]> +*/ + +#include <init.h> +#include <malloc.h> +#include <linux/bitops.h> +#include <linux/io.h> +#include <linux/sizes.h> + +DECLARE_GLOBAL_DATA_PTR ; + +int dram_init (void ) +{ + gd->ram_size =get_ram_size ((void *)KSEG1 ,SZ_256M ) -CONFIG_TEXT_BASE %SZ_256M ; +return 0 ; +}
arch/mips/mach-loongson/ls1c300/Makefile new file +7 -0
@@ -0,0 +1,7 @@ +# SPDX-License-Identifier: GPL-2.0 + +obj-y += lowlevel_init.o +obj-y += sdram.o +obj-y += init.o +obj-y += gpio.o +obj-$(CONFIG_SPL_BUILD) += serial.o
arch/mips/mach-loongson/ls1c300/init.c new file +61 -0
61 lines not on this page · raw message
arch/mips/mach-loongson/spl.c new file +46 -0
46 lines not on this page · raw message
Signature · 1 line
2.43.0
Re: [PATCH v6 1/7] mips: loongson: minimal initial SoC support
Quoted 44 lines · On 3/11/26 09:41, [email protected] wrote:
From: Du Huanpeng <[email protected]>
Loongson 1C is a cost-effective SOC chip for industrial control and the Internet of Things. The Loongson 1C includes a floating-point processing unit, supports multiple types of memory, and supports high-capacity MLC NAND Flash. Loongson 1C provides developers with a wealth of peripheral interfaces and on-chip modules, including Camera controller, USB OTG and USB HOST interfaces, AC97/I2S controller, LCD controller, SPI interface, UART interface, etc., providing sufficient computing power and multi-application connectivity.
Some highlights of this SoC are:
- Single core LS232, MIPS32 instruction set compatible, main frequency 300MHZ
- 16KB data cache and 16KB instruction cache
- 64 bit float unit, hardware division
- 8/16 bit SDRAM controller, 45 ~ 133MHz
- 8/16 bit SRAM, NAND
- I2S/AC97, LCD, MAC, USB, OTG, SPI, I2C, PWM, CAN, SDIO, ADC
- 12 UARTsLinks:
https://www.loongson.cn/introduce base support for the ls1c300 SoC.
- debug UART2
- serial console
- clock
- watchdog
- sysreset
- uartSigned-off-by Du Huanpeng <[email protected]>--- MAINTAINERS | 9 ++++ arch/mips/Kconfig | 11 ++++ arch/mips/Makefile | 1 + arch/mips/mach-loongson/Kconfig | 69 ++++++++++++++++++++++++ arch/mips/mach-loongson/Makefile | 6 +++ arch/mips/mach-loongson/cpu.c | 19 +++++++ arch/mips/mach-loongson/ls1c300/Makefile | 7 +++ arch/mips/mach-loongson/ls1c300/init.c | 61 +++++++++++++++++++++ arch/mips/mach-loongson/spl.c | 46 ++++++++++++++++ 9 files changed, 229 insertions(+)
Quoted 7 lines
create mode 100644
arch/mips/mach-loongson/Kconfigcreate mode 100644arch/mips/mach-loongson/Makefilecreate mode 100644arch/mips/mach-loongson/cpu.ccreate mode 100644arch/mips/mach-loongson/ls1c300/Makefilecreate mode 100644arch/mips/mach-loongson/ls1c300/init.ccreate mode 100644arch/mips/mach-loongson/spl.c
Signature · 1 line
- Daniel
PATCH v6 2/7 mips: loongson: lowlevel initialize
In reply to [email protected]From: Du Huanpeng <[email protected]>
- pll
- spi controller
- sdram
--- .../mach-loongson/ls1c300/lowlevel_init.S | 134 ++++++++++++++++++ arch/mips/mach-loongson/ls1c300/sdram.S | 95 +++++++++++++ 2 files changed, 229 insertions(+) create mode 100644 arch/mips/mach-loongson/ls1c300/lowlevel_init.S create mode 100644 arch/mips/mach-loongson/ls1c300/sdram.S
arch/mips/mach-loongson/ls1c300/lowlevel_init.S new file +134 -0
@@ -0,0 +1,134 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2020 MediaTek Inc. + * + * Author: Gao Weijie <[email protected]> + * + * Copyright (C) 2020-2023 Du Huanpeng <[email protected]> + */ + +#include <config.h> +#include <asm-offsets.h> +#include <asm/cacheops.h> +#include <asm/regdef.h> +#include <asm/mipsregs.h> +#include <asm/addrspace.h> +#include <asm/asm.h> +#include <linux/sizes.h> + +/* PLL control register */ +#define NAND_BASE 0xbfe70000 +#define START_FREQ 0x8030 +#define CLK_DIV_PARAM 0x8034 +#define CPU_THROT 0xc010 + +/* START_FREQ */ +#define PLL_VALID 31 +#define Reserved_24 24 +#define FRAC_N 16 +#define M_PLL 8 +#define Reserved_4 4 +#define RST_TIME 2 +#define SDRAM_DIV 0 + #define SDRAM_DIV2 0 + #define SDRAM_DIV4 1 + #define SDRAM_DIV3 2 + +/* CLK_DIV_PARAM */ +#define PIX_DIV 24 +#define CAM_DIV 16 +#define CPU_DIV 8 +#define PIX_DIV_VALID 5 +#define PIX_SEL 4 +#define CAM_DIV_VALID 3 +#define CAM_SEL 2 +#define CPU_DIV_VALID 1 +#define CPU_SEL 0 + +/* Document: + * Freq_PLL = XIN *(M_PLL + FRAC_N)/4 + */ +#define XIN 24000000 +#define PLL_VALID_1 (1<<PLL_VALID) +#define PREP_M_PLL(Freq_PLL) (((Freq_PLL * 4) / XIN) << M_PLL) +#define PREP_SDRAM_DIV(div) (div<<SDRAM_DIV) +#define PREP_CPU_DIV(div1) ((0x80|div1)<<CPU_DIV | (div1&&div1)<<CPU_DIV_VALID) +#define PREP_PIX_DIV(div2) (div2<<PIX_DIV) +#define PREP_CAM_DIV(div3) (div3<<CAM_DIV) + +/* PLL @264MHz, CPU @132MHz, SDRAM @66MHz */ +#define CFG_START_FREQ (PLL_VALID_1 | PREP_M_PLL(264000000) | SDRAM_DIV2) +#define CFG_CLK_DIV_PARAM (PREP_CPU_DIV(2) | PREP_PIX_DIV(0x24) | PREP_CAM_DIV(0x24)) +#define CFG_CPU_THROT 15 + +/* SPI0 control register */ +#define SPI0_BASE 0xbfe80000 +#define SPCR 0 +#define SPSR 1 +#define TxFIFO 2 +#define RxFIFO 2 +#define SPER 3 +#define SFC_PARAM 4 + #define CLK_DIV 4 + #define DUAL_IO 3 + #define FAST_READ 2 + #define BURST_EN 1 + #define MEMORY_EN 0 +#define SFC_SOFTCS 5 +#define SFC_TIMING 6 + #define T_FAST 2 + #define T_CSH 0 + + .set noreorder +LEAF(ls1c300_pll_init) +#if !CONFIG_IS_ENABLED(SKIP_LOWLEVEL_INIT) + li t0, NAND_BASE + li t1, CFG_START_FREQ + li t2, CFG_CLK_DIV_PARAM + li t3, CFG_CPU_THROT + + sw t3, CPU_THROT (t0) + sw t2, CLK_DIV_PARAM (t0) + sw t1, START_FREQ (t0) + + ori t2, 1<<CPU_SEL + sw t2, CLK_DIV_PARAM (t0) +#endif + jr ra + nop +END(ls1c300_pll_init) + +LEAF(ls1c300_spi_init) +#if !CONFIG_IS_ENABLED(SKIP_LOWLEVEL_INIT) + li t0, SPI0_BASE + li t1, (1<<MEMORY_EN) | (1<<BURST_EN) | (1<<FAST_READ) | (1<<DUAL_IO) + sb t1, SFC_PARAM (t0) + li t2, (1<<T_FAST) | (1<<T_CSH) + sb t2, SFC_TIMING (t0) +#endif + jr ra + nop +END(ls1c300_spi_init) + +NESTED(lowlevel_init, 0, ra) + /* Save ra and do real lowlevel initialization */ + move s0, ra + /* Setup PLL @264MHz */ + PTR_LA t9, ls1c300_pll_init + jalr t9 + nop + + /* Setup SPI Dual IO@33MHz */ + PTR_LA t9, ls1c300_spi_init + jalr t9 + nop + + /* Setup external SDRAM @66MHz */ + PTR_LA t9, ls1c300_sdram_init + jalr t9 + nop + + move ra, s0 + jr ra + nop +END(lowlevel_init)
arch/mips/mach-loongson/ls1c300/sdram.S new file +95 -0
95 lines not on this page · raw message
Signature · 1 line
2.43.0
Re: [PATCH v6 2/7] mips: loongson: lowlevel initialize
Quoted 6 lines · On 3/11/26 09:41, [email protected] wrote:
From: Du Huanpeng <[email protected]>
- pll
- spi controller
- sdram
Quoted 8 lines
Signed-off-by Du Huanpeng <[email protected]>--- .../mach-loongson/ls1c300/lowlevel_init.S | 134 ++++++++++++++++++ arch/mips/mach-loongson/ls1c300/sdram.S | 95 +++++++++++++ 2 files changed, 229 insertions(+)create mode 100644
arch/mips/mach-loongson/ls1c300/lowlevel_init.Screate mode 100644arch/mips/mach-loongson/ls1c300/sdram.S
Signature · 1 line
- Daniel
PATCH v6 3/7 mips: loongson: lowlevel debug serial
In reply to [email protected]From: Du Huanpeng <[email protected]>
set pin to uart alternate function and enable uart for lowlevel debug, also future pinctrl driver can base on this code.
--- arch/mips/mach-loongson/include/mach/serial.h | 16 +++ arch/mips/mach-loongson/ls1c300/gpio.c | 66 +++++++++++ arch/mips/mach-loongson/ls1c300/serial.c | 104 ++++++++++++++++++ 3 files changed, 186 insertions(+) create mode 100644 arch/mips/mach-loongson/include/mach/serial.h create mode 100644 arch/mips/mach-loongson/ls1c300/gpio.c create mode 100644 arch/mips/mach-loongson/ls1c300/serial.c
arch/mips/mach-loongson/include/mach/serial.h new file +16 -0
@@ -0,0 +1,16 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (C) 2020 MediaTek Inc. +* +* Author: Gao Weijie <[email protected]> +* +* Copyright (C) 2022 Du Huanpeng <[email protected]> +*/ + +#ifndef __LSMIPS_SERIAL_H_ +#define __LSMIPS_SERIAL_H_ + +void loongson_spl_serial_init (void ); +int gpio_set_alternate (int gpio,int func); + +#endif /* __LSMIPS_SERIAL_H_ */
arch/mips/mach-loongson/ls1c300/gpio.c new file +66 -0
66 lines not on this page · raw message
arch/mips/mach-loongson/ls1c300/serial.c new file +104 -0
104 lines not on this page · raw message
Signature · 1 line
2.43.0
Re: [PATCH v6 3/7] mips: loongson: lowlevel debug serial
Quoted 6 lines · On 3/11/26 09:41, [email protected] wrote:
From: Du Huanpeng <[email protected]>
set pin to uart alternate function and enable uart for lowlevel debug, also future pinctrl driver can base on this code.
Signed-off-by Du Huanpeng <[email protected]>
Quoted 9 lines
--- arch/mips/mach-loongson/include/mach/serial.h | 16 +++ arch/mips/mach-loongson/ls1c300/gpio.c | 66 +++++++++++ arch/mips/mach-loongson/ls1c300/serial.c | 104 ++++++++++++++++++ 3 files changed, 186 insertions(+)create mode 100644
arch/mips/mach-loongson/include/mach/serial.hcreate mode 100644arch/mips/mach-loongson/ls1c300/gpio.ccreate mode 100644arch/mips/mach-loongson/ls1c300/serial.c
Signature · 1 line
- Daniel
PATCH v6 4/7 mips: loongson: ls1c300 board support
In reply to [email protected]From: Du Huanpeng <[email protected]>
- 64MiB SDRAM K9F1G08
- 4MiB spi flash
- ethernet DM9161CEP
- UART2 console
Links:
https://dfgh.top/loongson
--- board/loongson/ls1c300-eval/Kconfig | 12 ++++++ board/loongson/ls1c300-eval/MAINTAINERS | 7 ++++ board/loongson/ls1c300-eval/Makefile | 3 ++ board/loongson/ls1c300-eval/board.c | 19 +++++++++ configs/ls1c300_defconfig | 52 +++++++++++++++++++++++++ include/configs/ls1c300.h | 36 +++++++++++++++++ 6 files changed, 129 insertions(+) create mode 100644 board/loongson/ls1c300-eval/Kconfig create mode 100644 board/loongson/ls1c300-eval/MAINTAINERS create mode 100644 board/loongson/ls1c300-eval/Makefile create mode 100644 board/loongson/ls1c300-eval/board.c create mode 100644 configs/ls1c300_defconfig create mode 100644 include/configs/ls1c300.h
board/loongson/ls1c300-eval/Kconfig new file +12 -0
@@ -0,0 +1,12 @@ +if BOARD_LS1C300 + +config SYS_BOARD + default "ls1c300-eval" + +config SYS_VENDOR + default "loongson" + +config SYS_CONFIG_NAME + default "ls1c300" + +endif
board/loongson/ls1c300-eval/MAINTAINERS new file +7 -0
@@ -0,0 +1,7 @@ +LS1C300_EVAL BOARD +M: Du Huanpeng <[email protected]> +S: Maintained +F: board/loongson/ls1c300-eval/ +F: include/configs/ls1c300.h +F: configs/ls1c300_defconfig +F: arch/mips/dts/ls1c300-eval.dts
board/loongson/ls1c300-eval/Makefile new file +3 -0
@@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0 + +obj-y += board.o
board/loongson/ls1c300-eval/board.c new file +19 -0
@@ -0,0 +1,19 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (C) 2020-2026 Du Huanpeng <[email protected]> +*/ + +#include <mach/serial.h> + +#if defined(CONFIG_DEBUG_UART_BOARD_INIT ) + +#define UART2_RX 36 +#define UART2_TX 37 +#define AFUNC 2 + +void board_debug_uart_init (void ) +{ +gpio_set_alternate (UART2_TX ,AFUNC ); +gpio_set_alternate (UART2_RX ,AFUNC ); +} +#endif
configs/ls1c300_defconfig new file +52 -0
52 lines not on this page · raw message
include/configs/ls1c300.h new file +36 -0
@@ -0,0 +1,36 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (C) 2020 MediaTek Inc. +* +* Author: Gao Weijie <[email protected]> +* based on: include/configs/mt7628.h +* Copyright (C) 2022-2026 Du Huanpeng <[email protected]> +*/ + +#ifndef __CONFIG_LS1C300_H__ +#define __CONFIG_LS1C300_H__ + +#define CFG_SYS_SDRAM_BASE 0x80200000 +#define CFG_SYS_INIT_SP_OFFSET 0x2000 + +/* SPL */ +#if defined(CONFIG_SPL_BUILD ) + +/* Serial SPL */ +#define CFG_SYS_NS16550_CLK 66000000 +#define CFG_SYS_NS16550_COM1 0xbfe44000 +#define CFG_SYS_NS16550_COM2 0xbfe48000 +#define CFG_SYS_NS16550_COM3 0xbfe4c000 +#define CFG_SYS_NS16550_COM4 0xbfe4c400 +#define CFG_SYS_NS16550_COM5 0xbfe4c500 +#define CFG_SYS_NS16550_COM6 0xbfe4c600 + +#define CFG_MALLOC_F_ADDR 0x80100000/* FIXME: find a proper place */ +#define CFG_SYS_UBOOT_BASE 0xbd000000 + +#endif + +/* Serial common */ +#define CFG_SYS_BAUDRATE_TABLE { 9600, 19200, 38400, 57600, 115200, 230400, 460800, 921600 } + +#endif /* __CONFIG_LS1C300_H__ */
Signature · 1 line
2.43.0
Re: [PATCH v6 4/7] mips: loongson: ls1c300 board support
Quoted 18 lines · On 3/11/26 09:41, [email protected] wrote:
From: Du Huanpeng <[email protected]>
- 64MiB SDRAM K9F1G08
- 4MiB spi flash
- ethernet DM9161CEP
- UART2 consoleLinks:
https://dfgh.top/loongsonSigned-off-by Du Huanpeng <[email protected]>--- board/loongson/ls1c300-eval/Kconfig | 12 ++++++ board/loongson/ls1c300-eval/MAINTAINERS | 7 ++++ board/loongson/ls1c300-eval/Makefile | 3 ++ board/loongson/ls1c300-eval/board.c | 19 +++++++++ configs/ls1c300_defconfig | 52 +++++++++++++++++++++++++ include/configs/ls1c300.h | 36 +++++++++++++++++ 6 files changed, 129 insertions(+)
Quoted 7 lines
create mode 100644 board/loongson/ls1c300-eval/Kconfig create mode 100644 board/loongson/ls1c300-eval/MAINTAINERS create mode 100644 board/loongson/ls1c300-eval/Makefile create mode 100644
board/loongson/ls1c300-eval/board.ccreate mode 100644 configs/ls1c300_defconfig create mode 100644include/configs/ls1c300.h
Signature · 1 line
- Daniel
PATCH v6 5/7 mips: loongson: add clk driver
In reply to [email protected]From: Du Huanpeng <[email protected]>
clk driver loongson mips for embedded SoC ls1c300
--- drivers/clk/Makefile | 1 + drivers/clk/loongson/Makefile | 3 + drivers/clk/loongson/clk-ls1c300.c | 179 +++++++++++++++++++++++++++++ 3 files changed, 183 insertions(+) create mode 100644 drivers/clk/loongson/Makefile create mode 100644 drivers/clk/loongson/clk-ls1c300.c
drivers/clk/Makefile +1 -0
@@ -23,6 +23,7 @@ obj-y += ti/ obj-$(CONFIG_CLK_THEAD) += thead/ obj-$(CONFIG_$(PHASE_)CLK_INTEL) += intel/ obj-$(CONFIG_ARCH_ASPEED) += aspeed/ +obj-$(CONFIG_ARCH_LSMIPS) += loongson/ obj-$(CONFIG_ARCH_MEDIATEK) += mediatek/ obj-$(CONFIG_ARCH_MESON) += meson/ obj-$(CONFIG_ARCH_MTMIPS) += mtmips/
drivers/clk/loongson/Makefile new file +3 -0
@@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0 + +obj-$(CONFIG_SOC_LS1C300) += clk-ls1c300.o
drivers/clk/loongson/clk-ls1c300.c new file +179 -0
179 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH v6 6/7 mips: loongson: add watchdog driver
In reply to [email protected]From: Du Huanpeng <[email protected]>
supports watchdog in loongson mips embedded SoCs
--- drivers/watchdog/Kconfig | 8 ++ drivers/watchdog/Makefile | 1 + drivers/watchdog/loongson_wdt.c | 127 ++++++++++++++++++++++++++++++++ 3 files changed, 136 insertions(+) create mode 100644 drivers/watchdog/loongson_wdt.c
drivers/watchdog/Kconfig +8 -0
@@ -213,6 +213,14 @@ config SPL_WDT_GPIO help Support for external watchdog fed by toggling a gpio in SPL. +config WDT_LOONGSON + bool "Loongson MIPS watchdog timer support" + depends on WDT + help + Select this to enable watchdog timer for Loongson SoCs. + The watchdog timer is stopped when initialized. + It performs full SoC reset. + config WDT_MAX6370 bool "MAX6370 watchdog timer support" depends on WDT
drivers/watchdog/Makefile +1 -0
@@ -33,6 +33,7 @@ obj-$(CONFIG_WDT_DA9063) += da9063-wdt.o obj-$(CONFIG_WDT_DAVINCI) += davinci_wdt.o obj-$(CONFIG_WDT_FTWDT010) += ftwdt010_wdt.o obj-$(CONFIG_$(SPL_TPL_)WDT_GPIO) += gpio_wdt.o +obj-$(CONFIG_WDT_LOONGSON) += loongson_wdt.o obj-$(CONFIG_WDT_MAX6370) += max6370_wdt.o obj-$(CONFIG_WDT_MCF) += mcf_wdt.o obj-$(CONFIG_WDT_MESON_GXBB) += meson_gxbb_wdt.o
drivers/watchdog/loongson_wdt.c new file +127 -0
127 lines not on this page · raw message
Signature · 1 line
2.43.0
Re: [PATCH v6 6/7] mips: loongson: add watchdog driver
Quoted 4 lines · On 3/11/26 09:41, [email protected] wrote:
From: Du Huanpeng <[email protected]>
supports watchdog in loongson mips embedded SoCs
Quoted 8 lines
Signed-off-by Du Huanpeng <[email protected]>--- drivers/watchdog/Kconfig | 8 ++ drivers/watchdog/Makefile | 1 + drivers/watchdog/loongson_wdt.c | 127 ++++++++++++++++++++++++++++++++ 3 files changed, 136 insertions(+)create mode 100644
drivers/watchdog/loongson_wdt.c
Signature · 1 line
- Daniel
PATCH v6 7/7 mips: loongson: ls1c300 dts and bindings
In reply to [email protected]From: Du Huanpeng <[email protected]>
- ls1c300 dtsi
- ls1c300-eval board dts
- clk binding header
- reset binding header
--- arch/mips/dts/loongson32-ls1c300b.dtsi | 151 ++++++++++++++++++++++ arch/mips/dts/ls1c300-eval.dts | 30 +++++ include/dt-bindings/clock/ls1c300-clk.h | 18 +++ include/dt-bindings/reset/ls1c300-reset.h | 36 ++++++ 4 files changed, 235 insertions(+) create mode 100644 arch/mips/dts/loongson32-ls1c300b.dtsi create mode 100644 arch/mips/dts/ls1c300-eval.dts create mode 100644 include/dt-bindings/clock/ls1c300-clk.h create mode 100644 include/dt-bindings/reset/ls1c300-reset.h
arch/mips/dts/loongson32-ls1c300b.dtsi new file +151 -0
@@ -0,0 +1,151 @@ +// SPDX-License-Identifier: GPL-2.0 +#include <dt-bindings/clock/ls1c300-clk.h> +#include <dt-bindings/reset/ls1c300-reset.h> + +/ { + #address-cells = <1>; + #size-cells = <1>; + compatible = "loongson,ls1c300-soc"; + + cpus { + #address-cells = <1>; + #size-cells = <0>; + cpu@0 { + device_type = "cpu"; + reg = <0>; + compatible = "loongson,gs232", "mips,mips4Kc"; + clocks = <&acc CLK_CPU_THROT>; + }; + }; + + clocks { + #address-cells = <1>; + #size-cells = <1>; + bootph-all; + + + xtal: oscillator { + compatible = "fixed-clock"; + clock-frequency = <24000000>; + #clock-cells = <0>; + }; + }; + + soc { + #address-cells = <1>; + #size-cells = <1>; + compatible = "simple-bus"; + ranges; + + acc: clock-controller@1fe78030 { + compatible = "loongson,ls1c300-clk"; + clocks = <&xtal>; + #clock-cells = <1>; + reg = <0x1fe78030 0x8>, <0x1fe7c010 0x4>; + bootph-all; + }; + + uart0: serial@1fe40000 { + compatible = "loongson,ls1c300-uart", "ns16550a"; + clocks = <&acc CLK_APB>; + reg = <0x1fe40000 0x100>; + status = "disabled"; + }; + + uart1: serial@1fe44000 { + compatible = "loongson,ls1c300-uart", "ns16550a"; + clocks = <&acc CLK_APB>; + reg = <0x1fe44000 0x100>; + status = "disabled"; + }; + + uart2: serial@1fe48000 { + compatible = "loongson,ls1c300-uart", "ns16550a"; + clocks = <&acc CLK_APB>; + reg = <0x1fe48000 0x100>; + resets = <&shut_ctrl UART2_SHUT>; + reset-names = "uart2"; + status = "disabled"; + }; + + uart3: serial@1fe4c000 { + compatible = "loongson,ls1c300-uart", "ns16550a"; + clocks = <&acc CLK_APB>; + reg = <0x1fe4c000 0x100>; + status = "disabled"; + }; + + uart4: serial@1fe4c400 { + compatible = "loongson,ls1c300-uart", "ns16550a"; + clocks = <&acc CLK_APB>; + reg = <0x1fe4c400 0x100>; + status = "disabled"; + }; + + uart5: serial@1fe4c500 { + compatible = "loongson,ls1c300-uart", "ns16550a"; + clocks = <&acc CLK_APB>; + reg = <0x1fe4c500 0x100>; + status = "disabled"; + }; + + uart6: serial@1fe4c600 { + compatible = "loongson,ls1c300-uart", "ns16550a"; + clocks = <&acc CLK_APB>; + reg = <0x1fe4c600 0x100>; + status = "disabled"; + }; + + uart7: serial@1fe4c700 { + compatible = "loongson,ls1c300-uart", "ns16550a"; + clocks = <&acc CLK_APB>; + reg = <0x1fe4c700 0x100>; + status = "disabled"; + }; + + uart8: serial@1fe4c800 { + compatible = "loongson,ls1c300-uart", "ns16550a"; + clocks = <&acc CLK_APB>; + reg = <0x1fe4c800 0x100>; + status = "disabled"; + }; + + uart9: serial@1fe4c900 { + compatible = "loongson,ls1c300-uart", "ns16550a"; + clocks = <&acc CLK_APB>; + reg = <0x1fe4c900 0x100>; + status = "disabled"; + }; + + uart10: serial@1fe4ca00 { + compatible = "loongson,ls1c300-uart", "ns16550a"; + clocks = <&acc CLK_APB>; + reg = <0x1fe4ca00 0x100>; + status = "disabled"; + }; + + uart11: serial@1fe4cb00 { + compatible = "loongson,ls1c300-uart", "ns16550a"; + clocks = <&acc CLK_APB>; + reg = <0x1fe4cb00 0x100>; + status = "disabled"; + }; + + wdt: watchdog@1fe5c060 { + compatible = "loongson,ls1c300-wdt"; + clocks = <&acc CLK_APB>; + reg = <0x1fe5c060 0x10>; + }; + + reset-controller { + compatible = "wdt-reboot"; + wdt = <&wdt>; + }; + + shut_ctrl: reset-controller@1fd00420 { + compatible = "loongson,shut_ctrl"; + reg = <0x1fd00420 0x4>; + #reset-cells = <1>; + }; + }; +};
arch/mips/dts/ls1c300-eval.dts new file +30 -0
@@ -0,0 +1,30 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2022 Du Huanpeng <[email protected]> + */ + +/dts-v1/; + +#include "loongson32-ls1c300b.dtsi" + +/ { + compatible = "lsmips,ls1c300-soc"; + model = "ls1c300-eval"; + + aliases { + serial0 = &uart2; + }; + + memory@80000000 { + device_type = "memory"; + reg = <0x80000000 0x4000000>; + }; + + chosen { + stdout-path = "serial0:115200n8"; + }; +}; + +&uart2 { + status = "okay"; +};
include/dt-bindings/clock/ls1c300-clk.h new file +18 -0
@@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: GPL-2.0-only OR MIT */ +/* +* Copyright (C) 2022-2026 Du Huanpeng <[email protected]> +*/ + +#ifndef __DT_BINDINGS_LS1C300_CLK_H__ +#define __DT_BINDINGS_LS1C300_CLK_H__ + +#define CLK_XTAL 0 +#define CLK_PLL 1 +#define CLK_CPU 2 +#define CLK_APB 3 +#define CLK_CAMERA 4 +#define CLK_PIX 5 +#define CLK_AXIMUX 6 +#define CLK_CPU_THROT 7 + +#endif /* __DT_BINDINGS_LS1C300_CLK_H__ */
include/dt-bindings/reset/ls1c300-reset.h new file +36 -0
@@ -0,0 +1,36 @@ +/* SPDX-License-Identifier: GPL-2.0-only OR MIT */ +/* +* Copyright (C) 2022-2026 Du Huanpeng <[email protected]> +*/ + +#ifndef _DT_BINDINGS_LS1C300_RESET_H_ +#define _DT_BINDINGS_LS1C300_RESET_H_ + +#define ADC_SHUT 25 +#define SDIO_SHUT 24 +#define DMA2_SHUT 23 +#define DMA1_SHUT 22 +#define DMA0_SHUT 21 +#define SPI1_SHUT 20 +#define SPI0_SHUT 19 +#define I2C2_SHUT 18 +#define I2C1_SHUT 17 +#define I2C0_SHUT 16 +#define AC97_SHUT 15 +#define I2S_SHUT 14 +#define UART3_SHUT 13 +#define UART2_SHUT 12 +#define UART1_SHUT 11 +#define UART0_SHUT 10 +#define CAN1_SHUT 9 +#define CAN0_SHUT 8 +#define ECC_SHUT 7 +#define MAC_SHUT 6 +#define USBHOST_SHUT 5 +#define USBOTG_SHUT 4 +#define SDRAM_SHUT 3 +#define SRAM_SHUT 2 +#define CAM_SHUT 1 +#define LCD_SHUT 0 + +#endif /* _DT_BINDINGS_LS1C300_RESET_H_*/
Signature · 1 line
2.43.0
Re: [PATCH v6 7/7] mips: loongson: ls1c300 dts and bindings
Quoted 14 lines · On 3/11/26 09:41, [email protected] wrote:
From: Du Huanpeng <[email protected]>
- ls1c300 dtsi
- ls1c300-eval board dts
- clk binding header
- reset binding headerSigned-off-by Du Huanpeng <[email protected]>--- arch/mips/dts/loongson32-ls1c300b.dtsi | 151 ++++++++++++++++++++++ arch/mips/dts/ls1c300-eval.dts | 30 +++++ include/dt-bindings/clock/ls1c300-clk.h | 18 +++ include/dt-bindings/reset/ls1c300-reset.h | 36 ++++++ 4 files changed, 235 insertions(+)
Quoted 5 lines
create mode 100644
arch/mips/dts/loongson32-ls1c300b.dtsicreate mode 100644arch/mips/dts/ls1c300-eval.dtscreate mode 100644include/dt-bindings/clock/ls1c300-clk.hcreate mode 100644include/dt-bindings/reset/ls1c300-reset.h
Signature · 1 line
- Daniel