I noticed that the patch at http://patchwork.openwrt.org/patch/4017/ for adding support for the MikroTik RouterBOARD 951Ui-2HnD had been abandoned because it wasn't generated and sent to the mailing list correctly and doesn't apply as a result. I have cleaned up this patch.
When testing this on real hardware, I also noticed that wireless didn't work, so this patch fixes that as well. This patch applies cleanly to SVN 39392. Signed-off-by: Matthew Reeve <mre...@tenxnetworks.com> --- target/linux/ar71xx/files/arch/mips/ath79/mach-rb95x.c 2014-01-24 14:15:19.656352285 -0700 +++ target/linux/ar71xx/files/arch/mips/ath79/mach-rb95x.c 2014-01-24 16:10:23.387390723 -0700 @@ -24,2 +24,3 @@ #include <linux/spi/flash.h> +#include <linux/rle.h> #include <linux/routerboot.h> @@ -38,2 +39,3 @@ #include "routerboot.h" +#include "dev-leds-gpio.h" @@ -41,2 +43,6 @@ +#define RB951UI_HARD_CFG_OFFSET 0xc000 +#define RB951UI_HARD_CFG_SIZE 0x1000 +#define RB951UI_ART_SIZE 0x10000 + static struct mtd_partition rb95x_nand_partitions[] = { @@ -79,2 +85,34 @@ static struct ar8327_platform_data rb95x +static struct gpio_led rb951ui_leds_gpio[] __initdata = { + { + .name = "rb951ui:wlan", + .gpio = 11, + .active_low = 1, + }, { + .name = "rb951ui:act", + .gpio = 3, + .active_low = 1, + }, { + .name = "rb951ui:lan:port1", + .gpio = 13, + .active_low = 1, + }, { + .name = "rb951ui:lan:port2", + .gpio = 12, + .active_low = 1, + }, { + .name = "rb951ui:lan:port3", + .gpio = 4, + .active_low = 1, + }, { + .name = "rb951ui:lan:port4", + .gpio = 21, + .active_low = 1, + }, { + .name = "rb951ui:lan:port5", + .gpio = 21, + .active_low = 1, + } +}; + static struct mdio_board_info rb95x_mdio0_info[] = { @@ -102,2 +140,36 @@ void __init rb95x_wlan_init(void) +void __init rb951ui_wlan_init(void) +{ + u8 *hard_cfg = (u8 *) KSEG1ADDR(0x1f000000 + RB951UI_HARD_CFG_OFFSET); + u16 tag_len; + u8 *tag; + char *art_buf; + u8 wlan_mac[ETH_ALEN]; + int err; + + err = routerboot_find_tag(hard_cfg, RB951UI_HARD_CFG_SIZE, RB_ID_WLAN_DATA, + &tag, &tag_len); + if (err) { + pr_err("no calibration data found\n"); + return; + } + + art_buf = kmalloc(RB951UI_ART_SIZE, GFP_KERNEL); + if (art_buf == NULL) { + pr_err("no memory for calibration data\n"); + return; + } + + err = rle_decode((char *) tag, tag_len, art_buf, RB951UI_ART_SIZE, + NULL, NULL); + if (err) { + pr_err("unable to decode calibration data\n"); + kfree(art_buf); + } + + ath79_init_mac(wlan_mac, ath79_mac_base, 11); + ath79_register_wmac(art_buf + 0x1000, wlan_mac); + +} + static void rb95x_nand_select_chip(int chip_no) @@ -187 +259,40 @@ MIPS_MACHINE(ATH79_MACH_RB_951G, "951G", rb951g_setup); + +static void __init rb951ui_setup(void) +{ + rb95x_nand_init(); + + ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_SW_ONLY_MODE); + + ath79_register_mdio(1, 0x0); + + ath79_init_mac(ath79_eth0_data.mac_addr, ath79_mac_base, 0); + ath79_init_mac(ath79_eth1_data.mac_addr, ath79_mac_base, 1); + + ath79_switch_data.phy4_mii_en = 1; + ath79_switch_data.phy_poll_mask = BIT(4); + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII; + ath79_eth0_data.phy_mask = BIT(4); + ath79_eth0_data.mii_bus_dev = &ath79_mdio1_device.dev; + ath79_register_eth(0); + + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII; + ath79_register_eth(1); + + gpio_request_one(20, + GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_CHANGEABLE, + "USB power"); + + gpio_request_one(2, + GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_CHANGEABLE, + "POE power"); + + rb951ui_wlan_init(); + ath79_register_usb(); + + ath79_register_leds_gpio(-1, ARRAY_SIZE(rb951ui_leds_gpio), + rb951ui_leds_gpio); +} + +MIPS_MACHINE(ATH79_MACH_RB_951U, "951HnD", "MikroTik RouterBOARD 951Ui-2HnD", + rb951ui_setup); --- target/linux/ar71xx/patches-3.10/704-MIPS-ath79-add-RB951Ui-2HnD-support.patch 2013-12-19 07:41:25.000000000 -0700 +++ target/linux/ar71xx/patches-3.10/704-MIPS-ath79-add-RB951Ui-2HnD-support.patch 2014-01-24 16:09:40.595215422 -0700 @@ -0,0 +1,6 @@ +--- a/arch/mips/ath79/machtypes.h 2014-01-24 14:18:10.070102654 -0700 ++++ b/arch/mips/ath79/machtypes.h 2014-01-24 14:18:56.501123754 -0700 +@@ -83,2 +83,3 @@ enum ath79_mach_type { + ATH79_MACH_RB_951G, /* Mikrotik RouterBOARD 951G */ ++ ATH79_MACH_RB_951U, /* Mikrotik RouterBOARD 951Ui-2HnD */ + ATH79_MACH_RB_2011G, /* Mikrotik RouterBOARD 2011UAS-2HnD */ _______________________________________________ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel