diff mbox

[OpenWrt-Devel] ar71xx: uThing support - take II

Message ID 5526557.BJjayZVTVq@ncpws04
State Changes Requested
Headers show

Commit Message

Lars Boegild Thomsen April 11, 2015, 6:22 a.m. UTC
Adding OpenWrt support for the uThing module.

Sorry for earlier mistakes.  I think they have all been fixed, except I am still a bit confused about the "subject line".

Signed-off-by: Lars Boegild Thomsen <lth@bright-things.com>

Comments

Karl Palsson April 11, 2015, 1:34 p.m. UTC | #1
There's a few places here where things are sorted alphabetically. 
You've added the uthing beside the dragino2, presumably because it's
based on the dragino2-HE module?  Still, it's just another ar9331 board,
so please keep the lists sorted.

Further, the board patch lists it as being based on the RIO700?  Which
is it?

Further, you still have // comments as mentioned earlier.

You've added _new_ files with copyright year of 2011.  This cannot be
correct. (target/linux/ar71xx/generic/profiles/uthing.mk)

Sincerely,
Karl Palsson

Lars Boegild Thomsen <lth@bright-things.com> wrote:
> Adding OpenWrt support for the uThing module.
> 
> Sorry for earlier mistakes.  I think they have all been fixed, except I
> am still a bit confused about the "subject line".
> 
> Signed-off-by: Lars Boegild Thomsen <lth@bright-things.com>
> 

full patch elided
diff mbox

Patch

diff --git a/target/linux/ar71xx/base-files/etc/diag.sh b/target/linux/ar71xx/base-files/etc/diag.sh
index 14ff625..32efd63 100644
--- a/target/linux/ar71xx/base-files/etc/diag.sh
+++ b/target/linux/ar71xx/base-files/etc/diag.sh
@@ -186,6 +186,9 @@  get_status_led() {
 	oolite)
 		status_led="oolite:red:system"
 		;;
+	uthing)
+		status_led="uthing:green:system"
+		;;
 	qihoo-c301)
 		status_led="qihoo:green:status"
 		;;
diff --git a/target/linux/ar71xx/base-files/etc/uci-defaults/02_network b/target/linux/ar71xx/base-files/etc/uci-defaults/02_network
index 9789834..9350968 100644
--- a/target/linux/ar71xx/base-files/etc/uci-defaults/02_network
+++ b/target/linux/ar71xx/base-files/etc/uci-defaults/02_network
@@ -380,6 +380,7 @@  ja76pf |\
 mc-mac1200r|\
 mynet-n600 |\
 oolite |\
+uthing |\
 qihoo-c301 |\
 rb-750 |\
 rb-751 |\
diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh b/target/linux/ar71xx/base-files/lib/ar71xx.sh
index b3dbcf5..5b3e5a7 100755
--- a/target/linux/ar71xx/base-files/lib/ar71xx.sh
+++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh
@@ -410,6 +410,9 @@  ar71xx_board_detect() {
 	*"Dragino v2")
 		name="dragino2"
 		;;
+	*"uThing")
+		name="uthing"
+		;;
 	*"EAP300 v2")
 		name="eap300v2"
 		;;
