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