Merge pull request #3993 from Memphiz/wetekleds

[WeTek_Play] - more control over the 3 leds
This commit is contained in:
Stefan Saraev 2015-03-09 00:29:37 +02:00
commit 4a1b9f7435
5 changed files with 316 additions and 110 deletions

View File

@ -3063,6 +3063,7 @@ CONFIG_LEDS_TRIGGERS=y
CONFIG_LEDS_TRIGGER_TIMER=y
CONFIG_LEDS_TRIGGER_ONESHOT=y
CONFIG_LEDS_TRIGGER_REMOTE_CONTROL=y
CONFIG_LEDS_TRIGGER_NETWORK=y
CONFIG_LEDS_TRIGGER_HEARTBEAT=y
# CONFIG_LEDS_TRIGGER_BACKLIGHT is not set
CONFIG_LEDS_TRIGGER_CPU=y

View File

@ -1,18 +1,23 @@
--- a/drivers/leds/Makefile.orig 2015-01-18 14:29:58.091729932 +0100
+++ b/drivers/leds/Makefile 2015-01-18 13:59:03.465220281 +0100
@@ -53,6 +53,7 @@
obj-$(CONFIG_LEDS_MAX8997) += leds-max8997.o
obj-$(CONFIG_LEDS_LM355x) += leds-lm355x.o
obj-$(CONFIG_LEDS_BLINKM) += leds-blinkm.o
+obj-$(CONFIG_LEDS_WETEKPLAY) += leds-wetekplay.o
# LED SPI Drivers
--- a/drivers/leds/Kconfig.orig 2015-01-18 14:30:02.727729748 +0100
+++ b/drivers/leds/Kconfig 2015-01-18 14:00:07.433217741 +0100
@@ -479,6 +479,13 @@
This option enables support for the BlinkM RGB LED connected
through I2C. Say Y to enable support for the BlinkM LED.
From 67e61bb31fa7365ccff454bb7d88a5eac5a05657 Mon Sep 17 00:00:00 2001
From: Memphiz <memphis@machzwo.de>
Date: Sun, 8 Mar 2015 22:26:05 +0100
Subject: [PATCH 1/4] [WeTek_Play] - add led driver for the 3 blue leds of the
wetekplay (powerled, ethled, wifiled)
---
drivers/leds/Kconfig | 7 ++
drivers/leds/Makefile | 1 +
drivers/leds/leds-wetekplay.c | 179 +++++++++++++++++++++++++++++++
4 files changed, 203 insertions(+)
create mode 100644 drivers/leds/leds-wetekplay.c
diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
index ef99229..878428e 100644
--- a/drivers/leds/Kconfig
+++ b/drivers/leds/Kconfig
@@ -73,6 +73,13 @@ config LEDS_LM3642
converter plus 1.5A constant current driver for a high-current
white LED.
+config LEDS_WETEKPLAY
+ tristate "LED support for the WeTek.Play status LED"
@ -22,11 +27,26 @@
+ of the WeTek.Play box. ON means BLUE, OFF means RED.
+
comment "LED Triggers"
source "drivers/leds/trigger/Kconfig"
--- /dev/null 2015-01-18 13:52:01.718570970 +0100
+++ b/drivers/leds/leds-wetekplay.c 2015-01-18 16:00:12.791515784 +0100
@@ -0,0 +1,107 @@
config LEDS_LOCOMO
tristate "LED Support for Locomo device"
diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile
index ac28977..843379e 100644
--- a/drivers/leds/Makefile
+++ b/drivers/leds/Makefile
@@ -53,6 +53,7 @@ obj-$(CONFIG_LEDS_RENESAS_TPU) += leds-renesas-tpu.o
obj-$(CONFIG_LEDS_MAX8997) += leds-max8997.o
obj-$(CONFIG_LEDS_LM355x) += leds-lm355x.o
obj-$(CONFIG_LEDS_BLINKM) += leds-blinkm.o
+obj-$(CONFIG_LEDS_WETEKPLAY) += leds-wetekplay.o
# LED SPI Drivers
obj-$(CONFIG_LEDS_DAC124S085) += leds-dac124s085.o
diff --git a/drivers/leds/leds-wetekplay.c b/drivers/leds/leds-wetekplay.c
new file mode 100644
index 0000000..4e00f3d
--- /dev/null
+++ b/drivers/leds/leds-wetekplay.c
@@ -0,0 +1,179 @@
+/*
+ * LEDs driver for the "User LED" on WeTek.Play
+ *
@ -38,11 +58,15 @@
+#include <linux/leds.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/amlogic/aml_gpio_consumer.h>
+
+#include <mach/am_regs.h>
+#include <plat/regops.h>
+
+static void wetekplay_led_set(struct led_classdev *cdev,
+#define GPIO_OWNER_WIFILED "WIFILED"
+#define GPIO_OWNER_ETHLED "ETHLED"
+
+static void wetekplay_powerled_set(struct led_classdev *cdev,
+ enum led_brightness brightness)
+{
+
@ -58,7 +82,7 @@
+ }
+}
+
+static enum led_brightness wetekplay_led_get(struct led_classdev *cdev)
+static enum led_brightness wetekplay_powerled_get(struct led_classdev *cdev)
+{
+ if (aml_get_reg32_bits(AOBUS_REG_ADDR(0x24), 31, 1))
+ return 255;
@ -66,21 +90,89 @@
+ return 0;
+}
+
+static void wetekplay_wifiled_set(struct led_classdev *cdev,
+ enum led_brightness brightness)
+{
+
+ if (brightness) {
+ //printk(KERN_INFO "%s() LED BLUE\n", __FUNCTION__);
+ amlogic_gpio_direction_output(GPIOC_8, 1, GPIO_OWNER_WIFILED);
+ }
+ else {
+ //printk(KERN_INFO "%s() LED OFF\n", __FUNCTION__);
+ amlogic_gpio_direction_output(GPIOC_8, 0, GPIO_OWNER_WIFILED);
+ }
+}
+
+static enum led_brightness wetekplay_wifiled_get(struct led_classdev *cdev)
+{
+ if (amlogic_get_value(GPIOC_8, GPIO_OWNER_WIFILED))
+ return 255;
+ else
+ return 0;
+}
+
+static void wetekplay_ethled_set(struct led_classdev *cdev,
+ enum led_brightness brightness)
+{
+
+ if (brightness) {
+ //printk(KERN_INFO "%s() LED BLUE\n", __FUNCTION__);
+ amlogic_gpio_direction_output(GPIOC_14, 1, GPIO_OWNER_ETHLED);
+ }
+ else {
+ //printk(KERN_INFO "%s() LED OFF\n", __FUNCTION__);
+ amlogic_gpio_direction_output(GPIOC_14, 0, GPIO_OWNER_ETHLED);
+ }
+}
+
+static enum led_brightness wetekplay_ethled_get(struct led_classdev *cdev)
+{
+ if (amlogic_get_value(GPIOC_14, GPIO_OWNER_ETHLED))
+ return 255;
+ else
+ return 0;
+}
+
+
+
+static struct led_classdev wetekplay_powerled = {
+ .name = "wetek:blue:powerled",
+ .brightness_set = wetekplay_led_set,
+ .brightness_get = wetekplay_led_get,
+ .brightness_set = wetekplay_powerled_set,
+ .brightness_get = wetekplay_powerled_get,
+ .default_trigger = "default-on",
+};
+
+static struct led_classdev wetekplay_wifiled = {
+ .name = "wetek:blue:wifiled",
+ .brightness_set = wetekplay_wifiled_set,
+ .brightness_get = wetekplay_wifiled_get,
+ .default_trigger = "wifilink",
+};
+
+static struct led_classdev wetekplay_ethled = {
+ .name = "wetek:blue:ethled",
+ .brightness_set = wetekplay_ethled_set,
+ .brightness_get = wetekplay_ethled_get,
+ .default_trigger = "ethlink",
+};
+
+static int wetekplay_led_probe(struct platform_device *pdev)
+{
+ return led_classdev_register(&pdev->dev, &wetekplay_powerled);
+ amlogic_gpio_request(GPIOC_8, GPIO_OWNER_WIFILED);
+ amlogic_gpio_request(GPIOC_14, GPIO_OWNER_ETHLED);
+ led_classdev_register(&pdev->dev, &wetekplay_powerled);
+ led_classdev_register(&pdev->dev, &wetekplay_wifiled);
+ return led_classdev_register(&pdev->dev, &wetekplay_ethled);
+}
+
+static int wetekplay_led_remove(struct platform_device *pdev)
+{
+ amlogic_gpio_free(GPIOC_8, GPIO_OWNER_WIFILED);
+ amlogic_gpio_free(GPIOC_14, GPIO_OWNER_ETHLED);
+ led_classdev_unregister(&wetekplay_powerled);
+ led_classdev_unregister(&wetekplay_wifiled);
+ led_classdev_unregister(&wetekplay_ethled);
+ return 0;
+}
+
@ -134,3 +226,5 @@
+MODULE_DESCRIPTION("Power LED support for WeTek.Play");
+MODULE_AUTHOR("Memphiz <memphiz@kodi.tv>");
+MODULE_ALIAS("platform:wetekplay-led");
--
1.9.3 (Apple Git-50)

View File

@ -0,0 +1,127 @@
From 9d998299c324d107cfb663f5e1e1bdf435f1cc66 Mon Sep 17 00:00:00 2001
From: Memphiz <memphis@machzwo.de>
Date: Sun, 8 Mar 2015 22:11:34 +0100
Subject: [PATCH 3/6] [WeTek_Play] - add network link status ledtrigger -
allows to assign leds to weteks network link status (either eth or wifi)
---
drivers/leds/trigger/Kconfig | 7 +++
drivers/leds/trigger/Makefile | 1 +
drivers/leds/trigger/ledtrig-network.c | 79 ++++++++++++++++++++++++++++++++++
3 files changed, 87 insertions(+)
create mode 100644 drivers/leds/trigger/ledtrig-network.c
diff --git a/drivers/leds/trigger/Kconfig b/drivers/leds/trigger/Kconfig
index e911914..4d889bb 100644
--- a/drivers/leds/trigger/Kconfig
+++ b/drivers/leds/trigger/Kconfig
@@ -48,6 +48,13 @@ config LEDS_TRIGGER_REMOTE_CONTROL
This allows LEDs to be controlled by Remote Control activity.
If unsure, say Y.
+config LEDS_TRIGGER_NETWORK
+ bool "LED network link trigger"
+ depends on LEDS_TRIGGERS
+ help
+ This allows LEDs to be controlled by network link status.
+ If unsure, say Y.
+
config LEDS_TRIGGER_HEARTBEAT
tristate "LED Heartbeat Trigger"
depends on LEDS_TRIGGERS
diff --git a/drivers/leds/trigger/Makefile b/drivers/leds/trigger/Makefile
index 868976b..4bbe38f 100644
--- a/drivers/leds/trigger/Makefile
+++ b/drivers/leds/trigger/Makefile
@@ -9,3 +9,4 @@ obj-$(CONFIG_LEDS_TRIGGER_DEFAULT_ON) += ledtrig-default-on.o
obj-$(CONFIG_LEDS_TRIGGER_TRANSIENT) += ledtrig-transient.o
obj-$(CONFIG_LEDS_TRIGGER_CAMERA) += ledtrig-camera.o
obj-$(CONFIG_LEDS_TRIGGER_REMOTE_CONTROL) += ledtrig-remote-control.o
+obj-$(CONFIG_LEDS_TRIGGER_NETWORK) += ledtrig-network.o
diff --git a/drivers/leds/trigger/ledtrig-network.c b/drivers/leds/trigger/ledtrig-network.c
new file mode 100644
index 0000000..790aa10
--- /dev/null
+++ b/drivers/leds/trigger/ledtrig-network.c
@@ -0,0 +1,79 @@
+/*
+ * LED Network Trigger
+ *
+ * Copyright 2015 Memphiz (memphiz@kodi.tv)
+ *
+ * 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/module.h>
+#include <linux/jiffies.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/timer.h>
+#include <linux/leds.h>
+
+void ledtrig_eth_linkup(struct led_classdev *led_cdev);
+void ledtrig_eth_linkdown(struct led_classdev *led_cdev);
+void ledtrig_wifi_linkup(struct led_classdev *led_cdev);
+void ledtrig_wifi_linkdown(struct led_classdev *led_cdev);
+
+static struct led_trigger ledtrig_eth = {
+ .name = "ethlink",
+ .activate = ledtrig_eth_linkup,
+ .deactivate = ledtrig_eth_linkdown,
+};
+
+static struct led_trigger ledtrig_wifi = {
+ .name = "wifilink",
+ .activate = ledtrig_wifi_linkup,
+ .deactivate = ledtrig_wifi_linkdown,
+};
+
+void ledtrig_eth_linkup(struct led_classdev *led_cdev)
+{
+ led_trigger_event(&ledtrig_eth, INT_MAX);
+}
+EXPORT_SYMBOL(ledtrig_eth_linkup);
+
+void ledtrig_eth_linkdown(struct led_classdev *led_cdev)
+{
+ led_trigger_event(&ledtrig_eth, LED_OFF);
+}
+EXPORT_SYMBOL(ledtrig_eth_linkdown);
+
+void ledtrig_wifi_linkup(struct led_classdev *led_cdev)
+{
+ led_trigger_event(&ledtrig_wifi, INT_MAX);
+}
+EXPORT_SYMBOL(ledtrig_wifi_linkup);
+
+void ledtrig_wifi_linkdown(struct led_classdev *led_cdev)
+{
+ led_trigger_event(&ledtrig_wifi, LED_OFF);
+}
+EXPORT_SYMBOL(ledtrig_wifi_linkdown);
+
+static int __init ledtrig_network_init(void)
+{
+ led_trigger_register(&ledtrig_eth);
+ led_trigger_register(&ledtrig_wifi);
+ return 0;
+}
+
+static void __exit ledtrig_network_exit(void)
+{
+ led_trigger_unregister(&ledtrig_eth);
+ led_trigger_unregister(&ledtrig_wifi);
+}
+
+module_init(ledtrig_network_init);
+module_exit(ledtrig_network_exit);
+
+MODULE_AUTHOR("Memphiz <memphiz@kodi.tv>");
+MODULE_DESCRIPTION("LED Network link trigger");
+MODULE_LICENSE("GPL");
+
--
1.9.3 (Apple Git-50)

View File

@ -1,12 +1,22 @@
--- a/arch/arm/boot/dts/amlogic/wetek_play.dtd 2015-01-25 17:18:35.065137487 +0100
+++ b/arch/arm/boot/dts/amlogic/wetek_play.dtd 2015-01-25 17:18:09.601138239 +0100
@@ -1427,4 +1427,9 @@
@@ -1427,4 +1427,19 @@
reserve-memory = <0x00a00000>; // 1920 * 1088 * 4 = 8,355,840
reserve-iomap = "true";
};
+
+powerled{
+leds{
+ compatible = "amlogic,wetekplay-led";
+ label = "wetek:blue:powerled";
+ powerled{
+ label = "wetek:blue:powerled";
+ };
+
+ wifiled{
+ label = "wetek:blue:wifiled";
+ };
+
+ ethled{
+ label = "wetek:blue:ethled";
+ };
+};
}; /* end of / */

