Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp221460imu; Tue, 27 Nov 2018 11:21:43 -0800 (PST) X-Google-Smtp-Source: AFSGD/X3Eb633EWqNBqy00CqKnknyifvXgz4QFIAhvzVaDrHkhIRE9dFxq3WifnbryPlux/KkmDq X-Received: by 2002:a62:8985:: with SMTP id n5mr12085023pfk.255.1543346503641; Tue, 27 Nov 2018 11:21:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543346503; cv=none; d=google.com; s=arc-20160816; b=CU3UYLABylX/ZnIusKz5HfVziJDm8b3wfuzarOdbytUDI35+RaDREDzQUqxFMn20IN WzJpK5MTRVz3J55fZrqSba7jfBOto8aYCP/0v+gN7fR+PmiHYM02AqydYoEKKRMpILKk dMCkdCv0pSMAPh25KCNW3Zbsc3eFvBp2U4Gfy5iLyfmwsu+6CBfrTh2LR9rLCvBxBZFG 8egPPTPINdyz8bie7yxEt4t9rztZWk/x+S7RFxYiL0vePTM0I3xOenip9GA90MCpRJTp Dzfu/0kqprJlcWvge4icxV4mxEhj4irWdDOw+dUfk4FC9VVvWEfJneh6tIfISmAROaFN Jh2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=vWlrYL+oeq5zkt8yjyz/8Ic22+flu+ciKjo4tglc9eA=; b=vMwZaSEUVouPGpItBq2BJwUFkwAnafb0qB5leDJGp1AwbJz709Vh4qexoExLIpLjW3 CzLT2/9HLHh3c7QiiwL9zPPToVtdueqcmkbHAWkDQ+oH8/17+oHEoZfkJ0ajDSIQLvbD K3j2eTOuW+yR0CQdV2f3qJp+medHnG+pL5oIi2yCgcusW0W1x2O6Ks7j/05p4imR/zrZ UNxN/66NFin25oTJx4pHePyPikvX3F6iqnZUAHIoxLvNv/JlD4DLlr7htAgb1jxG185V KbeFe3pvcFu0mQwjOtnVxIn7yAUA/FKy5tfMMgZKAOzH3kTMySJqRMnHd+NYoLw2kXog g/xA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b7si4778383plb.234.2018.11.27.11.21.27; Tue, 27 Nov 2018 11:21:43 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727190AbeK1AXb (ORCPT + 99 others); Tue, 27 Nov 2018 19:23:31 -0500 Received: from ms.tdt.de ([195.243.126.94]:58679 "EHLO mail.dev.tdt.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727148AbeK1AXb (ORCPT ); Tue, 27 Nov 2018 19:23:31 -0500 Received: from feckert01.dev.tdt.de (unknown [10.2.3.40]) by mail.dev.tdt.de (Postfix) with ESMTPSA id A16A621C5B; Tue, 27 Nov 2018 13:25:33 +0000 (UTC) From: Florian Eckert 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 Subject: [PATCH v5 2/2] platform: Add reset button device for PC Engines APU boards Date: Tue, 27 Nov 2018 14:25:08 +0100 Message-Id: <20181127132508.5501-3-fe@dev.tdt.de> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181127132508.5501-1-fe@dev.tdt.de> References: <20181127132508.5501-1-fe@dev.tdt.de> X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.dev.tdt.de Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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 + */ + +#include +#include +#include +#include +#include + +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