1 diff -Naur linux-4.14.102.org/arch/x86/Kconfig linux-4.14.102/arch/x86/Kconfig
2 --- linux-4.14.102.org/arch/x86/Kconfig 2019-02-20 10:20:56.000000000 +0100
3 +++ linux-4.14.102/arch/x86/Kconfig 2019-02-22 17:56:37.185202293 +0100
5 - AC adapter status updates
6 - Battery status updates
10 bool "PCEngines ALIX System Support (LED setup)"
12 @@ -2753,6 +2754,18 @@
17 + bool "PCEngines APU Led Support"
20 + This option enables system support for the PCEngines APU1.
23 + bool "PCEngines APU2/3/4 Led Support"
26 + This option enables system support for the PCEngines APU2/3/4.
30 depends on CPU_SUP_AMD && PCI
31 diff -Naur linux-4.14.102.org/arch/x86/platform/apu/apu2-led.c linux-4.14.102/arch/x86/platform/apu/apu2-led.c
32 --- linux-4.14.102.org/arch/x86/platform/apu/apu2-led.c 1970-01-01 01:00:00.000000000 +0100
33 +++ linux-4.14.102/arch/x86/platform/apu/apu2-led.c 2019-02-22 17:58:52.795665744 +0100
36 + * LEDs driver for PCEngines apu2/3/4
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, "PC Engines apu2") &&
179 + strcmp(product, "PC Engines apu3") &&
180 + strcmp(product, "PC Engines apu4") &&
181 + strcmp(product, "apu2") &&
182 + strcmp(product, "apu3") &&
183 + strcmp(product, "apu4") ) )
186 + printk(KERN_INFO "%s: system is recognized as \"%s %s\"\n",
187 + KBUILD_MODNAME, vendor, product);
189 + ret = platform_driver_register(&apu2_led_driver);
193 + pdev = platform_device_register_simple(DRVNAME, -1, NULL, 0);
194 + if (IS_ERR(pdev)) {
195 + ret = PTR_ERR(pdev);
196 + platform_driver_unregister(&apu2_led_driver);
200 + apu2_led_p1 = ioremap(BASEADDR, 4);
201 + apu2_led_p2 = ioremap(BASEADDR+4, 4);
202 + apu2_led_p3 = ioremap(BASEADDR+8, 4);
208 +static void __exit apu2_led_exit(void)
210 + platform_device_unregister(pdev);
211 + platform_driver_unregister(&apu2_led_driver);
214 +module_init(apu2_led_init);
215 +module_exit(apu2_led_exit);
217 +MODULE_AUTHOR("Arne Fitzenreiter");
218 +MODULE_DESCRIPTION("PCEngines apu2/3/4 LED driver");
219 +MODULE_LICENSE("GPL");
220 diff -Naur linux-4.14.102.org/arch/x86/platform/apu/apu-led.c linux-4.14.102/arch/x86/platform/apu/apu-led.c
221 --- linux-4.14.102.org/arch/x86/platform/apu/apu-led.c 1970-01-01 01:00:00.000000000 +0100
222 +++ linux-4.14.102/arch/x86/platform/apu/apu-led.c 2019-02-22 17:57:45.062504777 +0100
225 + * LEDs driver for PCEngines apu
227 + * Copyright (C) 2013 Christian Herzog <daduke@daduke.org>, based on
228 + * Petr Leibman's leds-alix
229 + * Hardware presence check added by Arne Fitzenreiter <arne_f@ipfire.org>
230 + * Based on leds-wrap.c
231 + * Hardware info taken from http://www.dpie.com/manuals/miniboards/kontron/KTD-S0043-0_KTA55_SoftwareGuide.pdf
233 + * This program is free software; you can redistribute it and/or modify
234 + * it under the terms of the GNU General Public License version 2 as
235 + * published by the Free Software Foundation.
238 +#include <linux/kernel.h>
239 +#include <linux/module.h>
240 +#include <linux/init.h>
241 +#include <linux/platform_device.h>
242 +#include <linux/leds.h>
243 +#include <linux/err.h>
245 +#include <linux/dmi.h>
247 +#define DRVNAME "apu-led"
248 +#define BASEADDR (0xFED801BD)
250 +#define LEDOFF (0xC8)
252 +static struct platform_device *pdev;
253 +unsigned int *apu_led_p1;
254 +unsigned int *apu_led_p2;
255 +unsigned int *apu_led_p3;
257 +static void apu_led_set_1(struct led_classdev *led_cdev,
258 + enum led_brightness value) {
260 + iowrite8(LEDON, apu_led_p1);
262 + iowrite8(LEDOFF, apu_led_p1);
265 +static void apu_led_set_2(struct led_classdev *led_cdev,
266 + enum led_brightness value) {
268 + iowrite8(LEDON, apu_led_p2);
270 + iowrite8(LEDOFF, apu_led_p2);
273 +static void apu_led_set_3(struct led_classdev *led_cdev,
274 + enum led_brightness value) {
276 + iowrite8(LEDON, apu_led_p3);
278 + iowrite8(LEDOFF, apu_led_p3);
281 +static struct led_classdev apu_led_1 = {
283 + .brightness_set = apu_led_set_1,
286 +static struct led_classdev apu_led_2 = {
288 + .brightness_set = apu_led_set_2,
291 +static struct led_classdev apu_led_3 = {
293 + .brightness_set = apu_led_set_3,
298 +static int apu_led_suspend(struct platform_device *dev,
299 + pm_message_t state)
301 + led_classdev_suspend(&apu_led_1);
302 + led_classdev_suspend(&apu_led_2);
303 + led_classdev_suspend(&apu_led_3);
307 +static int apu_led_resume(struct platform_device *dev)
309 + led_classdev_resume(&apu_led_1);
310 + led_classdev_resume(&apu_led_2);
311 + led_classdev_resume(&apu_led_3);
315 +#define apu_led_suspend NULL
316 +#define apu_led_resume NULL
319 +static int apu_led_probe(struct platform_device *pdev)
323 + ret = led_classdev_register(&pdev->dev, &apu_led_1);
326 + ret = led_classdev_register(&pdev->dev, &apu_led_2);
329 + ret = led_classdev_register(&pdev->dev, &apu_led_3);
331 + led_classdev_unregister(&apu_led_2);
334 + led_classdev_unregister(&apu_led_1);
339 +static int apu_led_remove(struct platform_device *pdev)
341 + led_classdev_unregister(&apu_led_1);
342 + led_classdev_unregister(&apu_led_2);
343 + led_classdev_unregister(&apu_led_3);
347 +static struct platform_driver apu_led_driver = {
348 + .probe = apu_led_probe,
349 + .remove = apu_led_remove,
350 + .suspend = apu_led_suspend,
351 + .resume = apu_led_resume,
354 + .owner = THIS_MODULE,
358 +static int __init apu_led_init(void)
361 + const char *vendor, *product;
363 + vendor = dmi_get_system_info(DMI_SYS_VENDOR);
364 + if (!vendor || strcmp(vendor, "PC Engines"))
367 + product = dmi_get_system_info(DMI_PRODUCT_NAME);
368 + if (!product || ( strcmp(product, "APU") &&
369 + strcmp(product, "apu1") &&
370 + strcmp(product, "PC Engines apu1") ))
373 + printk(KERN_INFO "%s: system is recognized as \"%s %s\"\n",
374 + KBUILD_MODNAME, vendor, product);
376 + ret = platform_driver_register(&apu_led_driver);
380 + pdev = platform_device_register_simple(DRVNAME, -1, NULL, 0);
381 + if (IS_ERR(pdev)) {
382 + ret = PTR_ERR(pdev);
383 + platform_driver_unregister(&apu_led_driver);
387 + apu_led_p1 = ioremap(BASEADDR, 1);
388 + apu_led_p2 = ioremap(BASEADDR+1, 1);
389 + apu_led_p3 = ioremap(BASEADDR+2, 1);
395 +static void __exit apu_led_exit(void)
397 + platform_device_unregister(pdev);
398 + platform_driver_unregister(&apu_led_driver);
401 +module_init(apu_led_init);
402 +module_exit(apu_led_exit);
404 +MODULE_AUTHOR("Christian Herzog");
405 +MODULE_DESCRIPTION("PCEngines apu LED driver");
406 +MODULE_LICENSE("GPL");
407 diff -Naur linux-4.14.102.org/arch/x86/platform/apu/Makefile linux-4.14.102/arch/x86/platform/apu/Makefile
408 --- linux-4.14.102.org/arch/x86/platform/apu/Makefile 1970-01-01 01:00:00.000000000 +0100
409 +++ linux-4.14.102/arch/x86/platform/apu/Makefile 2019-02-22 17:56:37.185202293 +0100
411 +obj-$(CONFIG_APULED) += apu-led.o
412 +obj-$(CONFIG_APU2LED) += apu2-led.o
413 diff -Naur linux-4.14.102.org/arch/x86/platform/Makefile linux-4.14.102/arch/x86/platform/Makefile
414 --- linux-4.14.102.org/arch/x86/platform/Makefile 2019-02-20 10:20:56.000000000 +0100
415 +++ linux-4.14.102/arch/x86/platform/Makefile 2019-02-22 17:56:37.185202293 +0100
417 # SPDX-License-Identifier: GPL-2.0
418 # Platform specific code goes here