PKGBUILDs/core/linux-kirkwood-dt/0001-leds-trigger-Introduce-a-SATA-trigger.patch

113 lines
3.5 KiB
Diff
Raw Normal View History

2018-03-01 01:15:12 +00:00
From 4058a4acb326b16fdde72d35d16930efaf7eecdd Mon Sep 17 00:00:00 2001
From: Kevin Mihelich <kevin@archlinuxarm.org>
Date: Sun, 25 Feb 2018 16:32:06 -0700
Subject: [PATCH 1/6] leds: trigger: Introduce a SATA trigger
Signed-off-by: Kevin Mihelich <kevin@archlinuxarm.org>
---
drivers/leds/trigger/Kconfig | 6 ++++++
drivers/leds/trigger/Makefile | 1 +
drivers/leds/trigger/ledtrig-sata.c | 43 +++++++++++++++++++++++++++++++++++++
include/linux/leds.h | 6 ++++++
4 files changed, 56 insertions(+)
create mode 100644 drivers/leds/trigger/ledtrig-sata.c
diff --git a/drivers/leds/trigger/Kconfig b/drivers/leds/trigger/Kconfig
index a2559b4fdfff..592f942e0300 100644
--- a/drivers/leds/trigger/Kconfig
+++ b/drivers/leds/trigger/Kconfig
@@ -41,6 +41,12 @@ config LEDS_TRIGGER_DISK
This allows LEDs to be controlled by disk activity.
If unsure, say Y.
+config LEDS_TRIGGER_SATA
+ bool "LED SATA Disk Trigger for Kirkwood SOC"
+ depends on LEDS_TRIGGERS
+ help
+ This allows LEDs to be controlled by IDE disk activity.
+
config LEDS_TRIGGER_MTD
bool "LED MTD (NAND/NOR) Trigger"
depends on MTD
diff --git a/drivers/leds/trigger/Makefile b/drivers/leds/trigger/Makefile
index f3cfe1950538..f294704a3ebe 100644
--- a/drivers/leds/trigger/Makefile
+++ b/drivers/leds/trigger/Makefile
@@ -2,6 +2,7 @@
obj-$(CONFIG_LEDS_TRIGGER_TIMER) += ledtrig-timer.o
obj-$(CONFIG_LEDS_TRIGGER_ONESHOT) += ledtrig-oneshot.o
obj-$(CONFIG_LEDS_TRIGGER_DISK) += ledtrig-disk.o
+obj-$(CONFIG_LEDS_TRIGGER_SATA) += ledtrig-sata.o
obj-$(CONFIG_LEDS_TRIGGER_MTD) += ledtrig-mtd.o
obj-$(CONFIG_LEDS_TRIGGER_HEARTBEAT) += ledtrig-heartbeat.o
obj-$(CONFIG_LEDS_TRIGGER_BACKLIGHT) += ledtrig-backlight.o
diff --git a/drivers/leds/trigger/ledtrig-sata.c b/drivers/leds/trigger/ledtrig-sata.c
new file mode 100644
index 000000000000..f1798f43666f
--- /dev/null
+++ b/drivers/leds/trigger/ledtrig-sata.c
@@ -0,0 +1,43 @@
+/*
+ * LED SATA-Disk Activity Trigger
+ *
+ * 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/kernel.h>
+#include <linux/init.h>
+#include <linux/leds.h>
+
+#define BLINK_DELAY 30
+
+DEFINE_LED_TRIGGER(ledtrig_sata1);
+DEFINE_LED_TRIGGER(ledtrig_sata2);
+
+void ledtrig_sata_activity(int port_number)
+{
+ unsigned long sata_blink_delay = BLINK_DELAY;
+
+ switch (port_number) {
+ case 0:
+ led_trigger_blink_oneshot(ledtrig_sata1, &sata_blink_delay, &sata_blink_delay, 0);
+ break;
+ case 1:
+ led_trigger_blink_oneshot(ledtrig_sata2, &sata_blink_delay, &sata_blink_delay, 0);
+ break;
+ default:
+ break;
+ }
+}
+EXPORT_SYMBOL(ledtrig_sata_activity);
+
+static int __init ledtrig_sata_init(void)
+{
+ led_trigger_register_simple("sata-disk1", &ledtrig_sata1);
+ led_trigger_register_simple("sata-disk2", &ledtrig_sata2);
+
+ return 0;
+}
+device_initcall(ledtrig_sata_init);
diff --git a/include/linux/leds.h b/include/linux/leds.h
index 5579c64c8fd6..77fd36d6173e 100644
--- a/include/linux/leds.h
+++ b/include/linux/leds.h
@@ -351,6 +351,12 @@ extern void ledtrig_disk_activity(void);
static inline void ledtrig_disk_activity(void) {}
#endif
+#ifdef CONFIG_LEDS_TRIGGER_SATA
+extern void ledtrig_sata_activity(int port_number);
+#else
+static inline void ledtrig_sata_activity(int port_number) {}
+#endif
+
#ifdef CONFIG_LEDS_TRIGGER_MTD
extern void ledtrig_mtd_activity(void);
#else
--
2.16.1