From: Florian Eckert <fe@dev.tdt.de>
To: linus.walleij@linaro.org, bgolaszewski@baylibre.com,
dvhart@infradead.org, andy@infradead.org,
Eckert.Florian@googlemail.com
Cc: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org,
platform-driver-x86@vger.kernel.org,
Florian Eckert <fe@dev.tdt.de>
Subject: [PATCH v5 2/2] platform: Add reset button device for PC Engines APU boards
Date: Tue, 27 Nov 2018 14:25:08 +0100 [thread overview]
Message-ID: <20181127132508.5501-3-fe@dev.tdt.de> (raw)
In-Reply-To: <20181127132508.5501-1-fe@dev.tdt.de>
Add a platform/x86 device "gpio-keys-polled" for the frontpanel reset button.
This device uses the gpio-apu driver for APU borads from PC Engines.
Signed-off-by: Florian Eckert <fe@dev.tdt.de>
---
drivers/platform/x86/Kconfig | 11 +++
drivers/platform/x86/Makefile | 1 +
drivers/platform/x86/pcengines-apu-platform.c | 114 ++++++++++++++++++++++++++
3 files changed, 126 insertions(+)
create mode 100644 drivers/platform/x86/pcengines-apu-platform.c
diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
index 54f6a40c75c6..5cd27c2174cb 100644
--- a/drivers/platform/x86/Kconfig
+++ b/drivers/platform/x86/Kconfig
@@ -1288,6 +1288,17 @@ config INTEL_ATOMISP2_PM
To compile this driver as a module, choose M here: the module
will be called intel_atomisp2_pm.
+config PCENGINES_APU_PLATFORM
+ bool "PCEngines APU System Support"
+ depends on X86_64 && DMI && GPIOLIB
+ help
+ This option enables system support for the PCEngines APU platform.
+ At present this just adds the GPIO reset button platform device on
+ APU2/APU3 boards.
+
+ Note: You must still enable the drivers for GPIO and LED support
+ (GPIO_APU & LEDS_APU) to actually use the LEDs and the GPIOs.
+
endif # X86_PLATFORM_DEVICES
config PMC_ATOM
diff --git a/drivers/platform/x86/Makefile b/drivers/platform/x86/Makefile
index 39ae94135406..f899cc4c6b48 100644
--- a/drivers/platform/x86/Makefile
+++ b/drivers/platform/x86/Makefile
@@ -96,3 +96,4 @@ obj-$(CONFIG_INTEL_TURBO_MAX_3) += intel_turbo_max_3.o
obj-$(CONFIG_INTEL_CHTDC_TI_PWRBTN) += intel_chtdc_ti_pwrbtn.o
obj-$(CONFIG_I2C_MULTI_INSTANTIATE) += i2c-multi-instantiate.o
obj-$(CONFIG_INTEL_ATOMISP2_PM) += intel_atomisp2_pm.o
+obj-$(CONFIG_PCENGINES_APU_PLATFORM) += pcengines-apu-platform.o
diff --git a/drivers/platform/x86/pcengines-apu-platform.c b/drivers/platform/x86/pcengines-apu-platform.c
new file mode 100644
index 000000000000..3bfbaa93cb11
--- /dev/null
+++ b/drivers/platform/x86/pcengines-apu-platform.c
@@ -0,0 +1,114 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * System Specific setup for PC-Engines APU2/APU3 devices
+ *
+ * Copyright (C) 2018 Florian Eckert <fe@dev.tdt.de>
+ */
+
+#include <linux/dmi.h>
+#include <linux/gpio_keys.h>
+#include <linux/input.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+
+static const struct dmi_system_id apu2_gpio_dmi_table[] __initconst = {
+ /* PC Engines APU2 with "Legacy" bios < 4.0.8 */
+ {
+ .ident = "apu2",
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "PC Engines"),
+ DMI_MATCH(DMI_BOARD_NAME, "APU2")
+ }
+ },
+ /* PC Engines APU2 with "Legacy" bios >= 4.0.8 */
+ {
+ .ident = "apu2",
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "PC Engines"),
+ DMI_MATCH(DMI_BOARD_NAME, "apu2")
+ }
+ },
+ /* PC Engines APU2 with "Mainline" bios */
+ {
+ .ident = "apu2",
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "PC Engines"),
+ DMI_MATCH(DMI_BOARD_NAME, "PC Engines apu2")
+ }
+ },
+ {}
+};
+MODULE_DEVICE_TABLE(dmi, apu2_gpio_dmi_table);
+
+static const struct dmi_system_id apu3_gpio_dmi_table[] __initconst = {
+ /* PC Engines APU3 with "Legacy" bios < 4.0.8 */
+ {
+ .ident = "apu3",
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "PC Engines"),
+ DMI_MATCH(DMI_BOARD_NAME, "APU3")
+ }
+ },
+ /* PC Engines APU3 with "Legacy" bios >= 4.0.8 */
+ {
+ .ident = "apu3",
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "PC Engines"),
+ DMI_MATCH(DMI_BOARD_NAME, "apu3")
+ }
+ },
+ /* PC Engines APU3 with "Mainline" bios */
+ {
+ .ident = "apu3",
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "PC Engines"),
+ DMI_MATCH(DMI_BOARD_NAME, "PC Engines apu3")
+ }
+ },
+ {}
+};
+MODULE_DEVICE_TABLE(dmi, apu3_gpio_dmi_table);
+
+
+static struct gpio_keys_button apu_gpio_buttons[] = {
+ {
+ .code = KEY_RESTART,
+ .gpio = 20,
+ .active_low = 1,
+ .desc = "Reset button",
+ .type = EV_KEY,
+ .debounce_interval = 60,
+ }
+};
+
+static struct gpio_keys_platform_data apu_buttons_data = {
+ .buttons = apu_gpio_buttons,
+ .nbuttons = ARRAY_SIZE(apu_gpio_buttons),
+ .poll_interval = 20,
+};
+
+static struct platform_device apu_button_dev = {
+ .name = "gpio-keys-polled",
+ .id = 1,
+ .dev = {
+ .platform_data = &apu_buttons_data,
+ }
+};
+
+static int __init apu_init(void)
+{
+ if (!(dmi_check_system(apu2_gpio_dmi_table)) &&
+ !(dmi_check_system(apu3_gpio_dmi_table))) {
+ return -ENODEV;
+ }
+
+ return platform_device_register(&apu_button_dev);
+}
+
+static void __exit apu_exit(void)
+{
+ platform_device_unregister(&apu_button_dev);
+}
+
+module_init(apu_init);
+module_exit(apu_exit);
--
2.11.0
next prev parent reply other threads:[~2018-11-27 13:25 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-27 13:25 [PATCH v5 0/2] Add device driver for APU2/APU3 GPIOs Florian Eckert
2018-11-27 13:25 ` [PATCH v5 1/2] gpio: Add driver for PC Engines APU boards Florian Eckert
2018-11-28 5:19 ` kbuild test robot
2018-11-28 12:00 ` Andy Shevchenko
2018-12-04 10:17 ` Florian Eckert
2018-11-27 13:25 ` Florian Eckert [this message]
2018-11-28 12:05 ` [PATCH v5 2/2] platform: Add reset button device " Andy Shevchenko
2018-11-28 17:06 ` kbuild test robot
2018-11-28 12:07 ` [PATCH v5 0/2] Add device driver for APU2/APU3 GPIOs Andy Shevchenko
2018-11-29 10:15 ` Florian Eckert
2018-11-29 13:44 ` Andy Shevchenko
2018-11-29 14:02 ` Florian Eckert
2018-11-29 15:24 ` Andy Shevchenko
2018-12-03 7:58 ` Florian Eckert
2018-12-03 15:43 ` Andy Shevchenko
2018-12-04 9:58 ` Florian Eckert
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181127132508.5501-3-fe@dev.tdt.de \
--to=fe@dev.tdt.de \
--cc=Eckert.Florian@googlemail.com \
--cc=andy@infradead.org \
--cc=bgolaszewski@baylibre.com \
--cc=dvhart@infradead.org \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=platform-driver-x86@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).