[PATCH 1/2] weio: adding WeIO profile for OpenWrt

Drasko DRASKOVIC drasko.draskovic at gmail.com
Sat Feb 8 21:46:43 EST 2014


More changes on WeIO profile

Corrected board name detection in /tmp/sysinfo/board_name

weio: leds - enable STA and AP leds for WeIO board

mach-weio: led names to correspond to convention.

weio: buttons - added WeIO button support

button: Soft reset button moved to GPIO23

weio: i2c - add I2C functionality to WeIO kernel
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic at gmail.com>
---
 .../ar71xx/base-files/etc/uci-defaults/01_leds     |   6 +
 target/linux/ar71xx/base-files/lib/ar71xx.sh       |   3 +
 .../ar71xx/base-files/lib/upgrade/platform.sh      |   3 +-
 target/linux/ar71xx/config-3.10                    |   1 +
 .../linux/ar71xx/files/arch/mips/ath79/mach-weio.c | 163 +++++++++++++++++++++
 target/linux/ar71xx/generic/profiles/weio.mk       |  17 +++
 target/linux/ar71xx/image/Makefile                 |   2 +
 .../610-MIPS-ath79-openwrt-machines.patch          |  81 +++++-----
 8 files changed, 240 insertions(+), 36 deletions(-)
 create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-weio.c
 create mode 100644 target/linux/ar71xx/generic/profiles/weio.mk

diff --git a/target/linux/ar71xx/base-files/etc/uci-defaults/01_leds
b/target/linux/ar71xx/base-files/etc/uci-defaults/01_leds
index fe5ff93..f0c2178 100755
--- a/target/linux/ar71xx/base-files/etc/uci-defaults/01_leds
+++ b/target/linux/ar71xx/base-files/etc/uci-defaults/01_leds
@@ -57,6 +57,12 @@ carambola2)
  ucidef_set_led_wlan "wlan" "WLAN" "carambola2:green:wlan" "phy0tpt"
  ;;

+weio)
+ ucidef_set_led_netdev "lan" "LAN" "weio:orange:eth0" "eth0"
+ ucidef_set_led_netdev "wan" "WAN" "weio:orange:eth1" "eth1"
+ ucidef_set_led_wlan "wlan" "WLAN" "weio:green:wlan" "phy0tpt"
+ ;;
+
 db120)
  ucidef_set_led_usbdev "usb" "USB" "db120:green:usb" "1-1"
  ;;
diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh
b/target/linux/ar71xx/base-files/lib/ar71xx.sh
index 4656ac2..a9c0c99 100755
--- a/target/linux/ar71xx/base-files/lib/ar71xx.sh
+++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh
@@ -679,6 +679,9 @@ ar71xx_board_detect() {
  "8devices Carambola2"*)
  name="carambola2"
  ;;
+ "WeIO"*)
+ name="weio"
+ ;;
  *"Sitecom WLR-8100")
  name="wlr8100"
  ;;
