From 2d48f93ff4537628f6860cf6f562b7282384b035 Mon Sep 17 00:00:00 2001
From: Felix Fietkau <nbd@nbd.name>
Date: Thu, 9 Jun 2016 16:51:39 +0200
Subject: lantiq: add Buffalo WBMR-300HPD support

Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
 target/linux/lantiq/base-files/etc/board.d/01_leds |   7 +
 .../linux/lantiq/base-files/etc/board.d/02_network |   7 +
 target/linux/lantiq/dts/WBMR300.dts                | 303 +++++++++++++++++++++
 target/linux/lantiq/image/Makefile                 |   8 +
 target/linux/lantiq/xrx200/config-default          |   3 +
 5 files changed, 328 insertions(+)
 create mode 100644 target/linux/lantiq/dts/WBMR300.dts

(limited to 'target')

diff --git a/target/linux/lantiq/base-files/etc/board.d/01_leds b/target/linux/lantiq/base-files/etc/board.d/01_leds
index 39b693a..c365468 100755
--- a/target/linux/lantiq/base-files/etc/board.d/01_leds
+++ b/target/linux/lantiq/base-files/etc/board.d/01_leds
@@ -42,6 +42,13 @@ P2812HNUF*)
 ARV7519RW22)
 	ucidef_set_led_netdev "lan" "lan" "arv7519rw22:green:lan" "eth0.1"
 	;;
+WBMR300)
+	ucidef_set_led_switch "lan1" "LAN1" "wbmr300:green:lan1" "switch0" "0x08"
+	ucidef_set_led_switch "lan2" "LAN2" "wbmr300:green:lan2" "switch0" "0x04"
+	ucidef_set_led_switch "wan" "WAN" "wbmr300:green:wan" "switch0" "0x10"
+	ucidef_set_led_switch "lan3" "LAN3" "wbmr300:green:lan3" "switch0" "0x20"
+	ucidef_set_led_default "router" "router" "wbmr300:green:router" "1"
+	;;
 *)
 	;;
 esac
diff --git a/target/linux/lantiq/base-files/etc/board.d/02_network b/target/linux/lantiq/base-files/etc/board.d/02_network
index a3dc80c..89ffc79 100755
--- a/target/linux/lantiq/base-files/etc/board.d/02_network
+++ b/target/linux/lantiq/base-files/etc/board.d/02_network
@@ -146,6 +146,13 @@ VGV7510KW22)
 		"2:lan:1" "3:lan:2" "4:lan:3" "5:lan:4" "6t@eth0"
 	;;
 
+WBMR300)
+	lan_mac=$(mtd_get_mac_ascii ubootconfig ethaddr)
+	wan_mac="$lan_mac"
+	ucidef_add_switch "switch0" \
+		"2:lan:1" "3:lan:2" "5:lan:3" "4:wan:1" "6t@eth0"
+	;;
+
 esac
 
 if [ -n "$(ls /lib/modules/`uname -r`/ltq_atm*)" ]; then
