[LEDE-DEV] [PATCH] ramips: Add support for GL-MT300N-V2

Mathias Kresin dev at kresin.me
Thu May 4 12:29:18 PDT 2017


Hey kysonlok,

thanks a lot for your contribution. Find my comments inline.

04.05.2017 08:41, kysonlok:
> This patches adds support for GL-MT300N-V2 router.
>
> Signed-off-by: kysonlok <kysonlok at gmail.com>

We have a realname policy for signed off by lines.

> ---
>  target/linux/ramips/base-files/etc/board.d/01_leds |   1 +
>  .../linux/ramips/base-files/etc/board.d/02_network |   1 +
>  target/linux/ramips/base-files/lib/ramips.sh       |   3 +
>  .../ramips/base-files/lib/upgrade/platform.sh      |   1 +
>  target/linux/ramips/dts/GL-MT300N-V2.dts           | 135 +++++++++++++++++++++
>  target/linux/ramips/image/mt7628.mk                |   8 ++
>  6 files changed, 149 insertions(+)
>  create mode 100644 target/linux/ramips/dts/GL-MT300N-V2.dts
>
> diff --git a/target/linux/ramips/base-files/etc/board.d/01_leds b/target/linux/ramips/base-files/etc/board.d/01_leds
> index 52542ec..101c1c2 100755
> --- a/target/linux/ramips/base-files/etc/board.d/01_leds
> +++ b/target/linux/ramips/base-files/etc/board.d/01_leds
> @@ -186,6 +186,7 @@ fonera20n)
>  	;;
>  gl-mt300a|\
>  gl-mt300n|\
> +gl-mt300n-v2|\
>  gl-mt750)
>  	set_wifi_led "$board:wlan"
>  	;;
> diff --git a/target/linux/ramips/base-files/etc/board.d/02_network b/target/linux/ramips/base-files/etc/board.d/02_network
> index 80a3bc2..6af0065 100755
> --- a/target/linux/ramips/base-files/etc/board.d/02_network
> +++ b/target/linux/ramips/base-files/etc/board.d/02_network
> @@ -156,6 +156,7 @@ ramips_setup_interfaces()
>  	f5d8235-v2|\
>  	gl-mt300a|\
>  	gl-mt300n|\
> +	gl-mt300n-v2|\
>  	gl-mt750|\
>  	hg255d|\
>  	jhr-n805r|\
> diff --git a/target/linux/ramips/base-files/lib/ramips.sh b/target/linux/ramips/base-files/lib/ramips.sh
> index 87cb7ff..1e031cd 100755
> --- a/target/linux/ramips/base-files/lib/ramips.sh
> +++ b/target/linux/ramips/base-files/lib/ramips.sh
> @@ -214,6 +214,9 @@ ramips_board_detect() {
>  	*"GL-MT300N")
>  		name="gl-mt300n"
>  		;;
> +	*"GL-MT300N-V2")
> +		name="gl-mt300n-v2"
> +		;;
>  	*"GL-MT750")
>  		name="gl-mt750"
>  		;;
> diff --git a/target/linux/ramips/base-files/lib/upgrade/platform.sh b/target/linux/ramips/base-files/lib/upgrade/platform.sh
> index adad8da..2c50c3c 100755
> --- a/target/linux/ramips/base-files/lib/upgrade/platform.sh
> +++ b/target/linux/ramips/base-files/lib/upgrade/platform.sh
> @@ -64,6 +64,7 @@ platform_check_image() {
>  	freestation5|\
>  	gl-mt300a|\
>  	gl-mt300n|\
> +	gl-mt300n-v2|\
>  	gl-mt750|\
>  	hc5*61|\
>  	hc5661a|\
> diff --git a/target/linux/ramips/dts/GL-MT300N-V2.dts b/target/linux/ramips/dts/GL-MT300N-V2.dts
> new file mode 100644
> index 0000000..bf64c99
> --- /dev/null
> +++ b/target/linux/ramips/dts/GL-MT300N-V2.dts
> @@ -0,0 +1,135 @@
> +/dts-v1/;
> +
> +#include "mt7628an.dtsi"
> +
> +#include <dt-bindings/gpio/gpio.h>
> +#include <dt-bindings/input/input.h>
> +
> +/{
> +	compatible = "GL-MT300N-V2", "ralink,mt7620an-soc";

The compatible string is "vendor,boardname":

compatible = "gli,gl-mt300n-v2", "ralink,mt7620an-soc";

> +	model = "GL-MT300N-V2";
> +
> +	chosen {
> +		bootargs = "console=ttyS0,115200";
> +	};
> +
> +	memory at 0 {
> +		device_type = "memory";
> +		reg = <0x0 0x4000000>;
> +	};
> +
> +	gpio-leds {
> +		compatible = "gpio-leds";
> +
> +		usbpow {
> +			label = "gl-mt300n-v2:usbpow";

Please add the led colour to the label. The format has to be 
device:colour:function.

I couldn't find any information about the gl-mt300n-v2, but I would be 
surprised if they dropped the lan LED and added a usb led instead. Would 
you please ensure that this LED is really meant to be used for usb.

> +			gpios = <&gpio0 11 1>;

Please use the GPIO_ACTIVE_LOW and GPIO_ACTIVE_HIGH macros provided by 
dt-bindings/gpio/gpio.h instead of 1 and 0 in the gpio parameters (as 
you have done it for the reset button).

> +		};
> +
> +		wan {
> +			label = "gl-mt300n-v2:wan";
> +			gpios = <&gpio1 11 1>;
> +		};
> +
> +		wlan {
> +			label = "gl-mt300n-v2:wlan";
> +			gpios = <&gpio1 12 1>;
> +		};
> +	};
> +
> +	gpio-keys {
> +		compatible = "gpio-keys-polled";
> +		#address-cells = <1>;
> +		#size-cells = <0>;
> +		poll-interval = <20>;
> +
> +		reset {
> +			label = "reset";
> +			gpios = <&gpio1 6 GPIO_ACTIVE_LOW>;
> +			linux,code = <KEY_RESTART>;
> +		};
> +
> +		BIT_0 {

Typo? Could it be that this should be BTN_0 and BTN_1

> +			label = "BIT_0";
> +			gpios = <&gpio0 0 1>;
> +			linux,code = <0x100>;

Please use the BTN_0 and BTN_1 macro from

> +		};
> +
> +		BIT_1 {
> +			label = "BIT_1";
> +			gpios = <&gpio0 3 1>;
> +			linux,code = <0x101>;
> +		};
> +	};
> +
> +};
> +
> +&pinctrl {
> +	state_default: pinctrl0 {
> +		gpio {
> +			ralink,group = "refclk", "gpio", "wled_an", "p0led_an", "p1led_an", "i2c", "i2s";
> +			ralink,function = "gpio";
> +		};
> +	};
> +};
> +
> +&ethernet {
> +	mtd-mac-address = <&factory 0x04000>;
> +};
> +
> +&wmac {
> +	status = "okay";
> +	ralink,mtd-eeprom = <&factory 0x04000>;
> +};
> +
> +&i2c {
> +	status = "okay";
> +};
> +
> +&spi0 {
> +	status = "okay";
> +
> +	m25p80 at 0 {
> +		#address-cells = <1>;
> +		#size-cells = <1>;
> +		compatible = "jedec,spi-nor";
> +		reg = <0>;
> +		spi-max-frequency = <10000000>;
> +		m25p,chunked-io = <32>;
> +
> +		partition at 0 {
> +			label = "u-boot";
> +			reg = <0x0 0x30000>;
> +			read-only;
> +		};
> +
> +		partition at 30000 {
> +			label = "u-boot-env";
> +			reg = <0x30000 0x10000>;
> +			read-only;
> +		};
> +
> +		factory: partition at 40000 {
> +			label = "factory";
> +			reg = <0x40000 0x10000>;
> +			read-only;
> +		};
> +
> +		partition at 50000 {
> +			label = "firmware";
> +			reg = <0x50000 0xf00000>;
> +		};
> +	};
> +};
> +
> +&sdhci {
> +	status = "okay";
> +};
> +
> +&ehci {
> +	status = "okay";
> +};
> +
> +&ohci {
> +	status = "okay";
> +};
> diff --git a/target/linux/ramips/image/mt7628.mk b/target/linux/ramips/image/mt7628.mk
> index 6bb04ea..90c7969 100644
> --- a/target/linux/ramips/image/mt7628.mk
> +++ b/target/linux/ramips/image/mt7628.mk
> @@ -26,6 +26,14 @@ define Device/miwifi-nano
>  endef
>  TARGET_DEVICES += miwifi-nano
>
> +define Device/gl-mt300n-v2
> +  DTS := GL-MT300N-V2
> +  IMAGE_SIZE := $(ralink_default_fw_size_16M)
> +  DEVICE_TITLE := GL-iNet GL-MT300N-V2
> +  DEVICE_PACKAGES := kmod-usb2 kmod-usb-ohci kmod-usb-ledtrig-usbport

If you add the kmod-usb-ledtrig-usbport, you should setup the usb led in 
target/linux/ramips/base-files/etc/board.d/01_leds as well.

> +endef
> +TARGET_DEVICES += gl-mt300n-v2
> +
>  define Device/vocore2
>    DTS := VOCORE2
>    IMAGE_SIZE := $(ralink_default_fw_size_16M)
>




More information about the Lede-dev mailing list