]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blame - src/patches/linux-3.10-apu_leds.patch
media.cgi: Fix typo 'writen'.
[people/teissler/ipfire-2.x.git] / src / patches / linux-3.10-apu_leds.patch
CommitLineData
e583643a
AF
1diff -Naur linux-3.10.33.org/arch/x86/Kconfig linux-3.10.33/arch/x86/Kconfig
2--- linux-3.10.33.org/arch/x86/Kconfig 2014-03-07 06:58:45.000000000 +0100
3+++ linux-3.10.33/arch/x86/Kconfig 2014-03-17 17:02:46.703135023 +0100
4@@ -2199,6 +2199,12 @@
5 - AC adapter status updates
6 - Battery status updates
7
8+config APULED
9+ bool "PCEngines APU Led Support"
10+ depends on DMI
11+ ---help---
12+ This option enables system support for the PCEngines APU.
13+
14 config ALIX
15 bool "PCEngines ALIX System Support (LED setup)"
16 select GPIOLIB
17diff -Naur linux-3.10.33.org/arch/x86/platform/apu/apu-led.c linux-3.10.33/arch/x86/platform/apu/apu-led.c
18--- linux-3.10.33.org/arch/x86/platform/apu/apu-led.c 1970-01-01 01:00:00.000000000 +0100
19+++ linux-3.10.33/arch/x86/platform/apu/apu-led.c 2014-03-17 17:00:36.187188456 +0100
20@@ -0,0 +1,181 @@
21+/*
22+ * LEDs driver for PCEngines apu
23+ *
24+ * Copyright (C) 2013 Christian Herzog <daduke@daduke.org>, based on
25+ * Petr Leibman's leds-alix
26+ * Hardware presence check added by Arne Fitzenreiter <arne_f@ipfire.org>
27+ * Based on leds-wrap.c
28+ * Hardware info taken from http://www.dpie.com/manuals/miniboards/kontron/KTD-S0043-0_KTA55_SoftwareGuide.pdf
29+ *
30+ * This program is free software; you can redistribute it and/or modify
31+ * it under the terms of the GNU General Public License version 2 as
32+ * published by the Free Software Foundation.
33+ */
34+
35+#include <linux/kernel.h>
36+#include <linux/module.h>
37+#include <linux/init.h>
38+#include <linux/platform_device.h>
39+#include <linux/leds.h>
40+#include <linux/err.h>
41+#include <asm/io.h>
42+#include <linux/dmi.h>
43+
44+#define DRVNAME "apu-led"
45+#define BASEADDR (0xFED801BD)
46+#define LEDON (0x8)
47+#define LEDOFF (0xC8)
48+
49+static struct platform_device *pdev;
50+unsigned int *p1;
51+unsigned int *p2;
52+unsigned int *p3;
53+
54+static void apu_led_set_1(struct led_classdev *led_cdev,
55+ enum led_brightness value) {
56+ if (value)
57+ iowrite8(LEDON, p1);
58+ else
59+ iowrite8(LEDOFF, p1);
60+}
61+
62+static void apu_led_set_2(struct led_classdev *led_cdev,
63+ enum led_brightness value) {
64+ if (value)
65+ iowrite8(LEDON, p2);
66+ else
67+ iowrite8(LEDOFF, p2);
68+}
69+
70+static void apu_led_set_3(struct led_classdev *led_cdev,
71+ enum led_brightness value) {
72+ if (value)
73+ iowrite8(LEDON, p3);
74+ else
75+ iowrite8(LEDOFF, p3);
76+}
77+
78+static struct led_classdev apu_led_1 = {
79+ .name = "apu:1",
80+ .brightness_set = apu_led_set_1,
81+};
82+
83+static struct led_classdev apu_led_2 = {
84+ .name = "apu:2",
85+ .brightness_set = apu_led_set_2,
86+};
87+
88+static struct led_classdev apu_led_3 = {
89+ .name = "apu:3",
90+ .brightness_set = apu_led_set_3,
91+};
92+
93+
94+#ifdef CONFIG_PM
95+static int apu_led_suspend(struct platform_device *dev,
96+ pm_message_t state)
97+{
98+ led_classdev_suspend(&apu_led_1);
99+ led_classdev_suspend(&apu_led_2);
100+ led_classdev_suspend(&apu_led_3);
101+ return 0;
102+}
103+
104+static int apu_led_resume(struct platform_device *dev)
105+{
106+ led_classdev_resume(&apu_led_1);
107+ led_classdev_resume(&apu_led_2);
108+ led_classdev_resume(&apu_led_3);
109+ return 0;
110+}
111+#else
112+#define apu_led_suspend NULL
113+#define apu_led_resume NULL
114+#endif
115+
116+static int apu_led_probe(struct platform_device *pdev)
117+{
118+ int ret;
119+
120+ ret = led_classdev_register(&pdev->dev, &apu_led_1);
121+ if (ret == 0)
122+ {
123+ ret = led_classdev_register(&pdev->dev, &apu_led_2);
124+ if (ret >= 0)
125+ {
126+ ret = led_classdev_register(&pdev->dev, &apu_led_3);
127+ if (ret < 0)
128+ led_classdev_unregister(&apu_led_2);
129+ }
130+ if (ret < 0)
131+ led_classdev_unregister(&apu_led_1);
132+ }
133+ return ret;
134+}
135+
136+static int apu_led_remove(struct platform_device *pdev)
137+{
138+ led_classdev_unregister(&apu_led_1);
139+ led_classdev_unregister(&apu_led_2);
140+ led_classdev_unregister(&apu_led_3);
141+ return 0;
142+}
143+
144+static struct platform_driver apu_led_driver = {
145+ .probe = apu_led_probe,
146+ .remove = apu_led_remove,
147+ .suspend = apu_led_suspend,
148+ .resume = apu_led_resume,
149+ .driver = {
150+ .name = DRVNAME,
151+ .owner = THIS_MODULE,
152+ },
153+};
154+
155+static int __init apu_led_init(void)
156+{
157+ int ret=0;
158+ const char *vendor, *product;
159+
160+ vendor = dmi_get_system_info(DMI_SYS_VENDOR);
161+ if (!vendor || strcmp(vendor, "PC Engines"))
162+ goto out;
163+
164+ product = dmi_get_system_info(DMI_PRODUCT_NAME);
165+ if (!product || strcmp(product, "APU"))
166+ goto out;
167+
168+ printk(KERN_INFO "%s: system is recognized as \"%s %s\"\n",
169+ KBUILD_MODNAME, vendor, product);
170+
171+ ret = platform_driver_register(&apu_led_driver);
172+ if (ret < 0)
173+ goto out;
174+
175+ pdev = platform_device_register_simple(DRVNAME, -1, NULL, 0);
176+ if (IS_ERR(pdev)) {
177+ ret = PTR_ERR(pdev);
178+ platform_driver_unregister(&apu_led_driver);
179+ goto out;
180+ }
181+
182+ p1 = ioremap(BASEADDR, 1);
183+ p2 = ioremap(BASEADDR+1, 1);
184+ p3 = ioremap(BASEADDR+2, 1);
185+
186+out:
187+ return ret;
188+}
189+
190+static void __exit apu_led_exit(void)
191+{
192+ platform_device_unregister(pdev);
193+ platform_driver_unregister(&apu_led_driver);
194+}
195+
196+module_init(apu_led_init);
197+module_exit(apu_led_exit);
198+
199+MODULE_AUTHOR("Christian Herzog");
200+MODULE_DESCRIPTION("PCEngines apu LED driver");
201+MODULE_LICENSE("GPL");
202diff -Naur linux-3.10.33.org/arch/x86/platform/apu/Makefile linux-3.10.33/arch/x86/platform/apu/Makefile
203--- linux-3.10.33.org/arch/x86/platform/apu/Makefile 1970-01-01 01:00:00.000000000 +0100
204+++ linux-3.10.33/arch/x86/platform/apu/Makefile 2014-03-17 17:05:19.245651480 +0100
205@@ -0,0 +1 @@
206+obj-$(CONFIG_APULED) += apu-led.o
207diff -Naur linux-3.10.33.org/arch/x86/platform/Makefile linux-3.10.33/arch/x86/platform/Makefile
208--- linux-3.10.33.org/arch/x86/platform/Makefile 2014-03-07 06:58:45.000000000 +0100
209+++ linux-3.10.33/arch/x86/platform/Makefile 2014-03-17 14:53:15.078571307 +0100
210@@ -1,4 +1,5 @@
211 # Platform specific code goes here
212+obj-y += apu/
213 obj-y += ce4100/
214 obj-y += efi/
215 obj-y += geode/