diff --git a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
index 8af9580..5308cf6 100755
--- a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
+++ b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
@@ -178,7 +178,8 @@ platform_check_image() {
  nbg460n_550n_550nh | \
  unifi | \
  unifi-outdoor | \
- carambola2 )
+ carambola2 | \
+    weio )
  [ "$magic" != "2705" ] && {
  echo "Invalid image type."
  return 1
diff --git a/target/linux/ar71xx/config-3.10 b/target/linux/ar71xx/config-3.10
index 1346c3f..36576a2 100644
--- a/target/linux/ar71xx/config-3.10
+++ b/target/linux/ar71xx/config-3.10
@@ -100,6 +100,7 @@ CONFIG_ATH79_MACH_TL_WR841N_V9=y
 CONFIG_ATH79_MACH_TL_WR941ND=y
 CONFIG_ATH79_MACH_UBNT=y
 CONFIG_ATH79_MACH_UBNT_XM=y
+CONFIG_ATH79_MACH_WEIO=y
 CONFIG_ATH79_MACH_WHR_HP_G300N=y
 CONFIG_ATH79_MACH_WLAE_AG300N=y
 CONFIG_ATH79_MACH_WLR8100=y
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-weio.c
b/target/linux/ar71xx/files/arch/mips/ath79/mach-weio.c
new file mode 100644
index 0000000..51534aa
--- /dev/null
+++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-weio.c
@@ -0,0 +1,163 @@
+/**
+ * WEIO Web Of Things Platform
+ *
+ * Copyright (C) 2013 Drasko DRASKOVIC and Uros PETREVSKI
+ * All rights reserved
+ *
+ *              ##      ## ######## ####  #######
+ *              ##  ##  ## ##        ##  ##     ##
+ *              ##  ##  ## ##        ##  ##     ##
+ *              ##  ##  ## ######    ##  ##     ##
+ *              ##  ##  ## ##        ##  ##     ##
+ *              ##  ##  ## ##        ##  ##     ##
+ *               ###  ###  ######## ####  #######
+ *
+ *                   Web Of Things Platform
+ *
+ * This file is part of WEIO
+ * WEIO is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * WEIO is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors :
+ * Drasko DRASKOVIC <drasko.draskovic at gmail.com>
+ * Uros PETREVSKI <uros at nodesign.net>
+ */
+
+#include <asm/mach-ath79/ath79.h>
+#include <asm/mach-ath79/ar71xx_regs.h>
+#include "common.h"
+#include "dev-eth.h"
+#include "dev-gpio-buttons.h"
+#include "dev-leds-gpio.h"
+#include "dev-m25p80.h"
+#include "dev-spi.h"
+#include "dev-usb.h"
+#include "dev-wmac.h"
+#include "machtypes.h"
+#include "linux/i2c-gpio.h"
+#include "linux/platform_device.h"
+
+#define WEIO_GPIO_LED_STA 1
+#define WEIO_GPIO_LED_AP 16
+//#define WEIO_GPIO_LED_ETH0 13
+
+#define WEIO_GPIO_BTN_AP    20
+#define WEIO_GPIO_BTN_RESET 23
+
+#define WEIO_KEYS_POLL_INTERVAL 20 /* msecs */
+#define WEIO_KEYS_DEBOUNCE_INTERVAL (3 * WEIO_KEYS_POLL_INTERVAL)
+
+#define WEIO_MAC0_OFFSET 0x0000
+#define WEIO_MAC1_OFFSET 0x0006
+#define WEIO_CALDATA_OFFSET    0x1000
+#define WEIO_WMAC_MAC_OFFSET 0x1002
+
+static struct gpio_led weio_leds_gpio[] __initdata = {
+ {
+ .name = "weio:green:sta",
+ .gpio = WEIO_GPIO_LED_STA,
+ .active_low = 1,
+        .default_state = LEDS_GPIO_DEFSTATE_ON,
+ }, {
+ .name = "weio:green:ap",
+ .gpio = WEIO_GPIO_LED_AP,
+ .active_low = 1,
+        .default_state = LEDS_GPIO_DEFSTATE_ON,
+ }
+};
+
+static struct gpio_keys_button weio_gpio_keys[] __initdata = {
+ {
+ .desc = "ap button",
+ .type = EV_KEY,
+ .code = BTN_0,
+ .debounce_interval = WEIO_KEYS_DEBOUNCE_INTERVAL,
+ .gpio = WEIO_GPIO_BTN_AP,
+ .active_low = 1,
+ },
+ {
+ .desc = "soft-reset button",
+ .type = EV_KEY,
+ .code = BTN_1,
+ .debounce_interval = WEIO_KEYS_DEBOUNCE_INTERVAL,
+ .gpio = WEIO_GPIO_BTN_RESET,
+ .active_low = 1,
+ }
+};
+
+static struct i2c_gpio_platform_data weio_i2c_gpio_data = {
+ .sda_pin        = 18,
+ .scl_pin        = 19,
+};
+
+static struct platform_device weio_i2c_gpio = {
+ .name           = "i2c-gpio",
+ .id             = 0,
+ .dev     = {
+ .platform_data  = &weio_i2c_gpio_data,
+ },
+};
+
+static struct platform_device *weio_devices[] __initdata = {
+        &weio_i2c_gpio
+};
+
+static void __init weio_common_setup(void)
+{
+ u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
+
+ ath79_register_m25p80(NULL);
+ ath79_register_wmac(art + WEIO_CALDATA_OFFSET,
+    art + WEIO_WMAC_MAC_OFFSET);
+
+    /** WeIO does not use ETH - only WiFi by default */
+#if 0
+ ath79_setup_ar933x_phy4_switch(true, true);
+
+ ath79_init_mac(ath79_eth0_data.mac_addr, art + WEIO_MAC0_OFFSET, 0);
+ ath79_init_mac(ath79_eth1_data.mac_addr, art + WEIO_MAC1_OFFSET, 0);
+
+ ath79_register_mdio(0, 0x0);
+
+ /* LAN ports */
+ ath79_register_eth(1);
+
+ /* WAN port */
+ ath79_register_eth(0);
+#endif /** commented out ETH */
+}
+
+static void __init weio_setup(void)
+{
+ weio_common_setup();
+
+
+ ath79_gpio_function_disable(AR933X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
+ AR933X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
+ AR933X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
+ AR933X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
+                AR933X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
+
+    platform_add_devices(weio_devices, ARRAY_SIZE(weio_devices));
+
+ ath79_register_leds_gpio(-1, ARRAY_SIZE(weio_leds_gpio),
+ weio_leds_gpio);
+
+ ath79_register_gpio_keys_polled(-1, WEIO_KEYS_POLL_INTERVAL,
+ ARRAY_SIZE(weio_gpio_keys),
+ weio_gpio_keys);
+ ath79_register_usb();
+}
+
+MIPS_MACHINE(ATH79_MACH_WEIO, "WEIO", "WeIO board from Drasko
DRASKOVIC and Uros PETREVSKI",
+ weio_setup);
diff --git a/target/linux/ar71xx/generic/profiles/weio.mk
b/target/linux/ar71xx/generic/profiles/weio.mk
new file mode 100644
index 0000000..227cec9
--- /dev/null
+++ b/target/linux/ar71xx/generic/profiles/weio.mk
@@ -0,0 +1,17 @@
+#
+# Copyright (C) 2013 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+define Profile/WEIO
+        NAME:=WeIO
+        PACKAGES:=kmod-usb-core kmod-usb2
+endef
+
+define Profile/WEIO/Description
+        Package set optimized for the WeIO board.
+endef
+
+$(eval $(call Profile,WEIO))
diff --git a/target/linux/ar71xx/image/Makefile
b/target/linux/ar71xx/image/Makefile
index 6bc1105..dc61472 100644
--- a/target/linux/ar71xx/image/Makefile
+++ b/target/linux/ar71xx/image/Makefile
@@ -249,6 +249,7 @@
ap113_mtd_layout=mtdparts=spi0.0:64k(u-boot),3008k(rootfs),896k(uImage),64k(NVRA
 ap121_mtdlayout_2M=mtdparts=spi0.0:64k(u-boot)ro,1216k(rootfs),704k(kernel),64k(art)ro,1920k at 0x10000(firmware)
 ap121_mtdlayout_4M=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,2752k(rootfs),896k(kernel),64k(nvram),64k(art)ro,3648k at 0x50000(firmware)
 carambola2_mtdlayout_16M=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,15936k(firmware),64k(nvram),64k(art)ro
+weio_mtdlayout_16M=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,15936k(firmware),64k(nvram),64k(art)ro
 ap132_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,1408k(kernel),6400k(rootfs),64k(art),7808k at 0x50000(firmware)
 ap135_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,14528k(rootfs),1472k(kernel),64k(art)ro,16000k at 0x50000(firmware)
 ap136_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,6336k(rootfs),1408k(kernel),64k(mib0),64k(art)ro,7744k at 0x50000(firmware)
@@ -1019,6 +1020,7 @@ $(eval $(call
SingleProfile,AthLzma,64k,AP113,ap113,AP113,ttyS0,115200,$$(ap113_
 $(eval $(call SingleProfile,AthLzma,64k,AP121_2M,ap121-2M,AP121,ttyATH0,115200,$$(ap121_mtdlayout_2M),RKuImage))
 $(eval $(call SingleProfile,AthLzma,64k,AP121_4M,ap121-4M,AP121,ttyATH0,115200,$$(ap121_mtdlayout_4M),RKuImage))
 $(eval $(call SingleProfile,AthLzma,64k,CARAMBOLA2,carambola2,CARAMBOLA2,ttyATH0,115200,$$(carambola2_mtdlayout_16M),KRuImage,65536))
+$(eval $(call SingleProfile,AthLzma,64k,WEIO,weio,WEIO,ttyATH0,115200,$$(weio_mtdlayout_16M),KRuImage,65536))
 $(eval $(call SingleProfile,AthLzma,64k,AP121MINI,ap121-mini,AP121-MINI,ttyATH0,115200,$$(ap121_mtdlayout_4M),RKuImage))
 $(eval $(call SingleProfile,AthLzma,64k,AP132,ap132,AP132,ttyS0,115200,$$(ap132_mtdlayout),KRuImage))
 $(eval $(call SingleProfile,AthLzma,64k,AP135,ap135-020,AP135-020,ttyS0,115200,$$(ap135_mtdlayout),RKuImage))
diff --git a/target/linux/ar71xx/patches-3.10/610-MIPS-ath79-openwrt-machines.patch
b/target/linux/ar71xx/patches-3.10/610-MIPS-ath79-openwrt-machines.patch
index 2dfecd2..c2c7472 100644
--- a/target/linux/ar71xx/patches-3.10/610-MIPS-ath79-openwrt-machines.patch
+++ b/target/linux/ar71xx/patches-3.10/610-MIPS-ath79-openwrt-machines.patch
@@ -24,6 +24,7 @@
 + ATH79_MACH_BHU_BXU2000N2_A1, /* BHU BXU2000n-2 A1 */
 + ATH79_MACH_CAP4200AG, /* Senao CAP4200AG */
 + ATH79_MACH_CARAMBOLA2, /* 8devices Carambola2 */
++ ATH79_MACH_WEIO, /* WeIO board */
  ATH79_MACH_DB120, /* Atheros DB120 reference board */
  ATH79_MACH_PB44, /* Atheros PB44 reference board */
 + ATH79_MACH_DIR_505_A1, /* D-Link DIR-505 rev. A1 */
@@ -208,13 +209,13 @@
  config ATH79_MACH_AP121
  bool "Atheros AP121 reference board"
  select SOC_AR933X
-@@ -9,64 +64,736 @@ config ATH79_MACH_AP121
- select ATH79_DEV_GPIO_BUTTONS
- select ATH79_DEV_LEDS_GPIO
+@@ -11,62 +66,734 @@ config ATH79_MACH_AP121
  select ATH79_DEV_M25P80
-- select ATH79_DEV_USB
-+ select ATH79_DEV_USB
-+ select ATH79_DEV_WMAC
+ select ATH79_DEV_USB
+ select ATH79_DEV_WMAC
+- help
+-  Say 'Y' here if you want your kernel to support the
+-  Atheros AP121 reference board.
 + help
 +  Say 'Y' here if you want your kernel to support the
 +  Atheros AP121 reference board.
@@ -677,13 +678,8 @@
 + select ATH79_DEV_GPIO_BUTTONS
 + select ATH79_DEV_LEDS_GPIO
 + select ATH79_DEV_M25P80
- select ATH79_DEV_WMAC
-- help
--  Say 'Y' here if you want your kernel to support the
--  Atheros AP121 reference board.
-
--config ATH79_MACH_AP136
-- bool "Atheros AP136/AP135 reference board"
++ select ATH79_DEV_WMAC
++
 +config ATH79_MACH_EAP7660D
 + bool "Senao EAP7660D support"
 + select SOC_AR71XX
@@ -694,20 +690,14 @@
 +
 +config ATH79_MACH_ARCHER_C7
 + bool "TP-LINK Archer C7 board support"
- select SOC_QCA955X
++ select SOC_QCA955X
 + select ATH79_DEV_ETH
- select ATH79_DEV_GPIO_BUTTONS
- select ATH79_DEV_LEDS_GPIO
-- select ATH79_DEV_NFC
- select ATH79_DEV_SPI
- select ATH79_DEV_USB
- select ATH79_DEV_WMAC
-- help
--  Say 'Y' here if you want your kernel to support the
--  Atheros AP136 or AP135 reference boards.
-
--config ATH79_MACH_AP81
-- bool "Atheros AP81 reference board"
++ select ATH79_DEV_GPIO_BUTTONS
++ select ATH79_DEV_LEDS_GPIO
++ select ATH79_DEV_SPI
++ select ATH79_DEV_USB
++ select ATH79_DEV_WMAC
++
 +config ATH79_MACH_TL_MR11U
 + bool "TP-LINK TL-MR11U/TL-MR3040 support"
 + select SOC_AR933X
@@ -717,17 +707,27 @@
 + select ATH79_DEV_M25P80
 + select ATH79_DEV_USB
 + select ATH79_DEV_WMAC
-+
+
+-config ATH79_MACH_AP136
+- bool "Atheros AP136/AP135 reference board"
+- select SOC_QCA955X
 +config ATH79_MACH_TL_MR13U
 + bool "TP-LINK TL-MR13U support"
 + select SOC_AR933X
 + select ATH79_DEV_ETH
-+ select ATH79_DEV_GPIO_BUTTONS
-+ select ATH79_DEV_LEDS_GPIO
+ select ATH79_DEV_GPIO_BUTTONS
+ select ATH79_DEV_LEDS_GPIO
+- select ATH79_DEV_NFC
+- select ATH79_DEV_SPI
 + select ATH79_DEV_M25P80
-+ select ATH79_DEV_USB
-+ select ATH79_DEV_WMAC
-+
+ select ATH79_DEV_USB
+ select ATH79_DEV_WMAC
+- help
+-  Say 'Y' here if you want your kernel to support the
+-  Atheros AP136 or AP135 reference boards.
+
+-config ATH79_MACH_AP81
+- bool "Atheros AP81 reference board"
 +config ATH79_MACH_TL_MR3020
 + bool "TP-LINK TL-MR3020 support"
 + select SOC_AR933X
@@ -971,7 +971,7 @@

  config ATH79_MACH_UBNT_XM
  bool "Ubiquiti Networks XM/UniFi boards"
-@@ -83,6 +810,65 @@ config ATH79_MACH_UBNT_XM
+@@ -83,6 +810,75 @@ config ATH79_MACH_UBNT_XM
   Say 'Y' here if you want your kernel to support the
   Ubiquiti Networks XM (rev 1.0) board.

@@ -1024,6 +1024,16 @@
 + select ATH79_DEV_USB
 + select ATH79_DEV_WMAC
 +
++config ATH79_MACH_WEIO
++ bool "WeIO board by Drasko DRASKOVIC and Uros PETREVSKI"
++ select SOC_AR933X
++ select ATH79_DEV_ETH
++ select ATH79_DEV_GPIO_BUTTONS
++ select ATH79_DEV_LEDS_GPIO
++ select ATH79_DEV_M25P80
++ select ATH79_DEV_USB
++ select ATH79_DEV_WMAC
++
 +config ATH79_MACH_BHU_BXU2000N2_A
 + bool "BHU BXU2000n-2 rev. A support"
 + select SOC_AR934X
@@ -1037,7 +1047,7 @@
  endmenu

  config SOC_AR71XX
-@@ -132,7 +918,10 @@ config ATH79_DEV_DSA
+@@ -132,7 +928,10 @@ config ATH79_DEV_DSA
  config ATH79_DEV_ETH
  def_bool n

@@ -1049,7 +1059,7 @@
  def_bool n

  config ATH79_DEV_GPIO_BUTTONS
-@@ -164,4 +953,7 @@ config ATH79_PCI_ATH9K_FIXUP
+@@ -164,4 +963,7 @@ config ATH79_PCI_ATH9K_FIXUP
  config ATH79_ROUTERBOOT
  def_bool n

@@ -1150,6 +1160,7 @@
 +obj-$(CONFIG_ATH79_MACH_WZR_HP_G450H) += mach-wzr-hp-g450h.o
 +obj-$(CONFIG_ATH79_MACH_ZCN_1523H) += mach-zcn-1523h.o
 +obj-$(CONFIG_ATH79_MACH_CARAMBOLA2) += mach-carambola2.o
++obj-$(CONFIG_ATH79_MACH_WEIO)      += mach-weio.o
 --- a/arch/mips/ath79/prom.c
 +++ b/arch/mips/ath79/prom.c
 @@ -180,6 +180,12 @@ void __init prom_init(void)
-- 
1.8.5.3
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list