diff mbox series

[v3,5/8] rockchip: puma: reorganize devicetrees to actually work and match upstream

Message ID 20200605100643.670921-6-heiko@sntech.de
State New
Headers show
Series revive Theobroma-Systems puma board | expand

Commit Message

Heiko Stübner June 5, 2020, 10:06 a.m. UTC
From: Heiko Stuebner <heiko.stuebner at theobroma-systems.com>

So far the puma dts files only just included the main puma dtsi without
handling the actual baseboard and rk3399-puma.dtsi was very much
detached from the variant in the mainline Linux kernel.

Recent changes resulted in a strange situation with nonworking puma boards.

Commit ab800e5a6f28 ("arm: dts: rockchip: puma: move U-Boot specific bits to u-boot.dtsi")
moved the sdram include from rk3399-puma-ddrX.dts to new files
rk3399-puma-ddrx-u-boot.dtsi which were never included anywhere though.

Commit 167efc2c7a46 ("arm64: dts: rk3399: Sync v5.7-rc1 from Linux")
replaced the rk3399-puma.dtsi nearly completely, but in the kernel
it definitly depends on a baseboard dts to actually enable peripherals
like sd-slot, uarts, etc.

So to untagle this and bring the whole thing more in line with mainline
Linux, bring the rk3399-puma-haikou.dts over as well, drop the separate
DDR-option devicetrees and instead replace them with a puma Kconfig option
to select and include the needed DDR variant.

Signed-off-by: Heiko Stuebner <heiko.stuebner at theobroma-systems.com>
Reviewed-by: Philipp Tomsich <philipp.tomsich at theobroma-systems.com>
---
 arch/arm/dts/Makefile                         |   4 +-
 arch/arm/dts/rk3399-puma-ddr1333-u-boot.dtsi  |   4 -
 arch/arm/dts/rk3399-puma-ddr1333.dts          |   8 -
 arch/arm/dts/rk3399-puma-ddr1600-u-boot.dtsi  |   4 -
 arch/arm/dts/rk3399-puma-ddr1600.dts          |   9 -
 arch/arm/dts/rk3399-puma-ddr1866-u-boot.dtsi  |   4 -
 arch/arm/dts/rk3399-puma-ddr1866.dts          |   8 -
 ...ot.dtsi => rk3399-puma-haikou-u-boot.dtsi} |  11 +
 arch/arm/dts/rk3399-puma-haikou.dts           | 271 ++++++++++++++++++
 board/theobroma-systems/puma_rk3399/Kconfig   |  15 +
 configs/puma-rk3399_defconfig                 |   2 +-
 11 files changed, 299 insertions(+), 41 deletions(-)
 delete mode 100644 arch/arm/dts/rk3399-puma-ddr1333-u-boot.dtsi
 delete mode 100644 arch/arm/dts/rk3399-puma-ddr1333.dts
 delete mode 100644 arch/arm/dts/rk3399-puma-ddr1600-u-boot.dtsi
 delete mode 100644 arch/arm/dts/rk3399-puma-ddr1600.dts
 delete mode 100644 arch/arm/dts/rk3399-puma-ddr1866-u-boot.dtsi
 delete mode 100644 arch/arm/dts/rk3399-puma-ddr1866.dts
 rename arch/arm/dts/{rk3399-puma-u-boot.dtsi => rk3399-puma-haikou-u-boot.dtsi} (80%)
 create mode 100644 arch/arm/dts/rk3399-puma-haikou.dts

Comments

Kever Yang June 7, 2020, 4:33 a.m. UTC | #1
On 2020/6/5 ??6:06, Heiko Stuebner wrote:
> From: Heiko Stuebner <heiko.stuebner at theobroma-systems.com>
>
> So far the puma dts files only just included the main puma dtsi without
> handling the actual baseboard and rk3399-puma.dtsi was very much
> detached from the variant in the mainline Linux kernel.
>
> Recent changes resulted in a strange situation with nonworking puma boards.
>
> Commit ab800e5a6f28 ("arm: dts: rockchip: puma: move U-Boot specific bits to u-boot.dtsi")
> moved the sdram include from rk3399-puma-ddrX.dts to new files
> rk3399-puma-ddrx-u-boot.dtsi which were never included anywhere though.
>
> Commit 167efc2c7a46 ("arm64: dts: rk3399: Sync v5.7-rc1 from Linux")
> replaced the rk3399-puma.dtsi nearly completely, but in the kernel
> it definitly depends on a baseboard dts to actually enable peripherals
> like sd-slot, uarts, etc.
>
> So to untagle this and bring the whole thing more in line with mainline
> Linux, bring the rk3399-puma-haikou.dts over as well, drop the separate
> DDR-option devicetrees and instead replace them with a puma Kconfig option
> to select and include the needed DDR variant.
>
> Signed-off-by: Heiko Stuebner <heiko.stuebner at theobroma-systems.com>
> Reviewed-by: Philipp Tomsich <philipp.tomsich at theobroma-systems.com>

