add loongson mips ls1c300 initial support
Subsystems (6)
v5 cover add loongson mips ls1c300 initial support
---
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 (6):
mips: initial build infrastructure for loongson SoCs
mips: ls1c300: add base support
mips: add a ls1c300 based board
mips: ls1c300: add clock driver
mips: ls1c300: add watchdog support
mips: ls1c300: add reset support based on watchdog driver
MAINTAINERS | 15 ++ arch/mips/Kconfig | 11 ++ arch/mips/Makefile | 1 + arch/mips/dts/Makefile | 1 + arch/mips/dts/loongson32-ls1c300b.dtsi | 150 +++++++++++++++ arch/mips/dts/ls1c300-eval.dts | 30 +++ arch/mips/mach-lsmips/Kconfig | 76 ++++++++ arch/mips/mach-lsmips/Makefile | 6 + arch/mips/mach-lsmips/cpu.c | 19 ++ arch/mips/mach-lsmips/include/mach/serial.h | 16 ++ arch/mips/mach-lsmips/ls1c300/Makefile | 7 + arch/mips/mach-lsmips/ls1c300/gpio.c | 66 +++++++ arch/mips/mach-lsmips/ls1c300/init.c | 62 ++++++ arch/mips/mach-lsmips/ls1c300/lowlevel_init.S | 135 +++++++++++++ arch/mips/mach-lsmips/ls1c300/sdram.S | 96 ++++++++++ arch/mips/mach-lsmips/ls1c300/serial.c | 109 +++++++++++ arch/mips/mach-lsmips/spl.c | 47 +++++ board/loongson/ls1c300-eval/Kconfig | 12 ++ board/loongson/ls1c300-eval/MAINTAINERS | 7 + board/loongson/ls1c300-eval/Makefile | 3 + board/loongson/ls1c300-eval/board.c | 20 ++ configs/ls1c300_defconfig | 53 ++++++ drivers/clk/Makefile | 1 + drivers/clk/lsmips/Makefile | 3 + drivers/clk/lsmips/clk-ls1c300.c | 180 ++++++++++++++++++ drivers/reset/Kconfig | 7 + drivers/reset/Makefile | 1 + drivers/reset/reset-lsmips.c | 118 ++++++++++++ drivers/watchdog/Kconfig | 8 + drivers/watchdog/Makefile | 1 + drivers/watchdog/lsmips_wdt.c | 128 +++++++++++++ include/configs/ls1c300.h | 34 ++++ include/dt-bindings/clock/ls1c300-clk.h | 18 ++ include/dt-bindings/reset/ls1c300-reset.h | 36 ++++ 34 files changed, 1477 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-lsmips/Kconfig create mode 100644 arch/mips/mach-lsmips/Makefile create mode 100644 arch/mips/mach-lsmips/cpu.c create mode 100644 arch/mips/mach-lsmips/include/mach/serial.h create mode 100644 arch/mips/mach-lsmips/ls1c300/Makefile create mode 100644 arch/mips/mach-lsmips/ls1c300/gpio.c create mode 100644 arch/mips/mach-lsmips/ls1c300/init.c create mode 100644 arch/mips/mach-lsmips/ls1c300/lowlevel_init.S create mode 100644 arch/mips/mach-lsmips/ls1c300/sdram.S create mode 100644 arch/mips/mach-lsmips/ls1c300/serial.c create mode 100644 arch/mips/mach-lsmips/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/lsmips/Makefile create mode 100644 drivers/clk/lsmips/clk-ls1c300.c create mode 100644 drivers/reset/reset-lsmips.c create mode 100644 drivers/watchdog/lsmips_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.34.1
PATCH v5 1/6 mips: initial build infrastructure for loongson SoCs
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
See Techinical Reference Manual for details:
https://www.loongson.cn/
https://github.com/hodcarrier/ls1c300_bsp
--- MAINTAINERS | 15 +++++ arch/mips/Kconfig | 11 ++++ arch/mips/Makefile | 1 + arch/mips/dts/Makefile | 1 + arch/mips/mach-lsmips/Kconfig | 76 ++++++++++++++++++++++++++ arch/mips/mach-lsmips/Makefile | 6 ++ arch/mips/mach-lsmips/ls1c300/Makefile | 7 +++ configs/ls1c300_defconfig | 53 ++++++++++++++++++ 8 files changed, 170 insertions(+) create mode 100644 arch/mips/mach-lsmips/Kconfig create mode 100644 arch/mips/mach-lsmips/Makefile create mode 100644 arch/mips/mach-lsmips/ls1c300/Makefile create mode 100644 configs/ls1c300_defconfig
MAINTAINERS +15 -0
@@ -1116,6 +1116,21 @@ 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/dts/ls1c300-eval.dts +F: arch/mips/mach-lsmips/ +F: board/loongson/ls1c300-eval/ +F: configs/ls1c300_defconfig +F: drivers/clk/lsmips/ +F: drivers/reset/reset-lsmips.c +F: drivers/watchdog/lsmips_wdt.c +F: include/configs/ls1c300.h +F: include/dt-bindings/clock/ls1c300-clk.h +F: include/dt-bindings/reset/ls1c300-reset.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 SUPPORTS_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
@@ -173,6 +183,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-lsmips/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) += lsmips machine-$(CONFIG_ARCH_MSCC) += mscc machine-${CONFIG_ARCH_OCTEON} += octeon
arch/mips/dts/Makefile +1 -0
@@ -21,6 +21,7 @@ dtb-$(CONFIG_BOARD_MT7621_NAND_RFB) += mediatek,mt7621-nand-rfb.dtb dtb-$(CONFIG_BOARD_MT7628_RFB) += mediatek,mt7628-rfb.dtb dtb-$(CONFIG_BOARD_GARDENA_SMART_GATEWAY_MT7688) += gardena-smart-gateway-mt7688.dtb dtb-$(CONFIG_BOARD_LINKIT_SMART_7688) += linkit-smart-7688.dtb +dtb-$(CONFIG_BOARD_LS1C300) += ls1c300-eval.dtb dtb-$(CONFIG_TARGET_OCTEON_EBB7304) += mrvl,octeon-ebb7304.dtb dtb-$(CONFIG_TARGET_OCTEON_NIC23) += mrvl,octeon-nic23.dtb dtb-$(CONFIG_BOARD_NETGEAR_CG3100D) += netgear,cg3100d.dtb
arch/mips/mach-lsmips/Kconfig new file +76 -0
76 lines not on this page · raw message
arch/mips/mach-lsmips/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-lsmips/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
configs/ls1c300_defconfig new file +53 -0
53 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH v5 1/6] mips: initial build infrastructure for loongson SoCs
Quoted 51 lines · Du Huanpeng
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 UARTsSee Techinical Reference Manual for details:
https://www.loongson.cn/
https://github.com/hodcarrier/ls1c300_bspSigned-off-by Du Huanpeng <[email protected]>--- MAINTAINERS | 15 +++++ arch/mips/Kconfig | 11 ++++ arch/mips/Makefile | 1 + arch/mips/dts/Makefile | 1 + arch/mips/mach-lsmips/Kconfig | 76 ++++++++++++++++++++++++++ arch/mips/mach-lsmips/Makefile | 6 ++ arch/mips/mach-lsmips/ls1c300/Makefile | 7 +++ configs/ls1c300_defconfig | 53 ++++++++++++++++++ 8 files changed, 170 insertions(+) create mode 100644 arch/mips/mach-lsmips/Kconfig create mode 100644 arch/mips/mach-lsmips/Makefile create mode 100644 arch/mips/mach-lsmips/ls1c300/Makefile create mode 100644 configs/ls1c300_defconfigMAINTAINERS +4
-0@@ -1116,6 +1116,21 @@ 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
MAINTAINERS F: drivers/net/cortina_ni.c · line 1132
Quoted 10 lines
MAINTAINERS +10
-0+F: arch/mips/dts/ls1c300-eval.dts +F: arch/mips/mach-lsmips/ +F: board/loongson/ls1c300-eval/ +F: configs/ls1c300_defconfig +F: drivers/clk/lsmips/ +F: drivers/reset/reset-lsmips.c +F: drivers/watchdog/lsmips_wdt.c +F: include/configs/ls1c300.h +F: include/dt-bindings/clock/ls1c300-clk.h +F: include/dt-bindings/reset/ls1c300-reset.h
The board specific parts should be in the board MAINTAINER file.
Quoted 26 lines
MAINTAINERS +25
-0+++ b/arch/mips/mach-lsmips/Kconfig@@ -0,0 +1,76 @@ +menu "Loongson MIPS platforms" + depends on ARCH_LSMIPS + +config SYS_MALLOC_F_LEN + default 0x1000 + +config SYS_SOC + default "ls1c300" if SOC_LS1C300 + +config SYS_DCACHE_SIZE + default 16384 + +config SYS_DCACHE_LINE_SIZE + default 32 + +config SYS_ICACHE_SIZE + default 16384 + +config SYS_ICACHE_LINE_SIZE + default 32 + +config TEXT_BASE + default 0xbfc00000 if !SPL + default 0x80200000 if SPL
MAINTAINERS line 34
Quoted 10 lines
MAINTAINERS +10
-0+ +config SPL_TEXT_BASE + default 0xbfc00000 + +config SPL_PAYLOAD + default "u-boot-lzma.img" if SPL_LZMA + +config BUILD_TARGET + default "u-boot-with-spl.bin" if SPL + default "u-boot.bin" if !SPL
As most of these are defined in common Kconfig files, the defaults for this arch should be there too.
Signature · 1 line
Tom
PATCH v5 2/6 mips: ls1c300: add base support
In reply to Du Huanpeng- pinmux setup functions for debug uart
- lowlevel initialization: sdram, pll, spi, debug uart
note that, this SoC have NO useable ram after reset, do not use nested call when doing lowlevel_init.
--- arch/mips/mach-lsmips/cpu.c | 19 +++ arch/mips/mach-lsmips/include/mach/serial.h | 16 +++ arch/mips/mach-lsmips/ls1c300/gpio.c | 66 +++++++++ arch/mips/mach-lsmips/ls1c300/init.c | 62 ++++++++ arch/mips/mach-lsmips/ls1c300/lowlevel_init.S | 135 ++++++++++++++++++ arch/mips/mach-lsmips/ls1c300/sdram.S | 96 +++++++++++++ arch/mips/mach-lsmips/ls1c300/serial.c | 109 ++++++++++++++ arch/mips/mach-lsmips/spl.c | 47 ++++++ include/configs/ls1c300.h | 34 +++++ 9 files changed, 584 insertions(+) create mode 100644 arch/mips/mach-lsmips/cpu.c create mode 100644 arch/mips/mach-lsmips/include/mach/serial.h create mode 100644 arch/mips/mach-lsmips/ls1c300/gpio.c create mode 100644 arch/mips/mach-lsmips/ls1c300/init.c create mode 100644 arch/mips/mach-lsmips/ls1c300/lowlevel_init.S create mode 100644 arch/mips/mach-lsmips/ls1c300/sdram.S create mode 100644 arch/mips/mach-lsmips/ls1c300/serial.c create mode 100644 arch/mips/mach-lsmips/spl.c create mode 100644 include/configs/ls1c300.h
arch/mips/mach-lsmips/cpu.c new file +19 -0
@@ -0,0 +1,19 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Copyright (C) 2018 Stefan Roese <[email protected]> +*/ + +#include <common.h> +#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 *)CFG_SYS_SDRAM_BASE ,SZ_256M ); +return 0 ; +}
arch/mips/mach-lsmips/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 lsmips_spl_serial_init (void ); +int gpio_set_alternate (int gpio,int func); + +#endif /* __LSMIPS_SERIAL_H_ */
arch/mips/mach-lsmips/ls1c300/gpio.c new file +66 -0
66 lines not on this page · raw message
arch/mips/mach-lsmips/ls1c300/init.c new file +62 -0
62 lines not on this page · raw message
arch/mips/mach-lsmips/ls1c300/lowlevel_init.S new file +135 -0
135 lines not on this page · raw message
arch/mips/mach-lsmips/ls1c300/sdram.S new file +96 -0
96 lines not on this page · raw message
arch/mips/mach-lsmips/ls1c300/serial.c new file +109 -0
109 lines not on this page · raw message
arch/mips/mach-lsmips/spl.c new file +47 -0
47 lines not on this page · raw message
include/configs/ls1c300.h new file +34 -0
@@ -0,0 +1,34 @@ +/* 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-2023 Du Huanpeng <[email protected]> +*/ + +#ifndef __CONFIG_LS1C300_H__ +#define __CONFIG_LS1C300_H__ + +#define CFG_SYS_SDRAM_BASE 0x80000000 +#define CFG_SYS_INIT_SP_OFFSET 0x2000 + +/* Serial SPL */ +#if defined(CONFIG_SPL_BUILD ) && defined(CONFIG_SPL_SERIAL ) +#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 +#endif + +/* Serial common */ +#define CFG_SYS_BAUDRATE_TABLE { 9600, 19200, 38400, 57600, 115200, 230400, 460800, 921600 } + +/* SPL */ +#define CFG_MALLOC_F_ADDR 0x80100000/* FIXME: find a proper place */ +#define CFG_SYS_UBOOT_BASE 0xbd000000 + +#endif /* __CONFIG_LS1C300_H__ */
Signature · 1 line
2.34.1
Re: [PATCH v5 2/6] mips: ls1c300: add base support
Quoted 2 lines · Du Huanpeng
- pinmux setup functions for debug uart
- lowlevel initialization: sdram, pll, spi, debug uart
[snip]
include/configs/ls1c300.h line 25
Quoted 10 lines
include/configs/ls1c300.h new file +10
-0+/* Serial SPL */ +#if defined(CONFIG_SPL_BUILD ) && defined(CONFIG_SPL_SERIAL ) +#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 +#endif
No guards around these please.
Signature · 1 line
Tom
PATCH v5 3/6 mips: add a ls1c300 based board
In reply to Du Huanpeng- devicetree for ls1c300 SoC and board
- setup debug uart pins
--- arch/mips/dts/loongson32-ls1c300b.dtsi | 150 ++++++++++++++++++++++++ arch/mips/dts/ls1c300-eval.dts | 30 +++++ board/loongson/ls1c300-eval/Kconfig | 12 ++ board/loongson/ls1c300-eval/MAINTAINERS | 7 ++ board/loongson/ls1c300-eval/Makefile | 3 + board/loongson/ls1c300-eval/board.c | 20 ++++ 6 files changed, 222 insertions(+) create mode 100644 arch/mips/dts/loongson32-ls1c300b.dtsi create mode 100644 arch/mips/dts/ls1c300-eval.dts 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
arch/mips/dts/loongson32-ls1c300b.dtsi new file +150 -0
@@ -0,0 +1,150 @@ +// 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>; + u-boot,dm-pre-reloc; + + 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>; + u-boot,dm-pre-reloc; + }; + + 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"; +};
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 +20 -0
@@ -0,0 +1,20 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (C) 2020-2022 Du Huanpeng <[email protected]> +*/ + +#include <common.h> +#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
Signature · 1 line
2.34.1
Re: [PATCH v5 3/6] mips: add a ls1c300 based board
Quoted 1 line · Du Huanpeng
- devicetree for ls1c300 SoC and board
What linux kernel release is this from?
[snip]
Review
Quoted 1 line
(quoted diff) +1
-0+ u-boot,dm-pre-reloc;
Here and elsewhere, these are "bootph-" now and also upstreamable.
[snip]
board/loongson/ls1c300-eval/MAINTAINERS line 2
Quoted 2 lines
board/loongson/ls1c300-eval/MAINTAINERS new file +2
-0+LS1C300_EVAL BOARD +M: Du Huanpeng<[email protected]>
Missing space.
Signature · 1 line
Tom
Re: [PATCH v5 3/6] mips: add a ls1c300 based board
Quoted 3 lines · Tom Rini
Quoted 1 line · Du Huanpeng
- devicetree for ls1c300 SoC and board
this devicetree was writen from scratch, I read the SoC's manual and devicetree-specification-v0.3.pdf, and write a Excel to generate it.
the v0.3 was lastest version when I wrote it.
https://www.devicetree.org/specifications/
the manual seens not available now from official site,
https://www.loongson.cn/product/list?id=2
here is my backup:
https://github.com/hodcarrier/ls1c300_bsp
Quoted 8 lines
What linux kernel release is this from?
[snip]
Review
Quoted 1 line
(quoted diff) +1
-0+ u-boot,dm-pre-reloc;Here and elsewhere, these are "bootph-" now and also upstreamable.
Quoted 8 lines
[snip]
board/loongson/ls1c300-eval/MAINTAINERS line 2
Quoted 2 lines
board/loongson/ls1c300-eval/MAINTAINERS new file +2
-0+LS1C300_EVAL BOARD +M: Du Huanpeng<[email protected]>Missing space.
Signature · 1 line
Tom
---
du huanpeng
Re: [PATCH v5 3/6] mips: add a ls1c300 based board
Quoted 4 lines · Du Huanpeng
Quoted 3 lines · Tom Rini
Quoted 1 line · Du Huanpeng
- devicetree for ls1c300 SoC and board
Quoted 9 lines
this devicetree was writen from scratch, I read the SoC's manual and devicetree-specification-v0.3.pdf, and write a Excel to generate it.
the v0.3 was lastest version when I wrote it.
https://www.devicetree.org/specifications/
the manual seens not available now from official site,
https://www.loongson.cn/product/list?id=2
here is my backup:
https://github.com/hodcarrier/ls1c300_bsp
The device tree in U-Boot needs to be kept in sync with the device tree in Linux. I haven't been following loongarch closely so I don't know the state of upstreaming the work there. We can be a little bit flexible when it comes to new platforms / chips, but we can't be "two different source trees".
Signature · 1 line
Tom
Re: [PATCH v5 3/6] mips: add a ls1c300 based board
Quoted 15 lines · Tom Rini
Quoted 4 lines · Du Huanpeng
Quoted 3 lines · Tom Rini
Quoted 1 line · Du Huanpeng
- devicetree for ls1c300 SoC and board
Quoted 9 lines
this devicetree was writen from scratch, I read the SoC's manual and devicetree-specification-v0.3.pdf, and write a Excel to generate it.
the v0.3 was lastest version when I wrote it.
https://www.devicetree.org/specifications/
the manual seens not available now from official site,
https://www.loongson.cn/product/list?id=2
here is my backup:
https://github.com/hodcarrier/ls1c300_bsp
Quoted 5 lines
The device tree in U-Boot needs to be kept in sync with the device tree in Linux. I haven't been following loongarch closely so I don't know the state of upstreaming the work there. We can be a little bit flexible when it comes to new platforms / chips, but we can't be "two different source trees".
thanks for this imformation, there is no devicetree for this SoC in current upstream kernel. I will try to sync this devicetree to Linux.
by the way, ls1c300 is MIPS chip, this patch is nothing about loongarch. loongarch is another architecture name. :)
Quoted 3 lines
Signature · 2 lines
-- Tom
---
Du Huanpeng
PATCH v5 4/6 mips: ls1c300: add clock driver
In reply to Du HuanpengI write a Excel sheet to calcate clock, technical manual also will be uploaded later [1].
[1] https://github.com/hodcarrier/ls1c300_bsp
--- drivers/clk/Makefile | 1 + drivers/clk/lsmips/Makefile | 3 + drivers/clk/lsmips/clk-ls1c300.c | 180 ++++++++++++++++++++++++ include/dt-bindings/clock/ls1c300-clk.h | 18 +++ 4 files changed, 202 insertions(+) create mode 100644 drivers/clk/lsmips/Makefile create mode 100644 drivers/clk/lsmips/clk-ls1c300.c create mode 100644 include/dt-bindings/clock/ls1c300-clk.h
drivers/clk/Makefile +1 -0
@@ -18,6 +18,7 @@ obj-y += tegra/ obj-y += ti/ obj-$(CONFIG_$(SPL_TPL_)CLK_INTEL) += intel/ obj-$(CONFIG_ARCH_ASPEED) += aspeed/ +obj-$(CONFIG_ARCH_LSMIPS) += lsmips/ obj-$(CONFIG_ARCH_MEDIATEK) += mediatek/ obj-$(CONFIG_ARCH_MESON) += meson/ obj-$(CONFIG_ARCH_MTMIPS) += mtmips/
drivers/clk/lsmips/Makefile new file +3 -0
@@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0 + +obj-$(CONFIG_SOC_LS1C300) += clk-ls1c300.o
drivers/clk/lsmips/clk-ls1c300.c new file +180 -0
180 lines not on this page · raw message
include/dt-bindings/clock/ls1c300-clk.h new file +18 -0
@@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (C) 2022 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__ */
Signature · 1 line
2.34.1
PATCH v5 5/6 mips: ls1c300: add watchdog support
In reply to Du Huanpeng- watchdog driver for ls1c300 with devicetree support
--- drivers/watchdog/Kconfig | 8 +++ drivers/watchdog/Makefile | 1 + drivers/watchdog/lsmips_wdt.c | 128 ++++++++++++++++++++++++++++++++++ 3 files changed, 137 insertions(+) create mode 100644 drivers/watchdog/lsmips_wdt.c
drivers/watchdog/Kconfig +8 -0
@@ -171,6 +171,14 @@ config WDT_GPIO doc/device-tree-bindings/watchdog/gpio-wdt.txt for information on how to describe the watchdog in device tree. +config WDT_LSMIPS + 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
@@ -30,6 +30,7 @@ obj-$(CONFIG_WDT_ORION) += orion_wdt.o obj-$(CONFIG_WDT_CDNS) += cdns_wdt.o obj-$(CONFIG_WDT_FTWDT010) += ftwdt010_wdt.o obj-$(CONFIG_WDT_GPIO) += gpio_wdt.o +obj-$(CONFIG_WDT_LSMIPS) += lsmips_wdt.o obj-$(CONFIG_WDT_MAX6370) += max6370_wdt.o obj-$(CONFIG_WDT_MESON_GXBB) += meson_gxbb_wdt.o obj-$(CONFIG_WDT_MPC8xxx) += mpc8xxx_wdt.o
drivers/watchdog/lsmips_wdt.c new file +128 -0
128 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH v5 6/6 mips: ls1c300: add reset support based on watchdog driver
In reply to Du Huanpeng--- drivers/reset/Kconfig | 7 ++ drivers/reset/Makefile | 1 + drivers/reset/reset-lsmips.c | 118 ++++++++++++++++++++++ include/dt-bindings/reset/ls1c300-reset.h | 36 +++++++ 4 files changed, 162 insertions(+) create mode 100644 drivers/reset/reset-lsmips.c create mode 100644 include/dt-bindings/reset/ls1c300-reset.h
drivers/reset/Kconfig +7 -0
@@ -121,6 +121,13 @@ config RESET_SOCFPGA help Support for reset controller on SoCFPGA platform. +config RESET_LSMIPS + bool "Reset controller driver for Loongson MIPS platform" + depends on DM_RESET && ARCH_LSMIPS + default y + help + Support for reset controller on Loongson MIPS platform. + config RESET_MEDIATEK bool "Reset controller driver for MediaTek SoCs" depends on DM_RESET && ARCH_MEDIATEK && CLK
drivers/reset/Makefile +1 -0
@@ -19,6 +19,7 @@ obj-$(CONFIG_RESET_AST2600) += reset-ast2600.o obj-$(CONFIG_RESET_ROCKCHIP) += reset-rockchip.o rst-rk3588.o obj-$(CONFIG_RESET_MESON) += reset-meson.o obj-$(CONFIG_RESET_SOCFPGA) += reset-socfpga.o +obj-$(CONFIG_RESET_LSMIPS) += reset-lsmips.o obj-$(CONFIG_RESET_MEDIATEK) += reset-mediatek.o obj-$(CONFIG_RESET_MTMIPS) += reset-mtmips.o obj-$(CONFIG_RESET_SUNXI) += reset-sunxi.o
drivers/reset/reset-lsmips.c new file +118 -0
118 lines not on this page · raw message
include/dt-bindings/reset/ls1c300-reset.h new file +36 -0
@@ -0,0 +1,36 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (C) 2022 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.34.1
Quoted 4 lines · Du Huanpeng
---
Changelog for v5:
- add detail commit message
- small fix in watchdog driver
Please run the whole series through checkpatch.pl and address the issues raised there, thanks.
Signature · 1 line
Tom