ramips: add LinkIt Smart7688 support

Signed-off-by: John Crispin <blogic@openwrt.org>

SVN-Revision: 47203
This commit is contained in:
John Crispin 2015-10-19 10:07:38 +00:00
parent b792ea7ac0
commit 51dd991d39
9 changed files with 312 additions and 0 deletions

View file

@ -19,6 +19,7 @@ all0256n | \
all5002) all5002)
ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x10000" "0x10000" ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x10000" "0x10000"
;; ;;
linkits7688 | \
wsr-600 | \ wsr-600 | \
wsr-1166 | \ wsr-1166 | \
br6425) br6425)

View file

@ -46,6 +46,8 @@ ramips_setup_interfaces()
dcs-930|\ dcs-930|\
dcs-930l-b1|\ dcs-930l-b1|\
ht-tm02|\ ht-tm02|\
linkits7688 | \
linkits7688d | \
microwrt|\ microwrt|\
ncs601w|\ ncs601w|\
w150m|\ w150m|\
@ -302,6 +304,11 @@ ramips_setup_macs()
ht-tm02) ht-tm02)
lan_mac=$(cat /sys/class/net/eth0/address) 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|\ m3|\
m4|\ m4|\
x5|\ x5|\

View file

@ -202,6 +202,15 @@ ramips_board_detect() {
*"M4") *"M4")
name="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") *"Memory 2 Move")
name="m2m" name="m2m"
;; ;;

View file

@ -62,6 +62,8 @@ platform_check_image() {
ht-tm02|\ ht-tm02|\
hw550-3g|\ hw550-3g|\
ip2202|\ ip2202|\
linkits7688|\
linkits7688d|\
m2m|\ m2m|\
m3|\ m3|\
m4|\ m4|\

View file

@ -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>;
};
};

View file

@ -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/squashfs=$(call BuildFirmware/OF,$(1),$(2),$(3),$(ralink_default_fw_size_16M),$(4))
BuildFirmware/Default16M/initramfs=$(call BuildFirmware/OF/initramfs,$(1),$(2),$(3),$(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 # Build images for a custom sized flash layout
# $(1) = squashfs/initramfs # $(1) = squashfs/initramfs
# $(2) = lowercase board name # $(2) = lowercase board name
@ -1014,10 +1018,12 @@ endif
# #
Image/Build/Profile/mt7688=$(call BuildFirmware/Default16M/$(1),$(1),mt7688,MT7688) 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) ifeq ($(SUBTARGET),mt7688)
define Image/Build/Profile/Default define Image/Build/Profile/Default
$(call Image/Build/Profile/mt7688,$(1)) $(call Image/Build/Profile/mt7688,$(1))
$(call Image/Build/Profile/LinkIt7688,$(1))
endef endef
endif endif

View file

@ -103,6 +103,7 @@ CONFIG_IRQ_FORCED_THREADING=y
CONFIG_IRQ_INTC=y CONFIG_IRQ_INTC=y
CONFIG_IRQ_WORK=y CONFIG_IRQ_WORK=y
CONFIG_LIBFDT=y CONFIG_LIBFDT=y
CONFIG_LINKIT_BOOTSTRAP=y
CONFIG_MDIO_BOARDINFO=y CONFIG_MDIO_BOARDINFO=y
CONFIG_MIPS=y CONFIG_MIPS=y
CONFIG_MIPS_FPU_EMULATOR=y CONFIG_MIPS_FPU_EMULATOR=y
@ -149,6 +150,10 @@ CONFIG_PINCTRL=y
CONFIG_PINCTRL_RT2880=y CONFIG_PINCTRL_RT2880=y
# CONFIG_PINCTRL_SINGLE is not set # CONFIG_PINCTRL_SINGLE is not set
# CONFIG_PREEMPT_RCU 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=y
# CONFIG_RALINK_WDT is not set # CONFIG_RALINK_WDT is not set
# CONFIG_RCU_STALL_COMMON 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_RT288X is not set
# CONFIG_SOC_RT305X is not set # CONFIG_SOC_RT305X is not set
# CONFIG_SOC_RT3883 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=y
CONFIG_SPI_MASTER=y CONFIG_SPI_MASTER=y
CONFIG_SPI_MT7621=y CONFIG_SPI_MT7621=y
# CONFIG_SPI_RT2880 is not set # CONFIG_SPI_RT2880 is not set
CONFIG_SPI_SPIDEV=y
CONFIG_SWCONFIG=y CONFIG_SWCONFIG=y
CONFIG_SYS_HAS_CPU_MIPS32_R1=y CONFIG_SYS_HAS_CPU_MIPS32_R1=y
CONFIG_SYS_HAS_CPU_MIPS32_R2=y CONFIG_SYS_HAS_CPU_MIPS32_R2=y

View file

@ -16,3 +16,15 @@ define Profile/mt7688/Description
Default package set compatible with most boards. Default package set compatible with most boards.
endef endef
$(eval $(call Profile,mt7688)) $(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))

View file

@ -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 <blogic@openwrt.org>
+ */
+
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/of.h>
+#include <linux/mtd/mtd.h>
+#include <linux/gpio.h>
+
+#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);