1 diff -Naur linux-4.9.8.org/arch/x86/Kconfig linux-4.9.8/arch/x86/Kconfig
2 --- linux-4.9.8.org/arch/x86/Kconfig 2017-02-04 09:47:29.000000000 +0100
3 +++ linux-4.9.8/arch/x86/Kconfig 2017-02-09 19:29:59.244945360 +0100
5 - AC adapter status updates
6 - Battery status updates
10 bool "PCEngines ALIX System Support (LED setup)"
12 @@ -2642,6 +2643,18 @@
17 + bool "PCEngines APU Led Support"
20 + This option enables system support for the PCEngines APU1.
23 + bool "PCEngines APU2 Led Support"
26 + This option enables system support for the PCEngines APU2.
30 depends on CPU_SUP_AMD && PCI
31 diff -Naur linux-4.9.8.org/arch/x86/platform/apu/apu2-led.c linux-4.9.8/arch/x86/platform/apu/apu2-led.c
32 --- linux-4.9.8.org/arch/x86/platform/apu/apu2-led.c 1970-01-01 01:00:00.000000000 +0100
33 +++ linux-4.9.8/arch/x86/platform/apu/apu2-led.c 2017-02-09 19:29:59.244945360 +0100
36 + * LEDs driver for PCEngines apu2
38 + * this basic driver only set the output, configuration
39 + * has already done by bios/coreboot.
40 + * suspend/resume was not tested because IPFire not use it.
42 + * Copyright (C) 2016 Arne Fitzenreiter <arne_f@ipfire.org> ,
43 + * based on Christian Herzog's apu_led.
45 + * This program is free software; you can redistribute it and/or modify
46 + * it under the terms of the GNU General Public License version 2 as
47 + * published by the Free Software Foundation.
50 +#include <linux/kernel.h>
51 +#include <linux/module.h>
52 +#include <linux/init.h>
53 +#include <linux/platform_device.h>
54 +#include <linux/leds.h>
55 +#include <linux/err.h>
57 +#include <linux/dmi.h>
59 +#define DRVNAME "apu2-led"
60 +#define BASEADDR (0xFED81610)
62 +static struct platform_device *pdev;
63 +unsigned int *apu2_led_p1;
64 +unsigned int *apu2_led_p2;
65 +unsigned int *apu2_led_p3;
67 +static void apu2_led_set_1(struct led_classdev *led_cdev,
68 + enum led_brightness value) {
70 + iowrite32((ioread32(apu2_led_p1)&~BIT(22)), apu2_led_p1);
72 + iowrite32((ioread32(apu2_led_p1)|BIT(22)), apu2_led_p1);
75 +static void apu2_led_set_2(struct led_classdev *led_cdev,
76 + enum led_brightness value) {
78 + iowrite32((ioread32(apu2_led_p2)&~BIT(22)), apu2_led_p2);
80 + iowrite32((ioread32(apu2_led_p2)|BIT(22)), apu2_led_p2);
83 +static void apu2_led_set_3(struct led_classdev *led_cdev,
84 + enum led_brightness value) {
86 + iowrite32((ioread32(apu2_led_p3)&~BIT(22)), apu2_led_p3);
88 + iowrite32((ioread32(apu2_led_p3)|BIT(22)), apu2_led_p3);
91 +static struct led_classdev apu2_led_1 = {
93 + .brightness_set = apu2_led_set_1,
96 +static struct led_classdev apu2_led_2 = {
98 + .brightness_set = apu2_led_set_2,
101 +static struct led_classdev apu2_led_3 = {
103 + .brightness_set = apu2_led_set_3,
108 +static int apu2_led_suspend(struct platform_device *dev,
109 + pm_message_t state)
111 + led_classdev_suspend(&apu2_led_1);
112 + led_classdev_suspend(&apu2_led_2);
113 + led_classdev_suspend(&apu2_led_3);
117 +static int apu2_led_resume(struct platform_device *dev)
119 + led_classdev_resume(&apu2_led_1);
120 + led_classdev_resume(&apu2_led_2);
121 + led_classdev_resume(&apu2_led_3);
125 +#define apu2_led_suspend NULL
126 +#define apu2_led_resume NULL
129 +static int apu2_led_probe(struct platform_device *pdev)
133 + ret = led_classdev_register(&pdev->dev, &apu2_led_1);
136 + ret = led_classdev_register(&pdev->dev, &apu2_led_2);
139 + ret = led_classdev_register(&pdev->dev, &apu2_led_3);
141 + led_classdev_unregister(&apu2_led_2);
144 + led_classdev_unregister(&apu2_led_1);
149 +static int apu2_led_remove(struct platform_device *pdev)
151 + led_classdev_unregister(&apu2_led_1);
152 + led_classdev_unregister(&apu2_led_2);
153 + led_classdev_unregister(&apu2_led_3);
157 +static struct platform_driver apu2_led_driver = {
158 + .probe = apu2_led_probe,
159 + .remove = apu2_led_remove,
160 + .suspend = apu2_led_suspend,
161 + .resume = apu2_led_resume,
164 + .owner = THIS_MODULE,
168 +static int __init apu2_led_init(void)
171 + const char *vendor, *product;
173 + vendor = dmi_get_system_info(DMI_SYS_VENDOR);
174 + if (!vendor || strcmp(vendor, "PC Engines"))
177 + product = dmi_get_system_info(DMI_PRODUCT_NAME);
178 + if (!product || strcmp(product, "apu2"))
181 + printk(KERN_INFO "%s: system is recognized as \"%s %s\"\n",
182 + KBUILD_MODNAME, vendor, product);
184 + ret = platform_driver_register(&apu2_led_driver);
188 + pdev = platform_device_register_simple(DRVNAME, -1, NULL, 0);
189 + if (IS_ERR(pdev)) {
190 + ret = PTR_ERR(pdev);
191 + platform_driver_unregister(&apu2_led_driver);
195 + apu2_led_p1 = ioremap(BASEADDR, 4);
196 + apu2_led_p2 = ioremap(BASEADDR+4, 4);
197 + apu2_led_p3 = ioremap(BASEADDR+8, 4);
203 +static void __exit apu2_led_exit(void)
205 + platform_device_unregister(pdev);
206 + platform_driver_unregister(&apu2_led_driver);
209 +module_init(apu2_led_init);
210 +module_exit(apu2_led_exit);
212 +MODULE_AUTHOR("Arne Fitzenreiter");
213 +MODULE_DESCRIPTION("PCEngines apu2 LED driver");
214 +MODULE_LICENSE("GPL");
215 diff -Naur linux-4.9.8.org/arch/x86/platform/apu/apu-led.c linux-4.9.8/arch/x86/platform/apu/apu-led.c
216 --- linux-4.9.8.org/arch/x86/platform/apu/apu-led.c 1970-01-01 01:00:00.000000000 +0100
217 +++ linux-4.9.8/arch/x86/platform/apu/apu-led.c 2017-02-09 19:29:59.244945360 +0100
220 + * LEDs driver for PCEngines apu
222 + * Copyright (C) 2013 Christian Herzog <daduke@daduke.org>, based on
223 + * Petr Leibman's leds-alix
224 + * Hardware presence check added by Arne Fitzenreiter <arne_f@ipfire.org>
225 + * Based on leds-wrap.c
226 + * Hardware info taken from http://www.dpie.com/manuals/miniboards/kontron/KTD-S0043-0_KTA55_SoftwareGuide.pdf
228 + * This program is free software; you can redistribute it and/or modify
229 + * it under the terms of the GNU General Public License version 2 as
230 + * published by the Free Software Foundation.
233 +#include <linux/kernel.h>
234 +#include <linux/module.h>
235 +#include <linux/init.h>
236 +#include <linux/platform_device.h>
237 +#include <linux/leds.h>
238 +#include <linux/err.h>
240 +#include <linux/dmi.h>
242 +#define DRVNAME "apu-led"
243 +#define BASEADDR (0xFED801BD)
245 +#define LEDOFF (0xC8)
247 +static struct platform_device *pdev;
248 +unsigned int *apu_led_p1;
249 +unsigned int *apu_led_p2;
250 +unsigned int *apu_led_p3;
252 +static void apu_led_set_1(struct led_classdev *led_cdev,
253 + enum led_brightness value) {
255 + iowrite8(LEDON, apu_led_p1);
257 + iowrite8(LEDOFF, apu_led_p1);
260 +static void apu_led_set_2(struct led_classdev *led_cdev,
261 + enum led_brightness value) {
263 + iowrite8(LEDON, apu_led_p2);
265 + iowrite8(LEDOFF, apu_led_p2);
268 +static void apu_led_set_3(struct led_classdev *led_cdev,
269 + enum led_brightness value) {
271 + iowrite8(LEDON, apu_led_p3);
273 + iowrite8(LEDOFF, apu_led_p3);
276 +static struct led_classdev apu_led_1 = {
278 + .brightness_set = apu_led_set_1,
281 +static struct led_classdev apu_led_2 = {
283 + .brightness_set = apu_led_set_2,
286 +static struct led_classdev apu_led_3 = {
288 + .brightness_set = apu_led_set_3,
293 +static int apu_led_suspend(struct platform_device *dev,
294 + pm_message_t state)
296 + led_classdev_suspend(&apu_led_1);
297 + led_classdev_suspend(&apu_led_2);
298 + led_classdev_suspend(&apu_led_3);
302 +static int apu_led_resume(struct platform_device *dev)
304 + led_classdev_resume(&apu_led_1);
305 + led_classdev_resume(&apu_led_2);
306 + led_classdev_resume(&apu_led_3);
310 +#define apu_led_suspend NULL
311 +#define apu_led_resume NULL
314 +static int apu_led_probe(struct platform_device *pdev)
318 + ret = led_classdev_register(&pdev->dev, &apu_led_1);
321 + ret = led_classdev_register(&pdev->dev, &apu_led_2);
324 + ret = led_classdev_register(&pdev->dev, &apu_led_3);
326 + led_classdev_unregister(&apu_led_2);
329 + led_classdev_unregister(&apu_led_1);
334 +static int apu_led_remove(struct platform_device *pdev)
336 + led_classdev_unregister(&apu_led_1);
337 + led_classdev_unregister(&apu_led_2);
338 + led_classdev_unregister(&apu_led_3);
342 +static struct platform_driver apu_led_driver = {
343 + .probe = apu_led_probe,
344 + .remove = apu_led_remove,
345 + .suspend = apu_led_suspend,
346 + .resume = apu_led_resume,
349 + .owner = THIS_MODULE,
353 +static int __init apu_led_init(void)
356 + const char *vendor, *product;
358 + vendor = dmi_get_system_info(DMI_SYS_VENDOR);
359 + if (!vendor || strcmp(vendor, "PC Engines"))
362 + product = dmi_get_system_info(DMI_PRODUCT_NAME);
363 + if (!product || strcmp(product, "APU"))
366 + printk(KERN_INFO "%s: system is recognized as \"%s %s\"\n",
367 + KBUILD_MODNAME, vendor, product);
369 + ret = platform_driver_register(&apu_led_driver);
373 + pdev = platform_device_register_simple(DRVNAME, -1, NULL, 0);
374 + if (IS_ERR(pdev)) {
375 + ret = PTR_ERR(pdev);
376 + platform_driver_unregister(&apu_led_driver);
380 + apu_led_p1 = ioremap(BASEADDR, 1);
381 + apu_led_p2 = ioremap(BASEADDR+1, 1);
382 + apu_led_p3 = ioremap(BASEADDR+2, 1);
388 +static void __exit apu_led_exit(void)
390 + platform_device_unregister(pdev);
391 + platform_driver_unregister(&apu_led_driver);
394 +module_init(apu_led_init);
395 +module_exit(apu_led_exit);
397 +MODULE_AUTHOR("Christian Herzog");
398 +MODULE_DESCRIPTION("PCEngines apu LED driver");
399 +MODULE_LICENSE("GPL");
400 diff -Naur linux-4.9.8.org/arch/x86/platform/apu/Makefile linux-4.9.8/arch/x86/platform/apu/Makefile
401 --- linux-4.9.8.org/arch/x86/platform/apu/Makefile 1970-01-01 01:00:00.000000000 +0100
402 +++ linux-4.9.8/arch/x86/platform/apu/Makefile 2017-02-09 19:29:59.244945360 +0100
404 +obj-$(CONFIG_APULED) += apu-led.o
405 +obj-$(CONFIG_APU2LED) += apu2-led.o
406 diff -Naur linux-4.9.8.org/arch/x86/platform/Makefile linux-4.9.8/arch/x86/platform/Makefile
407 --- linux-4.9.8.org/arch/x86/platform/Makefile 2017-02-04 09:47:29.000000000 +0100
408 +++ linux-4.9.8/arch/x86/platform/Makefile 2017-02-09 19:32:31.768269470 +0100
410 # Platform specific code goes here