PKGBUILDs/core/linux-armv5-rc/0004-leds-trigger-Introduce-a-SATA-trigger.patch
2020-02-12 04:00:15 +00:00

112 lines
3.5 KiB
Diff

From 4432cc83587dd30d739c6cd2ee180ecb14bd6fb7 Mon Sep 17 00:00:00 2001
From: Kevin Mihelich <kevin@archlinuxarm.org>
Date: Sun, 25 Feb 2018 16:32:06 -0700
Subject: [PATCH 4/9] 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 ce9429ca6dde..143075d13bd1 100644
--- a/drivers/leds/trigger/Kconfig
+++ b/drivers/leds/trigger/Kconfig
@@ -39,6 +39,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 733a83e2a718..023b9221202b 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 75353e5f9d13..fa9f630a80c6 100644
--- a/include/linux/leds.h
+++ b/include/linux/leds.h
@@ -456,6 +456,12 @@ void ledtrig_disk_activity(bool write);
static inline void ledtrig_disk_activity(bool write) {}
#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
void ledtrig_mtd_activity(void);
#else
--
2.25.0