// SPDX-License-Identifier: (GPL-2.0-or-later OR MIT)
/*
 * Device Tree file for Sercomm H500-s
 *
 * Copyright (C) 2020 Daniel González Cabanelas <dgcbueu@gmail.com>
 */

#include "bcm63268.dtsi"

#include <dt-bindings/input/input.h>

/ {
	aliases {
		led-boot = &led_power_green;
		led-failsafe = &led_power_red;
		led-running = &led_power_green;
		led-upgrade = &led_power_green;
	};

	chosen {
		bootargs = "rootfstype=squashfs,ubifs noinitrd console=ttyS0,115200";
		stdout-path = "serial0:115200n8";
	};

	keys {
		compatible = "gpio-keys-polled";
		#address-cells = <1>;
		#size-cells = <0>;
		poll-interval = <20>;

		wps {
			label = "wps";
			gpios = <&pinctrl 34 1>;
			linux,code = <KEY_WPS_BUTTON>;
			debounce-interval = <60>;
		};

		reset {
			label = "reset";
			gpios = <&pinctrl 35 1>;
			linux,code = <KEY_RESTART>;
			debounce-interval = <60>;
		};
	};
};

&leds {
	status = "okay";

	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_leds>;

	mobile_red {
		reg = <0>;
		label = "red:mobile";
	};

	mobile_green {
		reg = <1>;
		label = "green:mobile";
	};

	led_power_red: power_red {
		reg = <8>;
		label = "red:power";
	};

	wifi_green {
		reg = <9>;
		label = "green:wifi";
	};

	phone_red {
		reg = <12>;
		label = "red:phone";
	};

	wifi_red {
		reg = <13>;
		label = "red:wifi";
	};

	internet_red {
		reg = <14>;
		label = "red:internet";
	};

	internet_green {
		reg = <15>;
		label = "green:internet";
	};

	phone_green {
		reg = <16>;
		label = "green:phone";
	};

	led_power_green: power_green {
		reg = <17>;
		label = "green:power";
		default-state = "on";
	};

	mobile_blue {
		reg = <23>;
		label = "blue:mobile";
	};
};

&nflash {
	status = "okay";

	nandcs@0 {
		compatible = "brcm,nandcs";
		#size-cells = <1>;
		#address-cells = <1>;
		reg = <0>;
		nand-ecc-step-size = <512>;
		nand-ecc-strength = <4>;
		nand-on-flash-bbt;
		brcm,nand-oob-sector-size = <64>;

		partitions {
			compatible = "fixed-partitions";
			#address-cells = <1>;
			#size-cells = <1>;

			partition@0 {
				label = "cferom";
				reg = <0x0000000 0x0020000>;
				read-only;
			};

			partition@20000 {
				label = "part_map";
				reg = <0x0020000 0x00a0000>;
				read-only;
			};

			partition@c0000 {
				label = "cferam1";
				reg = <0x00c0000 0x0140000>;
				read-only;
			};

			partition@200000 {
				label = "cferam2";
				reg = <0x0200000 0x0140000>;
				read-only;
			};

			partition@6920000 {
				label = "bootflag1";
				reg = <0x6920000 0x0140000>;
			};

			partition@6a60000 {
				label = "bootflag2";
				reg = <0x6a60000 0x0140000>;
			};

			partition@520000 {
				compatible = "sercomm,wfi";
				label = "wfi";
				reg = <0x0520000 0x6400000>; /* 2 images, 97152 KiB */
			};

			partition@6ba0000 {
				label = "xml_cfg";
				reg = <0x6ba0000 0x0280000>;
				read-only;
			};

			partition@6e20000 {
				label = "app_data";
				reg = <0x6e20000 0x0280000>;
				read-only;
			};
		};
	};
};

&pinctrl {
	pinctrl_leds: leds {
		function = "led";
		pins = "gpio0",  "gpio1",  "gpio8",  "gpio9",
		       "gpio12", "gpio13", "gpio14", "gpio15",
		       "gpio16", "gpio17", "gpio23";
	};
};

&uart0 {
	status = "okay";
};
