Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp8028962imu; Thu, 15 Nov 2018 05:33:56 -0800 (PST) X-Google-Smtp-Source: AJdET5dqrEHsu6tH+NwuzqKuZ3xA+Xce0AfTKgmULlYq6X8SwBa7gNhUGNR9pMjIRjfrPpF5eZe6 X-Received: by 2002:a62:54c4:: with SMTP id i187-v6mr6511270pfb.155.1542288836656; Thu, 15 Nov 2018 05:33:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542288836; cv=none; d=google.com; s=arc-20160816; b=AXBhUCSVhmCe3B85I/0DHdE0syb9m0kj5Or2X+SxONaYND16ylGh8mCoJwKTS9dz1d ZZF/H1Cg3TildAN77OGRrJzI9CbGvK8Ttt0mSkfm/fyhjmFrnpQAQNoT6N8krZ1b2twt DgzQT94gyzSBy5xnNbOXQ7zr7wGp72wP1kIH4IyThfKoWfAoTonqToWFiploCvpyGp63 XCrq01DIf44II2h7mg+VvYEiqmNV5PUa9PW0geSfgP1+p1Vcc6yoRu9Ml6DZ7FXqXzU/ 9w8YiUtBV99oWLNlSCtFKysUI7zNSxDt3bTIv9fwlqrqpKfG965MpK0gLBxAfz3qhkwk x5dg== 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=HfEpu64v90m7XMqkpEwbfa5dNy9g6tBcJIlIgV+bJ7Tdsy5nhOjdEEItnlODDZMQr1 MkQ3lpxglzWOpH9UYZ+u+ZxY12wImgz9/xzZwVD7/xO6uOw4WDlwV2LyceEX5OBsPyTe FLN4ZU0sLb5Dy67r290+CkJyXbc3iQ1Ri8J2XUksCbKbQE1xGHhE+0z+j9zzt/7etWdA jXwSWxj4blwYv+qdfv2r2UX2W0xAVfVMvC6R8s84TLrN2uSJRxCqVcFTMke9ukalYI9C PPxqe91wnKQq33PTrKgzgNSxLITPh69NdO/FXWHmJxPgSNHWeP9uZSWSdLQySHNx3ujx Nh8g== 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 h5si10579697plk.373.2018.11.15.05.33.41; Thu, 15 Nov 2018 05:33:56 -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 S2388457AbeKOXkS (ORCPT + 99 others); Thu, 15 Nov 2018 18:40:18 -0500 Received: from ms.tdt.de ([195.243.126.94]:34254 "EHLO mail.dev.tdt.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2388290AbeKOXkR (ORCPT ); Thu, 15 Nov 2018 18:40:17 -0500 Received: from feckert01.dev.tdt.de (unknown [10.2.3.40]) by mail.dev.tdt.de (Postfix) with ESMTPSA id BDAE021A66; Thu, 15 Nov 2018 13:32:22 +0000 (UTC) From: Florian Eckert To: linus.walleij@linaro.org, andy.shevchenko@gmail.com, piotr.krol@3mdeb.com, Eckert.Florian@googlemail.com, dvhart@infradead.org Cc: platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, Florian Eckert Subject: [PATCH v4 2/2] platform: Add reset button device for PC Engines APU boards Date: Thu, 15 Nov 2018 14:32:01 +0100 Message-Id: <20181115133201.29092-3-fe@dev.tdt.de> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181115133201.29092-1-fe@dev.tdt.de> References: <20181115133201.29092-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