diff --git a/arch/loongarch/boot/dts/Makefile b/arch/loongarch/boot/dts/Makefile index 4a07360a1..d1363aa05 100644 --- a/arch/loongarch/boot/dts/Makefile +++ b/arch/loongarch/boot/dts/Makefile @@ -3,7 +3,8 @@ # dtb-y = loongson-2k0500-ref.dtb loongson-2k1000-ref.dtb loongson-2k2000-ref.dtb ifdef CONFIG_DTB_MATCH_BY_BOARD_NAME -dtb-$(CONFIG_LOONGSON_2K300) += ls2k300_mini_dp.dtb ls2k300_vanguard_pi.dtb +dtb-$(CONFIG_LOONGSON_2K300) += ls2k300_mini_dp.dtb ls2k300_vanguard_pi.dtb ls2k300_gongkong_gbkpgk0.dtb + obj-y += $(patsubst %.dtb, %.dtb.o, $(dtb-y)) else obj-$(CONFIG_BUILTIN_DTB) += $(addsuffix .dtb.o, $(CONFIG_BUILTIN_DTB_NAME)) diff --git a/arch/loongarch/boot/dts/loongson2k300.dtsi b/arch/loongarch/boot/dts/loongson2k300.dtsi index 62d4f1189..1a2ce983d 100644 --- a/arch/loongarch/boot/dts/loongson2k300.dtsi +++ b/arch/loongarch/boot/dts/loongson2k300.dtsi @@ -1,6 +1,10 @@ /dts-v1/; +#include #include #include +#include +#include +#include / { model = "loongson,generic"; @@ -184,10 +188,18 @@ pinctrl-single,bits = <0xc 0x00000f00 0x00000f00>; }; + i2c2_G82_G83_pins: pinmux_G82_G83_as_i2c2 { + pinctrl-single,bits = <0x14 0x000000a0 0x000000f0>; + }; + i2c3_pins: pinmux_G54_G55_as_i2c3 { pinctrl-single,bits = <0xc 0x0000f000 0x0000f000>; }; + i2c3_G84_G85_pins: pinmux_G84_G85_as_i2c3 { + pinctrl-single,bits = <0x14 0x00000a00 0x000000f00>; + }; + spi1_pins: pinmux_G60_G63_as_spi1 { pinctrl-single,bits = <0xc 0xff000000 0xff000000>; }; @@ -833,11 +845,9 @@ clock-frequency = <0 200000000>; bus-width = <8>; cap-mmc-highspeed; -#if CONFIG_LOONGSON_MMC_HIGH_PERFORMANCE - mmc-hs200-1_8v; -#endif no-sd; no-sdio; + non-removable; }; sdio1: sdio@0x16148000 { @@ -868,13 +878,13 @@ dma-mask = <0x0 0xffffffff>; }; - otg@0x16040000 { + otg: otg@0x16040000 { compatible = "loongson,loongson2-dwc2"; reg = <0 0x16040000 0 0x40000>; interrupt-parent = <&liointc1>; interrupts = <16 IRQ_TYPE_LEVEL_HIGH>; // 48 - 32 = 16 dma-mask = <0x0 0xffffffff>; - loongson,dwc2-fix = ; + loongson,dwc2-fix = ; //dr_mode = "peripheral"; /* Optional for that dr_mode = "host" or dr_mode = "peripheral" */ }; diff --git a/arch/loongarch/boot/dts/ls2k300_g2k03z0_core_v10.dtsi b/arch/loongarch/boot/dts/ls2k300_g2k03z0_core_v10.dtsi index f43bd695c..875511c33 100644 --- a/arch/loongarch/boot/dts/ls2k300_g2k03z0_core_v10.dtsi +++ b/arch/loongarch/boot/dts/ls2k300_g2k03z0_core_v10.dtsi @@ -1,8 +1,3 @@ -#include -#include -#include -#include - #include "loongson2k300.dtsi" / { @@ -63,4 +58,8 @@ motorcomm,led2_cfg = <0x2600>; //有数据时闪烁 }; }; -}; \ No newline at end of file +}; + +// &emmc { +// mmc-hs200-1_8v; +// }; diff --git a/arch/loongarch/boot/dts/ls2k300_gongkong_g2k03z2_core.dtsi b/arch/loongarch/boot/dts/ls2k300_gongkong_g2k03z2_core.dtsi new file mode 100644 index 000000000..de3e99f93 --- /dev/null +++ b/arch/loongarch/boot/dts/ls2k300_gongkong_g2k03z2_core.dtsi @@ -0,0 +1,53 @@ +#include "loongson2k300.dtsi" + +/ { + chosen { + stdout-path = "serial0:115200n8"; + bootargs = "earlycon"; + }; + + /* not need memory node, we get memory info from boot params. */ + //memory { + // name = "memory"; + // device_type = "memory"; + // reg = <0 0x00200000 0 0x0ee00000 + // 0 0x90000000 0 0x10000000>; + //}; + + 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"; +}; + +&spi0 { + status = "okay"; + + spi-flash@0 { + compatible = "jedec,spi-nor"; + spi-max-frequency = <25000000>; + reg = <0>; + }; +}; + +&i2c2 { + status = "okay"; + pinctrl-0 = <&i2c2_G82_G83_pins>; +}; + +&i2c3 { + status = "okay"; + pinctrl-0 = <&i2c3_G84_G85_pins>; +}; diff --git a/arch/loongarch/boot/dts/ls2k300_gongkong_gbkpgk0.dts b/arch/loongarch/boot/dts/ls2k300_gongkong_gbkpgk0.dts new file mode 100644 index 000000000..13ebe1585 --- /dev/null +++ b/arch/loongarch/boot/dts/ls2k300_gongkong_gbkpgk0.dts @@ -0,0 +1,345 @@ +#include "ls2k300_gongkong_g2k03z2_core.dtsi" +#include "loongson_panel_param.dtsi" + +/ { + model = "LS2K300-GONGKONG-GBKPGK0"; + + leds { + compatible = "gpio-leds"; + + sys_stat { + label = "sys_stat"; + gpios = <&io_expander_a 8 GPIO_ACTIVE_LOW>; + linux,default-trigger = "heartbeat"; + default-state = "on"; + }; + + led1 { + label = "led1"; + gpios = <&io_expander_a 5 GPIO_ACTIVE_LOW>; + default-state = "off"; + }; + + led2 { + label = "led2"; + gpios = <&io_expander_a 7 GPIO_ACTIVE_LOW>; + default-state = "off"; + }; + + led3 { + label = "led3"; + gpios = <&io_expander_a 6 GPIO_ACTIVE_LOW>; + default-state = "off"; + }; + }; + + lcd_backlight: backlight { + compatible = "gpio-backlight"; + gpios = <&gpio 89 GPIO_ACTIVE_HIGH>; + default-on; + }; + + panel: dvo-connector@0 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "panel-lvds", "auo,b101ean01"; + backlight = <&lcd_backlight>; + + /* lcd power on control gpio */ + // enable-gpios = <&pioA 3 GPIO_ACTIVE_HIGH>; + // power-supply = <&vdd_lcd>; +#if 0 // 4.3' LCD + width-mm = <223>; + height-mm = <125>; + label = "ATK-MD0430R-800x480"; + data-mapping = "jeida-24"; + + panel-timing { + clock-frequency = <27000000>; + hactive = <800>; + vactive = <480>; + hsync-len = <40>; + hfront-porch = <48>; + hback-porch = <40>; + vfront-porch = <13>; + vback-porch = <32>; + vsync-len = <1>; + de-active = <1>; + hsync-active = <0>; + vsync-active = <0>; + pixelclk-active = <0>; + }; +#else // 7' LCD + width-mm = <223>; + height-mm = <125>; + label = "ATK-MD0700R-1024x600"; + data-mapping = "jeida-24"; + + panel-timing { + clock-frequency = <51200000>; + hactive = <1024>; + vactive = <600>; + hsync-len = <20>; + hfront-porch = <160>; + hback-porch = <140>; + vfront-porch = <12>; + vback-porch = <20>; + vsync-len = <3>; + de-active = <1>; + hsync-active = <0>; + vsync-active = <0>; + pixelclk-active = <0>; + }; +#endif + port@0 { + reg = <0>; + + #address-cells = <1>; + #size-cells = <0>; + + dvo_connector_in: endpoint@0 { + reg = <0>; + remote-endpoint = <&dc_out_rgb0>; + }; + }; + }; + + vccio_codec: 3_3V{ + compatible = "regulator-fixed"; + regulator-name = "VCC_IO"; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + regulator-always-on; + }; + + // 虽然这个时钟在从模式下没用,但 es8388 驱动必须指定这个时钟 + es8388_clk: es8388-clock { + compatible = "fixed-clock"; + clock-frequency = <12288000>; + #clock-cells = <1>; + }; +}; + +&dc { + status = "ok"; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + dc_out_rgb0: endpoint { + remote-endpoint = <&dvo_connector_in>; + }; + }; + }; +}; + +&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>; //有数据时闪烁 + }; + }; +}; + +&gmac1 { + status = "okay"; + phy-handle = <&yt8511h1>; + mdio { + compatible = "snps,dwmac-mdio"; + #address-cells = <1>; + #size-cells = <0>; + + yt8511h1: ethernet-phy@1 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <0>; + motorcomm,led0_cfg = <0x40>; //千兆常亮 + motorcomm,led1_cfg = <0x30>; //百兆 十兆常亮 + motorcomm,led2_cfg = <0x2600>; //有数据时闪烁 + }; + }; +}; + +&i2c2 { + //i2c-speed = <400000>; + + codec: es8388@11{ + compatible = "everest,es8388"; + reg = <0x11>; + AVDD-supply = <&vccio_codec>; + DVDD-supply = <&vccio_codec>; + HPVDD-supply = <&vccio_codec>; + PVDD-supply = <&vccio_codec>; + clocks = <&es8388_clk 0>; + }; + + dido_A000: xl9555@20 { + compatible = "nxp,pca9555"; + reg = <0x20>; + gpio-controller; + #gpio-cells = <2>; + interrupt-parent = <&io_expander_a>; + interrupts = <10 IRQ_TYPE_EDGE_FALLING>; + interrupt-controller; + #interrupt-cells = <2>; + }; + + dido_A001: xl9555@21 { + compatible = "nxp,pca9555"; + reg = <0x21>; + gpio-controller; + #gpio-cells = <2>; + interrupt-parent = <&io_expander_a>; + interrupts = <11 IRQ_TYPE_EDGE_FALLING>; + interrupt-controller; + #interrupt-cells = <2>; + }; + + dido_A010: xl9555@22 { + compatible = "nxp,pca9555"; + reg = <0x22>; + gpio-controller; + #gpio-cells = <2>; + interrupt-parent = <&io_expander_a>; + interrupts = <12 IRQ_TYPE_EDGE_FALLING>; + interrupt-controller; + #interrupt-cells = <2>; + }; + + rtc_ds1307@68 { + compatible = "dallas,ds1307"; + reg = <0x68>; + }; +}; + +&i2c3 { + i2c-speed = <400000>; + + touchpad: gt9147@14 { + compatible = "goodix,gt9147"; + reg = <0x14>; + interrupt-parent = <&io_expander_a>; + interrupts = <2 IRQ_TYPE_EDGE_FALLING>; + irq-gpios = <&io_expander_a 2 GPIO_ACTIVE_LOW>; + reset-gpios = <&io_expander_a 3 GPIO_ACTIVE_LOW>; + }; + + io_expander_b: xl9555@26 { + compatible = "nxp,pca9555"; + reg = <0x26>; + gpio-controller; + #gpio-cells = <2>; + // 2K300 GPIO 支持中断控制 + // GPIO 中断号为 vhwirq-base + pinnum (195 = 128 + 67) + interrupt-parent = <&gpio>; + interrupts = <195 IRQ_TYPE_EDGE_FALLING>; + interrupt-controller; + #interrupt-cells = <2>; + }; + + io_expander_a: xl9555@27 { + compatible = "nxp,pca9555"; + reg = <0x27>; + gpio-controller; + #gpio-cells = <2>; + // 2K300 GPIO 支持中断控制 + // GPIO 中断号为 vhwirq-base + pinnum (194 = 128 + 66) + interrupt-parent = <&gpio>; + interrupts = <194 IRQ_TYPE_EDGE_FALLING>; + interrupt-controller; + #interrupt-cells = <2>; + }; + + dido_B000: xl9555@20 { + compatible = "nxp,pca9555"; + reg = <0x20>; + gpio-controller; + #gpio-cells = <2>; + interrupt-parent = <&io_expander_a>; + interrupts = <15 IRQ_TYPE_EDGE_FALLING>; + interrupt-controller; + #interrupt-cells = <2>; + }; + + dido_B001: xl9555@21 { + compatible = "nxp,pca9555"; + reg = <0x21>; + gpio-controller; + #gpio-cells = <2>; + interrupt-parent = <&io_expander_a>; + interrupts = <14 IRQ_TYPE_EDGE_FALLING>; + interrupt-controller; + #interrupt-cells = <2>; + }; + + dido_B010: xl9555@22 { + compatible = "nxp,pca9555"; + reg = <0x22>; + gpio-controller; + #gpio-cells = <2>; + interrupt-parent = <&io_expander_a>; + interrupts = <13 IRQ_TYPE_EDGE_FALLING>; + interrupt-controller; + #interrupt-cells = <2>; + }; +}; + +&uart1 { + status = "okay"; +}; + +&uart5 { + status = "okay"; +}; + +&can2 { + status = "ok"; + ls,canfd-stb-gpio = <&gpio 60 GPIO_ACTIVE_HIGH>; +}; + +&can3 { + status = "ok"; + ls,canfd-stb-gpio = <&gpio 60 GPIO_ACTIVE_HIGH>; +}; + +&adc { + status = "okay"; +}; + +&sdio1 { + pinctrl-0 = <&sdio1_pins>; + pinctrl-names = "default"; + cap-sd-highspeed; + cap-mmc-highspeed; + bus-width = <4>; + //cd-gpios = <&io_expander_a 4 GPIO_ACTIVE_LOW>; + status = "okay"; +}; + +&i2s { + status = "okay"; +}; + +&audio { + status = "okay"; +}; + +&sound { + status = "okay"; + loongson,audio-codec = <&codec>; + // Easy Compatible for asound.state Configure + loongson,sound-card-name = "ES8388"; +}; + diff --git a/arch/loongarch/boot/dts/ls2k300_mini_dp.dts b/arch/loongarch/boot/dts/ls2k300_mini_dp.dts index 0442e7676..41894b1d7 100644 --- a/arch/loongarch/boot/dts/ls2k300_mini_dp.dts +++ b/arch/loongarch/boot/dts/ls2k300_mini_dp.dts @@ -1,7 +1,5 @@ #include "ls2k300_g2k03z0_core_v10.dtsi" #include "loongson_panel_param.dtsi" -#include -#include / { model = "LS2K300-MINI-DP"; @@ -225,4 +223,4 @@ bus-width = <4>; cd-gpios = <&gpio 81 GPIO_ACTIVE_LOW>; status = "okay"; -}; \ No newline at end of file +}; diff --git a/arch/loongarch/boot/dts/ls2k300_vanguard_pi.dts b/arch/loongarch/boot/dts/ls2k300_vanguard_pi.dts index 52d939b34..50f290c92 100644 --- a/arch/loongarch/boot/dts/ls2k300_vanguard_pi.dts +++ b/arch/loongarch/boot/dts/ls2k300_vanguard_pi.dts @@ -1,8 +1,3 @@ -#include -#include -#include -#include - #include "ls2k300_vanguard_pi_common.dtsi" &uart2 { @@ -77,4 +72,4 @@ &pwm1 { status = "okay"; -}; \ No newline at end of file +}; diff --git a/arch/loongarch/boot/dts/ls2k300_vanguard_pi_common.dtsi b/arch/loongarch/boot/dts/ls2k300_vanguard_pi_common.dtsi index 229974c47..dbf0906f7 100644 --- a/arch/loongarch/boot/dts/ls2k300_vanguard_pi_common.dtsi +++ b/arch/loongarch/boot/dts/ls2k300_vanguard_pi_common.dtsi @@ -1,8 +1,3 @@ -#include -#include -#include -#include - #include "loongson2k300.dtsi" #include "loongson_panel_param.dtsi" diff --git a/arch/loongarch/boot/dts/ls2k300_vanguard_pi_func2.dts b/arch/loongarch/boot/dts/ls2k300_vanguard_pi_func2.dts index 352fec0d9..c21959614 100644 --- a/arch/loongarch/boot/dts/ls2k300_vanguard_pi_func2.dts +++ b/arch/loongarch/boot/dts/ls2k300_vanguard_pi_func2.dts @@ -1,8 +1,3 @@ -#include -#include -#include -#include - #include "ls2k300_vanguard_pi_common.dtsi" &uart2 { @@ -55,4 +50,4 @@ &can3 { status = "okay"; -}; \ No newline at end of file +}; diff --git a/arch/loongarch/boot/dts/ls2k300_vanguard_pi_pihat.dts b/arch/loongarch/boot/dts/ls2k300_vanguard_pi_pihat.dts index 7a84b8341..0cdc33ee0 100644 --- a/arch/loongarch/boot/dts/ls2k300_vanguard_pi_pihat.dts +++ b/arch/loongarch/boot/dts/ls2k300_vanguard_pi_pihat.dts @@ -1,8 +1,3 @@ -#include -#include -#include -#include - #include "ls2k300_vanguard_pi_common.dtsi" / { @@ -71,4 +66,4 @@ &can3 { status = "disabled"; -}; \ No newline at end of file +}; diff --git a/arch/loongarch/configs/loongson_2k300_defconfig b/arch/loongarch/configs/loongson_2k300_defconfig index 0b717bccf..c64f8d8a2 100644 --- a/arch/loongarch/configs/loongson_2k300_defconfig +++ b/arch/loongarch/configs/loongson_2k300_defconfig @@ -539,6 +539,8 @@ CONFIG_PINCTRL_SINGLE=y CONFIG_GPIO_SYSFS=y CONFIG_GPIO_LOONGSON_IRQCHIP=y CONFIG_GPIO_LOONGSON_64BIT=y +CONFIG_GPIO_PCA953X=y +CONFIG_GPIO_PCA953X_IRQ=y CONFIG_POWER_RESET=y CONFIG_POWER_RESET_RESTART=y CONFIG_POWER_RESET_SYSCON=y @@ -692,6 +694,7 @@ CONFIG_LEDS_GPIO=y CONFIG_LEDS_PWM=y CONFIG_LEDS_TRIGGER_HEARTBEAT=y CONFIG_RTC_CLASS=y +CONFIG_RTC_DRV_DS1307=y CONFIG_RTC_DRV_EFI=y CONFIG_RTC_DRV_LOONGSON=y CONFIG_DMADEVICES=y diff --git a/arch/loongarch/include/asm/mach/boot_param.h b/arch/loongarch/include/asm/mach/boot_param.h index 5739625cb..9dd7170fb 100644 --- a/arch/loongarch/include/asm/mach/boot_param.h +++ b/arch/loongarch/include/asm/mach/boot_param.h @@ -113,6 +113,7 @@ extern u32 __dtb_ls2k1000_dp_i2s_begin[]; extern u32 __dtb_ls2p500_gbkpjm0_v10_begin[]; extern u32 __dtb_ls2k300_mini_dp_begin[]; extern u32 __dtb_ls2k300_vanguard_pi_begin[]; +extern u32 __dtb_ls2k300_gongkong_gbkpgk0_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 e21858566..32a242e54 100644 --- a/arch/loongarch/kernel/setup.c +++ b/arch/loongarch/kernel/setup.c @@ -345,6 +345,8 @@ static void* __init get_fdt_by_board_name(void) fdt = &__dtb_ls2k300_mini_dp_begin; else if (!strncmp(board_name, "LS2K300-PAI", 11)) fdt = &__dtb_ls2k300_vanguard_pi_begin; + else if (!strncmp(board_name, "LS2K300-GONGKONG-GBKPGK0", 24)) + fdt = &__dtb_ls2k300_gongkong_gbkpgk0_begin; else fdt = &__dtb_ls2k300_mini_dp_begin; #endif diff --git a/drivers/mmc/host/ls2kmci.c b/drivers/mmc/host/ls2kmci.c index fc4dd5e16..66d381a3b 100644 --- a/drivers/mmc/host/ls2kmci.c +++ b/drivers/mmc/host/ls2kmci.c @@ -1033,6 +1033,10 @@ probe_free_host: static void ls2k_mci_shutdown(struct platform_device *pdev) { struct mmc_host *mmc = platform_get_drvdata(pdev); + struct ls2k_mci_host *host = mmc_priv(mmc); + + if (mmc->caps & MMC_CAP_NONREMOVABLE) + return; if (mmc->card) mmc->card->state &= ~1; @@ -1045,6 +1049,9 @@ static void ls2k_mci_remove(struct platform_device *pdev) struct mmc_host *mmc = platform_get_drvdata(pdev); struct ls2k_mci_host *host = mmc_priv(mmc); + if (mmc->caps & MMC_CAP_NONREMOVABLE) + return; + ls2k_mci_shutdown(pdev);