diff --git a/target/linux/lantiq/dts/WBMR300.dts b/target/linux/lantiq/dts/WBMR300.dts
new file mode 100644
index 0000000..824efb7
--- /dev/null
+++ b/target/linux/lantiq/dts/WBMR300.dts
@@ -0,0 +1,303 @@
+/dts-v1/;
+
+/include/ "vr9.dtsi"
+
+/ {
+	model = "WBMR300 - Buffalo WBMR-300HPD";
+
+	chosen {
+		bootargs = "console=ttyLTQ0,115200 init=/etc/preinit";
+
+		leds {
+			boot = &power_g;
+			failsafe = &diag_r;
+			running = &power_g;
+
+			dsl = &dsl;
+			internet = &router_g;
+			wifi = &wifi_g;
+		};
+	};
+
+	memory@0 {
+		reg = <0x0 0x4000000>;
+	};
+
+	fpi@10000000 {
+		gpio: pinmux@E100B10 {
+			pinctrl-names = "default";
+			pinctrl-0 = <&state_default>;
+
+			state_default: pinmux {
+				mdio {
+					lantiq,groups = "mdio";
+					lantiq,function = "mdio";
+				};
+				phy-rst {
+					lantiq,pins = "io42";
+					lantiq,pull = <0>;
+					lantiq,open-drain = <0>;
+					lantiq,output = <1>;
+				};
+				pcie-rst {
+					lantiq,pins = "io38";
+					lantiq,pull = <0>;
+					lantiq,output = <1>;
+				};
+			};
+			pins_spi_default: pins_spi_default {
+				spi_in {
+					lantiq,groups = "spi_di";
+					lantiq,function = "spi";
+				};
+				spi_out {
+					lantiq,groups = "spi_do", "spi_clk",
+						"spi_cs4";
+					lantiq,function = "spi";
+					lantiq,output = <1>;
+				};
+			};
+		};
+
+		ifxhcd@E101000 {
+			status = "okay";
+			gpios = <&gpio 33 0>;
+			lantiq,portmask = <0x3>;
+		};
+
+		ifxhcd@E106000 {
+			status = "okay";
+			gpios = <&gpio 33 0>;
+		};
+	};
+
+	gphy-xrx200 {
+		compatible = "lantiq,phy-xrx200";
+		firmware = "lantiq/vr9_phy22f_a2x.bin";
+		phys = [ 00 01 ];
+	};
+
+	gpio_poweroff {
+		compatible = "gpio-poweroff";
+		gpios = <&gpio 6 1>;
+	};
+
+	gpio-keys-polled {
+		compatible = "gpio-keys-polled";
+		#address-cells = <1>;
+		#size-cells = <0>;
+		poll-interval = <100>;
+
+		power {
+			label = "power";
+			gpios = <&gpio 5 1>;
+			linux,code = <0x74>;
+		};
+
+		reset {
+			label = "reset";
+			gpios = <&gpio 7 1>;
+			linux,code = <0x198>;
+		};
+
+		wps {
+			label = "wps";
+			gpios = <&gpio 31 1>;
+			linux,code = <0x211>;
+		};
+
+		auto {
+			label = "auto";
+			gpios = <&gpio 48 0>;
+			linux,code = <0x100>;
+			linux,input-type = <5>; /* EV_SW */
+		};
+
+		router {
+			label = "router";
+			gpios = <&gpio 2 0>;
+			linux,code = <0x100>;
+			linux,input-type = <5>; /* EV_SW */
+		};
+	};
+
+	gpio-leds {
+		compatible = "gpio-leds";
+
+		diag_r: diag_r {
+			label = "wbmr300:red:diag";
+			gpios = <&gpio 0 0>;
+			default_state = "off";
+		};
+
+		wifi_g: wifi_g {
+			label = "wbmr300:green:wifi";
+			gpios = <&gpio 1 0>;
+		};
+
+		dsl: dsl {
+			label = "dsl";
+			gpios = <&gpio 4 0>;
+		};
+
+		router_y: router_y {
+			label = "wbmr300:yellow:router";
+			gpios = <&gpio 8 0>;
+		};
+
+		wifi_y: wifi_y {
+			label = "wbmr300:yellow:wifi";
+			gpios = <&gpio 9 0>;
+		};
+
+		lan1: lan1 {
+			label = "wbmr300:green:lan1";
+			gpios = <&gpio 11 0>;
+		};
+
+		wan: wan {
+			label = "wbmr300:green:wan";
+			gpios = <&gpio 12 0>;
+		};
+
+		lan3: lan3 {
+			label = "wbmr300:green:lan3";
+			gpios = <&gpio 15 0>;
+		};
+
+		lan2: lan2 {
+			label = "wbmr300:green:lan2";
+			gpios = <&gpio 33 0>;
+		};
+
+		internet_g: internet_g {
+			label = "wbmr300:green:internet";
+			gpios = <&gpio 34 0>;
+		};
+
+		internet_y: internet_y {
+			label = "wbmr300:yellow:internet";
+			gpios = <&gpio 35 0>;
+		};
+
+		router_g: router_g {
+			label = "wbmr300:green:router";
+			gpios = <&gpio 36 0>;
+		};
+
+		power_g: power_g {
+			label = "wbmr300:green:power";
+			gpios = <&gpio 49 0>;
+		};
+	};
+};
+
+&spi {
+	pinctrl-names = "default";
+	pinctrl-0 = <&pins_spi_default>;
+
+	status = "ok";
+	m25p80@4 {
+		#address-cells = <1>;
+		#size-cells = <1>;
+		compatible = "jedec,spi-nor";
+		reg = <4 0>;
+		spi-max-frequency = <20000000>;
+
+		partition@0 {
+			reg = <0x0 0x10000>;
+			label = "u-boot";
+			read-only;
+		};
+
+		partition@10000 {
+			reg = <0x10000 0x10000>;
+			label = "gphyfirmware";
+			read-only;
+		};
+
+		partition@20000 {
+			reg = <0x20000 0x80000>;
+			label = "dsl_fw";
+		};
+
+		partition@de0000 {
+			reg = <0xa0000 0xf40000>;
+			label = "firmware";
+		};
+
+		partition@fe0000 {
+			reg = <0xfe0000 0x10000>;
+			label = "sysconfig";
+			read-only;
+		};
+
+		partition@ff0000 {
+			reg = <0xff0000 0x2000>;
+			label = "ubootconfig";
+		};
+
+		partition@ff3000 {
+			reg = <0xff3000 0x2000>;
+			label = "board_config";
+			read-only;
+		};
+	};
+};
+
+&eth0 {
+	lan: interface@0 {
+		compatible = "lantiq,xrx200-pdi";
+		#address-cells = <1>;
+		#size-cells = <0>;
+		reg = <0>;
+		lantiq,switch;
+
+		ethernet@1 {
+			compatible = "lantiq,xrx200-pdi-port";
+			reg = <4>;
+			phy-mode = "mii";
+			phy-handle = <&phy13>;
+		};
+		ethernet@2 {
+			compatible = "lantiq,xrx200-pdi-port";
+			reg = <5>;
+			phy-mode = "mii";
+			phy-handle = <&phy14>;
+		};
+		ethernet@3 {
+			compatible = "lantiq,xrx200-pdi-port";
+			reg = <2>;
+			phy-mode = "mii";
+			phy-handle = <&phy11>;
+		};
+		ethernet@4 {
+			compatible = "lantiq,xrx200-pdi-port";
+			reg = <3>;
+			phy-mode = "mii";
+			phy-handle = <&phy12>;
+		};
+	};
+
+	mdio@0 {
+		#address-cells = <1>;
+		#size-cells = <0>;
+		compatible = "lantiq,xrx200-mdio";
+		phy11: ethernet-phy@11 {
+			reg = <0x11>;
+			compatible = "lantiq,phy22f", "ethernet-phy-ieee802.3-c22";
+		};
+		phy12: ethernet-phy@12 {
+			reg = <0x12>;
+			compatible = "lantiq,phy22f", "ethernet-phy-ieee802.3-c22";
+		};
+		phy13: ethernet-phy@13 {
+			reg = <0x13>;
+			compatible = "lantiq,phy22f", "ethernet-phy-ieee802.3-c22";
+		};
+		phy14: ethernet-phy@14 {
+			reg = <0x14>;
+			compatible = "lantiq,phy22f", "ethernet-phy-ieee802.3-c22";
+		};
+	};
+};
diff --git a/target/linux/lantiq/image/Makefile b/target/linux/lantiq/image/Makefile
index b1a6a80..16c0820 100644
--- a/target/linux/lantiq/image/Makefile
+++ b/target/linux/lantiq/image/Makefile
@@ -647,6 +647,14 @@ Image/Build/Profile/VG3503J=$(call Image/BuildLoader/$(1),$(1),VG3503J)
 
 include tp-link.mk
 