Reviewed-by: Kever Yang <kever.yang at rock-chips.com>

Thanks,
- Kever
> ---
>   arch/arm/dts/Makefile                         |   4 +-
>   arch/arm/dts/rk3399-puma-ddr1333-u-boot.dtsi  |   4 -
>   arch/arm/dts/rk3399-puma-ddr1333.dts          |   8 -
>   arch/arm/dts/rk3399-puma-ddr1600-u-boot.dtsi  |   4 -
>   arch/arm/dts/rk3399-puma-ddr1600.dts          |   9 -
>   arch/arm/dts/rk3399-puma-ddr1866-u-boot.dtsi  |   4 -
>   arch/arm/dts/rk3399-puma-ddr1866.dts          |   8 -
>   ...ot.dtsi => rk3399-puma-haikou-u-boot.dtsi} |  11 +
>   arch/arm/dts/rk3399-puma-haikou.dts           | 271 ++++++++++++++++++
>   board/theobroma-systems/puma_rk3399/Kconfig   |  15 +
>   configs/puma-rk3399_defconfig                 |   2 +-
>   11 files changed, 299 insertions(+), 41 deletions(-)
>   delete mode 100644 arch/arm/dts/rk3399-puma-ddr1333-u-boot.dtsi
>   delete mode 100644 arch/arm/dts/rk3399-puma-ddr1333.dts
>   delete mode 100644 arch/arm/dts/rk3399-puma-ddr1600-u-boot.dtsi
>   delete mode 100644 arch/arm/dts/rk3399-puma-ddr1600.dts
>   delete mode 100644 arch/arm/dts/rk3399-puma-ddr1866-u-boot.dtsi
>   delete mode 100644 arch/arm/dts/rk3399-puma-ddr1866.dts
>   rename arch/arm/dts/{rk3399-puma-u-boot.dtsi => rk3399-puma-haikou-u-boot.dtsi} (80%)
>   create mode 100644 arch/arm/dts/rk3399-puma-haikou.dts
>
> diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
> index c6af87cf5e..a66bdb439d 100644
> --- a/arch/arm/dts/Makefile
> +++ b/arch/arm/dts/Makefile
> @@ -130,9 +130,7 @@ dtb-$(CONFIG_ROCKCHIP_RK3399) += \
>   	rk3399-nanopi-neo4.dtb \
>   	rk3399-orangepi.dtb \
>   	rk3399-pinebook-pro.dtb \
> -	rk3399-puma-ddr1333.dtb \
> -	rk3399-puma-ddr1600.dtb \
> -	rk3399-puma-ddr1866.dtb \
> +	rk3399-puma-haikou.dtb \
>   	rk3399-roc-pc.dtb \
>   	rk3399-roc-pc-mezzanine.dtb \
>   	rk3399-rock-pi-4.dtb \
> diff --git a/arch/arm/dts/rk3399-puma-ddr1333-u-boot.dtsi b/arch/arm/dts/rk3399-puma-ddr1333-u-boot.dtsi
> deleted file mode 100644
> index 39d3927f49..0000000000
> --- a/arch/arm/dts/rk3399-puma-ddr1333-u-boot.dtsi
> +++ /dev/null
> @@ -1,4 +0,0 @@
> -// SPDX-License-Identifier: GPL-2.0+
> -
> -#include "rk3399-puma-u-boot.dtsi"
> -#include "rk3399-sdram-ddr3-1333.dtsi"
> diff --git a/arch/arm/dts/rk3399-puma-ddr1333.dts b/arch/arm/dts/rk3399-puma-ddr1333.dts
> deleted file mode 100644
> index 80f27699f4..0000000000
> --- a/arch/arm/dts/rk3399-puma-ddr1333.dts
> +++ /dev/null
> @@ -1,8 +0,0 @@
> -// SPDX-License-Identifier: GPL-2.0+ OR X11
> -/*
> - * (C) Copyright 2017 Theobroma Systems Design und Consulting GmbH
> - */
> -
> -/dts-v1/;
> -
> -#include "rk3399-puma.dtsi"
> diff --git a/arch/arm/dts/rk3399-puma-ddr1600-u-boot.dtsi b/arch/arm/dts/rk3399-puma-ddr1600-u-boot.dtsi
> deleted file mode 100644
> index be58311dc4..0000000000
> --- a/arch/arm/dts/rk3399-puma-ddr1600-u-boot.dtsi
> +++ /dev/null
> @@ -1,4 +0,0 @@
> -// SPDX-License-Identifier: GPL-2.0+
> -
> -#include "rk3399-puma-u-boot.dtsi"
> -#include "rk3399-sdram-ddr3-1600.dtsi"
> diff --git a/arch/arm/dts/rk3399-puma-ddr1600.dts b/arch/arm/dts/rk3399-puma-ddr1600.dts
> deleted file mode 100644
> index cb76b0165c..0000000000
> --- a/arch/arm/dts/rk3399-puma-ddr1600.dts
> +++ /dev/null
> @@ -1,9 +0,0 @@
> -// SPDX-License-Identifier: GPL-2.0+ OR X11
> -/*
> - * (C) Copyright 2017 Theobroma Systems Design und Consulting GmbH
> - */
> -
> -/dts-v1/;
> -
> -#include "rk3399-puma.dtsi"
> -#include "rk3399-u-boot.dtsi"
> diff --git a/arch/arm/dts/rk3399-puma-ddr1866-u-boot.dtsi b/arch/arm/dts/rk3399-puma-ddr1866-u-boot.dtsi
> deleted file mode 100644
> index 48da076329..0000000000
> --- a/arch/arm/dts/rk3399-puma-ddr1866-u-boot.dtsi
> +++ /dev/null
> @@ -1,4 +0,0 @@
> -// SPDX-License-Identifier: GPL-2.0+
> -
> -#include "rk3399-puma-u-boot.dtsi"
> -#include "rk3399-sdram-ddr3-1866.dtsi"
> diff --git a/arch/arm/dts/rk3399-puma-ddr1866.dts b/arch/arm/dts/rk3399-puma-ddr1866.dts
> deleted file mode 100644
> index 80f27699f4..0000000000
> --- a/arch/arm/dts/rk3399-puma-ddr1866.dts
> +++ /dev/null
> @@ -1,8 +0,0 @@
> -// SPDX-License-Identifier: GPL-2.0+ OR X11
> -/*
> - * (C) Copyright 2017 Theobroma Systems Design und Consulting GmbH
> - */
> -
> -/dts-v1/;
> -
> -#include "rk3399-puma.dtsi"
> diff --git a/arch/arm/dts/rk3399-puma-u-boot.dtsi b/arch/arm/dts/rk3399-puma-haikou-u-boot.dtsi
> similarity index 80%
> rename from arch/arm/dts/rk3399-puma-u-boot.dtsi
> rename to arch/arm/dts/rk3399-puma-haikou-u-boot.dtsi
> index ddb5fa6e76..29846c4b00 100644
> --- a/arch/arm/dts/rk3399-puma-u-boot.dtsi
> +++ b/arch/arm/dts/rk3399-puma-haikou-u-boot.dtsi
> @@ -1,6 +1,17 @@
>   // SPDX-License-Identifier: GPL-2.0+
>   
>   #include "rk3399-u-boot.dtsi"
> +
> +#ifdef CONFIG_TARGET_PUMA_RK3399_RAM_DDR3_1333
> +#include "rk3399-sdram-ddr3-1333.dtsi"
> +#endif
> +#ifdef CONFIG_TARGET_PUMA_RK3399_RAM_DDR3_1600
> +#include "rk3399-sdram-ddr3-1600.dtsi"
> +#endif
> +#ifdef CONFIG_TARGET_PUMA_RK3399_RAM_DDR3_1866
> +#include "rk3399-sdram-ddr3-1866.dtsi"
> +#endif
> +
>   / {
>   	config {
>   		u-boot,spl-payload-offset = <0x40000>; /* @ 256KB */
> diff --git a/arch/arm/dts/rk3399-puma-haikou.dts b/arch/arm/dts/rk3399-puma-haikou.dts
> new file mode 100644
> index 0000000000..d80d6b7268
> --- /dev/null
> +++ b/arch/arm/dts/rk3399-puma-haikou.dts
> @@ -0,0 +1,271 @@
> +// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
> +/*
> + * Copyright (c) 2017 Theobroma Systems Design und Consulting GmbH
> + */
> +
> +/dts-v1/;
> +#include "rk3399-puma.dtsi"
> +
> +/ {
> +	model = "Theobroma Systems RK3399-Q7 SoM";
> +	compatible = "tsd,rk3399-puma-haikou", "rockchip,rk3399";
> +
> +	chosen {
> +		stdout-path = "serial0:115200n8";
> +	};
> +
> +	leds {
> +		pinctrl-0 = <&led_pin_module>, <&led_sd_haikou>;
> +
> +		sd-card-led {
> +			label = "sd_card_led";
> +			gpios = <&gpio1 RK_PA2 GPIO_ACTIVE_HIGH>;
> +			linux,default-trigger = "mmc0";
> +		};
> +	};
> +
> +	i2s0-sound {
> +		compatible = "simple-audio-card";
> +		simple-audio-card,format = "i2s";
> +		simple-audio-card,name = "Haikou,I2S-codec";
> +		simple-audio-card,mclk-fs = <512>;
> +
> +		simple-audio-card,codec {
> +			clocks = <&sgtl5000_clk>;
> +			sound-dai = <&sgtl5000>;
> +		};
> +
> +		simple-audio-card,cpu {
> +			bitclock-master;
> +			frame-master;
> +			sound-dai = <&i2s0>;
> +		};
> +	};
> +
> +	sgtl5000_clk: sgtl5000-oscillator  {
> +			compatible = "fixed-clock";
> +			#clock-cells = <0>;
> +			clock-frequency  = <24576000>;
> +	};
> +
> +	dc_12v: dc-12v {
> +		compatible = "regulator-fixed";
> +		regulator-name = "dc_12v";
> +		regulator-always-on;
> +		regulator-boot-on;
> +		regulator-min-microvolt = <12000000>;
> +		regulator-max-microvolt = <12000000>;
> +	};
> +
> +	vcc3v3_baseboard: vcc3v3-baseboard {
> +		compatible = "regulator-fixed";
> +		regulator-name = "vcc3v3_baseboard";
> +		regulator-always-on;
> +		regulator-boot-on;
> +		regulator-min-microvolt = <3300000>;
> +		regulator-max-microvolt = <3300000>;
> +		vin-supply = <&dc_12v>;
> +	};
> +
> +	vcc5v0_baseboard: vcc5v0-baseboard {
> +		compatible = "regulator-fixed";
> +		regulator-name = "vcc5v0_baseboard";
> +		regulator-always-on;
> +		regulator-boot-on;
> +		regulator-min-microvolt = <5000000>;
> +		regulator-max-microvolt = <5000000>;
> +		vin-supply = <&dc_12v>;
> +	};
> +
> +	vcc5v0_otg: vcc5v0-otg-regulator {
> +		compatible = "regulator-fixed";
> +		enable-active-high;
> +		gpio = <&gpio0 RK_PA2 GPIO_ACTIVE_HIGH>;
> +		pinctrl-names = "default";
> +		pinctrl-0 = <&otg_vbus_drv>;
> +		regulator-name = "vcc5v0_otg";
> +		regulator-always-on;
> +	};
> +
> +	vdda_codec: vdda-codec {
> +		compatible = "regulator-fixed";
> +		regulator-name = "vdda_codec";
> +		regulator-boot-on;
> +		regulator-min-microvolt = <3300000>;
> +		regulator-max-microvolt = <3300000>;
> +		vin-supply = <&vcc5v0_baseboard>;
> +	};
> +
> +	vddd_codec: vddd-codec {
> +		compatible = "regulator-fixed";
> +		regulator-name = "vddd_codec";
> +		regulator-boot-on;
> +		regulator-min-microvolt = <1600000>;
> +		regulator-max-microvolt = <1600000>;
> +		vin-supply = <&vcc5v0_baseboard>;
> +	};
> +};
> +
> +&hdmi {
> +	ddc-i2c-bus = <&i2c3>;
> +	status = "okay";
> +};
> +
> +&i2c1 {
> +	status = "okay";
> +	clock-frequency = <400000>;
> +};
> +
> +&i2c2 {
> +	status = "okay";
> +	clock-frequency = <400000>;
> +};
> +
> +&i2c3 {
> +	i2c-scl-rising-time-ns = <450>;
> +	i2c-scl-falling-time-ns = <15>;
> +	status = "okay";
> +};
> +
> +&i2c4 {
> +	status = "okay";
> +	clock-frequency = <400000>;
> +
> +	sgtl5000: codec at a {
> +		compatible = "fsl,sgtl5000";
> +		reg = <0x0a>;
> +		clocks = <&sgtl5000_clk>;
> +		#sound-dai-cells = <0>;
> +		VDDA-supply = <&vdda_codec>;
> +		VDDIO-supply = <&vdda_codec>;
> +		VDDD-supply = <&vddd_codec>;
> +		status = "okay";
> +	};
> +};
> +
> +&i2c6 {
> +	status = "okay";
> +	clock-frequency = <400000>;
> +};
> +
> +&pcie_phy {
> +	status = "okay";
> +};
> +
> +&pcie0 {
> +	ep-gpios = <&gpio4 RK_PC6 GPIO_ACTIVE_HIGH>;
> +	num-lanes = <4>;
> +	pinctrl-names = "default";
> +	pinctrl-0 = <&pcie_clkreqn_cpm>;
> +	status = "okay";
> +};
> +
> +&pinctrl {
> +	pinctrl-names = "default";
> +	pinctrl-0 = <&haikou_pin_hog>;
> +
> +	hog {
> +		haikou_pin_hog: haikou-pin-hog {
> +			rockchip,pins =
> +			  /* LID_BTN */
> +			  <0 RK_PA4 RK_FUNC_GPIO &pcfg_pull_up>,
> +			  /* BATLOW# */
> +			  <0 RK_PB2 RK_FUNC_GPIO &pcfg_pull_up>,
> +			  /* SLP_BTN# */
> +			  <0 RK_PB3 RK_FUNC_GPIO &pcfg_pull_up>,
> +			  /* BIOS_DISABLE# */
> +			  <0 RK_PB1 RK_FUNC_GPIO &pcfg_pull_up>;
> +		};
> +	};
> +
> +	leds {
> +		led_sd_haikou: led-sd-gpio {
> +			rockchip,pins =
> +			  <1 RK_PA2 RK_FUNC_GPIO &pcfg_pull_none>;
> +		};
> +	};
> +
> +	usb2 {
> +		otg_vbus_drv: otg-vbus-drv {
> +			rockchip,pins =
> +			  <0 RK_PA2 RK_FUNC_GPIO &pcfg_pull_none>;
> +		};
> +	};
> +};
> +
> +&pwm0 {
> +	status = "okay";
> +};
> +
> +&sdmmc {
> +	bus-width = <4>;
> +	cap-mmc-highspeed;
> +	cap-sd-highspeed;
> +	cd-gpios = <&gpio0 RK_PA7 GPIO_ACTIVE_LOW>;
> +	disable-wp;
> +	max-frequency = <150000000>;
> +	pinctrl-names = "default";
> +	pinctrl-0 = <&sdmmc_clk &sdmmc_cmd &sdmmc_cd &sdmmc_bus4>;
> +	vmmc-supply = <&vcc3v3_baseboard>;
> +	status = "okay";
> +};
> +
> +&spi5 {
> +	status = "okay";
> +};
> +
> +&tcphy0 {
> +	status = "okay";
> +};
> +
> +&u2phy0 {
> +	status = "okay";
> +};
> +
> +&usbdrd3_0 {
> +	status = "okay";
> +};
> +
> +&usbdrd_dwc3_0 {
> +	dr_mode = "otg";
> +	status = "okay";
> +};
> +
> +&u2phy0_host {
> +	phy-supply = <&vcc5v0_otg>;
> +	status = "okay";
> +};
> +
> +&uart0 {
> +	pinctrl-names = "default";
> +	pinctrl-0 = <&uart0_xfer &uart0_cts &uart0_rts>;
> +	status = "okay";
> +};
> +
> +&uart2 {
> +	status = "okay";
> +};
> +
> +&usb_host0_ehci {
> +	status = "okay";
> +};
> +
> +&usb_host0_ohci {
> +	status = "okay";
> +};
> +
> +&vopb {
> +	status = "okay";
> +};
> +
> +&vopb_mmu {
> +	status = "okay";
> +};
> +
> +&vopl {
> +	status = "okay";
> +};
> +
> +&vopl_mmu {
> +	status = "okay";
> +};
> diff --git a/board/theobroma-systems/puma_rk3399/Kconfig b/board/theobroma-systems/puma_rk3399/Kconfig
> index 9e23252754..e82623a170 100644
> --- a/board/theobroma-systems/puma_rk3399/Kconfig
> +++ b/board/theobroma-systems/puma_rk3399/Kconfig
> @@ -18,4 +18,19 @@ config ENV_SIZE
>   config ENV_OFFSET
>   	default 0x3fc000 if ENV_IS_IN_SPI_FLASH
>   
> +choice
> +	prompt "Theobroma Systems RK3399-Q7 DDR Option"
> +	default TARGET_PUMA_RK3399_RAM_DDR3_1333
> +
> +config TARGET_PUMA_RK3399_RAM_DDR3_1333
> +	bool "DDR3-1333MHz"
> +
> +config TARGET_PUMA_RK3399_RAM_DDR3_1600
> +	bool "DDR3-1600MHz"
> +
> +config TARGET_PUMA_RK3399_RAM_DDR3_1866
> +	bool "DDR3-1866MHz"
> +
> +endchoice
> +
>   endif
> diff --git a/configs/puma-rk3399_defconfig b/configs/puma-rk3399_defconfig
> index a148832b83..47a60930b6 100644
> --- a/configs/puma-rk3399_defconfig
> +++ b/configs/puma-rk3399_defconfig
> @@ -39,7 +39,7 @@ CONFIG_CMD_PMIC=y
>   CONFIG_CMD_REGULATOR=y
>   CONFIG_SPL_OF_CONTROL=y
>   CONFIG_OF_LIVE=y
> -CONFIG_DEFAULT_DEVICE_TREE="rk3399-puma-ddr1600"
> +CONFIG_DEFAULT_DEVICE_TREE="rk3399-puma-haikou"
>   CONFIG_OF_SPL_REMOVE_PROPS="pinctrl-0 pinctrl-names interrupt-parent assigned-clocks assigned-clock-rates assigned-clock-parents"
>   CONFIG_ENV_IS_IN_MMC=y
>   CONFIG_SYS_RELOC_GD_ENV_ADDR=y
diff mbox series

Patch

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index c6af87cf5e..a66bdb439d 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -130,9 +130,7 @@  dtb-$(CONFIG_ROCKCHIP_RK3399) += \
 	rk3399-nanopi-neo4.dtb \
 	rk3399-orangepi.dtb \
 	rk3399-pinebook-pro.dtb \
-	rk3399-puma-ddr1333.dtb \
-	rk3399-puma-ddr1600.dtb \
-	rk3399-puma-ddr1866.dtb \
+	rk3399-puma-haikou.dtb \
 	rk3399-roc-pc.dtb \
 	rk3399-roc-pc-mezzanine.dtb \
 	rk3399-rock-pi-4.dtb \
diff --git a/arch/arm/dts/rk3399-puma-ddr1333-u-boot.dtsi b/arch/arm/dts/rk3399-puma-ddr1333-u-boot.dtsi
deleted file mode 100644
index 39d3927f49..0000000000
--- a/arch/arm/dts/rk3399-puma-ddr1333-u-boot.dtsi
+++ /dev/null
@@ -1,4 +0,0 @@ 
-// SPDX-License-Identifier: GPL-2.0+
-
-#include "rk3399-puma-u-boot.dtsi"
-#include "rk3399-sdram-ddr3-1333.dtsi"
diff --git a/arch/arm/dts/rk3399-puma-ddr1333.dts b/arch/arm/dts/rk3399-puma-ddr1333.dts
deleted file mode 100644
index 80f27699f4..0000000000
--- a/arch/arm/dts/rk3399-puma-ddr1333.dts
+++ /dev/null
@@ -1,8 +0,0 @@ 
-// SPDX-License-Identifier: GPL-2.0+ OR X11
-/*
- * (C) Copyright 2017 Theobroma Systems Design und Consulting GmbH
- */
-
-/dts-v1/;
-
-#include "rk3399-puma.dtsi"
diff --git a/arch/arm/dts/rk3399-puma-ddr1600-u-boot.dtsi b/arch/arm/dts/rk3399-puma-ddr1600-u-boot.dtsi
deleted file mode 100644
index be58311dc4..0000000000
--- a/arch/arm/dts/rk3399-puma-ddr1600-u-boot.dtsi
+++ /dev/null
@@ -1,4 +0,0 @@ 
-// SPDX-License-Identifier: GPL-2.0+
-
-#include "rk3399-puma-u-boot.dtsi"
-#include "rk3399-sdram-ddr3-1600.dtsi"
diff --git a/arch/arm/dts/rk3399-puma-ddr1600.dts b/arch/arm/dts/rk3399-puma-ddr1600.dts
deleted file mode 100644
index cb76b0165c..0000000000
--- a/arch/arm/dts/rk3399-puma-ddr1600.dts
+++ /dev/null
@@ -1,9 +0,0 @@ 
-// SPDX-License-Identifier: GPL-2.0+ OR X11
-/*
- * (C) Copyright 2017 Theobroma Systems Design und Consulting GmbH
- */
-
-/dts-v1/;
-
-#include "rk3399-puma.dtsi"
-#include "rk3399-u-boot.dtsi"
diff --git a/arch/arm/dts/rk3399-puma-ddr1866-u-boot.dtsi b/arch/arm/dts/rk3399-puma-ddr1866-u-boot.dtsi
deleted file mode 100644
index 48da076329..0000000000
--- a/arch/arm/dts/rk3399-puma-ddr1866-u-boot.dtsi
+++ /dev/null
@@ -1,4 +0,0 @@ 
-// SPDX-License-Identifier: GPL-2.0+
-
-#include "rk3399-puma-u-boot.dtsi"
-#include "rk3399-sdram-ddr3-1866.dtsi"
diff --git a/arch/arm/dts/rk3399-puma-ddr1866.dts b/arch/arm/dts/rk3399-puma-ddr1866.dts
deleted file mode 100644
index 80f27699f4..0000000000
--- a/arch/arm/dts/rk3399-puma-ddr1866.dts
+++ /dev/null
@@ -1,8 +0,0 @@ 
-// SPDX-License-Identifier: GPL-2.0+ OR X11
-/*
- * (C) Copyright 2017 Theobroma Systems Design und Consulting GmbH
- */
-
-/dts-v1/;
-
-#include "rk3399-puma.dtsi"
diff --git a/arch/arm/dts/rk3399-puma-u-boot.dtsi b/arch/arm/dts/rk3399-puma-haikou-u-boot.dtsi
similarity index 80%
rename from arch/arm/dts/rk3399-puma-u-boot.dtsi
rename to arch/arm/dts/rk3399-puma-haikou-u-boot.dtsi
index ddb5fa6e76..29846c4b00 100644
--- a/arch/arm/dts/rk3399-puma-u-boot.dtsi
+++ b/arch/arm/dts/rk3399-puma-haikou-u-boot.dtsi
@@ -1,6 +1,17 @@ 
 // SPDX-License-Identifier: GPL-2.0+
 
 #include "rk3399-u-boot.dtsi"
+
+#ifdef CONFIG_TARGET_PUMA_RK3399_RAM_DDR3_1333
+#include "rk3399-sdram-ddr3-1333.dtsi"
+#endif
+#ifdef CONFIG_TARGET_PUMA_RK3399_RAM_DDR3_1600
+#include "rk3399-sdram-ddr3-1600.dtsi"
+#endif
+#ifdef CONFIG_TARGET_PUMA_RK3399_RAM_DDR3_1866
+#include "rk3399-sdram-ddr3-1866.dtsi"
+#endif
+
 / {
 	config {
 		u-boot,spl-payload-offset = <0x40000>; /* @ 256KB */
diff --git a/arch/arm/dts/rk3399-puma-haikou.dts b/arch/arm/dts/rk3399-puma-haikou.dts
new file mode 100644
index 0000000000..d80d6b7268
--- /dev/null
+++ b/arch/arm/dts/rk3399-puma-haikou.dts
@@ -0,0 +1,271 @@ 
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (c) 2017 Theobroma Systems Design und Consulting GmbH
+ */
+
+/dts-v1/;
+#include "rk3399-puma.dtsi"
+
+/ {
+	model = "Theobroma Systems RK3399-Q7 SoM";
+	compatible = "tsd,rk3399-puma-haikou", "rockchip,rk3399";
+
+	chosen {
+		stdout-path = "serial0:115200n8";
+	};
+
+	leds {
+		pinctrl-0 = <&led_pin_module>, <&led_sd_haikou>;
+
+		sd-card-led {
+			label = "sd_card_led";
+			gpios = <&gpio1 RK_PA2 GPIO_ACTIVE_HIGH>;
+			linux,default-trigger = "mmc0";
+		};
+	};
+
+	i2s0-sound {
+		compatible = "simple-audio-card";
+		simple-audio-card,format = "i2s";
+		simple-audio-card,name = "Haikou,I2S-codec";
+		simple-audio-card,mclk-fs = <512>;
+
+		simple-audio-card,codec {
+			clocks = <&sgtl5000_clk>;
+			sound-dai = <&sgtl5000>;
+		};
+
+		simple-audio-card,cpu {
+			bitclock-master;
+			frame-master;
+			sound-dai = <&i2s0>;
+		};
+	};
+
+	sgtl5000_clk: sgtl5000-oscillator  {
+			compatible = "fixed-clock";
+			#clock-cells = <0>;
+			clock-frequency  = <24576000>;
+	};
+
+	dc_12v: dc-12v {
+		compatible = "regulator-fixed";
+		regulator-name = "dc_12v";
+		regulator-always-on;
+		regulator-boot-on;
+		regulator-min-microvolt = <12000000>;
+		regulator-max-microvolt = <12000000>;
+	};
+
+	vcc3v3_baseboard: vcc3v3-baseboard {
+		compatible = "regulator-fixed";
+		regulator-name = "vcc3v3_baseboard";
+		regulator-always-on;
+		regulator-boot-on;
+		regulator-min-microvolt = <3300000>;
+		regulator-max-microvolt = <3300000>;
+		vin-supply = <&dc_12v>;
+	};
+
+	vcc5v0_baseboard: vcc5v0-baseboard {
+		compatible = "regulator-fixed";
+		regulator-name = "vcc5v0_baseboard";
+		regulator-always-on;
+		regulator-boot-on;
+		regulator-min-microvolt = <5000000>;
+		regulator-max-microvolt = <5000000>;
+		vin-supply = <&dc_12v>;
+	};
+
+	vcc5v0_otg: vcc5v0-otg-regulator {
+		compatible = "regulator-fixed";
+		enable-active-high;
+		gpio = <&gpio0 RK_PA2 GPIO_ACTIVE_HIGH>;
+		pinctrl-names = "default";
+		pinctrl-0 = <&otg_vbus_drv>;
+		regulator-name = "vcc5v0_otg";
+		regulator-always-on;
+	};
+
+	vdda_codec: vdda-codec {
+		compatible = "regulator-fixed";
+		regulator-name = "vdda_codec";
+		regulator-boot-on;
+		regulator-min-microvolt = <3300000>;
+		regulator-max-microvolt = <3300000>;
+		vin-supply = <&vcc5v0_baseboard>;
+	};
+
+	vddd_codec: vddd-codec {
+		compatible = "regulator-fixed";
+		regulator-name = "vddd_codec";
+		regulator-boot-on;
+		regulator-min-microvolt = <1600000>;
+		regulator-max-microvolt = <1600000>;
+		vin-supply = <&vcc5v0_baseboard>;
+	};
+};
+
+&hdmi {
+	ddc-i2c-bus = <&i2c3>;
+	status = "okay";
+};
+
+&i2c1 {
+	status = "okay";
+	clock-frequency = <400000>;
+};
+
+&i2c2 {
+	status = "okay";
+	clock-frequency = <400000>;
+};
+
+&i2c3 {
+	i2c-scl-rising-time-ns = <450>;
+	i2c-scl-falling-time-ns = <15>;
+	status = "okay";
+};
+
+&i2c4 {
+	status = "okay";
+	clock-frequency = <400000>;
+
+	sgtl5000: codec at a {
+		compatible = "fsl,sgtl5000";
+		reg = <0x0a>;
+		clocks = <&sgtl5000_clk>;
+		#sound-dai-cells = <0>;
+		VDDA-supply = <&vdda_codec>;
+		VDDIO-supply = <&vdda_codec>;
+		VDDD-supply = <&vddd_codec>;
+		status = "okay";
+	};
+};
+
+&i2c6 {
+	status = "okay";
+	clock-frequency = <400000>;
+};
+
+&pcie_phy {
+	status = "okay";
+};
+
+&pcie0 {
+	ep-gpios = <&gpio4 RK_PC6 GPIO_ACTIVE_HIGH>;
+	num-lanes = <4>;
+	pinctrl-names = "default";
+	pinctrl-0 = <&pcie_clkreqn_cpm>;
+	status = "okay";
+};
+
+&pinctrl {
+	pinctrl-names = "default";
+	pinctrl-0 = <&haikou_pin_hog>;
+
+	hog {
+		haikou_pin_hog: haikou-pin-hog {
+			rockchip,pins =
+			  /* LID_BTN */
+			  <0 RK_PA4 RK_FUNC_GPIO &pcfg_pull_up>,
+			  /* BATLOW# */
+			  <0 RK_PB2 RK_FUNC_GPIO &pcfg_pull_up>,
+			  /* SLP_BTN# */
+			  <0 RK_PB3 RK_FUNC_GPIO &pcfg_pull_up>,
+			  /* BIOS_DISABLE# */
+			  <0 RK_PB1 RK_FUNC_GPIO &pcfg_pull_up>;
+		};
+	};
+
+	leds {
+		led_sd_haikou: led-sd-gpio {
+			rockchip,pins =
+			  <1 RK_PA2 RK_FUNC_GPIO &pcfg_pull_none>;
+		};
+	};
+
+	usb2 {
+		otg_vbus_drv: otg-vbus-drv {
+			rockchip,pins =
+			  <0 RK_PA2 RK_FUNC_GPIO &pcfg_pull_none>;
+		};
+	};
+};
+
+&pwm0 {
+	status = "okay";
+};
+
+&sdmmc {
+	bus-width = <4>;
+	cap-mmc-highspeed;
+	cap-sd-highspeed;
+	cd-gpios = <&gpio0 RK_PA7 GPIO_ACTIVE_LOW>;
+	disable-wp;
+	max-frequency = <150000000>;
+	pinctrl-names = "default";
+	pinctrl-0 = <&sdmmc_clk &sdmmc_cmd &sdmmc_cd &sdmmc_bus4>;
+	vmmc-supply = <&vcc3v3_baseboard>;
+	status = "okay";
+};
+
+&spi5 {
+	status = "okay";
+};
+
+&tcphy0 {
+	status = "okay";
+};
+
+&u2phy0 {
+	status = "okay";
+};
+
+&usbdrd3_0 {
+	status = "okay";
+};
+
+&usbdrd_dwc3_0 {
+	dr_mode = "otg";
+	status = "okay";
+};
+
+&u2phy0_host {
+	phy-supply = <&vcc5v0_otg>;
+	status = "okay";
+};
+
+&uart0 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&uart0_xfer &uart0_cts &uart0_rts>;
+	status = "okay";
+};
+
+&uart2 {
+	status = "okay";
+};
+
+&usb_host0_ehci {
+	status = "okay";
+};
+
+&usb_host0_ohci {
+	status = "okay";
+};
+
+&vopb {
+	status = "okay";
+};
+
+&vopb_mmu {
+	status = "okay";
+};
+
+&vopl {
+	status = "okay";
+};
+
+&vopl_mmu {
+	status = "okay";
+};
diff --git a/board/theobroma-systems/puma_rk3399/Kconfig b/board/theobroma-systems/puma_rk3399/Kconfig
index 9e23252754..e82623a170 100644
--- a/board/theobroma-systems/puma_rk3399/Kconfig
+++ b/board/theobroma-systems/puma_rk3399/Kconfig
@@ -18,4 +18,19 @@  config ENV_SIZE
 config ENV_OFFSET
 	default 0x3fc000 if ENV_IS_IN_SPI_FLASH
 
+choice
+	prompt "Theobroma Systems RK3399-Q7 DDR Option"
+	default TARGET_PUMA_RK3399_RAM_DDR3_1333
+
+config TARGET_PUMA_RK3399_RAM_DDR3_1333
+	bool "DDR3-1333MHz"
+
+config TARGET_PUMA_RK3399_RAM_DDR3_1600
+	bool "DDR3-1600MHz"
+
+config TARGET_PUMA_RK3399_RAM_DDR3_1866
+	bool "DDR3-1866MHz"
+
+endchoice
+
 endif
diff --git a/configs/puma-rk3399_defconfig b/configs/puma-rk3399_defconfig
index a148832b83..47a60930b6 100644
--- a/configs/puma-rk3399_defconfig
+++ b/configs/puma-rk3399_defconfig
@@ -39,7 +39,7 @@  CONFIG_CMD_PMIC=y
 CONFIG_CMD_REGULATOR=y
 CONFIG_SPL_OF_CONTROL=y
 CONFIG_OF_LIVE=y
-CONFIG_DEFAULT_DEVICE_TREE="rk3399-puma-ddr1600"
+CONFIG_DEFAULT_DEVICE_TREE="rk3399-puma-haikou"
 CONFIG_OF_SPL_REMOVE_PROPS="pinctrl-0 pinctrl-names interrupt-parent assigned-clocks assigned-clock-rates assigned-clock-parents"
 CONFIG_ENV_IS_IN_MMC=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y