// SPDX-License-Identifier: GPL-2.0
/dts-v1/;
#include "bcm2837.dtsi"
#include "bcm2836-rpi.dtsi"
#include "bcm283x-rpi-lan7515.dtsi"
#include "bcm283x-rpi-usb-host.dtsi"

/ {
	compatible = "raspberrypi,3-model-b-plus", "brcm,bcm2837";
	model = "Raspberry Pi 3 Model B+";

	chosen {
		/* 8250 auxiliary UART instead of pl011 */
		stdout-path = "serial1:115200n8";
	};

	memory@0 {
		device_type = "memory";
		reg = <0 0x40000000>;
	};

	leds {
		led-act {
			gpios = <&gpio 29 GPIO_ACTIVE_HIGH>;
		};

		led-pwr {
			label = "PWR";
			gpios = <&expgpio 2 GPIO_ACTIVE_LOW>;
			default-state = "keep";
			linux,default-trigger = "default-on";
		};
	};

	wifi_pwrseq: wifi-pwrseq {
		compatible = "mmc-pwrseq-simple";
		reset-gpios = <&expgpio 1 GPIO_ACTIVE_LOW>;
	};
};

&firmware {
	expgpio: gpio {
		compatible = "raspberrypi,firmware-gpio";
		gpio-controller;
		#gpio-cells = <2>;
		gpio-line-names = "BT_ON",
				  "WL_ON",
				  "STATUS_LED_R",
				  "LAN_RUN",
				  "",
				  "CAM_GPIO0",
				  "CAM_GPIO1",
				  "";
		status = "okay";
	};
};

&gpio {
	/*
	 * Taken from rpi_SCH_3bplus_1p0_reduced.pdf and
	 * the official GPU firmware DT blob.
	 *
	 * Legend:
	 * "NC" = not connected (no rail from the SoC)
	 * "FOO" = GPIO line named "FOO" on the schematic
	 * "FOO_N" = GPIO line named "FOO" on schematic, active low
	 */
	gpio-line-names = "ID_SDA",
			  "ID_SCL",
			  "SDA1",
			  "SCL1",
			  "GPIO_GCLK",
			  "GPIO5",
			  "GPIO6",
			  "SPI_CE1_N",
			  "SPI_CE0_N",
			  "SPI_MISO",
			  "SPI_MOSI",
			  "SPI_SCLK",
			  "GPIO12",
			  "GPIO13",
			  /* Serial port */
			  "TXD1",
			  "RXD1",
			  "GPIO16",
			  "GPIO17",
			  "GPIO18",
			  "GPIO19",
			  "GPIO20",
			  "GPIO21",
			  "GPIO22",
			  "GPIO23",
			  "GPIO24",
			  "GPIO25",
			  "GPIO26",
			  "GPIO27",
			  "HDMI_HPD_N",
			  "STATUS_LED_G",
			  /* Used by BT module */
			  "CTS0",
			  "RTS0",
			  "TXD0",
			  "RXD0",
			  /* Used by Wifi */
			  "SD1_CLK",
			  "SD1_CMD",
			  "SD1_DATA0",
			  "SD1_DATA1",
			  "SD1_DATA2",
			  "SD1_DATA3",
			  "PWM0_OUT",
			  "PWM1_OUT",
			  "ETHCLK",
			  "WIFI_CLK",
			  "SDA0",
			  "SCL0",
			  "SMPS_SCL",
			  "SMPS_SDA",
			  /* Used by SD Card */
			  "SD_CLK_R",
			  "SD_CMD_R",
			  "SD_DATA0_R",
			  "SD_DATA1_R",
			  "SD_DATA2_R",
			  "SD_DATA3_R";
};

&hdmi {
	hpd-gpios = <&gpio 28 GPIO_ACTIVE_LOW>;
	power-domains = <&power RPI_POWER_DOMAIN_HDMI>;
	status = "okay";
};

&pwm {
	pinctrl-names = "default";
	pinctrl-0 = <&pwm0_gpio40 &pwm1_gpio41>;
	status = "okay";
};

/* SDHCI is used to control the SDIO for wireless */
&sdhci {
	#address-cells = <1>;
	#size-cells = <0>;
	pinctrl-names = "default";
	pinctrl-0 = <&emmc_gpio34>;
	status = "okay";
	bus-width = <4>;
	non-removable;
	mmc-pwrseq = <&wifi_pwrseq>;

	brcmf: wifi@1 {
		reg = <1>;
		compatible = "brcm,bcm4329-fmac";
	};
};

/* SDHOST is used to drive the SD card */
&sdhost {
	pinctrl-names = "default";
	pinctrl-0 = <&sdhost_gpio48>;
	status = "okay";
	bus-width = <4>;
};

/* uart0 communicates with the BT module */
&uart0 {
	pinctrl-names = "default";
	pinctrl-0 = <&uart0_ctsrts_gpio30 &uart0_gpio32 &gpclk2_gpio43>;
	status = "okay";

	bluetooth {
		compatible = "brcm,bcm43438-bt";
		max-speed = <2000000>;
		shutdown-gpios = <&expgpio 0 GPIO_ACTIVE_HIGH>;
	};
};

/* uart1 is mapped to the pin header */
&uart1 {
	pinctrl-names = "default";
	pinctrl-0 = <&uart1_gpio14>;
	status = "okay";
};
