From: John Crispin Date: Mon, 19 Oct 2015 10:07:38 +0000 (+0000) Subject: ramips: add LinkIt Smart7688 support X-Git-Tag: reboot~1798 X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=51dd991d3957a33f102c9887da379263599c395f;p=openwrt%2Fstaging%2Flynxis.git ramips: add LinkIt Smart7688 support Signed-off-by: John Crispin SVN-Revision: 47203 --- diff --git a/package/boot/uboot-envtools/files/ramips b/package/boot/uboot-envtools/files/ramips index 5ddaed0ee8..4640f4326c 100644 --- a/package/boot/uboot-envtools/files/ramips +++ b/package/boot/uboot-envtools/files/ramips @@ -19,6 +19,7 @@ all0256n | \ all5002) ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x10000" "0x10000" ;; +linkits7688 | \ wsr-600 | \ wsr-1166 | \ br6425) 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 94d69b9e7e..07327968fc 100755 --- a/target/linux/ramips/base-files/etc/board.d/02_network +++ b/target/linux/ramips/base-files/etc/board.d/02_network @@ -46,6 +46,8 @@ ramips_setup_interfaces() dcs-930|\ dcs-930l-b1|\ ht-tm02|\ + linkits7688 | \ + linkits7688d | \ microwrt|\ ncs601w|\ w150m|\ @@ -302,6 +304,11 @@ ramips_setup_macs() ht-tm02) lan_mac=$(cat /sys/class/net/eth0/address) ;; + linkits7688 | \ + linkits7688d) + wan_mac=$(mtd_get_mac_binary factory 4) + lan_mac=$(mtd_get_mac_binary factory 46) + ;; m3|\ m4|\ x5|\ diff --git a/target/linux/ramips/base-files/lib/ramips.sh b/target/linux/ramips/base-files/lib/ramips.sh index b89a88c27c..340bc4c3b3 100755 --- a/target/linux/ramips/base-files/lib/ramips.sh +++ b/target/linux/ramips/base-files/lib/ramips.sh @@ -202,6 +202,15 @@ ramips_board_detect() { *"M4") name="m4" ;; + *"MediaTek LinkIt Smart7688") + linkit="$(dd bs=1 skip=1024 count=12 if=/dev/mtd2 2> /dev/null)" + if [ "${linkit}" = "LINKITS7688D" ]; then + name="linkits7688d" + RAMIPS_MODEL="${machine} DUO" + else + name="linkits7688" + fi + ;; *"Memory 2 Move") name="m2m" ;; diff --git a/target/linux/ramips/base-files/lib/upgrade/platform.sh b/target/linux/ramips/base-files/lib/upgrade/platform.sh index 44d41c1406..d3d9df3a0f 100755 --- a/target/linux/ramips/base-files/lib/upgrade/platform.sh +++ b/target/linux/ramips/base-files/lib/upgrade/platform.sh @@ -62,6 +62,8 @@ platform_check_image() { ht-tm02|\ hw550-3g|\ ip2202|\ + linkits7688|\ + linkits7688d|\ m2m|\ m3|\ m4|\ diff --git a/target/linux/ramips/dts/LINKIT7688.dts b/target/linux/ramips/dts/LINKIT7688.dts new file mode 100644 index 0000000000..4d1b96474c --- /dev/null +++ b/target/linux/ramips/dts/LINKIT7688.dts @@ -0,0 +1,173 @@ +/dts-v1/; + +/include/ "mt7628an.dtsi" + +/ { + compatible = "mediatek,linkit", "mediatek,mt7628an-soc"; + model = "MediaTek LinkIt Smart7688"; + + chosen { + bootargs = "console=ttyS2,57600"; + }; + + memory@0 { + device_type = "memory"; + reg = <0x0 0x8000000>; + }; + + pinctrl { + state_default: pinctrl0 { + gpio { + ralink,group = "gpio"; + ralink,function = "gpio"; + }; + + perst { + ralink,group = "perst"; + ralink,function = "gpio"; + }; + + refclk { + ralink,group = "refclk"; + ralink,function = "gpio"; + }; + + i2s { + ralink,group = "i2s"; + ralink,function = "gpio"; + }; + + spis { + ralink,group = "spis"; + ralink,function = "gpio"; + }; + + wled_kn { + ralink,group = "wled_kn"; + ralink,function = "gpio"; + }; + + wled_an { + ralink,group = "wled_an"; + ralink,function = "wled_an"; + }; + + wdt { + ralink,group = "wdt"; + ralink,function = "gpio"; + }; + }; + }; + + palmbus@10000000 { + spi@b00 { + status = "okay"; + + pinctrl-names = "default"; + pinctrl-0 = <&spi_pins>, <&spi_cs1_pins>; + + m25p80@0 { + #address-cells = <1>; + #size-cells = <1>; + compatible = "mx25l25635e"; + reg = <0 0>; + linux,modalias = "m25p80", "mx25l25635e"; + spi-max-frequency = <40000000>; + m25p,chunked-io = <31>; + + partition@0 { + label = "u-boot"; + reg = <0x0 0x30000>; + read-only; + }; + + partition@30000 { + label = "u-boot-env"; + reg = <0x30000 0x10000>; + }; + + factory: partition@40000 { + label = "factory"; + reg = <0x40000 0x10000>; + read-only; + }; + + partition@50000 { + label = "firmware"; + reg = <0x50000 0x1fb0000>; + }; + }; + + spidev@1 { + #address-cells = <1>; + #size-cells = <1>; + compatible = "spidev"; + reg = <1 0>; + spi-max-frequency = <40000000>; + }; + }; + + i2c@900 { + status = "okay"; + }; + + uart1@d00 { + status = "okay"; + }; + + uart2@e00 { + status = "okay"; + }; + + pwm@5000 { + status = "okay"; + }; + }; + + ethernet@10100000 { + mtd-mac-address = <&factory 0x28>; + }; + + sdhci@10130000 { + status = "okay"; + mediatek,cd-high; + }; + + bootstrap { + compatible = "mediatek,linkit"; + + status = "okay"; + }; + + gpio-leds { + compatible = "gpio-leds"; + + wifi { + label = "mediatek:orange:wifi"; + gpios = <&wgpio 0 0>; + default-state = "on"; + }; + }; + + gpio-keys-polled { + compatible = "gpio-keys-polled"; + #address-cells = <1>; + #size-cells = <0>; + poll-interval = <20>; + + wps { + label = "reset"; + gpios = <&gpio1 6 1>; + linux,code = <0x211>; + }; + }; + + wgpio: gpio-wifi { + compatible = "mediatek,gpio-wifi"; + #address-cells = <1>; + #size-cells = <0>; + gpio-controller; + #gpio-cells = <2>; + }; + +}; diff --git a/target/linux/ramips/image/Makefile b/target/linux/ramips/image/Makefile index 117e07d4ef..c66409d75f 100644 --- a/target/linux/ramips/image/Makefile +++ b/target/linux/ramips/image/Makefile @@ -201,6 +201,10 @@ ralink_default_fw_size_16M=16121856 BuildFirmware/Default16M/squashfs=$(call BuildFirmware/OF,$(1),$(2),$(3),$(ralink_default_fw_size_16M),$(4)) BuildFirmware/Default16M/initramfs=$(call BuildFirmware/OF/initramfs,$(1),$(2),$(3),$(4)) +ralink_default_fw_size_32M=33226752 +BuildFirmware/Default32M/squashfs=$(call BuildFirmware/OF,$(1),$(2),$(3),$(ralink_default_fw_size_32M),$(4)) +BuildFirmware/Default32M/initramfs=$(call BuildFirmware/OF/initramfs,$(1),$(2),$(3),$(4)) + # Build images for a custom sized flash layout # $(1) = squashfs/initramfs # $(2) = lowercase board name @@ -1014,10 +1018,12 @@ endif # Image/Build/Profile/mt7688=$(call BuildFirmware/Default16M/$(1),$(1),mt7688,MT7688) +Image/Build/Profile/LinkIt7688=$(call BuildFirmware/Default32M/$(1),$(1),LinkIt7688,LINKIT7688) ifeq ($(SUBTARGET),mt7688) define Image/Build/Profile/Default $(call Image/Build/Profile/mt7688,$(1)) + $(call Image/Build/Profile/LinkIt7688,$(1)) endef endif diff --git a/target/linux/ramips/mt7688/config-3.18 b/target/linux/ramips/mt7688/config-3.18 index b828b997e2..27eab9a4fe 100644 --- a/target/linux/ramips/mt7688/config-3.18 +++ b/target/linux/ramips/mt7688/config-3.18 @@ -103,6 +103,7 @@ CONFIG_IRQ_FORCED_THREADING=y CONFIG_IRQ_INTC=y CONFIG_IRQ_WORK=y CONFIG_LIBFDT=y +CONFIG_LINKIT_BOOTSTRAP=y CONFIG_MDIO_BOARDINFO=y CONFIG_MIPS=y CONFIG_MIPS_FPU_EMULATOR=y @@ -149,6 +150,10 @@ CONFIG_PINCTRL=y CONFIG_PINCTRL_RT2880=y # CONFIG_PINCTRL_SINGLE is not set # CONFIG_PREEMPT_RCU is not set +CONFIG_PWM=y +# CONFIG_PWM_FSL_FTM is not set +CONFIG_PWM_MEDIATEK=y +CONFIG_PWM_SYSFS=y CONFIG_RALINK=y # CONFIG_RALINK_WDT is not set # CONFIG_RCU_STALL_COMMON is not set @@ -165,10 +170,13 @@ CONFIG_SOC_MT7620=y # CONFIG_SOC_RT288X is not set # CONFIG_SOC_RT305X is not set # CONFIG_SOC_RT3883 is not set +# CONFIG_SND_MT76XX_SOC_MT7620 is not set +CONFIG_SND_MT76XX_SOC_MT7628=y CONFIG_SPI=y CONFIG_SPI_MASTER=y CONFIG_SPI_MT7621=y # CONFIG_SPI_RT2880 is not set +CONFIG_SPI_SPIDEV=y CONFIG_SWCONFIG=y CONFIG_SYS_HAS_CPU_MIPS32_R1=y CONFIG_SYS_HAS_CPU_MIPS32_R2=y diff --git a/target/linux/ramips/mt7688/profiles/01-mediatek.mk b/target/linux/ramips/mt7688/profiles/01-mediatek.mk index 02190dd3ab..0e24e0686c 100644 --- a/target/linux/ramips/mt7688/profiles/01-mediatek.mk +++ b/target/linux/ramips/mt7688/profiles/01-mediatek.mk @@ -16,3 +16,15 @@ define Profile/mt7688/Description Default package set compatible with most boards. endef $(eval $(call Profile,mt7688)) + +define Profile/LinkIt7688 + NAME:=LinkIt7688 + PACKAGES:=\ + kmod-usb-core kmod-usb2 kmod-usb-ohci \ + uboot-envtools kmod-ledtrig-netdev +endef + +define Profile/LinkIt7688/Description + Default package set compatible with LinkIt Smart7688 dev board. +endef +$(eval $(call Profile,LinkIt7688)) diff --git a/target/linux/ramips/patches-3.18/0200-linkit_bootstrap.patch b/target/linux/ramips/patches-3.18/0200-linkit_bootstrap.patch new file mode 100644 index 0000000000..1471c7d329 --- /dev/null +++ b/target/linux/ramips/patches-3.18/0200-linkit_bootstrap.patch @@ -0,0 +1,94 @@ +--- a/drivers/misc/Makefile ++++ b/drivers/misc/Makefile +@@ -56,3 +56,4 @@ + obj-$(CONFIG_ECHO) += echo/ + obj-$(CONFIG_VEXPRESS_SYSCFG) += vexpress-syscfg.o + obj-$(CONFIG_CXL_BASE) += cxl/ ++obj-$(CONFIG_SOC_MT7620) += linkit.o +--- /dev/null ++++ b/drivers/misc/linkit.c +@@ -0,0 +1,84 @@ ++/* ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License version 2 as ++ * publishhed by the Free Software Foundation. ++ * ++ * Copyright (C) 2015 John Crispin ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++ ++#define LINKIT_LATCH_GPIO 11 ++ ++struct linkit_hw_data { ++ char board[16]; ++ char rev[16]; ++}; ++ ++static void sanify_string(char *s) ++{ ++ int i; ++ ++ for (i = 0; i < 15; i++) ++ if (s[i] <= 0x20) ++ s[i] = '\0'; ++ s[15] = '\0'; ++} ++ ++static int linkit_probe(struct platform_device *pdev) ++{ ++ struct linkit_hw_data hw; ++ struct mtd_info *mtd; ++ size_t retlen; ++ int ret; ++ ++ mtd = get_mtd_device_nm("factory"); ++ if (IS_ERR(mtd)) ++ return PTR_ERR(mtd); ++ ++ ret = mtd_read(mtd, 0x400, sizeof(hw), &retlen, (u_char *) &hw); ++ put_mtd_device(mtd); ++ ++ sanify_string(hw.board); ++ sanify_string(hw.rev); ++ ++ dev_info(&pdev->dev, "Version : %s\n", hw.board); ++ dev_info(&pdev->dev, "Revision : %s\n", hw.rev); ++ ++ if (!strcmp(hw.board, "LINKITS7688")) { ++ dev_info(&pdev->dev, "setting up bootstrap latch\n"); ++ ++ if (devm_gpio_request(&pdev->dev, LINKIT_LATCH_GPIO, "bootstrap")) { ++ dev_err(&pdev->dev, "failed to setup bootstrap gpio\n"); ++ return -1; ++ } ++ gpio_direction_output(LINKIT_LATCH_GPIO, 0); ++ } ++ ++ return 0; ++} ++ ++static const struct of_device_id linkit_match[] = { ++ { .compatible = "mediatek,linkit" }, ++ {}, ++}; ++MODULE_DEVICE_TABLE(of, linkit_match); ++ ++static struct platform_driver linkit_driver = { ++ .probe = linkit_probe, ++ .driver = { ++ .name = "mtk-linkit", ++ .owner = THIS_MODULE, ++ .of_match_table = linkit_match, ++ }, ++}; ++ ++int __init linkit_init(void) ++{ ++ return platform_driver_register(&linkit_driver); ++} ++late_initcall_sync(linkit_init);