mips: loongson: lowlevel debug serial
Subsystems (6)
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH v7 2/7 mips: loongson: lowlevel initialize
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
PATCH v7 3/7 mips: loongson: lowlevel debug serial
In reply to a message not in the archiveFrom: 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
PATCH v7 4/7 mips: loongson: ls1c300 board support
In reply to a message not in the archiveFrom: Du Huanpeng <[email protected]>
- 64MiB SDRAM K9F1G08
- 4MiB spi flash
- ethernet DM9161CEP
- UART2 console
--- 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 | 38 ++++++++++++++++++ 6 files changed, 131 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 +38 -0
@@ -0,0 +1,38 @@ +/* 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 0x80200000 +#define CFG_SYS_INIT_SP_OFFSET 0x2000 + +/* SPL */ +#if defined(CONFIG_SPL_BUILD ) + +/* Serial SPL */ +#if 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 + +#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
PATCH v7 5/7 mips: loongson: add clk driver
In reply to a message not in the archiveFrom: 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 | 186 +++++++++++++++++++++++++++++ 3 files changed, 190 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 +186 -0
186 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH v7 6/7 mips: loongson: add watchdog driver
In reply to a message not in the archiveFrom: 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
@@ -214,6 +214,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
PATCH v7 7/7 mips: loongson: ls1c300 dts and bindings
In reply to a message not in the archiveFrom: 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 */ +/* +* 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__ */
include/dt-bindings/reset/ls1c300-reset.h new file +36 -0
@@ -0,0 +1,36 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* 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.43.0