This patch adds support for Tenda W300A access point. Based on trunk / r31151.
More info available also on http://wiki.openwrt.org/toh/tenda/w300a
Signed-off-by: Tomas Menzl <tomasamot at googlemail.com>
---
Index: target/linux/ramips/rt288x/profiles/tenda.mk
===================================================================
--- target/linux/ramips/rt288x/profiles/tenda.mk (revision 0)
+++ target/linux/ramips/rt288x/profiles/tenda.mk (revision 0)
@@ -0,0 +1,18 @@
+#
+# Copyright (C) 2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+define Profile/W300A
+ NAME:=Tenda W300A
+ PACKAGES:=kmod-phy
+endef
+
+define Profile/W300A/Description
+ Package set for Tenda W300A board
+endef
+
+$(eval $(call Profile,W300A))
+
Index: target/linux/ramips/rt288x/config-3.2
===================================================================
--- target/linux/ramips/rt288x/config-3.2 (revision 31152)
+++ target/linux/ramips/rt288x/config-3.2 (working copy)
@@ -66,6 +66,7 @@
CONFIG_IRQ_FORCED_THREADING=y
# CONFIG_LANTIQ is not set
# CONFIG_LEDS_GPIO is not set
+CONFIG_MDIO_BOARDINFO=y
# CONFIG_MII is not set
# CONFIG_MINIX_FS_NATIVE_ENDIAN is not set
CONFIG_MIPS=y
@@ -99,6 +100,7 @@
CONFIG_RT288X_MACH_F5D8235_V1=y
CONFIG_RT288X_MACH_RT_N15=y
CONFIG_RT288X_MACH_V11ST_FE=y
+CONFIG_RT288X_MACH_W300A=y
CONFIG_RT288X_MACH_WLI_TX4_AG300N=y
CONFIG_RT288X_MACH_WZR_AGL300NH=y
CONFIG_RTL8366S_PHY=y
@@ -118,5 +120,8 @@
CONFIG_SYS_SUPPORTS_LITTLE_ENDIAN=y
CONFIG_USB_ARCH_HAS_XHCI=y
CONFIG_USB_SUPPORT=y
+CONFIG_VITESSE_PHY=y
+CONFIG_VITESSE_PHY_8601_W300A_LEDS=y
+CONFIG_VITESSE_PHY_8601_SKEW=y
CONFIG_XZ_DEC=y
CONFIG_ZONE_DMA_FLAG=0
Index: target/linux/ramips/files/arch/mips/ralink/rt288x/Kconfig
===================================================================
--- target/linux/ramips/files/arch/mips/ralink/rt288x/Kconfig (revision 31152)
+++ target/linux/ramips/files/arch/mips/ralink/rt288x/Kconfig (working copy)
@@ -17,6 +17,12 @@
select RALINK_DEV_GPIO_BUTTONS
select RALINK_DEV_GPIO_LEDS
+config RT288X_MACH_W300A
+ bool "Tenda W300A board support"
+ select HW_HAS_PCI
+ select RALINK_DEV_GPIO_BUTTONS
+ select RALINK_DEV_GPIO_LEDS
+
config RT288X_MACH_WLI_TX4_AG300N
bool "Buffalo WLI-TX4-AG300N board support"
select RALINK_DEV_GPIO_BUTTONS
Index: target/linux/ramips/files/arch/mips/ralink/rt288x/mach-w300a.c
===================================================================
--- target/linux/ramips/files/arch/mips/ralink/rt288x/mach-w300a.c
(revision 0)
+++ target/linux/ramips/files/arch/mips/ralink/rt288x/mach-w300a.c
(revision 0)
@@ -0,0 +1,132 @@
+/*
+ * Tenda W300A board support
+ *
+ *
+ * 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 published
+ * by the Free Software Foundation.
+ */
+
+#include <linux/init.h>
+#include <linux/platform_device.h>
+#include <linux/ethtool.h>
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/partitions.h>
+#include <linux/mtd/physmap.h>
+
+#include <asm/mach-ralink/machine.h>
+#include <asm/mach-ralink/dev-gpio-buttons.h>
+#include <asm/mach-ralink/dev-gpio-leds.h>
+#include <asm/mach-ralink/rt288x.h>
+#include <asm/mach-ralink/rt288x_regs.h>
+#include <asm/mach-ralink/ramips_eth_platform.h>
+
+#include "devices.h"
+
+#define W300A_GPIO_LED_WPS 11
+#define W300A_GPIO_LED_SYS 12
+#define W300A_GPIO_BUTTON_RESET 0
+
+#define W300A_KEYS_POLL_INTERVAL 20
+#define W300A_KEYS_DEBOUNCE_INTERVAL (3 * W300A_KEYS_POLL_INTERVAL)
+
+/*
+From stock firmware:
+ dev: size erasesize name
+ mtd0: 00030000 00010000 "Bootloader"
+ mtd1: 00010000 00010000 "Config "
+ mtd2: 00010000 00010000 "Factory"
+ mtd3: 003b0000 00010000 "Kernel"
+
+ 0x00000000-0x00030000 : "Bootloader"
+ 0x00030000-0x00040000 : "Config "
+ 0x00040000-0x00050000 : "Factory"
+ 0x00050000-0x00400000 : "Kernel"
+
+mtdlayout_4M=192k(u-boot)ro,64k(u-boot-env)ro,64k(factory)ro,896k(kernel),2880k(rootfs),3776k@0x50000(firmware)
+*/
+
+static struct mtd_partition w300a_partitions[] = {
+ {
+ .name = "u-boot",
+ .offset = 0,
+ .size = 0x030000, // 192KB = 196608 = 0x030000
+ .mask_flags = MTD_WRITEABLE,
+ }, {
+ .name = "u-boot-env",
+ .offset = 0x030000,
+ .size = 0x010000, // 64KB = 65536 = 0x010000
+ .mask_flags = MTD_WRITEABLE,
+ }, {
+ .name = "factory",
+ .offset = 0x040000,
+ .size = 0x010000, // 64KB = 65536 = 0x010000
+ .mask_flags = MTD_WRITEABLE,
+ }, {
+ .name = "kernel",
+ .offset = 0x050000,
+ .size = 0x0E0000, // 896KB = 917504 = 0x0E0000
+ } , {
+ .name = "rootfs",
+ .offset = 0x130000, // 0x050000 + 0x0E0000 = 0x130000
+ .size = 0x2d0000, // 2880KB = 2949120 = 2D0000,
end=0x400000=4MB
+ }, {
+ .name = "firmware",
+ .offset = 0x050000,
+ .size = 0x3b0000, //3776KB = 3866624 = 0x3B0000
+ }
+};
+
+static struct gpio_led w300a_leds_gpio[] __initdata = {
+ {
+ .name = "w300a:green:wps",
+ .gpio = W300A_GPIO_LED_WPS,
+ .active_low = 1,
+ },
+ {
+ .name = "w300a:green:sys",
+ .gpio = W300A_GPIO_LED_SYS,
+ .active_low = 1,
+ }
+};
+
+static struct gpio_keys_button w300a_gpio_buttons[] __initdata = {
+ {
+ .desc = "reset",
+ .type = EV_KEY,
+ .code = KEY_RESTART,
+ .debounce_interval = W300A_KEYS_DEBOUNCE_INTERVAL,
+ .gpio = W300A_GPIO_BUTTON_RESET,
+ .active_low = 1,
+ },
+};
+
+static void __init w300a_init(void)
+{
+ rt288x_gpio_init(RT2880_GPIO_MODE_UART0);
+
+ rt288x_flash0_data.nr_parts = ARRAY_SIZE(w300a_partitions);
+ rt288x_flash0_data.parts = w300a_partitions;
+ rt288x_register_flash(0);
+
+ rt288x_eth_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
+ rt288x_eth_data.speed = SPEED_1000;
+ rt288x_eth_data.duplex = DUPLEX_FULL;
+ rt288x_eth_data.tx_fc = 1;
+ rt288x_eth_data.rx_fc = 1;
+ rt288x_eth_data.phy_mask = BIT(6);
+ rt288x_register_ethernet();
+
+ ramips_register_gpio_leds(-1, ARRAY_SIZE(w300a_leds_gpio),
+ w300a_leds_gpio);
+
+ ramips_register_gpio_buttons(-1, W300A_KEYS_POLL_INTERVAL,
+ ARRAY_SIZE(w300a_gpio_buttons),
+ w300a_gpio_buttons);
+
+ rt288x_register_wifi();
+ rt288x_register_wdt();
+ rt288x_register_pci();
+}
+
+MIPS_MACHINE(RAMIPS_MACH_W300A, "W300A", "Tenda W300A", w300a_init);
Index: target/linux/ramips/files/arch/mips/ralink/rt288x/Makefile
===================================================================
--- target/linux/ramips/files/arch/mips/ralink/rt288x/Makefile (revision 31152)
+++ target/linux/ramips/files/arch/mips/ralink/rt288x/Makefile (working copy)
@@ -16,5 +16,6 @@
obj-$(CONFIG_RT288X_MACH_F5D8235_V1) += mach-f5d8235-v1.o
obj-$(CONFIG_RT288X_MACH_RT_N15) += mach-rt-n15.o
obj-$(CONFIG_RT288X_MACH_V11ST_FE) += mach-v11st-fe.o
+obj-$(CONFIG_RT288X_MACH_W300A) += mach-w300a.o
obj-$(CONFIG_RT288X_MACH_WLI_TX4_AG300N) += mach-wli-tx4-ag300n.o
obj-$(CONFIG_RT288X_MACH_WZR_AGL300NH) += mach-wzr-agl300nh.o
Index: target/linux/ramips/files/arch/mips/include/asm/mach-ralink/machine.h
===================================================================
--- target/linux/ramips/files/arch/mips/include/asm/mach-ralink/machine.h
(revision
31152)
+++ target/linux/ramips/files/arch/mips/include/asm/mach-ralink/machine.h
(working
copy)
@@ -17,6 +17,7 @@
RAMIPS_MACH_F5D8235_V1, /* Belkin F5D8235 v1 */
RAMIPS_MACH_RT_N15, /* Asus RT-N15 */
RAMIPS_MACH_V11ST_FE, /* Ralink V11ST-FE */
+ RAMIPS_MACH_W300A, /* Tenda W300A */
RAMIPS_MACH_WLI_TX4_AG300N, /* Buffalo WLI-TX4-AG300N */
RAMIPS_MACH_WZR_AGL300NH, /* Buffalo WZR-AGL300NH */
Index: target/linux/ramips/image/Makefile
===================================================================
--- target/linux/ramips/image/Makefile (revision 31152)
+++ target/linux/ramips/image/Makefile (working copy)
@@ -280,6 +280,10 @@
$(call
Image/Build/Template/$(fs_squash)/$(1),GENERIC_4M,v11st-fe,V11ST-FE,ttyS1,57600,phys)
endef
+define Image/Build/Profile/W300A
+ $(call
Image/Build/Template/$(fs_squash)/$(1),GENERIC_4M,w300a,W300A,ttyS1,57600,phys)
+endef
+
define Image/Build/Profile/WLITX4AG300N
$(call Image/Build/Template/$(fs_squash)/$(1),WLITX4AG300N)
endef
@@ -289,6 +293,7 @@
$(call Image/Build/Profile/F5D8235V1,$(1))
$(call Image/Build/Profile/RTN15,$(1))
$(call Image/Build/Profile/V11STFE,$(1))
+ $(call Image/Build/Profile/W300A,$(1))
$(call Image/Build/Profile/WLITX4AG300N,$(1))
endef
endif
Index: target/linux/ramips/patches-3.2/107-vitesse_8601.patch
===================================================================
--- target/linux/ramips/patches-3.2/107-vitesse_8601.patch (revision 0)
+++ target/linux/ramips/patches-3.2/107-vitesse_8601.patch (revision 0)
@@ -0,0 +1,186 @@
+--- a/drivers/net/phy/Kconfig
++++ b/drivers/net/phy/Kconfig
+@@ -55,9 +55,23 @@ config CICADA_PHY
+ Currently supports the cis8204
+
+ config VITESSE_PHY
+- tristate "Drivers for the Vitesse PHYs"
+- ---help---
+- Currently supports the vsc8244
++ tristate "Drivers for the Vitesse PHYs"
++ ---help---
++ Currently supports the vsc8244
++
++config VITESSE_PHY_8601_W300A_LEDS
++ bool "Enable vsc8601 LED config used on Tenda W300A"
++ depends on VITESSE_PHY
++ ---help---
++ Enable vsc8601 LED config used on Tenda W300A. VSC8601 has 3 LED lines
++ which could be configured to signal various PHY states. This switch
++ configures the PHY as for standard behaviour as used on Tenda W300A.
++
++config VITESSE_PHY_8601_SKEW
++ bool "Enable skew timing to vsc8601"
++ depends on VITESSE_PHY
++ ---help---
++ Apply clock timing adjustments for vsc8601
+
+ config SMSC_PHY
+ tristate "Drivers for SMSC PHYs"
+--- a/drivers/net/phy/vitesse.c
++++ b/drivers/net/phy/vitesse.c
+@@ -17,6 +17,7 @@
+ #include <linux/mii.h>
+ #include <linux/ethtool.h>
+ #include <linux/phy.h>
++#include <linux/delay.h>
+
+ /* Vitesse Extended Control Register 1 */
+ #define MII_VSC8244_EXT_CON1 0x17
+@@ -57,6 +58,19 @@
+ #define PHY_ID_VSC8244 0x000fc6c0
+ #define PHY_ID_VSC8221 0x000fc550
+
++/* Vitesse VSC8601 */
++#define PHY_ID_VSC8601 0x00070420
++#define PHY_ID_VSC8601_MASK 0x000ffff8
++
++#define MII_VSC8601_MODE_CONTROL 0
++#define MII_VSC8601_EXT_REG_PAGE 31
++
++#define MII_VSC8601_E_ENH_LED_METHOD 16
++#define MII_VSC8601_E_ENH_LED_BEHAVIOUR 17
++#define MII_VSC8601_E_RGMII_SKEW 28
++
++
++
+ MODULE_DESCRIPTION("Vitesse PHY driver");
+ MODULE_AUTHOR("Kriston Carson");
+ MODULE_LICENSE("GPL");
+@@ -98,6 +112,64 @@
+ return err;
+ }
+
++static int vsc8601_config_init(struct phy_device *phydev)
++{
++ int err;
++ int val;
++ int regValue;
++
++ /* switch to main registers */
++ err = phy_write(phydev, MII_VSC8601_EXT_REG_PAGE, 0x0000);
++ if (err < 0)
++ return err;
++ err = phy_write(phydev, MII_VSC8601_MODE_CONTROL, 0x8000);
/* SW reset */
++ if (err < 0)
++ return err;
++ udelay(4); /* wait 4us for the reset */
++
++ /* extended page registers */
++ err = phy_write(phydev, MII_VSC8601_EXT_REG_PAGE, 0x0001);
++ if (err < 0)
++ return err;
++
++#ifdef CONFIG_VITESSE_PHY_8601_W300A_LEDS
++ /* LEDs: enhanced mode, 2.5Hz blink, all combine link/act/dupl/coll. */
++ /* twice, bit 4 for enhanced mode */
++ err = phy_write(phydev, MII_VSC8601_E_ENH_LED_BEHAVIOUR, 0x0810);
++ if (err < 0)
++ return err;
++ err = phy_write(phydev, MII_VSC8601_E_ENH_LED_BEHAVIOUR, 0x0810);
++ if (err < 0)
++ return err;
++
++ /* LED2: Link/Activity, LED1: Link10/100/Activity, LED0:
Link1000/Activity */
++ err = phy_write(phydev, MII_VSC8601_E_ENH_LED_METHOD, 0x0061);
++ if (err < 0)
++ return err;
++ pr_info("Vitesse VSC8601 W300A LED config done");
++#endif
++
++ /* Skew setting */
++#ifdef CONFIG_VITESSE_PHY_8601_SKEW
++ regValue = phy_read(phydev, MII_VSC8601_E_RGMII_SKEW);
++ if (regValue < 0)
++ return regValue;
++ val = regValue;
++ regValue |= 0x3000; /* set 0x3000: Rx skew 2ns */
++ regValue &= ~(0xC000); /* clear 0xC000: Tx skew 0ns */
++ err = phy_write(phydev, MII_VSC8601_E_RGMII_SKEW, regValue);
++ pr_info("Vitesse VSC8601 phy skew: 0x%x -> 0x%x", val, regValue);
++ if (err < 0)
++ return err;
++#endif
++
++ err = phy_write(phydev, MII_VSC8601_EXT_REG_PAGE, 0); /*
switch back */
++ if (err < 0)
++ return err;
++
++ return err;
++}
++
+ static int vsc824x_ack_interrupt(struct phy_device *phydev)
+ {
+ int err = 0;
+@@ -153,13 +225,27 @@
+ .driver = { .owner = THIS_MODULE,},
+ };
+
++/* Vitesse 8601 */
++static struct phy_driver vsc8601_driver = {
++ .phy_id = PHY_ID_VSC8601,
++ .name = "Vitesse VSC8601",
++ .phy_id_mask = PHY_ID_VSC8601_MASK,
++ .features = PHY_GBIT_FEATURES,
++ .flags = PHY_HAS_INTERRUPT,
++ .config_init = &vsc8601_config_init,
++ .config_aneg = &genphy_config_aneg,
++ .read_status = &genphy_read_status,
++ .ack_interrupt = &vsc824x_ack_interrupt,
++ .config_intr = &vsc82xx_config_intr,
++ .driver = { .owner = THIS_MODULE,},
++};
++
+ static int vsc8221_config_init(struct phy_device *phydev)
+ {
+ int err;
+
+ err = phy_write(phydev, MII_VSC8244_AUX_CONSTAT,
+ MII_VSC8221_AUXCONSTAT_INIT);
+- return err;
+
+ /* Perhaps we should set EXT_CON1 based on the interface?
+ Options are 802.3Z SerDes or SGMII */
+@@ -186,10 +272,23 @@
+
+ err = phy_driver_register(&vsc8244_driver);
+ if (err < 0)
+- return err;
++ goto err;
++
+ err = phy_driver_register(&vsc8221_driver);
+ if (err < 0)
++ goto err1;
++
++ err = phy_driver_register(&vsc8601_driver);
++ if (err < 0)
++ goto err2;
++
++ return 0;
++
++err2:
++ phy_driver_unregister(&vsc8221_driver);
++err1:
+ phy_driver_unregister(&vsc8244_driver);
++err:
+ return err;
+ }
+
+@@ -205,6 +304,7 @@
+ static struct mdio_device_id __maybe_unused vitesse_tbl[] = {
+ { PHY_ID_VSC8244, 0x000fffc0 },
+ { PHY_ID_VSC8221, 0x000ffff0 },
++ { PHY_ID_VSC8601, PHY_ID_VSC8601_MASK },
+ { }
+ };
+
Index: target/linux/ramips/base-files/lib/ramips.sh
===================================================================
--- target/linux/ramips/base-files/lib/ramips.sh (revision 31152)
+++ target/linux/ramips/base-files/lib/ramips.sh (working copy)
@@ -134,6 +134,9 @@
*"Sitecom WL-351 v1 002")
name="wl-351"
;;
+ *"Tenda W300A")
+ name="w300a"
+ ;;
*"Ralink V11ST-FE")
name="v11st-fe"
;;
Index: target/linux/ramips/base-files/lib/upgrade/platform.sh
===================================================================
--- target/linux/ramips/base-files/lib/upgrade/platform.sh (revision 31152)
+++ target/linux/ramips/base-files/lib/upgrade/platform.sh (working copy)
@@ -32,6 +32,7 @@
rt-n15 | \
rt-n56u | \
sl-r7205 | \
+ w300a |\
w502u |\
wr6202 |\
v22rw-2x2 | \
Index: target/linux/ramips/base-files/lib/preinit/06_set_iface_mac
===================================================================
--- target/linux/ramips/base-files/lib/preinit/06_set_iface_mac (revision 31152)
+++ target/linux/ramips/base-files/lib/preinit/06_set_iface_mac (working copy)
@@ -28,6 +28,7 @@
hw550-3g |\
nbg-419n |\
omni-emb |\
+ w300a |\
w502u |\
wl-330n |\
wr6202 |\
Index: target/linux/ramips/base-files/etc/hotplug.d/firmware/10-rt2x00-eeprom
===================================================================
--- target/linux/ramips/base-files/etc/hotplug.d/firmware/10-rt2x00-eeprom
(revision
31152)
+++ target/linux/ramips/base-files/etc/hotplug.d/firmware/10-rt2x00-eeprom
(working
copy)
@@ -65,6 +65,7 @@
sl-r7205 | \
v11st-fe | \
v22rw-2x2 | \
+ w300a | \
w502u | \
wcr-150gn | \
whr-g300n | \
Index: target/linux/ramips/base-files/etc/uci-defaults/leds
===================================================================
--- target/linux/ramips/base-files/etc/uci-defaults/leds (revision 31152)
+++ target/linux/ramips/base-files/etc/uci-defaults/leds (working copy)
@@ -73,4 +73,7 @@
wcr-150gn)
set_usb_led "wcr150gn:amber:user"
;;
+ w300a)
+ set_wifi_led "rt2800pci-phy0::radio"
+ ;;
esac
Index: target/linux/ramips/base-files/etc/uci-defaults/network
===================================================================
--- target/linux/ramips/base-files/etc/uci-defaults/network (revision 31152)
+++ target/linux/ramips/base-files/etc/uci-defaults/network (working copy)
@@ -59,6 +59,7 @@
ucidef_set_interfaces_lan_wan "eth0.2" "eth0.1"
;;
+ w300a | \
wli-tx4-ag300n)
ucidef_set_interface_lan "eth0"
;;
@@ -96,6 +97,10 @@
wan_mac=$(/usr/sbin/maccalc add "$lan_mac" 1)
;;
+ w300a)
+ lan_mac=$(ramips_get_mac_binary factory 4)
+ ;;
+
dir-300-b1 |\
dir-300-b2 |\
dir-600-b1)
Index: target/linux/ramips/base-files/etc/diag.sh
===================================================================
--- target/linux/ramips/base-files/etc/diag.sh (revision 31152)
+++ target/linux/ramips/base-files/etc/diag.sh (working copy)
@@ -81,6 +81,9 @@
v22rw-2x2)
status_led="v22rw-2x2:green:security"
;;
+ w300a)
+ status_led="w300a:green:sys"
+ ;;
w502u)
status_led="alfa:blue:wps"
;;
_______________________________________________
openwrt-devel mailing list
[email protected]
https://lists.openwrt.org/mailman/listinfo/openwrt-devel