diff --git a/arch/loongarch/boot/dts/Makefile b/arch/loongarch/boot/dts/Makefile index 09e1b775b..0c59047e8 100644 --- a/arch/loongarch/boot/dts/Makefile +++ b/arch/loongarch/boot/dts/Makefile @@ -4,7 +4,7 @@ ifdef CONFIG_DTB_MATCH_BY_BOARD_NAME dtb-$(CONFIG_LOONGSON_2K300) += ls2k300_mini_dp.dtb ls2k300_vanguard_pi.dtb ls2k300_gongkong_gbkpgk0.dtb \ - ls2k300_alientek.dtb + ls2k300_alientek.dtb ls2k300_99pi_wifi.dtb dtb-$(CONFIG_LOONGSON_2K1000) += ls2k1000_dp.dtb obj-y += $(patsubst %.dtb, %.dtb.o, $(dtb-y)) diff --git a/arch/loongarch/boot/dts/loongson-2k0300.dtsi b/arch/loongarch/boot/dts/loongson-2k0300.dtsi index 50fba799c..fd7e3db36 100644 --- a/arch/loongarch/boot/dts/loongson-2k0300.dtsi +++ b/arch/loongarch/boot/dts/loongson-2k0300.dtsi @@ -138,6 +138,10 @@ pinctrl-single,register-width = <32>; pinctrl-single,function-mask = <0x3>; + uart0_pins: pinmux_G40_G41_as_uart0 { + pinctrl-single,bits = <0x8 0x000f0000 0x000f0000>; + }; + uart1_pins: pinmux_G42_G43_as_uart1 { pinctrl-single,bits = <0x8 0x00f00000 0x00f00000>; }; @@ -206,8 +210,25 @@ pinctrl-single,bits = <0x14 0x00000a00 0x000000f00>; }; + spi0_pins: pinmux_G56_G59_as_spi0 { + pinctrl-single,bits = <0xc 0x00ff0000 0x00ff0000>; + }; + + qspi0_pins: pinmux_G56_G59_G69_G70_as_qspi0 { + pinctrl-single,bits = <0xc 0x00ff0000 0x00ff0000 + 0x10 0x00001400 0x00003c00>; + }; + + spi0_cs1: pinmux_G68_as_spi0_cs { + pinctrl-single,bits = <0x10 0x00000100 0x00000300>; + }; + spi1_pins: pinmux_G60_G63_as_spi1 { - pinctrl-single,bits = <0xc 0xff000000 0xff000000>; + pinctrl-single,bits = <0xc 0xff000000 0xff000000>; + }; + + spi1_cs_as_gpio: pinmux_G60_G62_as_spi1 { + pinctrl-single,bits = <0xc 0x3f000000 0x3f000000>; }; spi2_pins: pinmux_G64_G67_as_spi2 { @@ -354,20 +375,52 @@ }; }; - pwm0_pins: pinmux_G86_as_pwm0 { - pinctrl-single,bits = <0x14 0x00002000 0x00003000>; + pwm0_pins: pwm0-pins { + pwm0_mux_m0: pinmux_G64_as_pwm0 { + pinctrl-single,bits = <0x10 0x00000001 0x00000003>; + }; + pwm0_mux_m1: pinmux_G86_as_pwm0 { + pinctrl-single,bits = <0x14 0x00002000 0x00003000>; + }; + pwm0_mux_m2: pinmux_G102_as_pwm0 { + pinctrl-single,bits = <0x18 0x00003000 0x00003000>; + }; }; - pwm1_pins: pinmux_G87_as_pwm1 { - pinctrl-single,bits = <0x14 0x00008000 0x0000c000>; + pwm1_pins: pwm1-pins { + pwm1_mux_m0: pinmux_G65_as_pwm1 { + pinctrl-single,bits = <0x10 0x00000004 0x0000000c>; + }; + pwm1_mux_m1: pinmux_G87_as_pwm1 { + pinctrl-single,bits = <0x14 0x00008000 0x0000c000>; + }; + pwm1_mux_m2: pinmux_G103_as_pwm1 { + pinctrl-single,bits = <0x18 0x0000c000 0x0000c000>; + }; + }; + + pwm2_pins: pwm2-pins { + pwm2_mux_m0: pinmux_G66_as_pwm2 { + pinctrl-single,bits = <0x10 0x00000010 0x00000030>; + }; + pwm2_mux_m1: pinmux_G88_as_pwm2 { + pinctrl-single,bits = <0x14 0x00020000 0x00030000>; + }; + pwm2_mux_m2: pinmux_G104_as_pwm2 { + pinctrl-single,bits = <0x18 0x00030000 0x00030000>; + }; }; - pwm2_pins: pinmux_G88_as_pwm2 { - pinctrl-single,bits = <0x14 0x00020000 0x00030000>; - }; - - pwm3_pins: pinmux_G89_as_pwm3 { - pinctrl-single,bits = <0x14 0x00080000 0x000c0000>; + pwm3_pins: pwm3-pins { + pwm3_mux_m0: pinmux_G67_as_pwm3 { + pinctrl-single,bits = <0x10 0x00000040 0x000000c0>; + }; + pwm3_mux_m1: pinmux_G89_as_pwm3 { + pinctrl-single,bits = <0x14 0x00080000 0x000c0000>; + }; + pwm3_mux_m2: pinmux_G105_as_pwm3 { + pinctrl-single,bits = <0x18 0x000c0000 0x000c0000>; + }; }; tim1_ch1:pinmux_G81_as_tim1_ch1 { @@ -442,6 +495,9 @@ interrupt-parent = <&liointc0>; interrupts = <0 IRQ_TYPE_LEVEL_HIGH>; no-loopback-test; + pinctrl-0 = <&uart0_pins>; + pinctrl-names = "default"; + status = "disabled"; }; uart1: serial@0x16100400 { @@ -737,6 +793,8 @@ interrupt-parent = <&liointc1>; interrupts = <12 IRQ_TYPE_LEVEL_HIGH>; // 44 - 32 = 12 clock-frequency = <200000000>; + pinctrl-0 = <&spi0_pins>; + pinctrl-names = "default"; status = "disabled"; }; @@ -906,7 +964,7 @@ interrupt-parent = <&liointc0>; interrupts = <16 IRQ_TYPE_LEVEL_HIGH>; #pwm-cells = <2>; - pinctrl-0 = <&pwm0_pins>; + pinctrl-0 = <&pwm0_mux_m1>; pinctrl-names = "default"; clock-frequency = <200000000>; status = "disabled"; @@ -918,7 +976,7 @@ interrupt-parent = <&liointc0>; interrupts = <16 IRQ_TYPE_LEVEL_HIGH>; #pwm-cells = <2>; - pinctrl-0 = <&pwm1_pins>; + pinctrl-0 = <&pwm1_mux_m1>; pinctrl-names = "default"; clock-frequency = <200000000>; status = "disabled"; @@ -930,7 +988,7 @@ interrupt-parent = <&liointc0>; interrupts = <17 IRQ_TYPE_LEVEL_HIGH>; #pwm-cells = <2>; - pinctrl-0 = <&pwm2_pins>; + pinctrl-0 = <&pwm2_mux_m1>; pinctrl-names = "default"; clock-frequency = <200000000>; status = "disabled"; @@ -942,7 +1000,7 @@ interrupt-parent = <&liointc0>; interrupts = <17 IRQ_TYPE_LEVEL_HIGH>; #pwm-cells = <2>; - pinctrl-0 = <&pwm3_pins>; + pinctrl-0 = <&pwm3_mux_m1>; pinctrl-names = "default"; clock-frequency = <200000000>; status = "disabled"; @@ -1057,7 +1115,7 @@ compatible = "loongson,ls-pcm-generic-audio"; reg = <0 0x16114000 0 0x4000>; dmas = <&dma 0 0xaf - &dma 1 0xbf>; + &dma 1 0xbf>; dma-names = "i2s_record", "i2s_play"; dma-mask = <0xffffffff 0xffffffff>; status = "disabled"; diff --git a/arch/loongarch/boot/dts/ls2k300_99pi_wifi.dts b/arch/loongarch/boot/dts/ls2k300_99pi_wifi.dts new file mode 100644 index 000000000..c18776b7e --- /dev/null +++ b/arch/loongarch/boot/dts/ls2k300_99pi_wifi.dts @@ -0,0 +1,191 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2025 Loongson Technology Corporation Limited + */ + +/dts-v1/; + +#include "loongson-2k0300.dtsi" +#include "loongson_panel_param.dtsi" + +/ { + model = "LS2K300-99PI-WIFI"; + + chosen { + stdout-path = "serial0:115200n8"; + bootargs = "earlycon"; + }; + + /* not need memory node, we get memory info from boot params. */ + + leds { + compatible = "gpio-leds"; + + led1 { + label = "led1"; + gpios = <&gpio 83 GPIO_ACTIVE_LOW>; + linux,default-trigger = "heartbeat"; + default-state = "on"; + }; + }; + + reserved-memory { + #address-cells = <2>; + #size-cells = <2>; + ranges; + + linux,cma { + compatible = "shared-dma-pool"; + reusable; + size = <0 0x02000000>; + linux,cma-default; + }; + }; +}; + +&uart0 { + status = "okay"; +}; + +&uart1 { + status = "okay"; +}; + +&uart2 { + status = "okay"; +}; + +&gmac0 { + status = "okay"; + phy-handle = <&yt8511h0>; + mdio { + compatible = "snps,dwmac-mdio"; + #address-cells = <1>; + #size-cells = <0>; + + yt8511h0: ethernet-phy@0 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <0>; + motorcomm,led0_cfg = <0x40>; //千兆常亮 + motorcomm,led1_cfg = <0x30>; //百兆 十兆常亮 + motorcomm,led2_cfg = <0x2600>; //有数据时闪烁 + }; + }; +}; + +&i2c0 { + status = "okay"; +}; + +&i2c1 { + status = "okay"; +}; + +&i2c2 { + status = "disabled"; // 在 LCD 排线处 +}; + +&spi0 { + status = "okay"; + pinctrl-0 = <&qspi0_pins>; + pinctrl-names = "default"; + + spi-flash@0 { + compatible = "jedec,spi-nor"; + spi-max-frequency = <25000000>; + reg = <0>; + }; +}; + +&spi1 { + status = "okay"; + + spidev0@0 { + compatible = "rohm,dh2228fv"; + reg = <0>; + spi-max-frequency = <25000000>; + }; +}; + +&spi2 { + status = "okay"; // 与 PWM0-3 的 MUX0 冲突 + + spidev1@0 { + compatible = "rohm,dh2228fv"; + reg = <0>; + spi-max-frequency = <25000000>; + }; +}; + +&timers1 { + status = "okay"; + /delete-property/ dmas; + /delete-property/ dma-names; + pinctrl-0 = <&atim3n_pin_m1>; // LCD PWM 背光,备用 + pinctrl-names = "default"; + + pwm { + compatible = "loongson,ls2k-pwm-timer"; + #pwm-cells = <2>; + status = "okay"; + }; +}; + +&timers2 { + status = "okay"; + dmas = <&dma 2 0x400>, <&dma 3 0x400>; + dma-names = "ch3", "ch4"; + pinctrl-0 = <>im2_pin_m1>, <>im3_pin_m1>; + pinctrl-names = "default"; + + pwm { + compatible = "loongson,ls2k-pwm-timer"; + #pwm-cells = <2>; + status = "okay"; + }; +}; + +&pwm0 { + status = "disabled"; + pinctrl-0 = <&pwm0_mux_m0>; + pinctrl-names = "default"; +}; + +&pwm1 { + status = "disabled"; + pinctrl-0 = <&pwm1_mux_m0>; + pinctrl-names = "default"; +}; + +&pwm2 { + status = "disabled"; + pinctrl-0 = <&pwm2_mux_m0>; + pinctrl-names = "default"; +}; + +&pwm3 { + status = "disabled"; + pinctrl-0 = <&pwm3_mux_m0>; + pinctrl-names = "default"; +}; + +&can2 { + status = "okay"; +}; + +&can3 { + status = "okay"; +}; + +&adc { + status = "okay"; +}; + +&rtc0 { + status = "okay"; +}; + +&sdio1 { + cd-gpios = <&gpio 82 GPIO_ACTIVE_LOW>; + status = "okay"; +}; diff --git a/arch/loongarch/include/asm/mach/boot_param.h b/arch/loongarch/include/asm/mach/boot_param.h index 071fca3ce..23284b28d 100644 --- a/arch/loongarch/include/asm/mach/boot_param.h +++ b/arch/loongarch/include/asm/mach/boot_param.h @@ -115,6 +115,7 @@ extern u32 __dtb_ls2k300_mini_dp_begin[]; extern u32 __dtb_ls2k300_vanguard_pi_begin[]; extern u32 __dtb_ls2k300_gongkong_gbkpgk0_begin[]; extern u32 __dtb_ls2k300_alientek_begin[]; +extern u32 __dtb_ls2k300_99pi_wifi_begin[]; extern char __dtb_start[]; extern struct boot_params *efi_bp; extern struct loongson_board_info b_info; diff --git a/arch/loongarch/kernel/setup.c b/arch/loongarch/kernel/setup.c index 0fafe6783..e44658332 100644 --- a/arch/loongarch/kernel/setup.c +++ b/arch/loongarch/kernel/setup.c @@ -310,6 +310,7 @@ char *board_names[] = { "LS2K300-PAI", "LS2K300-GONGKONG-GBKPGK0", "LS2K300-ATK-DL2K0300B-V01", + "LS2K300-99PI-WIFI", #endif NULL }; @@ -330,6 +331,7 @@ void *fdts[] = { &__dtb_ls2k300_vanguard_pi_begin, &__dtb_ls2k300_gongkong_gbkpgk0_begin, &__dtb_ls2k300_alientek_begin, + &__dtb_ls2k300_99pi_wifi_begin, #endif NULL };