View File

@ -1,108 +1,82 @@
diff -Naur a/drivers/amlogic/ethernet/am_net8218.c b/drivers/amlogic/ethernet/am_net8218.c
--- a/drivers/amlogic/ethernet/am_net8218.c 2015-02-14 20:42:23.000000000 +0100
+++ b/drivers/amlogic/ethernet/am_net8218.c 2015-03-03 16:30:11.000000000 +0100
@@ -54,6 +54,7 @@
From 8f08833d315afc65378d7f2e2b5704b46d68a099 Mon Sep 17 00:00:00 2001
From: Memphiz <memphis@machzwo.de>
Date: Sun, 8 Mar 2015 22:21:05 +0100
Subject: [PATCH 4/6] [WeTek_Play] - use new led trigger for signaling link
status of eth and wifi links
---
drivers/amlogic/ethernet/am_net8218.c | 14 ++++++++++++++
drivers/amlogic/wifi/broadcm_40181/wl_cfg80211.c | 12 ++++++++++++
2 files changed, 26 insertions(+)
diff --git a/drivers/amlogic/ethernet/am_net8218.c b/drivers/amlogic/ethernet/am_net8218.c
index aec2980..f5ced5a 100755
--- a/drivers/amlogic/ethernet/am_net8218.c
+++ b/drivers/amlogic/ethernet/am_net8218.c
@@ -55,6 +55,12 @@
#define DRV_NAME DRIVER_NAME
#define DRV_VERSION "v2.0.0"
+#define OWNER_NAME "meson-eth"
+#ifdef CONFIG_LEDS_TRIGGER_NETWORK
+#include <linux/leds.h>
+extern void ledtrig_eth_linkup(struct led_classdev *led_cdev);
+extern void ledtrig_eth_linkdown(struct led_classdev *led_cdev);
+#endif
+
#undef CONFIG_HAS_EARLYSUSPEND
#ifdef CONFIG_HAS_EARLYSUSPEND
@@ -975,6 +976,12 @@
#include <linux/earlysuspend.h>
@@ -975,6 +981,14 @@ static void aml_adjust_link(struct net_device *dev)
return;
spin_lock_irqsave(&priv->lock, flags);
+
+ if (phydev->link)
+ amlogic_gpio_direction_output(GPIOC_14, 1, OWNER_NAME);
+ else
+ amlogic_gpio_direction_output(GPIOC_14, 0, OWNER_NAME);
+
+#ifdef CONFIG_LEDS_TRIGGER_NETWORK
+ if (phydev->link)
+ ledtrig_eth_linkup(NULL);
+ else
+ ledtrig_eth_linkdown(NULL);
+#endif
+
if(phydev->phy_id == INTERNALPHY_ID){
val = (8<<27)|(7 << 24)|(1<<16)|(1<<15)|(1 << 13)|(1 << 12)|(4 << 4)|(0 << 1);
PERIPHS_SET_BITS(P_PREG_ETHERNET_ADDR0, val);
@@ -1316,6 +1323,8 @@
free_ringdesc(dev);
free_irq(dev->irq, dev);
diff --git a/drivers/amlogic/wifi/broadcm_40181/wl_cfg80211.c b/drivers/amlogic/wifi/broadcm_40181/wl_cfg80211.c
index 5596f1d..e9f91d7 100755
--- a/drivers/amlogic/wifi/broadcm_40181/wl_cfg80211.c
+++ b/drivers/amlogic/wifi/broadcm_40181/wl_cfg80211.c
@@ -92,6 +92,12 @@
#define IW_WSEC_ENABLED(wsec) ((wsec) & (WEP_ENABLED | TKIP_ENABLED | AES_ENABLED))
#endif /* BCMWAPI_WPI */
+ amlogic_gpio_direction_output(GPIOC_14, 0, OWNER_NAME);
+
if (g_debug > 0) {
printk(KERN_DEBUG "%s: closed\n", dev->name);
}
@@ -2870,7 +2879,7 @@
return ret;
}
-#define OWNER_NAME "meson-eth"
+#ifdef CONFIG_LEDS_TRIGGER_NETWORK
+#include <linux/leds.h>
+extern void ledtrig_wifi_linkup(struct led_classdev *led_cdev);
+extern void ledtrig_wifi_linkdown(struct led_classdev *led_cdev);
+#endif
+
void hardware_reset_phy(void){
if(reset_pin_enable){
amlogic_gpio_direction_output(reset_pin_num, 0, OWNER_NAME);
@@ -2958,6 +2967,7 @@
}
#endif
+ amlogic_gpio_request(GPIOC_14, OWNER_NAME);
printk(DRV_NAME "init(dbg[%p]=%d)\n", (&g_debug), g_debug);
switch_mod_gate_by_name("ethernet",1);
my_ndev = alloc_etherdev(sizeof(struct am_net_private));
diff -Naur a/drivers/amlogic/wifi/broadcm_40181/dhd_linux.c b/drivers/amlogic/wifi/broadcm_40181/dhd_linux.c
--- a/drivers/amlogic/wifi/broadcm_40181/dhd_linux.c 2015-02-14 20:42:23.000000000 +0100
+++ b/drivers/amlogic/wifi/broadcm_40181/dhd_linux.c 2015-03-03 16:33:58.000000000 +0100
@@ -34,7 +34,7 @@
#include <bcmutils.h>
#include <bcmendian.h>
#include <bcmdevs.h>
-
+#include <linux/amlogic/aml_gpio_consumer.h>
#include <proto/ethernet.h>
#include <proto/bcmip.h>
#include <dngl_stats.h>
@@ -4878,7 +4878,7 @@
{
printk("%s: Enter\n", __FUNCTION__);
-
+ amlogic_gpio_free(GPIOC_8, "WIFILED");
dhd_bus_unregister();
#if defined(CONFIG_WIFI_CONTROL_FUNC)
@@ -4907,6 +4907,7 @@
int chip_up = 0;
#endif
+ amlogic_gpio_request(GPIOC_8, "WIFILED");
printk("%s: Enter\n", __FUNCTION__);
if (wifi_setup_dt()) {
printk("wifi_dt : fail to setup dt\n");
diff -Naur a/drivers/amlogic/wifi/broadcm_40181/wl_cfg80211.c b/drivers/amlogic/wifi/broadcm_40181/wl_cfg80211.c
--- a/drivers/amlogic/wifi/broadcm_40181/wl_cfg80211.c 2015-02-14 20:42:23.000000000 +0100
+++ b/drivers/amlogic/wifi/broadcm_40181/wl_cfg80211.c 2015-03-03 16:35:01.000000000 +0100
@@ -47,6 +47,7 @@
#include <wl_cfgp2p.h>
#include <wl_android.h>
#include <dhd_config.h>
+#include <linux/amlogic/aml_gpio_consumer.h>
#ifdef PROP_TXSTATUS
#include <dhd_wlfc.h>
@@ -11181,6 +11182,8 @@
static struct device *cfg80211_parent_dev = NULL;
struct wl_priv *wlcfg_drv_priv = NULL;
u32 wl_dbg_level = WL_DBG_ERR;
@@ -11181,6 +11187,9 @@ static u32 wl_get_ielen(struct wl_priv *wl)
static void wl_link_up(struct wl_priv *wl)
{
wl->link_up = true;
+ amlogic_gpio_direction_output(GPIOC_8, 1, "WIFILED");
+
+#ifdef CONFIG_LEDS_TRIGGER_NETWORK
+ ledtrig_wifi_linkup(NULL);
+#endif
}
static void wl_link_down(struct wl_priv *wl)
@@ -11191,6 +11194,8 @@
@@ -11191,6 +11200,9 @@ static void wl_link_down(struct wl_priv *wl)
wl->link_up = false;
conn_info->req_ie_len = 0;
conn_info->resp_ie_len = 0;
+ amlogic_gpio_direction_output(GPIOC_8, 0, "WIFILED");
+
+#ifdef CONFIG_LEDS_TRIGGER_NETWORK
+ ledtrig_wifi_linkdown(NULL);
+#endif
}
static unsigned long wl_lock_eq(struct wl_priv *wl)
--
1.9.3 (Apple Git-50)