+define Device/WBMR300
+  DEVICE_PROFILE := WBMR300
+  IMAGE_SIZE := 15616k
+  DEVICE_TITLE := Buffalo WBMR-300HPD
+  DEVICE_PACKAGES := kmod-mt76 wpad-mini kmod-usb-dwc2
+endef
+TARGET_DEVICES += WBMR300
+
 define Device/VGV7510KW22NOR
   DEVICE_PROFILE := VGV7510KW22NOR
   IMAGE_SIZE := 15232k
diff --git a/target/linux/lantiq/xrx200/config-default b/target/linux/lantiq/xrx200/config-default
index c40ecfe..42e846e 100644
--- a/target/linux/lantiq/xrx200/config-default
+++ b/target/linux/lantiq/xrx200/config-default
@@ -27,6 +27,9 @@ CONFIG_MTD_UBI_BLOCK=y
 CONFIG_MTD_UBI_WL_THRESHOLD=4096
 CONFIG_NLS=y
 CONFIG_PCIE_LANTIQ=y
+CONFIG_POWER_RESET=y
+CONFIG_POWER_RESET_GPIO=y
+CONFIG_POWER_SUPPLY=y
 CONFIG_RTL8306_PHY=y
 CONFIG_RTL8366S_PHY=y
 CONFIG_RTL8367B_PHY=y
-- 
cgit v1.1