From patchwork Wed May 31 15:54:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Henning Schild X-Patchwork-Id: 688048 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7815FC7EE31 for ; Wed, 31 May 2023 15:55:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234215AbjEaPzP (ORCPT ); Wed, 31 May 2023 11:55:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233993AbjEaPzO (ORCPT ); Wed, 31 May 2023 11:55:14 -0400 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2040.outbound.protection.outlook.com [40.107.22.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F5669D; Wed, 31 May 2023 08:55:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oe+CSbF3Ut6QRE1KP9zgI05vS6JeJlVD/Fel7sVG/nbzt2++hS8fCRCUyBaLsuwvfiOWXkh5dN7WKXc5RzmRG/QAJWYOqkvYRJ+FS0V+MahUUVGtTc8manfMWN7hKc9gGWm7zeYS3aCPyw+RIoH1xj/ialKyAVhqk8K6u5luaMaoKMPDzvqma9beh9gqfYzE7oNsFXCHuyfsfXUb4uvd8PjpnZ6oFQ6VVdSvxDk6Pv/UbLuMcFfrXwJJQvfkGzcBpporqDNNhpM7wWHQ72EdU15I9fz13XTU1/csPWc0/Br3WeG2qfscB5dtMLMx+uU2tvijAwL07DxSWvBdn7c01w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=sTQ5lQ0dx8t8kIW5j6FAlAY5EvbdBlLUO9pMQ9KQs1k=; b=VSDtuAl5n7gvi4fcbGHNMPKvVyr5C4Ti8YGZ3CS4ZBk8mmBSrLNNDNGgljbKcMid5BlNrlM2J5p8Z4opkI7I4+doiqp/rKrLTQsHJdutNdibTyLVCw/CMxXIQ0dtN56WWXy4P0tlCf6Ozr0bbCSKOztErux2/vnyhi+cLx7zyU0EIvSWorCht3sNYx2ZvCVh75V2C033YwhV0QrmRvKnaHl8r07RFJJLKheCSa3+n3sAcnY06amwog2a9pjsRzAQlZwjE3Oi7bRZA5EpMGUBYu6d/khvoT5OKhUTYFzlkPZiopq4N+gwQbnutA+48GIv1KBWh9uF2ulGTV1pOoSlsw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 194.138.21.76) smtp.rcpttodomain=ucw.cz smtp.mailfrom=siemens.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=siemens.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=siemens.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=sTQ5lQ0dx8t8kIW5j6FAlAY5EvbdBlLUO9pMQ9KQs1k=; b=VML7KefdycWSy3Vf4CIcLtg035uNntYrkBloLVp3zN5Vy5rTTSq3eroDg5Wkpc1JGnJ6acqLAKUHZJ1R0CjOcZxbo/uTvkKt908J9oJTGl+Kc+0N4jA+1DF8B9lxH3UGrNJBZHb0jqhduSYfkElxqJex7m1OdIzSY03Fo0RkTt9DPYSd79MEaKaZL+MnqvnYGUeNfeF1e6BQK13+u12+eDLg26vCpMzMg1uW/ZY2cB8BK3cT9JksHPBoVqBP9pI9RAKosK0csSMMGxRsNaBFl6iup/sORFrKLdZPlQMMCUWssh9INFQE21KMf/6zAwg9vJMfLHBxprXV/sp4q3ykMA== Received: from GV3PEPF000000E2.SWEP280.PROD.OUTLOOK.COM (2603:10a6:144:1:0:2:0:f) by DU0PR10MB6534.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:10:405::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.22; Wed, 31 May 2023 15:55:09 +0000 Received: from HE1EUR01FT036.eop-EUR01.prod.protection.outlook.com (2a01:111:f400:7e1f::201) by GV3PEPF000000E2.outlook.office365.com (2603:1026:900:3::f) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.23 via Frontend Transport; Wed, 31 May 2023 15:55:09 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 194.138.21.76) smtp.mailfrom=siemens.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=siemens.com; Received-SPF: Pass (protection.outlook.com: domain of siemens.com designates 194.138.21.76 as permitted sender) receiver=protection.outlook.com; client-ip=194.138.21.76; helo=hybrid.siemens.com; pr=C Received: from hybrid.siemens.com (194.138.21.76) by HE1EUR01FT036.mail.protection.outlook.com (10.152.1.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.22 via Frontend Transport; Wed, 31 May 2023 15:55:08 +0000 Received: from DEMCHDC8WBA.ad011.siemens.net (139.25.226.105) by DEMCHDC8VSA.ad011.siemens.net (194.138.21.76) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.25; Wed, 31 May 2023 17:55:08 +0200 Received: from md1za8fc.ad001.siemens.net (139.25.0.56) by DEMCHDC8WBA.ad011.siemens.net (139.25.226.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.25; Wed, 31 May 2023 17:55:07 +0200 From: Henning Schild To: Pavel Machek , Lee Jones , Hans de Goede , Mark Gross , Andy Shevchenko , , , CC: Henning Schild Subject: [PATCH 1/1] leds: simatic-ipc-leds-gpio: add new model BX-21A Date: Wed, 31 May 2023 17:54:57 +0200 Message-ID: <20230531155457.31632-2-henning.schild@siemens.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20230531155457.31632-1-henning.schild@siemens.com> References: <20230531155457.31632-1-henning.schild@siemens.com> MIME-Version: 1.0 X-Originating-IP: [139.25.0.56] X-ClientProxiedBy: DEMCHDC8WAA.ad011.siemens.net (139.25.226.104) To DEMCHDC8WBA.ad011.siemens.net (139.25.226.105) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: HE1EUR01FT036:EE_|DU0PR10MB6534:EE_ X-MS-Office365-Filtering-Correlation-Id: b3748bf8-ebad-40f0-b8f6-08db61ef68f1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: aBlyNUanDwZeoEv4zBTVCbdaf9zWJVlXq+EBro5/XmyAeevZznyXLdHvQagyAhAg5vAhy76PD5vtXbSQKvOv00k5l+h1HpAS15D5CI6i9OF7Te8Zbh97QnGod38Fe8TQSxSYu2UABD9DOMWqtEQ6KTQZpSNvlpg2BQPMAMBH66TVApzkx4Aw5+dULUxQyqIjhFGcbmd5RiXIxk1ZSKgFpert0UjukQhQYdEuuNCrmydaeMT+FZ4g+E+9ZKheE3uY48I95XcyR1q5Ji/vuVnpsBc+GRxG8srOUzJ1zvxhDb3ocE+K/S6u8RFyNIkln7RVKeranv7xbeI6Cms5CqCRd2RtM3BM4oju8VLCdjSv1kfeXKt0z0fmShrKO2T775tjLnFcGVb/Rki6dsNOQDhOhI5MFPEe3kh7P131aLUxbcH+lL3J76Aovdt8xghkOBi7JI2HCC0SOS+2gQpZhr7FJPw5WTHwHRd/4ZqisB8u9kffGqNKqtj7snRMvhvbkycnRtOTEDV7nWyArGwNkR0an3hMYq+Qg2xi8kvo1oUT4R0FY3z/wtWQQV3EffKpAa0Z31CKNWDaE5r08c5GESRkpRva/Pm+YLuFi4z2XMSvserrtb7RY1i45oPEoYKZAsqj+Q9bAqFrllOA4C1ofmCsyTW8cE9xxbYHUdM9NlKJhTciSdlDCrXYjHJ4Pru6hP2AU2WP7DhC4jm4+bYhxSWaVeZ8yDrGfzq2dbdjPSeljs0YhUDbRpvALUXte5NwuL6eItaK4gbOoXkgEexMvmlPzw== X-Forefront-Antispam-Report: CIP:194.138.21.76; CTRY:DE; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:hybrid.siemens.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230028)(4636009)(396003)(376002)(39860400002)(346002)(136003)(451199021)(46966006)(40470700004)(36840700001)(86362001)(40460700003)(83380400001)(44832011)(6666004)(8676002)(336012)(8936002)(82740400003)(5660300002)(36860700001)(36756003)(26005)(1076003)(47076005)(82960400001)(107886003)(40480700001)(2906002)(356005)(4326008)(70206006)(70586007)(110136005)(478600001)(16526019)(956004)(2616005)(82310400005)(316002)(186003)(41300700001)(81166007)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: siemens.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 May 2023 15:55:08.7869 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b3748bf8-ebad-40f0-b8f6-08db61ef68f1 X-MS-Exchange-CrossTenant-Id: 38ae3bcd-9579-4fd4-adda-b42e1495d55a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=38ae3bcd-9579-4fd4-adda-b42e1495d55a; Ip=[194.138.21.76]; Helo=[hybrid.siemens.com] X-MS-Exchange-CrossTenant-AuthSource: HE1EUR01FT036.eop-EUR01.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR10MB6534 Precedence: bulk List-ID: X-Mailing-List: linux-leds@vger.kernel.org This adds support for the Siemens Simatic IPC BX-21A. Its LEDs are connected to GPIO pins provided by the Intel Elkhart Lake pinctrl driver. Signed-off-by: Henning Schild --- drivers/leds/simple/Kconfig | 13 +++++ drivers/leds/simple/Makefile | 1 + .../leds/simple/simatic-ipc-leds-gpio-core.c | 4 ++ .../simatic-ipc-leds-gpio-elkhartlake.c | 57 +++++++++++++++++++ drivers/platform/x86/simatic-ipc.c | 3 + .../platform_data/x86/simatic-ipc-base.h | 1 + include/linux/platform_data/x86/simatic-ipc.h | 3 +- 7 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 drivers/leds/simple/simatic-ipc-leds-gpio-elkhartlake.c diff --git a/drivers/leds/simple/Kconfig b/drivers/leds/simple/Kconfig index 44fa0f93cb3b..626ab18ac09d 100644 --- a/drivers/leds/simple/Kconfig +++ b/drivers/leds/simple/Kconfig @@ -34,3 +34,16 @@ config LEDS_SIEMENS_SIMATIC_IPC_F7188X To compile this driver as a module, choose M here: the module will be called simatic-ipc-leds-gpio-f7188x. + +config LEDS_SIEMENS_SIMATIC_IPC_ELKHARTLAKE + tristate "LED driver for Siemens Simatic IPCs based on Intel Elkhart Lake GPIO" + depends on LEDS_GPIO + depends on PINCTRL_ELKHARTLAKE + depends on SIEMENS_SIMATIC_IPC + default LEDS_SIEMENS_SIMATIC_IPC + help + This option enables support for the LEDs of several Industrial PCs + from Siemens based on Elkhart Lake GPIO i.e. BX-21A. + + To compile this driver as a module, choose M here: the module + will be called simatic-ipc-leds-gpio-elkhartlake. diff --git a/drivers/leds/simple/Makefile b/drivers/leds/simple/Makefile index e3e840cea275..783578f11bb0 100644 --- a/drivers/leds/simple/Makefile +++ b/drivers/leds/simple/Makefile @@ -2,3 +2,4 @@ obj-$(CONFIG_LEDS_SIEMENS_SIMATIC_IPC) += simatic-ipc-leds.o obj-$(CONFIG_LEDS_SIEMENS_SIMATIC_IPC_APOLLOLAKE) += simatic-ipc-leds-gpio-core.o simatic-ipc-leds-gpio-apollolake.o obj-$(CONFIG_LEDS_SIEMENS_SIMATIC_IPC_F7188X) += simatic-ipc-leds-gpio-core.o simatic-ipc-leds-gpio-f7188x.o +obj-$(CONFIG_LEDS_SIEMENS_SIMATIC_IPC_ELKHARTLAKE) += simatic-ipc-leds-gpio-core.o simatic-ipc-leds-gpio-elkhartlake.o diff --git a/drivers/leds/simple/simatic-ipc-leds-gpio-core.c b/drivers/leds/simple/simatic-ipc-leds-gpio-core.c index 2a21b663df87..c552ea73ed9d 100644 --- a/drivers/leds/simple/simatic-ipc-leds-gpio-core.c +++ b/drivers/leds/simple/simatic-ipc-leds-gpio-core.c @@ -57,6 +57,7 @@ int simatic_ipc_leds_gpio_probe(struct platform_device *pdev, switch (plat->devmode) { case SIMATIC_IPC_DEVICE_127E: case SIMATIC_IPC_DEVICE_227G: + case SIMATIC_IPC_DEVICE_BX_21A: break; default: return -ENODEV; @@ -72,6 +73,9 @@ int simatic_ipc_leds_gpio_probe(struct platform_device *pdev, goto out; } + if (!table_extra) + return 0; + table_extra->dev_id = dev_name(dev); gpiod_add_lookup_table(table_extra); diff --git a/drivers/leds/simple/simatic-ipc-leds-gpio-elkhartlake.c b/drivers/leds/simple/simatic-ipc-leds-gpio-elkhartlake.c new file mode 100644 index 000000000000..6ba21dbb3ba0 --- /dev/null +++ b/drivers/leds/simple/simatic-ipc-leds-gpio-elkhartlake.c @@ -0,0 +1,57 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Siemens SIMATIC IPC driver for GPIO based LEDs + * + * Copyright (c) Siemens AG, 2023 + * + * Author: + * Henning Schild + */ + +#include +#include +#include +#include +#include +#include + +#include "simatic-ipc-leds-gpio.h" + +static struct gpiod_lookup_table simatic_ipc_led_gpio_table = { + .dev_id = "leds-gpio", + .table = { + GPIO_LOOKUP_IDX("INTC1020:04", 72, NULL, 0, GPIO_ACTIVE_HIGH), + GPIO_LOOKUP_IDX("INTC1020:04", 77, NULL, 1, GPIO_ACTIVE_HIGH), + GPIO_LOOKUP_IDX("INTC1020:04", 78, NULL, 2, GPIO_ACTIVE_HIGH), + GPIO_LOOKUP_IDX("INTC1020:04", 58, NULL, 3, GPIO_ACTIVE_HIGH), + GPIO_LOOKUP_IDX("INTC1020:04", 60, NULL, 4, GPIO_ACTIVE_HIGH), + GPIO_LOOKUP_IDX("INTC1020:04", 62, NULL, 5, GPIO_ACTIVE_HIGH), + {} /* Terminating entry */ + }, +}; + +static int simatic_ipc_leds_gpio_elkhartlake_probe(struct platform_device *pdev) +{ + return simatic_ipc_leds_gpio_probe(pdev, &simatic_ipc_led_gpio_table, + NULL); +} + +static int simatic_ipc_leds_gpio_elkhartlake_remove(struct platform_device *pdev) +{ + return simatic_ipc_leds_gpio_remove(pdev, &simatic_ipc_led_gpio_table, + NULL); +} + +static struct platform_driver simatic_ipc_led_gpio_elkhartlake_driver = { + .probe = simatic_ipc_leds_gpio_elkhartlake_probe, + .remove = simatic_ipc_leds_gpio_elkhartlake_remove, + .driver = { + .name = KBUILD_MODNAME, + }, +}; +module_platform_driver(simatic_ipc_led_gpio_elkhartlake_driver); + +MODULE_LICENSE("GPL v2"); +MODULE_ALIAS("platform:" KBUILD_MODNAME); +MODULE_SOFTDEP("pre: simatic-ipc-leds-gpio-core platform:elkhartlake-pinctrl"); +MODULE_AUTHOR("Henning Schild "); diff --git a/drivers/platform/x86/simatic-ipc.c b/drivers/platform/x86/simatic-ipc.c index c773995b230d..4402cd354104 100644 --- a/drivers/platform/x86/simatic-ipc.c +++ b/drivers/platform/x86/simatic-ipc.c @@ -48,6 +48,7 @@ static struct { {SIMATIC_IPC_IPC477E, SIMATIC_IPC_DEVICE_NONE, SIMATIC_IPC_DEVICE_427E}, {SIMATIC_IPC_IPCBX_39A, SIMATIC_IPC_DEVICE_227G, SIMATIC_IPC_DEVICE_227G}, {SIMATIC_IPC_IPCPX_39A, SIMATIC_IPC_DEVICE_NONE, SIMATIC_IPC_DEVICE_227G}, + {SIMATIC_IPC_IPCBX_21A, SIMATIC_IPC_DEVICE_BX_21A, SIMATIC_IPC_DEVICE_NONE}, }; static int register_platform_devices(u32 station_id) @@ -72,6 +73,8 @@ static int register_platform_devices(u32 station_id) pdevname = KBUILD_MODNAME "_leds_gpio_apollolake"; if (ledmode == SIMATIC_IPC_DEVICE_227G) pdevname = KBUILD_MODNAME "_leds_gpio_f7188x"; + if (ledmode == SIMATIC_IPC_DEVICE_BX_21A) + pdevname = KBUILD_MODNAME "_leds_gpio_elkhartlake"; platform_data.devmode = ledmode; ipc_led_platform_device = platform_device_register_data(NULL, diff --git a/include/linux/platform_data/x86/simatic-ipc-base.h b/include/linux/platform_data/x86/simatic-ipc-base.h index 57d6a10dfc9e..00bf18ecb160 100644 --- a/include/linux/platform_data/x86/simatic-ipc-base.h +++ b/include/linux/platform_data/x86/simatic-ipc-base.h @@ -20,6 +20,7 @@ #define SIMATIC_IPC_DEVICE_127E 3 #define SIMATIC_IPC_DEVICE_227E 4 #define SIMATIC_IPC_DEVICE_227G 5 +#define SIMATIC_IPC_DEVICE_BX_21A 6 struct simatic_ipc_platform { u8 devmode; diff --git a/include/linux/platform_data/x86/simatic-ipc.h b/include/linux/platform_data/x86/simatic-ipc.h index a48bb5240977..1a8e4c1099e3 100644 --- a/include/linux/platform_data/x86/simatic-ipc.h +++ b/include/linux/platform_data/x86/simatic-ipc.h @@ -2,7 +2,7 @@ /* * Siemens SIMATIC IPC drivers * - * Copyright (c) Siemens AG, 2018-2021 + * Copyright (c) Siemens AG, 2018-2023 * * Authors: * Henning Schild @@ -34,6 +34,7 @@ enum simatic_ipc_station_ids { SIMATIC_IPC_IPC227G = 0x00000F01, SIMATIC_IPC_IPCBX_39A = 0x00001001, SIMATIC_IPC_IPCPX_39A = 0x00001002, + SIMATIC_IPC_IPCBX_21A = 0x00001101, }; static inline u32 simatic_ipc_get_station_id(u8 *data, int max_len)