1 diff -Naur linux-4.14.101.org/arch/x86/Kconfig linux-4.14.101/arch/x86/Kconfig
2 --- linux-4.14.101.org/arch/x86/Kconfig 2019-02-15 09:08:56.000000000 +0100
3 +++ linux-4.14.101/arch/x86/Kconfig 2019-02-18 22:24:00.682722072 +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.101.org/arch/x86/platform/apu/apu2-led.c linux-4.14.101/arch/x86/platform/apu/apu2-led.c
32 --- linux-4.14.101.org/arch/x86/platform/apu/apu2-led.c 1970-01-01 01:00:00.000000000 +0100
33 +++ linux-4.14.101/arch/x86/platform/apu/apu2-led.c 2019-02-18 22:30:08.503059825 +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") ) ) // apu2 on early bios relases
184 + printk(KERN_INFO "%s: system is recognized as \"%s %s\"\n",
185 + KBUILD_MODNAME, vendor, product);
187 + ret = platform_driver_register(&apu2_led_driver);
191 + pdev = platform_device_register_simple(DRVNAME, -1, NULL, 0);
192 + if (IS_ERR(pdev)) {
193 + ret = PTR_ERR(pdev);
194 + platform_driver_unregister(&apu2_led_driver);
198 + apu2_led_p1 = ioremap(BASEADDR, 4);
199 + apu2_led_p2 = ioremap(BASEADDR+4, 4);
200 + apu2_led_p3 = ioremap(BASEADDR+8, 4);
206 +static void __exit apu2_led_exit(void)
208 + platform_device_unregister(pdev);
209 + platform_driver_unregister(&apu2_led_driver);
212 +module_init(apu2_led_init);
213 +module_exit(apu2_led_exit);
215 +MODULE_AUTHOR("Arne Fitzenreiter");
216 +MODULE_DESCRIPTION("PCEngines apu2/3/4 LED driver");
217 +MODULE_LICENSE("GPL");
218 diff -Naur linux-4.14.101.org/arch/x86/platform/apu/apu-led.c linux-4.14.101/arch/x86/platform/apu/apu-led.c
219 --- linux-4.14.101.org/arch/x86/platform/apu/apu-led.c 1970-01-01 01:00:00.000000000 +0100
220 +++ linux-4.14.101/arch/x86/platform/apu/apu-led.c 2019-02-18 22:24:00.686721439 +0100
223 + * LEDs driver for PCEngines apu
225 + * Copyright (C) 2013 Christian Herzog <daduke@daduke.org>, based on
226 + * Petr Leibman's leds-alix
227 + * Hardware presence check added by Arne Fitzenreiter <arne_f@ipfire.org>
228 + * Based on leds-wrap.c
229 + * Hardware info taken from http://www.dpie.com/manuals/miniboards/kontron/KTD-S0043-0_KTA55_SoftwareGuide.pdf
231 + * This program is free software; you can redistribute it and/or modify
232 + * it under the terms of the GNU General Public License version 2 as
233 + * published by the Free Software Foundation.
236 +#include <linux/kernel.h>
237 +#include <linux/module.h>
238 +#include <linux/init.h>
239 +#include <linux/platform_device.h>
240 +#include <linux/leds.h>
241 +#include <linux/err.h>
243 +#include <linux/dmi.h>
245 +#define DRVNAME "apu-led"
246 +#define BASEADDR (0xFED801BD)
248 +#define LEDOFF (0xC8)
250 +static struct platform_device *pdev;
251 +unsigned int *apu_led_p1;
252 +unsigned int *apu_led_p2;
253 +unsigned int *apu_led_p3;
255 +static void apu_led_set_1(struct led_classdev *led_cdev,
256 + enum led_brightness value) {
258 + iowrite8(LEDON, apu_led_p1);
260 + iowrite8(LEDOFF, apu_led_p1);
263 +static void apu_led_set_2(struct led_classdev *led_cdev,
264 + enum led_brightness value) {
266 + iowrite8(LEDON, apu_led_p2);
268 + iowrite8(LEDOFF, apu_led_p2);
271 +static void apu_led_set_3(struct led_classdev *led_cdev,
272 + enum led_brightness value) {
274 + iowrite8(LEDON, apu_led_p3);
276 + iowrite8(LEDOFF, apu_led_p3);
279 +static struct led_classdev apu_led_1 = {
281 + .brightness_set = apu_led_set_1,
284 +static struct led_classdev apu_led_2 = {
286 + .brightness_set = apu_led_set_2,
289 +static struct led_classdev apu_led_3 = {
291 + .brightness_set = apu_led_set_3,
296 +static int apu_led_suspend(struct platform_device *dev,
297 + pm_message_t state)
299 + led_classdev_suspend(&apu_led_1);
300 + led_classdev_suspend(&apu_led_2);
301 + led_classdev_suspend(&apu_led_3);
305 +static int apu_led_resume(struct platform_device *dev)
307 + led_classdev_resume(&apu_led_1);
308 + led_classdev_resume(&apu_led_2);
309 + led_classdev_resume(&apu_led_3);
313 +#define apu_led_suspend NULL
314 +#define apu_led_resume NULL
317 +static int apu_led_probe(struct platform_device *pdev)
321 + ret = led_classdev_register(&pdev->dev, &apu_led_1);
324 + ret = led_classdev_register(&pdev->dev, &apu_led_2);
327 + ret = led_classdev_register(&pdev->dev, &apu_led_3);
329 + led_classdev_unregister(&apu_led_2);
332 + led_classdev_unregister(&apu_led_1);
337 +static int apu_led_remove(struct platform_device *pdev)
339 + led_classdev_unregister(&apu_led_1);
340 + led_classdev_unregister(&apu_led_2);
341 + led_classdev_unregister(&apu_led_3);
345 +static struct platform_driver apu_led_driver = {
346 + .probe = apu_led_probe,
347 + .remove = apu_led_remove,
348 + .suspend = apu_led_suspend,
349 + .resume = apu_led_resume,
352 + .owner = THIS_MODULE,
356 +static int __init apu_led_init(void)
359 + const char *vendor, *product;
361 + vendor = dmi_get_system_info(DMI_SYS_VENDOR);
362 + if (!vendor || strcmp(vendor, "PC Engines"))
365 + product = dmi_get_system_info(DMI_PRODUCT_NAME);
366 + if (!product || strcmp(product, "APU"))
369 + printk(KERN_INFO "%s: system is recognized as \"%s %s\"\n",
370 + KBUILD_MODNAME, vendor, product);
372 + ret = platform_driver_register(&apu_led_driver);
376 + pdev = platform_device_register_simple(DRVNAME, -1, NULL, 0);
377 + if (IS_ERR(pdev)) {
378 + ret = PTR_ERR(pdev);
379 + platform_driver_unregister(&apu_led_driver);
383 + apu_led_p1 = ioremap(BASEADDR, 1);
384 + apu_led_p2 = ioremap(BASEADDR+1, 1);
385 + apu_led_p3 = ioremap(BASEADDR+2, 1);
391 +static void __exit apu_led_exit(void)
393 + platform_device_unregister(pdev);
394 + platform_driver_unregister(&apu_led_driver);
397 +module_init(apu_led_init);
398 +module_exit(apu_led_exit);
400 +MODULE_AUTHOR("Christian Herzog");
401 +MODULE_DESCRIPTION("PCEngines apu LED driver");
402 +MODULE_LICENSE("GPL");
403 diff -Naur linux-4.14.101.org/arch/x86/platform/apu/Makefile linux-4.14.101/arch/x86/platform/apu/Makefile
404 --- linux-4.14.101.org/arch/x86/platform/apu/Makefile 1970-01-01 01:00:00.000000000 +0100
405 +++ linux-4.14.101/arch/x86/platform/apu/Makefile 2019-02-18 22:24:00.686721439 +0100
407 +obj-$(CONFIG_APULED) += apu-led.o
408 +obj-$(CONFIG_APU2LED) += apu2-led.o
409 diff -Naur linux-4.14.101.org/arch/x86/platform/Makefile linux-4.14.101/arch/x86/platform/Makefile
410 --- linux-4.14.101.org/arch/x86/platform/Makefile 2019-02-15 09:08:56.000000000 +0100
411 +++ linux-4.14.101/arch/x86/platform/Makefile 2019-02-18 22:24:00.686721439 +0100
413 # SPDX-License-Identifier: GPL-2.0
414 # Platform specific code goes here