diff --git a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
index 0cbee1d..5ed7440 100755
--- a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
+++ b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
@@ -206,6 +206,7 @@  platform_check_image() {
 	dir-825-c1 | \
 	dir-835-a1 | \
 	dragino2 | \
+	uthing | \
 	esr1750 | \
 	esr900 | \
 	ew-dorin | \
diff --git a/target/linux/ar71xx/config-3.18 b/target/linux/ar71xx/config-3.18
index b988048..720f3d3 100644
--- a/target/linux/ar71xx/config-3.18
+++ b/target/linux/ar71xx/config-3.18
@@ -52,6 +52,7 @@  CONFIG_ATH79_MACH_DIR_615_C1=y
 CONFIG_ATH79_MACH_DIR_825_B1=y
 CONFIG_ATH79_MACH_DIR_825_C1=y
 CONFIG_ATH79_MACH_DRAGINO2=y
+CONFIG_ATH79_MACH_UTHING=y
 CONFIG_ATH79_MACH_EAP300V2=y
 CONFIG_ATH79_MACH_EAP7660D=y
 CONFIG_ATH79_MACH_EL_M150=y
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-uthing.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-uthing.c
new file mode 100644
index 0000000..970b7fc
--- /dev/null
+++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-uthing.c
@@ -0,0 +1,112 @@ 
+/*
+ *  uThing module support, based on Rio700
+ *
+ *  Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
+ *  Copyright (C) 2012 Elektra Wagenrad <elektra@villagetelco.org>
+ *  Copyright (C) 2015 Bright Things UN Ltd. <lth@bright-things.com>
+ *
+ *  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/gpio.h>
+#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"
+
+#define UTHING_GPIO_LED_SYS		15
+#define UTHING_GPIO_LED_WLAN		0
+
+#define UTHING_GPIO_USB_PWR		1
+
+#define UTHING_GPIO_BTN_JUMPSTART	11
+#define UTHING_GPIO_BTN_RESET		12
+
+#define UTHING_KEYS_POLL_INTERVAL	20	/* msecs */
+#define UTHING_KEYS_DEBOUNCE_INTERVAL	(3 * UTHING_KEYS_POLL_INTERVAL)
+
+#define UTHING_MAC0_OFFSET		0x0000
+#define UTHING_MAC1_OFFSET		0x0006
+#define UTHING_CALDATA_OFFSET		0x1000
+#define UTHING_WMAC_MAC_OFFSET	0x1002
+
+static struct gpio_led uthing_leds_gpio[] __initdata = {
+	{
+		.name		= "uthing:yellow:wlan",
+		.gpio		= UTHING_GPIO_LED_WLAN,
+		.active_low	= 0,
+	},
+	{
+		.name		= "uthing:green:system",
+		.gpio		= UTHING_GPIO_LED_SYS,
+		.active_low	= 0,
+	},
+};
+
+static struct gpio_keys_button uthing_gpio_keys[] __initdata = {
+	{
+		.desc		= "jumpstart button",
+		.type		= EV_KEY,
+		.code		= KEY_WPS_BUTTON,
+		.debounce_interval = UTHING_KEYS_DEBOUNCE_INTERVAL,
+		.gpio		= UTHING_GPIO_BTN_JUMPSTART,
+		.active_low	= 1,
+	},
+	{
+		.desc		= "reset button",
+		.type		= EV_KEY,
+		.code		= KEY_RESTART,
+		.debounce_interval = UTHING_KEYS_DEBOUNCE_INTERVAL,
+		.gpio		= UTHING_GPIO_BTN_RESET,
+		.active_low	= 1,
+	}
+};
+
+static void __init uthing_common_setup(void)
+{
+	u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
+
+	ath79_register_m25p80(NULL);
+	ath79_register_wmac(art + UTHING_CALDATA_OFFSET,
+			    art + UTHING_WMAC_MAC_OFFSET);
+
+	ath79_init_mac(ath79_eth0_data.mac_addr, art + UTHING_MAC0_OFFSET, 0);
+	ath79_init_mac(ath79_eth1_data.mac_addr, art + UTHING_MAC1_OFFSET, 0);
+
+	ath79_register_mdio(0, 0x0);
+
+	/* LAN ports */
+	ath79_register_eth(1);
+
+	/* WAN port */
+	ath79_register_eth(0);
+}
+
+static void __init uthing_setup(void)
+{
+	uthing_common_setup();
+
+	// Enable USB power
+	gpio_request_one(UTHING_GPIO_USB_PWR, GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED, "USB Power");
+
+	ath79_register_usb();
+
+	ath79_register_leds_gpio(-1, ARRAY_SIZE(uthing_leds_gpio),
+				 uthing_leds_gpio);
+	ath79_register_gpio_keys_polled(-1, UTHING_KEYS_POLL_INTERVAL,
+					ARRAY_SIZE(uthing_gpio_keys),
+					uthing_gpio_keys);
+}
+
+MIPS_MACHINE(ATH79_MACH_UTHING, "uthing", "uThing",
+	     uthing_setup);
+
diff --git a/target/linux/ar71xx/generic/profiles/uthing.mk b/target/linux/ar71xx/generic/profiles/uthing.mk
new file mode 100644
index 0000000..4012231
--- /dev/null
+++ b/target/linux/ar71xx/generic/profiles/uthing.mk
@@ -0,0 +1,17 @@ 
+#
+# Copyright (C) 2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+define Profile/uThing
+	NAME:=uThing
+	PACKAGES:=kmod-ath9k kmod-usb-core kmod-usb-ohci kmod-usb2 kmod-ledtrig-usbdev
+endef
+
+define Profile/uThing/Description
+	Package set optimized for the uThing
+endef
+
+$(eval $(call Profile,uThing))
diff --git a/target/linux/ar71xx/image/Makefile b/target/linux/ar71xx/image/Makefile
index 8766756..ef9f7c4 100644
--- a/target/linux/ar71xx/image/Makefile
+++ b/target/linux/ar71xx/image/Makefile
@@ -468,6 +468,7 @@  f9k1115v2_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env),14464k(rootfs
 dlrtdev_mtdlayout=mtdparts=spi0.0:256k(uboot)ro,64k(config)ro,6208k(firmware),64k(caldata)ro,640k(certs),960k(unknown)ro,64k@0x7f0000(caldata_copy)
 dlrtdev_mtdlayout_fat=mtdparts=spi0.0:256k(uboot)ro,64k(config)ro,7168k(firmware),640k(certs),64k(caldata)ro,64k@0x660000(caldata_orig),6208k@0x50000(firmware_orig)
 dragino2_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,16000k(firmware),64k(config)ro,64k(art)ro
+uthing_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,16000k(firmware),64k(config),64k(art)ro
 hiwifi_hc6361_mtdlayout=mtdparts=spi0.0:64k(u-boot)ro,64k(bdinfo)ro,1280k(kernel),14848k(rootfs),64k(backup)ro,64k(art)ro,16128k@0x20000(firmware)
 pb92_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,2752k(rootfs),896k(kernel),64k(nvram),64k(art)ro,3648k@0x50000(firmware)
 planex_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,7744k(firmware),128k(art)ro
@@ -1341,6 +1342,7 @@  $(eval $(call SingleProfile,AthLzma,64k,BXU2000N2,bxu2000n-2-a1,BXU2000n-2-A1,tt
 $(eval $(call SingleProfile,AthLzma,64k,CAP4200AG,cap4200ag,CAP4200AG,ttyS0,115200,$$(cap4200ag_mtdlayout),KRuImage))
 $(eval $(call SingleProfile,AthLzma,64k,DB120,db120,DB120,ttyS0,115200,$$(db120_mtdlayout),RKuImage))
 $(eval $(call SingleProfile,AthLzma,64k,DRAGINO2,dragino2,DRAGINO2,ttyATH0,115200,$$(dragino2_mtdlayout),KRuImage,65536))
+$(eval $(call SingleProfile,AthLzma,64k,uThing,uthing,uthing,ttyATH0,115200,$$(uthing_mtdlayout),KRuImage,65536))
 $(eval $(call SingleProfile,AthLzma,64k,EWDORINAP,ew-dorin,EW-DORIN,ttyATH0,115200,$$(ew-dorin_mtdlayout_4M),KRuImage,65536))
 $(eval $(call SingleProfile,AthLzma,64k,EWDORINRT,ew-dorin-router,EW-DORIN-ROUTER,ttyATH0,115200,$$(ew-dorin_mtdlayout_4M),KRuImage,65536))
 $(eval $(call SingleProfile,AthLzma,64k,EWDORIN16M,ew-dorin-16M,EW-DORIN,ttyATH0,115200,$$(ew-dorin_mtdlayout_16M),KRuImage,65536))
diff --git a/target/linux/ar71xx/patches-3.14/910-uthing.patch b/target/linux/ar71xx/patches-3.14/910-uthing.patch
new file mode 100644
index 0000000..7c210eb
--- /dev/null
+++ b/target/linux/ar71xx/patches-3.14/910-uthing.patch
@@ -0,0 +1,41 @@ 
+--- a/arch/mips/ath79/Kconfig
++++ b/arch/mips/ath79/Kconfig
+@@ -365,6 +365,16 @@ config ATH79_MACH_DRAGINO2
+ 	select ATH79_DEV_ETH
+ 	select ATH79_DEV_USB
+ 
++config ATH79_MACH_UTHING
++	bool "uThing support"
++	select SOC_AR933X
++	select ATH79_DEV_M25P80
++	select ATH79_DEV_GPIO_BUTTONS
++	select ATH79_DEV_LEDS_GPIO
++	select ATH79_DEV_WMAC
++	select ATH79_DEV_ETH
++	select ATH79_DEV_USB
++
+ config ATH79_MACH_ESR900
+ 	bool "EnGenius ESR900 board support"
+ 	select SOC_QCA955X
+--- a/arch/mips/ath79/Makefile
++++ b/arch/mips/ath79/Makefile
+@@ -61,7 +61,8 @@ obj-$(CONFIG_ATH79_MACH_DIR_615_C1)	+= m
+ obj-$(CONFIG_ATH79_MACH_DIR_825_B1)	+= mach-dir-825-b1.o
+ obj-$(CONFIG_ATH79_MACH_DIR_825_C1)	+= mach-dir-825-c1.o
+ obj-$(CONFIG_ATH79_MACH_DRAGINO2)	+= mach-dragino2.o
+-obj-$(CONFIG_ATH79_MACH_ESR900)	+= mach-esr900.o
++obj-$(CONFIG_ATH79_MACH_UTHING)		+= mach-uthing.o
++obj-$(CONFIG_ATH79_MACH_ESR900)		+= mach-esr900.o
+ obj-$(CONFIG_ATH79_MACH_EW_DORIN)	+= mach-ew-dorin.o
+ obj-$(CONFIG_ATH79_MACH_EAP300V2)	+= mach-eap300v2.o
+ obj-$(CONFIG_ATH79_MACH_EAP7660D)	+= mach-eap7660d.o
+--- a/arch/mips/ath79/machtypes.h
++++ b/arch/mips/ath79/machtypes.h
+@@ -49,6 +49,7 @@ enum ath79_mach_type {
+ 	ATH79_MACH_DIR_825_C1,		/* D-Link DIR-825 rev. C1 */
+ 	ATH79_MACH_DIR_835_A1,		/* D-Link DIR-835 rev. A1 */
+ 	ATH79_MACH_DRAGINO2,		/* Dragino Version 2 */
++	ATH79_MACH_UTHING,		/* Dragino Version 2 */
+ 	ATH79_MACH_ESR900,		/* EnGenius ESR900 */
+ 	ATH79_MACH_EW_DORIN,		/* embedded wireless Dorin Platform */
+ 	ATH79_MACH_EW_DORIN_ROUTER,	/* embedded wireless Dorin Router Platform */
diff --git a/target/linux/ar71xx/patches-3.18/910-uthing.patch b/target/linux/ar71xx/patches-3.18/910-uthing.patch
new file mode 100644
index 0000000..b3c2800
--- /dev/null
+++ b/target/linux/ar71xx/patches-3.18/910-uthing.patch
@@ -0,0 +1,41 @@ 
+--- a/arch/mips/ath79/Kconfig
++++ b/arch/mips/ath79/Kconfig
+@@ -385,6 +385,16 @@ config ATH79_MACH_DRAGINO2
+ 	select ATH79_DEV_ETH
+ 	select ATH79_DEV_USB
+ 
++config ATH79_MACH_UTHING
++	bool "uThing support"
++	select SOC_AR933X
++	select ATH79_DEV_M25P80
++	select ATH79_DEV_GPIO_BUTTONS
++	select ATH79_DEV_LEDS_GPIO
++	select ATH79_DEV_WMAC
++	select ATH79_DEV_ETH
++	select ATH79_DEV_USB
++
+ config ATH79_MACH_ESR900
+ 	bool "EnGenius ESR900 board support"
+ 	select SOC_QCA955X
+--- a/arch/mips/ath79/Makefile
++++ b/arch/mips/ath79/Makefile
+@@ -63,7 +63,8 @@ obj-$(CONFIG_ATH79_MACH_DIR_615_C1)	+= m
+ obj-$(CONFIG_ATH79_MACH_DIR_825_B1)	+= mach-dir-825-b1.o
+ obj-$(CONFIG_ATH79_MACH_DIR_825_C1)	+= mach-dir-825-c1.o
+ obj-$(CONFIG_ATH79_MACH_DRAGINO2)	+= mach-dragino2.o
+-obj-$(CONFIG_ATH79_MACH_ESR900)	+= mach-esr900.o
++obj-$(CONFIG_ATH79_MACH_UTHING)		+= mach-uthing.o
++obj-$(CONFIG_ATH79_MACH_ESR900)		+= mach-esr900.o
+ obj-$(CONFIG_ATH79_MACH_EW_DORIN)	+= mach-ew-dorin.o
+ obj-$(CONFIG_ATH79_MACH_EAP300V2)	+= mach-eap300v2.o
+ obj-$(CONFIG_ATH79_MACH_EAP7660D)	+= mach-eap7660d.o
+--- a/arch/mips/ath79/machtypes.h
++++ b/arch/mips/ath79/machtypes.h
+@@ -51,6 +51,7 @@ enum ath79_mach_type {
+ 	ATH79_MACH_DIR_825_C1,		/* D-Link DIR-825 rev. C1 */
+ 	ATH79_MACH_DIR_835_A1,		/* D-Link DIR-835 rev. A1 */
+ 	ATH79_MACH_DRAGINO2,		/* Dragino Version 2 */
++	ATH79_MACH_UTHING,		/* Dragino Version 2 */
+ 	ATH79_MACH_ESR900,		/* EnGenius ESR900 */
+ 	ATH79_MACH_EW_DORIN,		/* embedded wireless Dorin Platform */
+ 	ATH79_MACH_EW_DORIN_ROUTER,	/* embedded wireless Dorin Router Platform */