summaryrefslogtreecommitdiff
path: root/target
diff options
context:
space:
mode:
authorGabor Juhos <juhosg@openwrt.org>2007-09-28 06:32:40 +0000
committerGabor Juhos <juhosg@openwrt.org>2007-09-28 06:32:40 +0000
commitc0b6f797308133919ab16e51ec9832e81720f9bc (patch)
treef68e7cbdab84daced5fc355ea7a40bb7b94a7c7a /target
parent969ac7459ee6f948ea1c8804cc38d659e0c4a9d1 (diff)
downloadmtk-20170518-c0b6f797308133919ab16e51ec9832e81720f9bc.zip
mtk-20170518-c0b6f797308133919ab16e51ec9832e81720f9bc.tar.gz
mtk-20170518-c0b6f797308133919ab16e51ec9832e81720f9bc.tar.bz2
add morse LED trigger, will be used for diagnostic, update kernel config
SVN-Revision: 9053
Diffstat (limited to 'target')
-rw-r--r--target/linux/adm5120/files/drivers/leds/ledtrig-morse.c284
-rw-r--r--target/linux/adm5120/patches-2.6.22/300-ledtrig_morse.patch19
-rw-r--r--target/linux/adm5120/router_be/config-2.6.225
-rw-r--r--target/linux/adm5120/router_le/config-2.6.2210
4 files changed, 310 insertions, 8 deletions
diff --git a/target/linux/adm5120/files/drivers/leds/ledtrig-morse.c b/target/linux/adm5120/files/drivers/leds/ledtrig-morse.c
new file mode 100644
index 0000000..1f215bc
--- /dev/null
+++ b/target/linux/adm5120/files/drivers/leds/ledtrig-morse.c
@@ -0,0 +1,284 @@
+/*
+ * LED Morse Trigger
+ *
+ * Copyright (C) 2007 Gabor Juhos <juhosg at openwrt.org>
+ *
+ * This file was based on: drivers/led/ledtrig-timer.c
+ * Copyright 2005-2006 Openedhand Ltd.
+ * Author: Richard Purdie <rpurdie@openedhand.com>
+ *
+ * also based on the patch '[PATCH] 2.5.59 morse code panics' posted
+ * in the LKML by Tomas Szepe at Thu, 30 Jan 2003
+ * Copyright (C) 2002 Andrew Rodland <arodland@noln.com>
+ * Copyright (C) 2003 Tomas Szepe <szepe@pinerecords.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/module.h>
+#include <linux/jiffies.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/list.h>
+#include <linux/spinlock.h>
+#include <linux/device.h>
+#include <linux/sysdev.h>
+#include <linux/timer.h>
+#include <linux/ctype.h>
+#include <linux/leds.h>
+
+#include "leds.h"
+
+struct morse_trig_data {
+ unsigned long delay;
+ char *msg;
+
+ unsigned char morse;
+ unsigned char state;
+ char *msgpos;
+ struct timer_list timer;
+};
+
+const unsigned char morsetable[] = {
+ 0122, 0, 0310, 0, 0, 0163, /* "#$%&' */
+ 055, 0155, 0, 0, 0163, 0141, 0152, 0051, /* ()*+,-./ */
+ 077, 076, 074, 070, 060, 040, 041, 043, 047, 057, /* 0-9 */
+ 0107, 0125, 0, 0061, 0, 0114, 0, /* :;<=>?@ */
+ 006, 021, 025, 011, 002, 024, 013, 020, 004, /* A-I */
+ 036, 015, 022, 007, 005, 017, 026, 033, 012, /* J-R */
+ 010, 003, 014, 030, 016, 031, 035, 023, /* S-Z */
+ 0, 0, 0, 0, 0154 /* [\]^_ */
+};
+
+static inline unsigned char tomorse(char c) {
+ if (c >= 'a' && c <= 'z')
+ c = c - 'a' + 'A';
+ if (c >= '"' && c <= '_') {
+ return morsetable[c - '"'];
+ } else
+ return 0;
+}
+
+static inline unsigned long dit_len(struct morse_trig_data *morse_data)
+{
+ return morse_data->delay;
+}
+
+static inline unsigned long dah_len(struct morse_trig_data *morse_data)
+{
+ return 3*morse_data->delay;
+}
+
+static inline unsigned long space_len(struct morse_trig_data *morse_data)
+{
+ return 7*morse_data->delay;
+}
+
+static void morse_timer_function(unsigned long data)
+{
+ struct led_classdev *led_cdev = (struct led_classdev *) data;
+ struct morse_trig_data *morse_data = led_cdev->trigger_data;
+ unsigned long brightness = LED_OFF;
+ unsigned long delay = 0;
+
+ if (!morse_data->msg)
+ goto set_led;
+
+ switch (morse_data->state) {
+ case 0:
+ /* Starting a new blink. We have a valid code in morse. */
+ delay = (morse_data->morse & 001) ? dah_len(morse_data):
+ dit_len(morse_data);
+ brightness = LED_FULL;
+ morse_data->state = 1;
+ morse_data->morse >>= 1;
+ break;
+ case 1:
+ /* Coming off of a blink. */
+ morse_data->state = 0;
+
+ if (morse_data->morse > 1) {
+ /* Not done yet, just a one-dit pause. */
+ delay = dit_len(morse_data);
+ break;
+ }
+
+ /* Get a new char, figure out how much space. */
+ /* First time through */
+ if (!morse_data->msgpos)
+ morse_data->msgpos = (char *)morse_data->msg;
+
+ if (!*morse_data->msgpos) {
+ /* Repeating */
+ morse_data->msgpos = (char *)morse_data->msg;
+ delay = space_len(morse_data);
+ } else {
+ /* Inter-letter space */
+ delay = dah_len(morse_data);
+ }
+
+ if (!(morse_data->morse = tomorse(*morse_data->msgpos))) {
+ delay = space_len(morse_data);
+ morse_data->state = 1; /* And get us back here */
+ }
+ morse_data->msgpos++;
+ break;
+ }
+
+ mod_timer(&morse_data->timer, jiffies + msecs_to_jiffies(delay));
+
+set_led:
+ led_set_brightness(led_cdev, brightness);
+}
+
+static ssize_t morse_delay_show(struct class_device *dev, char *buf)
+{
+ struct led_classdev *led_cdev = class_get_devdata(dev);
+ struct morse_trig_data *morse_data = led_cdev->trigger_data;
+
+ sprintf(buf, "%lu\n", morse_data->delay);
+
+ return strlen(buf) + 1;
+}
+
+static ssize_t morse_delay_store(struct class_device *dev, const char *buf,
+ size_t size)
+{
+ struct led_classdev *led_cdev = class_get_devdata(dev);
+ struct morse_trig_data *morse_data = led_cdev->trigger_data;
+ char *after;
+ unsigned long state = simple_strtoul(buf, &after, 10);
+ size_t count = after - buf;
+ int ret = -EINVAL;
+
+ if (*after && isspace(*after))
+ count++;
+
+ if (count == size) {
+ morse_data->delay = state;
+ mod_timer(&morse_data->timer, jiffies + 1);
+ ret = count;
+ }
+
+ return ret;
+}
+
+static ssize_t morse_msg_show(struct class_device *dev, char *buf)
+{
+ struct led_classdev *led_cdev = class_get_devdata(dev);
+ struct morse_trig_data *morse_data = led_cdev->trigger_data;
+
+ if (!morse_data->msg)
+ sprintf(buf, "<none>\n");
+ else
+ sprintf(buf, "%s\n", morse_data->msg);
+
+ return strlen(buf) + 1;
+}
+
+static ssize_t morse_msg_store(struct class_device *dev, const char *buf,
+ size_t size)
+{
+ struct led_classdev *led_cdev = class_get_devdata(dev);
+ struct morse_trig_data *morse_data = led_cdev->trigger_data;
+ char *m;
+
+ m = kmalloc(size, GFP_KERNEL);
+ if (!m)
+ return -ENOMEM;
+
+ memcpy(m,buf,size);
+ m[size]='\0';
+
+ if (!morse_data->msg)
+ kfree(morse_data->msg);
+
+ morse_data->msg = m;
+ morse_data->msgpos = NULL;
+ morse_data->state = 1;
+
+ mod_timer(&morse_data->timer, jiffies + 1);
+
+ return size;
+}
+
+static CLASS_DEVICE_ATTR(delay, 0644, morse_delay_show, morse_delay_store);
+static CLASS_DEVICE_ATTR(message, 0644, morse_msg_show, morse_msg_store);
+
+static void morse_trig_activate(struct led_classdev *led_cdev)
+{
+ struct morse_trig_data *morse_data;
+ int rc;
+
+ morse_data = kzalloc(sizeof(*morse_data), GFP_KERNEL);
+ if (!morse_data)
+ return;
+
+ led_cdev->trigger_data = morse_data;
+
+ morse_data->delay = (HZ/2);
+ init_timer(&morse_data->timer);
+ morse_data->timer.function = morse_timer_function;
+ morse_data->timer.data = (unsigned long) led_cdev;
+
+ rc = class_device_create_file(led_cdev->class_dev,
+ &class_device_attr_delay);
+ if (rc) goto err;
+
+ rc = class_device_create_file(led_cdev->class_dev,
+ &class_device_attr_message);
+ if (rc) goto err_delay;
+
+ return;
+
+err_delay:
+ class_device_remove_file(led_cdev->class_dev,
+ &class_device_attr_delay);
+err:
+ led_cdev->trigger_data = NULL;
+ kfree(morse_data);
+}
+
+static void morse_trig_deactivate(struct led_classdev *led_cdev)
+{
+ struct morse_trig_data *morse_data = led_cdev->trigger_data;
+
+ if (!morse_data)
+ return;
+
+ class_device_remove_file(led_cdev->class_dev,
+ &class_device_attr_message);
+ class_device_remove_file(led_cdev->class_dev,
+ &class_device_attr_delay);
+
+ del_timer_sync(&morse_data->timer);
+ if (!morse_data->msg)
+ kfree(morse_data->msg);
+ kfree(morse_data);
+}
+
+static struct led_trigger morse_led_trigger = {
+ .name = "morse",
+ .activate = morse_trig_activate,
+ .deactivate = morse_trig_deactivate,
+};
+
+static int __init morse_trig_init(void)
+{
+ return led_trigger_register(&morse_led_trigger);
+}
+
+static void __exit morse_trig_exit(void)
+{
+ led_trigger_unregister(&morse_led_trigger);
+}
+
+module_init(morse_trig_init);
+module_exit(morse_trig_exit);
+
+MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org>");
+MODULE_DESCRIPTION("Morse LED trigger");
+MODULE_LICENSE("GPL");
diff --git a/target/linux/adm5120/patches-2.6.22/300-ledtrig_morse.patch b/target/linux/adm5120/patches-2.6.22/300-ledtrig_morse.patch
new file mode 100644
index 0000000..f1602ed
--- /dev/null
+++ b/target/linux/adm5120/patches-2.6.22/300-ledtrig_morse.patch
@@ -0,0 +1,19 @@
+--- linux-2.6.21.1.orig/drivers/leds/Kconfig 2007-09-09 07:15:28.000000000 +0200
++++ linux-2.6.21.1/drivers/leds/Kconfig 2007-09-13 19:36:35.000000000 +0200
+@@ -149,5 +149,9 @@
+ load average.
+ If unsure, say Y.
+
++config LEDS_TRIGGER_MORSE
++ tristate "LED Morse Trigger"
++ depends on LEDS_TRIGGERS
++
+ endmenu
+
+--- linux-2.6.21.1.orig/drivers/leds/Makefile 2007-09-09 07:15:28.000000000 +0200
++++ linux-2.6.21.1/drivers/leds/Makefile 2007-09-13 19:33:15.000000000 +0200
+@@ -23,3 +23,4 @@
+ obj-$(CONFIG_LEDS_TRIGGER_TIMER) += ledtrig-timer.o
+ obj-$(CONFIG_LEDS_TRIGGER_IDE_DISK) += ledtrig-ide-disk.o
+ obj-$(CONFIG_LEDS_TRIGGER_HEARTBEAT) += ledtrig-heartbeat.o
++obj-$(CONFIG_LEDS_TRIGGER_MORSE) += ledtrig-morse.o
diff --git a/target/linux/adm5120/router_be/config-2.6.22 b/target/linux/adm5120/router_be/config-2.6.22
index daa08e3..f87d98b 100644
--- a/target/linux/adm5120/router_be/config-2.6.22
+++ b/target/linux/adm5120/router_be/config-2.6.22
@@ -6,7 +6,6 @@ CONFIG_ADM5120_CPU_OVERRIDES=y
# CONFIG_ARCH_HAS_ILOG2_U64 is not set
# CONFIG_ARCH_SUPPORTS_MSI is not set
CONFIG_ARM_AMBA=y
-# CONFIG_ATM_DRIVERS is not set
CONFIG_BASE_SMALL=0
CONFIG_BAYCOM_SER_FDX=m
CONFIG_BAYCOM_SER_HDX=m
@@ -93,6 +92,7 @@ CONFIG_LEDS_ADM5120=y
CONFIG_LEDS_ADM5120_DIAG=y
# CONFIG_LEDS_ADM5120_EXPERIMENTAL is not set
CONFIG_LEDS_GPIO=y
+# CONFIG_LEDS_TRIGGER_MORSE is not set
CONFIG_LEGACY_PTYS=y
CONFIG_LEGACY_PTY_COUNT=256
# CONFIG_MACH_ALCHEMY is not set
@@ -171,6 +171,8 @@ CONFIG_NET_KEY=y
# CONFIG_NET_PKTGEN is not set
CONFIG_NET_SCH_FIFO=y
# CONFIG_NET_VENDOR_3COM is not set
+CONFIG_NF_CT_PROTO_GRE=m
+CONFIG_NF_NAT_PROTO_GRE=m
# CONFIG_PAGE_SIZE_16KB is not set
CONFIG_PAGE_SIZE_4KB=y
# CONFIG_PAGE_SIZE_64KB is not set
@@ -182,7 +184,6 @@ CONFIG_PCI_ADM5120=y
# CONFIG_PNPACPI is not set
# CONFIG_PNX8550_JBS is not set
# CONFIG_PNX8550_STB810 is not set
-# CONFIG_ROMFS_FS is not set
# CONFIG_RTC is not set
CONFIG_RWSEM_GENERIC_SPINLOCK=y
CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y
diff --git a/target/linux/adm5120/router_le/config-2.6.22 b/target/linux/adm5120/router_le/config-2.6.22
index 1224a0a..5c27c06 100644
--- a/target/linux/adm5120/router_le/config-2.6.22
+++ b/target/linux/adm5120/router_le/config-2.6.22
@@ -6,7 +6,6 @@ CONFIG_ADM5120_CPU_OVERRIDES=y
# CONFIG_ARCH_HAS_ILOG2_U64 is not set
# CONFIG_ARCH_SUPPORTS_MSI is not set
CONFIG_ARM_AMBA=y
-# CONFIG_ATM_DRIVERS is not set
CONFIG_BASE_SMALL=0
CONFIG_BAYCOM_SER_FDX=m
CONFIG_BAYCOM_SER_HDX=m
@@ -93,6 +92,7 @@ CONFIG_LEDS_ADM5120=y
CONFIG_LEDS_ADM5120_DIAG=y
# CONFIG_LEDS_ADM5120_EXPERIMENTAL is not set
CONFIG_LEDS_GPIO=y
+# CONFIG_LEDS_TRIGGER_MORSE is not set
CONFIG_LEGACY_PTYS=y
CONFIG_LEGACY_PTY_COUNT=256
# CONFIG_MACH_ALCHEMY is not set
@@ -155,6 +155,7 @@ CONFIG_MTD_MAP_BANK_WIDTH_4=y
# CONFIG_MTD_MTDRAM is not set
CONFIG_MTD_MYLOADER_PARTS=y
CONFIG_MTD_NAND=y
+CONFIG_MTD_NAND_ADM5120=y
# CONFIG_MTD_NAND_CAFE is not set
# CONFIG_MTD_NAND_DISKONCHIP is not set
# CONFIG_MTD_NAND_ECC_SMC is not set
@@ -162,7 +163,6 @@ CONFIG_MTD_NAND_IDS=y
# CONFIG_MTD_NAND_MUSEUM_IDS is not set
# CONFIG_MTD_NAND_NANDSIM is not set
# CONFIG_MTD_NAND_PLATFORM is not set
-CONFIG_MTD_NAND_ADM5120=y
# CONFIG_MTD_NAND_VERIFY_WRITE is not set
# CONFIG_MTD_ONENAND is not set
CONFIG_MTD_PARTITIONS=y
@@ -181,6 +181,8 @@ CONFIG_NET_KEY=y
# CONFIG_NET_PKTGEN is not set
CONFIG_NET_SCH_FIFO=y
# CONFIG_NET_VENDOR_3COM is not set
+CONFIG_NF_CT_PROTO_GRE=m
+CONFIG_NF_NAT_PROTO_GRE=m
# CONFIG_PAGE_SIZE_16KB is not set
CONFIG_PAGE_SIZE_4KB=y
# CONFIG_PAGE_SIZE_64KB is not set
@@ -192,7 +194,6 @@ CONFIG_PCI_ADM5120=y
# CONFIG_PNPACPI is not set
# CONFIG_PNX8550_JBS is not set
# CONFIG_PNX8550_STB810 is not set
-# CONFIG_ROMFS_FS is not set
# CONFIG_RTC is not set
CONFIG_RWSEM_GENERIC_SPINLOCK=y
CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y
@@ -247,9 +248,6 @@ CONFIG_USB_ADM5120_HCD=m
# CONFIG_USB_CATC is not set
# CONFIG_USB_EHCI_BIG_ENDIAN_MMIO is not set
CONFIG_USB_EHCI_HCD=m
-# CONFIG_USB_EHCI_ROOT_HUB_TT is not set
-# CONFIG_USB_EHCI_SPLIT_ISO is not set
-# CONFIG_USB_EHCI_TT_NEWSCHED is not set
# CONFIG_USB_KAWETH is not set
# CONFIG_USB_NET_DM9601 is not set
# CONFIG_USB_NET_GL620A is not set